1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/arm/mm/cache-v4wt.S
5 * Copyright (C) 1997-2002 Russell king
7 * ARMv4 write through cache operations support.
9 * We assume that the write buffer is not enabled.
11 #include <linux/linkage.h>
12 #include <linux/init.h>
13 #include <asm/assembler.h>
15 #include "proc-macros.S"
18 * The size of one data cache line.
20 #define CACHE_DLINESIZE 32
23 * The number of data cache segments.
25 #define CACHE_DSEGMENTS 8
28 * The number of lines in a cache segment.
30 #define CACHE_DENTRIES 64
33 * This is the size at which it becomes more efficient to
34 * clean the whole cache, rather than using the individual
35 * cache line maintenance instructions.
37 * *** This needs benchmarking
39 #define CACHE_DLIMIT 16384
44 * Unconditionally clean and invalidate the entire icache.
46 ENTRY(v4wt_flush_icache_all)
48 mcr p15, 0, r0, c7, c5, 0 @ invalidate I cache
50 ENDPROC(v4wt_flush_icache_all)
53 * flush_user_cache_all()
55 * Invalidate all cache entries in a particular address
58 ENTRY(v4wt_flush_user_cache_all)
61 * flush_kern_cache_all()
63 * Clean and invalidate the entire cache.
65 ENTRY(v4wt_flush_kern_cache_all)
70 mcrne p15, 0, ip, c7, c5, 0 @ invalidate I cache
71 mcr p15, 0, ip, c7, c6, 0 @ invalidate D cache
75 * flush_user_cache_range(start, end, flags)
77 * Clean and invalidate a range of cache entries in the specified
80 * - start - start address (inclusive, page aligned)
81 * - end - end address (exclusive, page aligned)
82 * - flags - vma_area_struct flags describing address space
84 ENTRY(v4wt_flush_user_cache_range)
85 sub r3, r1, r0 @ calculate total size
87 bhs __flush_whole_cache
89 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
91 mcrne p15, 0, r0, c7, c5, 1 @ invalidate I entry
92 add r0, r0, #CACHE_DLINESIZE
98 * coherent_kern_range(start, end)
100 * Ensure coherency between the Icache and the Dcache in the
101 * region described by start. If you have non-snooping
102 * Harvard caches, you need to implement this function.
104 * - start - virtual start address
105 * - end - virtual end address
107 ENTRY(v4wt_coherent_kern_range)
111 * coherent_user_range(start, end)
113 * Ensure coherency between the Icache and the Dcache in the
114 * region described by start. If you have non-snooping
115 * Harvard caches, you need to implement this function.
117 * - start - virtual start address
118 * - end - virtual end address
120 ENTRY(v4wt_coherent_user_range)
121 bic r0, r0, #CACHE_DLINESIZE - 1
122 1: mcr p15, 0, r0, c7, c5, 1 @ invalidate I entry
123 add r0, r0, #CACHE_DLINESIZE
130 * flush_kern_dcache_area(void *addr, size_t size)
132 * Ensure no D cache aliasing occurs, either with itself or
135 * - addr - kernel address
136 * - size - region size
138 ENTRY(v4wt_flush_kern_dcache_area)
140 mcr p15, 0, r2, c7, c5, 0 @ invalidate I cache
145 * dma_inv_range(start, end)
147 * Invalidate (discard) the specified virtual address range.
148 * May not write back any entries. If 'start' or 'end'
149 * are not cache line aligned, those lines must be written
152 * - start - virtual start address
153 * - end - virtual end address
156 bic r0, r0, #CACHE_DLINESIZE - 1
157 1: mcr p15, 0, r0, c7, c6, 1 @ invalidate D entry
158 add r0, r0, #CACHE_DLINESIZE
164 * dma_flush_range(start, end)
166 * Clean and invalidate the specified virtual address range.
168 * - start - virtual start address
169 * - end - virtual end address
171 .globl v4wt_dma_flush_range
172 .equ v4wt_dma_flush_range, v4wt_dma_inv_range
175 * dma_unmap_area(start, size, dir)
176 * - start - kernel virtual start address
177 * - size - size of region
178 * - dir - DMA direction
180 ENTRY(v4wt_dma_unmap_area)
182 teq r2, #DMA_TO_DEVICE
183 bne v4wt_dma_inv_range
187 * dma_map_area(start, size, dir)
188 * - start - kernel virtual start address
189 * - size - size of region
190 * - dir - DMA direction
192 ENTRY(v4wt_dma_map_area)
194 ENDPROC(v4wt_dma_unmap_area)
195 ENDPROC(v4wt_dma_map_area)
197 .globl v4wt_flush_kern_cache_louis
198 .equ v4wt_flush_kern_cache_louis, v4wt_flush_kern_cache_all
202 @ define struct cpu_cache_fns (see <asm/cacheflush.h> and proc-macros.S)
203 define_cache_functions v4wt