summaryrefslogtreecommitdiff
path: root/board/gateworks
diff options
context:
space:
mode:
authorTim Harvey <tharvey@gateworks.com>2022-11-11 19:03:07 +0300
committerStefano Babic <sbabic@denx.de>2023-01-31 20:08:23 +0300
commit3041e094e45dba1853431e88d79a990d86fa80d7 (patch)
tree105c8095a15ff0e4b65b797f456c644ec08f0420 /board/gateworks
parenta4dc847b6017cfedd246623ed29e6f85ae0b67c6 (diff)
downloadu-boot-3041e094e45dba1853431e88d79a990d86fa80d7.tar.xz
board: gateworks: venice: poll I2C lines to wait for GSC firmware
In some situations the GSC firmware where the EEPROM containing the model and DRAM configuration may not be ready by the time the SoC is ready to talk to it over I2C. Instead of a hard delay, poll the I2C lines to wait until they are released to avoid the I2C drivers 'Arbitation lost' error message. Signed-off-by: Tim Harvey <tharvey@gateworks.com> Reviewed-by: Fabio Estevam <festevam@denx.de>
Diffstat (limited to 'board/gateworks')
-rw-r--r--board/gateworks/venice/spl.c39
1 files changed, 25 insertions, 14 deletions
diff --git a/board/gateworks/venice/spl.c b/board/gateworks/venice/spl.c
index 60830766ca..4eb7bdfcee 100644
--- a/board/gateworks/venice/spl.c
+++ b/board/gateworks/venice/spl.c
@@ -16,10 +16,12 @@
#include <asm/arch/imx8mp_pins.h>
#include <asm/arch/sys_proto.h>
#include <asm/mach-imx/boot_mode.h>
+#include <asm/mach-imx/mxc_i2c.h>
#include <asm/arch/ddr.h>
#include <asm-generic/gpio.h>
#include <dm/uclass.h>
#include <dm/device.h>
+#include <dm/pinctrl.h>
#include <linux/delay.h>
#include <power/bd71837.h>
#include <power/mp5416.h>
@@ -215,8 +217,8 @@ static int power_init_board(void)
void board_init_f(ulong dummy)
{
- struct udevice *dev;
- int ret;
+ struct udevice *bus, *dev;
+ int i, ret;
int dram_sz;
arch_cpu_init();
@@ -247,19 +249,28 @@ void board_init_f(ulong dummy)
*
* 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.
- */
-#ifdef CONFIG_IMX8MN
- /*
- * IMX8MN boots quicker than IMX8MM and exposes issue
- * where because GSC I2C state machine isn't running and its
- * SCL/SDA are driven low the I2C driver spams 'Arbitration lost'
- * I2C errors.
- *
- * TODO: Put a loop here that somehow waits for I2C CLK/DAT to be high
+ * running. Wait here for 50ms for the GSC firmware to let go of
+ * the SCL/SDA lines to avoid the i2c driver spamming
+ * 'Arbitration lost' I2C errors
*/
- mdelay(50);
-#endif
+ if (!uclass_get_device_by_seq(UCLASS_I2C, 0, &bus)) {
+ if (!pinctrl_select_state(bus, "gpio")) {
+ struct mxc_i2c_bus *i2c_bus = dev_get_priv(bus);
+ struct gpio_desc *scl_gpio = &i2c_bus->scl_gpio;
+ struct gpio_desc *sda_gpio = &i2c_bus->sda_gpio;
+
+ dm_gpio_set_dir_flags(scl_gpio, GPIOD_IS_IN);
+ dm_gpio_set_dir_flags(sda_gpio, GPIOD_IS_IN);
+ for (i = 0; i < 5; i++) {
+ if (dm_gpio_get_value(scl_gpio) &&
+ dm_gpio_get_value(sda_gpio))
+ break;
+ mdelay(10);
+ }
+ pinctrl_select_state(bus, "default");
+ }
+ }
+ /* Wait indefiniately until the GSC probes */
while (1) {
if (!uclass_get_device_by_driver(UCLASS_MISC, DM_DRIVER_GET(gsc), &dev))
break;