Commit af71100c authored by Rob Herring's avatar Rob Herring

i2c-designware: add OF binding support

Add of_match_table and DT style i2c registration to designware i2c
driver.

Refactored for pci/plat split by Dirk Brandewie.
Signed-off-by: default avatarRob Herring <rob.herring@calxeda.com>
Acked-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Signed-off-by: default avatarDirk Brandewie <dirk.brandewie@gmail.com>
parent 02bca5ff
* Synopsys DesignWare I2C
Required properties :
- compatible : should be "snps,designware-i2c"
- reg : Offset and length of the register set for the device
- interrupts : <IRQ> where IRQ is the interrupt number.
Recommended properties :
- clock-frequency : desired I2C bus clock frequency in Hz.
Example :
i2c@f0000 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "snps,designware-i2c";
reg = <0xf0000 0x1000>;
interrupts = <11>;
clock-frequency = <400000>;
};
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/err.h> #include <linux/err.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/of_i2c.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/slab.h> #include <linux/slab.h>
...@@ -137,6 +138,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev) ...@@ -137,6 +138,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
sizeof(adap->name)); sizeof(adap->name));
adap->algo = &i2c_dw_algo; adap->algo = &i2c_dw_algo;
adap->dev.parent = &pdev->dev; adap->dev.parent = &pdev->dev;
adap->dev.of_node = pdev->dev.of_node;
adap->nr = pdev->id; adap->nr = pdev->id;
r = i2c_add_numbered_adapter(adap); r = i2c_add_numbered_adapter(adap);
...@@ -144,6 +146,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev) ...@@ -144,6 +146,7 @@ static int __devinit dw_i2c_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "failure adding adapter\n"); dev_err(&pdev->dev, "failure adding adapter\n");
goto err_free_irq; goto err_free_irq;
} }
of_i2c_register_devices(adap);
return 0; return 0;
...@@ -187,6 +190,14 @@ static int __devexit dw_i2c_remove(struct platform_device *pdev) ...@@ -187,6 +190,14 @@ static int __devexit dw_i2c_remove(struct platform_device *pdev)
return 0; return 0;
} }
#ifdef CONFIG_OF
static const struct of_device_id dw_i2c_of_match[] = {
{ .compatible = "snps,designware-i2c", },
{},
};
MODULE_DEVICE_TABLE(of, dw_i2c_of_match);
#endif
/* work with hotplug and coldplug */ /* work with hotplug and coldplug */
MODULE_ALIAS("platform:i2c_designware"); MODULE_ALIAS("platform:i2c_designware");
...@@ -195,6 +206,7 @@ static struct platform_driver dw_i2c_driver = { ...@@ -195,6 +206,7 @@ static struct platform_driver dw_i2c_driver = {
.driver = { .driver = {
.name = "i2c_designware", .name = "i2c_designware",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.of_match_table = of_match_ptr(dw_i2c_of_match),
}, },
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment