aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/devicetree/bindings/i2c/i2c-rcar.txt23
-rw-r--r--drivers/i2c/busses/i2c-rcar.c21
2 files changed, 42 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/i2c/i2c-rcar.txt b/Documentation/devicetree/bindings/i2c/i2c-rcar.txt
new file mode 100644
index 000000000000..897cfcd5ce92
--- /dev/null
+++ b/Documentation/devicetree/bindings/i2c/i2c-rcar.txt
@@ -0,0 +1,23 @@
1I2C for R-Car platforms
2
3Required properties:
4- compatible: Must be one of
5 "renesas,i2c-rcar"
6 "renesas,i2c-r8a7778"
7 "renesas,i2c-r8a7779"
8 "renesas,i2c-r8a7790"
9- reg: physical base address of the controller and length of memory mapped
10 region.
11- interrupts: interrupt specifier.
12
13Optional properties:
14- clock-frequency: desired I2C bus clock frequency in Hz. The absence of this
15 propoerty indicates the default frequency 100 kHz.
16
17Examples :
18
19i2c0: i2c@e6500000 {
20 compatible = "renesas,i2c-rcar-h2";
21 reg = <0 0xe6500000 0 0x428>;
22 interrupts = <0 174 0x4>;
23};
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c
index 9325db49b4df..1f285a3be5c5 100644
--- a/drivers/i2c/busses/i2c-rcar.c
+++ b/drivers/i2c/busses/i2c-rcar.c
@@ -33,6 +33,7 @@
33#include <linux/i2c/i2c-rcar.h> 33#include <linux/i2c/i2c-rcar.h>
34#include <linux/kernel.h> 34#include <linux/kernel.h>
35#include <linux/module.h> 35#include <linux/module.h>
36#include <linux/of_device.h>
36#include <linux/platform_device.h> 37#include <linux/platform_device.h>
37#include <linux/pm_runtime.h> 38#include <linux/pm_runtime.h>
38#include <linux/slab.h> 39#include <linux/slab.h>
@@ -638,6 +639,15 @@ static const struct i2c_algorithm rcar_i2c_algo = {
638 .functionality = rcar_i2c_func, 639 .functionality = rcar_i2c_func,
639}; 640};
640 641
642static const struct of_device_id rcar_i2c_dt_ids[] = {
643 { .compatible = "renesas,i2c-rcar", .data = (void *)I2C_RCAR_H1 },
644 { .compatible = "renesas,i2c-r8a7778", .data = (void *)I2C_RCAR_H1 },
645 { .compatible = "renesas,i2c-r8a7779", .data = (void *)I2C_RCAR_H1 },
646 { .compatible = "renesas,i2c-r8a7790", .data = (void *)I2C_RCAR_H2 },
647 {},
648};
649MODULE_DEVICE_TABLE(of, rcar_i2c_dt_ids);
650
641static int rcar_i2c_probe(struct platform_device *pdev) 651static int rcar_i2c_probe(struct platform_device *pdev)
642{ 652{
643 struct i2c_rcar_platform_data *pdata = dev_get_platdata(&pdev->dev); 653 struct i2c_rcar_platform_data *pdata = dev_get_platdata(&pdev->dev);
@@ -655,10 +665,15 @@ static int rcar_i2c_probe(struct platform_device *pdev)
655 } 665 }
656 666
657 bus_speed = 100000; /* default 100 kHz */ 667 bus_speed = 100000; /* default 100 kHz */
658 if (pdata && pdata->bus_speed) 668 ret = of_property_read_u32(dev->of_node, "clock-frequency", &bus_speed);
669 if (ret < 0 && pdata && pdata->bus_speed)
659 bus_speed = pdata->bus_speed; 670 bus_speed = pdata->bus_speed;
660 671
661 priv->devtype = platform_get_device_id(pdev)->driver_data; 672 if (pdev->dev.of_node)
673 priv->devtype = (long)of_match_device(rcar_i2c_dt_ids,
674 dev)->data;
675 else
676 priv->devtype = platform_get_device_id(pdev)->driver_data;
662 677
663 ret = rcar_i2c_clock_calculate(priv, bus_speed, dev); 678 ret = rcar_i2c_clock_calculate(priv, bus_speed, dev);
664 if (ret < 0) 679 if (ret < 0)
@@ -679,6 +694,7 @@ static int rcar_i2c_probe(struct platform_device *pdev)
679 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD; 694 adap->class = I2C_CLASS_HWMON | I2C_CLASS_SPD;
680 adap->retries = 3; 695 adap->retries = 3;
681 adap->dev.parent = dev; 696 adap->dev.parent = dev;
697 adap->dev.of_node = dev->of_node;
682 i2c_set_adapdata(adap, priv); 698 i2c_set_adapdata(adap, priv);
683 strlcpy(adap->name, pdev->name, sizeof(adap->name)); 699 strlcpy(adap->name, pdev->name, sizeof(adap->name));
684 700
@@ -726,6 +742,7 @@ static struct platform_driver rcar_i2c_driver = {
726 .driver = { 742 .driver = {
727 .name = "i2c-rcar", 743 .name = "i2c-rcar",
728 .owner = THIS_MODULE, 744 .owner = THIS_MODULE,
745 .of_match_table = rcar_i2c_dt_ids,
729 }, 746 },
730 .probe = rcar_i2c_probe, 747 .probe = rcar_i2c_probe,
731 .remove = rcar_i2c_remove, 748 .remove = rcar_i2c_remove,