aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCédric Le Goater <clg@kaod.org>2017-06-02 11:51:49 +0100
committerPeter Maydell <peter.maydell@linaro.org>2017-06-02 11:51:49 +0100
commitd0efdc1686405c3873703a8617daba54d3fbb75f (patch)
tree033b6e7197d9e8ff1908b09d31bed24455126476
parentddabca757a4eb29f342f7f1d01634ccdbe0e3844 (diff)
aspeed/i2c: handle LAST command under the RX command
Today, the LAST command is handled with the STOP command but this is incorrect. Also nack the I2C bus when a LAST is issued. Signed-off-by: Cédric Le Goater <clg@kaod.org> Message-id: 1494827476-1487-3-git-send-email-clg@kaod.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--hw/i2c/aspeed_i2c.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
index 56a4fdf5c5..67004c6753 100644
--- a/hw/i2c/aspeed_i2c.c
+++ b/hw/i2c/aspeed_i2c.c
@@ -203,7 +203,7 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value)
bus->cmd &= ~I2CD_M_TX_CMD;
}
- if (bus->cmd & I2CD_M_RX_CMD) {
+ if (bus->cmd & (I2CD_M_RX_CMD | I2CD_M_S_RX_CMD_LAST)) {
int ret = i2c_recv(bus->bus);
if (ret < 0) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: read failed\n", __func__);
@@ -212,10 +212,13 @@ static void aspeed_i2c_bus_handle_cmd(AspeedI2CBus *bus, uint64_t value)
bus->intr_status |= I2CD_INTR_RX_DONE;
}
bus->buf = (ret & I2CD_BYTE_BUF_RX_MASK) << I2CD_BYTE_BUF_RX_SHIFT;
- bus->cmd &= ~I2CD_M_RX_CMD;
+ if (bus->cmd & I2CD_M_S_RX_CMD_LAST) {
+ i2c_nack(bus->bus);
+ }
+ bus->cmd &= ~(I2CD_M_RX_CMD | I2CD_M_S_RX_CMD_LAST);
}
- if (bus->cmd & (I2CD_M_STOP_CMD | I2CD_M_S_RX_CMD_LAST)) {
+ if (bus->cmd & I2CD_M_STOP_CMD) {
if (!i2c_bus_busy(bus->bus)) {
bus->intr_status |= I2CD_INTR_ABNORMAL;
} else {