rockchip: odroid-go2: Use env from same storage FIT was loaded from

Change to dynamically select what storage media to use for the U-Boot
environment depending on from what storage media the FIT images was
loaded from, fall back to use env from nowhere.

  U-Boot SPL 2025.07 (Jul 13 2025 - 10:07:16 +0000)
  Trying to boot from MMC1
  ...
  Loading Environment from MMC... Reading from MMC(0)...

or

  U-Boot SPL 2025.07 (Jul 13 2025 - 10:07:16 +0000)
  Trying to boot from SPI
  ...
  Loading Environment from SPIFlash...

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Quentin Schulz <quentin.schulz@cherry.de>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
This commit is contained in:
Jonas Karlman 2025-08-31 16:49:30 +00:00 committed by Tom Rini
parent b3438ed24f
commit b032ac74ac
3 changed files with 37 additions and 0 deletions

View File

@ -13,6 +13,7 @@ config BOARD_SPECIFIC_OPTIONS # dummy
def_bool y
select ADC
select BOARD_TYPES
select ENV_IS_NOWHERE
select SPL_ADC
endif

View File

@ -7,7 +7,9 @@
#include <adc.h>
#include <asm/io.h>
#include <dm.h>
#include <dm/uclass-internal.h>
#include <env.h>
#include <env_internal.h>
#include <stdlib.h>
DECLARE_GLOBAL_DATA_PTR;
@ -129,3 +131,35 @@ int board_fit_config_name_match(const char *name)
return -EINVAL;
}
enum env_location env_get_location(enum env_operation op, int prio)
{
const char *boot_device;
struct udevice *dev;
ofnode node;
if (prio)
return ENVL_UNKNOWN;
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 ENVL_NOWHERE;
}
debug("%s: booted from %s\n", __func__, boot_device);
node = ofnode_path(boot_device);
if (!ofnode_valid(node))
return ENVL_NOWHERE;
if (IS_ENABLED(CONFIG_ENV_IS_IN_SPI_FLASH) &&
!uclass_find_device_by_ofnode(UCLASS_SPI_FLASH, node, &dev))
return ENVL_SPI_FLASH;
if (IS_ENABLED(CONFIG_ENV_IS_IN_MMC) &&
!uclass_find_device_by_ofnode(UCLASS_MMC, node, &dev))
return ENVL_MMC;
return ENVL_NOWHERE;
}

View File

@ -65,6 +65,8 @@ CONFIG_OF_LIVE=y
CONFIG_OF_LIST="rockchip/rk3326-odroid-go2 rockchip/rk3326-odroid-go2-v11 rockchip/rk3326-odroid-go3"
CONFIG_OF_SPL_REMOVE_PROPS="interrupt-parent assigned-clocks assigned-clock-rates assigned-clock-parents"
CONFIG_ENV_IS_IN_MMC=y
CONFIG_ENV_IS_IN_SPI_FLASH=y
CONFIG_ENV_RELOC_GD_ENV_ADDR=y
CONFIG_SPL_DM_SEQ_ALIAS=y
CONFIG_REGMAP=y
CONFIG_SPL_REGMAP=y