]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: ti: j721s2: Add support for detecting multiple device trees
authorSinthu Raja <sinthu.raja@ti.com>
Tue, 10 Jan 2023 15:47:52 +0000 (21:17 +0530)
committerTom Rini <trini@konsulko.com>
Fri, 27 Jan 2023 17:51:26 +0000 (12:51 -0500)
Update the board_fit_config_name_match() to choose the right dtb
based on the board name read from EEPROM.

Also restrict multpile EEPROM reads by verifying if EEPROM is already
read

Signed-off-by: Sinthu Raja <sinthu.raja@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
board/ti/j721s2/evm.c

index db69aa150731685830432b8f1abb7e344e92ca31..9b159e3d5c68c30228a2d85f3007d6a77affa9ff 100644 (file)
@@ -72,16 +72,6 @@ int dram_init_banksize(void)
        return 0;
 }
 
-#ifdef CONFIG_SPL_LOAD_FIT
-int board_fit_config_name_match(const char *name)
-{
-       if (!strcmp(name, "k3-j721s2-common-proc-board"))
-               return 0;
-
-       return -1;
-}
-#endif
-
 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
 int ft_board_setup(void *blob, struct bd_info *bd)
 {
@@ -111,6 +101,9 @@ int do_board_detect(void)
 {
        int ret;
 
+       if (board_ti_was_eeprom_read())
+               return 0;
+
        ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
                                         CONFIG_EEPROM_CHIP_ADDRESS);
        if (ret) {
@@ -179,6 +172,28 @@ static void setup_serial(void)
 }
 #endif
 
+/*
+ * This function chooses the right dtb based on the board name read from
+ * EEPROM if the EEPROM is programmed. Also, by default the boot chooses
+ * the EVM DTB if there is no EEPROM is programmed or not detected.
+ */
+#ifdef CONFIG_SPL_LOAD_FIT
+int board_fit_config_name_match(const char *name)
+{
+       bool eeprom_read = board_ti_was_eeprom_read();
+
+       if (!eeprom_read || board_is_j721s2_som()) {
+               if (!strcmp(name, "k3-j721s2-common-proc-board"))
+                       return 0;
+       } else if (!eeprom_read || board_is_am68_sk_som()) {
+               if (!strcmp(name, "k3-am68-sk-base-board"))
+                       return 0;
+       }
+
+       return -1;
+}
+#endif
+
 int board_late_init(void)
 {
        if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {