Skip to content

Commit 3e5f06b

Browse files
Wolfram SangWolfram Sang
authored andcommitted
i2c: algo-bit: init the bus to a known state
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>
1 parent e535376 commit 3e5f06b

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎drivers/i2c/algos/i2c-algo-bit.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,11 @@ static int __i2c_bit_add_bus(struct i2c_adapter *adap,
649649
if (bit_adap->getscl == NULL)
650650
adap->quirks = &i2c_bit_quirk_no_clk_stretch;
651651

652+
/* Bring bus to a known state. Looks like STOP if bus is not free yet */
653+
setscl(bit_adap, 1);
654+
udelay(bit_adap->udelay);
655+
setsda(bit_adap, 1);
656+
652657
ret = add_adapter(adap);
653658
if (ret < 0)
654659
return ret;

0 commit comments

Comments
 (0)