1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifndef _XTENSA_INITIALIZE_MMU_H
24#define _XTENSA_INITIALIZE_MMU_H
25
26#include <asm/pgtable.h>
27#include <asm/vectors.h>
28
29#if XCHAL_HAVE_PTP_MMU
30#define CA_BYPASS (_PAGE_CA_BYPASS | _PAGE_HW_WRITE | _PAGE_HW_EXEC)
31#define CA_WRITEBACK (_PAGE_CA_WB | _PAGE_HW_WRITE | _PAGE_HW_EXEC)
32#else
33#define CA_WRITEBACK (0x4)
34#endif
35
36#ifndef XCHAL_SPANNING_WAY
37#define XCHAL_SPANNING_WAY 0
38#endif
39
40#ifdef __ASSEMBLY__
41
42#define XTENSA_HWVERSION_RC_2009_0 230000
43
44 .macro initialize_mmu
45
46#if XCHAL_HAVE_S32C1I && (XCHAL_HW_MIN_VERSION >= XTENSA_HWVERSION_RC_2009_0)
47
48
49
50
51#if XCHAL_DCACHE_IS_COHERENT
52 movi a3, 0x25
53
54
55#else
56 movi a3, 0x29
57
58
59#endif
60 wsr a3, atomctl
61#endif
62
63
64
65#if defined(CONFIG_MMU) && XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY
66
67
68
69
70#if !XCHAL_HAVE_VECBASE
71# error "MMU v3 requires reloc vectors"
72#endif
73
74 movi a1, 0
75 _call0 1f
76 _j 2f
77
78 .align 4
791: movi a2, 0x10000000
80
81#if CONFIG_KERNEL_LOAD_ADDRESS < 0x40000000ul
82#define TEMP_MAPPING_VADDR 0x40000000
83#else
84#define TEMP_MAPPING_VADDR 0x00000000
85#endif
86
87
88
89 movi a2, TEMP_MAPPING_VADDR | XCHAL_SPANNING_WAY
90 idtlb a2
91 iitlb a2
92 isync
93
94
95
96
97
98 srli a3, a0, 27
99 slli a3, a3, 27
100 addi a3, a3, CA_BYPASS
101 addi a7, a2, 5 - XCHAL_SPANNING_WAY
102 wdtlb a3, a7
103 witlb a3, a7
104 isync
105
106 slli a4, a0, 5
107 srli a4, a4, 5
108 addi a5, a2, -XCHAL_SPANNING_WAY
109 add a4, a4, a5
110 jx a4
111
112
113
114
1152: movi a4, 0x20000000
116 add a5, a2, a4
1173: idtlb a5
118 iitlb a5
119 add a5, a5, a4
120 bne a5, a2, 3b
121
122
123
124 movi a6, 0x01000000
125 wsr a6, ITLBCFG
126 wsr a6, DTLBCFG
127 isync
128
129 movi a5, XCHAL_KSEG_CACHED_VADDR + XCHAL_KSEG_TLB_WAY
130 movi a4, XCHAL_KSEG_PADDR + CA_WRITEBACK
131 wdtlb a4, a5
132 witlb a4, a5
133
134 movi a5, XCHAL_KSEG_BYPASS_VADDR + XCHAL_KSEG_TLB_WAY
135 movi a4, XCHAL_KSEG_PADDR + CA_BYPASS
136 wdtlb a4, a5
137 witlb a4, a5
138
139#ifdef CONFIG_XTENSA_KSEG_512M
140 movi a5, XCHAL_KSEG_CACHED_VADDR + 0x10000000 + XCHAL_KSEG_TLB_WAY
141 movi a4, XCHAL_KSEG_PADDR + 0x10000000 + CA_WRITEBACK
142 wdtlb a4, a5
143 witlb a4, a5
144
145 movi a5, XCHAL_KSEG_BYPASS_VADDR + 0x10000000 + XCHAL_KSEG_TLB_WAY
146 movi a4, XCHAL_KSEG_PADDR + 0x10000000 + CA_BYPASS
147 wdtlb a4, a5
148 witlb a4, a5
149#endif
150
151 movi a5, XCHAL_KIO_CACHED_VADDR + XCHAL_KIO_TLB_WAY
152 movi a4, XCHAL_KIO_DEFAULT_PADDR + CA_WRITEBACK
153 wdtlb a4, a5
154 witlb a4, a5
155
156 movi a5, XCHAL_KIO_BYPASS_VADDR + XCHAL_KIO_TLB_WAY
157 movi a4, XCHAL_KIO_DEFAULT_PADDR + CA_BYPASS
158 wdtlb a4, a5
159 witlb a4, a5
160
161 isync
162
163
164 movi a4, 1f
165 jx a4
166
1671:
168
169 idtlb a7
170 iitlb a7
171 isync
172
173 movi a0, 0
174 wsr a0, ptevaddr
175 rsync
176
177#endif
178
179
180#if !defined(CONFIG_MMU) && XCHAL_HAVE_TLBS && \
181 (XCHAL_DCACHE_SIZE || XCHAL_ICACHE_SIZE)
182
183
184
185
186 movi a5, PLATFORM_DEFAULT_MEM_START | XCHAL_SPANNING_WAY
187 movi a6, ~_PAGE_ATTRIB_MASK
188 movi a7, CA_WRITEBACK
189 movi a8, 0x20000000
190 movi a9, PLATFORM_DEFAULT_MEM_SIZE
191 j 2f
1921:
193 sub a9, a9, a8
1942:
195#if XCHAL_DCACHE_SIZE
196 rdtlb1 a3, a5
197 and a3, a3, a6
198 or a3, a3, a7
199 wdtlb a3, a5
200#endif
201#if XCHAL_ICACHE_SIZE
202 ritlb1 a4, a5
203 and a4, a4, a6
204 or a4, a4, a7
205 witlb a4, a5
206#endif
207 add a5, a5, a8
208 bltu a8, a9, 1b
209
210#endif
211
212 .endm
213
214#endif
215
216#endif
217