提交 3ac0b337 编写于 作者: L Lars-Peter Clausen 提交者: Wolfram Sang

I2C: xiic: Add OF binding support

Signed-off-by: NLars-Peter Clausen <lars@metafoo.de>
Signed-off-by: NWolfram Sang <w.sang@pengutronix.de>
上级 e7065e20
Xilinx IIC controller:
Required properties:
- compatible : Must be "xlnx,xps-iic-2.00.a"
- reg : IIC register location and length
- interrupts : IIC controller unterrupt
- #address-cells = <1>
- #size-cells = <0>
Optional properties:
- Child nodes conforming to i2c bus binding
Example:
axi_iic_0: i2c@40800000 {
compatible = "xlnx,xps-iic-2.00.a";
interrupts = < 1 2 >;
reg = < 0x40800000 0x10000 >;
#size-cells = <0>;
#address-cells = <1>;
};
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <linux/i2c-xiic.h> #include <linux/i2c-xiic.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/of_i2c.h>
#define DRIVER_NAME "xiic-i2c" #define DRIVER_NAME "xiic-i2c"
...@@ -705,8 +706,6 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev) ...@@ -705,8 +706,6 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev)
goto resource_missing; goto resource_missing;
pdata = (struct xiic_i2c_platform_data *) pdev->dev.platform_data; pdata = (struct xiic_i2c_platform_data *) pdev->dev.platform_data;
if (!pdata)
return -EINVAL;
i2c = kzalloc(sizeof(*i2c), GFP_KERNEL); i2c = kzalloc(sizeof(*i2c), GFP_KERNEL);
if (!i2c) if (!i2c)
...@@ -730,6 +729,7 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev) ...@@ -730,6 +729,7 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev)
i2c->adap = xiic_adapter; i2c->adap = xiic_adapter;
i2c_set_adapdata(&i2c->adap, i2c); i2c_set_adapdata(&i2c->adap, i2c);
i2c->adap.dev.parent = &pdev->dev; i2c->adap.dev.parent = &pdev->dev;
i2c->adap.dev.of_node = pdev->dev.of_node;
xiic_reinit(i2c); xiic_reinit(i2c);
...@@ -748,9 +748,13 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev) ...@@ -748,9 +748,13 @@ static int __devinit xiic_i2c_probe(struct platform_device *pdev)
goto add_adapter_failed; goto add_adapter_failed;
} }
/* add in known devices to the bus */ if (pdata) {
for (i = 0; i < pdata->num_devices; i++) /* add in known devices to the bus */
i2c_new_device(&i2c->adap, pdata->devices + i); for (i = 0; i < pdata->num_devices; i++)
i2c_new_device(&i2c->adap, pdata->devices + i);
}
of_i2c_register_devices(&i2c->adap);
return 0; return 0;
...@@ -795,12 +799,21 @@ static int __devexit xiic_i2c_remove(struct platform_device* pdev) ...@@ -795,12 +799,21 @@ static int __devexit xiic_i2c_remove(struct platform_device* pdev)
return 0; return 0;
} }
#if defined(CONFIG_OF)
static const struct of_device_id xiic_of_match[] __devinitconst = {
{ .compatible = "xlnx,xps-iic-2.00.a", },
{},
};
MODULE_DEVICE_TABLE(of, xiic_of_match);
#endif
static struct platform_driver xiic_i2c_driver = { static struct platform_driver xiic_i2c_driver = {
.probe = xiic_i2c_probe, .probe = xiic_i2c_probe,
.remove = __devexit_p(xiic_i2c_remove), .remove = __devexit_p(xiic_i2c_remove),
.driver = { .driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.name = DRIVER_NAME, .name = DRIVER_NAME,
.of_match_table = of_match_ptr(xiic_of_match),
}, },
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册