2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* arch/sh/mm/cache-sh2.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Paul Mundt
|
2008-08-04 15:33:47 +08:00
|
|
|
* Copyright (C) 2008 Yoshinori Sato
|
2005-04-17 06:20:36 +08:00
|
|
|
*
|
|
|
|
* Released under the terms of the GNU GPL v2.0.
|
|
|
|
*/
|
2006-11-05 14:40:13 +08:00
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
|
|
|
|
#include <asm/cache.h>
|
|
|
|
#include <asm/addrspace.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/cacheflush.h>
|
|
|
|
#include <asm/io.h>
|
|
|
|
|
2006-11-05 14:40:13 +08:00
|
|
|
void __flush_wback_region(void *start, int size)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
2006-11-05 14:40:13 +08:00
|
|
|
unsigned long v;
|
|
|
|
unsigned long begin, end;
|
|
|
|
|
|
|
|
begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
|
|
|
|
end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
|
|
|
|
& ~(L1_CACHE_BYTES-1);
|
|
|
|
for (v = begin; v < end; v+=L1_CACHE_BYTES) {
|
2008-08-04 15:33:47 +08:00
|
|
|
unsigned long addr = CACHE_OC_ADDRESS_ARRAY | (v & 0x00000ff0);
|
|
|
|
int way;
|
|
|
|
for (way = 0; way < 4; way++) {
|
|
|
|
unsigned long data = ctrl_inl(addr | (way << 12));
|
|
|
|
if ((data & CACHE_PHYSADDR_MASK) == (v & CACHE_PHYSADDR_MASK)) {
|
|
|
|
data &= ~SH_CACHE_UPDATED;
|
|
|
|
ctrl_outl(data, addr | (way << 12));
|
|
|
|
}
|
|
|
|
}
|
2006-11-05 14:40:13 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void __flush_purge_region(void *start, int size)
|
|
|
|
{
|
|
|
|
unsigned long v;
|
|
|
|
unsigned long begin, end;
|
|
|
|
|
|
|
|
begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
|
|
|
|
end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
|
|
|
|
& ~(L1_CACHE_BYTES-1);
|
2008-08-04 15:33:47 +08:00
|
|
|
|
|
|
|
for (v = begin; v < end; v+=L1_CACHE_BYTES)
|
|
|
|
ctrl_outl((v & CACHE_PHYSADDR_MASK),
|
|
|
|
CACHE_OC_ADDRESS_ARRAY | (v & 0x00000ff0) | 0x00000008);
|
2006-11-05 14:40:13 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void __flush_invalidate_region(void *start, int size)
|
|
|
|
{
|
2008-08-04 15:33:47 +08:00
|
|
|
#ifdef CONFIG_CACHE_WRITEBACK
|
|
|
|
/*
|
|
|
|
* SH-2 does not support individual line invalidation, only a
|
|
|
|
* global invalidate.
|
|
|
|
*/
|
|
|
|
unsigned long ccr;
|
|
|
|
unsigned long flags;
|
|
|
|
local_irq_save(flags);
|
|
|
|
jump_to_uncached();
|
|
|
|
|
|
|
|
ccr = ctrl_inl(CCR);
|
|
|
|
ccr |= CCR_CACHE_INVALIDATE;
|
|
|
|
ctrl_outl(ccr, CCR);
|
|
|
|
|
|
|
|
back_to_cached();
|
|
|
|
local_irq_restore(flags);
|
|
|
|
#else
|
2006-11-05 14:40:13 +08:00
|
|
|
unsigned long v;
|
|
|
|
unsigned long begin, end;
|
|
|
|
|
|
|
|
begin = (unsigned long)start & ~(L1_CACHE_BYTES-1);
|
|
|
|
end = ((unsigned long)start + size + L1_CACHE_BYTES-1)
|
|
|
|
& ~(L1_CACHE_BYTES-1);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2008-08-04 15:33:47 +08:00
|
|
|
for (v = begin; v < end; v+=L1_CACHE_BYTES)
|
|
|
|
ctrl_outl((v & CACHE_PHYSADDR_MASK),
|
|
|
|
CACHE_OC_ADDRESS_ARRAY | (v & 0x00000ff0) | 0x00000008);
|
|
|
|
#endif
|
|
|
|
}
|