Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Magnus Damm and committed by
Ben Dooks
81f81153 1082d5d2

+21 -2
+11 -2
drivers/i2c/busses/i2c-sh_mobile.c
··· 32 32 #include <linux/clk.h> 33 33 #include <linux/io.h> 34 34 #include <linux/slab.h> 35 + #include <linux/i2c/i2c-sh_mobile.h> 35 36 36 37 /* Transmit operation: */ 37 38 /* */ ··· 118 117 struct device *dev; 119 118 void __iomem *reg; 120 119 struct i2c_adapter adap; 121 - 120 + unsigned long bus_speed; 122 121 struct clk *clk; 123 122 u_int8_t icic; 124 123 u_int8_t iccl; ··· 206 205 * We also round off the result. 207 206 */ 208 207 num = i2c_clk * 5; 209 - denom = NORMAL_SPEED * 9; 208 + denom = pd->bus_speed * 9; 210 209 tmp = num * 10 / denom; 211 210 if (tmp % 10 >= 5) 212 211 pd->iccl = (u_int8_t)((num/denom) + 1); ··· 575 574 576 575 static int sh_mobile_i2c_probe(struct platform_device *dev) 577 576 { 577 + struct i2c_sh_mobile_platform_data *pdata = dev->dev.platform_data; 578 578 struct sh_mobile_i2c_data *pd; 579 579 struct i2c_adapter *adap; 580 580 struct resource *res; ··· 620 618 goto err_irq; 621 619 } 622 620 621 + /* Use platformd data bus speed or NORMAL_SPEED */ 622 + pd->bus_speed = NORMAL_SPEED; 623 + if (pdata && pdata->bus_speed) 624 + pd->bus_speed = pdata->bus_speed; 625 + 623 626 /* The IIC blocks on SH-Mobile ARM processors 624 627 * come with two new bits in ICIC. 625 628 */ ··· 665 658 goto err_all; 666 659 } 667 660 661 + dev_info(&dev->dev, "I2C adapter %d with bus speed %lu Hz\n", 662 + adap->nr, pd->bus_speed); 668 663 return 0; 669 664 670 665 err_all:
+10
include/linux/i2c/i2c-sh_mobile.h
··· 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__ */