Skip to content

Commit 533169d

Browse files
agnersWolfram Sang
authored andcommitted
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 <stefan@agner.ch> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Li Yang <leoyang.li@nxp.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de> Cc: stable@kernel.org
1 parent 171e23e commit 533169d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

drivers/i2c/busses/i2c-imx.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,10 +1009,13 @@ static int i2c_imx_init_recovery_info(struct imx_i2c_struct *i2c_imx,
10091009
rinfo->sda_gpio = of_get_named_gpio(pdev->dev.of_node, "sda-gpios", 0);
10101010
rinfo->scl_gpio = of_get_named_gpio(pdev->dev.of_node, "scl-gpios", 0);
10111011

1012-
if (!gpio_is_valid(rinfo->sda_gpio) ||
1013-
!gpio_is_valid(rinfo->scl_gpio) ||
1014-
IS_ERR(i2c_imx->pinctrl_pins_default) ||
1015-
IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
1012+
if (rinfo->sda_gpio == -EPROBE_DEFER ||
1013+
rinfo->scl_gpio == -EPROBE_DEFER) {
1014+
return -EPROBE_DEFER;
1015+
} else if (!gpio_is_valid(rinfo->sda_gpio) ||
1016+
!gpio_is_valid(rinfo->scl_gpio) ||
1017+
IS_ERR(i2c_imx->pinctrl_pins_default) ||
1018+
IS_ERR(i2c_imx->pinctrl_pins_gpio)) {
10161019
dev_dbg(&pdev->dev, "recovery information incomplete\n");
10171020
return 0;
10181021
}

0 commit comments

Comments
 (0)