Skip to content

Commit 9495b9b

Browse files
anholtwsakernel
authored andcommitted
i2c: bcm2835: Avoid clock stretching timeouts
The CLKT register contains at poweron 0x40, which at our typical 100kHz bus rate means .64ms. But there is no specified limit to how long devices should be able to stretch the clocks, so just disable the timeout. We still have a timeout wrapping the entire transfer. Signed-off-by: Eric Anholt <eric@anholt.net> Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> BugLink: raspberrypi/linux#3064 Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent e783362 commit 9495b9b

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

drivers/i2c/busses/i2c-bcm2835.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
#define BCM2835_I2C_FIFO 0x10
2424
#define BCM2835_I2C_DIV 0x14
2525
#define BCM2835_I2C_DEL 0x18
26+
/*
27+
* 16-bit field for the number of SCL cycles to wait after rising SCL
28+
* before deciding the slave is not responding. 0 disables the
29+
* timeout detection.
30+
*/
2631
#define BCM2835_I2C_CLKT 0x1c
2732

2833
#define BCM2835_I2C_C_READ BIT(0)
@@ -474,6 +479,12 @@ static int bcm2835_i2c_probe(struct platform_device *pdev)
474479
adap->dev.of_node = pdev->dev.of_node;
475480
adap->quirks = of_device_get_match_data(&pdev->dev);
476481

482+
/*
483+
* Disable the hardware clock stretching timeout. SMBUS
484+
* specifies a limit for how long the device can stretch the
485+
* clock, but core I2C doesn't.
486+
*/
487+
bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_CLKT, 0);
477488
bcm2835_i2c_writel(i2c_dev, BCM2835_I2C_C, 0);
478489

479490
ret = i2c_add_adapter(adap);

0 commit comments

Comments
 (0)