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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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 <geert+renesas@xxxxxxxxx>
---
 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux