i2c: i2c-sh_mobile: support I2C hardware block with a faster operating clock
authorShinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Wed, 24 Oct 2012 10:58:10 +0000 (19:58 +0900)
committerWolfram Sang <w.sang@pengutronix.de>
Fri, 16 Nov 2012 08:09:12 +0000 (09:09 +0100)
On newer SH-/R-Mobile SoCs, a clock supply to the I2C hardware block,
which is used to generate the SCL clock output, is getting faster than
before, while on the other hand, the SCL clock control registers, ICCH
and ICCL, stay unchanged in 9-bit-wide (8+1).

On such silicons, the internal SCL clock counter gets incremented every
2 clocks of the operating clock.

This patch makes it configurable through platform data.

Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Wolfram Sang <w.sang@pengutronix.de>
drivers/i2c/busses/i2c-sh_mobile.c
include/linux/i2c/i2c-sh_mobile.h

index 4dc0cc3611c2b3f1a3913a9d1f9955fab3b335f1..4c283583bea0cdbcc10ed7e3af9fde5cfeec71d9 100644 (file)
@@ -120,6 +120,7 @@ struct sh_mobile_i2c_data {
        void __iomem *reg;
        struct i2c_adapter adap;
        unsigned long bus_speed;
+       unsigned int clks_per_count;
        struct clk *clk;
        u_int8_t icic;
        u_int8_t flags;
@@ -231,6 +232,7 @@ static void sh_mobile_i2c_init(struct sh_mobile_i2c_data *pd)
        /* Get clock rate after clock is enabled */
        clk_enable(pd->clk);
        i2c_clk_khz = clk_get_rate(pd->clk) / 1000;
+       i2c_clk_khz /= pd->clks_per_count;
 
        if (pd->bus_speed == STANDARD_MODE) {
                tLOW    = 47;   /* tLOW = 4.7 us */
@@ -658,6 +660,9 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
        pd->bus_speed = STANDARD_MODE;
        if (pdata && pdata->bus_speed)
                pd->bus_speed = pdata->bus_speed;
+       pd->clks_per_count = 1;
+       if (pdata && pdata->clks_per_count)
+               pd->clks_per_count = pdata->clks_per_count;
 
        /* The IIC blocks on SH-Mobile ARM processors
         * come with two new bits in ICIC.
index beda7081aead57cb59493e75d5d5b11ab5d6b6df..06e3089795fbeee22572c0897f5a35fdfa2f86bf 100644 (file)
@@ -5,6 +5,7 @@
 
 struct i2c_sh_mobile_platform_data {
        unsigned long bus_speed;
+       unsigned int clks_per_count;
 };
 
 #endif /* __I2C_SH_MOBILE_H__ */
This page took 0.027026 seconds and 5 git commands to generate.