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>
27 #include "proc-macros.S"
30 * flush_icache_range(start,end)
32 * Ensure that the I and D caches are coherent within specified region.
33 * This is typically used when code has been written to a memory region,
34 * and will be executed.
36 * - start - virtual start address of region
37 * - end - virtual end address of region
39 ENTRY(flush_icache_range)
43 * __flush_cache_user_range(start,end)
45 * Ensure that the I and D caches are coherent within specified region.
46 * This is typically used when code has been written to a memory region,
47 * and will be executed.
49 * - start - virtual start address of region
50 * - end - virtual end address of region
52 ENTRY(__flush_cache_user_range)
53 dcache_line_size x2, x3
57 USER(9f, dc cvau, x4 ) // clean D line to PoU
63 icache_line_size x2, x3
67 USER(9f, ic ivau, x4 ) // invalidate I line PoU
78 ENDPROC(flush_icache_range)
79 ENDPROC(__flush_cache_user_range)
82 * __flush_dcache_area(kaddr, size)
84 * Ensure that the data held in the page kaddr is written back to the
87 * - kaddr - kernel address
88 * - size - size in question
90 ENTRY(__flush_dcache_area)
91 dcache_line_size x2, x3
95 1: dc civac, x0 // clean & invalidate D line / unified line
101 ENDPROC(__flush_dcache_area)
104 * __inval_cache_range(start, end)
105 * - start - start address of region
106 * - end - end address of region
108 ENTRY(__inval_cache_range)
112 * __dma_inv_range(start, end)
113 * - start - virtual start address of region
114 * - end - virtual end address of region
117 dcache_line_size x2, x3
119 tst x1, x3 // end cache line aligned?
122 dc civac, x1 // clean & invalidate D / U line
123 1: tst x0, x3 // start cache line aligned?
126 dc civac, x0 // clean & invalidate D / U line
128 2: dc ivac, x0 // invalidate D / U line
134 ENDPROC(__inval_cache_range)
135 ENDPROC(__dma_inv_range)
138 * __dma_clean_range(start, end)
139 * - start - virtual start address of region
140 * - end - virtual end address of region
143 dcache_line_size x2, x3
146 1: alternative_insn "dc cvac, x0", "dc civac, x0", ARM64_WORKAROUND_CLEAN_CACHE
152 ENDPROC(__dma_clean_range)
155 * __dma_flush_range(start, end)
156 * - start - virtual start address of region
157 * - end - virtual end address of region
159 ENTRY(__dma_flush_range)
160 dcache_line_size x2, x3
163 1: dc civac, x0 // clean & invalidate D / U line
169 ENDPROC(__dma_flush_range)
172 * __dma_map_area(start, size, dir)
173 * - start - kernel virtual start address
174 * - size - size of region
175 * - dir - DMA direction
177 ENTRY(__dma_map_area)
179 cmp w2, #DMA_FROM_DEVICE
182 ENDPROC(__dma_map_area)
185 * __dma_unmap_area(start, size, dir)
186 * - start - kernel virtual start address
187 * - size - size of region
188 * - dir - DMA direction
190 ENTRY(__dma_unmap_area)
192 cmp w2, #DMA_TO_DEVICE
195 ENDPROC(__dma_unmap_area)