/*
 * BCM7020 cache flush routines
 *
 * Copyright (C) 2001 TiVo Inc. All Rights Reserved.
 */

#include <linux/kernel.h>
#include <asm/system.h>
#include <asm/bcache.h>
#include <asm/bcm7020.h>

static void bcm_bc_noop(void) {}

// The "cache" here is the posted write buffer in the BCM7020 chip.  There's
// no way to force a flush, that will happen automatically, so just poll for
// FIFO empty
//
static void bcm_bc_wback_inv(unsigned long page, unsigned long size)
{
    unsigned long flags;
    int timeout = 0;

    save_and_cli(flags);

    while (!(*BCM_CPU_CTRL & 0x0040)) {
        if (timeout++ > 0x100000) {
            panic("post write FIFO timeout");
        }
    }

    restore_flags(flags);
}

struct bcache_ops bcm_bcops = {
    bc_enable:      (void *)bcm_bc_noop,
    bc_disable:     (void *)bcm_bc_noop,
    bc_wback_inv:   bcm_bc_wback_inv,
    bc_inv:         (void *)bcm_bc_noop,
};

