STM32_UART7_BASE,
STM32_UART8_BASE
};
+ const u32 sdmmc_addr[] = {
+ STM32_SDMMC1_BASE,
+ STM32_SDMMC2_BASE,
+ STM32_SDMMC3_BASE
+ };
char cmd[60];
u32 boot_ctx = readl(TAMP_BOOT_CONTEXT);
u32 boot_mode =
break;
case BOOT_FLASH_SD:
case BOOT_FLASH_EMMC:
- sprintf(cmd, "%d", instance);
+ if (instance > ARRAY_SIZE(sdmmc_addr))
+ break;
+ /* search associated sdmmc node in devicetree */
+ sprintf(cmd, "mmc@%x", sdmmc_addr[instance]);
+ if (uclass_get_device_by_name(UCLASS_MMC, cmd, &dev)) {
+ printf("mmc%d = %s not found in device tree!\n",
+ instance, cmd);
+ break;
+ }
+ sprintf(cmd, "%d", dev_seq(dev));
env_set("boot_device", "mmc");
env_set("boot_instance", cmd);
break;
#define STM32_UART7_BASE 0x40018000
#define STM32_UART8_BASE 0x40019000
+#define STM32_SDMMC1_BASE 0x58005000
+#define STM32_SDMMC2_BASE 0x58007000
+#define STM32_SDMMC3_BASE 0x48004000
+
#define STM32_SYSRAM_BASE 0x2FFC0000
#define STM32_SYSRAM_SIZE SZ_256K
}
}
+int mmc_get_boot(void)
+{
+ struct udevice *dev;
+ u32 boot_mode = get_bootmode();
+ unsigned int instance = (boot_mode & TAMP_BOOT_INSTANCE_MASK) - 1;
+ char cmd[20];
+ const u32 sdmmc_addr[] = {
+ STM32_SDMMC1_BASE,
+ STM32_SDMMC2_BASE,
+ STM32_SDMMC3_BASE
+ };
+
+ if (instance > ARRAY_SIZE(sdmmc_addr))
+ return 0;
+
+ /* search associated sdmmc node in devicetree */
+ snprintf(cmd, sizeof(cmd), "mmc@%x", sdmmc_addr[instance]);
+ if (uclass_get_device_by_name(UCLASS_MMC, cmd, &dev)) {
+ log_err("mmc%d = %s not found in device tree!\n", instance, cmd);
+ return 0;
+ }
+
+ return dev_seq(dev);
+};
+
const char *env_ext4_get_dev_part(void)
{
static char *const env_dev_part =
if (strlen(env_dev_part) > 0)
return env_dev_part;
- u32 bootmode = get_bootmode();
-
- return dev_part[(bootmode & TAMP_BOOT_INSTANCE_MASK) - 1];
+ return dev_part[mmc_get_boot()];
}
int mmc_get_env_dev(void)
{
- u32 bootmode;
-
if (CONFIG_SYS_MMC_ENV_DEV >= 0)
return CONFIG_SYS_MMC_ENV_DEV;
- bootmode = get_bootmode();
-
/* use boot instance to select the correct mmc device identifier */
- return (bootmode & TAMP_BOOT_INSTANCE_MASK) - 1;
+ return mmc_get_boot();
}
#if defined(CONFIG_OF_BOARD_SETUP)