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;
74 /* Invalidate the Entire Instruction cache by
77 ENTRY(_icache_invalidate)
78 ENTRY(_invalidate_entire_icache)
81 P0.L = (IMEM_CONTROL & 0xFFFF);
82 P0.H = (IMEM_CONTROL >> 16);
85 /* Clear the IMC bit , All valid bits in the instruction
86 * cache are set to the invalid state
90 SSYNC; /* SSYNC required before invalidating cache. */
96 /* Configures the instruction cache agian */
101 SSYNC; /* SSYNC required before writing to IMEM_CONTROL. */
111 * blackfin_cache_flush_range(start, end)
112 * Invalidate all cache lines assocoiated with this
115 * start: Start address
118 ENTRY(_blackfin_icache_flush_range)
119 R2 = -L1_CACHE_BYTES;
134 * blackfin_icache_dcache_flush_range(start, end)
135 * FLUSH all cache lines assocoiated with this
138 * start: Start address
142 ENTRY(_blackfin_icache_dcache_flush_range)
143 R2 = -L1_CACHE_BYTES;
159 /* Throw away all D-cached data in specified region without any obligation to
160 * write them back. However, we must clean the D-cached entries around the
161 * boundaries of the start and/or end address is not cache aligned.
163 * Start: start address,
167 ENTRY(_blackfin_dcache_invalidate_range)
168 R2 = -L1_CACHE_BYTES;
179 /* If the data crosses a cache line, then we'll be pointing to
180 * the last cache line, but won't have flushed/invalidated it yet,
187 /* Invalidate the Entire Data cache by
188 * clearing DMC[1:0] bits
190 ENTRY(_invalidate_entire_dcache)
191 ENTRY(_dcache_invalidate)
194 P0.L = (DMEM_CONTROL & 0xFFFF);
195 P0.H = (DMEM_CONTROL >> 16);
198 /* Clear the DMC[1:0] bits, All valid bits in the data
199 * cache are set to the invalid state
204 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
210 /* Configures the data cache again */
216 SSYNC; /* SSYNC required before writing to DMEM_CONTROL. */
225 ENTRY(_blackfin_dcache_flush_range)
226 R2 = -L1_CACHE_BYTES;
237 /* If the data crosses a cache line, then we'll be pointing to
238 * the last cache line, but won't have flushed it yet, so do
245 ENTRY(_blackfin_dflush_page)
246 P1 = 1 << (PAGE_SHIFT - L1_CACHE_SHIFT);
250 LSETUP (.Lfl1, .Lfl1) LC0 = P1;