[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/6] aspeed/i2c: handle LAST command under the RX co
From: |
Cédric Le Goater |
Subject: |
[Qemu-devel] [PATCH 2/6] aspeed/i2c: handle LAST command under the RX command |
Date: |
Mon, 15 May 2017 07:51:12 +0200 |
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 <address@hidden>
---
hw/i2c/aspeed_i2c.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/hw/i2c/aspeed_i2c.c b/hw/i2c/aspeed_i2c.c
index 56a4fdf5c542..67004c675359 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 {
--
2.7.4
- [Qemu-devel] [PATCH 0/6] aspeed: I2C controller fixes, Cédric Le Goater, 2017/05/15
- [Qemu-devel] [PATCH 2/6] aspeed/i2c: handle LAST command under the RX command,
Cédric Le Goater <=
- [Qemu-devel] [PATCH 3/6] aspeed/i2c: introduce a state machine, Cédric Le Goater, 2017/05/15
- [Qemu-devel] [PATCH 1/6] aspeed/i2c: improve command handling, Cédric Le Goater, 2017/05/15
- [Qemu-devel] [PATCH 4/6] aspeed: add some I2C devices to the Aspeed machines, Cédric Le Goater, 2017/05/15
- [Qemu-devel] [PATCH 5/6] hw/misc: add a TMP42{1,2,3} device model, Cédric Le Goater, 2017/05/15
- [Qemu-devel] [PATCH 6/6] aspeed: add a temp sensor device on I2C bus 3, Cédric Le Goater, 2017/05/15