]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
rockchip: odroid-go2: Select board FDT from FIT in SPL
authorJonas Karlman <jonas@kwiboo.se>
Sun, 31 Aug 2025 16:49:29 +0000 (16:49 +0000)
committerTom Rini <trini@konsulko.com>
Sun, 2 Nov 2025 18:14:03 +0000 (12:14 -0600)
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>
arch/arm/dts/rk3326-odroid-go2-u-boot.dtsi
arch/arm/dts/rk3326-odroid-go2-v11-u-boot.dtsi [new file with mode: 0644]
arch/arm/dts/rk3326-odroid-go3-u-boot.dtsi [new file with mode: 0644]
board/hardkernel/odroid_go2/Kconfig
board/hardkernel/odroid_go2/go2.c
configs/odroid-go2_defconfig

index 6c6efa964d804ea3866ed89f7f501394b4570c69..393710246e1c7baaf50638baeab8d7372f4a5674 100644 (file)
@@ -39,7 +39,8 @@
 };
 
 &saradc {
-       bootph-all;
+       bootph-pre-ram;
+       vdd-microvolts = <1800000>;
 };
 
 &sfc {
diff --git a/arch/arm/dts/rk3326-odroid-go2-v11-u-boot.dtsi b/arch/arm/dts/rk3326-odroid-go2-v11-u-boot.dtsi
new file mode 100644 (file)
index 0000000..89b2d95
--- /dev/null
@@ -0,0 +1,3 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+#include "rk3326-odroid-go2-u-boot.dtsi"
diff --git a/arch/arm/dts/rk3326-odroid-go3-u-boot.dtsi b/arch/arm/dts/rk3326-odroid-go3-u-boot.dtsi
new file mode 100644 (file)
index 0000000..89b2d95
--- /dev/null
@@ -0,0 +1,3 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+
+#include "rk3326-odroid-go2-u-boot.dtsi"
index 82988dffb3cb1e42403e4c8db988cc950f04155b..dd6e366282e3fef867bced8db301ef3c50b2af98 100644 (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
index a0338ead3b5ac8fe93b5012b4cebb21065583111..9d9f3cee36a551660d4d5b3e75579b0441e65f83 100644 (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;
+}
index 09ba6b7fcfaad363ad0bee4024a94994b9c036a6..05d9f9c09dee4d5e7484e837cd54ee935c4aef71 100644 (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