diff options
| -rw-r--r-- | drivers/i2c/busses/i2c-rcar.c | 10 | ||||
| -rw-r--r-- | drivers/i2c/i2c-slave-eeprom.c | 12 | ||||
| -rw-r--r-- | include/linux/i2c.h | 8 |
3 files changed, 14 insertions, 16 deletions
diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c index 71a6e07eb7ab..5a84bea5b845 100644 --- a/drivers/i2c/busses/i2c-rcar.c +++ b/drivers/i2c/busses/i2c-rcar.c | |||
| @@ -382,11 +382,11 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv) | |||
| 382 | if (ssr_filtered & SAR) { | 382 | if (ssr_filtered & SAR) { |
| 383 | /* read or write request */ | 383 | /* read or write request */ |
| 384 | if (ssr_raw & STM) { | 384 | if (ssr_raw & STM) { |
| 385 | i2c_slave_event(priv->slave, I2C_SLAVE_REQ_READ_START, &value); | 385 | i2c_slave_event(priv->slave, I2C_SLAVE_READ_REQUESTED, &value); |
| 386 | rcar_i2c_write(priv, ICRXTX, value); | 386 | rcar_i2c_write(priv, ICRXTX, value); |
| 387 | rcar_i2c_write(priv, ICSIER, SDE | SSR | SAR); | 387 | rcar_i2c_write(priv, ICSIER, SDE | SSR | SAR); |
| 388 | } else { | 388 | } else { |
| 389 | i2c_slave_event(priv->slave, I2C_SLAVE_REQ_WRITE_START, &value); | 389 | i2c_slave_event(priv->slave, I2C_SLAVE_WRITE_REQUESTED, &value); |
| 390 | rcar_i2c_read(priv, ICRXTX); /* dummy read */ | 390 | rcar_i2c_read(priv, ICRXTX); /* dummy read */ |
| 391 | rcar_i2c_write(priv, ICSIER, SDR | SSR | SAR); | 391 | rcar_i2c_write(priv, ICSIER, SDR | SSR | SAR); |
| 392 | } | 392 | } |
| @@ -406,17 +406,15 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv) | |||
| 406 | int ret; | 406 | int ret; |
| 407 | 407 | ||
| 408 | value = rcar_i2c_read(priv, ICRXTX); | 408 | value = rcar_i2c_read(priv, ICRXTX); |
| 409 | ret = i2c_slave_event(priv->slave, I2C_SLAVE_REQ_WRITE_END, &value); | 409 | ret = i2c_slave_event(priv->slave, I2C_SLAVE_WRITE_RECEIVED, &value); |
| 410 | /* Send NACK in case of error */ | 410 | /* Send NACK in case of error */ |
| 411 | rcar_i2c_write(priv, ICSCR, SIE | SDBS | (ret < 0 ? FNA : 0)); | 411 | rcar_i2c_write(priv, ICSCR, SIE | SDBS | (ret < 0 ? FNA : 0)); |
| 412 | i2c_slave_event(priv->slave, I2C_SLAVE_REQ_WRITE_START, &value); | ||
| 413 | rcar_i2c_write(priv, ICSSR, ~SDR & 0xff); | 412 | rcar_i2c_write(priv, ICSSR, ~SDR & 0xff); |
| 414 | } | 413 | } |
| 415 | 414 | ||
| 416 | /* master wants to read from us */ | 415 | /* master wants to read from us */ |
| 417 | if (ssr_filtered & SDE) { | 416 | if (ssr_filtered & SDE) { |
| 418 | i2c_slave_event(priv->slave, I2C_SLAVE_REQ_READ_END, &value); | 417 | i2c_slave_event(priv->slave, I2C_SLAVE_READ_PROCESSED, &value); |
| 419 | i2c_slave_event(priv->slave, I2C_SLAVE_REQ_READ_START, &value); | ||
| 420 | rcar_i2c_write(priv, ICRXTX, value); | 418 | rcar_i2c_write(priv, ICRXTX, value); |
| 421 | rcar_i2c_write(priv, ICSSR, ~SDE & 0xff); | 419 | rcar_i2c_write(priv, ICSSR, ~SDE & 0xff); |
| 422 | } | 420 | } |
diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c index cf9b09db092f..3fb45d894d80 100644 --- a/drivers/i2c/i2c-slave-eeprom.c +++ b/drivers/i2c/i2c-slave-eeprom.c | |||
| @@ -36,7 +36,7 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client, | |||
| 36 | struct eeprom_data *eeprom = i2c_get_clientdata(client); | 36 | struct eeprom_data *eeprom = i2c_get_clientdata(client); |
| 37 | 37 | ||
| 38 | switch (event) { | 38 | switch (event) { |
| 39 | case I2C_SLAVE_REQ_WRITE_END: | 39 | case I2C_SLAVE_WRITE_RECEIVED: |
| 40 | if (eeprom->first_write) { | 40 | if (eeprom->first_write) { |
| 41 | eeprom->buffer_idx = *val; | 41 | eeprom->buffer_idx = *val; |
| 42 | eeprom->first_write = false; | 42 | eeprom->first_write = false; |
| @@ -47,17 +47,17 @@ static int i2c_slave_eeprom_slave_cb(struct i2c_client *client, | |||
| 47 | } | 47 | } |
| 48 | break; | 48 | break; |
| 49 | 49 | ||
| 50 | case I2C_SLAVE_REQ_READ_START: | 50 | case I2C_SLAVE_READ_PROCESSED: |
| 51 | eeprom->buffer_idx++; | ||
| 52 | /* fallthrough */ | ||
| 53 | case I2C_SLAVE_READ_REQUESTED: | ||
| 51 | spin_lock(&eeprom->buffer_lock); | 54 | spin_lock(&eeprom->buffer_lock); |
| 52 | *val = eeprom->buffer[eeprom->buffer_idx]; | 55 | *val = eeprom->buffer[eeprom->buffer_idx]; |
| 53 | spin_unlock(&eeprom->buffer_lock); | 56 | spin_unlock(&eeprom->buffer_lock); |
| 54 | break; | 57 | break; |
| 55 | 58 | ||
| 56 | case I2C_SLAVE_REQ_READ_END: | ||
| 57 | eeprom->buffer_idx++; | ||
| 58 | break; | ||
| 59 | |||
| 60 | case I2C_SLAVE_STOP: | 59 | case I2C_SLAVE_STOP: |
| 60 | case I2C_SLAVE_WRITE_REQUESTED: | ||
| 61 | eeprom->first_write = true; | 61 | eeprom->first_write = true; |
| 62 | break; | 62 | break; |
| 63 | 63 | ||
diff --git a/include/linux/i2c.h b/include/linux/i2c.h index 243d1a1d78b2..c5e4bb2c5759 100644 --- a/include/linux/i2c.h +++ b/include/linux/i2c.h | |||
| @@ -253,10 +253,10 @@ static inline void i2c_set_clientdata(struct i2c_client *dev, void *data) | |||
| 253 | 253 | ||
| 254 | #if IS_ENABLED(CONFIG_I2C_SLAVE) | 254 | #if IS_ENABLED(CONFIG_I2C_SLAVE) |
| 255 | enum i2c_slave_event { | 255 | enum i2c_slave_event { |
| 256 | I2C_SLAVE_REQ_READ_START, | 256 | I2C_SLAVE_READ_REQUESTED, |
| 257 | I2C_SLAVE_REQ_READ_END, | 257 | I2C_SLAVE_WRITE_REQUESTED, |
| 258 | I2C_SLAVE_REQ_WRITE_START, | 258 | I2C_SLAVE_READ_PROCESSED, |
| 259 | I2C_SLAVE_REQ_WRITE_END, | 259 | I2C_SLAVE_WRITE_RECEIVED, |
| 260 | I2C_SLAVE_STOP, | 260 | I2C_SLAVE_STOP, |
| 261 | }; | 261 | }; |
| 262 | 262 | ||
