From: Marek Szyprowski Date: Fri, 18 Dec 2020 14:26:45 +0000 (+0100) Subject: board: amlogic: add MMC boot device detection for environment load X-Git-Url: http://git.dujemihanovic.xyz/img/sics.gif?a=commitdiff_plain;h=aa3c7912cb6cac8a214e5aa5a1a4251303c9a2c5;p=u-boot.git board: amlogic: add MMC boot device detection for environment load Detect eMMC or SD card boot on Odroid-C4/N2 and Khadas VIM3(l) boards and report proper MMC device for the environment loading code. This allows to automatically load and store environment variables on the FAT partition or RAW offset of the MMC device without the need to use different configurations on eMMC and SD card. To use this feature with environment stored on FAT partition, one has to specify an empty device part (i.e. ":1" for the first partition) in CONFIG_ENV_FAT_DEVICE_AND_PART to let the code to set the device to the value returned by mmc_get_env_dev() function. Signed-off-by: Marek Szyprowski Reviewed-by: Jaehoon Chung Signed-off-by: Neil Armstrong --- diff --git a/board/amlogic/odroid-n2/odroid-n2.c b/board/amlogic/odroid-n2/odroid-n2.c index dc0d933a39..d9955433bf 100644 --- a/board/amlogic/odroid-n2/odroid-n2.c +++ b/board/amlogic/odroid-n2/odroid-n2.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -18,6 +19,13 @@ #define EFUSE_MAC_SIZE 12 #define MAC_ADDR_LEN 6 +int mmc_get_env_dev(void) +{ + if (meson_get_boot_device() == BOOT_DEVICE_EMMC) + return 1; + return 0; +} + int misc_init_r(void) { u8 mac_addr[MAC_ADDR_LEN]; diff --git a/board/amlogic/vim3/vim3.c b/board/amlogic/vim3/vim3.c index a36df61583..824fff8262 100644 --- a/board/amlogic/vim3/vim3.c +++ b/board/amlogic/vim3/vim3.c @@ -10,11 +10,19 @@ #include #include #include +#include #include #include #include #include "khadas-mcu.h" +int mmc_get_env_dev(void) +{ + if (meson_get_boot_device() == BOOT_DEVICE_EMMC) + return 2; + return 1; +} + /* * The VIM3 on-board MCU can mux the PCIe/USB3.0 shared differential * lines using a FUSB340TMX USB 3.1 SuperSpeed Data Switch between