Skip to content

Commit 4ba6386

Browse files
fallenwsakernel
authored andcommitted
i2c: designware: Add support for recovery when GPIO need pinctrl
Currently if the SoC needs pinctrl to switch the SCL and SDA from the I2C function to GPIO function, the recovery won't work. scl-gpio = <>; sda-gpio = <>; Are not enough for some SoCs to have a working recovery. Some need: scl-gpio = <>; sda-gpio = <>; pinctrl-names = "default", "recovery"; pinctrl-0 = <&i2c_pins_hw>; pinctrl-1 = <&i2c_pins_gpio>; The driver was not filling rinfo->pinctrl with the device node pinctrl data which is needed by generic recovery code. Signed-off-by: Yann Sionneau <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Acked-by: Jarkko Nikula <[email protected]> Reviewed-by: Andi Shyti <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 2ed4fa9 commit 4ba6386

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

drivers/i2c/busses/i2c-designware-master.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/interrupt.h>
1818
#include <linux/io.h>
1919
#include <linux/module.h>
20+
#include <linux/pinctrl/consumer.h>
2021
#include <linux/pm_runtime.h>
2122
#include <linux/regmap.h>
2223
#include <linux/reset.h>
@@ -905,6 +906,17 @@ static int i2c_dw_init_recovery_info(struct dw_i2c_dev *dev)
905906
return PTR_ERR(gpio);
906907
rinfo->sda_gpiod = gpio;
907908

909+
rinfo->pinctrl = devm_pinctrl_get(dev->dev);
910+
if (IS_ERR(rinfo->pinctrl)) {
911+
if (PTR_ERR(rinfo->pinctrl) == -EPROBE_DEFER)
912+
return PTR_ERR(rinfo->pinctrl);
913+
914+
rinfo->pinctrl = NULL;
915+
dev_err(dev->dev, "getting pinctrl info failed: bus recovery might not work\n");
916+
} else if (!rinfo->pinctrl) {
917+
dev_dbg(dev->dev, "pinctrl is disabled, bus recovery might not work\n");
918+
}
919+
908920
rinfo->recover_bus = i2c_generic_scl_recovery;
909921
rinfo->prepare_recovery = i2c_dw_prepare_recovery;
910922
rinfo->unprepare_recovery = i2c_dw_unprepare_recovery;

0 commit comments

Comments
 (0)