2 * linux/arch/arm/mm/cache-v6.S
4 * Copyright (C) 2001 Deep Blue Solutions Ltd.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 * This is the "shell" of the ARMv6 processor support.
12 #include <linux/linkage.h>
13 #include <linux/init.h>
14 #include <asm/assembler.h>
15 #include <asm/unwind.h>
17 #include "proc-macros.S"
20 #define CACHE_LINE_SIZE 32
21 #define D_CACHE_LINE_SIZE 32
22 #define BTB_FLUSH_SIZE 8
24 #ifdef CONFIG_ARM_ERRATA_411920
26 * Invalidate the entire I cache (this code is a workaround for the ARM1136
27 * erratum 411920 - Invalidate Instruction Cache operation can fail. This
28 * erratum is present in 1136, 1156 and 1176. It does not affect the MPCore.
34 ENTRY(v6_icache_inval_all)
37 cpsid ifa @ disable interrupts
38 mcr p15, 0, r0, c7, c5, 0 @ invalidate entire I-cache
39 mcr p15, 0, r0, c7, c5, 0 @ invalidate entire I-cache
40 mcr p15, 0, r0, c7, c5, 0 @ invalidate entire I-cache
41 mcr p15, 0, r0, c7, c5, 0 @ invalidate entire I-cache
42 msr cpsr_cx, r1 @ restore interrupts
43 .rept 11 @ ARM Ltd recommends at least
50 * v6_flush_cache_all()
52 * Flush the entire cache.
56 ENTRY(v6_flush_kern_cache_all)
59 mcr p15, 0, r0, c7, c14, 0 @ D cache clean+invalidate
60 #ifndef CONFIG_ARM_ERRATA_411920
61 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
66 mcr p15, 0, r0, c7, c15, 0 @ Cache clean+invalidate
71 * v6_flush_cache_all()
73 * Flush all TLB entries in a particular address space
75 * - mm - mm_struct describing address space
77 ENTRY(v6_flush_user_cache_all)
81 * v6_flush_cache_range(start, end, flags)
83 * Flush a range of TLB entries in the specified address space.
85 * - start - start address (may not be aligned)
86 * - end - end address (exclusive, may not be aligned)
87 * - flags - vm_area_struct flags describing address space
90 * - we have a VIPT cache.
92 ENTRY(v6_flush_user_cache_range)
96 * v6_coherent_kern_range(start,end)
98 * Ensure that the I and D caches are coherent within specified
99 * region. This is typically used when code has been written to
100 * a memory region, and will be executed.
102 * - start - virtual start address of region
103 * - end - virtual end address of region
105 * It is assumed that:
106 * - the Icache does not read data from the write buffer
108 ENTRY(v6_coherent_kern_range)
112 * v6_coherent_user_range(start,end)
114 * Ensure that the I and D caches are coherent within specified
115 * region. This is typically used when code has been written to
116 * a memory region, and will be executed.
118 * - start - virtual start address of region
119 * - end - virtual end address of region
121 * It is assumed that:
122 * - the Icache does not read data from the write buffer
124 ENTRY(v6_coherent_user_range)
127 bic r0, r0, #CACHE_LINE_SIZE - 1
129 USER( mcr p15, 0, r0, c7, c10, 1 ) @ clean D line
130 add r0, r0, #CACHE_LINE_SIZE
137 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
138 #ifndef CONFIG_ARM_ERRATA_411920
139 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
141 b v6_icache_inval_all
144 mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB
149 * Fault handling for the cache operation above. If the virtual address in r0
150 * isn't mapped, just try the next page.
158 ENDPROC(v6_coherent_user_range)
159 ENDPROC(v6_coherent_kern_range)
162 * v6_flush_kern_dcache_area(void *addr, size_t size)
164 * Ensure that the data held in the page kaddr is written back
165 * to the page in question.
167 * - addr - kernel address
168 * - size - region size
170 ENTRY(v6_flush_kern_dcache_area)
174 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line
176 mcr p15, 0, r0, c7, c15, 1 @ clean & invalidate unified line
178 add r0, r0, #D_CACHE_LINE_SIZE
183 mcr p15, 0, r0, c7, c10, 4
189 * v6_dma_inv_range(start,end)
191 * Invalidate the data cache within the specified region; we will
192 * be performing a DMA operation in this region and we want to
193 * purge old data in the cache.
195 * - start - virtual start address of region
196 * - end - virtual end address of region
198 ENTRY(v6_dma_inv_range)
199 tst r0, #D_CACHE_LINE_SIZE - 1
200 bic r0, r0, #D_CACHE_LINE_SIZE - 1
202 mcrne p15, 0, r0, c7, c10, 1 @ clean D line
204 mcrne p15, 0, r0, c7, c11, 1 @ clean unified line
206 tst r1, #D_CACHE_LINE_SIZE - 1
207 bic r1, r1, #D_CACHE_LINE_SIZE - 1
209 mcrne p15, 0, r1, c7, c14, 1 @ clean & invalidate D line
211 mcrne p15, 0, r1, c7, c15, 1 @ clean & invalidate unified line
215 mcr p15, 0, r0, c7, c6, 1 @ invalidate D line
217 mcr p15, 0, r0, c7, c7, 1 @ invalidate unified line
219 add r0, r0, #D_CACHE_LINE_SIZE
223 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
227 * v6_dma_clean_range(start,end)
228 * - start - virtual start address of region
229 * - end - virtual end address of region
231 ENTRY(v6_dma_clean_range)
232 bic r0, r0, #D_CACHE_LINE_SIZE - 1
235 mcr p15, 0, r0, c7, c10, 1 @ clean D line
237 mcr p15, 0, r0, c7, c11, 1 @ clean unified line
239 add r0, r0, #D_CACHE_LINE_SIZE
243 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
247 * v6_dma_flush_range(start,end)
248 * - start - virtual start address of region
249 * - end - virtual end address of region
251 ENTRY(v6_dma_flush_range)
252 bic r0, r0, #D_CACHE_LINE_SIZE - 1
255 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line
257 mcr p15, 0, r0, c7, c15, 1 @ clean & invalidate line
259 add r0, r0, #D_CACHE_LINE_SIZE
263 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
268 .type v6_cache_fns, #object
270 .long v6_flush_kern_cache_all
271 .long v6_flush_user_cache_all
272 .long v6_flush_user_cache_range
273 .long v6_coherent_kern_range
274 .long v6_coherent_user_range
275 .long v6_flush_kern_dcache_area
276 .long v6_dma_inv_range
277 .long v6_dma_clean_range
278 .long v6_dma_flush_range
279 .size v6_cache_fns, . - v6_cache_fns