2021-08-07 08:00:31 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
|
|
|
/*
|
|
|
|
* Copyright 2021 NXP
|
|
|
|
*/
|
|
|
|
|
2021-08-07 08:00:33 +00:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/arch/clock.h>
|
|
|
|
#include <asm/arch/imx-regs.h>
|
2021-08-07 08:00:31 +00:00
|
|
|
#include <asm/arch/sys_proto.h>
|
2021-08-07 08:00:35 +00:00
|
|
|
#include <asm/armv8/mmu.h>
|
2021-08-07 08:00:33 +00:00
|
|
|
#include <asm/mach-imx/boot_mode.h>
|
2021-08-07 08:01:01 +00:00
|
|
|
#include <asm/global_data.h>
|
2021-08-07 08:00:48 +00:00
|
|
|
#include <efi_loader.h>
|
2022-03-04 15:43:05 +00:00
|
|
|
#include <event.h>
|
2021-08-07 08:00:48 +00:00
|
|
|
#include <spl.h>
|
2021-08-07 08:00:59 +00:00
|
|
|
#include <asm/arch/rdc.h>
|
2023-06-15 10:09:05 +00:00
|
|
|
#include <asm/mach-imx/ele_api.h>
|
2022-07-26 08:40:49 +00:00
|
|
|
#include <asm/mach-imx/mu_hal.h>
|
2021-08-07 08:00:55 +00:00
|
|
|
#include <cpu_func.h>
|
|
|
|
#include <asm/setup.h>
|
2021-08-07 08:01:00 +00:00
|
|
|
#include <dm.h>
|
|
|
|
#include <dm/device-internal.h>
|
|
|
|
#include <dm/lists.h>
|
|
|
|
#include <dm/uclass.h>
|
|
|
|
#include <dm/device.h>
|
|
|
|
#include <dm/uclass-internal.h>
|
2021-10-29 01:46:15 +00:00
|
|
|
#include <fuse.h>
|
2021-10-29 01:46:32 +00:00
|
|
|
#include <thermal.h>
|
2022-04-06 06:30:08 +00:00
|
|
|
#include <linux/iopoll.h>
|
2022-04-06 06:30:30 +00:00
|
|
|
#include <env.h>
|
|
|
|
#include <env_internal.h>
|
2021-08-07 08:00:31 +00:00
|
|
|
|
2021-08-07 08:00:35 +00:00
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
|
2021-08-07 08:00:39 +00:00
|
|
|
struct rom_api *g_rom_api = (struct rom_api *)0x1980;
|
|
|
|
|
2021-08-07 08:01:01 +00:00
|
|
|
bool is_usb_boot(void)
|
|
|
|
{
|
|
|
|
return get_boot_device() == USB_BOOT;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_ENV_IS_IN_MMC
|
|
|
|
__weak int board_mmc_get_env_dev(int devno)
|
|
|
|
{
|
|
|
|
return devno;
|
|
|
|
}
|
|
|
|
|
|
|
|
int mmc_get_env_dev(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
u32 boot;
|
|
|
|
u16 boot_type;
|
|
|
|
u8 boot_instance;
|
|
|
|
|
2022-06-20 08:53:22 +00:00
|
|
|
ret = rom_api_query_boot_infor(QUERY_BT_DEV, &boot);
|
2021-08-07 08:01:01 +00:00
|
|
|
|
|
|
|
if (ret != ROM_API_OKAY) {
|
|
|
|
puts("ROMAPI: failure at query_boot_info\n");
|
|
|
|
return CONFIG_SYS_MMC_ENV_DEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
boot_type = boot >> 16;
|
|
|
|
boot_instance = (boot >> 8) & 0xff;
|
|
|
|
|
|
|
|
/* If not boot from sd/mmc, use default value */
|
|
|
|
if (boot_type != BOOT_TYPE_SD && boot_type != BOOT_TYPE_MMC)
|
|
|
|
return env_get_ulong("mmcdev", 10, CONFIG_SYS_MMC_ENV_DEV);
|
|
|
|
|
|
|
|
return board_mmc_get_env_dev(boot_instance);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2023-06-15 10:09:05 +00:00
|
|
|
static void set_cpu_info(struct ele_get_info_data *info)
|
2023-01-31 08:42:13 +00:00
|
|
|
{
|
|
|
|
gd->arch.soc_rev = info->soc;
|
|
|
|
gd->arch.lifecycle = info->lc;
|
|
|
|
memcpy((void *)&gd->arch.uid, &info->uid, 4 * sizeof(u32));
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:31 +00:00
|
|
|
u32 get_cpu_rev(void)
|
|
|
|
{
|
2023-01-31 08:42:13 +00:00
|
|
|
u32 rev = (gd->arch.soc_rev >> 24) - 0xa0;
|
|
|
|
|
|
|
|
return (MXC_CPU_IMX8ULP << 12) | (CHIP_REV_1_0 + rev);
|
2021-08-07 08:00:31 +00:00
|
|
|
}
|
2021-08-07 08:00:33 +00:00
|
|
|
|
|
|
|
enum bt_mode get_boot_mode(void)
|
|
|
|
{
|
|
|
|
u32 bt0_cfg = 0;
|
|
|
|
|
2021-08-07 08:01:07 +00:00
|
|
|
bt0_cfg = readl(SIM_SEC_BASE_ADDR + 0x24);
|
2021-08-07 08:00:33 +00:00
|
|
|
bt0_cfg &= (BT0CFG_LPBOOT_MASK | BT0CFG_DUALBOOT_MASK);
|
|
|
|
|
|
|
|
if (!(bt0_cfg & BT0CFG_LPBOOT_MASK)) {
|
|
|
|
/* No low power boot */
|
|
|
|
if (bt0_cfg & BT0CFG_DUALBOOT_MASK)
|
|
|
|
return DUAL_BOOT;
|
|
|
|
else
|
|
|
|
return SINGLE_BOOT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LOW_POWER_BOOT;
|
|
|
|
}
|
|
|
|
|
2022-04-06 06:30:08 +00:00
|
|
|
bool m33_image_booted(void)
|
|
|
|
{
|
2023-01-31 08:42:17 +00:00
|
|
|
if (IS_ENABLED(CONFIG_SPL_BUILD)) {
|
|
|
|
u32 gp6 = 0;
|
|
|
|
|
|
|
|
/* DGO_GP6 */
|
|
|
|
gp6 = readl(SIM_SEC_BASE_ADDR + 0x28);
|
|
|
|
if (gp6 & BIT(5))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
u32 gpr0 = readl(SIM1_BASE_ADDR);
|
|
|
|
if (gpr0 & BIT(0))
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool rdc_enabled_in_boot(void)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_SPL_BUILD)) {
|
|
|
|
u32 val = 0;
|
|
|
|
int ret;
|
|
|
|
bool rdc_en = true; /* Default assume DBD_EN is set */
|
|
|
|
|
|
|
|
/* Read DBD_EN fuse */
|
|
|
|
ret = fuse_read(8, 1, &val);
|
|
|
|
if (!ret)
|
|
|
|
rdc_en = !!(val & 0x200); /* only A1 part uses DBD_EN, so check DBD_EN new place*/
|
|
|
|
|
|
|
|
return rdc_en;
|
|
|
|
} else {
|
|
|
|
u32 gpr0 = readl(SIM1_BASE_ADDR);
|
|
|
|
if (gpr0 & 0x2)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void spl_pass_boot_info(void)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_SPL_BUILD)) {
|
|
|
|
bool m33_booted = m33_image_booted();
|
|
|
|
bool rdc_en = rdc_enabled_in_boot();
|
|
|
|
u32 val = 0;
|
2022-04-06 06:30:08 +00:00
|
|
|
|
2023-01-31 08:42:17 +00:00
|
|
|
if (m33_booted)
|
|
|
|
val |= 0x1;
|
2022-04-06 06:30:08 +00:00
|
|
|
|
2023-01-31 08:42:17 +00:00
|
|
|
if (rdc_en)
|
|
|
|
val |= 0x2;
|
|
|
|
|
|
|
|
writel(val, SIM1_BASE_ADDR);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool is_m33_handshake_necessary(void)
|
|
|
|
{
|
|
|
|
/* Only need handshake in u-boot */
|
|
|
|
if (!IS_ENABLED(CONFIG_SPL_BUILD))
|
|
|
|
return (m33_image_booted() || rdc_enabled_in_boot());
|
|
|
|
else
|
|
|
|
return false;
|
2022-04-06 06:30:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int m33_image_handshake(ulong timeout_ms)
|
|
|
|
{
|
|
|
|
u32 fsr;
|
|
|
|
int ret;
|
|
|
|
ulong timeout_us = timeout_ms * 1000;
|
|
|
|
|
|
|
|
/* Notify m33 that it's ready to do init srtm(enable mu receive interrupt and so on) */
|
|
|
|
setbits_le32(MU0_B_BASE_ADDR + 0x100, BIT(0)); /* set FCR F0 flag of MU0_MUB */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Wait m33 to set FCR F0 flag of MU0_MUA
|
|
|
|
* Clear FCR F0 flag of MU0_MUB after m33 has set FCR F0 flag of MU0_MUA
|
|
|
|
*/
|
|
|
|
ret = readl_poll_sleep_timeout(MU0_B_BASE_ADDR + 0x104, fsr, fsr & BIT(0), 10, timeout_us);
|
|
|
|
if (!ret)
|
|
|
|
clrbits_le32(MU0_B_BASE_ADDR + 0x100, BIT(0));
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:34 +00:00
|
|
|
#define CMC_SRS_TAMPER BIT(31)
|
|
|
|
#define CMC_SRS_SECURITY BIT(30)
|
|
|
|
#define CMC_SRS_TZWDG BIT(29)
|
|
|
|
#define CMC_SRS_JTAG_RST BIT(28)
|
|
|
|
#define CMC_SRS_CORE1 BIT(16)
|
|
|
|
#define CMC_SRS_LOCKUP BIT(15)
|
|
|
|
#define CMC_SRS_SW BIT(14)
|
|
|
|
#define CMC_SRS_WDG BIT(13)
|
|
|
|
#define CMC_SRS_PIN_RESET BIT(8)
|
|
|
|
#define CMC_SRS_WARM BIT(4)
|
|
|
|
#define CMC_SRS_HVD BIT(3)
|
|
|
|
#define CMC_SRS_LVD BIT(2)
|
|
|
|
#define CMC_SRS_POR BIT(1)
|
|
|
|
#define CMC_SRS_WUP BIT(0)
|
|
|
|
|
|
|
|
static char *get_reset_cause(char *ret)
|
|
|
|
{
|
|
|
|
u32 cause1, cause = 0, srs = 0;
|
2021-08-07 08:00:35 +00:00
|
|
|
void __iomem *reg_ssrs = (void __iomem *)(CMC1_BASE_ADDR + 0x88);
|
|
|
|
void __iomem *reg_srs = (void __iomem *)(CMC1_BASE_ADDR + 0x80);
|
2021-08-07 08:00:34 +00:00
|
|
|
|
|
|
|
if (!ret)
|
|
|
|
return "null";
|
|
|
|
|
|
|
|
srs = readl(reg_srs);
|
|
|
|
cause1 = readl(reg_ssrs);
|
|
|
|
|
2021-08-07 08:01:06 +00:00
|
|
|
cause = srs & (CMC_SRS_POR | CMC_SRS_WUP | CMC_SRS_WARM);
|
2021-08-07 08:00:34 +00:00
|
|
|
|
|
|
|
switch (cause) {
|
|
|
|
case CMC_SRS_POR:
|
|
|
|
sprintf(ret, "%s", "POR");
|
|
|
|
break;
|
|
|
|
case CMC_SRS_WUP:
|
|
|
|
sprintf(ret, "%s", "WUP");
|
|
|
|
break;
|
|
|
|
case CMC_SRS_WARM:
|
2021-08-07 08:01:06 +00:00
|
|
|
cause = srs & (CMC_SRS_WDG | CMC_SRS_SW |
|
2021-08-07 08:00:34 +00:00
|
|
|
CMC_SRS_JTAG_RST);
|
|
|
|
switch (cause) {
|
|
|
|
case CMC_SRS_WDG:
|
|
|
|
sprintf(ret, "%s", "WARM-WDG");
|
|
|
|
break;
|
|
|
|
case CMC_SRS_SW:
|
|
|
|
sprintf(ret, "%s", "WARM-SW");
|
|
|
|
break;
|
|
|
|
case CMC_SRS_JTAG_RST:
|
|
|
|
sprintf(ret, "%s", "WARM-JTAG");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sprintf(ret, "%s", "WARM-UNKN");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2021-08-07 08:01:06 +00:00
|
|
|
sprintf(ret, "%s-%X", "UNKN", srs);
|
2021-08-07 08:00:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
debug("[%X] SRS[%X] %X - ", cause1, srs, srs ^ cause1);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:33 +00:00
|
|
|
#if defined(CONFIG_DISPLAY_CPUINFO)
|
|
|
|
const char *get_imx_type(u32 imxtype)
|
|
|
|
{
|
|
|
|
return "8ULP";
|
|
|
|
}
|
|
|
|
|
|
|
|
int print_cpuinfo(void)
|
|
|
|
{
|
|
|
|
u32 cpurev;
|
|
|
|
char cause[18];
|
|
|
|
|
|
|
|
cpurev = get_cpu_rev();
|
|
|
|
|
2021-10-29 01:46:24 +00:00
|
|
|
printf("CPU: i.MX%s rev%d.%d at %d MHz\n",
|
2021-08-07 08:00:33 +00:00
|
|
|
get_imx_type((cpurev & 0xFF000) >> 12),
|
|
|
|
(cpurev & 0x000F0) >> 4, (cpurev & 0x0000F) >> 0,
|
|
|
|
mxc_get_clock(MXC_ARM_CLK) / 1000000);
|
|
|
|
|
2021-10-29 01:46:32 +00:00
|
|
|
#if defined(CONFIG_IMX_PMC_TEMPERATURE)
|
|
|
|
struct udevice *udev;
|
|
|
|
int ret, temp;
|
|
|
|
|
|
|
|
ret = uclass_get_device(UCLASS_THERMAL, 0, &udev);
|
|
|
|
if (!ret) {
|
|
|
|
ret = thermal_get_temp(udev, &temp);
|
|
|
|
if (!ret)
|
|
|
|
printf("CPU current temperature: %d\n", temp);
|
|
|
|
else
|
|
|
|
debug(" - failed to get CPU current temperature\n");
|
|
|
|
} else {
|
|
|
|
debug(" - failed to get CPU current temperature\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-08-07 08:00:34 +00:00
|
|
|
printf("Reset cause: %s\n", get_reset_cause(cause));
|
|
|
|
|
2021-08-07 08:00:33 +00:00
|
|
|
printf("Boot mode: ");
|
|
|
|
switch (get_boot_mode()) {
|
|
|
|
case LOW_POWER_BOOT:
|
|
|
|
printf("Low power boot\n");
|
|
|
|
break;
|
|
|
|
case DUAL_BOOT:
|
|
|
|
printf("Dual boot\n");
|
|
|
|
break;
|
|
|
|
case SINGLE_BOOT:
|
|
|
|
default:
|
|
|
|
printf("Single boot\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-07 08:00:35 +00:00
|
|
|
|
2021-08-07 08:00:49 +00:00
|
|
|
#define UNLOCK_WORD0 0xC520 /* 1st unlock word */
|
|
|
|
#define UNLOCK_WORD1 0xD928 /* 2nd unlock word */
|
|
|
|
#define REFRESH_WORD0 0xA602 /* 1st refresh word */
|
|
|
|
#define REFRESH_WORD1 0xB480 /* 2nd refresh word */
|
|
|
|
|
|
|
|
static void disable_wdog(void __iomem *wdog_base)
|
|
|
|
{
|
|
|
|
u32 val_cs = readl(wdog_base + 0x00);
|
|
|
|
|
|
|
|
if (!(val_cs & 0x80))
|
|
|
|
return;
|
|
|
|
|
|
|
|
dmb();
|
|
|
|
__raw_writel(REFRESH_WORD0, (wdog_base + 0x04)); /* Refresh the CNT */
|
|
|
|
__raw_writel(REFRESH_WORD1, (wdog_base + 0x04));
|
|
|
|
dmb();
|
|
|
|
|
|
|
|
if (!(val_cs & 800)) {
|
|
|
|
dmb();
|
|
|
|
__raw_writel(UNLOCK_WORD0, (wdog_base + 0x04));
|
|
|
|
__raw_writel(UNLOCK_WORD1, (wdog_base + 0x04));
|
|
|
|
dmb();
|
|
|
|
|
|
|
|
while (!(readl(wdog_base + 0x00) & 0x800))
|
|
|
|
;
|
|
|
|
}
|
|
|
|
writel(0x0, (wdog_base + 0x0C)); /* Set WIN to 0 */
|
|
|
|
writel(0x400, (wdog_base + 0x08)); /* Set timeout to default 0x400 */
|
|
|
|
writel(0x120, (wdog_base + 0x00)); /* Disable it and set update */
|
|
|
|
|
|
|
|
while (!(readl(wdog_base + 0x00) & 0x400))
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:35 +00:00
|
|
|
void init_wdog(void)
|
|
|
|
{
|
2021-08-07 08:00:49 +00:00
|
|
|
disable_wdog((void __iomem *)WDG3_RBASE);
|
2021-08-07 08:00:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct mm_region imx8ulp_arm64_mem_map[] = {
|
|
|
|
{
|
|
|
|
/* ROM */
|
|
|
|
.virt = 0x0,
|
|
|
|
.phys = 0x0,
|
|
|
|
.size = 0x40000UL,
|
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
|
|
|
|
PTE_BLOCK_OUTER_SHARE
|
|
|
|
},
|
|
|
|
{
|
|
|
|
/* FLEXSPI0 */
|
|
|
|
.virt = 0x04000000,
|
|
|
|
.phys = 0x04000000,
|
|
|
|
.size = 0x08000000UL,
|
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
|
|
|
|
PTE_BLOCK_NON_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN
|
|
|
|
},
|
|
|
|
{
|
|
|
|
/* SSRAM (align with 2M) */
|
|
|
|
.virt = 0x1FE00000UL,
|
|
|
|
.phys = 0x1FE00000UL,
|
|
|
|
.size = 0x400000UL,
|
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
|
|
|
|
PTE_BLOCK_OUTER_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN
|
|
|
|
}, {
|
|
|
|
/* SRAM1 (align with 2M) */
|
|
|
|
.virt = 0x21000000UL,
|
|
|
|
.phys = 0x21000000UL,
|
|
|
|
.size = 0x200000UL,
|
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
|
|
|
|
PTE_BLOCK_OUTER_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN
|
|
|
|
}, {
|
|
|
|
/* SRAM0 (align with 2M) */
|
|
|
|
.virt = 0x22000000UL,
|
|
|
|
.phys = 0x22000000UL,
|
|
|
|
.size = 0x200000UL,
|
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
|
|
|
|
PTE_BLOCK_OUTER_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN
|
|
|
|
}, {
|
|
|
|
/* Peripherals */
|
|
|
|
.virt = 0x27000000UL,
|
|
|
|
.phys = 0x27000000UL,
|
|
|
|
.size = 0x3000000UL,
|
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
|
|
|
|
PTE_BLOCK_NON_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN
|
|
|
|
}, {
|
|
|
|
/* Peripherals */
|
|
|
|
.virt = 0x2D000000UL,
|
|
|
|
.phys = 0x2D000000UL,
|
|
|
|
.size = 0x1600000UL,
|
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
|
|
|
|
PTE_BLOCK_NON_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN
|
|
|
|
}, {
|
|
|
|
/* FLEXSPI1-2 */
|
|
|
|
.virt = 0x40000000UL,
|
|
|
|
.phys = 0x40000000UL,
|
|
|
|
.size = 0x40000000UL,
|
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
|
|
|
|
PTE_BLOCK_NON_SHARE |
|
|
|
|
PTE_BLOCK_PXN | PTE_BLOCK_UXN
|
|
|
|
}, {
|
|
|
|
/* DRAM1 */
|
|
|
|
.virt = 0x80000000UL,
|
|
|
|
.phys = 0x80000000UL,
|
|
|
|
.size = PHYS_SDRAM_SIZE,
|
|
|
|
.attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
|
|
|
|
PTE_BLOCK_OUTER_SHARE
|
|
|
|
}, {
|
|
|
|
/*
|
|
|
|
* empty entrie to split table entry 5
|
|
|
|
* if needed when TEEs are used
|
|
|
|
*/
|
|
|
|
0,
|
|
|
|
}, {
|
|
|
|
/* List terminator */
|
|
|
|
0,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct mm_region *mem_map = imx8ulp_arm64_mem_map;
|
|
|
|
|
2022-04-06 06:30:28 +00:00
|
|
|
static unsigned int imx8ulp_find_dram_entry_in_mem_map(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(imx8ulp_arm64_mem_map); i++)
|
2022-11-16 18:10:37 +00:00
|
|
|
if (imx8ulp_arm64_mem_map[i].phys == CFG_SYS_SDRAM_BASE)
|
2022-04-06 06:30:28 +00:00
|
|
|
return i;
|
|
|
|
|
|
|
|
hang(); /* Entry not found, this must never happen. */
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:35 +00:00
|
|
|
/* simplify the page table size to enhance boot speed */
|
|
|
|
#define MAX_PTE_ENTRIES 512
|
|
|
|
#define MAX_MEM_MAP_REGIONS 16
|
|
|
|
u64 get_page_table_size(void)
|
|
|
|
{
|
|
|
|
u64 one_pt = MAX_PTE_ENTRIES * sizeof(u64);
|
|
|
|
u64 size = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* For each memory region, the max table size:
|
|
|
|
* 2 level 3 tables + 2 level 2 tables + 1 level 1 table
|
|
|
|
*/
|
|
|
|
size = (2 + 2 + 1) * one_pt * MAX_MEM_MAP_REGIONS + one_pt;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We need to duplicate our page table once to have an emergency pt to
|
|
|
|
* resort to when splitting page tables later on
|
|
|
|
*/
|
|
|
|
size *= 2;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We may need to split page tables later on if dcache settings change,
|
|
|
|
* so reserve up to 4 (random pick) page tables for that.
|
|
|
|
*/
|
|
|
|
size += one_pt * 4;
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
|
|
|
void enable_caches(void)
|
|
|
|
{
|
2022-04-06 06:30:28 +00:00
|
|
|
/* If OPTEE runs, remove OPTEE memory from MMU table to avoid speculative prefetch */
|
|
|
|
if (rom_pointer[1]) {
|
|
|
|
/*
|
|
|
|
* TEE are loaded, So the ddr bank structures
|
|
|
|
* have been modified update mmu table accordingly
|
|
|
|
*/
|
|
|
|
int i = 0;
|
|
|
|
int entry = imx8ulp_find_dram_entry_in_mem_map();
|
|
|
|
u64 attrs = imx8ulp_arm64_mem_map[entry].attrs;
|
|
|
|
|
|
|
|
while (i < CONFIG_NR_DRAM_BANKS &&
|
|
|
|
entry < ARRAY_SIZE(imx8ulp_arm64_mem_map)) {
|
|
|
|
if (gd->bd->bi_dram[i].start == 0)
|
|
|
|
break;
|
|
|
|
imx8ulp_arm64_mem_map[entry].phys = gd->bd->bi_dram[i].start;
|
|
|
|
imx8ulp_arm64_mem_map[entry].virt = gd->bd->bi_dram[i].start;
|
|
|
|
imx8ulp_arm64_mem_map[entry].size = gd->bd->bi_dram[i].size;
|
|
|
|
imx8ulp_arm64_mem_map[entry].attrs = attrs;
|
|
|
|
debug("Added memory mapping (%d): %llx %llx\n", entry,
|
|
|
|
imx8ulp_arm64_mem_map[entry].phys, imx8ulp_arm64_mem_map[entry].size);
|
|
|
|
i++; entry++;
|
|
|
|
}
|
|
|
|
}
|
2021-08-07 08:00:35 +00:00
|
|
|
|
|
|
|
icache_enable();
|
|
|
|
dcache_enable();
|
|
|
|
}
|
|
|
|
|
2022-04-06 06:30:28 +00:00
|
|
|
__weak int board_phys_sdram_size(phys_size_t *size)
|
|
|
|
{
|
|
|
|
if (!size)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
*size = PHYS_SDRAM_SIZE;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:35 +00:00
|
|
|
int dram_init(void)
|
|
|
|
{
|
2022-04-06 06:30:28 +00:00
|
|
|
unsigned int entry = imx8ulp_find_dram_entry_in_mem_map();
|
|
|
|
phys_size_t sdram_size;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = board_phys_sdram_size(&sdram_size);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
/* rom_pointer[1] contains the size of TEE occupies */
|
|
|
|
if (rom_pointer[1])
|
|
|
|
gd->ram_size = sdram_size - rom_pointer[1];
|
|
|
|
else
|
|
|
|
gd->ram_size = sdram_size;
|
|
|
|
|
|
|
|
/* also update the SDRAM size in the mem_map used externally */
|
|
|
|
imx8ulp_arm64_mem_map[entry].size = sdram_size;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int dram_init_banksize(void)
|
|
|
|
{
|
|
|
|
int bank = 0;
|
|
|
|
int ret;
|
|
|
|
phys_size_t sdram_size;
|
|
|
|
|
|
|
|
ret = board_phys_sdram_size(&sdram_size);
|
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
gd->bd->bi_dram[bank].start = PHYS_SDRAM;
|
|
|
|
if (rom_pointer[1]) {
|
|
|
|
phys_addr_t optee_start = (phys_addr_t)rom_pointer[0];
|
|
|
|
phys_size_t optee_size = (size_t)rom_pointer[1];
|
|
|
|
|
|
|
|
gd->bd->bi_dram[bank].size = optee_start - gd->bd->bi_dram[bank].start;
|
|
|
|
if ((optee_start + optee_size) < (PHYS_SDRAM + sdram_size)) {
|
|
|
|
if (++bank >= CONFIG_NR_DRAM_BANKS) {
|
|
|
|
puts("CONFIG_NR_DRAM_BANKS is not enough\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
gd->bd->bi_dram[bank].start = optee_start + optee_size;
|
|
|
|
gd->bd->bi_dram[bank].size = PHYS_SDRAM +
|
|
|
|
sdram_size - gd->bd->bi_dram[bank].start;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
gd->bd->bi_dram[bank].size = sdram_size;
|
|
|
|
}
|
2021-08-07 08:00:35 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-04-06 06:30:28 +00:00
|
|
|
phys_size_t get_effective_memsize(void)
|
|
|
|
{
|
|
|
|
/* return the first bank as effective memory */
|
|
|
|
if (rom_pointer[1])
|
|
|
|
return ((phys_addr_t)rom_pointer[0] - PHYS_SDRAM);
|
|
|
|
|
|
|
|
return gd->ram_size;
|
|
|
|
}
|
|
|
|
|
2021-08-30 13:16:29 +00:00
|
|
|
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
|
2021-08-07 08:00:35 +00:00
|
|
|
void get_board_serial(struct tag_serialnr *serialnr)
|
|
|
|
{
|
2021-08-07 08:01:00 +00:00
|
|
|
u32 uid[4];
|
|
|
|
u32 res;
|
|
|
|
int ret;
|
|
|
|
|
2023-06-15 10:09:05 +00:00
|
|
|
ret = ele_read_common_fuse(1, uid, 4, &res);
|
2021-08-07 08:01:00 +00:00
|
|
|
if (ret)
|
2023-06-15 10:09:05 +00:00
|
|
|
printf("ele read fuse failed %d, 0x%x\n", ret, res);
|
2021-08-07 08:01:00 +00:00
|
|
|
else
|
|
|
|
printf("UID 0x%x,0x%x,0x%x,0x%x\n", uid[0], uid[1], uid[2], uid[3]);
|
|
|
|
|
|
|
|
serialnr->low = uid[0];
|
|
|
|
serialnr->high = uid[3];
|
2021-08-07 08:00:35 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2021-08-07 08:00:50 +00:00
|
|
|
static void set_core0_reset_vector(u32 entry)
|
2021-08-07 08:00:35 +00:00
|
|
|
{
|
2021-08-07 08:00:48 +00:00
|
|
|
/* Update SIM1 DGO8 for reset vector base */
|
2021-08-07 08:00:50 +00:00
|
|
|
writel(entry, SIM1_BASE_ADDR + 0x5c);
|
2021-08-07 08:00:48 +00:00
|
|
|
|
|
|
|
/* set update bit */
|
|
|
|
setbits_le32(SIM1_BASE_ADDR + 0x8, 0x1 << 24);
|
|
|
|
|
|
|
|
/* polling the ack */
|
|
|
|
while ((readl(SIM1_BASE_ADDR + 0x8) & (0x1 << 26)) == 0)
|
|
|
|
;
|
|
|
|
|
|
|
|
/* clear the update */
|
|
|
|
clrbits_le32(SIM1_BASE_ADDR + 0x8, (0x1 << 24));
|
|
|
|
|
|
|
|
/* clear the ack by set 1 */
|
|
|
|
setbits_le32(SIM1_BASE_ADDR + 0x8, (0x1 << 26));
|
2021-08-07 08:00:50 +00:00
|
|
|
}
|
|
|
|
|
2023-01-31 08:42:16 +00:00
|
|
|
/* Not used now */
|
|
|
|
int trdc_set_access(void)
|
2021-08-07 08:00:58 +00:00
|
|
|
{
|
|
|
|
/*
|
2021-08-07 08:00:59 +00:00
|
|
|
* TRDC mgr + 4 MBC + 2 MRC.
|
2021-08-07 08:00:58 +00:00
|
|
|
*/
|
2023-01-31 08:42:16 +00:00
|
|
|
trdc_mbc_set_access(2, 7, 0, 49, true);
|
|
|
|
trdc_mbc_set_access(2, 7, 0, 50, true);
|
|
|
|
trdc_mbc_set_access(2, 7, 0, 51, true);
|
|
|
|
trdc_mbc_set_access(2, 7, 0, 52, true);
|
|
|
|
trdc_mbc_set_access(2, 7, 0, 53, true);
|
|
|
|
trdc_mbc_set_access(2, 7, 0, 54, true);
|
|
|
|
|
|
|
|
/* 0x1fff8000 used for resource table by remoteproc */
|
|
|
|
trdc_mbc_set_access(0, 7, 2, 31, false);
|
|
|
|
|
|
|
|
/* CGC0: PBridge0 slot 47 and PCC0 slot 48 */
|
2021-08-07 08:00:59 +00:00
|
|
|
trdc_mbc_set_access(2, 7, 0, 47, false);
|
2023-01-31 08:42:16 +00:00
|
|
|
trdc_mbc_set_access(2, 7, 0, 48, false);
|
|
|
|
|
|
|
|
/* PCC1 */
|
|
|
|
trdc_mbc_set_access(2, 7, 1, 17, false);
|
|
|
|
trdc_mbc_set_access(2, 7, 1, 34, false);
|
2021-08-07 08:00:58 +00:00
|
|
|
|
2021-08-07 08:00:59 +00:00
|
|
|
/* Iomuxc0: : PBridge1 slot 33 */
|
|
|
|
trdc_mbc_set_access(2, 7, 1, 33, false);
|
2021-08-07 08:00:58 +00:00
|
|
|
|
2021-10-29 01:46:20 +00:00
|
|
|
/* flexspi0 */
|
2023-01-31 08:42:16 +00:00
|
|
|
trdc_mbc_set_access(2, 7, 0, 57, false);
|
2021-10-29 01:46:20 +00:00
|
|
|
trdc_mrc_region_set_access(0, 7, 0x04000000, 0x0c000000, false);
|
2021-10-29 01:46:21 +00:00
|
|
|
|
|
|
|
/* tpm0: PBridge1 slot 21 */
|
|
|
|
trdc_mbc_set_access(2, 7, 1, 21, false);
|
|
|
|
/* lpi2c0: PBridge1 slot 24 */
|
|
|
|
trdc_mbc_set_access(2, 7, 1, 24, false);
|
2023-01-31 08:42:16 +00:00
|
|
|
|
|
|
|
/* Allow M33 to access TRDC MGR */
|
|
|
|
trdc_mbc_set_access(2, 6, 0, 49, true);
|
|
|
|
trdc_mbc_set_access(2, 6, 0, 50, true);
|
|
|
|
trdc_mbc_set_access(2, 6, 0, 51, true);
|
|
|
|
trdc_mbc_set_access(2, 6, 0, 52, true);
|
|
|
|
trdc_mbc_set_access(2, 6, 0, 53, true);
|
|
|
|
trdc_mbc_set_access(2, 6, 0, 54, true);
|
|
|
|
|
|
|
|
/* Set SAI0 for eDMA 0, NS */
|
|
|
|
trdc_mbc_set_access(2, 0, 1, 28, false);
|
|
|
|
|
|
|
|
/* Set SSRAM for eDMA0 access */
|
|
|
|
trdc_mbc_set_access(0, 0, 2, 0, false);
|
|
|
|
trdc_mbc_set_access(0, 0, 2, 1, false);
|
|
|
|
trdc_mbc_set_access(0, 0, 2, 2, false);
|
|
|
|
trdc_mbc_set_access(0, 0, 2, 3, false);
|
|
|
|
trdc_mbc_set_access(0, 0, 2, 4, false);
|
|
|
|
trdc_mbc_set_access(0, 0, 2, 5, false);
|
|
|
|
trdc_mbc_set_access(0, 0, 2, 6, false);
|
|
|
|
trdc_mbc_set_access(0, 0, 2, 7, false);
|
|
|
|
|
|
|
|
writel(0x800000a0, 0x28031840);
|
|
|
|
|
2021-08-07 08:00:58 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-04-06 06:30:17 +00:00
|
|
|
void lpav_configure(bool lpav_to_m33)
|
2021-10-29 01:46:16 +00:00
|
|
|
{
|
2022-04-06 06:30:17 +00:00
|
|
|
if (!lpav_to_m33)
|
|
|
|
setbits_le32(SIM_SEC_BASE_ADDR + 0x44, BIT(7)); /* LPAV to APD */
|
2021-10-29 01:46:16 +00:00
|
|
|
|
2021-10-29 01:46:17 +00:00
|
|
|
/* PXP/GPU 2D/3D/DCNANO/MIPI_DSI/EPDC/HIFI4 to APD */
|
|
|
|
setbits_le32(SIM_SEC_BASE_ADDR + 0x4c, 0x7F);
|
2021-10-29 01:46:16 +00:00
|
|
|
|
|
|
|
/* LPAV slave/dma2 ch allocation and request allocation to APD */
|
|
|
|
writel(0x1f, SIM_SEC_BASE_ADDR + 0x50);
|
|
|
|
writel(0xffffffff, SIM_SEC_BASE_ADDR + 0x54);
|
|
|
|
writel(0x003fffff, SIM_SEC_BASE_ADDR + 0x58);
|
2021-10-29 01:46:23 +00:00
|
|
|
}
|
2021-10-29 01:46:22 +00:00
|
|
|
|
2021-10-29 01:46:25 +00:00
|
|
|
void load_lposc_fuse(void)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
u32 val = 0, val2 = 0, reg;
|
|
|
|
|
|
|
|
ret = fuse_read(25, 0, &val);
|
|
|
|
if (ret)
|
|
|
|
return; /* failed */
|
|
|
|
|
|
|
|
ret = fuse_read(25, 1, &val2);
|
|
|
|
if (ret)
|
|
|
|
return; /* failed */
|
|
|
|
|
|
|
|
/* LPOSCCTRL */
|
|
|
|
reg = readl(0x2802f304);
|
|
|
|
reg &= ~0xff;
|
|
|
|
reg |= (val & 0xff);
|
|
|
|
writel(reg, 0x2802f304);
|
|
|
|
}
|
|
|
|
|
2021-10-29 01:46:23 +00:00
|
|
|
void set_lpav_qos(void)
|
|
|
|
{
|
2021-10-29 01:46:22 +00:00
|
|
|
/* Set read QoS of dcnano on LPAV NIC */
|
|
|
|
writel(0xf, 0x2e447100);
|
2021-10-29 01:46:16 +00:00
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:50 +00:00
|
|
|
int arch_cpu_init(void)
|
|
|
|
{
|
|
|
|
if (IS_ENABLED(CONFIG_SPL_BUILD)) {
|
2022-04-06 06:30:27 +00:00
|
|
|
/* Enable System Reset Interrupt using WDOG_AD */
|
|
|
|
setbits_le32(CMC1_BASE_ADDR + 0x8C, BIT(13));
|
|
|
|
/* Clear AD_PERIPH Power switch domain out of reset interrupt flag */
|
|
|
|
setbits_le32(CMC1_BASE_ADDR + 0x70, BIT(4));
|
|
|
|
|
|
|
|
if (readl(CMC1_BASE_ADDR + 0x90) & BIT(13)) {
|
|
|
|
/* Clear System Reset Interrupt Flag Register of WDOG_AD */
|
|
|
|
setbits_le32(CMC1_BASE_ADDR + 0x90, BIT(13));
|
|
|
|
/* Reset WDOG to clear reset request */
|
|
|
|
pcc_reset_peripheral(3, WDOG3_PCC3_SLOT, true);
|
|
|
|
pcc_reset_peripheral(3, WDOG3_PCC3_SLOT, false);
|
|
|
|
}
|
|
|
|
|
2021-08-07 08:00:55 +00:00
|
|
|
/* Disable wdog */
|
|
|
|
init_wdog();
|
|
|
|
|
2023-01-31 08:42:16 +00:00
|
|
|
if (get_boot_mode() == SINGLE_BOOT)
|
2022-04-06 06:30:17 +00:00
|
|
|
lpav_configure(false);
|
2023-01-31 08:42:16 +00:00
|
|
|
else
|
2022-04-06 06:30:17 +00:00
|
|
|
lpav_configure(true);
|
2021-08-07 08:00:57 +00:00
|
|
|
|
2021-10-29 01:46:15 +00:00
|
|
|
/* Release xrdc, then allow A35 to write SRAM2 */
|
2023-01-31 08:42:17 +00:00
|
|
|
if (rdc_enabled_in_boot())
|
2021-10-29 01:46:15 +00:00
|
|
|
release_rdc(RDC_XRDC);
|
|
|
|
|
2021-08-07 08:00:55 +00:00
|
|
|
xrdc_mrc_region_set_access(2, CONFIG_SPL_TEXT_BASE, 0xE00);
|
|
|
|
|
2022-04-06 06:30:12 +00:00
|
|
|
clock_init_early();
|
2023-01-31 08:42:17 +00:00
|
|
|
|
|
|
|
spl_pass_boot_info();
|
2021-08-07 08:00:50 +00:00
|
|
|
} else {
|
2023-01-31 08:42:17 +00:00
|
|
|
int ret;
|
2021-08-07 08:00:50 +00:00
|
|
|
/* reconfigure core0 reset vector to ROM */
|
|
|
|
set_core0_reset_vector(0x1000);
|
2023-01-31 08:42:17 +00:00
|
|
|
|
|
|
|
if (is_m33_handshake_necessary()) {
|
|
|
|
/* Start handshake with M33 to ensure TRDC configuration completed */
|
|
|
|
ret = m33_image_handshake(1000);
|
|
|
|
if (!ret)
|
|
|
|
gd->arch.m33_handshake_done = true;
|
|
|
|
else /* Skip and go through to panic in checkcpu as console is ready then */
|
|
|
|
gd->arch.m33_handshake_done = false;
|
|
|
|
}
|
2021-08-07 08:00:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-01-31 08:42:17 +00:00
|
|
|
int checkcpu(void)
|
|
|
|
{
|
|
|
|
if (is_m33_handshake_necessary()) {
|
|
|
|
if (!gd->arch.m33_handshake_done) {
|
|
|
|
puts("M33 Sync: Timeout, Boot Stop!\n");
|
|
|
|
hang();
|
|
|
|
} else {
|
|
|
|
puts("M33 Sync: OK\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2023-01-31 08:42:13 +00:00
|
|
|
int imx8ulp_dm_post_init(void)
|
2021-08-07 08:01:00 +00:00
|
|
|
{
|
|
|
|
struct udevice *devp;
|
2023-01-31 08:42:12 +00:00
|
|
|
int ret;
|
2023-01-31 08:42:13 +00:00
|
|
|
u32 res;
|
2023-06-15 10:09:05 +00:00
|
|
|
struct ele_get_info_data *info = (struct ele_get_info_data *)SRAM0_BASE;
|
2021-08-07 08:01:00 +00:00
|
|
|
|
2023-01-31 08:42:12 +00:00
|
|
|
ret = uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(imx8ulp_mu), &devp);
|
2021-08-07 08:01:00 +00:00
|
|
|
if (ret) {
|
|
|
|
printf("could not get S400 mu %d\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2023-06-15 10:09:05 +00:00
|
|
|
ret = ele_get_info(info, &res);
|
2023-01-31 08:42:13 +00:00
|
|
|
if (ret) {
|
2023-06-15 10:09:05 +00:00
|
|
|
printf("ele_get_info failed %d\n", ret);
|
2023-01-31 08:42:13 +00:00
|
|
|
/* fallback to A0.1 revision */
|
2023-06-15 10:09:05 +00:00
|
|
|
memset((void *)info, 0, sizeof(struct ele_get_info_data));
|
2023-01-31 08:42:13 +00:00
|
|
|
info->soc = 0xa000084d;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_cpu_info(info);
|
|
|
|
|
2021-08-07 08:01:00 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2023-08-22 03:16:56 +00:00
|
|
|
EVENT_SPY_SIMPLE(EVT_DM_POST_INIT_F, imx8ulp_dm_post_init);
|
2021-08-07 08:01:00 +00:00
|
|
|
|
2021-08-07 08:00:50 +00:00
|
|
|
#if defined(CONFIG_SPL_BUILD)
|
|
|
|
__weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
|
|
|
|
{
|
|
|
|
debug("image entry point: 0x%lx\n", spl_image->entry_point);
|
|
|
|
|
|
|
|
set_core0_reset_vector((u32)spl_image->entry_point);
|
2021-08-07 08:00:48 +00:00
|
|
|
|
|
|
|
/* Enable the 512KB cache */
|
|
|
|
setbits_le32(SIM1_BASE_ADDR + 0x30, (0x1 << 4));
|
|
|
|
|
|
|
|
/* reset core */
|
|
|
|
setbits_le32(SIM1_BASE_ADDR + 0x30, (0x1 << 16));
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
;
|
|
|
|
}
|
|
|
|
#endif
|
2021-08-07 08:01:03 +00:00
|
|
|
|
|
|
|
void imx_get_mac_from_fuse(int dev_id, unsigned char *mac)
|
|
|
|
{
|
2021-10-29 01:46:28 +00:00
|
|
|
u32 val[2] = {};
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
ret = fuse_read(5, 3, &val[0]);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
ret = fuse_read(5, 4, &val[1]);
|
|
|
|
if (ret)
|
|
|
|
goto err;
|
|
|
|
|
|
|
|
mac[0] = val[0];
|
|
|
|
mac[1] = val[0] >> 8;
|
|
|
|
mac[2] = val[0] >> 16;
|
|
|
|
mac[3] = val[0] >> 24;
|
|
|
|
mac[4] = val[1];
|
|
|
|
mac[5] = val[1] >> 8;
|
|
|
|
|
|
|
|
debug("%s: MAC%d: %02x.%02x.%02x.%02x.%02x.%02x\n",
|
|
|
|
__func__, dev_id, mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
|
|
|
|
return;
|
|
|
|
err:
|
2021-08-07 08:01:03 +00:00
|
|
|
memset(mac, 0, 6);
|
2021-10-29 01:46:28 +00:00
|
|
|
printf("%s: fuse read err: %d\n", __func__, ret);
|
2021-08-07 08:01:03 +00:00
|
|
|
}
|
2021-08-07 08:01:08 +00:00
|
|
|
|
|
|
|
int (*card_emmc_is_boot_part_en)(void) = (void *)0x67cc;
|
|
|
|
u32 spl_arch_boot_image_offset(u32 image_offset, u32 rom_bt_dev)
|
|
|
|
{
|
|
|
|
/* Hard code for eMMC image_offset on 8ULP ROM, need fix by ROM, temp workaround */
|
2023-01-31 08:42:14 +00:00
|
|
|
if (is_soc_rev(CHIP_REV_1_0) && ((rom_bt_dev >> 16) & 0xff) == BT_DEV_TYPE_MMC &&
|
|
|
|
card_emmc_is_boot_part_en())
|
2021-08-07 08:01:08 +00:00
|
|
|
image_offset = 0;
|
|
|
|
|
|
|
|
return image_offset;
|
|
|
|
}
|
2022-04-06 06:30:30 +00:00
|
|
|
|
|
|
|
enum env_location env_get_location(enum env_operation op, int prio)
|
|
|
|
{
|
|
|
|
enum boot_device dev = get_boot_device();
|
|
|
|
|
|
|
|
if (prio)
|
2023-08-25 14:44:14 +00:00
|
|
|
return ENVL_UNKNOWN;
|
2022-04-06 06:30:30 +00:00
|
|
|
|
|
|
|
switch (dev) {
|
|
|
|
case QSPI_BOOT:
|
2023-08-25 14:44:14 +00:00
|
|
|
if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
|
|
|
|
return ENVL_SPI_FLASH;
|
|
|
|
return ENVL_NOWHERE;
|
2022-04-06 06:30:30 +00:00
|
|
|
case SD1_BOOT:
|
|
|
|
case SD2_BOOT:
|
|
|
|
case SD3_BOOT:
|
|
|
|
case MMC1_BOOT:
|
|
|
|
case MMC2_BOOT:
|
|
|
|
case MMC3_BOOT:
|
2023-08-25 14:44:14 +00:00
|
|
|
if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC))
|
|
|
|
return ENVL_MMC;
|
|
|
|
else if (CONFIG_IS_ENABLED(ENV_IS_IN_EXT4))
|
|
|
|
return ENVL_EXT4;
|
|
|
|
else if (CONFIG_IS_ENABLED(ENV_IS_IN_FAT))
|
|
|
|
return ENVL_FAT;
|
|
|
|
return ENVL_NOWHERE;
|
2022-04-06 06:30:30 +00:00
|
|
|
default:
|
2023-08-25 14:44:14 +00:00
|
|
|
return ENVL_NOWHERE;
|
2022-04-06 06:30:30 +00:00
|
|
|
}
|
|
|
|
}
|