devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c: i2c-gpio: fix issue when DT node greater than 1
@ 2012-09-18  9:02 Bo Shen
       [not found] ` <1347958949-5598-1-git-send-email-voice.shen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 10+ messages in thread
From: Bo Shen @ 2012-09-18  9:02 UTC (permalink / raw)
  To: hskinnemoen, linux-i2c, linux-arm-kernel
  Cc: nicolas.ferre, devicetree-discuss, plagnioj, Bo Shen

When i2c-gpio node number is greater than 1, the second can not sucessfully
regiter

Using alias method to get the pdev->id, or else the second device will use
the same id which will cause fail to register

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---
 Documentation/devicetree/bindings/i2c/gpio-i2c.txt |   46 +++++++++++++++++++-
 drivers/i2c/busses/i2c-gpio.c                      |    1 +
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/Documentation/devicetree/bindings/i2c/gpio-i2c.txt b/Documentation/devicetree/bindings/i2c/gpio-i2c.txt
index 4f8ec94..e76dd00 100644
--- a/Documentation/devicetree/bindings/i2c/gpio-i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/gpio-i2c.txt
@@ -1,4 +1,7 @@
-Device-Tree bindings for i2c gpio driver
+* Device-Tree bindings for i2c gpio driver
+
+Optional alias:
+	- i2c-gpio: used to get id, when more than one i2c-gpio in dts file
 
 Required properties:
 	- compatible = "i2c-gpio";
@@ -30,3 +33,44 @@ i2c@0 {
 		reg = <0x56>;
 	};
 };
+
+
+Example nodes with alias:
+
+aliases {
+	i2c-gpio0 = &i2c0;
+	i2c-gpio1 = &i2c1;
+};
+
+i2c0: i2c@0 {
+	compatible = "i2c-gpio";
+	gpios = <&pioA 23 0 /* sda */
+		 &pioA 24 0 /* scl */
+		>;
+	i2c-gpio,sda-open-drain;
+	i2c-gpio,scl-open-drain;
+	i2c-gpio,delay-us = <2>;	/* ~100 kHz */
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	rv3029c2@56 {
+		compatible = "rv3029c2";
+		reg = <0x56>;
+	};
+};
+
+i2c1: i2c@0 {
+	compatible = "i2c-gpio";
+	gpios = <&pioA 30 0 /* sda */
+		 &pioA 31 0 /* scl */
+		>;
+	i2c-gpio,sda-open-drain;
+	i2c-gpio,scl-open-drain;
+	i2c-gpio,delay-us = <2>;	/* ~100 kHz */
+	#address-cells = <1>;
+	#size-cells = <0>;
+
+	rv3029c2@56 {
+		compatible = "rv3029c2";
+		reg = <0x56>;
+	};
diff --git a/drivers/i2c/busses/i2c-gpio.c b/drivers/i2c/busses/i2c-gpio.c
index e62d2d9..051fbb3 100644
--- a/drivers/i2c/busses/i2c-gpio.c
+++ b/drivers/i2c/busses/i2c-gpio.c
@@ -136,6 +136,7 @@ static int __devinit i2c_gpio_probe(struct platform_device *pdev)
 		ret = of_i2c_gpio_probe(pdev->dev.of_node, pdata);
 		if (ret)
 			return ret;
+		pdev->id = of_alias_get_id(pdev->dev.of_node, "i2c-gpio");
 	} else {
 		if (!pdev->dev.platform_data)
 			return -ENXIO;
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2012-10-15  7:32 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-18  9:02 [PATCH] i2c: i2c-gpio: fix issue when DT node greater than 1 Bo Shen
     [not found] ` <1347958949-5598-1-git-send-email-voice.shen-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-09-18 14:51   ` Stephen Warren
     [not found]     ` <50588A8F.30203-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-09-19  1:15       ` Bo Shen
     [not found]         ` <50591C9C.2080809-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-09-19 15:28           ` Stephen Warren
     [not found]             ` <5059E484.6090708-3lzwWm7+Weoh9ZMKESR00Q@public.gmane.org>
2012-09-19 15:54               ` Jean Delvare
     [not found]                 ` <20120919175433.3841a954-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-10-10  2:54                   ` Bo Shen
     [not found]                     ` <5074E349.30605-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-10-15  2:59                       ` Bo Shen
     [not found]                         ` <507B7C07.3070702-AIFe0yeh4nAAvxtiuMwx3w@public.gmane.org>
2012-10-15  5:55                           ` Jean-Christophe PLAGNIOL-VILLARD
2012-10-15  6:49                           ` Jean Delvare
     [not found]                             ` <20121015084920.75d4aa53-R0o5gVi9kd7kN2dkZ6Wm7A@public.gmane.org>
2012-10-15  7:32                               ` Bo Shen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).