Skip to contentSkip to conversation

aspeed queue

GIT PULL Cédric Le Goater 2 participants 4 messages Aug 25, 2022 Arm/Aspeed machine support

lore
Share & tools
lore
#0 lore raw

The following changes since commit 9a99f964b152f8095949bbddca7841744ad418da:

Update version for v7.1.0-rc4 release (2022-08-24 19:27:56 -0700)

are available in the Git repository at:

https://github.com/legoater/qemu/ tags/pull-aspeed-20220825

for you to fetch changes up to 7ccff968f65cfad573bc0015cb0ab800d4337a6e:

hw/i2c/aspeed: Fix old reg slave receive (2022-08-25 10:46:42 +0200)

----------------------------------------------------------------
Aspeed queue:

* hw/i2c/aspeed: Fix old reg slave receive

----------------------------------------------------------------
Peter Delevoryas (1):
hw/i2c/aspeed: Fix old reg slave receive

 include/hw/i2c/aspeed_i2c.h | 1 +
 hw/i2c/aspeed_i2c.c         | 8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
#1 lore raw

[PULL for-7.1 1/1] hw/i2c/aspeed: Fix old reg slave receive

From: Peter Delevoryas <[email protected]>

I think when Klaus ported his slave mode changes from the original patch series to the rewritten I2C module, he changed the behavior of the first byte that is received by the slave device.

What's supposed to happen is that the AspeedI2CBus's slave device's i2c_event callback should run, and if the event is "send_async", then it should populate the byte buffer with the 8-bit I2C address that is being sent to. Since we only support "send_async", the lowest bit should always be 0 (indicating that the master is requesting to send data).

This is the code Klaus had previously, for reference. [1]

    switch (event) {
    case I2C_START_SEND:
        bus->buf = bus->dev_addr << 1;

        bus->buf &= I2CD_BYTE_BUF_RX_MASK;
        bus->buf <<= I2CD_BYTE_BUF_RX_SHIFT;

        bus->intr_status |= (I2CD_INTR_SLAVE_ADDR_RX_MATCH | I2CD_INTR_RX_DONE);
        aspeed_i2c_set_state(bus, I2CD_STXD);

        break;

[1]: https://lore.kernel.org/qemu-devel/[email protected]/

Fixes a8d48f59cd021b25 ("hw/i2c/aspeed: add slave device in old register mode")
---
 include/hw/i2c/aspeed_i2c.h | 1 +
 hw/i2c/aspeed_i2c.c         | 8 +++++---
 2 files changed, 6 insertions(+), 3 deletions(-)
include/hw/i2c/aspeed_i2c.h +1 -0
index 300a89b34301..adc904d6c1f8 100644
@@ -130,6 +130,7 @@ REG32(I2CD_CMD, 0x14) /* I2CD Command/Status */
     SHARED_FIELD(M_TX_CMD, 1, 1)
     SHARED_FIELD(M_START_CMD, 0, 1)
 REG32(I2CD_DEV_ADDR, 0x18) /* Slave Device Address */
+    SHARED_FIELD(SLAVE_DEV_ADDR1, 0, 7)
 REG32(I2CD_POOL_CTRL, 0x1C) /* Pool Buffer Control */
     SHARED_FIELD(RX_COUNT, 24, 5)
     SHARED_FIELD(RX_SIZE, 16, 5)
hw/i2c/aspeed_i2c.c +5 -3
index 42c6d69b82f0..c166fd20fa11 100644
@@ -1131,7 +1131,9 @@ static int aspeed_i2c_bus_slave_event(I2CSlave *slave, enum i2c_event event)
     AspeedI2CBus *bus = ASPEED_I2C_BUS(qbus->parent);
     uint32_t reg_intr_sts = aspeed_i2c_bus_intr_sts_offset(bus);
     uint32_t reg_byte_buf = aspeed_i2c_bus_byte_buf_offset(bus);
-    uint32_t value;
+    uint32_t reg_dev_addr = aspeed_i2c_bus_dev_addr_offset(bus);
+    uint32_t dev_addr = SHARED_ARRAY_FIELD_EX32(bus->regs, reg_dev_addr,
+                                                SLAVE_DEV_ADDR1);
 
     if (aspeed_i2c_is_new_mode(bus->controller)) {
         return aspeed_i2c_bus_new_slave_event(bus, event);
@@ -1139,8 +1141,8 @@ static int aspeed_i2c_bus_slave_event(I2CSlave *slave, enum i2c_event event)
 
     switch (event) {
     case I2C_START_SEND_ASYNC:
-        value = SHARED_ARRAY_FIELD_EX32(bus->regs, reg_byte_buf, TX_BUF);
-        SHARED_ARRAY_FIELD_DP32(bus->regs, reg_byte_buf, RX_BUF, value << 1);
+        /* Bit[0] == 0 indicates "send". */
+        SHARED_ARRAY_FIELD_DP32(bus->regs, reg_byte_buf, RX_BUF, dev_addr << 1);
 
         ARRAY_FIELD_DP32(bus->regs, I2CD_INTR_STS, SLAVE_ADDR_RX_MATCH, 1);
         SHARED_ARRAY_FIELD_DP32(bus->regs, reg_intr_sts, RX_DONE, 1);
Signature · 1 line
2.37.1
#2 lore raw
In reply to Cédric Le Goater
Quoted 3 lines · Cédric Le Goater

The following changes since commit 9a99f964b152f8095949bbddca7841744ad418da:

   Update version for v7.1.0-rc4 release (2022-08-24 19:27:56 -0700)

Too late, as you can see by -rc4.

r~

Quoted 21 lines

are available in the Git repository at:

   https://github.com/legoater/qemu/ tags/pull-aspeed-20220825

for you to fetch changes up to 7ccff968f65cfad573bc0015cb0ab800d4337a6e:

   hw/i2c/aspeed: Fix old reg slave receive (2022-08-25 10:46:42 +0200)

----------------------------------------------------------------
Aspeed queue:

* hw/i2c/aspeed: Fix old reg slave receive

----------------------------------------------------------------
Peter Delevoryas (1):
hw/i2c/aspeed: Fix old reg slave receive

  include/hw/i2c/aspeed_i2c.h | 1 +
  hw/i2c/aspeed_i2c.c         | 8 +++++---
  2 files changed, 6 insertions(+), 3 deletions(-)
#3 lore raw
Quoted 6 lines · Richard Henderson
Quoted 3 lines · Cédric Le Goater

The following changes since commit 9a99f964b152f8095949bbddca7841744ad418da:

   Update version for v7.1.0-rc4 release (2022-08-24 19:27:56 -0700)

Too late, as you can see by -rc4.

It will wait 7.2 then.

Thanks,

C.

Quoted 25 lines

r~

Quoted 21 lines

are available in the Git repository at:

   https://github.com/legoater/qemu/ tags/pull-aspeed-20220825

for you to fetch changes up to 7ccff968f65cfad573bc0015cb0ab800d4337a6e:

   hw/i2c/aspeed: Fix old reg slave receive (2022-08-25 10:46:42 +0200)

----------------------------------------------------------------
Aspeed queue:

* hw/i2c/aspeed: Fix old reg slave receive

----------------------------------------------------------------
Peter Delevoryas (1):
       hw/i2c/aspeed: Fix old reg slave receive

  include/hw/i2c/aspeed_i2c.h | 1 +
  hw/i2c/aspeed_i2c.c         | 8 +++++---

  2 files changed, 6 insertions(+), 3 deletions(-)