Peng Fan | 5c2218a | 2021-08-07 16:00:31 +0800 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright 2021 NXP |
| 4 | */ |
| 5 | |
Peng Fan | 7253016 | 2021-08-07 16:00:33 +0800 | [diff] [blame] | 6 | #include <asm/io.h> |
| 7 | #include <asm/arch/clock.h> |
| 8 | #include <asm/arch/imx-regs.h> |
Peng Fan | 5c2218a | 2021-08-07 16:00:31 +0800 | [diff] [blame] | 9 | #include <asm/arch/sys_proto.h> |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 10 | #include <asm/armv8/mmu.h> |
Peng Fan | 7253016 | 2021-08-07 16:00:33 +0800 | [diff] [blame] | 11 | #include <asm/mach-imx/boot_mode.h> |
Ye Li | 6dd4302 | 2021-08-07 16:00:48 +0800 | [diff] [blame] | 12 | #include <efi_loader.h> |
| 13 | #include <spl.h> |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 14 | #include <asm/arch/s400_api.h> |
| 15 | #include <asm/arch/mu_hal.h> |
| 16 | #include <cpu_func.h> |
| 17 | #include <asm/setup.h> |
Peng Fan | 5c2218a | 2021-08-07 16:00:31 +0800 | [diff] [blame] | 18 | |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 19 | DECLARE_GLOBAL_DATA_PTR; |
| 20 | |
Ye Li | 7a71c61 | 2021-08-07 16:00:39 +0800 | [diff] [blame] | 21 | struct rom_api *g_rom_api = (struct rom_api *)0x1980; |
| 22 | |
Peng Fan | 5c2218a | 2021-08-07 16:00:31 +0800 | [diff] [blame] | 23 | u32 get_cpu_rev(void) |
| 24 | { |
| 25 | return (MXC_CPU_IMX8ULP << 12) | CHIP_REV_1_0; |
| 26 | } |
Peng Fan | 7253016 | 2021-08-07 16:00:33 +0800 | [diff] [blame] | 27 | |
| 28 | enum bt_mode get_boot_mode(void) |
| 29 | { |
| 30 | u32 bt0_cfg = 0; |
| 31 | |
Ye Li | 0be116e | 2021-08-07 16:00:47 +0800 | [diff] [blame] | 32 | bt0_cfg = readl(CMC1_BASE_ADDR + 0xa0); |
Peng Fan | 7253016 | 2021-08-07 16:00:33 +0800 | [diff] [blame] | 33 | bt0_cfg &= (BT0CFG_LPBOOT_MASK | BT0CFG_DUALBOOT_MASK); |
| 34 | |
| 35 | if (!(bt0_cfg & BT0CFG_LPBOOT_MASK)) { |
| 36 | /* No low power boot */ |
| 37 | if (bt0_cfg & BT0CFG_DUALBOOT_MASK) |
| 38 | return DUAL_BOOT; |
| 39 | else |
| 40 | return SINGLE_BOOT; |
| 41 | } |
| 42 | |
| 43 | return LOW_POWER_BOOT; |
| 44 | } |
| 45 | |
Peng Fan | af4f3b3 | 2021-08-07 16:00:34 +0800 | [diff] [blame] | 46 | #define CMC_SRS_TAMPER BIT(31) |
| 47 | #define CMC_SRS_SECURITY BIT(30) |
| 48 | #define CMC_SRS_TZWDG BIT(29) |
| 49 | #define CMC_SRS_JTAG_RST BIT(28) |
| 50 | #define CMC_SRS_CORE1 BIT(16) |
| 51 | #define CMC_SRS_LOCKUP BIT(15) |
| 52 | #define CMC_SRS_SW BIT(14) |
| 53 | #define CMC_SRS_WDG BIT(13) |
| 54 | #define CMC_SRS_PIN_RESET BIT(8) |
| 55 | #define CMC_SRS_WARM BIT(4) |
| 56 | #define CMC_SRS_HVD BIT(3) |
| 57 | #define CMC_SRS_LVD BIT(2) |
| 58 | #define CMC_SRS_POR BIT(1) |
| 59 | #define CMC_SRS_WUP BIT(0) |
| 60 | |
| 61 | static u32 reset_cause = -1; |
| 62 | |
| 63 | static char *get_reset_cause(char *ret) |
| 64 | { |
| 65 | u32 cause1, cause = 0, srs = 0; |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 66 | void __iomem *reg_ssrs = (void __iomem *)(CMC1_BASE_ADDR + 0x88); |
| 67 | void __iomem *reg_srs = (void __iomem *)(CMC1_BASE_ADDR + 0x80); |
Peng Fan | af4f3b3 | 2021-08-07 16:00:34 +0800 | [diff] [blame] | 68 | |
| 69 | if (!ret) |
| 70 | return "null"; |
| 71 | |
| 72 | srs = readl(reg_srs); |
| 73 | cause1 = readl(reg_ssrs); |
| 74 | |
| 75 | reset_cause = cause1; |
| 76 | |
| 77 | cause = cause1 & (CMC_SRS_POR | CMC_SRS_WUP | CMC_SRS_WARM); |
| 78 | |
| 79 | switch (cause) { |
| 80 | case CMC_SRS_POR: |
| 81 | sprintf(ret, "%s", "POR"); |
| 82 | break; |
| 83 | case CMC_SRS_WUP: |
| 84 | sprintf(ret, "%s", "WUP"); |
| 85 | break; |
| 86 | case CMC_SRS_WARM: |
| 87 | cause = cause1 & (CMC_SRS_WDG | CMC_SRS_SW | |
| 88 | CMC_SRS_JTAG_RST); |
| 89 | switch (cause) { |
| 90 | case CMC_SRS_WDG: |
| 91 | sprintf(ret, "%s", "WARM-WDG"); |
| 92 | break; |
| 93 | case CMC_SRS_SW: |
| 94 | sprintf(ret, "%s", "WARM-SW"); |
| 95 | break; |
| 96 | case CMC_SRS_JTAG_RST: |
| 97 | sprintf(ret, "%s", "WARM-JTAG"); |
| 98 | break; |
| 99 | default: |
| 100 | sprintf(ret, "%s", "WARM-UNKN"); |
| 101 | break; |
| 102 | } |
| 103 | break; |
| 104 | default: |
| 105 | sprintf(ret, "%s-%X", "UNKN", cause1); |
| 106 | break; |
| 107 | } |
| 108 | |
| 109 | debug("[%X] SRS[%X] %X - ", cause1, srs, srs ^ cause1); |
| 110 | return ret; |
| 111 | } |
| 112 | |
Peng Fan | 7253016 | 2021-08-07 16:00:33 +0800 | [diff] [blame] | 113 | #if defined(CONFIG_DISPLAY_CPUINFO) |
| 114 | const char *get_imx_type(u32 imxtype) |
| 115 | { |
| 116 | return "8ULP"; |
| 117 | } |
| 118 | |
| 119 | int print_cpuinfo(void) |
| 120 | { |
| 121 | u32 cpurev; |
| 122 | char cause[18]; |
| 123 | |
| 124 | cpurev = get_cpu_rev(); |
| 125 | |
| 126 | printf("CPU: Freescale i.MX%s rev%d.%d at %d MHz\n", |
| 127 | get_imx_type((cpurev & 0xFF000) >> 12), |
| 128 | (cpurev & 0x000F0) >> 4, (cpurev & 0x0000F) >> 0, |
| 129 | mxc_get_clock(MXC_ARM_CLK) / 1000000); |
| 130 | |
Peng Fan | af4f3b3 | 2021-08-07 16:00:34 +0800 | [diff] [blame] | 131 | printf("Reset cause: %s\n", get_reset_cause(cause)); |
| 132 | |
Peng Fan | 7253016 | 2021-08-07 16:00:33 +0800 | [diff] [blame] | 133 | printf("Boot mode: "); |
| 134 | switch (get_boot_mode()) { |
| 135 | case LOW_POWER_BOOT: |
| 136 | printf("Low power boot\n"); |
| 137 | break; |
| 138 | case DUAL_BOOT: |
| 139 | printf("Dual boot\n"); |
| 140 | break; |
| 141 | case SINGLE_BOOT: |
| 142 | default: |
| 143 | printf("Single boot\n"); |
| 144 | break; |
| 145 | } |
| 146 | |
| 147 | return 0; |
| 148 | } |
| 149 | #endif |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 150 | |
Peng Fan | c84bc10 | 2021-08-07 16:00:49 +0800 | [diff] [blame] | 151 | #define UNLOCK_WORD0 0xC520 /* 1st unlock word */ |
| 152 | #define UNLOCK_WORD1 0xD928 /* 2nd unlock word */ |
| 153 | #define REFRESH_WORD0 0xA602 /* 1st refresh word */ |
| 154 | #define REFRESH_WORD1 0xB480 /* 2nd refresh word */ |
| 155 | |
| 156 | static void disable_wdog(void __iomem *wdog_base) |
| 157 | { |
| 158 | u32 val_cs = readl(wdog_base + 0x00); |
| 159 | |
| 160 | if (!(val_cs & 0x80)) |
| 161 | return; |
| 162 | |
| 163 | dmb(); |
| 164 | __raw_writel(REFRESH_WORD0, (wdog_base + 0x04)); /* Refresh the CNT */ |
| 165 | __raw_writel(REFRESH_WORD1, (wdog_base + 0x04)); |
| 166 | dmb(); |
| 167 | |
| 168 | if (!(val_cs & 800)) { |
| 169 | dmb(); |
| 170 | __raw_writel(UNLOCK_WORD0, (wdog_base + 0x04)); |
| 171 | __raw_writel(UNLOCK_WORD1, (wdog_base + 0x04)); |
| 172 | dmb(); |
| 173 | |
| 174 | while (!(readl(wdog_base + 0x00) & 0x800)) |
| 175 | ; |
| 176 | } |
| 177 | writel(0x0, (wdog_base + 0x0C)); /* Set WIN to 0 */ |
| 178 | writel(0x400, (wdog_base + 0x08)); /* Set timeout to default 0x400 */ |
| 179 | writel(0x120, (wdog_base + 0x00)); /* Disable it and set update */ |
| 180 | |
| 181 | while (!(readl(wdog_base + 0x00) & 0x400)) |
| 182 | ; |
| 183 | } |
| 184 | |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 185 | void init_wdog(void) |
| 186 | { |
Peng Fan | c84bc10 | 2021-08-07 16:00:49 +0800 | [diff] [blame] | 187 | disable_wdog((void __iomem *)WDG3_RBASE); |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 188 | } |
| 189 | |
| 190 | static struct mm_region imx8ulp_arm64_mem_map[] = { |
| 191 | { |
| 192 | /* ROM */ |
| 193 | .virt = 0x0, |
| 194 | .phys = 0x0, |
| 195 | .size = 0x40000UL, |
| 196 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 197 | PTE_BLOCK_OUTER_SHARE |
| 198 | }, |
| 199 | { |
| 200 | /* FLEXSPI0 */ |
| 201 | .virt = 0x04000000, |
| 202 | .phys = 0x04000000, |
| 203 | .size = 0x08000000UL, |
| 204 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 205 | PTE_BLOCK_NON_SHARE | |
| 206 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 207 | }, |
| 208 | { |
| 209 | /* SSRAM (align with 2M) */ |
| 210 | .virt = 0x1FE00000UL, |
| 211 | .phys = 0x1FE00000UL, |
| 212 | .size = 0x400000UL, |
| 213 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 214 | PTE_BLOCK_OUTER_SHARE | |
| 215 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 216 | }, { |
| 217 | /* SRAM1 (align with 2M) */ |
| 218 | .virt = 0x21000000UL, |
| 219 | .phys = 0x21000000UL, |
| 220 | .size = 0x200000UL, |
| 221 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 222 | PTE_BLOCK_OUTER_SHARE | |
| 223 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 224 | }, { |
| 225 | /* SRAM0 (align with 2M) */ |
| 226 | .virt = 0x22000000UL, |
| 227 | .phys = 0x22000000UL, |
| 228 | .size = 0x200000UL, |
| 229 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 230 | PTE_BLOCK_OUTER_SHARE | |
| 231 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 232 | }, { |
| 233 | /* Peripherals */ |
| 234 | .virt = 0x27000000UL, |
| 235 | .phys = 0x27000000UL, |
| 236 | .size = 0x3000000UL, |
| 237 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 238 | PTE_BLOCK_NON_SHARE | |
| 239 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 240 | }, { |
| 241 | /* Peripherals */ |
| 242 | .virt = 0x2D000000UL, |
| 243 | .phys = 0x2D000000UL, |
| 244 | .size = 0x1600000UL, |
| 245 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 246 | PTE_BLOCK_NON_SHARE | |
| 247 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 248 | }, { |
| 249 | /* FLEXSPI1-2 */ |
| 250 | .virt = 0x40000000UL, |
| 251 | .phys = 0x40000000UL, |
| 252 | .size = 0x40000000UL, |
| 253 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 254 | PTE_BLOCK_NON_SHARE | |
| 255 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 256 | }, { |
| 257 | /* DRAM1 */ |
| 258 | .virt = 0x80000000UL, |
| 259 | .phys = 0x80000000UL, |
| 260 | .size = PHYS_SDRAM_SIZE, |
| 261 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 262 | PTE_BLOCK_OUTER_SHARE |
| 263 | }, { |
| 264 | /* |
| 265 | * empty entrie to split table entry 5 |
| 266 | * if needed when TEEs are used |
| 267 | */ |
| 268 | 0, |
| 269 | }, { |
| 270 | /* List terminator */ |
| 271 | 0, |
| 272 | } |
| 273 | }; |
| 274 | |
| 275 | struct mm_region *mem_map = imx8ulp_arm64_mem_map; |
| 276 | |
| 277 | /* simplify the page table size to enhance boot speed */ |
| 278 | #define MAX_PTE_ENTRIES 512 |
| 279 | #define MAX_MEM_MAP_REGIONS 16 |
| 280 | u64 get_page_table_size(void) |
| 281 | { |
| 282 | u64 one_pt = MAX_PTE_ENTRIES * sizeof(u64); |
| 283 | u64 size = 0; |
| 284 | |
| 285 | /* |
| 286 | * For each memory region, the max table size: |
| 287 | * 2 level 3 tables + 2 level 2 tables + 1 level 1 table |
| 288 | */ |
| 289 | size = (2 + 2 + 1) * one_pt * MAX_MEM_MAP_REGIONS + one_pt; |
| 290 | |
| 291 | /* |
| 292 | * We need to duplicate our page table once to have an emergency pt to |
| 293 | * resort to when splitting page tables later on |
| 294 | */ |
| 295 | size *= 2; |
| 296 | |
| 297 | /* |
| 298 | * We may need to split page tables later on if dcache settings change, |
| 299 | * so reserve up to 4 (random pick) page tables for that. |
| 300 | */ |
| 301 | size += one_pt * 4; |
| 302 | |
| 303 | return size; |
| 304 | } |
| 305 | |
| 306 | void enable_caches(void) |
| 307 | { |
| 308 | /* TODO: add TEE memmap region */ |
| 309 | |
| 310 | icache_enable(); |
| 311 | dcache_enable(); |
| 312 | } |
| 313 | |
| 314 | int dram_init(void) |
| 315 | { |
| 316 | gd->ram_size = PHYS_SDRAM_SIZE; |
| 317 | |
| 318 | return 0; |
| 319 | } |
| 320 | |
| 321 | #ifdef CONFIG_SERIAL_TAG |
| 322 | void get_board_serial(struct tag_serialnr *serialnr) |
| 323 | { |
| 324 | /* TODO */ |
| 325 | } |
| 326 | #endif |
| 327 | |
Ye Li | 6ee435eb | 2021-08-07 16:00:50 +0800 | [diff] [blame] | 328 | static void set_core0_reset_vector(u32 entry) |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 329 | { |
Ye Li | 6dd4302 | 2021-08-07 16:00:48 +0800 | [diff] [blame] | 330 | /* Update SIM1 DGO8 for reset vector base */ |
Ye Li | 6ee435eb | 2021-08-07 16:00:50 +0800 | [diff] [blame] | 331 | writel(entry, SIM1_BASE_ADDR + 0x5c); |
Ye Li | 6dd4302 | 2021-08-07 16:00:48 +0800 | [diff] [blame] | 332 | |
| 333 | /* set update bit */ |
| 334 | setbits_le32(SIM1_BASE_ADDR + 0x8, 0x1 << 24); |
| 335 | |
| 336 | /* polling the ack */ |
| 337 | while ((readl(SIM1_BASE_ADDR + 0x8) & (0x1 << 26)) == 0) |
| 338 | ; |
| 339 | |
| 340 | /* clear the update */ |
| 341 | clrbits_le32(SIM1_BASE_ADDR + 0x8, (0x1 << 24)); |
| 342 | |
| 343 | /* clear the ack by set 1 */ |
| 344 | setbits_le32(SIM1_BASE_ADDR + 0x8, (0x1 << 26)); |
Ye Li | 6ee435eb | 2021-08-07 16:00:50 +0800 | [diff] [blame] | 345 | } |
| 346 | |
Peng Fan | fa55b21 | 2021-08-07 16:00:57 +0800 | [diff] [blame^] | 347 | enum rdc_type { |
| 348 | RDC_TRDC, |
| 349 | RDC_XRDC, |
| 350 | }; |
| 351 | |
| 352 | static int release_rdc(enum rdc_type type) |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 353 | { |
| 354 | ulong s_mu_base = 0x27020000UL; |
| 355 | struct imx8ulp_s400_msg msg; |
| 356 | int ret; |
Peng Fan | fa55b21 | 2021-08-07 16:00:57 +0800 | [diff] [blame^] | 357 | u32 rdc_id = (type == RDC_XRDC) ? 0x78 : 0x74; |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 358 | |
| 359 | msg.version = AHAB_VERSION; |
| 360 | msg.tag = AHAB_CMD_TAG; |
| 361 | msg.size = 2; |
| 362 | msg.command = AHAB_RELEASE_RDC_REQ_CID; |
Peng Fan | fa55b21 | 2021-08-07 16:00:57 +0800 | [diff] [blame^] | 363 | msg.data[0] = (rdc_id << 8) | 0x2; /* A35 XRDC */ |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 364 | |
| 365 | mu_hal_init(s_mu_base); |
| 366 | mu_hal_sendmsg(s_mu_base, 0, *((u32 *)&msg)); |
| 367 | mu_hal_sendmsg(s_mu_base, 1, msg.data[0]); |
| 368 | |
| 369 | ret = mu_hal_receivemsg(s_mu_base, 0, (u32 *)&msg); |
| 370 | if (!ret) { |
| 371 | ret = mu_hal_receivemsg(s_mu_base, 1, &msg.data[0]); |
Peng Fan | fa55b21 | 2021-08-07 16:00:57 +0800 | [diff] [blame^] | 372 | if (!ret) { |
| 373 | if ((msg.data[0] & 0xff) == 0xd6) |
| 374 | return 0; |
| 375 | } |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 376 | |
Peng Fan | fa55b21 | 2021-08-07 16:00:57 +0800 | [diff] [blame^] | 377 | return -EIO; |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 378 | } |
| 379 | |
| 380 | return ret; |
| 381 | } |
| 382 | |
| 383 | static void xrdc_mrc_region_set_access(int mrc_index, u32 addr, u32 access) |
| 384 | { |
| 385 | ulong xrdc_base = 0x292f0000, off; |
| 386 | u32 mrgd[5]; |
| 387 | u8 mrcfg, j, region_num; |
| 388 | u8 dsel; |
| 389 | |
| 390 | mrcfg = readb(xrdc_base + 0x140 + mrc_index); |
| 391 | region_num = mrcfg & 0x1f; |
| 392 | |
| 393 | for (j = 0; j < region_num; j++) { |
| 394 | off = 0x2000 + mrc_index * 0x200 + j * 0x20; |
| 395 | |
| 396 | mrgd[0] = readl(xrdc_base + off); |
| 397 | mrgd[1] = readl(xrdc_base + off + 4); |
| 398 | mrgd[2] = readl(xrdc_base + off + 8); |
| 399 | mrgd[3] = readl(xrdc_base + off + 0xc); |
| 400 | mrgd[4] = readl(xrdc_base + off + 0x10); |
| 401 | |
| 402 | debug("MRC [%u][%u]\n", mrc_index, j); |
| 403 | debug("0x%x, 0x%x, 0x%x, 0x%x, 0x%x\n", |
| 404 | mrgd[0], mrgd[1], mrgd[2], mrgd[3], mrgd[4]); |
| 405 | |
| 406 | /* hit */ |
| 407 | if (addr >= mrgd[0] && addr <= mrgd[1]) { |
| 408 | /* find domain 7 DSEL */ |
| 409 | dsel = (mrgd[2] >> 21) & 0x7; |
| 410 | if (dsel == 1) { |
| 411 | mrgd[4] &= ~0xFFF; |
| 412 | mrgd[4] |= (access & 0xFFF); |
| 413 | } else if (dsel == 2) { |
| 414 | mrgd[4] &= ~0xFFF0000; |
| 415 | mrgd[4] |= ((access & 0xFFF) << 16); |
| 416 | } |
| 417 | |
| 418 | /* not handle other cases, since S400 only set ACCESS1 and 2 */ |
| 419 | writel(mrgd[4], xrdc_base + off + 0x10); |
| 420 | return; |
| 421 | } |
| 422 | } |
| 423 | } |
| 424 | |
Ye Li | 6ee435eb | 2021-08-07 16:00:50 +0800 | [diff] [blame] | 425 | int arch_cpu_init(void) |
| 426 | { |
| 427 | if (IS_ENABLED(CONFIG_SPL_BUILD)) { |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 428 | /* Disable wdog */ |
| 429 | init_wdog(); |
| 430 | |
Peng Fan | fa55b21 | 2021-08-07 16:00:57 +0800 | [diff] [blame^] | 431 | if (get_boot_mode() == SINGLE_BOOT) |
| 432 | release_rdc(RDC_TRDC); |
| 433 | |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 434 | /* release xrdc, then allow A35 to write SRAM2 */ |
Peng Fan | fa55b21 | 2021-08-07 16:00:57 +0800 | [diff] [blame^] | 435 | release_rdc(RDC_XRDC); |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 436 | xrdc_mrc_region_set_access(2, CONFIG_SPL_TEXT_BASE, 0xE00); |
| 437 | |
Ye Li | 6ee435eb | 2021-08-07 16:00:50 +0800 | [diff] [blame] | 438 | clock_init(); |
| 439 | } else { |
| 440 | /* reconfigure core0 reset vector to ROM */ |
| 441 | set_core0_reset_vector(0x1000); |
| 442 | } |
| 443 | |
| 444 | return 0; |
| 445 | } |
| 446 | |
| 447 | #if defined(CONFIG_SPL_BUILD) |
| 448 | __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) |
| 449 | { |
| 450 | debug("image entry point: 0x%lx\n", spl_image->entry_point); |
| 451 | |
| 452 | set_core0_reset_vector((u32)spl_image->entry_point); |
Ye Li | 6dd4302 | 2021-08-07 16:00:48 +0800 | [diff] [blame] | 453 | |
| 454 | /* Enable the 512KB cache */ |
| 455 | setbits_le32(SIM1_BASE_ADDR + 0x30, (0x1 << 4)); |
| 456 | |
| 457 | /* reset core */ |
| 458 | setbits_le32(SIM1_BASE_ADDR + 0x30, (0x1 << 16)); |
| 459 | |
| 460 | while (1) |
| 461 | ; |
| 462 | } |
| 463 | #endif |