diff options
Diffstat (limited to 'board/gateworks/venice/gsc.c')
-rw-r--r-- | board/gateworks/venice/gsc.c | 82 |
1 files changed, 44 insertions, 38 deletions
diff --git a/board/gateworks/venice/gsc.c b/board/gateworks/venice/gsc.c index 271bc8c229..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) @@ -123,13 +124,13 @@ enum { GSC_SC_RST_CAUSE_MAX = 10, }; +#include <dm/device.h> static struct udevice *gsc_get_dev(int busno, int slave) { - static const char * const i2c[] = { "i2c@30a20000", "i2c@30a30000" }; struct udevice *dev, *bus; int ret; - ret = uclass_get_device_by_name(UCLASS_I2C, i2c[busno - 1], &bus); + ret = uclass_get_device_by_seq(UCLASS_I2C, busno, &bus); if (ret) { printf("GSC : failed I2C%d probe: %d\n", busno, ret); return NULL; @@ -246,7 +247,7 @@ int gsc_hwmon(void) return node; /* probe device */ - dev = gsc_get_dev(1, GSC_HWMON_ADDR); + dev = gsc_get_dev(GSC_BUSNO, GSC_HWMON_ADDR); if (!dev) { puts("ERROR: Failed to probe GSC HWMON\n"); return -ENODEV; @@ -451,33 +452,22 @@ 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(1, GSC_EEPROM_ADDR, 1, &som_info); + ret = gsc_read_eeprom(GSC_BUSNO, GSC_EEPROM_ADDR, 1, &som_info); if (ret) { memset(&som_info, 0, sizeof(som_info)); return ret; } /* read optional baseboard EEPROM */ - return gsc_read_eeprom(2, 0x52, 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 */ @@ -498,27 +488,38 @@ 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 */ puts("RTC : "); - dev = gsc_get_dev(1, GSC_RTC_ADDR); + dev = gsc_get_dev(GSC_BUSNO, GSC_RTC_ADDR); if (!dev) { puts("Failed to probe GSC RTC\n"); } else { @@ -542,7 +543,7 @@ int gsc_init(int quiet) */ while (1) { /* probe device */ - dev = gsc_get_dev(1, GSC_SC_ADDR); + dev = gsc_get_dev(GSC_BUSNO, GSC_SC_ADDR); if (dev) break; mdelay(1); @@ -575,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) { @@ -583,7 +589,7 @@ static int gsc_sleep(unsigned long secs) int ret; /* probe device */ - dev = gsc_get_dev(1, GSC_SC_ADDR); + dev = gsc_get_dev(GSC_BUSNO, GSC_SC_ADDR); if (!dev) return -ENODEV; @@ -631,7 +637,7 @@ static int gsc_boot_wd_disable(void) int ret; /* probe device */ - dev = gsc_get_dev(1, GSC_SC_ADDR); + dev = gsc_get_dev(GSC_BUSNO, GSC_SC_ADDR); if (!dev) return -ENODEV; |