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
30 /* start = (start & -L1_CACHE_BYTES) */
33 /* end = ((end - 1) & -L1_CACHE_BYTES) + L1_CACHE_BYTES; */
38 /* count = (end - start) >> L1_CACHE_SHIFT */
40 R2 >>= L1_CACHE_SHIFT;
47 LSETUP (1f, 2f) LC1 = P1;
67 /* Invalidate all instruction cache lines assocoiated with this memory area */
68 ENTRY(_blackfin_icache_flush_range)
69 do_flush IFLUSH, , nop
70 ENDPROC(_blackfin_icache_flush_range)
72 /* Flush all cache lines assocoiated with this area of memory. */
73 ENTRY(_blackfin_icache_dcache_flush_range)
74 do_flush FLUSH, IFLUSH
75 ENDPROC(_blackfin_icache_dcache_flush_range)
77 /* Throw away all D-cached data in specified region without any obligation to
78 * write them back. Since the Blackfin ISA does not have an "invalidate"
79 * instruction, we use flush/invalidate. Perhaps as a speed optimization we
80 * could bang on the DTEST MMRs ...
82 ENTRY(_blackfin_dcache_invalidate_range)
84 ENDPROC(_blackfin_dcache_invalidate_range)
86 /* Flush all data cache lines assocoiated with this memory area */
87 ENTRY(_blackfin_dcache_flush_range)
88 do_flush FLUSH, , , .Ldfr
89 ENDPROC(_blackfin_dcache_flush_range)
91 /* Our headers convert the page structure to an address, so just need to flush
92 * its contents like normal. We know the start address is page aligned (which
93 * greater than our cache alignment), as is the end address. So just jump into
94 * the middle of the dcache flush function.
96 ENTRY(_blackfin_dflush_page)
97 P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT);
99 ENDPROC(_blackfin_dflush_page)