From a9addcafd180abf4c51d02a5954c8d03ba747f26 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Mon, 15 Jun 2020 11:18:22 +0200 Subject: stm32mp1: board: add support of CONFIG_ENV_IS_IN_MMC Add support of CONFIG_ENV_IS_IN_MMC in env_get_location, used for all mmc device (SD card and eMMC). The 2 configs CONFIG_ENV_IS_IN_MMC and CONFIG_ENV_IS_IN_EXT4 are incompatible. Add the weak function mmc_get_env_dev to select the mmc boot instance. Reviewed-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- board/st/stm32mp1/stm32mp1.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'board') diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 57a649e97e..0d59102da7 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -787,6 +787,11 @@ enum env_location env_get_location(enum env_operation op, int prio) return ENVL_UNKNOWN; switch (bootmode & TAMP_BOOT_DEVICE_MASK) { +#ifdef CONFIG_ENV_IS_IN_MMC + case BOOT_FLASH_SD: + case BOOT_FLASH_EMMC: + return ENVL_MMC; +#endif #ifdef CONFIG_ENV_IS_IN_EXT4 case BOOT_FLASH_SD: case BOOT_FLASH_EMMC: @@ -829,6 +834,15 @@ const char *env_ext4_get_dev_part(void) } #endif +#if defined(CONFIG_ENV_IS_IN_MMC) +int mmc_get_env_dev(void) +{ + u32 bootmode = get_bootmode(); + + return (bootmode & TAMP_BOOT_INSTANCE_MASK) - 1; +} +#endif + #if defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, struct bd_info *bd) { -- cgit From b0cbafe5090e9e2df290db29a3483529aa804ed3 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Mon, 15 Jun 2020 11:18:24 +0200 Subject: configs:stm32mp1: activate env config in SPL Activate env config in SPL with CONFIG_SPL_ENV_SUPPORT and use CONFIG_IS_ENABLED macro to test the activated CONFIG_$(SPL_)ENV_IS_IN_... in env_get_location. Reviewed-by: Patrice Chotard Signed-off-by: Patrick Delaunay --- board/st/stm32mp1/stm32mp1.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'board') diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 0d59102da7..158a7d6aaa 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -787,22 +787,22 @@ enum env_location env_get_location(enum env_operation op, int prio) return ENVL_UNKNOWN; switch (bootmode & TAMP_BOOT_DEVICE_MASK) { -#ifdef CONFIG_ENV_IS_IN_MMC +#if CONFIG_IS_ENABLED(ENV_IS_IN_MMC) case BOOT_FLASH_SD: case BOOT_FLASH_EMMC: return ENVL_MMC; #endif -#ifdef CONFIG_ENV_IS_IN_EXT4 +#if CONFIG_IS_ENABLED(ENV_IS_IN_EXT4) case BOOT_FLASH_SD: case BOOT_FLASH_EMMC: return ENVL_EXT4; #endif -#ifdef CONFIG_ENV_IS_IN_UBI +#if CONFIG_IS_ENABLED(ENV_IS_IN_UBI) case BOOT_FLASH_NAND: case BOOT_FLASH_SPINAND: return ENVL_UBI; #endif -#ifdef CONFIG_ENV_IS_IN_SPI_FLASH +#if CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH) case BOOT_FLASH_NOR: return ENVL_SPI_FLASH; #endif -- cgit From 1e3d0605018fd8ab6e3b00550e7e7c797d2f0cfc Mon Sep 17 00:00:00 2001 From: Jakob Riepler Date: Mon, 27 Jul 2020 14:18:29 +0200 Subject: board: dh_stm32mp1: remove env location override Overriding the environment location is not necessary as the defconfig for the relevant boards only enable SPI flash and nowhere sources which are in the same order per default but having this explicit override prevents using eMMC or SD card (or EXT4) as environment source. Signed-off-by: Jakob Riepler Reviewed-by: Patrick Delaunay --- board/dhelectronics/dh_stm32mp1/board.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'board') diff --git a/board/dhelectronics/dh_stm32mp1/board.c b/board/dhelectronics/dh_stm32mp1/board.c index ae8d581d1c..17dbf20d76 100644 --- a/board/dhelectronics/dh_stm32mp1/board.c +++ b/board/dhelectronics/dh_stm32mp1/board.c @@ -653,18 +653,6 @@ int board_interface_eth_init(struct udevice *dev, return 0; } -enum env_location env_get_location(enum env_operation op, int prio) -{ - if (prio) - return ENVL_UNKNOWN; - -#ifdef CONFIG_ENV_IS_IN_SPI_FLASH - return ENVL_SPI_FLASH; -#else - return ENVL_NOWHERE; -#endif -} - #if defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, struct bd_info *bd) { -- cgit From 4b64265bb472fba6c820eb81074221c4bd485ba2 Mon Sep 17 00:00:00 2001 From: Patrick Delaunay Date: Fri, 3 Jul 2020 17:45:07 +0200 Subject: board: update test on misc_read result in board_late_init Update management of misc_read, which now return length of data after the commit 8729b1ae2cbd ("misc: Update read() and write() methods to return bytes xfered") Fixes: 8b8b3d6b55b9 ("stm32mp1: board: add environment variable for board id and board rev") Signed-off-by: Patrick Delaunay Reviewed-by: Patrice Chotard --- board/st/stm32mp1/stm32mp1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'board') diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 158a7d6aaa..1d274c3157 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -686,7 +686,7 @@ int board_late_init(void) if (!ret) ret = misc_read(dev, STM32_BSEC_SHADOW(BSEC_OTP_BOARD), &otp, sizeof(otp)); - if (!ret && otp) { + if (ret > 0 && otp) { snprintf(buf, sizeof(buf), "0x%04x", otp >> 16); env_set("board_id", buf); -- cgit