mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 10:00:17 +00:00
The BCM2835 I2C blocks have a register to set the clock-stretch timeout - how long the device is allowed to hold SCL low - in bus cycles. The current driver doesn't write to the register, therefore the default value of 64 cycles is being used for all devices. Set the timeout to the value recommended for SMBus - 35ms. See: https://github.com/raspberrypi/linux/issues/3064 Signed-off-by: Phil Elwell <phil@raspberrypi.org> i2c: bcm2835: Make clock-stretch timeout configurable The default clock-stretch timeout is 35 mS, which works well for SMBus, but there are some I2C devices which can stretch the clock even longer. Rather than trying to prescribe a safe default for everyone, allow the timeout to be configured. Signed-off-by: Alex Crawford <raspberrypi/linux@code.acrawford.com> i2c-bcm2835: Flush FIFOs cleanly on error On error condition, note the error return code, but still handle the FIFOs in the normal way rather than relying on C_CLEAR flushing everything cleanly. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com> i2c-bcm2835: Do not abort transfers on ERR if still active If a transaction is aborted immediately on ERR being reported, then the bus is not returned to the STOP condition, and devices generally get very upset. Handle the ERR and CLKT conditions only when TA is not set. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com> i2c-bcm2835: Implement I2C_M_IGNORE_NAK Now that transfers aren't aborted immediately (and uncleanly) on errors, and the FIFOs are always drained after all transfers, we can implement I2C_M_IGNORE_NAK by ignoring the returned error value. Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>