board: stm32mp1: use CONFIG_SYS_MMC_ENV_DEV when available
authorPatrick Delaunay <patrick.delaunay@foss.st.com>
Mon, 1 Mar 2021 12:17:56 +0000 (13:17 +0100)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Thu, 11 Mar 2021 17:02:51 +0000 (18:02 +0100)
Check whether user has explicitly defined the mmc device to use
in mmc_get_env_dev() with CONFIG_SYS_MMC_ENV_DEV.

On STMicroelectronics boards the used mmc device for environment is
the instance of boot device provided by the ROM code; the mmc instance
is configured by alias in device tree. The used partition is defined in
device tree with u-boot,mmc-env-partition = "ssbl".

This patch allows to override this selection for the support of customer
boards without alias; for example when SDMMC1 is not used and ENV in
mmc0=SDMMC2, user can force the value: CONFIG_SYS_MMC_ENV_DEV = 0.

On STMicroelectronics boards, the current behavior is kept with
CONFIG_SYS_MMC_ENV_DEV = -1.

Signed-off-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
board/st/stm32mp1/stm32mp1.c
configs/stm32mp15_basic_defconfig
configs/stm32mp15_trusted_defconfig

index ab85d8b..759181f 100644 (file)
@@ -862,8 +862,14 @@ const char *env_ext4_get_dev_part(void)
 
 int mmc_get_env_dev(void)
 {
-       u32 bootmode = get_bootmode();
+       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;
 }
 
index 0864d4f..fbca482 100644 (file)
@@ -72,6 +72,7 @@ CONFIG_ENV_UBI_PART="UBI"
 CONFIG_ENV_UBI_VOLUME="uboot_config"
 CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=-1
 # CONFIG_SPL_ENV_IS_NOWHERE is not set
 # CONFIG_SPL_ENV_IS_IN_SPI_FLASH is not set
 CONFIG_STM32_ADC=y
index 7c32eb7..ba9a660 100644 (file)
@@ -53,6 +53,7 @@ CONFIG_ENV_UBI_PART="UBI"
 CONFIG_ENV_UBI_VOLUME="uboot_config"
 CONFIG_ENV_UBI_VOLUME_REDUND="uboot_config_r"
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=-1
 CONFIG_STM32_ADC=y
 CONFIG_CLK_SCMI=y
 CONFIG_SET_DFU_ALT_INFO=y