4 * Copyright (C) 2001 Deep Blue Solutions Ltd.
5 * Copyright (C) 2012 ARM Ltd.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include <linux/errno.h>
21 #include <linux/linkage.h>
22 #include <linux/init.h>
23 #include <asm/assembler.h>
24 #include <asm/cpufeature.h>
25 #include <asm/alternative.h>
28 * flush_icache_range(start,end)
30 * Ensure that the I and D caches are coherent within specified region.
31 * This is typically used when code has been written to a memory region,
32 * and will be executed.
34 * - start - virtual start address of region
35 * - end - virtual end address of region
37 ENTRY(flush_icache_range)
41 * __flush_cache_user_range(start,end)
43 * Ensure that the I and D caches are coherent within specified region.
44 * This is typically used when code has been written to a memory region,
45 * and will be executed.
47 * - start - virtual start address of region
48 * - end - virtual end address of region
50 ENTRY(__flush_cache_user_range)
51 dcache_line_size x2, x3
55 USER(9f, dc cvau, x4 ) // clean D line to PoU
61 icache_line_size x2, x3
65 USER(9f, ic ivau, x4 ) // invalidate I line PoU
76 ENDPROC(flush_icache_range)
77 ENDPROC(__flush_cache_user_range)
80 * __flush_dcache_area(kaddr, size)
82 * Ensure that any D-cache lines for the interval [kaddr, kaddr+size)
83 * are cleaned and invalidated to the PoC.
85 * - kaddr - kernel address
86 * - size - size in question
88 ENTRY(__flush_dcache_area)
89 dcache_by_line_op civac, sy, x0, x1, x2, x3
91 ENDPIPROC(__flush_dcache_area)
94 * __clean_dcache_area_pou(kaddr, size)
96 * Ensure that any D-cache lines for the interval [kaddr, kaddr+size)
97 * are cleaned to the PoU.
99 * - kaddr - kernel address
100 * - size - size in question
102 ENTRY(__clean_dcache_area_pou)
103 dcache_by_line_op cvau, ish, x0, x1, x2, x3
105 ENDPROC(__clean_dcache_area_pou)
108 * __inval_cache_range(start, end)
109 * - start - start address of region
110 * - end - end address of region
112 ENTRY(__inval_cache_range)
116 * __dma_inv_range(start, end)
117 * - start - virtual start address of region
118 * - end - virtual end address of region
121 dcache_line_size x2, x3
123 tst x1, x3 // end cache line aligned?
126 dc civac, x1 // clean & invalidate D / U line
127 1: tst x0, x3 // start cache line aligned?
130 dc civac, x0 // clean & invalidate D / U line
132 2: dc ivac, x0 // invalidate D / U line
138 ENDPIPROC(__inval_cache_range)
139 ENDPROC(__dma_inv_range)
142 * __dma_clean_range(start, end)
143 * - start - virtual start address of region
144 * - end - virtual end address of region
147 dcache_line_size x2, x3
151 alternative_if_not ARM64_WORKAROUND_CLEAN_CACHE
161 ENDPROC(__dma_clean_range)
164 * __dma_flush_range(start, end)
165 * - start - virtual start address of region
166 * - end - virtual end address of region
168 ENTRY(__dma_flush_range)
169 dcache_line_size x2, x3
172 1: dc civac, x0 // clean & invalidate D / U line
178 ENDPIPROC(__dma_flush_range)
181 * __dma_map_area(start, size, dir)
182 * - start - kernel virtual start address
183 * - size - size of region
184 * - dir - DMA direction
186 ENTRY(__dma_map_area)
188 cmp w2, #DMA_FROM_DEVICE
191 ENDPIPROC(__dma_map_area)
194 * __dma_unmap_area(start, size, dir)
195 * - start - kernel virtual start address
196 * - size - size of region
197 * - dir - DMA direction
199 ENTRY(__dma_unmap_area)
201 cmp w2, #DMA_TO_DEVICE
204 ENDPIPROC(__dma_unmap_area)