rockchip: odroid-go2: Select board FDT from FIT in SPL

Include FDTs for all three board variants in the FIT image and adjust
the board selection code to use correct FDT in U-Boot proper.

E.g. use the odroid-go3 DT for a ODROID-GO Super device:

  U-Boot 2025.07 (Jul 13 2025 - 10:07:16 +0000)

  Model: ODROID-GO Super
  DRAM:  1 GiB (total 1022 MiB)
  PMIC:  RK817 (on=0x80, off=0x08)

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
This commit is contained in:
Jonas Karlman
2025-08-31 16:49:29 +00:00
committed by Tom Rini
parent 1a267cbc0d
commit b3438ed24f
6 changed files with 55 additions and 16 deletions

View File

@@ -39,7 +39,8 @@
};
&saradc {
bootph-all;
bootph-pre-ram;
vdd-microvolts = <1800000>;
};
&sfc {

View File

@@ -0,0 +1,3 @@
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
#include "rk3326-odroid-go2-u-boot.dtsi"

View File

@@ -0,0 +1,3 @@
// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
#include "rk3326-odroid-go2-u-boot.dtsi"

View File

@@ -9,4 +9,10 @@ config SYS_VENDOR
config SYS_CONFIG_NAME
default "odroid_go2"
config BOARD_SPECIFIC_OPTIONS # dummy
def_bool y
select ADC
select BOARD_TYPES
select SPL_ADC
endif

View File

@@ -10,6 +10,8 @@
#include <env.h>
#include <stdlib.h>
DECLARE_GLOBAL_DATA_PTR;
#define DTB_DIR "rockchip/"
struct oga_model {
@@ -20,7 +22,7 @@ struct oga_model {
};
enum oga_device_id {
OGA,
OGA = 1,
OGA_V11,
OGS,
};
@@ -50,15 +52,10 @@ static const struct oga_model oga_model_details[] = {
},
};
/* Detect which Odroid Go Advance device we are using so as to load the
* correct devicetree for Linux. Set an environment variable once
* found. The detection depends on the value of ADC channel 0.
*/
int oga_detect_device(void)
static int oga_read_board_id(void)
{
u32 adc_info;
int ret, i;
int board_id = -ENXIO;
int i, ret;
ret = adc_channel_single_shot("saradc@ff288000", 0, &adc_info);
if (ret) {
@@ -72,22 +69,32 @@ int oga_detect_device(void)
* accounted for this with a 5% tolerance, so assume a +- value
* of 50 should be enough.
*/
for (i = 0; i < ARRAY_SIZE(oga_model_details); i++) {
for (i = 1; i < ARRAY_SIZE(oga_model_details); i++) {
u32 adc_min = oga_model_details[i].adc_value - 50;
u32 adc_max = oga_model_details[i].adc_value + 50;
if (adc_min < adc_info && adc_max > adc_info) {
board_id = i;
break;
}
if (adc_min < adc_info && adc_max > adc_info)
return i;
}
return -ENODEV;
}
/* Detect which Odroid Go Advance device we are using so as to load the
* correct devicetree for Linux. Set an environment variable once
* found. The detection depends on the value of ADC channel 0.
*/
static int oga_detect_device(void)
{
int board_id;
board_id = oga_read_board_id();
if (board_id < 0)
return board_id;
gd->board_type = board_id;
env_set("board", oga_model_details[board_id].board);
env_set("board_name",
oga_model_details[board_id].board_name);
env_set("board_name", oga_model_details[board_id].board_name);
env_set("fdtfile", oga_model_details[board_id].fdtfile);
return 0;
@@ -105,3 +112,20 @@ int rk_board_late_init(void)
return 0;
}
int board_fit_config_name_match(const char *name)
{
int board_id;
if (!gd->board_type) {
board_id = oga_read_board_id();
if (board_id < 0)
return board_id;
gd->board_type = board_id;
}
if (!strcmp(name, oga_model_details[gd->board_type].fdtfile))
return 0;
return -EINVAL;
}

View File

@@ -8,6 +8,7 @@ CONFIG_SF_DEFAULT_MODE=0x1000
CONFIG_ENV_SIZE=0x4000
CONFIG_ENV_OFFSET=0x4000
CONFIG_DEFAULT_DEVICE_TREE="rockchip/rk3326-odroid-go2"
CONFIG_OF_LIBFDT_OVERLAY=y
CONFIG_DM_RESET=y
CONFIG_ROCKCHIP_PX30=y
CONFIG_ROCKCHIP_RK8XX_DISABLE_BOOT_ON_POWERON=y
@@ -61,6 +62,7 @@ CONFIG_CMD_USB_MASS_STORAGE=y
CONFIG_EFI_PARTITION_ENTRIES_NUMBERS=64
CONFIG_SPL_OF_CONTROL=y
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_SPL_DM_SEQ_ALIAS=y