board: starfive: spl: Support multiple DTBs for JH7110 based boards
authorHal Feng <hal.feng@starfivetech.com>
Sun, 8 Dec 2024 09:19:41 +0000 (17:19 +0800)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Wed, 18 Dec 2024 05:19:16 +0000 (13:19 +0800)
Get product ID and the other information from EEPROM, use them to select
the correct DTB.

Tested-by: Anand Moon <linux.amoon@gmail.com>
Tested-by: E Shattow <lucent@gmail.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Hal Feng <hal.feng@starfivetech.com>
board/starfive/visionfive2/spl.c

index cf7f39d..22afd76 100644 (file)
@@ -113,7 +113,36 @@ void board_init_f(ulong dummy)
 #if CONFIG_IS_ENABLED(LOAD_FIT)
 int board_fit_config_name_match(const char *name)
 {
-       /* boot using first FIT config */
-       return 0;
+       const char *product_id;
+       u8 version;
+
+       product_id = get_product_id_from_eeprom();
+
+       if (!strncmp(product_id, "VF7110", 6)) {
+               version = get_pcb_revision_from_eeprom();
+               if ((version == 'b' || version == 'B') &&
+                   !strcmp(name, "jh7110-starfive-visionfive-2-v1.3b"))
+                       return 0;
+
+               if ((version == 'a' || version == 'A') &&
+                   !strcmp(name, "jh7110-starfive-visionfive-2-v1.2a"))
+                       return 0;
+       } else if (!strncmp(product_id, "MARS", 4) &&
+                  !strcmp(name, "jh7110-milkv-mars")) {
+               return 0;
+       } else if (!strncmp(product_id, "MARC", 4)) {
+               if (!get_mmc_size_from_eeprom()) {
+                       if (!strcmp(name, "jh7110-milkv-mars-cm-lite"))
+                               return 0;
+               } else {
+                       if (!strcmp(name, "jh7110-milkv-mars-cm"))
+                               return 0;
+               }
+       } else if (!strncmp(product_id, "STAR64", 6) &&
+                  !strcmp(name, "jh7110-pine64-star64")) {
+               return 0;
+       }
+
+       return -EINVAL;
 }
 #endif