diff options
author | Dasnavis Sabiya <sabiya.d@ti.com> | 2023-06-02 19:26:15 +0530 |
---|---|---|
committer | Praneeth Bajjuri <praneeth@ti.com> | 2023-06-07 16:56:46 -0500 |
commit | d55ef5a2dbf406b21dbcfc67465971362b57b106 (patch) | |
tree | 7a3d876ff9367ab3807986b0ec4f9b4d72a4c6cc /board | |
parent | 80f0787237869288730f6670b022d9eac03d1c20 (diff) |
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 <sabiya.d@ti.com>
Diffstat (limited to 'board')
-rw-r--r-- | board/ti/j784s4/evm.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/board/ti/j784s4/evm.c b/board/ti/j784s4/evm.c index 11815b8096d..18cc77aa514 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) { |