[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 11/16] hw/i3c/aspeed_i3c: Add ctrl MMIO handling
From: |
Joe Komlodi |
Subject: |
[PATCH 11/16] hw/i3c/aspeed_i3c: Add ctrl MMIO handling |
Date: |
Fri, 31 Mar 2023 01:01:26 +0000 |
Adds functionality to the CTRL register.
Signed-off-by: Joe Komlodi <komlodi@google.com>
Reviewed-by: Titus Rwantare <titusr@google.com>
Reviewed-by: Patrick Venture <venture@google.com>
---
hw/i3c/aspeed_i3c.c | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/hw/i3c/aspeed_i3c.c b/hw/i3c/aspeed_i3c.c
index 055ad3f7fd..4c0c074012 100644
--- a/hw/i3c/aspeed_i3c.c
+++ b/hw/i3c/aspeed_i3c.c
@@ -340,6 +340,8 @@ REG32(DEVICE_ADDR_TABLE_LOC1, 0x280)
FIELD(DEVICE_ADDR_TABLE_LOC1, DEV_NACK_RETRY_CNT, 29, 2)
FIELD(DEVICE_ADDR_TABLE_LOC1, LEGACY_I2C_DEVICE, 31, 1)
+static void aspeed_i3c_device_cmd_queue_execute(AspeedI3CDevice *s);
+
static const uint32_t ast2600_i3c_controller_ro[ASPEED_I3C_DEVICE_NR_REGS] = {
[R_I3C1_REG0] = 0xfc000000,
[R_I3C1_REG1] = 0xfff00000,
@@ -588,6 +590,37 @@ static int aspeed_i3c_device_recv_data(AspeedI3CDevice *s,
bool is_i2c,
return ret;
}
+static inline void aspeed_i3c_device_ctrl_w(AspeedI3CDevice *s,
+ uint32_t val)
+{
+ /*
+ * If the user is setting I3C_RESUME, the controller was halted.
+ * Try and resume execution and leave the bit cleared.
+ */
+ if (FIELD_EX32(val, DEVICE_CTRL, I3C_RESUME)) {
+ aspeed_i3c_device_cmd_queue_execute(s);
+ val = FIELD_DP32(val, DEVICE_CTRL, I3C_RESUME, 0);
+ }
+ /*
+ * I3C_ABORT being set sends an I3C STOP. It's cleared when the STOP is
+ * sent.
+ */
+ if (FIELD_EX32(val, DEVICE_CTRL, I3C_ABORT)) {
+ aspeed_i3c_device_end_transfer(s, /*is_i2c=*/true);
+ aspeed_i3c_device_end_transfer(s, /*is_i2c=*/false);
+ val = FIELD_DP32(val, DEVICE_CTRL, I3C_ABORT, 0);
+ ARRAY_FIELD_DP32(s->regs, INTR_STATUS, TRANSFER_ABORT, 1);
+ aspeed_i3c_device_update_irq(s);
+ }
+ /* Update present state. */
+ ARRAY_FIELD_DP32(s->regs, PRESENT_STATE, CM_TFR_ST_STATUS,
+ ASPEED_I3C_TRANSFER_STATE_IDLE);
+ ARRAY_FIELD_DP32(s->regs, PRESENT_STATE, CM_TFR_STATUS,
+ ASPEED_I3C_TRANSFER_STATUS_IDLE);
+
+ s->regs[R_DEVICE_CTRL] = val;
+}
+
static inline bool aspeed_i3c_device_target_is_i2c(AspeedI3CDevice *s,
uint16_t offset)
{
@@ -1650,6 +1683,9 @@ static void aspeed_i3c_device_write(void *opaque, hwaddr
offset,
"] = 0x%08" PRIx64 "\n",
__func__, offset, value);
break;
+ case R_DEVICE_CTRL:
+ aspeed_i3c_device_ctrl_w(s, val32);
+ break;
case R_RX_TX_DATA_PORT:
aspeed_i3c_device_push_tx(s, val32);
break;
--
2.40.0.348.gf938b09366-goog
- [PATCH 01/16] hw/misc/aspeed_i3c: Move to i3c directory, (continued)
- [PATCH 01/16] hw/misc/aspeed_i3c: Move to i3c directory, Joe Komlodi, 2023/03/30
- [PATCH 03/16] hw/i3c/aspeed_i3c: Add more register fields, Joe Komlodi, 2023/03/30
- [PATCH 04/16] hw/i3c/aspeed_i3c: Add more reset values, Joe Komlodi, 2023/03/30
- [PATCH 02/16] hw/i3c: Add bus support, Joe Komlodi, 2023/03/30
- [PATCH 05/16] hw/i3c/aspeed_i3c: Add register RO field masks, Joe Komlodi, 2023/03/30
- [PATCH 06/16] hw/i3c/aspeed_i3c: Treat more registers as read-as-zero, Joe Komlodi, 2023/03/30
- [PATCH 07/16] hw/i3c/aspeed_i3c: Use 32 bits on MMIO writes, Joe Komlodi, 2023/03/30
- [PATCH 08/16] hw/i3c/aspeed_i3c: Add IRQ MMIO behavior, Joe Komlodi, 2023/03/30
- [PATCH 09/16] hw/i3c/aspeed_i3c: Add data TX and RX, Joe Komlodi, 2023/03/30
- [PATCH 10/16] hw/i3c/aspeed_i3c: Add IBI handling, Joe Komlodi, 2023/03/30
- [PATCH 11/16] hw/i3c/aspeed_i3c: Add ctrl MMIO handling,
Joe Komlodi <=
- [PATCH 12/16] hw/i3c/aspeed_i3c: Add controller resets, Joe Komlodi, 2023/03/30
- [PATCH 13/16] hw/i3c: Add Mock target, Joe Komlodi, 2023/03/30
- [PATCH 14/16] hw/i3c: remote_i3c: Add model, Joe Komlodi, 2023/03/30
- [PATCH 16/16] hw/i3c: Add hotplug support, Joe Komlodi, 2023/03/30
- [PATCH 15/16] qtest: remote_i3c: Add remote I3C qtest, Joe Komlodi, 2023/03/30