1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * linux/arch/unicore32/mm/cache-ucv2.S
5 * Code specific to PKUnity SoC and UniCore ISA
7 * Copyright (C) 2001-2010 GUAN Xue-tao
9 * This is the "shell" of the UniCore-v2 processor support.
11 #include <linux/linkage.h>
12 #include <linux/init.h>
13 #include <asm/assembler.h>
16 #include "proc-macros.S"
19 * __cpuc_flush_icache_all()
20 * __cpuc_flush_kern_all()
21 * __cpuc_flush_user_all()
23 * Flush the entire cache.
25 ENTRY(__cpuc_flush_icache_all)
27 ENTRY(__cpuc_flush_kern_all)
29 ENTRY(__cpuc_flush_user_all)
31 movc p0.c5, r0, #14 @ Dcache flush all
35 movc p0.c5, r0, #20 @ Icache invalidate all
41 * __cpuc_flush_user_range(start, end, flags)
43 * Flush a range of TLB entries in the specified address space.
45 * - start - start address (may not be aligned)
46 * - end - end address (exclusive, may not be aligned)
47 * - flags - vm_area_struct flags describing address space
49 ENTRY(__cpuc_flush_user_range)
51 beq __cpuc_dma_flush_range
53 #ifndef CONFIG_CPU_DCACHE_LINE_DISABLE
54 andn r0, r0, #CACHE_LINESIZE - 1 @ Safety check
56 csub.a r1, #MAX_AREA_SIZE
59 andn r1, r1, #CACHE_LINESIZE - 1
60 add r1, r1, #CACHE_LINESIZE
62 101: dcacheline_flush r0, r11, r12
64 add r0, r0, #CACHE_LINESIZE
65 sub.a r1, r1, #CACHE_LINESIZE
70 movc p0.c5, ip, #14 @ Dcache flush all
74 movc p0.c5, ip, #20 @ Icache invalidate all
80 * __cpuc_coherent_kern_range(start,end)
81 * __cpuc_coherent_user_range(start,end)
83 * Ensure that the I and D caches are coherent within specified
84 * region. This is typically used when code has been written to
85 * a memory region, and will be executed.
87 * - start - virtual start address of region
88 * - end - virtual end address of region
90 ENTRY(__cpuc_coherent_kern_range)
92 ENTRY(__cpuc_coherent_user_range)
93 #ifndef CONFIG_CPU_DCACHE_LINE_DISABLE
94 andn r0, r0, #CACHE_LINESIZE - 1 @ Safety check
96 csub.a r1, #MAX_AREA_SIZE
99 andn r1, r1, #CACHE_LINESIZE - 1
100 add r1, r1, #CACHE_LINESIZE
104 sub r9, r9, #1 @ PAGE_MASK
105 101: va2pa r0, r10, r11, r12, r13, 2f @ r10 is PA
110 103: movc p0.c5, r10, #11 @ Dcache clean line of R10
113 add r0, r0, #CACHE_LINESIZE
114 add r10, r10, #CACHE_LINESIZE
115 sub.a r1, r1, #CACHE_LINESIZE
120 movc p0.c5, ip, #10 @ Dcache clean all
124 movc p0.c5, ip, #20 @ Icache invalidate all
130 * __cpuc_flush_kern_dcache_area(void *addr, size_t size)
132 * - addr - kernel address
133 * - size - region size
135 ENTRY(__cpuc_flush_kern_dcache_area)
137 movc p0.c5, ip, #14 @ Dcache flush all
142 * __cpuc_dma_clean_range(start,end)
143 * - start - virtual start address of region
144 * - end - virtual end address of region
146 ENTRY(__cpuc_dma_clean_range)
147 #ifndef CONFIG_CPU_DCACHE_LINE_DISABLE
148 andn r0, r0, #CACHE_LINESIZE - 1
150 andn r1, r1, #CACHE_LINESIZE - 1
151 add r1, r1, #CACHE_LINESIZE
153 csub.a r1, #MAX_AREA_SIZE
158 sub r9, r9, #1 @ PAGE_MASK
159 101: va2pa r0, r10, r11, r12, r13, 2f @ r10 is PA
164 1: movc p0.c5, r10, #11 @ Dcache clean line of R10
166 add r0, r0, #CACHE_LINESIZE
167 add r10, r10, #CACHE_LINESIZE
168 sub.a r1, r1, #CACHE_LINESIZE
173 movc p0.c5, ip, #10 @ Dcache clean all
179 * __cpuc_dma_inv_range(start,end)
180 * __cpuc_dma_flush_range(start,end)
181 * - start - virtual start address of region
182 * - end - virtual end address of region
184 __cpuc_dma_inv_range:
186 ENTRY(__cpuc_dma_flush_range)
187 #ifndef CONFIG_CPU_DCACHE_LINE_DISABLE
188 andn r0, r0, #CACHE_LINESIZE - 1
190 andn r1, r1, #CACHE_LINESIZE - 1
191 add r1, r1, #CACHE_LINESIZE
193 csub.a r1, #MAX_AREA_SIZE
197 101: dcacheline_flush r0, r11, r12
199 add r0, r0, #CACHE_LINESIZE
200 sub.a r1, r1, #CACHE_LINESIZE
205 movc p0.c5, ip, #14 @ Dcache flush all