board: ti: am62x: Add EEPROM support and refactor board detection
Subsystems (2)
v3 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 v3:
- Remove beagleplay part
- Link to v2: https://lore.kernel.org/r/[email protected]
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 | 51 +++++++++++++++++++++++++++++++++++++++++- 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, 124 insertions(+), 58 deletions(-)
---
base-commit: 6a56d10fdcf1309d2070b62dc15e80a047da971b
change-id: 20251016-am62xeeprom-41a1920b8bd2
Best regards,
Signature · 1 line
Guillaume La Roque (TI.com) <[email protected]>
PATCH v3 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
@@ -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
@@ -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
PATCH v3 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 | 51 +++++++++++++++++++++++++++++++++++++++++- configs/am62x_evm_r5_defconfig | 1 + 3 files changed, 54 insertions(+), 1 deletion(-)
arch/arm/mach-k3/am62x/Kconfig +3 -0
@@ -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 +50 -1
67 lines not on this page · raw message
configs/am62x_evm_r5_defconfig +1 -0
@@ -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
PATCH v3 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
@@ -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
[REGRESSION]: Re: [PATCH v3 3/4] board: am64x: Use generic AM6x board detection functions
Hi,
In our daily build and boot test of u-boot master, am64x board is failing to boot. The boot stops at SPL stage.
With git bisect, I have narrowed it down to this commit. By reverting this commit, I'm able to boot the board. Looks like some issue with the configs when using the common board detection functions. Bisect log:
ce56e553c31377b9cda7c53e2161c8e02071fc4e is the first bad commit commit ce56e553c31377b9cda7c53e2161c8e02071fc4e
Author: Guillaume La Roque (TI.com) <[email protected]> Date: Mon Nov 3 19:40:04 2025 +0100
board: am64x: Use generic AM6x board detection functions
Regards
T Pratham <[email protected]>
Re: [REGRESSION]: Re: [PATCH v3 3/4] board: am64x: Use generic AM6x board detection functions
Hi,
sorry for that i will send a fix today.
Guillaume
Le 14/11/2025 à 13:48, T Pratham a écrit :
Quoted 18 lines
Hi,
In our daily build and boot test of u-boot master, am64x board is failing to boot. The boot stops at SPL stage.
With git bisect, I have narrowed it down to this commit. By reverting this commit, I'm able to boot the board. Looks like some issue with the configs when using the common board detection functions. Bisect log:
ce56e553c31377b9cda7c53e2161c8e02071fc4eis the first bad commit commitce56e553c31377b9cda7c53e2161c8e02071fc4eAuthor: Guillaume La Roque (TI.com) <[email protected]> Date: Mon Nov 3 19:40:04 2025 +0100board: am64x: Use generic AM6x board detection functions
Regards
T Pratham <[email protected]>
PATCH v3 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
@@ -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
Quoted 11 lines · Guillaume La Roque (TI.com)
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[...]
Applied to u-boot/master, thanks!
[1/4] board: ti: common: Add generic AM6x board detection functions
commit: 46684bb0369879413015c93c61998ff2986e0617
[2/4] board: am62x: Add support for reading eeprom data
commit: ff1b83c095c2b96b6092099180d9a563702ee256
[3/4] board: am64x: Use generic AM6x board detection functions
commit: ce56e553c31377b9cda7c53e2161c8e02071fc4e
[4/4] board: am65x: Use generic AM6x board detection function
commit: 804b80288ac048f3c4403ddbb48f0944a3b5cc7eSignature · 1 line
Tom