diff options
-rw-r--r-- | drivers/i2c/busses/i2c-sh_mobile.c | 13 | ||||
-rw-r--r-- | include/linux/i2c/i2c-sh_mobile.h | 10 |
2 files changed, 21 insertions, 2 deletions
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c index 5a1d37d0b62f..d917dd1cc091 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 | ||
575 | static int sh_mobile_i2c_probe(struct platform_device *dev) | 576 | static 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: |
diff --git a/include/linux/i2c/i2c-sh_mobile.h b/include/linux/i2c/i2c-sh_mobile.h new file mode 100644 index 000000000000..beda7081aead --- /dev/null +++ b/include/linux/i2c/i2c-sh_mobile.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef __I2C_SH_MOBILE_H__ | ||
2 | #define __I2C_SH_MOBILE_H__ | ||
3 | |||
4 | #include <linux/platform_device.h> | ||
5 | |||
6 | struct i2c_sh_mobile_platform_data { | ||
7 | unsigned long bus_speed; | ||
8 | }; | ||
9 | |||
10 | #endif /* __I2C_SH_MOBILE_H__ */ | ||