2 * File: arch/blackfin/mach-common/cache.S
4 * Author: LG Soft India
7 * Description: cache control support
10 * Copyright 2004-2006 Analog Devices Inc.
12 * Bugs: Enter bugs at http://blackfin.uclinux.org/
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2 of the License, or
17 * (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, see the file COPYING, or write
26 * to the Free Software Foundation, Inc.,
27 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 #include <linux/linkage.h>
32 #include <asm/entry.h>
33 #include <asm/blackfin.h>
34 #include <asm/cache.h>
38 ENTRY(_cache_invalidate)
41 * Icache or DcacheA or DcacheB Invalidation
42 * or any combination thereof
44 * CPLB_ENABLE_ICACHE_P,CPLB_ENABLE_DCACHE_P,CPLB_ENABLE_DCACHE2_P
50 CC = BITTST(R7,CPLB_ENABLE_ICACHE_P);
51 IF !CC JUMP .Lno_icache;
53 CALL _icache_invalidate;
56 CC = BITTST(R7,CPLB_ENABLE_DCACHE_P);
57 IF !CC JUMP .Lno_dcache_a;
58 R0 = 0; /* specifies bank A */
60 CALL _dcache_invalidate;
63 CC = BITTST(R7,CPLB_ENABLE_DCACHE2_P);
64 IF !CC JUMP .Lno_dcache_b;
66 BITSET(R0, 23); /* specifies bank B */
68 CALL _dcache_invalidate;
73 ENDPROC(_cache_invalidate)
75 /* Invalidate the Entire Instruction cache by
78 ENTRY(_icache_invalidate)
79 ENTRY(_invalidate_entire_icache)
82 P0.L = LO(IMEM_CONTROL);
83 P0.H = HI(IMEM_CONTROL);
86 /* Clear the IMC bit , All valid bits in the instruction
87 * cache are set to the invalid state
91 SSYNC; /* SSYNC required before invalidating cache. */
97 /* Configures the instruction cache agian */
102 SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
110 ENDPROC(_invalidate_entire_icache)
111 ENDPROC(_icache_invalidate)
114 * blackfin_cache_flush_range(start, end)
115 * Invalidate all cache lines assocoiated with this
118 * start: Start address
121 ENTRY(_blackfin_icache_flush_range)
122 R2 = -L1_CACHE_BYTES;
135 ENDPROC(_blackfin_icache_flush_range)
138 * blackfin_icache_dcache_flush_range(start, end)
139 * FLUSH all cache lines assocoiated with this
142 * start: Start address
146 ENTRY(_blackfin_icache_dcache_flush_range)
147 R2 = -L1_CACHE_BYTES;
162 ENDPROC(_blackfin_icache_dcache_flush_range)
164 /* Throw away all D-cached data in specified region without any obligation to
165 * write them back. However, we must clean the D-cached entries around the
166 * boundaries of the start and/or end address is not cache aligned.
168 * Start: start address,
172 ENTRY(_blackfin_dcache_invalidate_range)
173 R2 = -L1_CACHE_BYTES;
184 /* If the data crosses a cache line, then we'll be pointing to
185 * the last cache line, but won't have flushed/invalidated it yet,
191 ENDPROC(_blackfin_dcache_invalidate_range)
193 /* Invalidate the Entire Data cache by
194 * clearing DMC[1:0] bits
196 ENTRY(_invalidate_entire_dcache)
197 ENTRY(_dcache_invalidate)
200 P0.L = LO(DMEM_CONTROL);
201 P0.H = HI(DMEM_CONTROL);
204 /* Clear the DMC[1:0] bits, All valid bits in the data
205 * cache are set to the invalid state
210 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
216 /* Configures the data cache again */
222 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
230 ENDPROC(_dcache_invalidate)
231 ENDPROC(_invalidate_entire_dcache)
233 ENTRY(_blackfin_dcache_flush_range)
234 R2 = -L1_CACHE_BYTES;
245 /* If the data crosses a cache line, then we'll be pointing to
246 * the last cache line, but won't have flushed it yet, so do
252 ENDPROC(_blackfin_dcache_flush_range)
254 ENTRY(_blackfin_dflush_page)
255 P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT);
259 LSETUP (.Lfl1, .Lfl1) LC0 = P1;
263 ENDPROC(_blackfin_dflush_page)