Commit d7aa1b14 authored by Tali Perry's avatar Tali Perry Committed by Wolfram Sang

i2c: npcm: Correct slave role behavior

Correct the slave transaction logic to be compatible with the generic
slave backend driver.

Fixes: 56a1485b ("i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver")
Signed-off-by: default avatarTali Perry <tali.perry1@gmail.com>
Signed-off-by: default avatarTyrone Ting <kfting@nuvoton.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarWolfram Sang <wsa@kernel.org>
parent 47d506d1
...@@ -915,11 +915,15 @@ static int npcm_i2c_slave_get_wr_buf(struct npcm_i2c *bus) ...@@ -915,11 +915,15 @@ static int npcm_i2c_slave_get_wr_buf(struct npcm_i2c *bus)
for (i = 0; i < I2C_HW_FIFO_SIZE; i++) { for (i = 0; i < I2C_HW_FIFO_SIZE; i++) {
if (bus->slv_wr_size >= I2C_HW_FIFO_SIZE) if (bus->slv_wr_size >= I2C_HW_FIFO_SIZE)
break; break;
i2c_slave_event(bus->slave, I2C_SLAVE_READ_REQUESTED, &value); if (bus->state == I2C_SLAVE_MATCH) {
i2c_slave_event(bus->slave, I2C_SLAVE_READ_REQUESTED, &value);
bus->state = I2C_OPER_STARTED;
} else {
i2c_slave_event(bus->slave, I2C_SLAVE_READ_PROCESSED, &value);
}
ind = (bus->slv_wr_ind + bus->slv_wr_size) % I2C_HW_FIFO_SIZE; ind = (bus->slv_wr_ind + bus->slv_wr_size) % I2C_HW_FIFO_SIZE;
bus->slv_wr_buf[ind] = value; bus->slv_wr_buf[ind] = value;
bus->slv_wr_size++; bus->slv_wr_size++;
i2c_slave_event(bus->slave, I2C_SLAVE_READ_PROCESSED, &value);
} }
return I2C_HW_FIFO_SIZE - ret; return I2C_HW_FIFO_SIZE - ret;
} }
...@@ -967,7 +971,6 @@ static void npcm_i2c_slave_xmit(struct npcm_i2c *bus, u16 nwrite, ...@@ -967,7 +971,6 @@ static void npcm_i2c_slave_xmit(struct npcm_i2c *bus, u16 nwrite,
if (nwrite == 0) if (nwrite == 0)
return; return;
bus->state = I2C_OPER_STARTED;
bus->operation = I2C_WRITE_OPER; bus->operation = I2C_WRITE_OPER;
/* get the next buffer */ /* get the next buffer */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment