Skip to contentSkip to conversation

board: ti: am62x: Add EEPROM support and refactor board detection

PATCH Superseded Guillaume La Roque (TI.com) 3 participants 11 messages Oct 24, 2025 – Oct 31, 2025

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover board: ti: am62x: Add EEPROM support and refactor board detection

This series adds EEPROM board detection support for AM62x and refactors the board detection code across AM6x family boards to eliminate code duplication.

The series introduces two new generic functions for AM6x boards:
- do_board_detect_am6(): Reads the on-board EEPROM with fallback logic to alternate I2C addresses
- setup_serial_am6(): Sets up the serial number environment variable from EEPROM data

---
Changes in v2:
- Create Generic function
- migrate am64 and am65 on it
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Guillaume La Roque (TI.com) (4):
board: ti: common: Add generic AM6x board detection functions
board: am62x: Add support for reading eeprom data
board: am64x: Use generic AM6x board detection functions
board: am65x: Use generic AM6x board detection function

 arch/arm/mach-k3/am62x/Kconfig |  3 +++
 board/ti/am62x/evm.c           | 54 +++++++++++++++++++++++++++++++++++++++++-
 board/ti/am64x/evm.c           | 45 +++--------------------------------
 board/ti/am65x/evm.c           | 17 ++-----------
 board/ti/common/board_detect.c | 43 +++++++++++++++++++++++++++++++++
 board/ti/common/board_detect.h | 22 +++++++++++++++++
 configs/am62x_evm_r5_defconfig |  1 +
 7 files changed, 127 insertions(+), 58 deletions(-)

---
base-commit: 6a56d10fdcf1309d2070b62dc15e80a047da971b
change-id: 20251016-am62xeeprom-41a1920b8bd2

Best regards,

Signature · 1 line
Guillaume La Roque (TI.com) <[email protected]>
#1 lore raw

PATCH v2 1/4 board: ti: common: Add generic AM6x board detection functions

Add two new generic functions for AM6x family boards to simplify board-specific implementations:

- do_board_detect_am6(): Generic board detection function that reads the on-board EEPROM. It first attempts to read at the configured address, and if that fails, tries the alternate address (CONFIG_EEPROM_CHIP_ADDRESS + 1). This provides a common implementation that can be used across different AM6x boards.

- setup_serial_am6(): Sets up the serial number environment variable from the EEPROM data. The serial number is converted from hexadecimal string format to a 16-character hexadecimal representation and stored in the "serial#" environment variable.

Both functions are protected by CONFIG_IS_ENABLED(TI_I2C_BOARD_DETECT) and are designed to be used by AM62x, AM64x, AM65x, and other AM6x family boards.

---
 board/ti/common/board_detect.c | 43 ++++++++++++++++++++++++++++++++++++++++++
 board/ti/common/board_detect.h | 22 +++++++++++++++++++++
 2 files changed, 65 insertions(+)
board/ti/common/board_detect.c +43 -0
index a43cc075b92..d49e26fa453 100644
@@ -824,3 +824,46 @@ bool __maybe_unused board_ti_was_eeprom_read(void)
 	else
 		return false;
 }
+
+#if CONFIG_IS_ENABLED(TI_I2C_BOARD_DETECT)
+int do_board_detect_am6(void)
+{
+	int ret;
+
+	ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
+					 CONFIG_EEPROM_CHIP_ADDRESS);
+	if (ret) {
+		printf("EEPROM not available at 0x%02x, trying to read at 0x%02x\n",
+		       CONFIG_EEPROM_CHIP_ADDRESS,
+		       CONFIG_EEPROM_CHIP_ADDRESS + 1);
+		ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
+						 CONFIG_EEPROM_CHIP_ADDRESS +
+							 1);
+		if (ret)
+			pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
+			       CONFIG_EEPROM_CHIP_ADDRESS + 1, ret);
+	}
+
+	return ret;
+}
+
+void setup_serial_am6(void)
+{
+	struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
+	unsigned long board_serial;
+	char *endp;
+	char serial_string[17] = { 0 };
+
+	if (env_get("serial#"))
+		return;
+
+	board_serial = simple_strtoul(ep->serial, &endp, 16);
+	if (*endp != '\0') {
+		pr_err("Error: Can't set serial# to %s\n", ep->serial);
+		return;
+	}
+
+	snprintf(serial_string, sizeof(serial_string), "%016lx", board_serial);
+	env_set("serial#", serial_string);
+}
+#endif
board/ti/common/board_detect.h +22 -0
index b057f3b2269..26ada2a449c 100644
@@ -313,6 +313,28 @@ int __maybe_unused ti_i2c_eeprom_am6_get(int bus_addr, int dev_addr,
  */
 int __maybe_unused ti_i2c_eeprom_am6_get_base(int bus_addr, int dev_addr);
 
+/**
+ * do_board_detect_am6() - Detect AM6x board and read EEPROM data
+ *
+ * This is a generic board detection function for AM6x family boards.
+ * It attempts to read the on-board EEPROM at the configured address,
+ * and if that fails, tries the alternate address (CONFIG_EEPROM_CHIP_ADDRESS + 1).
+ *
+ * Return: 0 on success or corresponding error on failure.
+ */
+int do_board_detect_am6(void);
+
+/**
+ * setup_serial_am6() - Setup serial number environment variable for AM6x boards
+ *
+ * This function reads the serial number from the AM6x EEPROM data and
+ * sets the "serial#" environment variable. The serial number is converted
+ * from hexadecimal string format to a 16-character hexadecimal representation.
+ *
+ * EEPROM should be already read before calling this function.
+ */
+void setup_serial_am6(void);
+
 #ifdef CONFIG_TI_I2C_BOARD_DETECT
 /**
  * board_ti_is() - Board detection logic for TI EVMs
Signature · 1 line
2.34.1
Reviewed-by on v2 1/4
#2 lore raw

Re: [PATCH v2 1/4] board: ti: common: Add generic AM6x board detection functions

Hi Guillaume,

Thank you for the patch.

Quoted 14 lines · Guillaume La Roque (TI.com)

Add two new generic functions for AM6x family boards to simplify board-specific implementations:

- do_board_detect_am6(): Generic board detection function that reads the on-board EEPROM. It first attempts to read at the configured address, and if that fails, tries the alternate address (CONFIG_EEPROM_CHIP_ADDRESS + 1). This provides a common implementation that can be used across different AM6x boards.

- setup_serial_am6(): Sets up the serial number environment variable from the EEPROM data. The serial number is converted from hexadecimal string format to a 16-character hexadecimal representation and stored in the "serial#" environment variable.

Quoted 5 lines

Both functions are protected by CONFIG_IS_ENABLED(TI_I2C_BOARD_DETECT) and are designed to be used by AM62x, AM64x, AM65x, and other AM6x family boards.

Quoted 92 lines
---
 board/ti/common/board_detect.c | 43 ++++++++++++++++++++++++++++++++++++++++++
 board/ti/common/board_detect.h | 22 +++++++++++++++++++++
 2 files changed, 65 insertions(+)
board/ti/common/board_detect.c +43 -0
index a43cc075b92..d49e26fa453 100644
@@ -824,3 +824,46 @@ bool __maybe_unused board_ti_was_eeprom_read(void)
 	else
 		return false;
 }
+
+#if CONFIG_IS_ENABLED(TI_I2C_BOARD_DETECT)
+int do_board_detect_am6(void)
+{
+	int ret;
+
+	ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
+					 CONFIG_EEPROM_CHIP_ADDRESS);
+	if (ret) {
+		printf("EEPROM not available at 0x%02x, trying to read at 0x%02x\n",
+		       CONFIG_EEPROM_CHIP_ADDRESS,
+		       CONFIG_EEPROM_CHIP_ADDRESS + 1);
+		ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
+						 CONFIG_EEPROM_CHIP_ADDRESS +
+							 1);
+		if (ret)
+			pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
+			       CONFIG_EEPROM_CHIP_ADDRESS + 1, ret);
+	}
+
+	return ret;
+}
+
+void setup_serial_am6(void)
+{
+	struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
+	unsigned long board_serial;
+	char *endp;
+	char serial_string[17] = { 0 };
+
+	if (env_get("serial#"))
+		return;
+
+	board_serial = simple_strtoul(ep->serial, &endp, 16);
+	if (*endp != '\0') {
+		pr_err("Error: Can't set serial# to %s\n", ep->serial);
+		return;
+	}
+
+	snprintf(serial_string, sizeof(serial_string), "%016lx", board_serial);
+	env_set("serial#", serial_string);
+}
+#endif
board/ti/common/board_detect.h +22 -0
index b057f3b2269..26ada2a449c 100644
@@ -313,6 +313,28 @@ int __maybe_unused ti_i2c_eeprom_am6_get(int bus_addr, int dev_addr,
  */
 int __maybe_unused ti_i2c_eeprom_am6_get_base(int bus_addr, int dev_addr);
 
+/**
+ * do_board_detect_am6() - Detect AM6x board and read EEPROM data
+ *
+ * This is a generic board detection function for AM6x family boards.
+ * It attempts to read the on-board EEPROM at the configured address,
+ * and if that fails, tries the alternate address (CONFIG_EEPROM_CHIP_ADDRESS + 1).
+ *
+ * Return: 0 on success or corresponding error on failure.
+ */
+int do_board_detect_am6(void);
+
+/**
+ * setup_serial_am6() - Setup serial number environment variable for AM6x boards
+ *
+ * This function reads the serial number from the AM6x EEPROM data and
+ * sets the "serial#" environment variable. The serial number is converted
+ * from hexadecimal string format to a 16-character hexadecimal representation.
+ *
+ * EEPROM should be already read before calling this function.
+ */
+void setup_serial_am6(void);
+
 #ifdef CONFIG_TI_I2C_BOARD_DETECT
 /**
  * board_ti_is() - Board detection logic for TI EVMs
Signature · 2 lines
-- 
2.34.1
#3 lore raw

PATCH v2 2/4 board: am62x: Add support for reading eeprom data

In reply to Guillaume La Roque (TI.com)

I2C EEPROM data contains the board name and its revision. Add support for:
- Reading EEPROM data and store a copy at end of SRAM
- Updating env variable with relevant board info
- Printing board info during boot

Use the generic do_board_detect_am6() and setup_serial_am6() functions to avoid code duplication across AM6x family boards.

---
 arch/arm/mach-k3/am62x/Kconfig |  3 +++
 board/ti/am62x/evm.c           | 54 +++++++++++++++++++++++++++++++++++++++++-
 configs/am62x_evm_r5_defconfig |  1 +
 3 files changed, 57 insertions(+), 1 deletion(-)
arch/arm/mach-k3/am62x/Kconfig +3 -0
index 81199ada3a1..f7ad52db7d8 100644
@@ -14,6 +14,8 @@ config TARGET_AM625_A53_EVM
 	select ARM64
 	select BINMAN
 	select OF_SYSTEM_SETUP
+	imply TI_COMMON_CMD_OPTIONS
+	imply TI_I2C_BOARD_DETECT
 
 config TARGET_AM625_R5_EVM
 	bool "TI K3 based AM625 EVM running on R5"
@@ -25,6 +27,7 @@ config TARGET_AM625_R5_EVM
 	select K3_DDRSS
 	select BINMAN
 	imply SYS_K3_SPL_ATF
+	imply TI_I2C_BOARD_DETECT
 
 config TARGET_PHYCORE_AM62X_A53
 	bool "PHYTEC phyCORE-AM62x running on A53"
board/ti/am62x/evm.c +53 -1

70 lines not on this page · raw message

configs/am62x_evm_r5_defconfig +1 -0
index 18ffc991b25..d42bdf1f074 100644
@@ -85,6 +85,7 @@ CONFIG_SPL_CLK_K3_PLL=y
 CONFIG_SPL_CLK_K3=y
 CONFIG_TI_SCI_PROTOCOL=y
 CONFIG_DA8XX_GPIO=y
+CONFIG_DM_I2C=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_SPL_MISC=y
Signature · 1 line
2.34.1
Reviewed-by on v2 2/4
#4 lore raw

Re: [PATCH v2 2/4] board: am62x: Add support for reading eeprom data

Hi Guillaume,

Thank you for the patch.

Quoted 10 lines · Guillaume La Roque (TI.com)

I2C EEPROM data contains the board name and its revision. Add support for:
- Reading EEPROM data and store a copy at end of SRAM
- Updating env variable with relevant board info
- Printing board info during boot

Use the generic do_board_detect_am6() and setup_serial_am6() functions to avoid code duplication across AM6x family boards.

Quoted 118 lines
---
 arch/arm/mach-k3/am62x/Kconfig |  3 +++
 board/ti/am62x/evm.c           | 54 +++++++++++++++++++++++++++++++++++++++++-
 configs/am62x_evm_r5_defconfig |  1 +
 3 files changed, 57 insertions(+), 1 deletion(-)
arch/arm/mach-k3/am62x/Kconfig +3 -0
index 81199ada3a1..f7ad52db7d8 100644
@@ -14,6 +14,8 @@ config TARGET_AM625_A53_EVM
 	select ARM64
 	select BINMAN
 	select OF_SYSTEM_SETUP
+	imply TI_COMMON_CMD_OPTIONS
+	imply TI_I2C_BOARD_DETECT
 
 config TARGET_AM625_R5_EVM
 	bool "TI K3 based AM625 EVM running on R5"
@@ -25,6 +27,7 @@ config TARGET_AM625_R5_EVM
 	select K3_DDRSS
 	select BINMAN
 	imply SYS_K3_SPL_ATF
+	imply TI_I2C_BOARD_DETECT
 
 config TARGET_PHYCORE_AM62X_A53
 	bool "PHYTEC phyCORE-AM62x running on A53"
board/ti/am62x/evm.c +53 -1
index c2c7a0216b9..591324ecc15 100644
@@ -22,8 +22,16 @@
 #include <dm/uclass.h>
 #include <asm/arch/k3-ddr.h>
 
+#include "../common/board_detect.h"
 #include "../common/fdt_ops.h"
 
+#define board_is_am62x_skevm()  (board_ti_k3_is("AM62-SKEVM") || \
+				 board_ti_k3_is("AM62B-SKEVM"))
+#define board_is_am62b_p1_skevm() board_ti_k3_is("AM62B-SKEVM-P1")
+#define board_is_am62x_lp_skevm()  board_ti_k3_is("AM62-LP-SKEVM")
+#define board_is_am62x_sip_skevm()  board_ti_k3_is("AM62SIP-SKEVM")
+#define board_is_am62x_play()	board_ti_k3_is("BEAGLEPLAY-A0-")
+
 DECLARE_GLOBAL_DATA_PTR;
 
 #if CONFIG_IS_ENABLED(SPLASH_SCREEN)
@@ -74,9 +82,53 @@ struct efi_capsule_update_info update_info = {
 	.images = fw_images,
 };
 
-#ifdef CONFIG_BOARD_LATE_INIT
+#if CONFIG_IS_ENABLED(TI_I2C_BOARD_DETECT)
+int checkboard(void)
+{
+	struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
+
+	if (!do_board_detect_am6())
+		printf("Board: %s rev %s\n", ep->name, ep->version);
+
+	return 0;
+}
+
+#if CONFIG_IS_ENABLED(BOARD_LATE_INIT)
+static void setup_board_eeprom_env(void)
+{
+	char *name = "am62x_skevm";
+
+	if (do_board_detect_am6())
+		goto invalid_eeprom;
+
+	if (board_is_am62x_skevm())
+		name = "am62x_skevm";
+	else if (board_is_am62b_p1_skevm())
+		name = "am62b_p1_skevm";
+	else if (board_is_am62x_lp_skevm())
+		name = "am62x_lp_skevm";
+	else if (board_is_am62x_sip_skevm())
+		name = "am62x_sip_skevm";
+	else if (board_is_am62x_play())
+		name = "am62x_beagleplay";
+	else
+		printf("Unidentified board claims %s in eeprom header\n",
+		       board_ti_get_name());
+
+invalid_eeprom:
+	set_board_info_env_am6(name);
+}
+#endif
+#endif
+
+#if CONFIG_IS_ENABLED(BOARD_LATE_INIT)
 int board_late_init(void)
 {
+	if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
+		setup_board_eeprom_env();
+		setup_serial_am6();
+	}
+
 	ti_set_fdt_env(NULL, NULL);
 	return 0;
 }
configs/am62x_evm_r5_defconfig +1 -0
index 18ffc991b25..d42bdf1f074 100644
@@ -85,6 +85,7 @@ CONFIG_SPL_CLK_K3_PLL=y
 CONFIG_SPL_CLK_K3=y
 CONFIG_TI_SCI_PROTOCOL=y
 CONFIG_DA8XX_GPIO=y
+CONFIG_DM_I2C=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_SPL_MISC=y
Signature · 2 lines
-- 
2.34.1
#5 lore raw

Re: [PATCH v2 2/4] board: am62x: Add support for reading eeprom data

In reply to Guillaume La Roque (TI.com)
Quoted 44 lines · Guillaume La Roque (TI.com)

I2C EEPROM data contains the board name and its revision. Add support for:
- Reading EEPROM data and store a copy at end of SRAM
- Updating env variable with relevant board info
- Printing board info during boot

Use the generic do_board_detect_am6() and setup_serial_am6() functions to avoid code duplication across AM6x family boards.

---
  arch/arm/mach-k3/am62x/Kconfig |  3 +++
  board/ti/am62x/evm.c           | 54 +++++++++++++++++++++++++++++++++++++++++-
  configs/am62x_evm_r5_defconfig |  1 +
  3 files changed, 57 insertions(+), 1 deletion(-)
arch/arm/mach-k3/am62x/Kconfig +3 -0
index 81199ada3a1..f7ad52db7d8 100644
@@ -14,6 +14,8 @@ config TARGET_AM625_A53_EVM
  	select ARM64
  	select BINMAN
  	select OF_SYSTEM_SETUP
+	imply TI_COMMON_CMD_OPTIONS
+	imply TI_I2C_BOARD_DETECT
 
  config TARGET_AM625_R5_EVM
  	bool "TI K3 based AM625 EVM running on R5"
@@ -25,6 +27,7 @@ config TARGET_AM625_R5_EVM
  	select K3_DDRSS
  	select BINMAN
  	imply SYS_K3_SPL_ATF
+	imply TI_I2C_BOARD_DETECT
 
  config TARGET_PHYCORE_AM62X_A53
  	bool "PHYTEC phyCORE-AM62x running on A53"
board/ti/am62x/evm.c +0 -0
index c2c7a0216b9..591324ecc15 100644
@@ -22,8 +22,16 @@
  #include <dm/uclass.h>
  #include <asm/arch/k3-ddr.h>

board/ti/am62x/evm.c line 33

Quoted 10 lines
board/ti/am62x/evm.c +7 -0
 
+#include "../common/board_detect.h"
  #include "../common/fdt_ops.h"
 
+#define board_is_am62x_skevm()  (board_ti_k3_is("AM62-SKEVM") || \
+				 board_ti_k3_is("AM62B-SKEVM"))
+#define board_is_am62b_p1_skevm() board_ti_k3_is("AM62B-SKEVM-P1")
+#define board_is_am62x_lp_skevm()  board_ti_k3_is("AM62-LP-SKEVM")
+#define board_is_am62x_sip_skevm()  board_ti_k3_is("AM62SIP-SKEVM")
+#define board_is_am62x_play()	board_ti_k3_is("BEAGLEPLAY-A0-")

BeaglePlay is not a TI AM62x EVM variant, its support is handled separately over in board/beagle/beagleplay/, might be good to drop this line to avoid any confusion around how the board is supported.

Andrew

Quoted 72 lines
board/ti/am62x/evm.c +46 -1
+
  DECLARE_GLOBAL_DATA_PTR;
 
  #if CONFIG_IS_ENABLED(SPLASH_SCREEN)
@@ -74,9 +82,53 @@ struct efi_capsule_update_info update_info = {
  	.images = fw_images,
  };
 
-#ifdef CONFIG_BOARD_LATE_INIT
+#if CONFIG_IS_ENABLED(TI_I2C_BOARD_DETECT)
+int checkboard(void)
+{
+	struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
+
+	if (!do_board_detect_am6())
+		printf("Board: %s rev %s\n", ep->name, ep->version);
+
+	return 0;
+}
+
+#if CONFIG_IS_ENABLED(BOARD_LATE_INIT)
+static void setup_board_eeprom_env(void)
+{
+	char *name = "am62x_skevm";
+
+	if (do_board_detect_am6())
+		goto invalid_eeprom;
+
+	if (board_is_am62x_skevm())
+		name = "am62x_skevm";
+	else if (board_is_am62b_p1_skevm())
+		name = "am62b_p1_skevm";
+	else if (board_is_am62x_lp_skevm())
+		name = "am62x_lp_skevm";
+	else if (board_is_am62x_sip_skevm())
+		name = "am62x_sip_skevm";
+	else if (board_is_am62x_play())
+		name = "am62x_beagleplay";
+	else
+		printf("Unidentified board claims %s in eeprom header\n",
+		       board_ti_get_name());
+
+invalid_eeprom:
+	set_board_info_env_am6(name);
+}
+#endif
+#endif
+
+#if CONFIG_IS_ENABLED(BOARD_LATE_INIT)
  int board_late_init(void)
  {
+	if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) {
+		setup_board_eeprom_env();
+		setup_serial_am6();
+	}
+
  	ti_set_fdt_env(NULL, NULL);
  	return 0;
  }
configs/am62x_evm_r5_defconfig +1 -0
index 18ffc991b25..d42bdf1f074 100644
@@ -85,6 +85,7 @@ CONFIG_SPL_CLK_K3_PLL=y
  CONFIG_SPL_CLK_K3=y
  CONFIG_TI_SCI_PROTOCOL=y
  CONFIG_DA8XX_GPIO=y
+CONFIG_DM_I2C=y
  CONFIG_DM_MAILBOX=y
  CONFIG_K3_SEC_PROXY=y
  CONFIG_SPL_MISC=y
#6 lore raw

Re: [PATCH v2 2/4] board: am62x: Add support for reading eeprom data

Le 27/10/2025 à 19:08, Andrew Davis a écrit :

Quoted 48 lines · Guillaume La Roque (TI.com)
Quoted 47 lines

I2C EEPROM data contains the board name and its revision. Add support for:
- Reading EEPROM data and store a copy at end of SRAM
- Updating env variable with relevant board info
- Printing board info during boot

Use the generic do_board_detect_am6() and setup_serial_am6() functions to avoid code duplication across AM6x family boards.

---
  arch/arm/mach-k3/am62x/Kconfig |  3 +++
  board/ti/am62x/evm.c           | 54
+++++++++++++++++++++++++++++++++++++++++-
  configs/am62x_evm_r5_defconfig |  1 +

  3 files changed, 57 insertions(+), 1 deletion(-)
arch/arm/mach-k3/am62x/Kconfig +0 -0
index 81199ada3a1..f7ad52db7d8 100644
@@ -14,6 +14,8 @@ config TARGET_AM625_A53_EVM

      select ARM64
      select BINMAN
      select OF_SYSTEM_SETUP
+    imply TI_COMMON_CMD_OPTIONS
+    imply TI_I2C_BOARD_DETECT
    config TARGET_AM625_R5_EVM
      bool "TI K3 based AM625 EVM running on R5"

arch/arm/mach-k3/am62x/Kconfig +0 -0
@@ -25,6 +27,7 @@ config TARGET_AM625_R5_EVM

      select K3_DDRSS
      select BINMAN
      imply SYS_K3_SPL_ATF
+    imply TI_I2C_BOARD_DETECT
    config TARGET_PHYCORE_AM62X_A53
      bool "PHYTEC phyCORE-AM62x running on A53"

board/ti/am62x/evm.c +0 -0
index c2c7a0216b9..591324ecc15 100644
@@ -22,8 +22,16 @@
   #include <dm/uclass.h>
   #include <asm/arch/k3-ddr.h>

  +#include "../common/board_detect.h"
  #include "../common/fdt_ops.h"
  +#define board_is_am62x_skevm()  (board_ti_k3_is("AM62-SKEVM") || \
+                 board_ti_k3_is("AM62B-SKEVM"))

Quoted 8 lines

board/ti/am62x/evm.c line 33

Quoted 4 lines
board/ti/am62x/evm.c +4 -0
+#define board_is_am62b_p1_skevm() board_ti_k3_is("AM62B-SKEVM-P1")
+#define board_is_am62x_lp_skevm() board_ti_k3_is("AM62-LP-SKEVM")
+#define board_is_am62x_sip_skevm() board_ti_k3_is("AM62SIP-SKEVM")
+#define board_is_am62x_play() board_ti_k3_is("BEAGLEPLAY-A0-")

BeaglePlay is not a TI AM62x EVM variant, its support is handled separately over in board/beagle/beagleplay/, might be good to drop this line to avoid any confusion around how the board is supported.

yes sorry i forgot it i will fix in v3

Quoted 74 lines

Andrew

Quoted 70 lines

+
  DECLARE_GLOBAL_DATA_PTR;
    #if CONFIG_IS_ENABLED(SPLASH_SCREEN)

board/ti/am62x/evm.c +0 -0
@@ -74,9 +82,53 @@ struct efi_capsule_update_info update_info = {
       .images = fw_images,
   };

  -#ifdef CONFIG_BOARD_LATE_INIT

board/ti/am62x/evm.c +40 -0
+#if CONFIG_IS_ENABLED(TI_I2C_BOARD_DETECT)
+int checkboard(void)
+{
+    struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
+
+    if (!do_board_detect_am6())
+        printf("Board: %s rev %s\n", ep->name, ep->version);
+
+    return 0;
+}
+
+#if CONFIG_IS_ENABLED(BOARD_LATE_INIT)
+static void setup_board_eeprom_env(void)
+{
+    char *name = "am62x_skevm";
+
+    if (do_board_detect_am6())
+        goto invalid_eeprom;
+
+    if (board_is_am62x_skevm())
+        name = "am62x_skevm";
+    else if (board_is_am62b_p1_skevm())
+        name = "am62b_p1_skevm";
+    else if (board_is_am62x_lp_skevm())
+        name = "am62x_lp_skevm";
+    else if (board_is_am62x_sip_skevm())
+        name = "am62x_sip_skevm";
+    else if (board_is_am62x_play())
+        name = "am62x_beagleplay";
+    else
+        printf("Unidentified board claims %s in eeprom header\n",
+               board_ti_get_name());
+
+invalid_eeprom:
+    set_board_info_env_am6(name);
+}
+#endif
+#endif
+
+#if CONFIG_IS_ENABLED(BOARD_LATE_INIT)

  int board_late_init(void)
  {
+    if (IS_ENABLED(CONFIG_TI_I2C_BOARD_DETECT)) { +        setup_board_eeprom_env();
+        setup_serial_am6();
+    }
+
      ti_set_fdt_env(NULL, NULL);
      return 0;
  }

configs/am62x_evm_r5_defconfig +0 -0
index 18ffc991b25..d42bdf1f074 100644
@@ -85,6 +85,7 @@ CONFIG_SPL_CLK_K3_PLL=y

  CONFIG_SPL_CLK_K3=y
  CONFIG_TI_SCI_PROTOCOL=y
  CONFIG_DA8XX_GPIO=y
+CONFIG_DM_I2C=y
  CONFIG_DM_MAILBOX=y
  CONFIG_K3_SEC_PROXY=y
  CONFIG_SPL_MISC=y

#7 lore raw

PATCH v2 3/4 board: am64x: Use generic AM6x board detection functions

In reply to Guillaume La Roque (TI.com)

Replace the board-specific implementation of do_board_detect() and setup_serial() with calls to the generic do_board_detect_am6() and setup_serial_am6() functions.

The generic function provides the same functionality with additional fallback logic to try alternate EEPROM addresses.

---
 board/ti/am64x/evm.c | 45 +++------------------------------------------
 1 file changed, 3 insertions(+), 42 deletions(-)
board/ti/am64x/evm.c +3 -42
index f9bb593e4c6..3688cf2ca25 100644
@@ -114,30 +114,11 @@ void spl_perform_board_fixups(struct spl_image_info *spl_image)
 #endif
 
 #ifdef CONFIG_TI_I2C_BOARD_DETECT
-int do_board_detect(void)
-{
-	int ret;
-
-	ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
-					 CONFIG_EEPROM_CHIP_ADDRESS);
-	if (ret) {
-		printf("EEPROM not available at 0x%02x, trying to read at 0x%02x\n",
-			CONFIG_EEPROM_CHIP_ADDRESS, CONFIG_EEPROM_CHIP_ADDRESS + 1);
-		ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
-						 CONFIG_EEPROM_CHIP_ADDRESS + 1);
-		if (ret)
-			pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
-			       CONFIG_EEPROM_CHIP_ADDRESS + 1, ret);
-	}
-
-	return ret;
-}
-
 int checkboard(void)
 {
 	struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
 
-	if (!do_board_detect())
+	if (!do_board_detect_am6())
 		printf("Board: %s rev %s\n", ep->name, ep->version);
 
 	return 0;
@@ -154,7 +135,7 @@ static void setup_board_eeprom_env(void)
 {
 	char *name = "am64x_gpevm";
 
-	if (do_board_detect())
+	if (do_board_detect_am6())
 		goto invalid_eeprom;
 
 	if (board_is_am64x_gpevm())
@@ -169,26 +150,6 @@ invalid_eeprom:
 	set_board_info_env_am6(name);
 	ti_set_fdt_env(name, ti_am64_evm_fdt_map);
 }
-
-static void setup_serial(void)
-{
-	struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
-	unsigned long board_serial;
-	char *endp;
-	char serial_string[17] = { 0 };
-
-	if (env_get("serial#"))
-		return;
-
-	board_serial = hextoul(ep->serial, &endp);
-	if (*endp != '\0') {
-		pr_err("Error: Can't set serial# to %s\n", ep->serial);
-		return;
-	}
-
-	snprintf(serial_string, sizeof(serial_string), "%016lx", board_serial);
-	env_set("serial#", serial_string);
-}
 #endif
 #endif
 
@@ -199,7 +160,7 @@ int board_late_init(void)
 		struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
 
 		setup_board_eeprom_env();
-		setup_serial();
+		setup_serial_am6();
 		/*
 		 * The first MAC address for ethernet a.k.a. ethernet0 comes from
 		 * efuse populated via the am654 gigabit eth switch subsystem driver.
Signature · 1 line
2.34.1
Reviewed-by on v2 3/4
#8 lore raw

Re: [PATCH v2 3/4] board: am64x: Use generic AM6x board detection functions

Hi Guillaume,

Thank you for the patch.

Quoted 6 lines · Guillaume La Roque (TI.com)

Replace the board-specific implementation of do_board_detect() and setup_serial() with calls to the generic do_board_detect_am6() and setup_serial_am6() functions.

The generic function provides the same functionality with additional fallback logic to try alternate EEPROM addresses.

The am64x board-specific one also has the fallback logic.

Since that's a minor commit message nitpick:

Quoted 90 lines
---
 board/ti/am64x/evm.c | 45 +++------------------------------------------
 1 file changed, 3 insertions(+), 42 deletions(-)
board/ti/am64x/evm.c +3 -42
index f9bb593e4c6..3688cf2ca25 100644
@@ -114,30 +114,11 @@ void spl_perform_board_fixups(struct spl_image_info *spl_image)
 #endif
 
 #ifdef CONFIG_TI_I2C_BOARD_DETECT
-int do_board_detect(void)
-{
-	int ret;
-
-	ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
-					 CONFIG_EEPROM_CHIP_ADDRESS);
-	if (ret) {
-		printf("EEPROM not available at 0x%02x, trying to read at 0x%02x\n",
-			CONFIG_EEPROM_CHIP_ADDRESS, CONFIG_EEPROM_CHIP_ADDRESS + 1);
-		ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
-						 CONFIG_EEPROM_CHIP_ADDRESS + 1);
-		if (ret)
-			pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
-			       CONFIG_EEPROM_CHIP_ADDRESS + 1, ret);
-	}
-
-	return ret;
-}
-
 int checkboard(void)
 {
 	struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
 
-	if (!do_board_detect())
+	if (!do_board_detect_am6())
 		printf("Board: %s rev %s\n", ep->name, ep->version);
 
 	return 0;
@@ -154,7 +135,7 @@ static void setup_board_eeprom_env(void)
 {
 	char *name = "am64x_gpevm";
 
-	if (do_board_detect())
+	if (do_board_detect_am6())
 		goto invalid_eeprom;
 
 	if (board_is_am64x_gpevm())
@@ -169,26 +150,6 @@ invalid_eeprom:
 	set_board_info_env_am6(name);
 	ti_set_fdt_env(name, ti_am64_evm_fdt_map);
 }
-
-static void setup_serial(void)
-{
-	struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
-	unsigned long board_serial;
-	char *endp;
-	char serial_string[17] = { 0 };
-
-	if (env_get("serial#"))
-		return;
-
-	board_serial = hextoul(ep->serial, &endp);
-	if (*endp != '\0') {
-		pr_err("Error: Can't set serial# to %s\n", ep->serial);
-		return;
-	}
-
-	snprintf(serial_string, sizeof(serial_string), "%016lx", board_serial);
-	env_set("serial#", serial_string);
-}
 #endif
 #endif
 
@@ -199,7 +160,7 @@ int board_late_init(void)
 		struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
 
 		setup_board_eeprom_env();
-		setup_serial();
+		setup_serial_am6();
 		/*
 		 * The first MAC address for ethernet a.k.a. ethernet0 comes from
 		 * efuse populated via the am654 gigabit eth switch subsystem driver.
Signature · 2 lines
-- 
2.34.1
#9 lore raw

PATCH v2 4/4 board: am65x: Use generic AM6x board detection function

In reply to Guillaume La Roque (TI.com)

Replace the board-specific implementation of do_board_detect() with a call to the generic do_board_detect_am6() function to avoid code duplication across AM6x family boards.

The generic function provides the same functionality with additional fallback logic to try alternate EEPROM addresses.

---
 board/ti/am65x/evm.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
board/ti/am65x/evm.c +2 -15
index 5c45a33eac9..68606746d5f 100644
@@ -72,24 +72,11 @@ int board_fit_config_name_match(const char *name)
 #endif
 
 #ifdef CONFIG_TI_I2C_BOARD_DETECT
-int do_board_detect(void)
-{
-	int ret;
-
-	ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
-					 CONFIG_EEPROM_CHIP_ADDRESS);
-	if (ret)
-		pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
-		       CONFIG_EEPROM_CHIP_ADDRESS, ret);
-
-	return ret;
-}
-
 int checkboard(void)
 {
 	struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
 
-	if (do_board_detect())
+	if (do_board_detect_am6())
 		/* EEPROM not populated */
 		printf("Board: %s rev %s\n", "AM6-COMPROCEVM", "E3");
 	else
@@ -102,7 +89,7 @@ static void setup_board_eeprom_env(void)
 {
 	char *name = "am65x";
 
-	if (do_board_detect())
+	if (do_board_detect_am6())
 		goto invalid_eeprom;
 
 	if (board_is_am65x_base_board())
Signature · 1 line
2.34.1
Reviewed-by on v2 4/4
#10 lore raw

Re: [PATCH v2 4/4] board: am65x: Use generic AM6x board detection function

Hi Guillaume,

Thank you for the patch.

Quoted 8 lines · Guillaume La Roque (TI.com)

Replace the board-specific implementation of do_board_detect() with a call to the generic do_board_detect_am6() function to avoid code duplication across AM6x family boards.

The generic function provides the same functionality with additional fallback logic to try alternate EEPROM addresses.

Quoted 46 lines
---
 board/ti/am65x/evm.c | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
board/ti/am65x/evm.c +2 -15
index 5c45a33eac9..68606746d5f 100644
@@ -72,24 +72,11 @@ int board_fit_config_name_match(const char *name)
 #endif
 
 #ifdef CONFIG_TI_I2C_BOARD_DETECT
-int do_board_detect(void)
-{
-	int ret;
-
-	ret = ti_i2c_eeprom_am6_get_base(CONFIG_EEPROM_BUS_ADDRESS,
-					 CONFIG_EEPROM_CHIP_ADDRESS);
-	if (ret)
-		pr_err("Reading on-board EEPROM at 0x%02x failed %d\n",
-		       CONFIG_EEPROM_CHIP_ADDRESS, ret);
-
-	return ret;
-}
-
 int checkboard(void)
 {
 	struct ti_am6_eeprom *ep = TI_AM6_EEPROM_DATA;
 
-	if (do_board_detect())
+	if (do_board_detect_am6())
 		/* EEPROM not populated */
 		printf("Board: %s rev %s\n", "AM6-COMPROCEVM", "E3");
 	else
@@ -102,7 +89,7 @@ static void setup_board_eeprom_env(void)
 {
 	char *name = "am65x";
 
-	if (do_board_detect())
+	if (do_board_detect_am6())
 		goto invalid_eeprom;
 
 	if (board_is_am65x_base_board())
Signature · 2 lines
-- 
2.34.1