From d55ef5a2dbf406b21dbcfc67465971362b57b106 Mon Sep 17 00:00:00 2001 From: Dasnavis Sabiya Date: Fri, 2 Jun 2023 19:26:15 +0530 Subject: board: ti: j784s4: Add support to update serial environmental variable The serial number of the board is programmed in the EEPROM. Add support for setup_serial() to read the serial number from EEPROM and update the serial environmental variable with the same. Signed-off-by: Dasnavis Sabiya --- board/ti/j784s4/evm.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/board/ti/j784s4/evm.c b/board/ti/j784s4/evm.c index 11815b8096..18cc77aa51 100644 --- a/board/ti/j784s4/evm.c +++ b/board/ti/j784s4/evm.c @@ -143,6 +143,26 @@ invalid_eeprom: set_board_info_env_am6(name); } +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 = 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); +} + #ifdef CONFIG_SPL_LOAD_FIT int board_fit_config_name_match(const char *name) { -- cgit v1.2.3