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;
63 /* Invalidate all instruction cache lines assocoiated with this memory area */
64 ENTRY(_blackfin_icache_flush_range)
65 do_flush IFLUSH, , nop
66 ENDPROC(_blackfin_icache_flush_range)
68 /* Flush all cache lines assocoiated with this area of memory. */
69 ENTRY(_blackfin_icache_dcache_flush_range)
70 do_flush FLUSH, IFLUSH
71 ENDPROC(_blackfin_icache_dcache_flush_range)
73 /* Throw away all D-cached data in specified region without any obligation to
74 * write them back. Since the Blackfin ISA does not have an "invalidate"
75 * instruction, we use flush/invalidate. Perhaps as a speed optimization we
76 * could bang on the DTEST MMRs ...
78 ENTRY(_blackfin_dcache_invalidate_range)
80 ENDPROC(_blackfin_dcache_invalidate_range)
82 /* Flush all data cache lines assocoiated with this memory area */
83 ENTRY(_blackfin_dcache_flush_range)
84 do_flush FLUSH, , , .Ldfr
85 ENDPROC(_blackfin_dcache_flush_range)
87 /* Our headers convert the page structure to an address, so just need to flush
88 * its contents like normal. We know the start address is page aligned (which
89 * greater than our cache alignment), as is the end address. So just jump into
90 * the middle of the dcache flush function.
92 ENTRY(_blackfin_dflush_page)
93 P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT);
95 ENDPROC(_blackfin_dflush_page)