diff options
author | John Bonesio <bones@secretlab.ca> | 2011-06-22 12:16:56 -0400 |
---|---|---|
committer | Ben Dooks <ben-linux@fluff.org> | 2011-07-26 19:02:28 -0400 |
commit | 5c470f39eea66ff00b31136f8bce9359d6b95375 (patch) | |
tree | 129c3a0cbd22fca7f3d953e5e3524505d4e4e737 /drivers/i2c | |
parent | ba5b56cb3e3d2cab73d4fee9a022bb69462a8cd9 (diff) |
i2c: Tegra: Add DeviceTree support
This patch modifies the tegra i2c driver so that it can be initiailized
using the device tree along with the devices connected to the i2c bus.
Signed-off-by: John Bonesio <bones@secretlab.ca>
Acked-by: Grant Likely <grant.likely@secretlab.ca>
Acked-by: OIof Johansson <olof@lixom.net>
Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/busses/i2c-tegra.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers/i2c/busses/i2c-tegra.c b/drivers/i2c/busses/i2c-tegra.c index fb3b4f8f8152..2440b7411978 100644 --- a/drivers/i2c/busses/i2c-tegra.c +++ b/drivers/i2c/busses/i2c-tegra.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/delay.h> | 26 | #include <linux/delay.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/i2c-tegra.h> | 28 | #include <linux/i2c-tegra.h> |
29 | #include <linux/of_i2c.h> | ||
29 | 30 | ||
30 | #include <asm/unaligned.h> | 31 | #include <asm/unaligned.h> |
31 | 32 | ||
@@ -546,6 +547,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) | |||
546 | struct resource *iomem; | 547 | struct resource *iomem; |
547 | struct clk *clk; | 548 | struct clk *clk; |
548 | struct clk *i2c_clk; | 549 | struct clk *i2c_clk; |
550 | const unsigned int *prop; | ||
549 | void *base; | 551 | void *base; |
550 | int irq; | 552 | int irq; |
551 | int ret = 0; | 553 | int ret = 0; |
@@ -603,7 +605,17 @@ static int tegra_i2c_probe(struct platform_device *pdev) | |||
603 | i2c_dev->irq = irq; | 605 | i2c_dev->irq = irq; |
604 | i2c_dev->cont_id = pdev->id; | 606 | i2c_dev->cont_id = pdev->id; |
605 | i2c_dev->dev = &pdev->dev; | 607 | i2c_dev->dev = &pdev->dev; |
606 | i2c_dev->bus_clk_rate = pdata ? pdata->bus_clk_rate : 100000; | 608 | |
609 | i2c_dev->bus_clk_rate = 100000; /* default clock rate */ | ||
610 | if (pdata) { | ||
611 | i2c_dev->bus_clk_rate = pdata->bus_clk_rate; | ||
612 | |||
613 | } else if (i2c_dev->dev->of_node) { /* if there is a device tree node ... */ | ||
614 | prop = of_get_property(i2c_dev->dev->of_node, | ||
615 | "clock-frequency", NULL); | ||
616 | if (prop) | ||
617 | i2c_dev->bus_clk_rate = be32_to_cpup(prop); | ||
618 | } | ||
607 | 619 | ||
608 | if (pdev->id == 3) | 620 | if (pdev->id == 3) |
609 | i2c_dev->is_dvc = 1; | 621 | i2c_dev->is_dvc = 1; |
@@ -633,6 +645,7 @@ static int tegra_i2c_probe(struct platform_device *pdev) | |||
633 | i2c_dev->adapter.algo = &tegra_i2c_algo; | 645 | i2c_dev->adapter.algo = &tegra_i2c_algo; |
634 | i2c_dev->adapter.dev.parent = &pdev->dev; | 646 | i2c_dev->adapter.dev.parent = &pdev->dev; |
635 | i2c_dev->adapter.nr = pdev->id; | 647 | i2c_dev->adapter.nr = pdev->id; |
648 | i2c_dev->adapter.dev.of_node = pdev->dev.of_node; | ||
636 | 649 | ||
637 | ret = i2c_add_numbered_adapter(&i2c_dev->adapter); | 650 | ret = i2c_add_numbered_adapter(&i2c_dev->adapter); |
638 | if (ret) { | 651 | if (ret) { |
@@ -640,6 +653,8 @@ static int tegra_i2c_probe(struct platform_device *pdev) | |||
640 | goto err_free_irq; | 653 | goto err_free_irq; |
641 | } | 654 | } |
642 | 655 | ||
656 | of_i2c_register_devices(&i2c_dev->adapter); | ||
657 | |||
643 | return 0; | 658 | return 0; |
644 | err_free_irq: | 659 | err_free_irq: |
645 | free_irq(i2c_dev->irq, i2c_dev); | 660 | free_irq(i2c_dev->irq, i2c_dev); |