Lokesh Vutla | 49297cf | 2018-08-27 15:57:13 +0530 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * K3: ARM64 MMU setup |
| 4 | * |
Suman Anna | 0bc221d | 2020-08-17 18:15:09 -0500 | [diff] [blame] | 5 | * Copyright (C) 2018-2020 Texas Instruments Incorporated - https://www.ti.com/ |
Lokesh Vutla | 49297cf | 2018-08-27 15:57:13 +0530 | [diff] [blame] | 6 | * Lokesh Vutla <lokeshvutla@ti.com> |
Suman Anna | 0bc221d | 2020-08-17 18:15:09 -0500 | [diff] [blame] | 7 | * Suman Anna <s-anna@ti.com> |
Michal Simek | 7f60b23 | 2019-01-17 08:22:43 +0100 | [diff] [blame] | 8 | * (This file is derived from arch/arm/mach-zynqmp/cpu.c) |
Lokesh Vutla | 49297cf | 2018-08-27 15:57:13 +0530 | [diff] [blame] | 9 | * |
| 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | #include <asm/system.h> |
| 14 | #include <asm/armv8/mmu.h> |
| 15 | |
Andrew Davis | 1be5e97 | 2022-07-15 10:25:27 -0500 | [diff] [blame] | 16 | #ifdef CONFIG_SOC_K3_AM654 |
Lokesh Vutla | 49297cf | 2018-08-27 15:57:13 +0530 | [diff] [blame] | 17 | /* NR_DRAM_BANKS + 32bit IO + 64bit IO + terminator */ |
Suman Anna | f359afb | 2019-09-04 16:01:49 +0530 | [diff] [blame] | 18 | #define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 5) |
Lokesh Vutla | 49297cf | 2018-08-27 15:57:13 +0530 | [diff] [blame] | 19 | |
| 20 | /* ToDo: Add 64bit IO */ |
| 21 | struct mm_region am654_mem_map[NR_MMU_REGIONS] = { |
| 22 | { |
| 23 | .virt = 0x0UL, |
| 24 | .phys = 0x0UL, |
| 25 | .size = 0x80000000UL, |
| 26 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 27 | PTE_BLOCK_NON_SHARE | |
| 28 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 29 | }, { |
| 30 | .virt = 0x80000000UL, |
| 31 | .phys = 0x80000000UL, |
Suman Anna | f359afb | 2019-09-04 16:01:49 +0530 | [diff] [blame] | 32 | .size = 0x20000000UL, |
| 33 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 34 | PTE_BLOCK_INNER_SHARE |
| 35 | }, { |
| 36 | .virt = 0xa0000000UL, |
| 37 | .phys = 0xa0000000UL, |
| 38 | .size = 0x02100000UL, |
| 39 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) | |
| 40 | PTE_BLOCK_INNER_SHARE |
| 41 | }, { |
| 42 | .virt = 0xa2100000UL, |
| 43 | .phys = 0xa2100000UL, |
| 44 | .size = 0x5df00000UL, |
Lokesh Vutla | 49297cf | 2018-08-27 15:57:13 +0530 | [diff] [blame] | 45 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 46 | PTE_BLOCK_INNER_SHARE |
| 47 | }, { |
| 48 | .virt = 0x880000000UL, |
| 49 | .phys = 0x880000000UL, |
| 50 | .size = 0x80000000UL, |
| 51 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 52 | PTE_BLOCK_INNER_SHARE |
| 53 | }, { |
Vignesh Raghavendra | f271638 | 2020-02-04 11:09:49 +0530 | [diff] [blame] | 54 | .virt = 0x500000000UL, |
| 55 | .phys = 0x500000000UL, |
| 56 | .size = 0x400000000UL, |
| 57 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 58 | PTE_BLOCK_NON_SHARE | |
| 59 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 60 | }, { |
Lokesh Vutla | 49297cf | 2018-08-27 15:57:13 +0530 | [diff] [blame] | 61 | /* List terminator */ |
| 62 | 0, |
| 63 | } |
| 64 | }; |
| 65 | |
| 66 | struct mm_region *mem_map = am654_mem_map; |
Andrew Davis | 1be5e97 | 2022-07-15 10:25:27 -0500 | [diff] [blame] | 67 | #endif /* CONFIG_SOC_K3_AM654 */ |
Suman Anna | 41dfdbf | 2019-06-13 10:29:48 +0530 | [diff] [blame] | 68 | |
| 69 | #ifdef CONFIG_SOC_K3_J721E |
Suman Anna | 0bc221d | 2020-08-17 18:15:09 -0500 | [diff] [blame] | 70 | |
| 71 | #ifdef CONFIG_TARGET_J721E_A72_EVM |
Suman Anna | 41dfdbf | 2019-06-13 10:29:48 +0530 | [diff] [blame] | 72 | /* NR_DRAM_BANKS + 32bit IO + 64bit IO + terminator */ |
Suman Anna | 063761b | 2020-03-10 16:05:55 -0500 | [diff] [blame] | 73 | #define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 6) |
Suman Anna | 41dfdbf | 2019-06-13 10:29:48 +0530 | [diff] [blame] | 74 | |
| 75 | /* ToDo: Add 64bit IO */ |
| 76 | struct mm_region j721e_mem_map[NR_MMU_REGIONS] = { |
| 77 | { |
| 78 | .virt = 0x0UL, |
| 79 | .phys = 0x0UL, |
| 80 | .size = 0x80000000UL, |
| 81 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 82 | PTE_BLOCK_NON_SHARE | |
| 83 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 84 | }, { |
| 85 | .virt = 0x80000000UL, |
| 86 | .phys = 0x80000000UL, |
| 87 | .size = 0x20000000UL, |
| 88 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 89 | PTE_BLOCK_INNER_SHARE |
| 90 | }, { |
| 91 | .virt = 0xa0000000UL, |
| 92 | .phys = 0xa0000000UL, |
Kedar Chitnis | 0e01e3e | 2019-09-04 16:01:50 +0530 | [diff] [blame] | 93 | .size = 0x1bc00000UL, |
Suman Anna | 41dfdbf | 2019-06-13 10:29:48 +0530 | [diff] [blame] | 94 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) | |
| 95 | PTE_BLOCK_NON_SHARE |
| 96 | }, { |
Kedar Chitnis | 0e01e3e | 2019-09-04 16:01:50 +0530 | [diff] [blame] | 97 | .virt = 0xbbc00000UL, |
| 98 | .phys = 0xbbc00000UL, |
| 99 | .size = 0x44400000UL, |
Suman Anna | 41dfdbf | 2019-06-13 10:29:48 +0530 | [diff] [blame] | 100 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 101 | PTE_BLOCK_INNER_SHARE |
| 102 | }, { |
| 103 | .virt = 0x880000000UL, |
| 104 | .phys = 0x880000000UL, |
| 105 | .size = 0x80000000UL, |
| 106 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 107 | PTE_BLOCK_INNER_SHARE |
| 108 | }, { |
| 109 | .virt = 0x500000000UL, |
| 110 | .phys = 0x500000000UL, |
| 111 | .size = 0x400000000UL, |
| 112 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 113 | PTE_BLOCK_NON_SHARE | |
| 114 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 115 | }, { |
Suman Anna | 063761b | 2020-03-10 16:05:55 -0500 | [diff] [blame] | 116 | .virt = 0x4d80000000UL, |
| 117 | .phys = 0x4d80000000UL, |
| 118 | .size = 0x0002000000UL, |
| 119 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) | |
| 120 | PTE_BLOCK_INNER_SHARE |
| 121 | }, { |
Suman Anna | 41dfdbf | 2019-06-13 10:29:48 +0530 | [diff] [blame] | 122 | /* List terminator */ |
| 123 | 0, |
| 124 | } |
| 125 | }; |
| 126 | |
| 127 | struct mm_region *mem_map = j721e_mem_map; |
Suman Anna | 0bc221d | 2020-08-17 18:15:09 -0500 | [diff] [blame] | 128 | #endif /* CONFIG_TARGET_J721E_A72_EVM */ |
| 129 | |
| 130 | #ifdef CONFIG_TARGET_J7200_A72_EVM |
| 131 | #define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 5) |
| 132 | |
| 133 | /* ToDo: Add 64bit IO */ |
| 134 | struct mm_region j7200_mem_map[NR_MMU_REGIONS] = { |
| 135 | { |
| 136 | .virt = 0x0UL, |
| 137 | .phys = 0x0UL, |
| 138 | .size = 0x80000000UL, |
| 139 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 140 | PTE_BLOCK_NON_SHARE | |
| 141 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 142 | }, { |
| 143 | .virt = 0x80000000UL, |
| 144 | .phys = 0x80000000UL, |
| 145 | .size = 0x20000000UL, |
| 146 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 147 | PTE_BLOCK_INNER_SHARE |
| 148 | }, { |
| 149 | .virt = 0xa0000000UL, |
| 150 | .phys = 0xa0000000UL, |
| 151 | .size = 0x04800000UL, |
| 152 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL_NC) | |
| 153 | PTE_BLOCK_NON_SHARE |
| 154 | }, { |
| 155 | .virt = 0xa4800000UL, |
| 156 | .phys = 0xa4800000UL, |
| 157 | .size = 0x5b800000UL, |
| 158 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 159 | PTE_BLOCK_INNER_SHARE |
| 160 | }, { |
| 161 | .virt = 0x880000000UL, |
| 162 | .phys = 0x880000000UL, |
| 163 | .size = 0x80000000UL, |
| 164 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 165 | PTE_BLOCK_INNER_SHARE |
| 166 | }, { |
| 167 | .virt = 0x500000000UL, |
| 168 | .phys = 0x500000000UL, |
| 169 | .size = 0x400000000UL, |
| 170 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 171 | PTE_BLOCK_NON_SHARE | |
| 172 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 173 | }, { |
| 174 | /* List terminator */ |
| 175 | 0, |
| 176 | } |
| 177 | }; |
| 178 | |
| 179 | struct mm_region *mem_map = j7200_mem_map; |
| 180 | #endif /* CONFIG_TARGET_J7200_A72_EVM */ |
| 181 | |
Suman Anna | 41dfdbf | 2019-06-13 10:29:48 +0530 | [diff] [blame] | 182 | #endif /* CONFIG_SOC_K3_J721E */ |
Keerthy | e07dfe5 | 2021-04-23 11:27:39 -0500 | [diff] [blame] | 183 | |
David Huang | 6109820 | 2022-01-25 20:56:31 +0530 | [diff] [blame] | 184 | #ifdef CONFIG_SOC_K3_J721S2 |
| 185 | #define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 3) |
| 186 | |
| 187 | /* ToDo: Add 64bit IO */ |
| 188 | struct mm_region j721s2_mem_map[NR_MMU_REGIONS] = { |
| 189 | { |
| 190 | .virt = 0x0UL, |
| 191 | .phys = 0x0UL, |
| 192 | .size = 0x80000000UL, |
| 193 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 194 | PTE_BLOCK_NON_SHARE | |
| 195 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 196 | }, { |
| 197 | .virt = 0x80000000UL, |
| 198 | .phys = 0x80000000UL, |
| 199 | .size = 0x80000000UL, |
| 200 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 201 | PTE_BLOCK_INNER_SHARE |
| 202 | }, { |
| 203 | .virt = 0x880000000UL, |
| 204 | .phys = 0x880000000UL, |
| 205 | .size = 0x80000000UL, |
| 206 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 207 | PTE_BLOCK_INNER_SHARE |
| 208 | }, { |
| 209 | .virt = 0x500000000UL, |
| 210 | .phys = 0x500000000UL, |
| 211 | .size = 0x400000000UL, |
| 212 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 213 | PTE_BLOCK_NON_SHARE | |
| 214 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 215 | }, { |
| 216 | /* List terminator */ |
| 217 | 0, |
| 218 | } |
| 219 | }; |
| 220 | |
| 221 | struct mm_region *mem_map = j721s2_mem_map; |
| 222 | |
| 223 | #endif /* CONFIG_SOC_K3_J721S2 */ |
| 224 | |
Kamlesh Gurudasani | ae83fe2 | 2023-05-12 17:28:52 +0530 | [diff] [blame] | 225 | #if defined(CONFIG_SOC_K3_AM625) || defined(CONFIG_SOC_K3_AM62A7) |
Bryan Brattlof | daa39a6 | 2022-11-03 19:13:55 -0500 | [diff] [blame] | 226 | |
Keerthy | e07dfe5 | 2021-04-23 11:27:39 -0500 | [diff] [blame] | 227 | /* NR_DRAM_BANKS + 32bit IO + 64bit IO + terminator */ |
Kamlesh Gurudasani | ae83fe2 | 2023-05-12 17:28:52 +0530 | [diff] [blame] | 228 | #define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 4) |
Keerthy | e07dfe5 | 2021-04-23 11:27:39 -0500 | [diff] [blame] | 229 | |
| 230 | /* ToDo: Add 64bit IO */ |
Kamlesh Gurudasani | ae83fe2 | 2023-05-12 17:28:52 +0530 | [diff] [blame] | 231 | struct mm_region am62_mem_map[NR_MMU_REGIONS] = { |
Keerthy | e07dfe5 | 2021-04-23 11:27:39 -0500 | [diff] [blame] | 232 | { |
| 233 | .virt = 0x0UL, |
| 234 | .phys = 0x0UL, |
| 235 | .size = 0x80000000UL, |
| 236 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 237 | PTE_BLOCK_NON_SHARE | |
| 238 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 239 | }, { |
| 240 | .virt = 0x80000000UL, |
| 241 | .phys = 0x80000000UL, |
Kamlesh Gurudasani | ae83fe2 | 2023-05-12 17:28:52 +0530 | [diff] [blame] | 242 | .size = 0x1E780000UL, |
| 243 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 244 | PTE_BLOCK_INNER_SHARE |
| 245 | }, { |
| 246 | .virt = 0xA0000000UL, |
| 247 | .phys = 0xA0000000UL, |
| 248 | .size = 0x60000000UL, |
| 249 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 250 | PTE_BLOCK_INNER_SHARE |
| 251 | |
| 252 | }, { |
| 253 | .virt = 0x880000000UL, |
| 254 | .phys = 0x880000000UL, |
| 255 | .size = 0x80000000UL, |
| 256 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 257 | PTE_BLOCK_INNER_SHARE |
| 258 | }, { |
| 259 | .virt = 0x500000000UL, |
| 260 | .phys = 0x500000000UL, |
| 261 | .size = 0x400000000UL, |
| 262 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 263 | PTE_BLOCK_NON_SHARE | |
| 264 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 265 | }, { |
| 266 | /* List terminator */ |
| 267 | 0, |
| 268 | } |
| 269 | }; |
| 270 | |
| 271 | struct mm_region *mem_map = am62_mem_map; |
| 272 | #endif /* CONFIG_SOC_K3_AM625 || CONFIG_SOC_K3_AM62A7 */ |
| 273 | |
| 274 | #ifdef CONFIG_SOC_K3_AM642 |
| 275 | |
| 276 | /* NR_DRAM_BANKS + 32bit IO + 64bit IO + terminator */ |
| 277 | #define NR_MMU_REGIONS (CONFIG_NR_DRAM_BANKS + 4) |
| 278 | |
| 279 | /* ToDo: Add 64bit IO */ |
| 280 | struct mm_region am64_mem_map[NR_MMU_REGIONS] = { |
| 281 | { |
| 282 | .virt = 0x0UL, |
| 283 | .phys = 0x0UL, |
Keerthy | e07dfe5 | 2021-04-23 11:27:39 -0500 | [diff] [blame] | 284 | .size = 0x80000000UL, |
Kamlesh Gurudasani | ae83fe2 | 2023-05-12 17:28:52 +0530 | [diff] [blame] | 285 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 286 | PTE_BLOCK_NON_SHARE | |
| 287 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 288 | }, { |
| 289 | .virt = 0x80000000UL, |
| 290 | .phys = 0x80000000UL, |
| 291 | .size = 0x1E800000UL, |
| 292 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 293 | PTE_BLOCK_INNER_SHARE |
| 294 | }, { |
| 295 | .virt = 0xA0000000UL, |
| 296 | .phys = 0xA0000000UL, |
| 297 | .size = 0x60000000UL, |
Keerthy | e07dfe5 | 2021-04-23 11:27:39 -0500 | [diff] [blame] | 298 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 299 | PTE_BLOCK_INNER_SHARE |
| 300 | }, { |
| 301 | .virt = 0x880000000UL, |
| 302 | .phys = 0x880000000UL, |
| 303 | .size = 0x80000000UL, |
| 304 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 305 | PTE_BLOCK_INNER_SHARE |
| 306 | }, { |
| 307 | .virt = 0x500000000UL, |
| 308 | .phys = 0x500000000UL, |
| 309 | .size = 0x400000000UL, |
| 310 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 311 | PTE_BLOCK_NON_SHARE | |
| 312 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 313 | }, { |
| 314 | /* List terminator */ |
| 315 | 0, |
| 316 | } |
| 317 | }; |
| 318 | |
| 319 | struct mm_region *mem_map = am64_mem_map; |
Kamlesh Gurudasani | ae83fe2 | 2023-05-12 17:28:52 +0530 | [diff] [blame] | 320 | #endif /* CONFIG_SOC_K3_AM642 */ |