Override env_get_location function at board level, previously dropped
down from soc.c

References:
 - commit 63cd508ce696cb1ef0867d9ab6e93d36df339e0a

Signed-off-by: Tommaso Merciai <tomm.merc...@gmail.com>
---
Changes since v1:
 - Fix code indentation using checkpatch as suggested by MBehĂșn

 board/freescale/imx8mn_evk/imx8mn_evk.c | 35 +++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/board/freescale/imx8mn_evk/imx8mn_evk.c 
b/board/freescale/imx8mn_evk/imx8mn_evk.c
index 9a0a0488bf..ec1ab202a6 100644
--- a/board/freescale/imx8mn_evk/imx8mn_evk.c
+++ b/board/freescale/imx8mn_evk/imx8mn_evk.c
@@ -5,11 +5,46 @@
 
 #include <common.h>
 #include <env.h>
+#include <env_internal.h>
 #include <init.h>
+#include <asm/arch/sys_proto.h>
+#include <asm/mach-imx/boot_mode.h>
 #include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
+enum env_location env_get_location(enum env_operation op, int prio)
+{
+       enum boot_device dev = get_boot_device();
+       enum env_location env_loc = ENVL_UNKNOWN;
+
+       if (prio)
+               return env_loc;
+
+       if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH) && dev == QSPI_BOOT) {
+               env_loc = ENVL_SPI_FLASH;
+       } else if (IS_ENABLED(CONFIG_ENV_IS_IN_NAND) && dev == NAND_BOOT) {
+               env_loc = ENVL_NAND;
+       } else if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC)) {
+               switch (dev) {
+               case SD1_BOOT:
+               case SD2_BOOT:
+               case SD3_BOOT:
+               case MMC1_BOOT:
+               case MMC2_BOOT:
+               case MMC3_BOOT:
+                       env_loc = ENVL_MMC;
+                       break;
+               default:
+                       break;
+               }
+       } else if (IS_ENABLED(CONFIG_ENV_IS_NOWHERE)) {
+               env_loc = ENVL_MMC;
+       }
+
+       return env_loc;
+}
+
 int board_init(void)
 {
        return 0;
-- 
2.25.1

Reply via email to