Use the EEPROM information to select the correct DTB.

Signed-off-by: Hal Feng <[email protected]>
---
 board/starfive/visionfive2/spl.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/board/starfive/visionfive2/spl.c b/board/starfive/visionfive2/spl.c
index cf7f39d5c5..7f57f80de3 100644
--- a/board/starfive/visionfive2/spl.c
+++ b/board/starfive/visionfive2/spl.c
@@ -113,7 +113,28 @@ 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();
+       version = get_pcb_revision_from_eeprom();
+
+       if (!strncmp(product_id, "VF7110", 6)) {
+               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, "STAR64", 6) &&
+                   !strcmp(name, "jh7110-pine64-star64")) {
+               return 0;
+       }
+
+       return -EINVAL;
 }
 #endif
-- 
2.43.2

Reply via email to