From 57d27aa917dca7aed39df2a457473161d29dcf16 Mon Sep 17 00:00:00 2001 From: Tim Harvey Date: Tue, 27 Jul 2021 15:19:39 -0700 Subject: [PATCH] board: gateworks: venice: add board model/serial# to env Add board model/serial# strings to env. Move the creation of the strings to gsc_read() and the display of the info into gsc_info() so they are available to U-Boot proper. Signed-off-by: Tim Harvey --- board/gateworks/venice/gsc.c | 67 ++++++++++++++------------ board/gateworks/venice/gsc.h | 1 + board/gateworks/venice/imx8mm_venice.c | 4 ++ 3 files changed, 41 insertions(+), 31 deletions(-) diff --git a/board/gateworks/venice/gsc.c b/board/gateworks/venice/gsc.c index e3d44cea95..7d6acd7b4a 100644 --- a/board/gateworks/venice/gsc.c +++ b/board/gateworks/venice/gsc.c @@ -18,6 +18,7 @@ DECLARE_GLOBAL_DATA_PTR; struct venice_board_info som_info; struct venice_board_info base_info; char venice_model[32]; +uint32_t venice_serial; /* return a mac address from EEPROM info */ int gsc_getmac(int index, uint8_t *address) @@ -451,6 +452,8 @@ const char *gsc_get_dtb_name(int level, char *buf, int sz) static int gsc_read(void) { + char rev_pcb; + int rev_bom; int ret; ret = gsc_read_eeprom(GSC_BUSNO, GSC_EEPROM_ADDR, 1, &som_info); @@ -460,25 +463,11 @@ static int gsc_read(void) } /* read optional baseboard EEPROM */ - return gsc_read_eeprom(BASEBOARD_EEPROM_BUSNO, BASEBOARD_EEPROM_ADDR, - 2, &base_info); -} + gsc_read_eeprom(BASEBOARD_EEPROM_BUSNO, BASEBOARD_EEPROM_ADDR, + 2, &base_info); -static int gsc_info(int verbose) -{ - struct udevice *dev; - unsigned char buf[16]; - char rev_pcb; - int rev_bom; - - if (!base_info.model[0]) { - strcpy(venice_model, som_info.model); - printf("Model : %s\n", som_info.model); - printf("Serial : %d\n", som_info.serial); - printf("MFGDate : %02x-%02x-%02x%02x\n", - som_info.mfgdate[0], som_info.mfgdate[1], - som_info.mfgdate[2], som_info.mfgdate[3]); - } else { + /* create model strings */ + if (base_info.model[0]) { sprintf(venice_model, "GW%c%c%c%c-%c%c-", som_info.model[2], /* family */ base_info.model[3], /* baseboard */ @@ -499,22 +488,33 @@ static int gsc_info(int verbose) sprintf(venice_model + strlen(venice_model), "%c%d", rev_pcb, rev_bom); else sprintf(venice_model + strlen(venice_model), "%c", rev_pcb); + } else { + strcpy(venice_model, som_info.model); + } + venice_serial = som_info.serial; - if (verbose > 1) { - printf("SOM : %s %d %02x-%02x-%02x%02x\n", - som_info.model, som_info.serial, - som_info.mfgdate[0], som_info.mfgdate[1], - som_info.mfgdate[2], som_info.mfgdate[3]); - printf("BASE : %s %d %02x-%02x-%02x%02x\n", - base_info.model, base_info.serial, - base_info.mfgdate[0], base_info.mfgdate[1], - base_info.mfgdate[2], base_info.mfgdate[3]); - } - printf("Model : %s\n", venice_model); - printf("Serial : %d\n", som_info.serial); - printf("MFGDate : %02x-%02x-%02x%02x\n", + return 0; +} + +static int gsc_info(int verbose) +{ + struct udevice *dev; + unsigned char buf[16]; + + printf("Model : %s\n", venice_model); + printf("Serial : %d\n", som_info.serial); + printf("MFGDate : %02x-%02x-%02x%02x\n", + som_info.mfgdate[0], som_info.mfgdate[1], + som_info.mfgdate[2], som_info.mfgdate[3]); + if (base_info.model[0] && verbose > 1) { + printf("SOM : %s %d %02x-%02x-%02x%02x\n", + som_info.model, som_info.serial, som_info.mfgdate[0], som_info.mfgdate[1], som_info.mfgdate[2], som_info.mfgdate[3]); + printf("BASE : %s %d %02x-%02x-%02x%02x\n", + base_info.model, base_info.serial, + base_info.mfgdate[0], base_info.mfgdate[1], + base_info.mfgdate[2], base_info.mfgdate[3]); } /* Display RTC */ @@ -576,6 +576,11 @@ const char *gsc_get_model(void) return venice_model; } +uint32_t gsc_get_serial(void) +{ + return venice_serial; +} + #if !(IS_ENABLED(CONFIG_SPL_BUILD)) static int gsc_sleep(unsigned long secs) { diff --git a/board/gateworks/venice/gsc.h b/board/gateworks/venice/gsc.h index e0d0332a82..b391b2e326 100644 --- a/board/gateworks/venice/gsc.h +++ b/board/gateworks/venice/gsc.h @@ -40,5 +40,6 @@ int gsc_hwmon(void); const char *gsc_get_model(void); const char *gsc_get_dtb_name(int level, char *buf, int len); int gsc_getmac(int index, uint8_t *enetaddr); +uint32_t gsc_get_serial(void); #endif diff --git a/board/gateworks/venice/imx8mm_venice.c b/board/gateworks/venice/imx8mm_venice.c index ff64d697a7..ca01e75d0d 100644 --- a/board/gateworks/venice/imx8mm_venice.c +++ b/board/gateworks/venice/imx8mm_venice.c @@ -113,6 +113,10 @@ int board_late_init(void) led_default_state(); + /* Set board serial/model */ + env_set_ulong("serial#", gsc_get_serial()); + env_set("model", gsc_get_model()); + /* Set fdt_file vars */ i = 0; do { -- 2.39.5