Skip to contentSkip to conversation

i2c: imx: defer probe if bus recovery GPIOs are not ready

PATCH In review Stefan Agner 4 participants 4 messages Sep 27, 2016 – Oct 25, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i2c: imx: defer probe if bus recovery GPIOs are not ready

Some SoC might load the GPIO driver after the I2C driver and using the I2C bus recovery mechanism via GPIOs. In this case it is crucial to defer probing if the GPIO request functions do so, otherwise the I2C driver gets loaded without recovery mechanisms enabled.

---
This is an actual issue on NXP Vybrid devices on which the GPIO driver gets loaded rather later.

--
Stefan

 drivers/i2c/busses/i2c-imx.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-imx.c +7 -4
index 592a8f2..47fc1f1 100644
@@ -1009,10 +1009,13 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
 	rinfo->sda_gpio = of_get_named_gpio(pdev->dev.of_node, "sda-gpios", 0);
 	rinfo->scl_gpio = of_get_named_gpio(pdev->dev.of_node, "scl-gpios", 0);
 
-	if (!gpio_is_valid(rinfo->sda_gpio) ||
-	    !gpio_is_valid(rinfo->scl_gpio) ||
-	    IS_ERR(i2c_imx->pinctrl_pins_default) ||
-	    IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
+	if (rinfo->sda_gpio == -EPROBE_DEFER ||
+	    rinfo->scl_gpio == -EPROBE_DEFER) {
+		return -EPROBE_DEFER;
+	} else if (!gpio_is_valid(rinfo->sda_gpio) ||
+		   !gpio_is_valid(rinfo->scl_gpio) ||
+		   IS_ERR(i2c_imx->pinctrl_pins_default) ||
+		   IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
 		dev_dbg(&pdev->dev, "recovery information incomplete\n");
 		return 0;
 	}
Signature · 1 line
2.10.0
Acked-by on v1 1/1
#1 lore raw

Hello Stefan,

Quoted 7 lines · Stefan Agner

Some SoC might load the GPIO driver after the I2C driver and using the I2C bus recovery mechanism via GPIOs. In this case it is crucial to defer probing if the GPIO request functions do so, otherwise the I2C driver gets loaded without recovery mechanisms enabled.

Thanks
Uwe

Signature · 2 lines
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Acked-by on v1 1/1
#2 lore raw
In reply to Stefan Agner
Quoted 11 lines

-----Original Message-----
From: Stefan Agner [mailto:[email protected]]
Sent: Monday, September 26, 2016 7:19 PM
To: [email protected]
Cc: Leo Li <[email protected]>; [email protected]; u.kleine- [email protected]; [email protected]; Stefan Agner <[email protected]>
Subject: [PATCH] i2c: imx: defer probe if bus recovery GPIOs are not ready

Quoted 7 lines

Some SoC might load the GPIO driver after the I2C driver and using the I2C bus recovery mechanism via GPIOs. In this case it is crucial to defer probing if the GPIO request functions do so, otherwise the I2C driver gets loaded without recovery mechanisms enabled.

Quoted 37 lines

---
This is an actual issue on NXP Vybrid devices on which the GPIO driver gets loaded rather later.

--
Stefan

 drivers/i2c/busses/i2c-imx.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/i2c/busses/i2c-imx.c +7 -4
index 592a8f2..47fc1f1 100644
@@ -1009,10 +1009,13 @@ static int i2c_imx_init_recovery_info(struct
 imx_i2c_struct *i2c_imx,
 	rinfo->sda_gpio = of_get_named_gpio(pdev->dev.of_node, "sda-gpios",
 0);
 	rinfo->scl_gpio = of_get_named_gpio(pdev->dev.of_node, "scl-gpios",
 0);
 
-	if (!gpio_is_valid(rinfo->sda_gpio) ||
-	    !gpio_is_valid(rinfo->scl_gpio) ||
-	    IS_ERR(i2c_imx->pinctrl_pins_default) ||
-	    IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
+	if (rinfo->sda_gpio == -EPROBE_DEFER ||
+	    rinfo->scl_gpio == -EPROBE_DEFER) {
+		return -EPROBE_DEFER;
+	} else if (!gpio_is_valid(rinfo->sda_gpio) ||
+		   !gpio_is_valid(rinfo->scl_gpio) ||
+		   IS_ERR(i2c_imx->pinctrl_pins_default) ||
+		   IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
drivers/i2c/busses/i2c-imx.c +0 -1
 		dev_dbg(&pdev->dev, "recovery information incomplete\n");
 		return 0;
 	}
--

2.10.0

#3 lore raw
In reply to Stefan Agner
Quoted 7 lines · Stefan Agner

Some SoC might load the GPIO driver after the I2C driver and using the I2C bus recovery mechanism via GPIOs. In this case it is crucial to defer probing if the GPIO request functions do so, otherwise the I2C driver gets loaded without recovery mechanisms enabled.

Added stable and applied to for-current, thanks! Please consider adding a "Fixes: <sha-id>" next time. This would be helpful.