* [PATCH 0/2] dts for i2c-omap: fix incorrect adapter id
@ 2012-08-31 7:52 Florian Vaussard
2012-08-31 7:52 ` [PATCH 1/2] i2c-omap: Fix incorrect adapter id when booting from a device tree Florian Vaussard
2012-08-31 7:52 ` [PATCH 2/2] arm/dts: Add i2c aliases for OMAP3 and OMAP4/AM33xx Florian Vaussard
0 siblings, 2 replies; 5+ messages in thread
From: Florian Vaussard @ 2012-08-31 7:52 UTC (permalink / raw)
To: linux-arm-kernel
Hello,
This patchset fixes the i2c adapter id on OMAP3 and OMAP4/AM33xx when booting
from a device tree.
Currently, pdev->id is used, regardless of the boot method. The first patch
checks for of_node, and get the id from the alias if a device tree is found.
The boot message is updated accordingly.
The second patch add the necessary aliases for OMAP3, OMAP4 and AM33xx.
This patchset applies on 3.6-rc3 and has been tested on OMAP3 (Gumstix Overo).
Regards,
Florian
Florian Vaussard (2):
i2c-omap: Fix incorrect adapter id when booting from a device tree
arm/dts: Add i2c aliases for OMAP3 and OMAP4/AM33xx
arch/arm/boot/dts/am33xx.dtsi | 3 +++
arch/arm/boot/dts/omap3.dtsi | 3 +++
arch/arm/boot/dts/omap4.dtsi | 4 ++++
drivers/i2c/busses/i2c-omap.c | 19 +++++++++++++++----
4 files changed, 25 insertions(+), 4 deletions(-)
--
1.7.5.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] i2c-omap: Fix incorrect adapter id when booting from a device tree
2012-08-31 7:52 [PATCH 0/2] dts for i2c-omap: fix incorrect adapter id Florian Vaussard
@ 2012-08-31 7:52 ` Florian Vaussard
2012-08-31 9:14 ` Benoit Cousson
2012-08-31 7:52 ` [PATCH 2/2] arm/dts: Add i2c aliases for OMAP3 and OMAP4/AM33xx Florian Vaussard
1 sibling, 1 reply; 5+ messages in thread
From: Florian Vaussard @ 2012-08-31 7:52 UTC (permalink / raw)
To: linux-arm-kernel
When booting from a device tree, the omap driver is using pdev->id,
which is incorrect. The proposed patch uses aliases, as done in
omap-serial.
Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
---
drivers/i2c/busses/i2c-omap.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index 5d19a49..9445d1f 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -1064,9 +1064,6 @@ omap_i2c_probe(struct platform_device *pdev)
goto err_unuse_clocks;
}
- dev_info(dev->dev, "bus %d rev%d.%d.%d at %d kHz\n", pdev->id,
- dev->dtrev, dev->rev >> 4, dev->rev & 0xf, dev->speed);
-
adap = &dev->adapter;
i2c_set_adapdata(adap, dev);
adap->owner = THIS_MODULE;
@@ -1076,8 +1073,22 @@ omap_i2c_probe(struct platform_device *pdev)
adap->dev.parent = &pdev->dev;
adap->dev.of_node = pdev->dev.of_node;
+ if (adap->dev.of_node)
+ adap->nr = of_alias_get_id(adap->dev.of_node, "i2c");
+ else
+ adap->nr = pdev->id;
+
+ if (adap->nr < 0) {
+ dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n",
+ adap->nr);
+ r = -ENODEV;
+ goto err_free_irq;
+ }
+
+ dev_info(dev->dev, "bus %d rev%d.%d.%d at %d kHz\n", adap->nr,
+ dev->dtrev, dev->rev >> 4, dev->rev & 0xf, dev->speed);
+
/* i2c device drivers may be active on return from add_adapter() */
- adap->nr = pdev->id;
r = i2c_add_numbered_adapter(adap);
if (r) {
dev_err(dev->dev, "failure adding adapter\n");
--
1.7.5.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] arm/dts: Add i2c aliases for OMAP3 and OMAP4/AM33xx
2012-08-31 7:52 [PATCH 0/2] dts for i2c-omap: fix incorrect adapter id Florian Vaussard
2012-08-31 7:52 ` [PATCH 1/2] i2c-omap: Fix incorrect adapter id when booting from a device tree Florian Vaussard
@ 2012-08-31 7:52 ` Florian Vaussard
1 sibling, 0 replies; 5+ messages in thread
From: Florian Vaussard @ 2012-08-31 7:52 UTC (permalink / raw)
To: linux-arm-kernel
I2C aliases need to be set, for the omap-i2c driver to get a correct adapter id.
Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
---
arch/arm/boot/dts/am33xx.dtsi | 3 +++
arch/arm/boot/dts/omap3.dtsi | 3 +++
arch/arm/boot/dts/omap4.dtsi | 4 ++++
3 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi
index 59509c4..ff2d879 100644
--- a/arch/arm/boot/dts/am33xx.dtsi
+++ b/arch/arm/boot/dts/am33xx.dtsi
@@ -20,6 +20,9 @@
serial3 = &uart4;
serial4 = &uart5;
serial5 = &uart6;
+ i2c0 = &i2c1;
+ i2c1 = &i2c2;
+ i2c2 = &i2c3;
};
cpus {
diff --git a/arch/arm/boot/dts/omap3.dtsi b/arch/arm/boot/dts/omap3.dtsi
index 8109471..a7d2f83 100644
--- a/arch/arm/boot/dts/omap3.dtsi
+++ b/arch/arm/boot/dts/omap3.dtsi
@@ -18,6 +18,9 @@
serial1 = &uart2;
serial2 = &uart3;
serial3 = &uart4;
+ i2c0 = &i2c1;
+ i2c1 = &i2c2;
+ i2c2 = &i2c3;
};
cpus {
diff --git a/arch/arm/boot/dts/omap4.dtsi b/arch/arm/boot/dts/omap4.dtsi
index 04cbbcb..496c7ce 100644
--- a/arch/arm/boot/dts/omap4.dtsi
+++ b/arch/arm/boot/dts/omap4.dtsi
@@ -25,6 +25,10 @@
serial1 = &uart2;
serial2 = &uart3;
serial3 = &uart4;
+ i2c0 = &i2c1;
+ i2c1 = &i2c2;
+ i2c2 = &i2c3;
+ i2c3 = &i2c4;
};
cpus {
--
1.7.5.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 1/2] i2c-omap: Fix incorrect adapter id when booting from a device tree
2012-08-31 7:52 ` [PATCH 1/2] i2c-omap: Fix incorrect adapter id when booting from a device tree Florian Vaussard
@ 2012-08-31 9:14 ` Benoit Cousson
2012-08-31 9:53 ` Florian Vaussard
0 siblings, 1 reply; 5+ messages in thread
From: Benoit Cousson @ 2012-08-31 9:14 UTC (permalink / raw)
To: linux-arm-kernel
Hi Florian,
On 08/31/2012 09:52 AM, Florian Vaussard wrote:
> When booting from a device tree, the omap driver is using pdev->id,
> which is incorrect.
Not really, see below...
> The proposed patch uses aliases, as done in omap-serial.
Mmm, but is it really needed?
In the case of serial the id is important because of the tty number used
as device interface.
In the case of I2C, the id is mostly irrelevant.
In fact, using the pdev->id = -1 was used on purpose to have a dynamic
assignment:
int i2c_add_numbered_adapter(struct i2c_adapter *adap)
...
if (adap->nr == -1) /* -1 means dynamically assign bus id */
return i2c_add_adapter(adap);
> Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
> ---
> drivers/i2c/busses/i2c-omap.c | 19 +++++++++++++++----
> 1 files changed, 15 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
> index 5d19a49..9445d1f 100644
> --- a/drivers/i2c/busses/i2c-omap.c
> +++ b/drivers/i2c/busses/i2c-omap.c
> @@ -1064,9 +1064,6 @@ omap_i2c_probe(struct platform_device *pdev)
> goto err_unuse_clocks;
> }
>
> - dev_info(dev->dev, "bus %d rev%d.%d.%d at %d kHz\n", pdev->id,
> - dev->dtrev, dev->rev >> 4, dev->rev & 0xf, dev->speed);
> -
[ 0.658843] omap_i2c i2c.15: bus -1 rev2.4.0 at 400 kHz
[ 0.760192] omap_i2c i2c.16: bus -1 rev2.4.0 at 400 kHz
[ 0.775817] omap_i2c i2c.17: bus -1 rev2.4.0 at 400 kHz
[ 0.791442] omap_i2c i2c.18: bus -1 rev2.4.0 at 400 kHz
OK, it is true that the current log is not that nice with bus -1, but
maybe we should just remove that.
Or we can potentially retrieve the i2c adapter number assign later, and
delay the log.
> r = i2c_add_numbered_adapter(adap);
> if (r) {
> dev_err(dev->dev, "failure adding adapter\n");
Regards,
Benoit
> adap = &dev->adapter;
> i2c_set_adapdata(adap, dev);
> adap->owner = THIS_MODULE;
> @@ -1076,8 +1073,22 @@ omap_i2c_probe(struct platform_device *pdev)
> adap->dev.parent = &pdev->dev;
> adap->dev.of_node = pdev->dev.of_node;
>
> + if (adap->dev.of_node)
> + adap->nr = of_alias_get_id(adap->dev.of_node, "i2c");
> + else
> + adap->nr = pdev->id;
> +
> + if (adap->nr < 0) {
> + dev_err(&pdev->dev, "failed to get alias/pdev id, errno %d\n",
> + adap->nr);
> + r = -ENODEV;
> + goto err_free_irq;
> + }
> +
> + dev_info(dev->dev, "bus %d rev%d.%d.%d at %d kHz\n", adap->nr,
> + dev->dtrev, dev->rev >> 4, dev->rev & 0xf, dev->speed);
> +
> /* i2c device drivers may be active on return from add_adapter() */
> - adap->nr = pdev->id;
> r = i2c_add_numbered_adapter(adap);
> if (r) {
> dev_err(dev->dev, "failure adding adapter\n");
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] i2c-omap: Fix incorrect adapter id when booting from a device tree
2012-08-31 9:14 ` Benoit Cousson
@ 2012-08-31 9:53 ` Florian Vaussard
0 siblings, 0 replies; 5+ messages in thread
From: Florian Vaussard @ 2012-08-31 9:53 UTC (permalink / raw)
To: linux-arm-kernel
Hi Benoit,
> [ 0.658843] omap_i2c i2c.15: bus -1 rev2.4.0 at 400 kHz
> [ 0.760192] omap_i2c i2c.16: bus -1 rev2.4.0 at 400 kHz
> [ 0.775817] omap_i2c i2c.17: bus -1 rev2.4.0 at 400 kHz
> [ 0.791442] omap_i2c i2c.18: bus -1 rev2.4.0 at 400 kHz
>
> OK, it is true that the current log is not that nice with bus -1, but
> maybe we should just remove that.
>
> Or we can potentially retrieve the i2c adapter number assign later, and
> delay the log.
>
>> r = i2c_add_numbered_adapter(adap);
>> if (r) {
>> dev_err(dev->dev, "failure adding adapter\n");
I agree, we should defer the log if we want a nice print. I will send a
new patch.
Regards,
Florian
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-08-31 9:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-31 7:52 [PATCH 0/2] dts for i2c-omap: fix incorrect adapter id Florian Vaussard
2012-08-31 7:52 ` [PATCH 1/2] i2c-omap: Fix incorrect adapter id when booting from a device tree Florian Vaussard
2012-08-31 9:14 ` Benoit Cousson
2012-08-31 9:53 ` Florian Vaussard
2012-08-31 7:52 ` [PATCH 2/2] arm/dts: Add i2c aliases for OMAP3 and OMAP4/AM33xx Florian Vaussard
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).