aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2012-05-12 01:43:32 -0400
committerShawn Guo <shawn.guo@linaro.org>2012-05-12 20:27:44 -0400
commitb2378668489d16eb1a1ac722e84cc6a9a1513ba0 (patch)
tree2cd477d1d479d861133e6e89b9af162c66a1e649
parent35d23047f8ba1b7cc9a067b9506352fd257c8df5 (diff)
i2c: mxs: add device tree probe support
Add device tree probe support for i2c-mxs driver. So far, it's only been tested on imx28. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Acked-by: Wolfram Sang <w.sang@pengutronix.de>
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-mxs.txt16
-rw-r--r--drivers/i2c/busses/i2c-mxs.c13
2 files changed, 29 insertions, 0 deletions
diff --git a/Documentation/devicetree/bindings/i2c/i2c-mxs.txt b/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
new file mode 100644
index 000000000000..1bfc02de1b0c
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-mxs.txt
@@ -0,0 +1,16 @@
1* Freescale MXS Inter IC (I2C) Controller
2
3Required properties:
4- compatible: Should be "fsl,<chip>-i2c"
5- reg: Should contain registers location and length
6- interrupts: Should contain ERROR and DMA interrupts
7
8Examples:
9
10i2c0: i2c@80058000 {
11 #address-cells = <1>;
12 #size-cells = <0>;
13 compatible = "fsl,imx28-i2c";
14 reg = <0x80058000 2000>;
15 interrupts = <111 68>;
16};
diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 7fa73eed84a7..7dca58b0e746 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -27,6 +27,9 @@
27#include <linux/jiffies.h> 27#include <linux/jiffies.h>
28#include <linux/io.h> 28#include <linux/io.h>
29#include <linux/pinctrl/consumer.h> 29#include <linux/pinctrl/consumer.h>
30#include <linux/of.h>
31#include <linux/of_device.h>
32#include <linux/of_i2c.h>
30 33
31#include <mach/common.h> 34#include <mach/common.h>
32 35
@@ -371,6 +374,7 @@ static int __devinit mxs_i2c_probe(struct platform_device *pdev)
371 adap->algo = &mxs_i2c_algo; 374 adap->algo = &mxs_i2c_algo;
372 adap->dev.parent = dev; 375 adap->dev.parent = dev;
373 adap->nr = pdev->id; 376 adap->nr = pdev->id;
377 adap->dev.of_node = pdev->dev.of_node;
374 i2c_set_adapdata(adap, i2c); 378 i2c_set_adapdata(adap, i2c);
375 err = i2c_add_numbered_adapter(adap); 379 err = i2c_add_numbered_adapter(adap);
376 if (err) { 380 if (err) {
@@ -380,6 +384,8 @@ static int __devinit mxs_i2c_probe(struct platform_device *pdev)
380 return err; 384 return err;
381 } 385 }
382 386
387 of_i2c_register_devices(adap);
388
383 return 0; 389 return 0;
384} 390}
385 391
@@ -399,10 +405,17 @@ static int __devexit mxs_i2c_remove(struct platform_device *pdev)
399 return 0; 405 return 0;
400} 406}
401 407
408static const struct of_device_id mxs_i2c_dt_ids[] = {
409 { .compatible = "fsl,imx28-i2c", },
410 { /* sentinel */ }
411};
412MODULE_DEVICE_TABLE(of, mxs_i2c_dt_ids);
413
402static struct platform_driver mxs_i2c_driver = { 414static struct platform_driver mxs_i2c_driver = {
403 .driver = { 415 .driver = {
404 .name = DRIVER_NAME, 416 .name = DRIVER_NAME,
405 .owner = THIS_MODULE, 417 .owner = THIS_MODULE,
418 .of_match_table = mxs_i2c_dt_ids,
406 }, 419 },
407 .remove = __devexit_p(mxs_i2c_remove), 420 .remove = __devexit_p(mxs_i2c_remove),
408}; 421};