aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorWolfram Sang <wsa+renesas@sang-engineering.com>2014-05-02 15:15:16 -0400
committerWolfram Sang <wsa@the-dreams.de>2014-05-22 04:09:25 -0400
commit67240dfcb8dcf756cc00fb37f5cb7e3ee2fa6190 (patch)
tree998fac70bb3516601d0492e6468f30bb4bfb75ed /drivers/i2c
parent7663ebefca8079ef0fd2fff1047d3d10af654c78 (diff)
i2c: sh_mobile: fix clock calculation for newer SoCs
Newer SoCs have so fast input clocks that the ICCL/H registers only count every second clock to have a meaningful 9-bit range. The driver was already prepared for that happening, but didn't use it so far. Add the proper DT configuration for SoCs that need it. Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index b1d399e3e5fc..c29be2bba6ea 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -32,6 +32,7 @@
32#include <linux/clk.h> 32#include <linux/clk.h>
33#include <linux/io.h> 33#include <linux/io.h>
34#include <linux/slab.h> 34#include <linux/slab.h>
35#include <linux/of_device.h>
35#include <linux/i2c/i2c-sh_mobile.h> 36#include <linux/i2c/i2c-sh_mobile.h>
36 37
37/* Transmit operation: */ 38/* Transmit operation: */
@@ -139,6 +140,10 @@ struct sh_mobile_i2c_data {
139 bool send_stop; 140 bool send_stop;
140}; 141};
141 142
143struct sh_mobile_dt_config {
144 int clks_per_count;
145};
146
142#define IIC_FLAG_HAS_ICIC67 (1 << 0) 147#define IIC_FLAG_HAS_ICIC67 (1 << 0)
143 148
144#define STANDARD_MODE 100000 149#define STANDARD_MODE 100000
@@ -617,6 +622,22 @@ static struct i2c_algorithm sh_mobile_i2c_algorithm = {
617 .master_xfer = sh_mobile_i2c_xfer, 622 .master_xfer = sh_mobile_i2c_xfer,
618}; 623};
619 624
625static const struct sh_mobile_dt_config default_dt_config = {
626 .clks_per_count = 1,
627};
628
629static const struct sh_mobile_dt_config rcar_gen2_dt_config = {
630 .clks_per_count = 2,
631};
632
633static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
634 { .compatible = "renesas,rmobile-iic", .data = &default_dt_config },
635 { .compatible = "renesas,iic-r8a7790", .data = &rcar_gen2_dt_config },
636 { .compatible = "renesas,iic-r8a7791", .data = &rcar_gen2_dt_config },
637 {},
638};
639MODULE_DEVICE_TABLE(of, sh_mobile_i2c_dt_ids);
640
620static int sh_mobile_i2c_hook_irqs(struct platform_device *dev) 641static int sh_mobile_i2c_hook_irqs(struct platform_device *dev)
621{ 642{
622 struct resource *res; 643 struct resource *res;
@@ -674,11 +695,24 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
674 ret = of_property_read_u32(dev->dev.of_node, "clock-frequency", &bus_speed); 695 ret = of_property_read_u32(dev->dev.of_node, "clock-frequency", &bus_speed);
675 pd->bus_speed = ret ? STANDARD_MODE : bus_speed; 696 pd->bus_speed = ret ? STANDARD_MODE : bus_speed;
676 697
677 if (pdata && pdata->bus_speed)
678 pd->bus_speed = pdata->bus_speed;
679 pd->clks_per_count = 1; 698 pd->clks_per_count = 1;
680 if (pdata && pdata->clks_per_count) 699
681 pd->clks_per_count = pdata->clks_per_count; 700 if (dev->dev.of_node) {
701 const struct of_device_id *match;
702
703 match = of_match_device(sh_mobile_i2c_dt_ids, &dev->dev);
704 if (match) {
705 const struct sh_mobile_dt_config *config;
706
707 config = match->data;
708 pd->clks_per_count = config->clks_per_count;
709 }
710 } else {
711 if (pdata && pdata->bus_speed)
712 pd->bus_speed = pdata->bus_speed;
713 if (pdata && pdata->clks_per_count)
714 pd->clks_per_count = pdata->clks_per_count;
715 }
682 716
683 /* The IIC blocks on SH-Mobile ARM processors 717 /* The IIC blocks on SH-Mobile ARM processors
684 * come with two new bits in ICIC. 718 * come with two new bits in ICIC.
@@ -758,12 +792,6 @@ static const struct dev_pm_ops sh_mobile_i2c_dev_pm_ops = {
758 .runtime_resume = sh_mobile_i2c_runtime_nop, 792 .runtime_resume = sh_mobile_i2c_runtime_nop,
759}; 793};
760 794
761static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
762 { .compatible = "renesas,rmobile-iic", },
763 {},
764};
765MODULE_DEVICE_TABLE(of, sh_mobile_i2c_dt_ids);
766
767static struct platform_driver sh_mobile_i2c_driver = { 795static struct platform_driver sh_mobile_i2c_driver = {
768 .driver = { 796 .driver = {
769 .name = "i2c-sh_mobile", 797 .name = "i2c-sh_mobile",