Thread (1 message) 1 message, 1 author, 2017-08-24
DORMANTno replies

[PATCH/RFC 2/3] i2c: gpio: Add support for named gpios in DT

From: Geert Uytterhoeven <hidden>
Date: 2017-08-24 09:21:13
Also in: linux-i2c, linux-renesas-soc
Subsystem: generic gpio i2c driver, i2c subsystem, i2c subsystem host drivers, the rest · Maintainers: Wolfram Sang, Andi Shyti, Linus Torvalds

Possibly related (same subject, not in this thread)

Add support for the new DT bindings using named gpios, which are less
error-prone than unnamed gpios.  The latter are still supported as a
fallback.

Signed-off-by: Geert Uytterhoeven <redacted>
---
 drivers/i2c/busses/i2c-gpio.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index 0ef8fcc6ac3aca1e..45b7ec99dc210bbe 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -88,6 +88,15 @@ static int i2c_gpio_getscl(void *data)
 static int of_i2c_gpio_get_pins(struct device_node *np,
 				unsigned int *sda_pin, unsigned int *scl_pin)
 {
+	*sda_pin = of_get_named_gpio(np, "sda-gpios", 0);
+	*scl_pin = of_get_named_gpio(np, "scl-gpios", 0);
+	if (*sda_pin == -EPROBE_DEFER || *scl_pin == -EPROBE_DEFER)
+		return -EPROBE_DEFER;
+
+	if (gpio_is_valid(*sda_pin) && gpio_is_valid(*scl_pin))
+		return 0;
+
+	/* Try deprecated unnamed gpios */
 	if (of_gpio_count(np) < 2)
 		return -ENODEV;
 
-- 
2.7.4

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help