I2C: BCM2835: Linking platform nodes to adapter nodes
Subsystems (3)
PATCH 1/1 I2C: BCM2835: Linking platform nodes to adapter nodes
In order to find I2C devices in the device tree, the platform nodes have to be known by the I2C core. Analogous to the i2c-omap driver this requires setting the dev.of_node parameter of the adapter.
---
I don't know if this is really necessary, but for me it does not work without this line.
drivers/i2c/busses/i2c-bcm2835.c | 1 + 1 file changed, 1 insertion(+)
drivers/i2c/busses/i2c-bcm2835.c +1 -0
@@ -299,6 +299,7 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)strlcpy (adap->name,"bcm2835 I2C adapter" ,sizeof (adap->name)); adap->algo = &bcm2835_i2c_algo; adap->dev.parent = &pdev->dev; + adap->dev.of_node = pdev->dev.of_node;bcm2835_i2c_writel (i2c_dev,BCM2835_I2C_C ,0 );
Signature · 1 line
1.7.9.5
Quoted 3 lines · Florian Meier
In order to find I2C devices in the device tree, the platform nodes have to be known by the I2C core. Analogous to the i2c-omap driver this requires setting the dev.of_node parameter of the adapter.
(CCing the I2C maintainers...)
drivers/i2c/busses/i2c-bcm2835.c static int bcm2835_i2c_probe(struct platform_device *pdev) · line 302
Quoted 7 lines
drivers/i2c/busses/i2c-bcm2835.c +1
-0@@ -299,6 +299,7 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)strlcpy (adap->name,"bcm2835 I2C adapter" ,sizeof (adap->name)); adap->algo = &bcm2835_i2c_algo; adap->dev.parent = &pdev->dev; + adap->dev.of_node = pdev->dev.of_node;
Ah, that makes sense. Thinking about it now, I'd only ever used i2cget etc. to access I2C devices, rather than instantiating drivers from DT.
That all said, I wonder if the I2C core shouldn't do something like the following inside i2c_add_adapter():
if (!adap->dev.of_node && adap->dev.parent)
adap->dev.of_node = adap->dev.parent->of_node;
That would save every single I2C driver from having to set up this field manually.
Quoted 18 lines · Stephen Warren
Quoted 3 lines · Florian Meier
In order to find I2C devices in the device tree, the platform nodes have to be known by the I2C core. Analogous to the i2c-omap driver this requires setting the dev.of_node parameter of the adapter.
(CCing the I2C maintainers...)
drivers/i2c/busses/i2c-bcm2835.c static int bcm2835_i2c_probe(struct platform_device *pdev) · line 302
Quoted 7 lines
drivers/i2c/busses/i2c-bcm2835.c +1
-0@@ -299,6 +299,7 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)strlcpy (adap->name,"bcm2835 I2C adapter" ,sizeof (adap->name)); adap->algo = &bcm2835_i2c_algo; adap->dev.parent = &pdev->dev; + adap->dev.of_node = pdev->dev.of_node;Ah, that makes sense. Thinking about it now, I'd only ever used i2cget etc. to access I2C devices, rather than instantiating drivers from DT.
Quoted 8 lines
That all said, I wonder if the I2C core shouldn't do something like the following inside
i2c_add_adapter():if (!adap->dev.of_node &&
adap->dev.parent)adap->dev.of_node = adap->dev.parent->of_node;That would save every single I2C driver from having to set up this field manually.
BTW, this should probably be:
Cc: stable at vger.kernel.org
Quoted 18 lines · Stephen Warren
Quoted 3 lines · Florian Meier
In order to find I2C devices in the device tree, the platform nodes have to be known by the I2C core. Analogous to the i2c-omap driver this requires setting the dev.of_node parameter of the adapter.
(CCing the I2C maintainers...)
drivers/i2c/busses/i2c-bcm2835.c static int bcm2835_i2c_probe(struct platform_device *pdev) · line 302
Quoted 7 lines
drivers/i2c/busses/i2c-bcm2835.c +1
-0@@ -299,6 +299,7 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)strlcpy (adap->name,"bcm2835 I2C adapter" ,sizeof (adap->name)); adap->algo = &bcm2835_i2c_algo; adap->dev.parent = &pdev->dev; + adap->dev.of_node = pdev->dev.of_node;Ah, that makes sense. Thinking about it now, I'd only ever used i2cget etc. to access I2C devices, rather than instantiating drivers from DT.
Quoted 5 lines
That all said, I wonder if the I2C core shouldn't do something like the following inside
i2c_add_adapter():if (!adap->dev.of_node &&
adap->dev.parent)adap->dev.of_node = adap->dev.parent->of_node;
Should this not also have an of_node_get to increment the ref count on the node?
Thanks,
Charles
Quoted 10 lines · Charles Keepax
Quoted 5 lines · Stephen Warren
That all said, I wonder if the I2C core shouldn't do something like the following inside
i2c_add_adapter():if (!adap->dev.of_node &&
adap->dev.parent)adap->dev.of_node = adap->dev.parent->of_node;Should this not also have an
of_node_getto increment the ref count on the node?
Given that it's pointing to the device that registered the I2C adaptor
it should be able to assume that there's a reference already.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20131128/5170cc34/attachment.sig>