-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Yoshinori Sato
authored and
Paul Mundt
committed
Aug 4, 2008
1 parent
54c77e2
commit f65b642
Showing
8 changed files
with
214 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 1af446edfe3239b2b731f3458b3c285c397464cc | ||
refs/heads/master: cce2d453e4940d3fccd42a6917d01027148e11c3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#ifndef __ASM_CPU_SH2A_CACHEFLUSH_H | ||
#define __ASM_CPU_SH2A_CACHEFLUSH_H | ||
|
||
/* | ||
* Cache flushing: | ||
* | ||
* - flush_cache_all() flushes entire cache | ||
* - flush_cache_mm(mm) flushes the specified mm context's cache lines | ||
* - flush_cache_dup mm(mm) handles cache flushing when forking | ||
* - flush_cache_page(mm, vmaddr, pfn) flushes a single page | ||
* - flush_cache_range(vma, start, end) flushes a range of pages | ||
* | ||
* - flush_dcache_page(pg) flushes(wback&invalidates) a page for dcache | ||
* - flush_icache_range(start, end) flushes(invalidates) a range for icache | ||
* - flush_icache_page(vma, pg) flushes(invalidates) a page for icache | ||
* | ||
* Caches are indexed (effectively) by physical address on SH-2, so | ||
* we don't need them. | ||
*/ | ||
#define flush_cache_all() do { } while (0) | ||
#define flush_cache_mm(mm) do { } while (0) | ||
#define flush_cache_dup_mm(mm) do { } while (0) | ||
#define flush_cache_range(vma, start, end) do { } while (0) | ||
#define flush_cache_page(vma, vmaddr, pfn) do { } while (0) | ||
#define flush_dcache_page(page) do { } while (0) | ||
#define flush_dcache_mmap_lock(mapping) do { } while (0) | ||
#define flush_dcache_mmap_unlock(mapping) do { } while (0) | ||
void flush_icache_range(unsigned long start, unsigned long end); | ||
#define flush_icache_page(vma,pg) do { } while (0) | ||
#define flush_icache_user_range(vma,pg,adr,len) do { } while (0) | ||
#define flush_cache_sigtramp(vaddr) do { } while (0) | ||
|
||
#define p3_cache_init() do { } while (0) | ||
#endif /* __ASM_CPU_SH2A_CACHEFLUSH_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* arch/sh/mm/cache-sh2a.c | ||
* | ||
* Copyright (C) 2008 Yoshinori Sato | ||
* | ||
* Released under the terms of the GNU GPL v2.0. | ||
*/ | ||
|
||
#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> | ||
|
||
void __flush_wback_region(void *start, int size) | ||
{ | ||
unsigned long v; | ||
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); | ||
|
||
local_irq_save(flags); | ||
jump_to_uncached(); | ||
|
||
for (v = begin; v < end; v+=L1_CACHE_BYTES) { | ||
unsigned long addr = CACHE_OC_ADDRESS_ARRAY | (v & 0x000007f0); | ||
int way; | ||
for (way = 0; way < 4; way++) { | ||
unsigned long data = ctrl_inl(addr | (way << 11)); | ||
if ((data & CACHE_PHYSADDR_MASK) == (v & CACHE_PHYSADDR_MASK)) { | ||
data &= ~SH_CACHE_UPDATED; | ||
ctrl_outl(data, addr | (way << 11)); | ||
} | ||
} | ||
} | ||
|
||
back_to_cached(); | ||
local_irq_restore(flags); | ||
} | ||
|
||
void __flush_purge_region(void *start, int size) | ||
{ | ||
unsigned long v; | ||
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); | ||
|
||
local_irq_save(flags); | ||
jump_to_uncached(); | ||
|
||
for (v = begin; v < end; v+=L1_CACHE_BYTES) { | ||
ctrl_outl((v & CACHE_PHYSADDR_MASK), | ||
CACHE_OC_ADDRESS_ARRAY | (v & 0x000003f0) | 0x00000008); | ||
} | ||
back_to_cached(); | ||
local_irq_restore(flags); | ||
} | ||
|
||
void __flush_invalidate_region(void *start, int size) | ||
{ | ||
unsigned long v; | ||
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); | ||
local_irq_save(flags); | ||
jump_to_uncached(); | ||
|
||
#ifdef CONFIG_CACHE_WRITEBACK | ||
ctrl_outl(ctrl_inl(CCR) | CCR_OCACHE_INVALIDATE, CCR); | ||
/* I-cache invalidate */ | ||
for (v = begin; v < end; v+=L1_CACHE_BYTES) { | ||
ctrl_outl((v & CACHE_PHYSADDR_MASK), | ||
CACHE_IC_ADDRESS_ARRAY | (v & 0x000003f0) | 0x00000008); | ||
} | ||
#else | ||
for (v = begin; v < end; v+=L1_CACHE_BYTES) { | ||
ctrl_outl((v & CACHE_PHYSADDR_MASK), | ||
CACHE_IC_ADDRESS_ARRAY | (v & 0x000003f0) | 0x00000008); | ||
ctrl_outl((v & CACHE_PHYSADDR_MASK), | ||
CACHE_OC_ADDRESS_ARRAY | (v & 0x000003f0) | 0x00000008); | ||
} | ||
#endif | ||
back_to_cached(); | ||
local_irq_restore(flags); | ||
} | ||
|
||
/* WBack O-Cache and flush I-Cache */ | ||
void flush_icache_range(unsigned long start, unsigned long end) | ||
{ | ||
unsigned long v; | ||
unsigned long flags; | ||
|
||
start = start & ~(L1_CACHE_BYTES-1); | ||
end = (end + L1_CACHE_BYTES-1) & ~(L1_CACHE_BYTES-1); | ||
|
||
local_irq_save(flags); | ||
jump_to_uncached(); | ||
|
||
for (v = start; v < end; v+=L1_CACHE_BYTES) { | ||
unsigned long addr = (v & 0x000007f0); | ||
int way; | ||
/* O-Cache writeback */ | ||
for (way = 0; way < 4; way++) { | ||
unsigned long data = ctrl_inl(CACHE_OC_ADDRESS_ARRAY | addr | (way << 11)); | ||
if ((data & CACHE_PHYSADDR_MASK) == (v & CACHE_PHYSADDR_MASK)) { | ||
data &= ~SH_CACHE_UPDATED; | ||
ctrl_outl(data, CACHE_OC_ADDRESS_ARRAY | addr | (way << 11)); | ||
} | ||
} | ||
/* I-Cache invalidate */ | ||
ctrl_outl(addr, | ||
CACHE_IC_ADDRESS_ARRAY | addr | 0x00000008); | ||
} | ||
|
||
back_to_cached(); | ||
local_irq_restore(flags); | ||
} |