]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
imx: kontron-sl-mx8mm: Enable environment in MMC
authorFrieder Schrempf <frieder.schrempf@kontron.de>
Wed, 24 Aug 2022 13:59:08 +0000 (15:59 +0200)
committerStefano Babic <sbabic@denx.de>
Thu, 20 Oct 2022 15:35:51 +0000 (17:35 +0200)
In case we boot from SD card or eMMC, we also want to load
the environment from the according boot device.

Signed-off-by: Frieder Schrempf <frieder.schrempf@kontron.de>
Reviewed-by: Fabio Estevam <festevam@denx.de>
board/kontron/sl-mx8mm/sl-mx8mm.c
configs/kontron-sl-mx8mm_defconfig

index fea9327837427ac926e1bc0e3d87e80a42e556b0..416c4cbb407ce91a45ac8e431b968d5f5cf05171 100644 (file)
@@ -4,10 +4,13 @@
  */
 
 #include <asm/arch/imx-regs.h>
+#include <asm/arch/sys_proto.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
+#include <asm/mach-imx/boot_mode.h>
 #include <efi.h>
 #include <efi_loader.h>
+#include <env_internal.h>
 #include <fdt_support.h>
 #include <linux/errno.h>
 #include <linux/kernel.h>
@@ -117,3 +120,31 @@ int board_init(void)
 {
        return 0;
 }
+
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+       enum boot_device boot_dev = get_boot_device();
+
+       if (prio)
+               return ENVL_UNKNOWN;
+
+       /*
+        * Make sure that the environment is loaded from
+        * the MMC if we are running from SD card or eMMC.
+        */
+       if (CONFIG_IS_ENABLED(ENV_IS_IN_MMC) &&
+           (boot_dev == SD1_BOOT || boot_dev == SD2_BOOT))
+               return ENVL_MMC;
+
+       if (CONFIG_IS_ENABLED(ENV_IS_IN_SPI_FLASH))
+               return ENVL_SPI_FLASH;
+
+       return ENVL_NOWHERE;
+}
+
+#if defined(CONFIG_ENV_IS_IN_MMC)
+int board_mmc_get_env_dev(int devno)
+{
+       return devno;
+}
+#endif
index e796189f5722126bc757578ff0aa34bdca01d4cc..18b926e357f786b95b63f5aaab3505ba306bf899 100644 (file)
@@ -71,6 +71,7 @@ CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_EXT4_WRITE=y
 CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 CONFIG_SYS_REDUNDAND_ENVIRONMENT=y
 CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y