aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/i2c
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2011-04-28 00:25:36 -0400
committerBen Dooks <ben-linux@fluff.org>2011-05-11 02:08:13 -0400
commit81f8115305f821335cf9e16110bf0806f7b93283 (patch)
tree99353fbf61b57769b52cadb47c30ae6f3fb88479 /drivers/i2c
parent1082d5d29d9a71f43b969b89ce613374602a6946 (diff)
i2c: i2c-sh_mobile bus speed platform data V2
Add support to the i2c-sh_mobile driver for setting the I2C bus speed using platform data. Signed-off-by: Magnus Damm <damm@opensource.se> Signed-off-by: Ben Dooks <ben-linux@fluff.org>
Diffstat (limited to 'drivers/i2c')
-rw-r--r--drivers/i2c/busses/i2c-sh_mobile.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index 5a1d37d0b62..d917dd1cc09 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,6 +575,7 @@ 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;
@@ -618,6 +620,11 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
618 goto err_irq; 620 goto err_irq;
619 } 621 }
620 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
621 /* The IIC blocks on SH-Mobile ARM processors 628 /* The IIC blocks on SH-Mobile ARM processors
622 * come with two new bits in ICIC. 629 * come with two new bits in ICIC.
623 */ 630 */
@@ -658,6 +665,8 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
658 goto err_all; 665 goto err_all;
659 } 666 }
660 667
668 dev_info(&dev->dev, "I2C adapter %d with bus speed %lu Hz\n",
669 adap->nr, pd->bus_speed);
661 return 0; 670 return 0;
662 671
663 err_all: 672 err_all: