blob: e8db5332ae08ff207064a59f50fc851d4c644e7e [file] [log] [blame]
Lokesh Vutla49297cf2018-08-27 15:57:13 +05301// SPDX-License-Identifier: GPL-2.0+
2/*
3 * K3: ARM64 MMU setup
4 *
Suman Anna0bc221d2020-08-17 18:15:09 -05005 * Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/
Lokesh Vutla49297cf2018-08-27 15:57:13 +05306 * Lokesh Vutla <lokeshvutla@ti.com>
Suman Anna0bc221d2020-08-17 18:15:09 -05007 * Suman Anna <s-anna@ti.com>
Michal Simek7f60b232019-01-17 08:22:43 +01008 * (This file is derived from arch/arm/mach-zynqmp/cpu.c)
Lokesh Vutla49297cf2018-08-27 15:57:13 +05309 *
10 */
11
Lokesh Vutla49297cf2018-08-27 15:57:13 +053012#include <asm/system.h>
13#include <asm/armv8/mmu.h>
14
Andrew Davis1be5e972022-07-15 10:25:27 -050015#ifdef CONFIG_SOC_K3_AM654
Lokesh Vutla49297cf2018-08-27 15:57:13 +053016/* NR_DRAM_BANKS + 32bit IO + 64bit IO + terminator */
Suman Annaf359afb2019-09-04 16:01:49 +053017#define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 5)
Lokesh Vutla49297cf2018-08-27 15:57:13 +053018
19/* ToDo: Add 64bit IO */
20struct mm_region am654_mem_map[NR_MMU_REGIONS] = {
21 {
22 .virt = 0x0UL,
23 .phys = 0x0UL,
24 .size = 0x80000000UL,
25 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
26 PTE_BLOCK_NON_SHARE |
27 PTE_BLOCK_PXN | PTE_BLOCK_UXN
28 }, {
29 .virt = 0x80000000UL,
30 .phys = 0x80000000UL,
Suman Annaf359afb2019-09-04 16:01:49 +053031 .size = 0x20000000UL,
32 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
33 PTE_BLOCK_INNER_SHARE
34 }, {
35 .virt = 0xa0000000UL,
36 .phys = 0xa0000000UL,
37 .size = 0x02100000UL,
38 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) |
39 PTE_BLOCK_INNER_SHARE
40 }, {
41 .virt = 0xa2100000UL,
42 .phys = 0xa2100000UL,
43 .size = 0x5df00000UL,
Lokesh Vutla49297cf2018-08-27 15:57:13 +053044 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
45 PTE_BLOCK_INNER_SHARE
46 }, {
47 .virt = 0x880000000UL,
48 .phys = 0x880000000UL,
49 .size = 0x80000000UL,
50 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
51 PTE_BLOCK_INNER_SHARE
52 }, {
Vignesh Raghavendraf2716382020-02-04 11:09:49 +053053 .virt = 0x500000000UL,
54 .phys = 0x500000000UL,
55 .size = 0x400000000UL,
56 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
57 PTE_BLOCK_NON_SHARE |
58 PTE_BLOCK_PXN | PTE_BLOCK_UXN
59 }, {
Lokesh Vutla49297cf2018-08-27 15:57:13 +053060 /* List terminator */
61 0,
62 }
63};
64
65struct mm_region *mem_map = am654_mem_map;
Andrew Davis1be5e972022-07-15 10:25:27 -050066#endif /* CONFIG_SOC_K3_AM654 */
Suman Anna41dfdbf2019-06-13 10:29:48 +053067
68#ifdef CONFIG_SOC_K3_J721E
Suman Anna0bc221d2020-08-17 18:15:09 -050069
Nishanth Menon7fb31d32023-11-04 02:21:46 -050070#ifdef CONFIG_SOC_K3_J721E_J7200
71#define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 5)
Suman Anna41dfdbf2019-06-13 10:29:48 +053072
73/* ToDo: Add 64bit IO */
Nishanth Menon7fb31d32023-11-04 02:21:46 -050074struct mm_region j7200_mem_map[NR_MMU_REGIONS] = {
Suman Anna41dfdbf2019-06-13 10:29:48 +053075 {
76 .virt = 0x0UL,
77 .phys = 0x0UL,
78 .size = 0x80000000UL,
79 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
80 PTE_BLOCK_NON_SHARE |
81 PTE_BLOCK_PXN | PTE_BLOCK_UXN
82 }, {
83 .virt = 0x80000000UL,
84 .phys = 0x80000000UL,
85 .size = 0x20000000UL,
86 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
87 PTE_BLOCK_INNER_SHARE
88 }, {
89 .virt = 0xa0000000UL,
90 .phys = 0xa0000000UL,
Nishanth Menon7fb31d32023-11-04 02:21:46 -050091 .size = 0x04800000UL,
Suman Anna41dfdbf2019-06-13 10:29:48 +053092 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) |
93 PTE_BLOCK_NON_SHARE
94 }, {
Nishanth Menon7fb31d32023-11-04 02:21:46 -050095 .virt = 0xa4800000UL,
96 .phys = 0xa4800000UL,
97 .size = 0x5b800000UL,
Suman Anna41dfdbf2019-06-13 10:29:48 +053098 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
99 PTE_BLOCK_INNER_SHARE
100 }, {
101 .virt = 0x880000000UL,
102 .phys = 0x880000000UL,
103 .size = 0x80000000UL,
104 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
105 PTE_BLOCK_INNER_SHARE
106 }, {
107 .virt = 0x500000000UL,
108 .phys = 0x500000000UL,
109 .size = 0x400000000UL,
110 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
111 PTE_BLOCK_NON_SHARE |
112 PTE_BLOCK_PXN | PTE_BLOCK_UXN
113 }, {
114 /* List terminator */
115 0,
116 }
117};
118
Nishanth Menon7fb31d32023-11-04 02:21:46 -0500119struct mm_region *mem_map = j7200_mem_map;
Suman Anna0bc221d2020-08-17 18:15:09 -0500120
Nishanth Menon7fb31d32023-11-04 02:21:46 -0500121#else /* CONFIG_SOC_K3_J721E_J7200 */
122
123/* NR_DRAM_BANKS + 32bit IO + 64bit IO + terminator */
124#define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 6)
Suman Anna0bc221d2020-08-17 18:15:09 -0500125
126/* ToDo: Add 64bit IO */
Nishanth Menon7fb31d32023-11-04 02:21:46 -0500127struct mm_region j721e_mem_map[NR_MMU_REGIONS] = {
Suman Anna0bc221d2020-08-17 18:15:09 -0500128 {
129 .virt = 0x0UL,
130 .phys = 0x0UL,
131 .size = 0x80000000UL,
132 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
133 PTE_BLOCK_NON_SHARE |
134 PTE_BLOCK_PXN | PTE_BLOCK_UXN
135 }, {
136 .virt = 0x80000000UL,
137 .phys = 0x80000000UL,
138 .size = 0x20000000UL,
139 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
140 PTE_BLOCK_INNER_SHARE
141 }, {
142 .virt = 0xa0000000UL,
143 .phys = 0xa0000000UL,
Nishanth Menon7fb31d32023-11-04 02:21:46 -0500144 .size = 0x1bc00000UL,
Suman Anna0bc221d2020-08-17 18:15:09 -0500145 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) |
146 PTE_BLOCK_NON_SHARE
147 }, {
Nishanth Menon7fb31d32023-11-04 02:21:46 -0500148 .virt = 0xbbc00000UL,
149 .phys = 0xbbc00000UL,
150 .size = 0x44400000UL,
Suman Anna0bc221d2020-08-17 18:15:09 -0500151 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
152 PTE_BLOCK_INNER_SHARE
153 }, {
154 .virt = 0x880000000UL,
155 .phys = 0x880000000UL,
156 .size = 0x80000000UL,
157 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
158 PTE_BLOCK_INNER_SHARE
159 }, {
160 .virt = 0x500000000UL,
161 .phys = 0x500000000UL,
162 .size = 0x400000000UL,
163 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
164 PTE_BLOCK_NON_SHARE |
165 PTE_BLOCK_PXN | PTE_BLOCK_UXN
166 }, {
Nishanth Menon7fb31d32023-11-04 02:21:46 -0500167 .virt = 0x4d80000000UL,
168 .phys = 0x4d80000000UL,
169 .size = 0x0002000000UL,
170 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) |
171 PTE_BLOCK_INNER_SHARE
172 }, {
Suman Anna0bc221d2020-08-17 18:15:09 -0500173 /* List terminator */
174 0,
175 }
176};
177
Nishanth Menon7fb31d32023-11-04 02:21:46 -0500178struct mm_region *mem_map = j721e_mem_map;
179#endif /* CONFIG_SOC_K3_J721E_J7200 */
Suman Anna0bc221d2020-08-17 18:15:09 -0500180
Suman Anna41dfdbf2019-06-13 10:29:48 +0530181#endif /* CONFIG_SOC_K3_J721E */
Keerthye07dfe52021-04-23 11:27:39 -0500182
David Huang61098202022-01-25 20:56:31 +0530183#ifdef CONFIG_SOC_K3_J721S2
184#define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 3)
185
186/* ToDo: Add 64bit IO */
187struct mm_region j721s2_mem_map[NR_MMU_REGIONS] = {
188 {
189 .virt = 0x0UL,
190 .phys = 0x0UL,
191 .size = 0x80000000UL,
192 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
193 PTE_BLOCK_NON_SHARE |
194 PTE_BLOCK_PXN | PTE_BLOCK_UXN
195 }, {
196 .virt = 0x80000000UL,
197 .phys = 0x80000000UL,
198 .size = 0x80000000UL,
199 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
200 PTE_BLOCK_INNER_SHARE
201 }, {
202 .virt = 0x880000000UL,
203 .phys = 0x880000000UL,
204 .size = 0x80000000UL,
205 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
206 PTE_BLOCK_INNER_SHARE
207 }, {
208 .virt = 0x500000000UL,
209 .phys = 0x500000000UL,
210 .size = 0x400000000UL,
211 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
212 PTE_BLOCK_NON_SHARE |
213 PTE_BLOCK_PXN | PTE_BLOCK_UXN
214 }, {
215 /* List terminator */
216 0,
217 }
218};
219
220struct mm_region *mem_map = j721s2_mem_map;
221
222#endif /* CONFIG_SOC_K3_J721S2 */
223
Kamlesh Gurudasaniae83fe22023-05-12 17:28:52 +0530224#if defined(CONFIG_SOC_K3_AM625) || defined(CONFIG_SOC_K3_AM62A7)
Bryan Brattlofdaa39a62022-11-03 19:13:55 -0500225
Keerthye07dfe52021-04-23 11:27:39 -0500226/* NR_DRAM_BANKS + 32bit IO + 64bit IO + terminator */
Kamlesh Gurudasaniae83fe22023-05-12 17:28:52 +0530227#define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 4)
Keerthye07dfe52021-04-23 11:27:39 -0500228
229/* ToDo: Add 64bit IO */
Kamlesh Gurudasaniae83fe22023-05-12 17:28:52 +0530230struct mm_region am62_mem_map[NR_MMU_REGIONS] = {
Keerthye07dfe52021-04-23 11:27:39 -0500231 {
232 .virt = 0x0UL,
233 .phys = 0x0UL,
234 .size = 0x80000000UL,
235 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
236 PTE_BLOCK_NON_SHARE |
237 PTE_BLOCK_PXN | PTE_BLOCK_UXN
238 }, {
239 .virt = 0x80000000UL,
240 .phys = 0x80000000UL,
Kamlesh Gurudasaniae83fe22023-05-12 17:28:52 +0530241 .size = 0x1E780000UL,
242 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
243 PTE_BLOCK_INNER_SHARE
244 }, {
245 .virt = 0xA0000000UL,
246 .phys = 0xA0000000UL,
247 .size = 0x60000000UL,
248 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
249 PTE_BLOCK_INNER_SHARE
250
251 }, {
252 .virt = 0x880000000UL,
253 .phys = 0x880000000UL,
254 .size = 0x80000000UL,
255 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
256 PTE_BLOCK_INNER_SHARE
257 }, {
258 .virt = 0x500000000UL,
259 .phys = 0x500000000UL,
260 .size = 0x400000000UL,
261 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
262 PTE_BLOCK_NON_SHARE |
263 PTE_BLOCK_PXN | PTE_BLOCK_UXN
264 }, {
265 /* List terminator */
266 0,
267 }
268};
269
270struct mm_region *mem_map = am62_mem_map;
271#endif /* CONFIG_SOC_K3_AM625 || CONFIG_SOC_K3_AM62A7 */
272
273#ifdef CONFIG_SOC_K3_AM642
274
275/* NR_DRAM_BANKS + 32bit IO + 64bit IO + terminator */
276#define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 4)
277
278/* ToDo: Add 64bit IO */
279struct mm_region am64_mem_map[NR_MMU_REGIONS] = {
280 {
281 .virt = 0x0UL,
282 .phys = 0x0UL,
Keerthye07dfe52021-04-23 11:27:39 -0500283 .size = 0x80000000UL,
Kamlesh Gurudasaniae83fe22023-05-12 17:28:52 +0530284 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
285 PTE_BLOCK_NON_SHARE |
286 PTE_BLOCK_PXN | PTE_BLOCK_UXN
287 }, {
288 .virt = 0x80000000UL,
289 .phys = 0x80000000UL,
290 .size = 0x1E800000UL,
291 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
292 PTE_BLOCK_INNER_SHARE
293 }, {
294 .virt = 0xA0000000UL,
295 .phys = 0xA0000000UL,
296 .size = 0x60000000UL,
Keerthye07dfe52021-04-23 11:27:39 -0500297 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
298 PTE_BLOCK_INNER_SHARE
299 }, {
300 .virt = 0x880000000UL,
301 .phys = 0x880000000UL,
302 .size = 0x80000000UL,
303 .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
304 PTE_BLOCK_INNER_SHARE
305 }, {
306 .virt = 0x500000000UL,
307 .phys = 0x500000000UL,
308 .size = 0x400000000UL,
309 .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
310 PTE_BLOCK_NON_SHARE |
311 PTE_BLOCK_PXN | PTE_BLOCK_UXN
312 }, {
313 /* List terminator */
314 0,
315 }
316};
317
318struct mm_region *mem_map = am64_mem_map;
Kamlesh Gurudasaniae83fe22023-05-12 17:28:52 +0530319#endif /* CONFIG_SOC_K3_AM642 */