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>
16 #include "proc-macros.S"
19 #define CACHE_LINE_SIZE 32
20 #define D_CACHE_LINE_SIZE 32
21 #define BTB_FLUSH_SIZE 8
23 #ifdef CONFIG_ARM_ERRATA_411920
25 * Invalidate the entire I cache (this code is a workaround for the ARM1136
26 * erratum 411920 - Invalidate Instruction Cache operation can fail. This
27 * erratum is present in 1136, 1156 and 1176. It does not affect the MPCore.
33 ENTRY(v6_icache_inval_all)
36 cpsid ifa @ disable interrupts
37 mcr p15, 0, r0, c7, c5, 0 @ invalidate entire I-cache
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 msr cpsr_cx, r1 @ restore interrupts
42 .rept 11 @ ARM Ltd recommends at least
49 * v6_flush_cache_all()
51 * Flush the entire cache.
55 ENTRY(v6_flush_kern_cache_all)
58 mcr p15, 0, r0, c7, c14, 0 @ D cache clean+invalidate
59 #ifndef CONFIG_ARM_ERRATA_411920
60 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
65 mcr p15, 0, r0, c7, c15, 0 @ Cache clean+invalidate
70 * v6_flush_cache_all()
72 * Flush all TLB entries in a particular address space
74 * - mm - mm_struct describing address space
76 ENTRY(v6_flush_user_cache_all)
80 * v6_flush_cache_range(start, end, flags)
82 * Flush a range of TLB entries in the specified address space.
84 * - start - start address (may not be aligned)
85 * - end - end address (exclusive, may not be aligned)
86 * - flags - vm_area_struct flags describing address space
89 * - we have a VIPT cache.
91 ENTRY(v6_flush_user_cache_range)
95 * v6_coherent_kern_range(start,end)
97 * Ensure that the I and D caches are coherent within specified
98 * region. This is typically used when code has been written to
99 * a memory region, and will be executed.
101 * - start - virtual start address of region
102 * - end - virtual end address of region
104 * It is assumed that:
105 * - the Icache does not read data from the write buffer
107 ENTRY(v6_coherent_kern_range)
111 * v6_coherent_user_range(start,end)
113 * Ensure that the I and D caches are coherent within specified
114 * region. This is typically used when code has been written to
115 * a memory region, and will be executed.
117 * - start - virtual start address of region
118 * - end - virtual end address of region
120 * It is assumed that:
121 * - the Icache does not read data from the write buffer
123 ENTRY(v6_coherent_user_range)
126 bic r0, r0, #CACHE_LINE_SIZE - 1
127 1: mcr p15, 0, r0, c7, c10, 1 @ clean D line
128 add r0, r0, #CACHE_LINE_SIZE
134 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
135 #ifndef CONFIG_ARM_ERRATA_411920
136 mcr p15, 0, r0, c7, c5, 0 @ I+BTB cache invalidate
138 b v6_icache_inval_all
141 mcr p15, 0, r0, c7, c5, 6 @ invalidate BTB
146 * v6_flush_kern_dcache_page(kaddr)
148 * Ensure that the data held in the page kaddr is written back
149 * to the page in question.
151 * - kaddr - kernel address (guaranteed to be page aligned)
153 ENTRY(v6_flush_kern_dcache_page)
157 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line
159 mcr p15, 0, r0, c7, c15, 1 @ clean & invalidate unified line
161 add r0, r0, #D_CACHE_LINE_SIZE
166 mcr p15, 0, r0, c7, c10, 4
172 * v6_dma_inv_range(start,end)
174 * Invalidate the data cache within the specified region; we will
175 * be performing a DMA operation in this region and we want to
176 * purge old data in the cache.
178 * - start - virtual start address of region
179 * - end - virtual end address of region
181 ENTRY(v6_dma_inv_range)
182 tst r0, #D_CACHE_LINE_SIZE - 1
183 bic r0, r0, #D_CACHE_LINE_SIZE - 1
185 mcrne p15, 0, r0, c7, c10, 1 @ clean D line
187 mcrne p15, 0, r0, c7, c11, 1 @ clean unified line
189 tst r1, #D_CACHE_LINE_SIZE - 1
190 bic r1, r1, #D_CACHE_LINE_SIZE - 1
192 mcrne p15, 0, r1, c7, c14, 1 @ clean & invalidate D line
194 mcrne p15, 0, r1, c7, c15, 1 @ clean & invalidate unified line
198 mcr p15, 0, r0, c7, c6, 1 @ invalidate D line
200 mcr p15, 0, r0, c7, c7, 1 @ invalidate unified line
202 add r0, r0, #D_CACHE_LINE_SIZE
206 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
210 * v6_dma_clean_range(start,end)
211 * - start - virtual start address of region
212 * - end - virtual end address of region
214 ENTRY(v6_dma_clean_range)
215 bic r0, r0, #D_CACHE_LINE_SIZE - 1
218 mcr p15, 0, r0, c7, c10, 1 @ clean D line
220 mcr p15, 0, r0, c7, c11, 1 @ clean unified line
222 add r0, r0, #D_CACHE_LINE_SIZE
226 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
230 * v6_dma_flush_range(start,end)
231 * - start - virtual start address of region
232 * - end - virtual end address of region
234 ENTRY(v6_dma_flush_range)
235 bic r0, r0, #D_CACHE_LINE_SIZE - 1
238 mcr p15, 0, r0, c7, c14, 1 @ clean & invalidate D line
240 mcr p15, 0, r0, c7, c15, 1 @ clean & invalidate line
242 add r0, r0, #D_CACHE_LINE_SIZE
246 mcr p15, 0, r0, c7, c10, 4 @ drain write buffer
251 .type v6_cache_fns, #object
253 .long v6_flush_kern_cache_all
254 .long v6_flush_user_cache_all
255 .long v6_flush_user_cache_range
256 .long v6_coherent_kern_range
257 .long v6_coherent_user_range
258 .long v6_flush_kern_dcache_page
259 .long v6_dma_inv_range
260 .long v6_dma_clean_range
261 .long v6_dma_flush_range
262 .size v6_cache_fns, . - v6_cache_fns