2019-05-29 01:10:14 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* arch/sh/mm/cache-sh3.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 1999, 2000 Niibe Yutaka
|
|
|
|
* Copyright (C) 2002 Paul Mundt
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/mman.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/threads.h>
|
|
|
|
#include <asm/addrspace.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/pgtable.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/cache.h>
|
|
|
|
#include <asm/io.h>
|
2016-12-25 03:46:01 +08:00
|
|
|
#include <linux/uaccess.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/pgalloc.h>
|
|
|
|
#include <asm/mmu_context.h>
|
|
|
|
#include <asm/cacheflush.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write back the dirty D-caches, but not invalidate them.
|
|
|
|
*
|
|
|
|
* Is this really worth it, or should we just alias this routine
|
|
|
|
* to __flush_purge_region too?
|
|
|
|
*
|
|
|
|
* START: Virtual Address (U0, P1, or P3)
|
|
|
|
* SIZE: Size of the region.
|
|
|
|
*/
|
|
|
|
|
2009-08-15 11:42:55 +08:00
|
|
|
static void sh3__flush_wback_region(void *start, int size)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned long v, j;
|
|
|
|
unsigned long begin, end;
|
|
|
|
unsigned long flags;
|
|
|
|
|
|
|
|
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) {
|
|
|
|
unsigned long addrstart = CACHE_OC_ADDRESS_ARRAY;
|
2006-12-25 09:19:56 +08:00
|
|
|
for (j = 0; j < current_cpu_data.dcache.ways; j++) {
|
2005-04-17 06:20:36 +08:00
|
|
|
unsigned long data, addr, p;
|
|
|
|
|
|
|
|
p = __pa(v);
|
2006-12-25 09:19:56 +08:00
|
|
|
addr = addrstart | (v & current_cpu_data.dcache.entry_mask);
|
2005-04-17 06:20:36 +08:00
|
|
|
local_irq_save(flags);
|
2010-01-26 11:58:40 +08:00
|
|
|
data = __raw_readl(addr);
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
if ((data & CACHE_PHYSADDR_MASK) ==
|
|
|
|
(p & CACHE_PHYSADDR_MASK)) {
|
|
|
|
data &= ~SH_CACHE_UPDATED;
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writel(data, addr);
|
2005-04-17 06:20:36 +08:00
|
|
|
local_irq_restore(flags);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
local_irq_restore(flags);
|
2006-12-25 09:19:56 +08:00
|
|
|
addrstart += current_cpu_data.dcache.way_incr;
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write back the dirty D-caches and invalidate them.
|
|
|
|
*
|
|
|
|
* START: Virtual Address (U0, P1, or P3)
|
|
|
|
* SIZE: Size of the region.
|
|
|
|
*/
|
2009-08-15 11:42:55 +08:00
|
|
|
static void sh3__flush_purge_region(void *start, int size)
|
2005-04-17 06:20:36 +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) {
|
|
|
|
unsigned long data, addr;
|
|
|
|
|
|
|
|
data = (v & 0xfffffc00); /* _Virtual_ address, ~U, ~V */
|
|
|
|
addr = CACHE_OC_ADDRESS_ARRAY |
|
2006-12-25 09:19:56 +08:00
|
|
|
(v & current_cpu_data.dcache.entry_mask) | SH_CACHE_ASSOC;
|
2010-01-26 11:58:40 +08:00
|
|
|
__raw_writel(data, addr);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-08-15 11:42:55 +08:00
|
|
|
void __init sh3_cache_init(void)
|
|
|
|
{
|
|
|
|
__flush_wback_region = sh3__flush_wback_region;
|
|
|
|
__flush_purge_region = sh3__flush_purge_region;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* No write back please
|
|
|
|
*
|
|
|
|
* Except I don't think there's any way to avoid the writeback.
|
|
|
|
* So we just alias it to sh3__flush_purge_region(). dwmw2.
|
|
|
|
*/
|
|
|
|
__flush_invalidate_region = sh3__flush_purge_region;
|
|
|
|
}
|