Re: [PATCH] i2c: imx: defer probe if bus recovery GPIOs are not ready

2016-10-25 Thread Wolfram Sang
On Mon, Sep 26, 2016 at 05:18:58PM -0700, Stefan Agner wrote:
> 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.
> 
> Signed-off-by: Stefan Agner 

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



signature.asc
Description: PGP signature


Re: [PATCH] i2c: imx: defer probe if bus recovery GPIOs are not ready

2016-10-25 Thread Wolfram Sang
On Mon, Sep 26, 2016 at 05:18:58PM -0700, Stefan Agner wrote:
> 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.
> 
> Signed-off-by: Stefan Agner 

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



signature.asc
Description: PGP signature


RE: [PATCH] i2c: imx: defer probe if bus recovery GPIOs are not ready

2016-09-27 Thread Leo Li


> -Original Message-
> From: Stefan Agner [mailto:ste...@agner.ch]
> Sent: Monday, September 26, 2016 7:19 PM
> To: w...@the-dreams.de
> Cc: Leo Li <leoyang...@nxp.com>; linux-...@vger.kernel.org; u.kleine-
> koe...@pengutronix.de; linux-kernel@vger.kernel.org; Stefan Agner
> <ste...@agner.ch>
> Subject: [PATCH] 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.
> 
> Signed-off-by: Stefan Agner <ste...@agner.ch>

Acked-by: Li Yang <leoyang...@nxp.com>

> ---
> 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(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 592a8f2..47fc1f1 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -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(>dev, "recovery information incomplete\n");
>   return 0;
>   }
> --
> 2.10.0



RE: [PATCH] i2c: imx: defer probe if bus recovery GPIOs are not ready

2016-09-27 Thread Leo Li


> -Original Message-
> From: Stefan Agner [mailto:ste...@agner.ch]
> Sent: Monday, September 26, 2016 7:19 PM
> To: w...@the-dreams.de
> Cc: Leo Li ; linux-...@vger.kernel.org; u.kleine-
> koe...@pengutronix.de; linux-kernel@vger.kernel.org; Stefan Agner
> 
> Subject: [PATCH] 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.
> 
> Signed-off-by: Stefan Agner 

Acked-by: Li Yang 

> ---
> 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(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index 592a8f2..47fc1f1 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -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(>dev, "recovery information incomplete\n");
>   return 0;
>   }
> --
> 2.10.0



Re: [PATCH] i2c: imx: defer probe if bus recovery GPIOs are not ready

2016-09-27 Thread Uwe Kleine-König
Hello Stefan,

On Mon, Sep 26, 2016 at 05:18:58PM -0700, Stefan Agner wrote:
> 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.
> 
> Signed-off-by: Stefan Agner 
Acked-by: Uwe Kleine-König 

Thanks
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |


Re: [PATCH] i2c: imx: defer probe if bus recovery GPIOs are not ready

2016-09-27 Thread Uwe Kleine-König
Hello Stefan,

On Mon, Sep 26, 2016 at 05:18:58PM -0700, Stefan Agner wrote:
> 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.
> 
> Signed-off-by: Stefan Agner 
Acked-by: Uwe Kleine-König 

Thanks
Uwe

-- 
Pengutronix e.K.   | Uwe Kleine-König|
Industrial Linux Solutions | http://www.pengutronix.de/  |


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

2016-09-26 Thread 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.

Signed-off-by: Stefan Agner 
---
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(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 592a8f2..47fc1f1 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -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(>dev, "recovery information incomplete\n");
return 0;
}
-- 
2.10.0



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

2016-09-26 Thread 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.

Signed-off-by: Stefan Agner 
---
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(-)

diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
index 592a8f2..47fc1f1 100644
--- a/drivers/i2c/busses/i2c-imx.c
+++ b/drivers/i2c/busses/i2c-imx.c
@@ -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(>dev, "recovery information incomplete\n");
return 0;
}
-- 
2.10.0