diff --git a/arch/arm/mach-stm32mp/Kconfig b/arch/arm/mach-stm32mp/Kconfig index 8c755f8e642636639f6b64710605e3ebac8ca055..9771af927a13ec0cf25144b62d96b04662141def 100644 --- a/arch/arm/mach-stm32mp/Kconfig +++ b/arch/arm/mach-stm32mp/Kconfig @@ -38,6 +38,14 @@ config SYS_TEXT_BASE when DDR driver is used: DDR + 1MB (0xC0100000) +config SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2 + hex "Partition on MMC2 to use to load U-Boot from" + depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION + default 1 + help + Partition on the second MMC to load U-Boot from when the MMC is being + used in raw mode + source "board/st/stm32mp1/Kconfig" endif diff --git a/arch/arm/mach-stm32mp/spl.c b/arch/arm/mach-stm32mp/spl.c index 8f5962a9351150ec358d7ac37f9852797d702182..bfb3e50f67c2351c1e393aa1a20529136d2ae5f7 100644 --- a/arch/arm/mach-stm32mp/spl.c +++ b/arch/arm/mach-stm32mp/spl.c @@ -7,9 +7,27 @@ #include #include #include +#include u32 spl_boot_device(void) { + u32 boot_mode; + + boot_mode = (readl(TAMP_BOOT_CONTEXT) & TAMP_BOOT_MODE_MASK) >> + TAMP_BOOT_MODE_SHIFT; + clrsetbits_le32(TAMP_BOOT_CONTEXT, + TAMP_BOOT_MODE_MASK, + boot_mode << TAMP_BOOT_MODE_SHIFT); + + switch (boot_mode) { + case BOOT_FLASH_SD_1: + case BOOT_FLASH_EMMC_1: + return BOOT_DEVICE_MMC1; + case BOOT_FLASH_SD_2: + case BOOT_FLASH_EMMC_2: + return BOOT_DEVICE_MMC2; + } + return BOOT_DEVICE_MMC1; } @@ -18,6 +36,18 @@ u32 spl_boot_mode(const u32 boot_device) return MMCSD_MODE_RAW; } +int spl_boot_partition(const u32 boot_device) +{ + switch (boot_device) { + case BOOT_DEVICE_MMC1: + return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION; + case BOOT_DEVICE_MMC2: + return CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION_MMC2; + default: + return -EINVAL; + } +} + void board_init_f(ulong dummy) { struct udevice *dev; diff --git a/include/configs/stm32mp1.h b/include/configs/stm32mp1.h index 6281dd5387d687e5b3b792bdd9575a8183863691..815910128e55cfb7aa5427086a1e7dfb815ef568 100644 --- a/include/configs/stm32mp1.h +++ b/include/configs/stm32mp1.h @@ -82,6 +82,12 @@ #include +#define STM32MP_PREBOOT \ + "echo \"Boot over ${boot_device}${boot_instance}!\"; " \ + "if test \"${boot_device}\" = \"mmc\"; then " \ + "env set boot_targets \"mmc${boot_instance}\"; "\ + "fi;" + #define CONFIG_EXTRA_ENV_SETTINGS \ "scriptaddr=0xC0000000\0" \ "pxefile_addr_r=0xC0000000\0" \ @@ -90,6 +96,7 @@ "ramdisk_addr_r=0xC4100000\0" \ "fdt_high=0xffffffff\0" \ "initrd_high=0xffffffff\0" \ + "preboot=" STM32MP_PREBOOT "\0" \ BOOTENV #endif /* ifndef CONFIG_SPL_BUILD */