1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

i2c: aspeed: Reset the i2c controller when timeout occurs

Reset the i2c controller when an i2c transfer timeout occurs.
The remaining interrupts and device should be reset to avoid
unpredictable controller behavior.

Fixes: 2e57b7cebb ("i2c: aspeed: Add multi-master use case support")
Cc: <stable@vger.kernel.org> # v5.1+
Signed-off-by: Tommy Huang <tommy_huang@aspeedtech.com>
Reviewed-by: Andi Shyti <andi.shyti@kernel.org>
Signed-off-by: Wolfram Sang <wsa@kernel.org>
This commit is contained in:
Tommy Huang 2023-09-06 08:49:10 +08:00 committed by Wolfram Sang
parent b2cacc2e81
commit fee465150b

View file

@ -698,13 +698,16 @@ static int aspeed_i2c_master_xfer(struct i2c_adapter *adap,
if (time_left == 0) { if (time_left == 0) {
/* /*
* If timed out and bus is still busy in a multi master * In a multi-master setup, if a timeout occurs, attempt
* environment, attempt recovery at here. * recovery. But if the bus is idle, we still need to reset the
* i2c controller to clear the remaining interrupts.
*/ */
if (bus->multi_master && if (bus->multi_master &&
(readl(bus->base + ASPEED_I2C_CMD_REG) & (readl(bus->base + ASPEED_I2C_CMD_REG) &
ASPEED_I2CD_BUS_BUSY_STS)) ASPEED_I2CD_BUS_BUSY_STS))
aspeed_i2c_recover_bus(bus); aspeed_i2c_recover_bus(bus);
else
aspeed_i2c_reset(bus);
/* /*
* If timed out and the state is still pending, drop the pending * If timed out and the state is still pending, drop the pending