]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
i2c: algo-bit: init the bus to a known state
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Mon, 4 Dec 2017 08:16:18 +0000 (09:16 +0100)
committerWolfram Sang <wsa@the-dreams.de>
Sat, 30 Dec 2017 23:16:37 +0000 (00:16 +0100)
Ensure the bus is free when we register the adapter. Before the SCL/SDA
wires were in an unknown state. It used to work because sending a byte
has a retry mechanism which was triggered if the bus was initially in a
non-free state. But the graceful way to do it is to initialize
correctly.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/algos/i2c-algo-bit.c

index 1147bddb8b2c8a877e04a24a4f35acf8cb69ae2b..3df0efd69ae336035c8f6994ef3230f6cff920f6 100644 (file)
@@ -649,6 +649,11 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap,
        if (bit_adap->getscl == NULL)
                adap->quirks = &i2c_bit_quirk_no_clk_stretch;
 
+       /* Bring bus to a known state. Looks like STOP if bus is not free yet */
+       setscl(bit_adap, 1);
+       udelay(bit_adap->udelay);
+       setsda(bit_adap, 1);
+
        ret = add_adapter(adap);
        if (ret < 0)
                return ret;