From 42cc3125c414b340b3c90600486c6951325b27a6 Mon Sep 17 00:00:00 2001 From: Ye Li Date: Wed, 10 Jul 2019 10:23:09 +0000 Subject: [PATCH 1/3] i2c-mux-gpio: Fix GPIO request flag issue When requesting GPIO, the GPIOD_IS_OUT is missed in flag, so the GPIO is set the input mode not output and cause mux not work. Signed-off-by: Ye Li --- drivers/i2c/muxes/i2c-mux-gpio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index 28f640042f..e8b124f4f5 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c @@ -106,7 +106,7 @@ static int i2c_mux_gpio_probe(struct udevice *dev) } ret = gpio_request_list_by_name(dev, "mux-gpios", gpios, mux->n_gpios, - GPIOD_IS_OUT_ACTIVE); + GPIOD_IS_OUT | GPIOD_IS_OUT_ACTIVE); if (ret <= 0) { dev_err(dev, "Failed to request mux-gpios\n"); return ret; From d7d864017d7f21a4cc3ff2a902024724c26ad213 Mon Sep 17 00:00:00 2001 From: Ye Li Date: Wed, 10 Jul 2019 10:24:15 +0000 Subject: [PATCH 2/3] i2c: mxc_i2c: Remove i2c_idle_bus from probe i2c_idle_bus is already used in i2c_init_transfer. So before each transfer if the bus is not ready, the i2c_idle_bus will be used to force idle. It is unnecessary to call it again in probe. We found a issue when enabling i2c mux with the mxc_i2c. The mxc_i2c is probed after mux probing. However, at this moment the mux is still in idle state not select any port. So if we call i2c_idle_bus in probe, it will fail and cause mxc_i2c probe failed. Signed-off-by: Ye Li --- drivers/i2c/mxc_i2c.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 73b9807598..20f6dc4ecb 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -917,13 +917,6 @@ static int mxc_i2c_probe(struct udevice *bus) } } - ret = i2c_idle_bus(i2c_bus); - if (ret < 0) { - /* Disable clk */ - enable_i2c_clk(0, bus->seq); - return ret; - } - /* * Pinmux settings are in board file now, until pinmux is supported, * we can set pinmux here in probe function. From 5ae84860b0428b37063a6d7b03cae26a4e772da7 Mon Sep 17 00:00:00 2001 From: Baruch Siach Date: Mon, 5 Aug 2019 09:03:30 +0300 Subject: [PATCH 3/3] misc: i2c_eeprom: verify that the chip is functional at probe() Read a single byte from EEPROM to verify that it is actually there. This is equivalent to Linux kernel commit 00f0ea70d2b8 ("eeprom: at24: check if the chip is functional in probe()"). Cc: Bartosz Golaszewski Signed-off-by: Baruch Siach hs: fixed style check prefer kernel type 'u8' over 'uint8_t' --- drivers/misc/i2c_eeprom.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/misc/i2c_eeprom.c b/drivers/misc/i2c_eeprom.c index f25d054007..8f2349ad5a 100644 --- a/drivers/misc/i2c_eeprom.c +++ b/drivers/misc/i2c_eeprom.c @@ -84,6 +84,14 @@ static int i2c_eeprom_std_ofdata_to_platdata(struct udevice *dev) static int i2c_eeprom_std_probe(struct udevice *dev) { + u8 test_byte; + int ret; + + /* Verify that the chip is functional */ + ret = i2c_eeprom_read(dev, 0, &test_byte, 1); + if (ret) + return -ENODEV; + return 0; }