diff options
author | Antony Pavlov <antonynpavlov@gmail.com> | 2016-03-07 16:30:16 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2016-03-09 19:58:50 +0100 |
commit | e3fbe5e85d24a63f8c46d486b60ebb15cfcad541 (patch) | |
tree | a3fd0a4f40e0aafa6138cda5aeb3d489467b3c28 | |
parent | 6d352cacb8dca98a9afefc42d4e0fec7e8aa2509 (diff) | |
download | barebox-e3fbe5e85d24a63f8c46d486b60ebb15cfcad541.tar.gz barebox-e3fbe5e85d24a63f8c46d486b60ebb15cfcad541.tar.xz |
MIPS: add initial R4000-style cache support
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | arch/mips/include/asm/cacheops.h | 7 | ||||
-rw-r--r-- | arch/mips/include/asm/io.h | 3 | ||||
-rw-r--r-- | arch/mips/lib/c-r4k.c | 47 |
3 files changed, 57 insertions, 0 deletions
diff --git a/arch/mips/include/asm/cacheops.h b/arch/mips/include/asm/cacheops.h index 5bd44d5fd4..3bc585259f 100644 --- a/arch/mips/include/asm/cacheops.h +++ b/arch/mips/include/asm/cacheops.h @@ -18,12 +18,19 @@ #define Cache_I 0x00 #define Cache_D 0x01 +#define Index_Writeback_Inv 0x00 #define Index_Store_Tag 0x08 +#define Hit_Invalidate 0x10 +#define Hit_Writeback_Inv 0x14 /* not with Cache_I though */ /* * Cache Operations available on all MIPS processors with R4000-style caches */ +#define Index_Invalidate_I (Cache_I | Index_Writeback_Inv) +#define Index_Writeback_Inv_D (Cache_D | Index_Writeback_Inv) #define Index_Store_Tag_I (Cache_I | Index_Store_Tag) #define Index_Store_Tag_D (Cache_D | Index_Store_Tag) +#define Hit_Invalidate_D (Cache_D | Hit_Invalidate) +#define Hit_Writeback_Inv_D (Cache_D | Hit_Writeback_Inv) #endif /* __ASM_CACHEOPS_H */ diff --git a/arch/mips/include/asm/io.h b/arch/mips/include/asm/io.h index 4832be6d09..4bee5913a5 100644 --- a/arch/mips/include/asm/io.h +++ b/arch/mips/include/asm/io.h @@ -14,6 +14,9 @@ #include <asm/types.h> #include <asm/byteorder.h> +void dma_flush_range(unsigned long, unsigned long); +void dma_inv_range(unsigned long, unsigned long); + #define IO_SPACE_LIMIT 0 /*****************************************************************************/ diff --git a/arch/mips/lib/c-r4k.c b/arch/mips/lib/c-r4k.c index ff686770e1..ba77d18e7c 100644 --- a/arch/mips/lib/c-r4k.c +++ b/arch/mips/lib/c-r4k.c @@ -10,10 +10,57 @@ #include <common.h> #include <asm/io.h> #include <asm/mipsregs.h> +#include <asm/cacheops.h> #include <asm/cpu.h> #include <asm/cpu-info.h> #include <asm/bitops.h> +#define cache_op(op,addr) \ + __asm__ __volatile__( \ + " .set push \n" \ + " .set noreorder \n" \ + " .set mips3\n\t \n" \ + " cache %0, %1 \n" \ + " .set pop \n" \ + : \ + : "i" (op), "R" (*(unsigned char *)(addr))) + +#define __BUILD_BLAST_CACHE_RANGE(pfx, desc, hitop) \ +static inline void blast_##pfx##cache##_range(unsigned long start, \ + unsigned long end) \ +{ \ + unsigned long lsize = current_cpu_data.desc.linesz; \ + unsigned long addr = start & ~(lsize - 1); \ + unsigned long aend = (end - 1) & ~(lsize - 1); \ + \ + if (current_cpu_data.desc.flags & MIPS_CACHE_NOT_PRESENT) \ + return; \ + \ + while (1) { \ + cache_op(hitop, addr); \ + if (addr == aend) \ + break; \ + addr += lsize; \ + } \ +} + +__BUILD_BLAST_CACHE_RANGE(d, dcache, Hit_Writeback_Inv_D) +__BUILD_BLAST_CACHE_RANGE(inv_d, dcache, Hit_Invalidate_D) + +void dma_flush_range(unsigned long start, unsigned long end) +{ + blast_dcache_range(start, end); + + /* secondatory cache skipped */ +} + +void dma_inv_range(unsigned long start, unsigned long end) +{ + blast_inv_dcache_range(start, end); + + /* secondatory cache skipped */ +} + void r4k_cache_init(void); static void probe_pcache(void) |