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>
14 /* 05000443 - IFLUSH cannot be last instruction in hardware loop */
16 # define BROK_FLUSH_INST "IFLUSH"
18 # define BROK_FLUSH_INST "no anomaly! yeah!"
21 /* Since all L1 caches work the same way, we use the same method for flushing
22 * them. Only the actual flush instruction differs. We write this in asm as
23 * GCC can be hard to coax into writing nice hardware loops.
25 * Also, we assume the following register setup:
29 .macro do_flush flushins:req label
33 /* start = (start & -L1_CACHE_BYTES) */
36 /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */
41 /* count = (end - start) >> L1_CACHE_SHIFT */
43 R2 >>= L1_CACHE_SHIFT;
51 LSETUP (1f, 2f) LC1 = P1;
53 .ifeqs "\flushins", BROK_FLUSH_INST
65 #ifdef CONFIG_ICACHE_FLUSH_L1
71 /* Invalidate all instruction cache lines assocoiated with this memory area */
73 # define _blackfin_icache_flush_range _blackfin_icache_flush_range_l1
75 ENTRY(_blackfin_icache_flush_range)
77 ENDPROC(_blackfin_icache_flush_range)
81 # undef _blackfin_icache_flush_range
82 ENTRY(_blackfin_icache_flush_range)
88 p0.L = _blackfin_iflush_l1_entry;
89 p0.H = _blackfin_iflush_l1_entry;
93 ENDPROC(_blackfin_icache_flush_range)
96 #ifdef CONFIG_DCACHE_FLUSH_L1
102 /* Throw away all D-cached data in specified region without any obligation to
103 * write them back. Since the Blackfin ISA does not have an "invalidate"
104 * instruction, we use flush/invalidate. Perhaps as a speed optimization we
105 * could bang on the DTEST MMRs ...
107 ENTRY(_blackfin_dcache_invalidate_range)
109 ENDPROC(_blackfin_dcache_invalidate_range)
111 /* Flush all data cache lines assocoiated with this memory area */
112 ENTRY(_blackfin_dcache_flush_range)
113 do_flush FLUSH, .Ldfr
114 ENDPROC(_blackfin_dcache_flush_range)
116 /* Our headers convert the page structure to an address, so just need to flush
117 * its contents like normal. We know the start address is page aligned (which
118 * greater than our cache alignment), as is the end address. So just jump into
119 * the middle of the dcache flush function.
121 ENTRY(_blackfin_dflush_page)
122 P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT);
124 ENDPROC(_blackfin_dflush_page)