From 3f7f73165379feaf002e07b4ed676e36992173f7 Mon Sep 17 00:00:00 2001 From: Frieder Schrempf Date: Wed, 24 Aug 2022 15:59:08 +0200 Subject: imx: kontron-sl-mx8mm: Enable environment in MMC 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 Reviewed-by: Fabio Estevam --- board/kontron/sl-mx8mm/sl-mx8mm.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'board/kontron') diff --git a/board/kontron/sl-mx8mm/sl-mx8mm.c b/board/kontron/sl-mx8mm/sl-mx8mm.c index fea9327837..416c4cbb40 100644 --- a/board/kontron/sl-mx8mm/sl-mx8mm.c +++ b/board/kontron/sl-mx8mm/sl-mx8mm.c @@ -4,10 +4,13 @@ */ #include +#include #include #include +#include #include #include +#include #include #include #include @@ -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 -- cgit v1.2.3