aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c/busses/i2c-sh_mobile.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/i2c/busses/i2c-sh_mobile.c')
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 81ccd787562..f633a53b6db 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/i2c/i2c-sh_mobile.h>
35 36
36/* Transmit operation: */ 37/* Transmit operation: */
37/* */ 38/* */
@@ -117,7 +118,7 @@ struct sh_mobile_i2c_data {
117 struct device *dev; 118 struct device *dev;
118 void __iomem *reg; 119 void __iomem *reg;
119 struct i2c_adapter adap; 120 struct i2c_adapter adap;
120 121 unsigned long bus_speed;
121 struct clk *clk; 122 struct clk *clk;
122 u_int8_t icic; 123 u_int8_t icic;
123 u_int8_t iccl; 124 u_int8_t iccl;
@@ -205,7 +206,7 @@ static void activate_ch(struct sh_mobile_i2c_data *pd)
205 * We also round off the result. 206 * We also round off the result.
206 */ 207 */
207 num = i2c_clk * 5; 208 num = i2c_clk * 5;
208 denom = NORMAL_SPEED * 9; 209 denom = pd->bus_speed * 9;
209 tmp = num * 10 / denom; 210 tmp = num * 10 / denom;
210 if (tmp % 10 >= 5) 211 if (tmp % 10 >= 5)
211 pd->iccl = (u_int8_t)((num/denom) + 1); 212 pd->iccl = (u_int8_t)((num/denom) + 1);
@@ -574,10 +575,10 @@ static int sh_mobile_i2c_hook_irqs(struct platform_device *dev, int hook)
574 575
575static int sh_mobile_i2c_probe(struct platform_device *dev) 576static int sh_mobile_i2c_probe(struct platform_device *dev)
576{ 577{
578 struct i2c_sh_mobile_platform_data *pdata = dev->dev.platform_data;
577 struct sh_mobile_i2c_data *pd; 579 struct sh_mobile_i2c_data *pd;
578 struct i2c_adapter *adap; 580 struct i2c_adapter *adap;
579 struct resource *res; 581 struct resource *res;
580 char clk_name[8];
581 int size; 582 int size;
582 int ret; 583 int ret;
583 584
@@ -587,10 +588,9 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
587 return -ENOMEM; 588 return -ENOMEM;
588 } 589 }
589 590
590 snprintf(clk_name, sizeof(clk_name), "i2c%d", dev->id); 591 pd->clk = clk_get(&dev->dev, NULL);
591 pd->clk = clk_get(&dev->dev, clk_name);
592 if (IS_ERR(pd->clk)) { 592 if (IS_ERR(pd->clk)) {
593 dev_err(&dev->dev, "cannot get clock \"%s\"\n", clk_name); 593 dev_err(&dev->dev, "cannot get clock\n");
594 ret = PTR_ERR(pd->clk); 594 ret = PTR_ERR(pd->clk);
595 goto err; 595 goto err;
596 } 596 }
@@ -620,6 +620,11 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
620 goto err_irq; 620 goto err_irq;
621 } 621 }
622 622
623 /* Use platformd data bus speed or NORMAL_SPEED */
624 pd->bus_speed = NORMAL_SPEED;
625 if (pdata && pdata->bus_speed)
626 pd->bus_speed = pdata->bus_speed;
627
623 /* The IIC blocks on SH-Mobile ARM processors 628 /* The IIC blocks on SH-Mobile ARM processors
624 * come with two new bits in ICIC. 629 * come with two new bits in ICIC.
625 */ 630 */
@@ -660,6 +665,8 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
660 goto err_all; 665 goto err_all;
661 } 666 }
662 667
668 dev_info(&dev->dev, "I2C adapter %d with bus speed %lu Hz\n",
669 adap->nr, pd->bus_speed);
663 return 0; 670 return 0;
664 671
665 err_all: 672 err_all: