2 * Blackfin cache control code
4 * Copyright 2004-2008 Analog Devices Inc.
6 * Enter bugs at http://blackfin.uclinux.org/
8 * Licensed under the GPL-2 or later.
11 #include <linux/linkage.h>
12 #include <asm/blackfin.h>
13 #include <asm/cache.h>
18 /* Since all L1 caches work the same way, we use the same method for flushing
19 * them. Only the actual flush instruction differs. We write this in asm as
20 * GCC can be hard to coax into writing nice hardware loops.
22 * Also, we assume the following register setup:
26 .macro do_flush flushins:req optflushins optnopins label
28 /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */
34 /* count = (end - start) >> L1_CACHE_SHIFT */
36 R2 >>= L1_CACHE_SHIFT;
43 LSETUP (1f, 2f) LC1 = P1;
59 /* Invalidate all instruction cache lines assocoiated with this memory area */
60 ENTRY(_blackfin_icache_flush_range)
61 do_flush IFLUSH, , nop
62 ENDPROC(_blackfin_icache_flush_range)
64 /* Flush all cache lines assocoiated with this area of memory. */
65 ENTRY(_blackfin_icache_dcache_flush_range)
66 do_flush IFLUSH, FLUSH
67 ENDPROC(_blackfin_icache_dcache_flush_range)
69 /* Throw away all D-cached data in specified region without any obligation to
70 * write them back. Since the Blackfin ISA does not have an "invalidate"
71 * instruction, we use flush/invalidate. Perhaps as a speed optimization we
72 * could bang on the DTEST MMRs ...
74 ENTRY(_blackfin_dcache_invalidate_range)
76 ENDPROC(_blackfin_dcache_invalidate_range)
78 /* Flush all data cache lines assocoiated with this memory area */
79 ENTRY(_blackfin_dcache_flush_range)
80 do_flush FLUSH, , , .Ldfr
81 ENDPROC(_blackfin_dcache_flush_range)
83 /* Our headers convert the page structure to an address, so just need to flush
84 * its contents like normal. We know the start address is page aligned (which
85 * greater than our cache alignment), as is the end address. So just jump into
86 * the middle of the dcache flush function.
88 ENTRY(_blackfin_dflush_page)
89 P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT);
91 ENDPROC(_blackfin_dflush_page)