]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
rockchip: puma-rk3399: load environment from same MMC as used for loading U-Boot...
authorQuentin Schulz <quentin.schulz@theobroma-systems.com>
Thu, 15 Sep 2022 09:14:25 +0000 (11:14 +0200)
committerKever Yang <kever.yang@rock-chips.com>
Wed, 19 Oct 2022 11:30:49 +0000 (19:30 +0800)
Automatically detect which MMC device (SD-Card or eMMC) was used to load
U-Boot proper and load the environment from that MMC device instead of
a hardcoded one.

Cc: Quentin Schulz <foss+uboot@0leil.net>
Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
board/theobroma-systems/puma_rk3399/puma-rk3399.c

index b2c0ff5afe116473bc05ae86dcadec47dd0adc30..f41293080cb542f9135f766ee21ad7b4f3e3eca8 100644 (file)
@@ -113,6 +113,28 @@ static int setup_boottargets(void)
        return 0;
 }
 
+int mmc_get_env_dev(void)
+{
+       const char *boot_device =
+               ofnode_read_chosen_string("u-boot,spl-boot-device");
+
+       if (!boot_device) {
+               debug("%s: /chosen/u-boot,spl-boot-device not set\n",
+                     __func__);
+               return CONFIG_SYS_MMC_ENV_DEV;
+       }
+
+       debug("%s: booted from %s\n", __func__, boot_device);
+
+       if (!strcmp(boot_device, "/mmc@fe320000"))
+               return 1;
+
+       if (!strcmp(boot_device, "/mmc@fe330000"))
+               return 0;
+
+       return CONFIG_SYS_MMC_ENV_DEV;
+}
+
 int misc_init_r(void)
 {
        const u32 cpuid_offset = 0x7;