Skip to content

Commit fd66bd7

Browse files
qnguyen-amperewsakernel
authored andcommitted
i2c: aspeed: Assert NAK when slave is busy
On I2C_SLAVE_WRITE_REQUESTED event, Slave already ACK'ed on the address phase. But as the backend driver is busy and unable to process any request from Master, issue RxCmdLast for Slave to auto send NACK on next incoming byte. Signed-off-by: Quan Nguyen <[email protected]> Signed-off-by: Wolfram Sang <[email protected]>
1 parent 301c8f5 commit fd66bd7

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/i2c/busses/i2c-aspeed.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
244244
u32 command, irq_handled = 0;
245245
struct i2c_client *slave = bus->slave;
246246
u8 value;
247+
int ret;
247248

248249
if (!slave)
249250
return 0;
@@ -311,7 +312,13 @@ static u32 aspeed_i2c_slave_irq(struct aspeed_i2c_bus *bus, u32 irq_status)
311312
break;
312313
case ASPEED_I2C_SLAVE_WRITE_REQUESTED:
313314
bus->slave_state = ASPEED_I2C_SLAVE_WRITE_RECEIVED;
314-
i2c_slave_event(slave, I2C_SLAVE_WRITE_REQUESTED, &value);
315+
ret = i2c_slave_event(slave, I2C_SLAVE_WRITE_REQUESTED, &value);
316+
/*
317+
* Slave ACK's on this address phase already but as the backend driver
318+
* returns an errno, the bus driver should nack the next incoming byte.
319+
*/
320+
if (ret < 0)
321+
writel(ASPEED_I2CD_M_S_RX_CMD_LAST, bus->base + ASPEED_I2C_CMD_REG);
315322
break;
316323
case ASPEED_I2C_SLAVE_WRITE_RECEIVED:
317324
i2c_slave_event(slave, I2C_SLAVE_WRITE_RECEIVED, &value);

0 commit comments

Comments
 (0)