i2c: davinci: Avoid zero value of CLKH
authorAlexander Sverdlin <alexander.sverdlin@nokia.com>
Fri, 13 Jul 2018 15:20:17 +0000 (17:20 +0200)
committerWolfram Sang <wsa@the-dreams.de>
Mon, 23 Jul 2018 18:04:35 +0000 (20:04 +0200)
If CLKH is set to 0 I2C clock is not generated at all, so avoid this value
and stretch the clock in this case.

Signed-off-by: Alexander Sverdlin <alexander.sverdlin@nokia.com>
Acked-by: Sekhar Nori <nsekhar@ti.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/busses/i2c-davinci.c

index 75d6ab177055efa2119635eb56845388ac3a0848..7379043711dfa89455abd65bce74ac08707073f9 100644 (file)
@@ -237,12 +237,16 @@ static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
        /*
         * It's not always possible to have 1 to 2 ratio when d=7, so fall back
         * to minimal possible clkh in this case.
+        *
+        * Note:
+        * CLKH is not allowed to be 0, in this case I2C clock is not generated
+        * at all
         */
-       if (clk >= clkl + d) {
+       if (clk > clkl + d) {
                clkh = clk - clkl - d;
                clkl -= d;
        } else {
-               clkh = 0;
+               clkh = 1;
                clkl = clk - (d << 1);
        }