2 * Blackfin cache control code
4 * Copyright 2004-2008 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
9 #include <linux/linkage.h>
10 #include <asm/blackfin.h>
11 #include <asm/cache.h>
16 /* 05000443 - IFLUSH cannot be last instruction in hardware loop */
18 # define BROK_FLUSH_INST "IFLUSH"
20 # define BROK_FLUSH_INST "no anomaly! yeah!"
23 /* Since all L1 caches work the same way, we use the same method for flushing
24 * them. Only the actual flush instruction differs. We write this in asm as
25 * GCC can be hard to coax into writing nice hardware loops.
27 * Also, we assume the following register setup:
31 .macro do_flush flushins:req label
35 /* start = (start & -L1_CACHE_BYTES) */
38 /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */
43 /* count = (end - start) >> L1_CACHE_SHIFT */
45 R2 >>= L1_CACHE_SHIFT;
53 LSETUP (1f, 2f) LC1 = P1;
55 .ifeqs "\flushins", BROK_FLUSH_INST
65 /* Invalidate all instruction cache lines assocoiated with this memory area */
66 ENTRY(_blackfin_icache_flush_range)
68 * Walkaround to avoid loading wrong instruction after invalidating icache
69 * and following sequence is met.
71 * 1) One instruction address is cached in the instruction cache.
72 * 2) This instruction in SDRAM is changed.
73 * 3) IFLASH[P0] is executed only once in blackfin_icache_flush_range().
74 * 4) This instruction is executed again, but the old one is loaded.
79 ENDPROC(_blackfin_icache_flush_range)
81 /* Throw away all D-cached data in specified region without any obligation to
82 * write them back. Since the Blackfin ISA does not have an "invalidate"
83 * instruction, we use flush/invalidate. Perhaps as a speed optimization we
84 * could bang on the DTEST MMRs ...
86 ENTRY(_blackfin_dcache_invalidate_range)
88 ENDPROC(_blackfin_dcache_invalidate_range)
90 /* Flush all data cache lines assocoiated with this memory area */
91 ENTRY(_blackfin_dcache_flush_range)
93 ENDPROC(_blackfin_dcache_flush_range)
95 /* Our headers convert the page structure to an address, so just need to flush
96 * its contents like normal. We know the start address is page aligned (which
97 * greater than our cache alignment), as is the end address. So just jump into
98 * the middle of the dcache flush function.
100 ENTRY(_blackfin_dflush_page)
101 P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT);
103 ENDPROC(_blackfin_dflush_page)