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 | 88044c7 | 2021-08-07 16:01:01 +0800 | [diff] [blame] | 12 | #include <asm/global_data.h> |
Ye Li | 6dd4302 | 2021-08-07 16:00:48 +0800 | [diff] [blame] | 13 | #include <efi_loader.h> |
Simon Glass | fc55736 | 2022-03-04 08:43:05 -0700 | [diff] [blame] | 14 | #include <event.h> |
Ye Li | 6dd4302 | 2021-08-07 16:00:48 +0800 | [diff] [blame] | 15 | #include <spl.h> |
Peng Fan | 9c87e46 | 2021-08-07 16:00:59 +0800 | [diff] [blame] | 16 | #include <asm/arch/rdc.h> |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 17 | #include <asm/arch/s400_api.h> |
| 18 | #include <asm/arch/mu_hal.h> |
| 19 | #include <cpu_func.h> |
| 20 | #include <asm/setup.h> |
Ye Li | 7bea5b0 | 2021-08-07 16:01:00 +0800 | [diff] [blame] | 21 | #include <dm.h> |
| 22 | #include <dm/device-internal.h> |
| 23 | #include <dm/lists.h> |
| 24 | #include <dm/uclass.h> |
| 25 | #include <dm/device.h> |
| 26 | #include <dm/uclass-internal.h> |
Ye Li | 7201262 | 2021-10-29 09:46:15 +0800 | [diff] [blame] | 27 | #include <fuse.h> |
Alice Guo | f2c4a39 | 2021-10-29 09:46:32 +0800 | [diff] [blame] | 28 | #include <thermal.h> |
Ye Li | 2e9f15c | 2022-04-06 14:30:08 +0800 | [diff] [blame] | 29 | #include <linux/iopoll.h> |
Ye Li | 48836ae | 2022-04-06 14:30:30 +0800 | [diff] [blame] | 30 | #include <env.h> |
| 31 | #include <env_internal.h> |
Peng Fan | 5c2218a | 2021-08-07 16:00:31 +0800 | [diff] [blame] | 32 | |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
Ye Li | 7a71c61 | 2021-08-07 16:00:39 +0800 | [diff] [blame] | 35 | struct rom_api *g_rom_api = (struct rom_api *)0x1980; |
| 36 | |
Ye Li | 88044c7 | 2021-08-07 16:01:01 +0800 | [diff] [blame] | 37 | enum boot_device get_boot_device(void) |
| 38 | { |
| 39 | volatile gd_t *pgd = gd; |
| 40 | int ret; |
| 41 | u32 boot; |
| 42 | u16 boot_type; |
| 43 | u8 boot_instance; |
| 44 | enum boot_device boot_dev = SD1_BOOT; |
| 45 | |
| 46 | ret = g_rom_api->query_boot_infor(QUERY_BT_DEV, &boot, |
| 47 | ((uintptr_t)&boot) ^ QUERY_BT_DEV); |
| 48 | set_gd(pgd); |
| 49 | |
| 50 | if (ret != ROM_API_OKAY) { |
| 51 | puts("ROMAPI: failure at query_boot_info\n"); |
| 52 | return -1; |
| 53 | } |
| 54 | |
| 55 | boot_type = boot >> 16; |
| 56 | boot_instance = (boot >> 8) & 0xff; |
| 57 | |
| 58 | switch (boot_type) { |
| 59 | case BT_DEV_TYPE_SD: |
| 60 | boot_dev = boot_instance + SD1_BOOT; |
| 61 | break; |
| 62 | case BT_DEV_TYPE_MMC: |
| 63 | boot_dev = boot_instance + MMC1_BOOT; |
| 64 | break; |
| 65 | case BT_DEV_TYPE_NAND: |
| 66 | boot_dev = NAND_BOOT; |
| 67 | break; |
| 68 | case BT_DEV_TYPE_FLEXSPINOR: |
| 69 | boot_dev = QSPI_BOOT; |
| 70 | break; |
| 71 | case BT_DEV_TYPE_USB: |
| 72 | boot_dev = USB_BOOT; |
| 73 | break; |
| 74 | default: |
| 75 | break; |
| 76 | } |
| 77 | |
| 78 | return boot_dev; |
| 79 | } |
| 80 | |
| 81 | bool is_usb_boot(void) |
| 82 | { |
| 83 | return get_boot_device() == USB_BOOT; |
| 84 | } |
| 85 | |
| 86 | #ifdef CONFIG_ENV_IS_IN_MMC |
| 87 | __weak int board_mmc_get_env_dev(int devno) |
| 88 | { |
| 89 | return devno; |
| 90 | } |
| 91 | |
| 92 | int mmc_get_env_dev(void) |
| 93 | { |
| 94 | volatile gd_t *pgd = gd; |
| 95 | int ret; |
| 96 | u32 boot; |
| 97 | u16 boot_type; |
| 98 | u8 boot_instance; |
| 99 | |
| 100 | ret = g_rom_api->query_boot_infor(QUERY_BT_DEV, &boot, |
| 101 | ((uintptr_t)&boot) ^ QUERY_BT_DEV); |
| 102 | set_gd(pgd); |
| 103 | |
| 104 | if (ret != ROM_API_OKAY) { |
| 105 | puts("ROMAPI: failure at query_boot_info\n"); |
| 106 | return CONFIG_SYS_MMC_ENV_DEV; |
| 107 | } |
| 108 | |
| 109 | boot_type = boot >> 16; |
| 110 | boot_instance = (boot >> 8) & 0xff; |
| 111 | |
| 112 | /* If not boot from sd/mmc, use default value */ |
| 113 | if (boot_type != BOOT_TYPE_SD && boot_type != BOOT_TYPE_MMC) |
| 114 | return env_get_ulong("mmcdev", 10, CONFIG_SYS_MMC_ENV_DEV); |
| 115 | |
| 116 | return board_mmc_get_env_dev(boot_instance); |
| 117 | } |
| 118 | #endif |
| 119 | |
Peng Fan | 5c2218a | 2021-08-07 16:00:31 +0800 | [diff] [blame] | 120 | u32 get_cpu_rev(void) |
| 121 | { |
| 122 | return (MXC_CPU_IMX8ULP << 12) | CHIP_REV_1_0; |
| 123 | } |
Peng Fan | 7253016 | 2021-08-07 16:00:33 +0800 | [diff] [blame] | 124 | |
| 125 | enum bt_mode get_boot_mode(void) |
| 126 | { |
| 127 | u32 bt0_cfg = 0; |
| 128 | |
Ye Li | 0e35805 | 2021-08-07 16:01:07 +0800 | [diff] [blame] | 129 | bt0_cfg = readl(SIM_SEC_BASE_ADDR + 0x24); |
Peng Fan | 7253016 | 2021-08-07 16:00:33 +0800 | [diff] [blame] | 130 | bt0_cfg &= (BT0CFG_LPBOOT_MASK | BT0CFG_DUALBOOT_MASK); |
| 131 | |
| 132 | if (!(bt0_cfg & BT0CFG_LPBOOT_MASK)) { |
| 133 | /* No low power boot */ |
| 134 | if (bt0_cfg & BT0CFG_DUALBOOT_MASK) |
| 135 | return DUAL_BOOT; |
| 136 | else |
| 137 | return SINGLE_BOOT; |
| 138 | } |
| 139 | |
| 140 | return LOW_POWER_BOOT; |
| 141 | } |
| 142 | |
Ye Li | 2e9f15c | 2022-04-06 14:30:08 +0800 | [diff] [blame] | 143 | bool m33_image_booted(void) |
| 144 | { |
| 145 | u32 gp6; |
| 146 | |
| 147 | /* DGO_GP6 */ |
| 148 | gp6 = readl(SIM_SEC_BASE_ADDR + 0x28); |
| 149 | if (gp6 & BIT(5)) |
| 150 | return true; |
| 151 | |
| 152 | return false; |
| 153 | } |
| 154 | |
| 155 | int m33_image_handshake(ulong timeout_ms) |
| 156 | { |
| 157 | u32 fsr; |
| 158 | int ret; |
| 159 | ulong timeout_us = timeout_ms * 1000; |
| 160 | |
Ye Li | 2e9f15c | 2022-04-06 14:30:08 +0800 | [diff] [blame] | 161 | /* Notify m33 that it's ready to do init srtm(enable mu receive interrupt and so on) */ |
| 162 | setbits_le32(MU0_B_BASE_ADDR + 0x100, BIT(0)); /* set FCR F0 flag of MU0_MUB */ |
| 163 | |
| 164 | /* |
| 165 | * Wait m33 to set FCR F0 flag of MU0_MUA |
| 166 | * Clear FCR F0 flag of MU0_MUB after m33 has set FCR F0 flag of MU0_MUA |
| 167 | */ |
| 168 | ret = readl_poll_sleep_timeout(MU0_B_BASE_ADDR + 0x104, fsr, fsr & BIT(0), 10, timeout_us); |
| 169 | if (!ret) |
| 170 | clrbits_le32(MU0_B_BASE_ADDR + 0x100, BIT(0)); |
| 171 | |
| 172 | return ret; |
| 173 | } |
| 174 | |
Peng Fan | af4f3b3 | 2021-08-07 16:00:34 +0800 | [diff] [blame] | 175 | #define CMC_SRS_TAMPER BIT(31) |
| 176 | #define CMC_SRS_SECURITY BIT(30) |
| 177 | #define CMC_SRS_TZWDG BIT(29) |
| 178 | #define CMC_SRS_JTAG_RST BIT(28) |
| 179 | #define CMC_SRS_CORE1 BIT(16) |
| 180 | #define CMC_SRS_LOCKUP BIT(15) |
| 181 | #define CMC_SRS_SW BIT(14) |
| 182 | #define CMC_SRS_WDG BIT(13) |
| 183 | #define CMC_SRS_PIN_RESET BIT(8) |
| 184 | #define CMC_SRS_WARM BIT(4) |
| 185 | #define CMC_SRS_HVD BIT(3) |
| 186 | #define CMC_SRS_LVD BIT(2) |
| 187 | #define CMC_SRS_POR BIT(1) |
| 188 | #define CMC_SRS_WUP BIT(0) |
| 189 | |
Peng Fan | af4f3b3 | 2021-08-07 16:00:34 +0800 | [diff] [blame] | 190 | static char *get_reset_cause(char *ret) |
| 191 | { |
| 192 | u32 cause1, cause = 0, srs = 0; |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 193 | void __iomem *reg_ssrs = (void __iomem *)(CMC1_BASE_ADDR + 0x88); |
| 194 | void __iomem *reg_srs = (void __iomem *)(CMC1_BASE_ADDR + 0x80); |
Peng Fan | af4f3b3 | 2021-08-07 16:00:34 +0800 | [diff] [blame] | 195 | |
| 196 | if (!ret) |
| 197 | return "null"; |
| 198 | |
| 199 | srs = readl(reg_srs); |
| 200 | cause1 = readl(reg_ssrs); |
| 201 | |
Peng Fan | 0d720e2 | 2021-08-07 16:01:06 +0800 | [diff] [blame] | 202 | cause = srs & (CMC_SRS_POR | CMC_SRS_WUP | CMC_SRS_WARM); |
Peng Fan | af4f3b3 | 2021-08-07 16:00:34 +0800 | [diff] [blame] | 203 | |
| 204 | switch (cause) { |
| 205 | case CMC_SRS_POR: |
| 206 | sprintf(ret, "%s", "POR"); |
| 207 | break; |
| 208 | case CMC_SRS_WUP: |
| 209 | sprintf(ret, "%s", "WUP"); |
| 210 | break; |
| 211 | case CMC_SRS_WARM: |
Peng Fan | 0d720e2 | 2021-08-07 16:01:06 +0800 | [diff] [blame] | 212 | cause = srs & (CMC_SRS_WDG | CMC_SRS_SW | |
Peng Fan | af4f3b3 | 2021-08-07 16:00:34 +0800 | [diff] [blame] | 213 | CMC_SRS_JTAG_RST); |
| 214 | switch (cause) { |
| 215 | case CMC_SRS_WDG: |
| 216 | sprintf(ret, "%s", "WARM-WDG"); |
| 217 | break; |
| 218 | case CMC_SRS_SW: |
| 219 | sprintf(ret, "%s", "WARM-SW"); |
| 220 | break; |
| 221 | case CMC_SRS_JTAG_RST: |
| 222 | sprintf(ret, "%s", "WARM-JTAG"); |
| 223 | break; |
| 224 | default: |
| 225 | sprintf(ret, "%s", "WARM-UNKN"); |
| 226 | break; |
| 227 | } |
| 228 | break; |
| 229 | default: |
Peng Fan | 0d720e2 | 2021-08-07 16:01:06 +0800 | [diff] [blame] | 230 | sprintf(ret, "%s-%X", "UNKN", srs); |
Peng Fan | af4f3b3 | 2021-08-07 16:00:34 +0800 | [diff] [blame] | 231 | break; |
| 232 | } |
| 233 | |
| 234 | debug("[%X] SRS[%X] %X - ", cause1, srs, srs ^ cause1); |
| 235 | return ret; |
| 236 | } |
| 237 | |
Peng Fan | 7253016 | 2021-08-07 16:00:33 +0800 | [diff] [blame] | 238 | #if defined(CONFIG_DISPLAY_CPUINFO) |
| 239 | const char *get_imx_type(u32 imxtype) |
| 240 | { |
| 241 | return "8ULP"; |
| 242 | } |
| 243 | |
| 244 | int print_cpuinfo(void) |
| 245 | { |
| 246 | u32 cpurev; |
| 247 | char cause[18]; |
| 248 | |
| 249 | cpurev = get_cpu_rev(); |
| 250 | |
Ye Li | f012ceb | 2021-10-29 09:46:24 +0800 | [diff] [blame] | 251 | printf("CPU: i.MX%s rev%d.%d at %d MHz\n", |
Peng Fan | 7253016 | 2021-08-07 16:00:33 +0800 | [diff] [blame] | 252 | get_imx_type((cpurev & 0xFF000) >> 12), |
| 253 | (cpurev & 0x000F0) >> 4, (cpurev & 0x0000F) >> 0, |
| 254 | mxc_get_clock(MXC_ARM_CLK) / 1000000); |
| 255 | |
Alice Guo | f2c4a39 | 2021-10-29 09:46:32 +0800 | [diff] [blame] | 256 | #if defined(CONFIG_IMX_PMC_TEMPERATURE) |
| 257 | struct udevice *udev; |
| 258 | int ret, temp; |
| 259 | |
| 260 | ret = uclass_get_device(UCLASS_THERMAL, 0, &udev); |
| 261 | if (!ret) { |
| 262 | ret = thermal_get_temp(udev, &temp); |
| 263 | if (!ret) |
| 264 | printf("CPU current temperature: %d\n", temp); |
| 265 | else |
| 266 | debug(" - failed to get CPU current temperature\n"); |
| 267 | } else { |
| 268 | debug(" - failed to get CPU current temperature\n"); |
| 269 | } |
| 270 | #endif |
| 271 | |
Peng Fan | af4f3b3 | 2021-08-07 16:00:34 +0800 | [diff] [blame] | 272 | printf("Reset cause: %s\n", get_reset_cause(cause)); |
| 273 | |
Peng Fan | 7253016 | 2021-08-07 16:00:33 +0800 | [diff] [blame] | 274 | printf("Boot mode: "); |
| 275 | switch (get_boot_mode()) { |
| 276 | case LOW_POWER_BOOT: |
| 277 | printf("Low power boot\n"); |
| 278 | break; |
| 279 | case DUAL_BOOT: |
| 280 | printf("Dual boot\n"); |
| 281 | break; |
| 282 | case SINGLE_BOOT: |
| 283 | default: |
| 284 | printf("Single boot\n"); |
| 285 | break; |
| 286 | } |
| 287 | |
| 288 | return 0; |
| 289 | } |
| 290 | #endif |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 291 | |
Peng Fan | c84bc10 | 2021-08-07 16:00:49 +0800 | [diff] [blame] | 292 | #define UNLOCK_WORD0 0xC520 /* 1st unlock word */ |
| 293 | #define UNLOCK_WORD1 0xD928 /* 2nd unlock word */ |
| 294 | #define REFRESH_WORD0 0xA602 /* 1st refresh word */ |
| 295 | #define REFRESH_WORD1 0xB480 /* 2nd refresh word */ |
| 296 | |
| 297 | static void disable_wdog(void __iomem *wdog_base) |
| 298 | { |
| 299 | u32 val_cs = readl(wdog_base + 0x00); |
| 300 | |
| 301 | if (!(val_cs & 0x80)) |
| 302 | return; |
| 303 | |
| 304 | dmb(); |
| 305 | __raw_writel(REFRESH_WORD0, (wdog_base + 0x04)); /* Refresh the CNT */ |
| 306 | __raw_writel(REFRESH_WORD1, (wdog_base + 0x04)); |
| 307 | dmb(); |
| 308 | |
| 309 | if (!(val_cs & 800)) { |
| 310 | dmb(); |
| 311 | __raw_writel(UNLOCK_WORD0, (wdog_base + 0x04)); |
| 312 | __raw_writel(UNLOCK_WORD1, (wdog_base + 0x04)); |
| 313 | dmb(); |
| 314 | |
| 315 | while (!(readl(wdog_base + 0x00) & 0x800)) |
| 316 | ; |
| 317 | } |
| 318 | writel(0x0, (wdog_base + 0x0C)); /* Set WIN to 0 */ |
| 319 | writel(0x400, (wdog_base + 0x08)); /* Set timeout to default 0x400 */ |
| 320 | writel(0x120, (wdog_base + 0x00)); /* Disable it and set update */ |
| 321 | |
| 322 | while (!(readl(wdog_base + 0x00) & 0x400)) |
| 323 | ; |
| 324 | } |
| 325 | |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 326 | void init_wdog(void) |
| 327 | { |
Peng Fan | c84bc10 | 2021-08-07 16:00:49 +0800 | [diff] [blame] | 328 | disable_wdog((void __iomem *)WDG3_RBASE); |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | static struct mm_region imx8ulp_arm64_mem_map[] = { |
| 332 | { |
| 333 | /* ROM */ |
| 334 | .virt = 0x0, |
| 335 | .phys = 0x0, |
| 336 | .size = 0x40000UL, |
| 337 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 338 | PTE_BLOCK_OUTER_SHARE |
| 339 | }, |
| 340 | { |
| 341 | /* FLEXSPI0 */ |
| 342 | .virt = 0x04000000, |
| 343 | .phys = 0x04000000, |
| 344 | .size = 0x08000000UL, |
| 345 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 346 | PTE_BLOCK_NON_SHARE | |
| 347 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 348 | }, |
| 349 | { |
| 350 | /* SSRAM (align with 2M) */ |
| 351 | .virt = 0x1FE00000UL, |
| 352 | .phys = 0x1FE00000UL, |
| 353 | .size = 0x400000UL, |
| 354 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 355 | PTE_BLOCK_OUTER_SHARE | |
| 356 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 357 | }, { |
| 358 | /* SRAM1 (align with 2M) */ |
| 359 | .virt = 0x21000000UL, |
| 360 | .phys = 0x21000000UL, |
| 361 | .size = 0x200000UL, |
| 362 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 363 | PTE_BLOCK_OUTER_SHARE | |
| 364 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 365 | }, { |
| 366 | /* SRAM0 (align with 2M) */ |
| 367 | .virt = 0x22000000UL, |
| 368 | .phys = 0x22000000UL, |
| 369 | .size = 0x200000UL, |
| 370 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 371 | PTE_BLOCK_OUTER_SHARE | |
| 372 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 373 | }, { |
| 374 | /* Peripherals */ |
| 375 | .virt = 0x27000000UL, |
| 376 | .phys = 0x27000000UL, |
| 377 | .size = 0x3000000UL, |
| 378 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 379 | PTE_BLOCK_NON_SHARE | |
| 380 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 381 | }, { |
| 382 | /* Peripherals */ |
| 383 | .virt = 0x2D000000UL, |
| 384 | .phys = 0x2D000000UL, |
| 385 | .size = 0x1600000UL, |
| 386 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 387 | PTE_BLOCK_NON_SHARE | |
| 388 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 389 | }, { |
| 390 | /* FLEXSPI1-2 */ |
| 391 | .virt = 0x40000000UL, |
| 392 | .phys = 0x40000000UL, |
| 393 | .size = 0x40000000UL, |
| 394 | .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) | |
| 395 | PTE_BLOCK_NON_SHARE | |
| 396 | PTE_BLOCK_PXN | PTE_BLOCK_UXN |
| 397 | }, { |
| 398 | /* DRAM1 */ |
| 399 | .virt = 0x80000000UL, |
| 400 | .phys = 0x80000000UL, |
| 401 | .size = PHYS_SDRAM_SIZE, |
| 402 | .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) | |
| 403 | PTE_BLOCK_OUTER_SHARE |
| 404 | }, { |
| 405 | /* |
| 406 | * empty entrie to split table entry 5 |
| 407 | * if needed when TEEs are used |
| 408 | */ |
| 409 | 0, |
| 410 | }, { |
| 411 | /* List terminator */ |
| 412 | 0, |
| 413 | } |
| 414 | }; |
| 415 | |
| 416 | struct mm_region *mem_map = imx8ulp_arm64_mem_map; |
| 417 | |
Ji Luo | 2fd258c | 2022-04-06 14:30:28 +0800 | [diff] [blame] | 418 | static unsigned int imx8ulp_find_dram_entry_in_mem_map(void) |
| 419 | { |
| 420 | int i; |
| 421 | |
| 422 | for (i = 0; i < ARRAY_SIZE(imx8ulp_arm64_mem_map); i++) |
| 423 | if (imx8ulp_arm64_mem_map[i].phys == CONFIG_SYS_SDRAM_BASE) |
| 424 | return i; |
| 425 | |
| 426 | hang(); /* Entry not found, this must never happen. */ |
| 427 | } |
| 428 | |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 429 | /* simplify the page table size to enhance boot speed */ |
| 430 | #define MAX_PTE_ENTRIES 512 |
| 431 | #define MAX_MEM_MAP_REGIONS 16 |
| 432 | u64 get_page_table_size(void) |
| 433 | { |
| 434 | u64 one_pt = MAX_PTE_ENTRIES * sizeof(u64); |
| 435 | u64 size = 0; |
| 436 | |
| 437 | /* |
| 438 | * For each memory region, the max table size: |
| 439 | * 2 level 3 tables + 2 level 2 tables + 1 level 1 table |
| 440 | */ |
| 441 | size = (2 + 2 + 1) * one_pt * MAX_MEM_MAP_REGIONS + one_pt; |
| 442 | |
| 443 | /* |
| 444 | * We need to duplicate our page table once to have an emergency pt to |
| 445 | * resort to when splitting page tables later on |
| 446 | */ |
| 447 | size *= 2; |
| 448 | |
| 449 | /* |
| 450 | * We may need to split page tables later on if dcache settings change, |
| 451 | * so reserve up to 4 (random pick) page tables for that. |
| 452 | */ |
| 453 | size += one_pt * 4; |
| 454 | |
| 455 | return size; |
| 456 | } |
| 457 | |
| 458 | void enable_caches(void) |
| 459 | { |
Ji Luo | 2fd258c | 2022-04-06 14:30:28 +0800 | [diff] [blame] | 460 | /* If OPTEE runs, remove OPTEE memory from MMU table to avoid speculative prefetch */ |
| 461 | if (rom_pointer[1]) { |
| 462 | /* |
| 463 | * TEE are loaded, So the ddr bank structures |
| 464 | * have been modified update mmu table accordingly |
| 465 | */ |
| 466 | int i = 0; |
| 467 | int entry = imx8ulp_find_dram_entry_in_mem_map(); |
| 468 | u64 attrs = imx8ulp_arm64_mem_map[entry].attrs; |
| 469 | |
| 470 | while (i < CONFIG_NR_DRAM_BANKS && |
| 471 | entry < ARRAY_SIZE(imx8ulp_arm64_mem_map)) { |
| 472 | if (gd->bd->bi_dram[i].start == 0) |
| 473 | break; |
| 474 | imx8ulp_arm64_mem_map[entry].phys = gd->bd->bi_dram[i].start; |
| 475 | imx8ulp_arm64_mem_map[entry].virt = gd->bd->bi_dram[i].start; |
| 476 | imx8ulp_arm64_mem_map[entry].size = gd->bd->bi_dram[i].size; |
| 477 | imx8ulp_arm64_mem_map[entry].attrs = attrs; |
| 478 | debug("Added memory mapping (%d): %llx %llx\n", entry, |
| 479 | imx8ulp_arm64_mem_map[entry].phys, imx8ulp_arm64_mem_map[entry].size); |
| 480 | i++; entry++; |
| 481 | } |
| 482 | } |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 483 | |
| 484 | icache_enable(); |
| 485 | dcache_enable(); |
| 486 | } |
| 487 | |
Ji Luo | 2fd258c | 2022-04-06 14:30:28 +0800 | [diff] [blame] | 488 | __weak int board_phys_sdram_size(phys_size_t *size) |
| 489 | { |
| 490 | if (!size) |
| 491 | return -EINVAL; |
| 492 | |
| 493 | *size = PHYS_SDRAM_SIZE; |
| 494 | return 0; |
| 495 | } |
| 496 | |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 497 | int dram_init(void) |
| 498 | { |
Ji Luo | 2fd258c | 2022-04-06 14:30:28 +0800 | [diff] [blame] | 499 | unsigned int entry = imx8ulp_find_dram_entry_in_mem_map(); |
| 500 | phys_size_t sdram_size; |
| 501 | int ret; |
| 502 | |
| 503 | ret = board_phys_sdram_size(&sdram_size); |
| 504 | if (ret) |
| 505 | return ret; |
| 506 | |
| 507 | /* rom_pointer[1] contains the size of TEE occupies */ |
| 508 | if (rom_pointer[1]) |
| 509 | gd->ram_size = sdram_size - rom_pointer[1]; |
| 510 | else |
| 511 | gd->ram_size = sdram_size; |
| 512 | |
| 513 | /* also update the SDRAM size in the mem_map used externally */ |
| 514 | imx8ulp_arm64_mem_map[entry].size = sdram_size; |
| 515 | return 0; |
| 516 | } |
| 517 | |
| 518 | int dram_init_banksize(void) |
| 519 | { |
| 520 | int bank = 0; |
| 521 | int ret; |
| 522 | phys_size_t sdram_size; |
| 523 | |
| 524 | ret = board_phys_sdram_size(&sdram_size); |
| 525 | if (ret) |
| 526 | return ret; |
| 527 | |
| 528 | gd->bd->bi_dram[bank].start = PHYS_SDRAM; |
| 529 | if (rom_pointer[1]) { |
| 530 | phys_addr_t optee_start = (phys_addr_t)rom_pointer[0]; |
| 531 | phys_size_t optee_size = (size_t)rom_pointer[1]; |
| 532 | |
| 533 | gd->bd->bi_dram[bank].size = optee_start - gd->bd->bi_dram[bank].start; |
| 534 | if ((optee_start + optee_size) < (PHYS_SDRAM + sdram_size)) { |
| 535 | if (++bank >= CONFIG_NR_DRAM_BANKS) { |
| 536 | puts("CONFIG_NR_DRAM_BANKS is not enough\n"); |
| 537 | return -1; |
| 538 | } |
| 539 | |
| 540 | gd->bd->bi_dram[bank].start = optee_start + optee_size; |
| 541 | gd->bd->bi_dram[bank].size = PHYS_SDRAM + |
| 542 | sdram_size - gd->bd->bi_dram[bank].start; |
| 543 | } |
| 544 | } else { |
| 545 | gd->bd->bi_dram[bank].size = sdram_size; |
| 546 | } |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 547 | |
| 548 | return 0; |
| 549 | } |
| 550 | |
Ji Luo | 2fd258c | 2022-04-06 14:30:28 +0800 | [diff] [blame] | 551 | phys_size_t get_effective_memsize(void) |
| 552 | { |
| 553 | /* return the first bank as effective memory */ |
| 554 | if (rom_pointer[1]) |
| 555 | return ((phys_addr_t)rom_pointer[0] - PHYS_SDRAM); |
| 556 | |
| 557 | return gd->ram_size; |
| 558 | } |
| 559 | |
Tom Rini | ae21e7f | 2021-08-30 09:16:29 -0400 | [diff] [blame] | 560 | #ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 561 | void get_board_serial(struct tag_serialnr *serialnr) |
| 562 | { |
Ye Li | 7bea5b0 | 2021-08-07 16:01:00 +0800 | [diff] [blame] | 563 | u32 uid[4]; |
| 564 | u32 res; |
| 565 | int ret; |
| 566 | |
| 567 | ret = ahab_read_common_fuse(1, uid, 4, &res); |
| 568 | if (ret) |
| 569 | printf("ahab read fuse failed %d, 0x%x\n", ret, res); |
| 570 | else |
| 571 | printf("UID 0x%x,0x%x,0x%x,0x%x\n", uid[0], uid[1], uid[2], uid[3]); |
| 572 | |
| 573 | serialnr->low = uid[0]; |
| 574 | serialnr->high = uid[3]; |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 575 | } |
| 576 | #endif |
| 577 | |
Ye Li | 6ee435eb | 2021-08-07 16:00:50 +0800 | [diff] [blame] | 578 | static void set_core0_reset_vector(u32 entry) |
Peng Fan | b15705a | 2021-08-07 16:00:35 +0800 | [diff] [blame] | 579 | { |
Ye Li | 6dd4302 | 2021-08-07 16:00:48 +0800 | [diff] [blame] | 580 | /* Update SIM1 DGO8 for reset vector base */ |
Ye Li | 6ee435eb | 2021-08-07 16:00:50 +0800 | [diff] [blame] | 581 | writel(entry, SIM1_BASE_ADDR + 0x5c); |
Ye Li | 6dd4302 | 2021-08-07 16:00:48 +0800 | [diff] [blame] | 582 | |
| 583 | /* set update bit */ |
| 584 | setbits_le32(SIM1_BASE_ADDR + 0x8, 0x1 << 24); |
| 585 | |
| 586 | /* polling the ack */ |
| 587 | while ((readl(SIM1_BASE_ADDR + 0x8) & (0x1 << 26)) == 0) |
| 588 | ; |
| 589 | |
| 590 | /* clear the update */ |
| 591 | clrbits_le32(SIM1_BASE_ADDR + 0x8, (0x1 << 24)); |
| 592 | |
| 593 | /* clear the ack by set 1 */ |
| 594 | setbits_le32(SIM1_BASE_ADDR + 0x8, (0x1 << 26)); |
Ye Li | 6ee435eb | 2021-08-07 16:00:50 +0800 | [diff] [blame] | 595 | } |
| 596 | |
Peng Fan | 9c87e46 | 2021-08-07 16:00:59 +0800 | [diff] [blame] | 597 | static int trdc_set_access(void) |
Peng Fan | b5c41b1 | 2021-08-07 16:00:58 +0800 | [diff] [blame] | 598 | { |
| 599 | /* |
Peng Fan | 9c87e46 | 2021-08-07 16:00:59 +0800 | [diff] [blame] | 600 | * TRDC mgr + 4 MBC + 2 MRC. |
| 601 | * S400 should already configure when release RDC |
| 602 | * A35 only map non-secure region for pbridge0 and 1, set sec_access to false |
Peng Fan | b5c41b1 | 2021-08-07 16:00:58 +0800 | [diff] [blame] | 603 | */ |
Peng Fan | 9c87e46 | 2021-08-07 16:00:59 +0800 | [diff] [blame] | 604 | trdc_mbc_set_access(2, 7, 0, 49, false); |
| 605 | trdc_mbc_set_access(2, 7, 0, 50, false); |
| 606 | trdc_mbc_set_access(2, 7, 0, 51, false); |
| 607 | trdc_mbc_set_access(2, 7, 0, 52, false); |
| 608 | trdc_mbc_set_access(2, 7, 0, 53, false); |
| 609 | trdc_mbc_set_access(2, 7, 0, 54, false); |
Peng Fan | b5c41b1 | 2021-08-07 16:00:58 +0800 | [diff] [blame] | 610 | |
Peng Fan | 9c87e46 | 2021-08-07 16:00:59 +0800 | [diff] [blame] | 611 | /* CGC0: PBridge0 slot 47 */ |
| 612 | trdc_mbc_set_access(2, 7, 0, 47, false); |
Peng Fan | b5c41b1 | 2021-08-07 16:00:58 +0800 | [diff] [blame] | 613 | |
Peng Fan | 9c87e46 | 2021-08-07 16:00:59 +0800 | [diff] [blame] | 614 | /* Iomuxc0: : PBridge1 slot 33 */ |
| 615 | trdc_mbc_set_access(2, 7, 1, 33, false); |
Peng Fan | b5c41b1 | 2021-08-07 16:00:58 +0800 | [diff] [blame] | 616 | |
Ye Li | d325d37 | 2021-10-29 09:46:20 +0800 | [diff] [blame] | 617 | /* flexspi0 */ |
| 618 | trdc_mrc_region_set_access(0, 7, 0x04000000, 0x0c000000, false); |
Ye Li | 27666ca | 2021-10-29 09:46:21 +0800 | [diff] [blame] | 619 | |
| 620 | /* tpm0: PBridge1 slot 21 */ |
| 621 | trdc_mbc_set_access(2, 7, 1, 21, false); |
| 622 | /* lpi2c0: PBridge1 slot 24 */ |
| 623 | trdc_mbc_set_access(2, 7, 1, 24, false); |
Peng Fan | b5c41b1 | 2021-08-07 16:00:58 +0800 | [diff] [blame] | 624 | return 0; |
| 625 | } |
| 626 | |
Ye Li | ec10a80 | 2022-04-06 14:30:17 +0800 | [diff] [blame] | 627 | void lpav_configure(bool lpav_to_m33) |
Ye Li | 43819eb | 2021-10-29 09:46:16 +0800 | [diff] [blame] | 628 | { |
Ye Li | ec10a80 | 2022-04-06 14:30:17 +0800 | [diff] [blame] | 629 | if (!lpav_to_m33) |
| 630 | setbits_le32(SIM_SEC_BASE_ADDR + 0x44, BIT(7)); /* LPAV to APD */ |
Ye Li | 43819eb | 2021-10-29 09:46:16 +0800 | [diff] [blame] | 631 | |
Peng Fan | fa609b4 | 2021-10-29 09:46:17 +0800 | [diff] [blame] | 632 | /* PXP/GPU 2D/3D/DCNANO/MIPI_DSI/EPDC/HIFI4 to APD */ |
| 633 | setbits_le32(SIM_SEC_BASE_ADDR + 0x4c, 0x7F); |
Ye Li | 43819eb | 2021-10-29 09:46:16 +0800 | [diff] [blame] | 634 | |
| 635 | /* LPAV slave/dma2 ch allocation and request allocation to APD */ |
| 636 | writel(0x1f, SIM_SEC_BASE_ADDR + 0x50); |
| 637 | writel(0xffffffff, SIM_SEC_BASE_ADDR + 0x54); |
| 638 | writel(0x003fffff, SIM_SEC_BASE_ADDR + 0x58); |
Ye Li | 715cfa0 | 2021-10-29 09:46:23 +0800 | [diff] [blame] | 639 | } |
Ye Li | a031155 | 2021-10-29 09:46:22 +0800 | [diff] [blame] | 640 | |
Ye Li | 133f8b8 | 2021-10-29 09:46:25 +0800 | [diff] [blame] | 641 | void load_lposc_fuse(void) |
| 642 | { |
| 643 | int ret; |
| 644 | u32 val = 0, val2 = 0, reg; |
| 645 | |
| 646 | ret = fuse_read(25, 0, &val); |
| 647 | if (ret) |
| 648 | return; /* failed */ |
| 649 | |
| 650 | ret = fuse_read(25, 1, &val2); |
| 651 | if (ret) |
| 652 | return; /* failed */ |
| 653 | |
| 654 | /* LPOSCCTRL */ |
| 655 | reg = readl(0x2802f304); |
| 656 | reg &= ~0xff; |
| 657 | reg |= (val & 0xff); |
| 658 | writel(reg, 0x2802f304); |
| 659 | } |
| 660 | |
Ye Li | 715cfa0 | 2021-10-29 09:46:23 +0800 | [diff] [blame] | 661 | void set_lpav_qos(void) |
| 662 | { |
Ye Li | a031155 | 2021-10-29 09:46:22 +0800 | [diff] [blame] | 663 | /* Set read QoS of dcnano on LPAV NIC */ |
| 664 | writel(0xf, 0x2e447100); |
Ye Li | 43819eb | 2021-10-29 09:46:16 +0800 | [diff] [blame] | 665 | } |
| 666 | |
Ye Li | 6ee435eb | 2021-08-07 16:00:50 +0800 | [diff] [blame] | 667 | int arch_cpu_init(void) |
| 668 | { |
| 669 | if (IS_ENABLED(CONFIG_SPL_BUILD)) { |
Ye Li | 7201262 | 2021-10-29 09:46:15 +0800 | [diff] [blame] | 670 | u32 val = 0; |
| 671 | int ret; |
| 672 | bool rdc_en = true; /* Default assume DBD_EN is set */ |
| 673 | |
Peng Fan | 21bda43 | 2022-04-06 14:30:27 +0800 | [diff] [blame] | 674 | /* Enable System Reset Interrupt using WDOG_AD */ |
| 675 | setbits_le32(CMC1_BASE_ADDR + 0x8C, BIT(13)); |
| 676 | /* Clear AD_PERIPH Power switch domain out of reset interrupt flag */ |
| 677 | setbits_le32(CMC1_BASE_ADDR + 0x70, BIT(4)); |
| 678 | |
| 679 | if (readl(CMC1_BASE_ADDR + 0x90) & BIT(13)) { |
| 680 | /* Clear System Reset Interrupt Flag Register of WDOG_AD */ |
| 681 | setbits_le32(CMC1_BASE_ADDR + 0x90, BIT(13)); |
| 682 | /* Reset WDOG to clear reset request */ |
| 683 | pcc_reset_peripheral(3, WDOG3_PCC3_SLOT, true); |
| 684 | pcc_reset_peripheral(3, WDOG3_PCC3_SLOT, false); |
| 685 | } |
| 686 | |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 687 | /* Disable wdog */ |
| 688 | init_wdog(); |
| 689 | |
Ye Li | 7201262 | 2021-10-29 09:46:15 +0800 | [diff] [blame] | 690 | /* Read DBD_EN fuse */ |
| 691 | ret = fuse_read(8, 1, &val); |
| 692 | if (!ret) |
| 693 | rdc_en = !!(val & 0x4000); |
| 694 | |
Peng Fan | b5c41b1 | 2021-08-07 16:00:58 +0800 | [diff] [blame] | 695 | if (get_boot_mode() == SINGLE_BOOT) { |
Ye Li | 7201262 | 2021-10-29 09:46:15 +0800 | [diff] [blame] | 696 | if (rdc_en) |
| 697 | release_rdc(RDC_TRDC); |
| 698 | |
Peng Fan | b5c41b1 | 2021-08-07 16:00:58 +0800 | [diff] [blame] | 699 | trdc_set_access(); |
Ye Li | ec10a80 | 2022-04-06 14:30:17 +0800 | [diff] [blame] | 700 | lpav_configure(false); |
| 701 | } else { |
| 702 | lpav_configure(true); |
Peng Fan | b5c41b1 | 2021-08-07 16:00:58 +0800 | [diff] [blame] | 703 | } |
Peng Fan | fa55b21 | 2021-08-07 16:00:57 +0800 | [diff] [blame] | 704 | |
Ye Li | 7201262 | 2021-10-29 09:46:15 +0800 | [diff] [blame] | 705 | /* Release xrdc, then allow A35 to write SRAM2 */ |
| 706 | if (rdc_en) |
| 707 | release_rdc(RDC_XRDC); |
| 708 | |
Ye Li | 853cc9d | 2021-08-07 16:00:55 +0800 | [diff] [blame] | 709 | xrdc_mrc_region_set_access(2, CONFIG_SPL_TEXT_BASE, 0xE00); |
| 710 | |
Peng Fan | 4cdb3a3 | 2022-04-06 14:30:12 +0800 | [diff] [blame] | 711 | clock_init_early(); |
Ye Li | 6ee435eb | 2021-08-07 16:00:50 +0800 | [diff] [blame] | 712 | } else { |
| 713 | /* reconfigure core0 reset vector to ROM */ |
| 714 | set_core0_reset_vector(0x1000); |
| 715 | } |
| 716 | |
| 717 | return 0; |
| 718 | } |
| 719 | |
Simon Glass | fc55736 | 2022-03-04 08:43:05 -0700 | [diff] [blame] | 720 | static int imx8ulp_check_mu(void *ctx, struct event *event) |
Ye Li | 7bea5b0 | 2021-08-07 16:01:00 +0800 | [diff] [blame] | 721 | { |
| 722 | struct udevice *devp; |
| 723 | int node, ret; |
| 724 | |
| 725 | node = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "fsl,imx8ulp-mu"); |
| 726 | |
| 727 | ret = uclass_get_device_by_of_offset(UCLASS_MISC, node, &devp); |
| 728 | if (ret) { |
| 729 | printf("could not get S400 mu %d\n", ret); |
| 730 | return ret; |
| 731 | } |
| 732 | |
| 733 | return 0; |
| 734 | } |
Simon Glass | fc55736 | 2022-03-04 08:43:05 -0700 | [diff] [blame] | 735 | EVENT_SPY(EVT_DM_POST_INIT, imx8ulp_check_mu); |
Ye Li | 7bea5b0 | 2021-08-07 16:01:00 +0800 | [diff] [blame] | 736 | |
Ye Li | 6ee435eb | 2021-08-07 16:00:50 +0800 | [diff] [blame] | 737 | #if defined(CONFIG_SPL_BUILD) |
| 738 | __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) |
| 739 | { |
| 740 | debug("image entry point: 0x%lx\n", spl_image->entry_point); |
| 741 | |
| 742 | set_core0_reset_vector((u32)spl_image->entry_point); |
Ye Li | 6dd4302 | 2021-08-07 16:00:48 +0800 | [diff] [blame] | 743 | |
| 744 | /* Enable the 512KB cache */ |
| 745 | setbits_le32(SIM1_BASE_ADDR + 0x30, (0x1 << 4)); |
| 746 | |
| 747 | /* reset core */ |
| 748 | setbits_le32(SIM1_BASE_ADDR + 0x30, (0x1 << 16)); |
| 749 | |
| 750 | while (1) |
| 751 | ; |
| 752 | } |
| 753 | #endif |
Peng Fan | fa6ae05 | 2021-08-07 16:01:03 +0800 | [diff] [blame] | 754 | |
| 755 | void imx_get_mac_from_fuse(int dev_id, unsigned char *mac) |
| 756 | { |
Ye Li | 992b0ae | 2021-10-29 09:46:28 +0800 | [diff] [blame] | 757 | u32 val[2] = {}; |
| 758 | int ret; |
| 759 | |
| 760 | ret = fuse_read(5, 3, &val[0]); |
| 761 | if (ret) |
| 762 | goto err; |
| 763 | |
| 764 | ret = fuse_read(5, 4, &val[1]); |
| 765 | if (ret) |
| 766 | goto err; |
| 767 | |
| 768 | mac[0] = val[0]; |
| 769 | mac[1] = val[0] >> 8; |
| 770 | mac[2] = val[0] >> 16; |
| 771 | mac[3] = val[0] >> 24; |
| 772 | mac[4] = val[1]; |
| 773 | mac[5] = val[1] >> 8; |
| 774 | |
| 775 | debug("%s: MAC%d: %02x.%02x.%02x.%02x.%02x.%02x\n", |
| 776 | __func__, dev_id, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); |
| 777 | return; |
| 778 | err: |
Peng Fan | fa6ae05 | 2021-08-07 16:01:03 +0800 | [diff] [blame] | 779 | memset(mac, 0, 6); |
Ye Li | 992b0ae | 2021-10-29 09:46:28 +0800 | [diff] [blame] | 780 | printf("%s: fuse read err: %d\n", __func__, ret); |
Peng Fan | fa6ae05 | 2021-08-07 16:01:03 +0800 | [diff] [blame] | 781 | } |
Ye Li | 479fd4a | 2021-08-07 16:01:08 +0800 | [diff] [blame] | 782 | |
| 783 | int (*card_emmc_is_boot_part_en)(void) = (void *)0x67cc; |
| 784 | u32 spl_arch_boot_image_offset(u32 image_offset, u32 rom_bt_dev) |
| 785 | { |
| 786 | /* Hard code for eMMC image_offset on 8ULP ROM, need fix by ROM, temp workaround */ |
| 787 | if (((rom_bt_dev >> 16) & 0xff) == BT_DEV_TYPE_MMC && card_emmc_is_boot_part_en()) |
| 788 | image_offset = 0; |
| 789 | |
| 790 | return image_offset; |
| 791 | } |
Ye Li | 48836ae | 2022-04-06 14:30:30 +0800 | [diff] [blame] | 792 | |
| 793 | enum env_location env_get_location(enum env_operation op, int prio) |
| 794 | { |
| 795 | enum boot_device dev = get_boot_device(); |
| 796 | enum env_location env_loc = ENVL_UNKNOWN; |
| 797 | |
| 798 | if (prio) |
| 799 | return env_loc; |
| 800 | |
| 801 | switch (dev) { |
| 802 | #ifdef CONFIG_ENV_IS_IN_SPI_FLASH |
| 803 | case QSPI_BOOT: |
| 804 | env_loc = ENVL_SPI_FLASH; |
| 805 | break; |
| 806 | #endif |
| 807 | #ifdef CONFIG_ENV_IS_IN_MMC |
| 808 | case SD1_BOOT: |
| 809 | case SD2_BOOT: |
| 810 | case SD3_BOOT: |
| 811 | case MMC1_BOOT: |
| 812 | case MMC2_BOOT: |
| 813 | case MMC3_BOOT: |
| 814 | env_loc = ENVL_MMC; |
| 815 | break; |
| 816 | #endif |
| 817 | default: |
| 818 | #if defined(CONFIG_ENV_IS_NOWHERE) |
| 819 | env_loc = ENVL_NOWHERE; |
| 820 | #endif |
| 821 | break; |
| 822 | } |
| 823 | |
| 824 | return env_loc; |
| 825 | } |