summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Schulz <quentin.schulz@theobroma-systems.com>2022-09-15 11:14:25 +0200
committerQuentin Schulz <quentin.schulz@theobroma-systems.com>2022-10-19 12:13:03 +0200
commita6949bb1bb465443a5926a2c4bf7afd922f2f311 (patch)
tree12876a186b1122306626604faabaebb5df391f3d
parente23d3f1ba3c75f3c9d83a194335dddbb78a28078 (diff)
FROMLIST: rockchip: puma-rk3399: load environment from same MMC as used for loading U-Boot proper
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> Reviewed-by: Kever Yang <kever.yang@rock-chips.com> Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com> Link: https://lore.kernel.org/r/20220915091432.789294-6-foss+uboot@0leil.net Signed-off-by: Quentin Schulz <quentin.schulz@theobroma-systems.com>
-rw-r--r--board/theobroma-systems/puma_rk3399/puma-rk3399.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/board/theobroma-systems/puma_rk3399/puma-rk3399.c b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
index ce3436b770..5e5e58c88e 100644
--- a/board/theobroma-systems/puma_rk3399/puma-rk3399.c
+++ b/board/theobroma-systems/puma_rk3399/puma-rk3399.c
@@ -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;