hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/xtensa/include/asm/initialize_mmu.h
....@@ -6,7 +6,7 @@
66 * For the new V3 MMU we remap the TLB from virtual == physical
77 * to the standard Linux mapping used in earlier MMU's.
88 *
9
- * The the MMU we also support a new configuration register that
9
+ * For the MMU we also support a new configuration register that
1010 * specifies how the S32C1I instruction operates with the cache
1111 * controller.
1212 *
....@@ -23,7 +23,8 @@
2323 #ifndef _XTENSA_INITIALIZE_MMU_H
2424 #define _XTENSA_INITIALIZE_MMU_H
2525
26
-#include <asm/pgtable.h>
26
+#include <linux/init.h>
27
+#include <linux/pgtable.h>
2728 #include <asm/vectors.h>
2829
2930 #if XCHAL_HAVE_PTP_MMU
....@@ -31,10 +32,6 @@
3132 #define CA_WRITEBACK (_PAGE_CA_WB | _PAGE_HW_WRITE | _PAGE_HW_EXEC)
3233 #else
3334 #define CA_WRITEBACK (0x4)
34
-#endif
35
-
36
-#ifndef XCHAL_SPANNING_WAY
37
-#define XCHAL_SPANNING_WAY 0
3835 #endif
3936
4037 #ifdef __ASSEMBLY__
....@@ -46,7 +43,7 @@
4643 #if XCHAL_HAVE_S32C1I && (XCHAL_HW_MIN_VERSION >= XTENSA_HWVERSION_RC_2009_0)
4744 /*
4845 * We Have Atomic Operation Control (ATOMCTL) Register; Initialize it.
49
- * For details see Documentation/xtensa/atomctl.txt
46
+ * For details see Documentation/xtensa/atomctl.rst
5047 */
5148 #if XCHAL_DCACHE_IS_COHERENT
5249 movi a3, 0x25 /* For SMP/MX -- internal for writeback,
....@@ -181,11 +178,42 @@
181178
182179 .macro initialize_cacheattr
183180
184
-#if !defined(CONFIG_MMU) && XCHAL_HAVE_TLBS
181
+#if !defined(CONFIG_MMU) && (XCHAL_HAVE_TLBS || XCHAL_HAVE_MPU)
185182 #if CONFIG_MEMMAP_CACHEATTR == 0x22222222 && XCHAL_HAVE_PTP_MMU
186183 #error Default MEMMAP_CACHEATTR of 0x22222222 does not work with full MMU.
187184 #endif
188185
186
+#if XCHAL_HAVE_MPU
187
+ __REFCONST
188
+ .align 4
189
+.Lattribute_table:
190
+ .long 0x000000, 0x1fff00, 0x1ddf00, 0x1eef00
191
+ .long 0x006600, 0x000000, 0x000000, 0x000000
192
+ .long 0x000000, 0x000000, 0x000000, 0x000000
193
+ .long 0x000000, 0x000000, 0x000000, 0x000000
194
+ .previous
195
+
196
+ movi a3, .Lattribute_table
197
+ movi a4, CONFIG_MEMMAP_CACHEATTR
198
+ movi a5, 1
199
+ movi a6, XCHAL_MPU_ENTRIES
200
+ movi a10, 0x20000000
201
+ movi a11, -1
202
+1:
203
+ sub a5, a5, a10
204
+ extui a8, a4, 28, 4
205
+ beq a8, a11, 2f
206
+ addi a6, a6, -1
207
+ mov a11, a8
208
+2:
209
+ addx4 a9, a8, a3
210
+ l32i a9, a9, 0
211
+ or a9, a9, a6
212
+ wptlb a9, a5
213
+ slli a4, a4, 4
214
+ bgeu a5, a10, 1b
215
+
216
+#else
189217 movi a5, XCHAL_SPANNING_WAY
190218 movi a6, ~_PAGE_ATTRIB_MASK
191219 movi a4, CONFIG_MEMMAP_CACHEATTR
....@@ -208,6 +236,7 @@
208236
209237 isync
210238 #endif
239
+#endif
211240
212241 .endm
213242