From: Tim Harvey Date: Wed, 13 Apr 2022 16:29:16 +0000 (-0700) Subject: board: gateworks: gw_ventana: use comomn GSC driver X-Git-Tag: v2022.07~90^2~33 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=61cf22505339a281befc715a5e4fbcc3ccfb2999;p=platform%2Fkernel%2Fu-boot.git board: gateworks: gw_ventana: use comomn GSC driver Use the common GSC driver. This allows us to do some additional cleanup: - use the GSC driver functions - move waiting for the EEPROM to the SPL int (it will always be ready after this) - move eeprom functions into eeprom file and elimate GSC_I2C_BUS - eliminate some redundant EEPROM reads (the EEPROM must be read in SPL before relocation, in SPL after relocation, and in U-Boot init. All subsequent uses can use the global structure) - remove unnecessary header files and alphabatize includes Signed-off-by: Tim Harvey --- diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig index 3d675fcd73..947b73fab2 100644 --- a/arch/arm/mach-imx/mx6/Kconfig +++ b/arch/arm/mach-imx/mx6/Kconfig @@ -227,6 +227,8 @@ config TARGET_GW_VENTANA bool "gw_ventana" depends on MX6QDL select SUPPORT_SPL + select GATEWORKS_SC + select MISC imply CMD_SATA imply CMD_SPL diff --git a/board/gateworks/gw_ventana/Kconfig b/board/gateworks/gw_ventana/Kconfig index fee910ca83..c82e8aeb9d 100644 --- a/board/gateworks/gw_ventana/Kconfig +++ b/board/gateworks/gw_ventana/Kconfig @@ -17,12 +17,4 @@ config CMD_EECONFIG help Provides access to EEPROM configuration on Gateworks Ventana -config CMD_GSC - bool "Enable the 'gsc' command" - help - Provides access to the GSC configuration: - - gsc sleep - sleeps for a period of seconds - gsc wd - enables / disables the watchdog - endif diff --git a/board/gateworks/gw_ventana/Makefile b/board/gateworks/gw_ventana/Makefile index 360d1d4c12..c407f8e6c5 100644 --- a/board/gateworks/gw_ventana/Makefile +++ b/board/gateworks/gw_ventana/Makefile @@ -6,5 +6,5 @@ # SPDX-License-Identifier: GPL-2.0+ # -obj-y := gw_ventana.o gsc.o eeprom.o common.o +obj-y := gw_ventana.o eeprom.o common.o obj-$(CONFIG_SPL_BUILD) += gw_ventana_spl.o diff --git a/board/gateworks/gw_ventana/common.c b/board/gateworks/gw_ventana/common.c index 414406461e..74328b2e1b 100644 --- a/board/gateworks/gw_ventana/common.c +++ b/board/gateworks/gw_ventana/common.c @@ -6,15 +6,15 @@ */ #include +#include +#include +#include #include #include #include #include #include #include -#include -#include -#include #include #include "common.h" @@ -1045,7 +1045,7 @@ struct ventana gpio_cfg[GW_UNKNOWN] = { #define SETUP_GPIO_INPUT(gpio, name) \ gpio_request(gpio, name); \ gpio_direction_input(gpio); -void setup_iomux_gpio(int board, struct ventana_board_info *info) +void setup_iomux_gpio(int board) { if (board >= GW_UNKNOWN) return; @@ -1214,8 +1214,6 @@ static struct fsl_esdhc_cfg usdhc_cfg[2]; int board_mmc_init(struct bd_info *bis) { - struct ventana_board_info ventana_info; - int board_type = read_eeprom(CONFIG_I2C_GSC, &ventana_info); int ret; switch (board_type) { @@ -1279,13 +1277,11 @@ int board_mmc_init(struct bd_info *bis) int board_mmc_getcd(struct mmc *mmc) { - struct ventana_board_info ventana_info; struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; - int board = read_eeprom(CONFIG_I2C_GSC, &ventana_info); - int gpio = gpio_cfg[board].mmc_cd; + int gpio = gpio_cfg[board_type].mmc_cd; /* Card Detect */ - switch (board) { + switch (board_type) { case GW560x: /* emmc is always present */ if (cfg->esdhc_base == USDHC2_BASE_ADDR) diff --git a/board/gateworks/gw_ventana/common.h b/board/gateworks/gw_ventana/common.h index 7a60db7385..480c6675d7 100644 --- a/board/gateworks/gw_ventana/common.h +++ b/board/gateworks/gw_ventana/common.h @@ -8,7 +8,7 @@ #ifndef _GWVENTANA_COMMON_H_ #define _GWVENTANA_COMMON_H_ -#include "ventana_eeprom.h" +#include "eeprom.h" /* GPIO's common to all baseboards */ #define GP_RS232_EN IMX_GPIO_NR(2, 11) @@ -80,6 +80,6 @@ struct ventana { extern struct ventana gpio_cfg[GW_UNKNOWN]; /* configure gpio iomux/defaults */ -void setup_iomux_gpio(int board, struct ventana_board_info *); +void setup_iomux_gpio(int board); #endif /* #ifndef _GWVENTANA_COMMON_H_ */ diff --git a/board/gateworks/gw_ventana/eeprom.c b/board/gateworks/gw_ventana/eeprom.c index c3a2bbe9ca..e622a9ba9e 100644 --- a/board/gateworks/gw_ventana/eeprom.c +++ b/board/gateworks/gw_ventana/eeprom.c @@ -4,23 +4,211 @@ * Author: Tim Harvey */ -#include #include -#include +#include +#include #include #include -#include -#include -#include -#include +#include +#include #include +#include +#include + +#include "eeprom.h" + +/* + * EEPROM board info struct populated by read_eeprom so that we only have to + * read it once. + */ +struct ventana_board_info ventana_info; +int board_type; + +#if CONFIG_IS_ENABLED(DM_I2C) +struct udevice *i2c_get_dev(int busno, int slave) +{ + struct udevice *dev, *bus; + int ret; + + ret = uclass_get_device_by_seq(UCLASS_I2C, busno, &bus); + if (ret) + return NULL; + ret = dm_i2c_probe(bus, slave, 0, &dev); + if (ret) + return NULL; + + return dev; +} +#endif + +/* + * The Gateworks System Controller will fail to ACK a master transaction if + * it is busy, which can occur during its 1HZ timer tick while reading ADC's. + * When this does occur, it will never be busy long enough to fail more than + * 2 back-to-back transfers. Thus we wrap i2c_read and i2c_write with + * 3 retries. + */ +int gsc_i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len) +{ + int retry = 3; + int n = 0; + int ret; +#if CONFIG_IS_ENABLED(DM_I2C) + struct udevice *dev; + + dev = i2c_get_dev(BOARD_EEPROM_BUSNO, chip); + if (!dev) + return -ENODEV; + ret = i2c_set_chip_offset_len(dev, alen); + if (ret) { + puts("EEPROM: Failed to set alen\n"); + return ret; + } +#else + i2c_set_bus_num(BOARD_EEPROM_BUSNO); +#endif + + while (n++ < retry) { +#if CONFIG_IS_ENABLED(DM_I2C) + ret = dm_i2c_read(dev, addr, buf, len); +#else + ret = i2c_read(chip, addr, alen, buf, len); +#endif + if (!ret) + break; + debug("%s: 0x%02x 0x%02x retry%d: %d\n", __func__, chip, addr, + n, ret); + if (ret != -ENODEV) + break; + mdelay(10); + } + return ret; +} + +int gsc_i2c_write(uchar chip, uint addr, int alen, uchar *buf, int len) +{ + int retry = 3; + int n = 0; + int ret; +#if CONFIG_IS_ENABLED(DM_I2C) + struct udevice *dev; + + dev = i2c_get_dev(BOARD_EEPROM_BUSNO, chip); + if (!dev) + return -ENODEV; + ret = i2c_set_chip_offset_len(dev, alen); + if (ret) { + puts("EEPROM: Failed to set alen\n"); + return ret; + } +#endif + + while (n++ < retry) { +#if CONFIG_IS_ENABLED(DM_I2C) + ret = dm_i2c_write(dev, addr, buf, len); +#else + ret = i2c_write(chip, addr, alen, buf, len); +#endif + if (!ret) + break; + debug("%s: 0x%02x 0x%02x retry%d: %d\n", __func__, chip, addr, + n, ret); + if (ret != -ENODEV) + break; + mdelay(10); + } + mdelay(100); + return ret; +} + +/* determine BOM revision from model */ +int get_bom_rev(const char *str) +{ + int rev_bom = 0; + int i; + + for (i = strlen(str) - 1; i > 0; i--) { + if (str[i] == '-') + break; + if (str[i] >= '1' && str[i] <= '9') { + rev_bom = str[i] - '0'; + break; + } + } + return rev_bom; +} -#include "gsc.h" -#include "ventana_eeprom.h" +/* determine PCB revision from model */ +char get_pcb_rev(const char *str) +{ + char rev_pcb = 'A'; + int i; + for (i = strlen(str) - 1; i > 0; i--) { + if (str[i] == '-') + break; + if (str[i] >= 'A') { + rev_pcb = str[i]; + break; + } + } + return rev_pcb; +} + +/* + * get dt name based on model and detail level: + */ +const char *gsc_get_dtb_name(int level, char *buf, int sz) +{ + const char *model = (const char *)ventana_info.model; + const char *pre = is_mx6dq() ? "imx6q-" : "imx6dl-"; + int modelno, rev_pcb, rev_bom; + + /* a few board models are dt equivalents to other models */ + if (strncasecmp(model, "gw5906", 6) == 0) + model = "gw552x-d"; + else if (strncasecmp(model, "gw5908", 6) == 0) + model = "gw53xx-f"; + else if (strncasecmp(model, "gw5905", 6) == 0) + model = "gw5904-a"; + + modelno = ((model[2] - '0') * 1000) + + ((model[3] - '0') * 100) + + ((model[4] - '0') * 10) + + (model[5] - '0'); + rev_pcb = tolower(get_pcb_rev(model)); + rev_bom = get_bom_rev(model); + + /* compare model/rev/bom in order of most specific to least */ + snprintf(buf, sz, "%s%04d", pre, modelno); + switch (level) { + case 0: /* full model first (ie gw5400-a1) */ + if (rev_bom) { + snprintf(buf, sz, "%sgw%04d-%c%d", pre, modelno, rev_pcb, rev_bom); + break; + } + fallthrough; + case 1: /* don't care about bom rev (ie gw5400-a) */ + snprintf(buf, sz, "%sgw%04d-%c", pre, modelno, rev_pcb); + break; + case 2: /* don't care about the pcb rev (ie gw5400) */ + snprintf(buf, sz, "%sgw%04d", pre, modelno); + break; + case 3: /* look for generic model (ie gw540x) */ + snprintf(buf, sz, "%sgw%03dx", pre, modelno / 10); + break; + case 4: /* look for more generic model (ie gw54xx) */ + snprintf(buf, sz, "%sgw%02dxx", pre, modelno / 100); + break; + default: /* give up */ + return NULL; + } + + return buf; +} /* read ventana EEPROM, check for validity, and return baseboard type */ int -read_eeprom(int bus, struct ventana_board_info *info) +read_eeprom(struct ventana_board_info *info) { int i; int chksum; @@ -30,29 +218,8 @@ read_eeprom(int bus, struct ventana_board_info *info) memset(info, 0, sizeof(*info)); - /* - * On a board with a missing/depleted backup battery for GSC, the - * board may be ready to probe the GSC before its firmware is - * running. We will wait here indefinately for the GSC/EEPROM. - */ -#if CONFIG_IS_ENABLED(DM_I2C) - while (1) { - if (i2c_get_dev(bus, GSC_EEPROM_ADDR)) - break; - mdelay(1); - } -#else - while (1) { - if (0 == i2c_set_bus_num(bus) && - 0 == i2c_probe(GSC_EEPROM_ADDR)) - break; - mdelay(1); - } -#endif - /* read eeprom config section */ - mdelay(10); - if (gsc_i2c_read(GSC_EEPROM_ADDR, 0x00, 1, buf, sizeof(*info))) { + if (gsc_i2c_read(BOARD_EEPROM_ADDR, 0x00, 1, buf, sizeof(*info))) { puts("EEPROM: Failed to read EEPROM\n"); return GW_UNKNOWN; } @@ -219,14 +386,14 @@ static int do_econfig(struct cmd_tbl *cmdtp, int flag, int argc, info->chksum[1] = chksum & 0xff; /* write new config data */ - if (gsc_i2c_write(GSC_EEPROM_ADDR, info->config - (u8 *)info, + if (gsc_i2c_write(BOARD_EEPROM_ADDR, info->config - (u8 *)info, 1, econfig_bytes, sizeof(econfig_bytes))) { printf("EEPROM: Failed updating config\n"); return CMD_RET_FAILURE; } /* write new config data */ - if (gsc_i2c_write(GSC_EEPROM_ADDR, info->chksum - (u8 *)info, + if (gsc_i2c_write(BOARD_EEPROM_ADDR, info->chksum - (u8 *)info, 1, info->chksum, 2)) { printf("EEPROM: Failed updating checksum\n"); return CMD_RET_FAILURE; diff --git a/board/gateworks/gw_ventana/eeprom.h b/board/gateworks/gw_ventana/eeprom.h new file mode 100644 index 0000000000..2354205e72 --- /dev/null +++ b/board/gateworks/gw_ventana/eeprom.h @@ -0,0 +1,157 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2013 Gateworks Corporation + */ + +#ifndef _VENTANA_EEPROM_ +#define _VENTANA_EEPROM_ + +#define BOARD_EEPROM_BUSNO 0 +#define BOARD_EEPROM_ADDR 0x51 + +struct ventana_board_info { + u8 mac0[6]; /* 0x00: MAC1 */ + u8 mac1[6]; /* 0x06: MAC2 */ + u8 res0[12]; /* 0x0C: reserved */ + u32 serial; /* 0x18: Serial Number (read only) */ + u8 res1[4]; /* 0x1C: reserved */ + u8 mfgdate[4]; /* 0x20: MFG date (read only) */ + u8 res2[7]; /* 0x24 */ + /* sdram config */ + u8 sdram_size; /* 0x2B: (16 << n) MB */ + u8 sdram_speed; /* 0x2C: (33.333 * n) MHz */ + u8 sdram_width; /* 0x2D: (8 << n) bit */ + /* cpu config */ + u8 cpu_speed; /* 0x2E: (33.333 * n) MHz */ + u8 cpu_type; /* 0x2F: 7=imx6q, 8=imx6dl */ + u8 model[16]; /* 0x30: model string */ + /* FLASH config */ + u8 nand_flash_size; /* 0x40: (8 << (n-1)) MB */ + u8 spi_flash_size; /* 0x41: (4 << (n-1)) MB */ + + /* Config1: SoC Peripherals */ + u8 config[8]; /* 0x42: loading options */ + + u8 res3[4]; /* 0x4A */ + + u8 chksum[2]; /* 0x4E */ +}; + +/* config bits */ +enum { + EECONFIG_ETH0, + EECONFIG_ETH1, + EECONFIG_HDMI_OUT, + EECONFIG_SATA, + EECONFIG_PCIE, + EECONFIG_SSI0, + EECONFIG_SSI1, + EECONFIG_LCD, + EECONFIG_LVDS0, + EECONFIG_LVDS1, + EECONFIG_USB0, + EECONFIG_USB1, + EECONFIG_SD0, + EECONFIG_SD1, + EECONFIG_SD2, + EECONFIG_SD3, + EECONFIG_UART0, + EECONFIG_UART1, + EECONFIG_UART2, + EECONFIG_UART3, + EECONFIG_UART4, + EECONFIG_IPU0, + EECONFIG_IPU1, + EECONFIG_FLEXCAN, + EECONFIG_MIPI_DSI, + EECONFIG_MIPI_CSI, + EECONFIG_TZASC0, + EECONFIG_TZASC1, + EECONFIG_I2C0, + EECONFIG_I2C1, + EECONFIG_I2C2, + EECONFIG_VPU, + EECONFIG_CSI0, + EECONFIG_CSI1, + EECONFIG_CAAM, + EECONFIG_MEZZ, + EECONFIG_RES1, + EECONFIG_RES2, + EECONFIG_RES3, + EECONFIG_RES4, + EECONFIG_ESPCI0, + EECONFIG_ESPCI1, + EECONFIG_ESPCI2, + EECONFIG_ESPCI3, + EECONFIG_ESPCI4, + EECONFIG_ESPCI5, + EECONFIG_RES5, + EECONFIG_RES6, + EECONFIG_GPS, + EECONFIG_SPIFL0, + EECONFIG_SPIFL1, + EECONFIG_GSPBATT, + EECONFIG_HDMI_IN, + EECONFIG_VID_OUT, + EECONFIG_VID_IN, + EECONFIG_NAND, + EECONFIG_RES8, + EECONFIG_RES9, + EECONFIG_RES10, + EECONFIG_RES11, + EECONFIG_RES12, + EECONFIG_RES13, + EECONFIG_RES14, + EECONFIG_RES15, +}; + +enum { + GW54proto, /* original GW5400-A prototype */ + GW51xx, + GW52xx, + GW53xx, + GW54xx, + GW551x, + GW552x, + GW553x, + GW560x, + GW5901, + GW5902, + GW5903, + GW5904, + GW5905, + GW5906, + GW5907, + GW5908, + GW5909, + GW5910, + GW5912, + GW5913, + GW_UNKNOWN, + GW_BADCRC, +}; + +/* config items */ +struct ventana_eeprom_config { + const char *name; /* name of item */ + const char *dtalias; /* name of dt node to remove if not set */ + int bit; /* bit within config */ +}; + +extern struct ventana_eeprom_config econfig[]; +extern struct ventana_board_info ventana_info; +extern int board_type; + +int read_eeprom(struct ventana_board_info *info); + +/* + * I2C transactions to the GSC are done via these functions which + * perform retries in the case of a busy GSC NAK'ing the transaction + */ +int gsc_i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len); +int gsc_i2c_write(uchar chip, uint addr, int alen, uchar *buf, int len); +const char *gsc_get_dtb_name(int level, char *buf, int sz); +struct udevice *i2c_get_dev(int busno, int slave); +const char *eeprom_get_model(void); + +#endif diff --git a/board/gateworks/gw_ventana/gsc.h b/board/gateworks/gw_ventana/gsc.h deleted file mode 100644 index 2e1d25bc6f..0000000000 --- a/board/gateworks/gw_ventana/gsc.h +++ /dev/null @@ -1,72 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Copyright (C) 2013 Gateworks Corporation - * - * Author: Tim Harvey - */ - -#ifndef __ASSEMBLY__ - -/* i2c slave addresses */ -#define GSC_SC_ADDR 0x20 -#define GSC_RTC_ADDR 0x68 -#define GSC_HWMON_ADDR 0x29 -#define GSC_EEPROM_ADDR 0x51 - -/* System Controller registers */ -enum { - GSC_SC_CTRL0 = 0x00, - GSC_SC_CTRL1 = 0x01, - GSC_SC_STATUS = 0x0a, - GSC_SC_FWCRC = 0x0c, - GSC_SC_FWVER = 0x0e, -}; - -/* System Controller Control1 bits */ -enum { - GSC_SC_CTRL1_WDTIME = 4, /* 1 = 60s timeout, 0 = 30s timeout */ - GSC_SC_CTRL1_WDEN = 5, /* 1 = enable, 0 = disable */ - GSC_SC_CTRL1_WDDIS = 7, /* 1 = disable boot watchdog */ -}; - -/* System Controller Interrupt bits */ -enum { - GSC_SC_IRQ_PB = 0, /* Pushbutton switch */ - GSC_SC_IRQ_SECURE = 1, /* Secure Key erase operation complete */ - GSC_SC_IRQ_EEPROM_WP = 2, /* EEPROM write violation */ - GSC_SC_IRQ_GPIO = 4, /* GPIO change */ - GSC_SC_IRQ_TAMPER = 5, /* Tamper detect */ - GSC_SC_IRQ_WATCHDOG = 6, /* Watchdog trip */ - GSC_SC_IRQ_PBLONG = 7, /* Pushbutton long hold */ -}; - -/* Hardware Monitor registers */ -enum { - GSC_HWMON_TEMP = 0x00, - GSC_HWMON_VIN = 0x02, - GSC_HWMON_VDD_3P3 = 0x05, - GSC_HWMON_VBATT = 0x08, - GSC_HWMON_VDD_5P0 = 0x0b, - GSC_HWMON_VDD_CORE = 0x0e, - GSC_HWMON_VDD_SOC = 0x11, - GSC_HWMON_VDD_HIGH = 0x14, - GSC_HWMON_VDD_DDR = 0x17, - GSC_HWMON_VDD_EXT = 0x1a, - GSC_HWMON_VDD_1P8 = 0x1d, - GSC_HWMON_VDD_IO2 = 0x20, - GSC_HWMON_VDD_2P5 = 0x23, - GSC_HWMON_VDD_IO3 = 0x26, - GSC_HWMON_VDD_IO4 = 0x29, -}; - -/* - * I2C transactions to the GSC are done via these functions which - * perform retries in the case of a busy GSC NAK'ing the transaction - */ -int gsc_i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len); -int gsc_i2c_write(uchar chip, uint addr, int alen, uchar *buf, int len); -int gsc_info(int verbose); -int gsc_boot_wd_disable(void); -const char *gsc_get_dtb_name(int level, char *buf, int sz); -struct udevice *i2c_get_dev(int busno, int slave); -#endif diff --git a/board/gateworks/gw_ventana/gw_ventana.c b/board/gateworks/gw_ventana/gw_ventana.c index 8748878eb3..c06630a66b 100644 --- a/board/gateworks/gw_ventana/gw_ventana.c +++ b/board/gateworks/gw_ventana/gw_ventana.c @@ -5,40 +5,29 @@ * Author: Tim Harvey */ +#include #include +#include +#include +#include +#include +#include +#include #include #include #include #include #include -#include -#include #include #include -#include -#include -#include +#include #include -#include -#include #include -#include -#include -#include -#include "gsc.h" #include "common.h" DECLARE_GLOBAL_DATA_PTR; - -/* - * EEPROM board info struct populated by read_eeprom so that we only have to - * read it once. - */ -struct ventana_board_info ventana_info; -static int board_type; - /* configure eth0 PHY board-specific LED behavior */ int board_phy_config(struct phy_device *phydev) { @@ -482,9 +471,12 @@ int board_init(void) gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; /* read Gateworks EEPROM into global struct (used later) */ - board_type = read_eeprom(CONFIG_I2C_GSC, &ventana_info); + board_type = read_eeprom(&ventana_info); - setup_iomux_gpio(board_type, &ventana_info); + setup_iomux_gpio(board_type); + + /* show GSC details */ + run_command("gsc", 0); return 0; } @@ -517,7 +509,6 @@ int board_fit_config_name_match(const char *name) int checkboard(void) { struct ventana_board_info *info = &ventana_info; - unsigned char buf[4]; const char *p; int quiet; /* Quiet or minimal output mode */ @@ -541,15 +532,6 @@ int checkboard(void) if (quiet) return 0; - /* Display GSC firmware revision/CRC/status */ - gsc_info(0); - - /* Display RTC */ - if (!gsc_i2c_read(GSC_RTC_ADDR, 0x00, 1, buf, 4)) { - printf("RTC: %d\n", - buf[0] | buf[1]<<8 | buf[2]<<16 | buf[3]<<24); - } - return 0; } #endif diff --git a/board/gateworks/gw_ventana/gw_ventana_spl.c b/board/gateworks/gw_ventana/gw_ventana_spl.c index 3149e88315..e85a00954c 100644 --- a/board/gateworks/gw_ventana/gw_ventana_spl.c +++ b/board/gateworks/gw_ventana/gw_ventana_spl.c @@ -6,26 +6,22 @@ #include #include +#include #include +#include #include -#include -#include +#include #include #include #include #include -#include -#include #include -#include -#include -#include +#include +#include #include -#include #include -#include +#include -#include "gsc.h" #include "common.h" #define RTT_NOM_120OHM /* use 120ohm Rtt_nom vs 60ohm (lower power) */ @@ -778,8 +774,6 @@ static void setup_ventana_i2c(int i2c) void setup_pmic(void) { struct pmic *p; - struct ventana_board_info ventana_info; - int board = read_eeprom(CONFIG_I2C_GSC, &ventana_info); const int i2c_pmic = 1; u32 reg; char rev; @@ -817,7 +811,7 @@ void setup_pmic(void) reg |= (SWBST_5_00V | (SWBST_MODE_AUTO << SWBST_MODE_SHIFT)); pmic_reg_write(p, PFUZE100_SWBSTCON1, reg); - if (board == GW54xx && (rev == 'G')) { + if (board_type == GW54xx && (rev == 'G')) { /* Disable VGEN5 */ pmic_reg_write(p, PFUZE100_VGEN5VOL, 0); @@ -873,7 +867,7 @@ void setup_pmic(void) * is a bit shy of the Vmin of 1350mV in the datasheet * for LDO enabled mode but is as high as we can go. */ - switch (board) { + switch (board_type) { case GW560x: /* mask PGOOD during SW3 transition */ pmic_reg_write(p, LTC3676_DVB3B, @@ -931,7 +925,7 @@ void setup_pmic(void) /* configure MP5416 PMIC */ else if (!i2c_probe(0x69)) { puts("PMIC: MP5416\n"); - switch (board) { + switch (board_type) { case GW5910: /* SW1: VDD_ARM 1.2V -> (1.275 to 1.475) */ reg = MP5416_VSET_EN | MP5416_VSET_SW1_SVAL(1475000); @@ -974,11 +968,23 @@ void board_init_f(ulong dummy) /* UART clocks enabled and gd valid - init serial console */ preloader_console_init(); + /* + * On a board with a missing/depleted backup battery for GSC, the + * board may be ready to probe the GSC before its firmware is + * running. We will wait here indefinately for the GSC/EEPROM. + */ + while (1) { + if (!i2c_set_bus_num(BOARD_EEPROM_BUSNO) && + !i2c_probe(BOARD_EEPROM_ADDR)) + break; + mdelay(1); + } + /* read/validate EEPROM info to determine board model and SDRAM cfg */ - board_model = read_eeprom(CONFIG_I2C_GSC, &ventana_info); + board_model = read_eeprom(&ventana_info); /* configure model-specific gpio */ - setup_iomux_gpio(board_model, &ventana_info); + setup_iomux_gpio(board_model); /* provide some some default: 32bit 128MB */ if (GW_UNKNOWN == board_model) @@ -1006,7 +1012,6 @@ void board_boot_order(u32 *spl_boot_list) /* called from board_init_r after gd setup if CONFIG_SPL_BOARD_INIT defined */ /* its our chance to print info about boot device */ -static int board_type; void spl_board_init(void) { u32 boot_device; @@ -1015,7 +1020,7 @@ void spl_board_init(void) boot_device = spl_boot_device(); /* read eeprom again now that we have gd */ - board_type = read_eeprom(CONFIG_I2C_GSC, &ventana_info); + board_type = read_eeprom(&ventana_info); if (board_type == GW_UNKNOWN) hang(); diff --git a/board/gateworks/gw_ventana/ventana_eeprom.h b/board/gateworks/gw_ventana/ventana_eeprom.h deleted file mode 100644 index 2d5c27261e..0000000000 --- a/board/gateworks/gw_ventana/ventana_eeprom.h +++ /dev/null @@ -1,143 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0+ */ -/* - * Copyright (C) 2013 Gateworks Corporation - */ - -#ifndef _VENTANA_EEPROM_ -#define _VENTANA_EEPROM_ - -struct ventana_board_info { - u8 mac0[6]; /* 0x00: MAC1 */ - u8 mac1[6]; /* 0x06: MAC2 */ - u8 res0[12]; /* 0x0C: reserved */ - u32 serial; /* 0x18: Serial Number (read only) */ - u8 res1[4]; /* 0x1C: reserved */ - u8 mfgdate[4]; /* 0x20: MFG date (read only) */ - u8 res2[7]; /* 0x24 */ - /* sdram config */ - u8 sdram_size; /* 0x2B: (16 << n) MB */ - u8 sdram_speed; /* 0x2C: (33.333 * n) MHz */ - u8 sdram_width; /* 0x2D: (8 << n) bit */ - /* cpu config */ - u8 cpu_speed; /* 0x2E: (33.333 * n) MHz */ - u8 cpu_type; /* 0x2F: 7=imx6q, 8=imx6dl */ - u8 model[16]; /* 0x30: model string */ - /* FLASH config */ - u8 nand_flash_size; /* 0x40: (8 << (n-1)) MB */ - u8 spi_flash_size; /* 0x41: (4 << (n-1)) MB */ - - /* Config1: SoC Peripherals */ - u8 config[8]; /* 0x42: loading options */ - - u8 res3[4]; /* 0x4A */ - - u8 chksum[2]; /* 0x4E */ -}; - -/* config bits */ -enum { - EECONFIG_ETH0, - EECONFIG_ETH1, - EECONFIG_HDMI_OUT, - EECONFIG_SATA, - EECONFIG_PCIE, - EECONFIG_SSI0, - EECONFIG_SSI1, - EECONFIG_LCD, - EECONFIG_LVDS0, - EECONFIG_LVDS1, - EECONFIG_USB0, - EECONFIG_USB1, - EECONFIG_SD0, - EECONFIG_SD1, - EECONFIG_SD2, - EECONFIG_SD3, - EECONFIG_UART0, - EECONFIG_UART1, - EECONFIG_UART2, - EECONFIG_UART3, - EECONFIG_UART4, - EECONFIG_IPU0, - EECONFIG_IPU1, - EECONFIG_FLEXCAN, - EECONFIG_MIPI_DSI, - EECONFIG_MIPI_CSI, - EECONFIG_TZASC0, - EECONFIG_TZASC1, - EECONFIG_I2C0, - EECONFIG_I2C1, - EECONFIG_I2C2, - EECONFIG_VPU, - EECONFIG_CSI0, - EECONFIG_CSI1, - EECONFIG_CAAM, - EECONFIG_MEZZ, - EECONFIG_RES1, - EECONFIG_RES2, - EECONFIG_RES3, - EECONFIG_RES4, - EECONFIG_ESPCI0, - EECONFIG_ESPCI1, - EECONFIG_ESPCI2, - EECONFIG_ESPCI3, - EECONFIG_ESPCI4, - EECONFIG_ESPCI5, - EECONFIG_RES5, - EECONFIG_RES6, - EECONFIG_GPS, - EECONFIG_SPIFL0, - EECONFIG_SPIFL1, - EECONFIG_GSPBATT, - EECONFIG_HDMI_IN, - EECONFIG_VID_OUT, - EECONFIG_VID_IN, - EECONFIG_NAND, - EECONFIG_RES8, - EECONFIG_RES9, - EECONFIG_RES10, - EECONFIG_RES11, - EECONFIG_RES12, - EECONFIG_RES13, - EECONFIG_RES14, - EECONFIG_RES15, -}; - -enum { - GW54proto, /* original GW5400-A prototype */ - GW51xx, - GW52xx, - GW53xx, - GW54xx, - GW551x, - GW552x, - GW553x, - GW560x, - GW5901, - GW5902, - GW5903, - GW5904, - GW5905, - GW5906, - GW5907, - GW5908, - GW5909, - GW5910, - GW5912, - GW5913, - GW_UNKNOWN, - GW_BADCRC, -}; - -/* config items */ -struct ventana_eeprom_config { - const char *name; /* name of item */ - const char *dtalias; /* name of dt node to remove if not set */ - int bit; /* bit within config */ -}; - -extern struct ventana_eeprom_config econfig[]; -extern struct ventana_board_info ventana_info; - -int read_eeprom(int bus, struct ventana_board_info *); - -#endif diff --git a/configs/gwventana_emmc_defconfig b/configs/gwventana_emmc_defconfig index f65f28e4cd..28a73fb304 100644 --- a/configs/gwventana_emmc_defconfig +++ b/configs/gwventana_emmc_defconfig @@ -14,11 +14,11 @@ CONFIG_SYS_I2C_MXC_I2C1=y CONFIG_SYS_I2C_MXC_I2C2=y CONFIG_SYS_I2C_MXC_I2C3=y CONFIG_CMD_EECONFIG=y -CONFIG_CMD_GSC=y CONFIG_DEFAULT_DEVICE_TREE="imx6q-gw54xx" CONFIG_SPL_TEXT_BASE=0x00908000 CONFIG_SPL_MMC=y CONFIG_SPL_SERIAL=y +CONFIG_SPL_DRIVERS_MISC=y CONFIG_SPL_STACK_R_ADDR=0x18000000 CONFIG_SPL=y CONFIG_ENV_OFFSET_REDUND=0xD1400 diff --git a/configs/gwventana_gw5904_defconfig b/configs/gwventana_gw5904_defconfig index 1d95fb07fd..9deb080ca2 100644 --- a/configs/gwventana_gw5904_defconfig +++ b/configs/gwventana_gw5904_defconfig @@ -14,11 +14,11 @@ CONFIG_SYS_I2C_MXC_I2C1=y CONFIG_SYS_I2C_MXC_I2C2=y CONFIG_SYS_I2C_MXC_I2C3=y CONFIG_CMD_EECONFIG=y -CONFIG_CMD_GSC=y CONFIG_DEFAULT_DEVICE_TREE="imx6q-gw54xx" CONFIG_SPL_TEXT_BASE=0x00908000 CONFIG_SPL_MMC=y CONFIG_SPL_SERIAL=y +CONFIG_SPL_DRIVERS_MISC=y CONFIG_SPL_STACK_R_ADDR=0x18000000 CONFIG_SPL=y CONFIG_ENV_OFFSET_REDUND=0xD1400 diff --git a/configs/gwventana_nand_defconfig b/configs/gwventana_nand_defconfig index 275b2c68d6..8ef794c21e 100644 --- a/configs/gwventana_nand_defconfig +++ b/configs/gwventana_nand_defconfig @@ -14,11 +14,11 @@ CONFIG_SYS_I2C_MXC_I2C1=y CONFIG_SYS_I2C_MXC_I2C2=y CONFIG_SYS_I2C_MXC_I2C3=y CONFIG_CMD_EECONFIG=y -CONFIG_CMD_GSC=y CONFIG_DEFAULT_DEVICE_TREE="imx6q-gw54xx" CONFIG_SPL_TEXT_BASE=0x00908000 CONFIG_SPL_MMC=y CONFIG_SPL_SERIAL=y +CONFIG_SPL_DRIVERS_MISC=y CONFIG_SPL_STACK_R_ADDR=0x18000000 CONFIG_SPL=y CONFIG_ENV_OFFSET_REDUND=0x1080000 diff --git a/include/configs/gw_ventana.h b/include/configs/gw_ventana.h index 81582227d4..86d0fb60f1 100644 --- a/include/configs/gw_ventana.h +++ b/include/configs/gw_ventana.h @@ -31,9 +31,6 @@ #undef CONFIG_SYS_BOOTM_LEN #define CONFIG_SYS_BOOTM_LEN (64 << 20) -/* I2C Configs */ -#define CONFIG_I2C_GSC 0 - /* MMC Configs */ #define CONFIG_SYS_FSL_ESDHC_ADDR 0 diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt index 0c3c0b33d5..3233a830fe 100644 --- a/scripts/config_whitelist.txt +++ b/scripts/config_whitelist.txt @@ -316,7 +316,6 @@ CONFIG_HUSH_INIT_VAR CONFIG_HWCONFIG CONFIG_HW_ENV_SETTINGS CONFIG_I2C_ENV_EEPROM_BUS -CONFIG_I2C_GSC CONFIG_I2C_MULTI_BUS CONFIG_I2C_MVTWSI CONFIG_I2C_MVTWSI_BASE