Skip to contentSkip to conversation

Add powernv10 I2C devices and tests

PATCH Superseded Glenn Miles 2 participants 17 messages Nov 10, 2023 – Nov 14, 2023 Arm/Amlogic Meson SoC support

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add powernv10 I2C devices and tests

This series of patches includes support, tests and fixes for adding PCA9552 and PCA9554 I2C devices to the powernv10 chip.

The PCA9552 device is used for PCIe slot hotplug power control and monitoring, while the PCA9554 device is used for presence detection of IBM CableCard devices. Both devices are required by the Power Hypervisor Firmware on Power10 platforms.

Changes from previous version:
- Added prerequisite patch that hasn't merged into master yet. (see patch 1/8 for details). Without this patch, the code compiles but "make check" fails.

Glenn Miles (8):
ppc/pnv: Add pca9552 to powernv10 for PCIe hotplug power control ppc/pnv: Wire up pca9552 GPIO pins for PCIe hotplug power control ppc/pnv: PNV I2C engines assigned incorrect XSCOM addresses ppc/pnv: Fix PNV I2C invalid status after reset ppc/pnv: Use resettable interface to reset child I2C buses
misc: Add a pca9554 GPIO device model
ppc/pnv: Add a pca9554 I2C device to powernv10 ppc/pnv: Test pnv i2c master and connected devices

 MAINTAINERS                     |   2 +
 hw/misc/Kconfig                 |   4 +
 hw/misc/meson.build             |   1 +
 hw/misc/pca9554.c               | 328 ++++++++++++++++
 hw/ppc/Kconfig                  |   2 +
 hw/ppc/pnv.c                    |  35 +-
 hw/ppc/pnv_i2c.c                |  47 ++-
 include/hw/misc/pca9554.h       |  36 ++
 include/hw/misc/pca9554_regs.h  |  19 +
 tests/qtest/meson.build         |   1 +
 tests/qtest/pnv-host-i2c-test.c | 653 ++++++++++++++++++++++++++++++++
 11 files changed, 1106 insertions(+), 22 deletions(-)
 create mode 100644 hw/misc/pca9554.c
 create mode 100644 include/hw/misc/pca9554.h
 create mode 100644 include/hw/misc/pca9554_regs.h
 create mode 100644 tests/qtest/pnv-host-i2c-test.c
Signature · 1 line
2.31.1
#1 lore raw

PATCH v2 1/8 ppc/pnv: Add pca9552 to powernv10 for PCIe hotplug power control

The Power Hypervisor code expects to see a pca9552 device connected to the 3rd PNV I2C engine on port 1 at I2C address 0x63 (or left- justified address of 0xC6). This is used by hypervisor code to control PCIe slot power during hotplug events.

---
Based-on: <[email protected]> [PATCH v3 2/2] misc/pca9552: Let external devices set pca9552 inputs

 hw/ppc/Kconfig | 1 +
 hw/ppc/pnv.c   | 7 +++++++
 2 files changed, 8 insertions(+)
hw/ppc/Kconfig +1 -0
index 56f0475a8e..f77ca773cf 100644
@@ -32,6 +32,7 @@ config POWERNV
     select XIVE
     select FDT_PPC
     select PCI_POWERNV
+    select PCA9552
 
 config PPC405
     bool
hw/ppc/pnv.c +7 -0
index 9c29727337..7afaf1008f 100644
@@ -1877,6 +1877,13 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)
                               qdev_get_gpio_in(DEVICE(&chip10->psi),
                                                PSIHB9_IRQ_SBE_I2C));
     }
+
+    /*
+     * Add a PCA9552 I2C device for PCIe hotplug control
+     * to engine 2, bus 1, address 0x63
+     */
+    i2c_slave_create_simple(chip10->i2c[2].busses[1], "pca9552", 0x63);
+
 }
 
 static uint32_t pnv_chip_power10_xscom_pcba(PnvChip *chip, uint64_t addr)
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH v2 1/8] ppc/pnv: Add pca9552 to powernv10 for PCIe hotplug power control

Quoted 9 lines · Glenn Miles

The Power Hypervisor code expects to see a pca9552 device connected to the 3rd PNV I2C engine on port 1 at I2C address 0x63 (or left- justified address of 0xC6). This is used by hypervisor code to control PCIe slot power during hotplug events.

---
Based-on: <[email protected]> [PATCH v3 2/2] misc/pca9552: Let external devices set pca9552 inputs

Has this series been reviewed / merged ? If not, I would include the patches in this one.

Quoted 22 lines
  hw/ppc/Kconfig | 1 +
  hw/ppc/pnv.c   | 7 +++++++
  2 files changed, 8 insertions(+)
hw/ppc/Kconfig +1 -0
index 56f0475a8e..f77ca773cf 100644
@@ -32,6 +32,7 @@ config POWERNV
      select XIVE
      select FDT_PPC
      select PCI_POWERNV
+    select PCA9552
 
  config PPC405
      bool
hw/ppc/pnv.c +0 -0
index 9c29727337..7afaf1008f 100644

hw/ppc/pnv.c static void pnv_chip_power10_realize(DeviceState *dev, Error **errp) · line 1886

Quoted 10 lines
hw/ppc/pnv.c +7 -0
@@ -1877,6 +1877,13 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)
                                qdev_get_gpio_in(DEVICE(&chip10->psi),
                                                 PSIHB9_IRQ_SBE_I2C));
      }
+
+    /*
+     * Add a PCA9552 I2C device for PCIe hotplug control
+     * to engine 2, bus 1, address 0x63
+     */
+    i2c_slave_create_simple(chip10->i2c[2].busses[1], "pca9552", 0x63);
+

Are all POWER10 chips wired this way (on rainier, denali, etc) ? or is this device board specific ? If this is the case, then we should introduce a new custom powernv10 machine. Please take a look at the Aspeed machines for an example.

Thanks,

C.

Quoted 3 lines
hw/ppc/pnv.c +0 -0
  }
 
  static uint32_t pnv_chip_power10_xscom_pcba(PnvChip *chip, uint64_t addr)
#3 lore raw

Re: [PATCH v2 1/8] ppc/pnv: Add pca9552 to powernv10 for PCIe hotplug power control

Quoted 6 lines · Cédric Le Goater
Quoted 5 lines · Glenn Miles

The Power Hypervisor code expects to see a pca9552 device connected to the 3rd PNV I2C engine on port 1 at I2C address 0x63 (or left- justified address of 0xC6). This is used by hypervisor code to control PCIe slot power during hotplug events.

Quoted 9 lines
Quoted 5 lines

---
Based-on: <[email protected]> [PATCH v3 2/2] misc/pca9552: Let external devices set pca9552 inputs

Has this series been reviewed / merged ? If not, I would include the patches in this one.

It has been reviewed but not yet merged.

-Glenn

Quoted 52 lines
Quoted 33 lines
  hw/ppc/Kconfig | 1 +
  hw/ppc/pnv.c   | 7 +++++++
  2 files changed, 8 insertions(+)
hw/ppc/Kconfig +1 -0
index 56f0475a8e..f77ca773cf 100644
@@ -32,6 +32,7 @@ config POWERNV
      select XIVE
      select FDT_PPC
      select PCI_POWERNV
+    select PCA9552
 
  config PPC405
      bool
hw/ppc/pnv.c +6 -0
index 9c29727337..7afaf1008f 100644
@@ -1877,6 +1877,13 @@ static void
 pnv_chip_power10_realize(DeviceState *dev, Error **errp)
                                qdev_get_gpio_in(DEVICE(&chip10-
 >psi),
                                                 PSIHB9_IRQ_SBE_I2C
 ));
      }
+
+    /*
+     * Add a PCA9552 I2C device for PCIe hotplug control
+     * to engine 2, bus 1, address 0x63
+     */
+    i2c_slave_create_simple(chip10->i2c[2].busses[1], "pca9552",
Quoted 2 lines

0x63);
+

Are all POWER10 chips wired this way (on rainier, denali, etc) ? or is this device board specific ? If this is the case, then we should introduce a new custom powernv10 machine. Please take a look at the Aspeed machines for an example.

Thanks,

C.

Quoted 4 lines
  }

static uint32_t pnv_chip_power10_xscom_pcba(PnvChip *chip,
uint64_t addr)

#4 lore raw

PATCH v2 2/8 ppc/pnv: Wire up pca9552 GPIO pins for PCIe hotplug power control

In reply to Glenn Miles

For power10, a pca9552 device is used for PCIe slot hotplug power control by the Power Hypervisor code. The code expects that some time after it enables power to a PCIe slot by asserting one of the pca9552 GPIO pins 0-4, it should see a "power good" signal asserted on one of pca9552 GPIO pins 5-9.

To simulate this behavior, we simply connect the GPIO outputs for pins 0-4 to the GPIO inputs for pins 5-9.

Each PCIe slot is assigned 3 GPIO pins on the pca9552 device, for control of up to 5 PCIe slots. The per-slot signal names are:

SLOTx_EN.......PHYP uses this as an output to enable
slot power. We connect this to the SLOTx_PG pin to simulate a PGOOD signal.
SLOTx_PG.......PHYP uses this as in input to detect
PGOOD for the slot. For our purposes we just connect this to the SLOTx_EN output.
SLOTx_Control..PHYP uses this as an output to prevent
a race condition in the real hotplug circuitry, but we can ignore this output for simulation.

---
 hw/ppc/pnv.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)
hw/ppc/pnv.c +18 -1
index 7afaf1008f..0b24d7d8ed 100644
@@ -1882,7 +1882,24 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)
      * Add a PCA9552 I2C device for PCIe hotplug control
      * to engine 2, bus 1, address 0x63
      */
-    i2c_slave_create_simple(chip10->i2c[2].busses[1], "pca9552", 0x63);
+    I2CSlave* hotplug = i2c_slave_create_simple(chip10->i2c[2].busses[1],
+                                                "pca9552", 0x63);
+
+    /*
+     * Connect PCA9552 GPIO pins 0-4 (SLOTx_EN) outputs to GPIO pins 5-9
+     * (SLOTx_PG) inputs in order to fake the pgood state of PCIe slots after
+     * hypervisor code sets a SLOTx_EN pin high.
+     */
+    qdev_connect_gpio_out(DEVICE(hotplug), 0,
+                          qdev_get_gpio_in(DEVICE(hotplug), 5));
+    qdev_connect_gpio_out(DEVICE(hotplug), 1,
+                          qdev_get_gpio_in(DEVICE(hotplug), 6));
+    qdev_connect_gpio_out(DEVICE(hotplug), 2,
+                          qdev_get_gpio_in(DEVICE(hotplug), 7));
+    qdev_connect_gpio_out(DEVICE(hotplug), 3,
+                          qdev_get_gpio_in(DEVICE(hotplug), 8));
+    qdev_connect_gpio_out(DEVICE(hotplug), 4,
+                          qdev_get_gpio_in(DEVICE(hotplug), 9));
 
 }
 
Signature · 1 line
2.31.1
#5 lore raw

PATCH v2 3/8 ppc/pnv: PNV I2C engines assigned incorrect XSCOM addresses

In reply to Glenn Miles

The PNV I2C engines for power9 and power10 were being assigned a base XSCOM address that was off by one I2C engine's address range such that engine 0 had engine 1's address and so on. The xscom address assignment was being based on the device tree engine numbering, which starts at 1. Rather than changing the device tree numbering to start with 0, the addressing was changed to be based on the existing device tree numbers minus one.

---
 hw/ppc/pnv.c     | 6 ++++--
 hw/ppc/pnv_i2c.c | 2 +-
 2 files changed, 5 insertions(+), 3 deletions(-)
hw/ppc/pnv.c +4 -2
index 0b24d7d8ed..516434bc9c 100644
@@ -1623,7 +1623,8 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
             return;
         }
         pnv_xscom_add_subregion(chip, PNV9_XSCOM_I2CM_BASE +
-                               chip9->i2c[i].engine * PNV9_XSCOM_I2CM_SIZE,
+                                (chip9->i2c[i].engine - 1) *
+                                        PNV9_XSCOM_I2CM_SIZE,
                                 &chip9->i2c[i].xscom_regs);
         qdev_connect_gpio_out(DEVICE(&chip9->i2c[i]), 0,
                               qdev_get_gpio_in(DEVICE(&chip9->psi),
@@ -1871,7 +1872,8 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)
             return;
         }
         pnv_xscom_add_subregion(chip, PNV10_XSCOM_I2CM_BASE +
-                                chip10->i2c[i].engine * PNV10_XSCOM_I2CM_SIZE,
+                                (chip10->i2c[i].engine - 1) *
+                                        PNV10_XSCOM_I2CM_SIZE,
                                 &chip10->i2c[i].xscom_regs);
         qdev_connect_gpio_out(DEVICE(&chip10->i2c[i]), 0,
                               qdev_get_gpio_in(DEVICE(&chip10->psi),
hw/ppc/pnv_i2c.c +1 -1
index f75e59e709..b2c738da50 100644
@@ -593,7 +593,7 @@ static int pnv_i2c_dt_xscom(PnvXScomInterface *dev, void *fdt,
     int i2c_offset;
     const char i2c_compat[] = "ibm,power8-i2cm\0ibm,power9-i2cm";
     uint32_t i2c_pcba = PNV9_XSCOM_I2CM_BASE +
-        i2c->engine * PNV9_XSCOM_I2CM_SIZE;
+        (i2c->engine - 1) * PNV9_XSCOM_I2CM_SIZE;
     uint32_t reg[2] = {
         cpu_to_be32(i2c_pcba),
         cpu_to_be32(PNV9_XSCOM_I2CM_SIZE)
Signature · 1 line
2.31.1
#6 lore raw

Re: [PATCH v2 3/8] ppc/pnv: PNV I2C engines assigned incorrect XSCOM addresses

Quoted 9 lines · Glenn Miles

The PNV I2C engines for power9 and power10 were being assigned a base XSCOM address that was off by one I2C engine's address range such that engine 0 had engine 1's address and so on. The xscom address assignment was being based on the device tree engine numbering, which starts at 1. Rather than changing the device tree numbering to start with 0, the addressing was changed to be based on the existing device tree numbers minus one.

Looks like a fix to me. Please add a Fixes: tag and the patch will be queued for 8.2

Thanks,

C.

Quoted 42 lines
---
  hw/ppc/pnv.c     | 6 ++++--
  hw/ppc/pnv_i2c.c | 2 +-
  2 files changed, 5 insertions(+), 3 deletions(-)
hw/ppc/pnv.c +4 -2
index 0b24d7d8ed..516434bc9c 100644
@@ -1623,7 +1623,8 @@ static void pnv_chip_power9_realize(DeviceState *dev, Error **errp)
              return;
          }
          pnv_xscom_add_subregion(chip, PNV9_XSCOM_I2CM_BASE +
-                               chip9->i2c[i].engine * PNV9_XSCOM_I2CM_SIZE,
+                                (chip9->i2c[i].engine - 1) *
+                                        PNV9_XSCOM_I2CM_SIZE,
                                  &chip9->i2c[i].xscom_regs);
          qdev_connect_gpio_out(DEVICE(&chip9->i2c[i]), 0,
                                qdev_get_gpio_in(DEVICE(&chip9->psi),
@@ -1871,7 +1872,8 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)
              return;
          }
          pnv_xscom_add_subregion(chip, PNV10_XSCOM_I2CM_BASE +
-                                chip10->i2c[i].engine * PNV10_XSCOM_I2CM_SIZE,
+                                (chip10->i2c[i].engine - 1) *
+                                        PNV10_XSCOM_I2CM_SIZE,
                                  &chip10->i2c[i].xscom_regs);
          qdev_connect_gpio_out(DEVICE(&chip10->i2c[i]), 0,
                                qdev_get_gpio_in(DEVICE(&chip10->psi),
hw/ppc/pnv_i2c.c +1 -1
index f75e59e709..b2c738da50 100644
@@ -593,7 +593,7 @@ static int pnv_i2c_dt_xscom(PnvXScomInterface *dev, void *fdt,
      int i2c_offset;
      const char i2c_compat[] = "ibm,power8-i2cm\0ibm,power9-i2cm";
      uint32_t i2c_pcba = PNV9_XSCOM_I2CM_BASE +
-        i2c->engine * PNV9_XSCOM_I2CM_SIZE;
+        (i2c->engine - 1) * PNV9_XSCOM_I2CM_SIZE;
      uint32_t reg[2] = {
          cpu_to_be32(i2c_pcba),
          cpu_to_be32(PNV9_XSCOM_I2CM_SIZE)
#7 lore raw

Re: [PATCH v2 3/8] ppc/pnv: PNV I2C engines assigned incorrect XSCOM addresses

Quoted 13 lines · Cédric Le Goater
Quoted 12 lines · Glenn Miles

The PNV I2C engines for power9 and power10 were being assigned a base
XSCOM address that was off by one I2C engine's address range such that engine 0 had engine 1's address and so on. The xscom address assignment was being based on the device tree engine numbering, which
starts at 1. Rather than changing the device tree numbering to start
with 0, the addressing was changed to be based on the existing device
tree numbers minus one.

Quoted 9 lines
Quoted 1 line

Looks like a fix to me. Please add a Fixes: tag and the patch will be queued for 8.2

Thanks,

C.

Yes, I agree. Sorry, still learning about all of these tags!

Thanks,

Glenn

Quoted 50 lines
Quoted 50 lines
---
  hw/ppc/pnv.c     | 6 ++++--
  hw/ppc/pnv_i2c.c | 2 +-
  2 files changed, 5 insertions(+), 3 deletions(-)
hw/ppc/pnv.c +2 -1
index 0b24d7d8ed..516434bc9c 100644
@@ -1623,7 +1623,8 @@ static void
 pnv_chip_power9_realize(DeviceState *dev, Error **errp)
              return;
          }
          pnv_xscom_add_subregion(chip, PNV9_XSCOM_I2CM_BASE +
-                               chip9->i2c[i].engine *
 PNV9_XSCOM_I2CM_SIZE,
+                                (chip9->i2c[i].engine - 1) *
+                                        PNV9_XSCOM_I2CM_SIZE,
                                  &chip9->i2c[i].xscom_regs);
          qdev_connect_gpio_out(DEVICE(&chip9->i2c[i]), 0,
                                qdev_get_gpio_in(DEVICE(&chip9-
Quoted 1 line

psi),

hw/ppc/pnv.c +2 -1
@@ -1871,7 +1872,8 @@ static void
 pnv_chip_power10_realize(DeviceState *dev, Error **errp)
              return;
          }
          pnv_xscom_add_subregion(chip, PNV10_XSCOM_I2CM_BASE +
-                                chip10->i2c[i].engine *
 PNV10_XSCOM_I2CM_SIZE,
+                                (chip10->i2c[i].engine - 1) *
+                                        PNV10_XSCOM_I2CM_SIZE,
                                  &chip10->i2c[i].xscom_regs);
          qdev_connect_gpio_out(DEVICE(&chip10->i2c[i]), 0,
                                qdev_get_gpio_in(DEVICE(&chip10-
Quoted 1 line

psi),

hw/ppc/pnv_i2c.c +1 -1
index f75e59e709..b2c738da50 100644
@@ -593,7 +593,7 @@ static int pnv_i2c_dt_xscom(PnvXScomInterface
 *dev, void *fdt,
      int i2c_offset;
      const char i2c_compat[] = "ibm,power8-i2cm\0ibm,power9-i2cm";
      uint32_t i2c_pcba = PNV9_XSCOM_I2CM_BASE +
-        i2c->engine * PNV9_XSCOM_I2CM_SIZE;
+        (i2c->engine - 1) * PNV9_XSCOM_I2CM_SIZE;
      uint32_t reg[2] = {
          cpu_to_be32(i2c_pcba),
          cpu_to_be32(PNV9_XSCOM_I2CM_SIZE)
#8 lore raw

PATCH v2 4/8 ppc/pnv: Fix PNV I2C invalid status after reset

In reply to Glenn Miles

The PNV I2C Controller was clearing the status register after a reset without repopulating the "upper threshold for I2C ports", "Command Complete" and the SCL/SDA input level fields.

Fixed this for resets caused by a system reset as well as from writing to the "Immediate Reset" register.

---
 hw/ppc/pnv_i2c.c | 42 ++++++++++++++++++------------------------
 1 file changed, 18 insertions(+), 24 deletions(-)
hw/ppc/pnv_i2c.c +18 -24
index b2c738da50..f80589157b 100644
@@ -462,6 +462,23 @@ static uint64_t pnv_i2c_xscom_read(void *opaque, hwaddr addr,
     return val;
 }
 
+static void pnv_i2c_reset(void *dev)
+{
+    PnvI2C *i2c = PNV_I2C(dev);
+
+    memset(i2c->regs, 0, sizeof(i2c->regs));
+
+    i2c->regs[I2C_STAT_REG] =
+        SETFIELD(I2C_STAT_UPPER_THRS, 0ull, i2c->num_busses - 1) |
+        I2C_STAT_CMD_COMP | I2C_STAT_SCL_INPUT_LEVEL |
+        I2C_STAT_SDA_INPUT_LEVEL;
+    i2c->regs[I2C_EXTD_STAT_REG] =
+        SETFIELD(I2C_EXTD_STAT_FIFO_SIZE, 0ull, PNV_I2C_FIFO_SIZE) |
+        SETFIELD(I2C_EXTD_STAT_I2C_VERSION, 0ull, 23); /* last version */
+
+    fifo8_reset(&i2c->fifo);
+}
+
 static void pnv_i2c_xscom_write(void *opaque, hwaddr addr,
                                 uint64_t val, unsigned size)
 {
@@ -499,16 +516,7 @@ static void pnv_i2c_xscom_write(void *opaque, hwaddr addr,
         break;
 
     case I2C_RESET_I2C_REG:
-        i2c->regs[I2C_MODE_REG] = 0;
-        i2c->regs[I2C_CMD_REG] = 0;
-        i2c->regs[I2C_WATERMARK_REG] = 0;
-        i2c->regs[I2C_INTR_MASK_REG] = 0;
-        i2c->regs[I2C_INTR_COND_REG] = 0;
-        i2c->regs[I2C_INTR_RAW_COND_REG] = 0;
-        i2c->regs[I2C_STAT_REG] = 0;
-        i2c->regs[I2C_RESIDUAL_LEN_REG] = 0;
-        i2c->regs[I2C_EXTD_STAT_REG] &=
-            (I2C_EXTD_STAT_FIFO_SIZE | I2C_EXTD_STAT_I2C_VERSION);
+        pnv_i2c_reset(i2c);
         break;
 
     case I2C_RESET_ERRORS:
@@ -620,20 +628,6 @@ static int pnv_i2c_dt_xscom(PnvXScomInterface *dev, void *fdt,
     return 0;
 }
 
-static void pnv_i2c_reset(void *dev)
-{
-    PnvI2C *i2c = PNV_I2C(dev);
-
-    memset(i2c->regs, 0, sizeof(i2c->regs));
-
-    i2c->regs[I2C_STAT_REG] = I2C_STAT_CMD_COMP;
-    i2c->regs[I2C_EXTD_STAT_REG] =
-        SETFIELD(I2C_EXTD_STAT_FIFO_SIZE, 0ull, PNV_I2C_FIFO_SIZE) |
-        SETFIELD(I2C_EXTD_STAT_I2C_VERSION, 0ull, 23); /* last version */
-
-    fifo8_reset(&i2c->fifo);
-}
-
 static void pnv_i2c_realize(DeviceState *dev, Error **errp)
 {
     PnvI2C *i2c = PNV_I2C(dev);
Signature · 1 line
2.31.1
#9 lore raw

Re: [PATCH v2 4/8] ppc/pnv: Fix PNV I2C invalid status after reset

Quoted 46 lines · Glenn Miles

The PNV I2C Controller was clearing the status register after a reset without repopulating the "upper threshold for I2C ports", "Command Complete" and the SCL/SDA input level fields.

Fixed this for resets caused by a system reset as well as from writing to the "Immediate Reset" register.

---
  hw/ppc/pnv_i2c.c | 42 ++++++++++++++++++------------------------
  1 file changed, 18 insertions(+), 24 deletions(-)
hw/ppc/pnv_i2c.c +17 -1
index b2c738da50..f80589157b 100644
@@ -462,6 +462,23 @@ static uint64_t pnv_i2c_xscom_read(void *opaque, hwaddr addr,
      return val;
  }
 
+static void pnv_i2c_reset(void *dev)
+{
+    PnvI2C *i2c = PNV_I2C(dev);
+
+    memset(i2c->regs, 0, sizeof(i2c->regs));
+
+    i2c->regs[I2C_STAT_REG] =
+        SETFIELD(I2C_STAT_UPPER_THRS, 0ull, i2c->num_busses - 1) |
+        I2C_STAT_CMD_COMP | I2C_STAT_SCL_INPUT_LEVEL |
+        I2C_STAT_SDA_INPUT_LEVEL;
+    i2c->regs[I2C_EXTD_STAT_REG] =
+        SETFIELD(I2C_EXTD_STAT_FIFO_SIZE, 0ull, PNV_I2C_FIFO_SIZE) |
+        SETFIELD(I2C_EXTD_STAT_I2C_VERSION, 0ull, 23); /* last version */
+
+    fifo8_reset(&i2c->fifo);
+}
+
  static void pnv_i2c_xscom_write(void *opaque, hwaddr addr,
                                  uint64_t val, unsigned size)
  {
@@ -499,16 +516,7 @@ static void pnv_i2c_xscom_write(void *opaque, hwaddr addr,
          break;
 
      case I2C_RESET_I2C_REG:
-        i2c->regs[I2C_MODE_REG] = 0;

hw/ppc/pnv_i2c.c static void pnv_i2c_xscom_write(void *opaque, hwaddr addr, · line 519

Quoted 10 lines
hw/ppc/pnv_i2c.c +1 -9
-        i2c->regs[I2C_CMD_REG] = 0;
-        i2c->regs[I2C_WATERMARK_REG] = 0;
-        i2c->regs[I2C_INTR_MASK_REG] = 0;
-        i2c->regs[I2C_INTR_COND_REG] = 0;
-        i2c->regs[I2C_INTR_RAW_COND_REG] = 0;
-        i2c->regs[I2C_STAT_REG] = 0;
-        i2c->regs[I2C_RESIDUAL_LEN_REG] = 0;
-        i2c->regs[I2C_EXTD_STAT_REG] &=
-            (I2C_EXTD_STAT_FIFO_SIZE | I2C_EXTD_STAT_I2C_VERSION);
+        pnv_i2c_reset(i2c);

or simply call device_cold_reset()

Thanks,

C.

Quoted 24 lines
hw/ppc/pnv_i2c.c +0 -14
          break;
 
      case I2C_RESET_ERRORS:
@@ -620,20 +628,6 @@ static int pnv_i2c_dt_xscom(PnvXScomInterface *dev, void *fdt,
      return 0;
  }
 
-static void pnv_i2c_reset(void *dev)
-{
-    PnvI2C *i2c = PNV_I2C(dev);
-
-    memset(i2c->regs, 0, sizeof(i2c->regs));
-
-    i2c->regs[I2C_STAT_REG] = I2C_STAT_CMD_COMP;
-    i2c->regs[I2C_EXTD_STAT_REG] =
-        SETFIELD(I2C_EXTD_STAT_FIFO_SIZE, 0ull, PNV_I2C_FIFO_SIZE) |
-        SETFIELD(I2C_EXTD_STAT_I2C_VERSION, 0ull, 23); /* last version */
-
-    fifo8_reset(&i2c->fifo);
-}
-
  static void pnv_i2c_realize(DeviceState *dev, Error **errp)
  {
      PnvI2C *i2c = PNV_I2C(dev);
#10 lore raw

Re: [PATCH v2 4/8] ppc/pnv: Fix PNV I2C invalid status after reset

Quoted 65 lines · Cédric Le Goater
Quoted 50 lines · Glenn Miles

The PNV I2C Controller was clearing the status register after a reset without repopulating the "upper threshold for I2C ports", "Command Complete" and the SCL/SDA input level fields.

Fixed this for resets caused by a system reset as well as from writing to the "Immediate Reset" register.

---
  hw/ppc/pnv_i2c.c | 42 ++++++++++++++++++------------------------
  1 file changed, 18 insertions(+), 24 deletions(-)
hw/ppc/pnv_i2c.c +12 -0
index b2c738da50..f80589157b 100644
@@ -462,6 +462,23 @@ static uint64_t pnv_i2c_xscom_read(void
 *opaque, hwaddr addr,
      return val;
  }
 
+static void pnv_i2c_reset(void *dev)
+{
+    PnvI2C *i2c = PNV_I2C(dev);
+
+    memset(i2c->regs, 0, sizeof(i2c->regs));
+
+    i2c->regs[I2C_STAT_REG] =
+        SETFIELD(I2C_STAT_UPPER_THRS, 0ull, i2c->num_busses - 1) |
+        I2C_STAT_CMD_COMP | I2C_STAT_SCL_INPUT_LEVEL |
+        I2C_STAT_SDA_INPUT_LEVEL;
+    i2c->regs[I2C_EXTD_STAT_REG] =
+        SETFIELD(I2C_EXTD_STAT_FIFO_SIZE, 0ull, PNV_I2C_FIFO_SIZE)

|
+ SETFIELD(I2C_EXTD_STAT_I2C_VERSION, 0ull, 23); /* last
version */

hw/ppc/pnv_i2c.c +4 -1
+
+    fifo8_reset(&i2c->fifo);
+}
+
  static void pnv_i2c_xscom_write(void *opaque, hwaddr addr,
                                  uint64_t val, unsigned size)
  {
@@ -499,16 +516,7 @@ static void pnv_i2c_xscom_write(void *opaque,
 hwaddr addr,
          break;
 
      case I2C_RESET_I2C_REG:
-        i2c->regs[I2C_MODE_REG] = 0;

hw/ppc/pnv_i2c.c static void pnv_i2c_xscom_write(void *opaque, · line 520

Quoted 10 lines
hw/ppc/pnv_i2c.c +1 -9
-        i2c->regs[I2C_CMD_REG] = 0;
-        i2c->regs[I2C_WATERMARK_REG] = 0;
-        i2c->regs[I2C_INTR_MASK_REG] = 0;
-        i2c->regs[I2C_INTR_COND_REG] = 0;
-        i2c->regs[I2C_INTR_RAW_COND_REG] = 0;
-        i2c->regs[I2C_STAT_REG] = 0;
-        i2c->regs[I2C_RESIDUAL_LEN_REG] = 0;
-        i2c->regs[I2C_EXTD_STAT_REG] &=
-            (I2C_EXTD_STAT_FIFO_SIZE | I2C_EXTD_STAT_I2C_VERSION);
+        pnv_i2c_reset(i2c);

or simply call device_cold_reset()

Quoted 4 lines

Thanks,

C.

The device_cold_reset() function performs a recursive reset, which I believe performs a reset on the specified device as well as a reset on all child devices. For the case of doing an "immediate reset" of the i2c controller, I think we just want to reset the i2c controller and not any child devices, so I think I prefer leaving it how it is if that is ok.

Thanks,

Glenn

Quoted 29 lines
Quoted 29 lines
hw/ppc/pnv_i2c.c +0 -0
          break;
 

case I2C_RESET_ERRORS:

hw/ppc/pnv_i2c.c +0 -9
@@ -620,20 +628,6 @@ static int pnv_i2c_dt_xscom(PnvXScomInterface
 *dev, void *fdt,
      return 0;
  }
 
-static void pnv_i2c_reset(void *dev)
-{
-    PnvI2C *i2c = PNV_I2C(dev);
-
-    memset(i2c->regs, 0, sizeof(i2c->regs));
-
-    i2c->regs[I2C_STAT_REG] = I2C_STAT_CMD_COMP;
-    i2c->regs[I2C_EXTD_STAT_REG] =
-        SETFIELD(I2C_EXTD_STAT_FIFO_SIZE, 0ull, PNV_I2C_FIFO_SIZE)

|
- SETFIELD(I2C_EXTD_STAT_I2C_VERSION, 0ull, 23); /* last
version */

hw/ppc/pnv_i2c.c +0 -4
-
-    fifo8_reset(&i2c->fifo);
-}
-
  static void pnv_i2c_realize(DeviceState *dev, Error **errp)
  {
      PnvI2C *i2c = PNV_I2C(dev);
#11 lore raw

Re: [PATCH v2 4/8] ppc/pnv: Fix PNV I2C invalid status after reset

Quoted 71 lines · Miles Glenn
Quoted 65 lines · Cédric Le Goater
Quoted 50 lines · Glenn Miles

The PNV I2C Controller was clearing the status register after a reset without repopulating the "upper threshold for I2C ports", "Command Complete" and the SCL/SDA input level fields.

Fixed this for resets caused by a system reset as well as from writing to the "Immediate Reset" register.

---
   hw/ppc/pnv_i2c.c | 42 ++++++++++++++++++------------------------
   1 file changed, 18 insertions(+), 24 deletions(-)
hw/ppc/pnv_i2c.c +12 -0
index b2c738da50..f80589157b 100644
@@ -462,6 +462,23 @@ static uint64_t pnv_i2c_xscom_read(void
 *opaque, hwaddr addr,
       return val;
   }
 
+static void pnv_i2c_reset(void *dev)
+{
+    PnvI2C *i2c = PNV_I2C(dev);
+
+    memset(i2c->regs, 0, sizeof(i2c->regs));
+
+    i2c->regs[I2C_STAT_REG] =
+        SETFIELD(I2C_STAT_UPPER_THRS, 0ull, i2c->num_busses - 1) |
+        I2C_STAT_CMD_COMP | I2C_STAT_SCL_INPUT_LEVEL |
+        I2C_STAT_SDA_INPUT_LEVEL;
+    i2c->regs[I2C_EXTD_STAT_REG] =
+        SETFIELD(I2C_EXTD_STAT_FIFO_SIZE, 0ull, PNV_I2C_FIFO_SIZE)

|
+ SETFIELD(I2C_EXTD_STAT_I2C_VERSION, 0ull, 23); /* last
version */

hw/ppc/pnv_i2c.c +4 -1
+
+    fifo8_reset(&i2c->fifo);
+}
+
   static void pnv_i2c_xscom_write(void *opaque, hwaddr addr,
                                   uint64_t val, unsigned size)
   {
@@ -499,16 +516,7 @@ static void pnv_i2c_xscom_write(void *opaque,
 hwaddr addr,
           break;
 
       case I2C_RESET_I2C_REG:
-        i2c->regs[I2C_MODE_REG] = 0;

hw/ppc/pnv_i2c.c static void pnv_i2c_xscom_write(void *opaque, · line 520

Quoted 10 lines
hw/ppc/pnv_i2c.c +1 -9
-        i2c->regs[I2C_CMD_REG] = 0;
-        i2c->regs[I2C_WATERMARK_REG] = 0;
-        i2c->regs[I2C_INTR_MASK_REG] = 0;
-        i2c->regs[I2C_INTR_COND_REG] = 0;
-        i2c->regs[I2C_INTR_RAW_COND_REG] = 0;
-        i2c->regs[I2C_STAT_REG] = 0;
-        i2c->regs[I2C_RESIDUAL_LEN_REG] = 0;
-        i2c->regs[I2C_EXTD_STAT_REG] &=
-            (I2C_EXTD_STAT_FIFO_SIZE | I2C_EXTD_STAT_I2C_VERSION);
+        pnv_i2c_reset(i2c);

or simply call device_cold_reset()

Quoted 4 lines

Thanks,

C.

Quoted 6 lines

The device_cold_reset() function performs a recursive reset, which I believe performs a reset on the specified device as well as a reset on all child devices. For the case of doing an "immediate reset" of the i2c controller, I think we just want to reset the i2c controller and not any child devices, so I think I prefer leaving it how it is if that is ok.

OK. Is is a fix for 8.2 ?

Thanks,

C.

Quoted 34 lines

Thanks,

Glenn

Quoted 29 lines
Quoted 29 lines
hw/ppc/pnv_i2c.c +0 -0
           break;
 

case I2C_RESET_ERRORS:

hw/ppc/pnv_i2c.c +0 -9
@@ -620,20 +628,6 @@ static int pnv_i2c_dt_xscom(PnvXScomInterface
 *dev, void *fdt,
       return 0;
   }
 
-static void pnv_i2c_reset(void *dev)
-{
-    PnvI2C *i2c = PNV_I2C(dev);
-
-    memset(i2c->regs, 0, sizeof(i2c->regs));
-
-    i2c->regs[I2C_STAT_REG] = I2C_STAT_CMD_COMP;
-    i2c->regs[I2C_EXTD_STAT_REG] =
-        SETFIELD(I2C_EXTD_STAT_FIFO_SIZE, 0ull, PNV_I2C_FIFO_SIZE)

|
- SETFIELD(I2C_EXTD_STAT_I2C_VERSION, 0ull, 23); /* last
version */

hw/ppc/pnv_i2c.c +0 -4
-
-    fifo8_reset(&i2c->fifo);
-}
-
   static void pnv_i2c_realize(DeviceState *dev, Error **errp)
   {
       PnvI2C *i2c = PNV_I2C(dev);
#12 lore raw

Re: [PATCH v2 4/8] ppc/pnv: Fix PNV I2C invalid status after reset

Quoted 86 lines · Cédric Le Goater
Quoted 75 lines · Miles Glenn
Quoted 69 lines · Cédric Le Goater
Quoted 54 lines · Glenn Miles

The PNV I2C Controller was clearing the status register after a reset without repopulating the "upper threshold for I2C ports", "Command Complete" and the SCL/SDA input level fields.

Fixed this for resets caused by a system reset as well as from writing to the "Immediate Reset" register.

---
   hw/ppc/pnv_i2c.c | 42 ++++++++++++++++++------------------
------
   1 file changed, 18 insertions(+), 24 deletions(-)
hw/ppc/pnv_i2c.c +8 -0
index b2c738da50..f80589157b 100644
@@ -462,6 +462,23 @@ static uint64_t pnv_i2c_xscom_read(void
 *opaque, hwaddr addr,
       return val;
   }
 
+static void pnv_i2c_reset(void *dev)
+{
+    PnvI2C *i2c = PNV_I2C(dev);
+
+    memset(i2c->regs, 0, sizeof(i2c->regs));
+
+    i2c->regs[I2C_STAT_REG] =
+        SETFIELD(I2C_STAT_UPPER_THRS, 0ull, i2c->num_busses -

1) |

hw/ppc/pnv_i2c.c +4 -0
+        I2C_STAT_CMD_COMP | I2C_STAT_SCL_INPUT_LEVEL |
+        I2C_STAT_SDA_INPUT_LEVEL;
+    i2c->regs[I2C_EXTD_STAT_REG] =
+        SETFIELD(I2C_EXTD_STAT_FIFO_SIZE, 0ull,

PNV_I2C_FIFO_SIZE)
+ SETFIELD(I2C_EXTD_STAT_I2C_VERSION, 0ull, 23); /* last
version */

hw/ppc/pnv_i2c.c +4 -2
+
+    fifo8_reset(&i2c->fifo);
+}
+
   static void pnv_i2c_xscom_write(void *opaque, hwaddr addr,
                                   uint64_t val, unsigned size)
   {
@@ -499,16 +516,7 @@ static void pnv_i2c_xscom_write(void
 *opaque,
 hwaddr addr,
           break;
 
       case I2C_RESET_I2C_REG:
-        i2c->regs[I2C_MODE_REG] = 0;
-        i2c->regs[I2C_CMD_REG] = 0;

hw/ppc/pnv_i2c.c static void pnv_i2c_xscom_write(void · line 522

Quoted 10 lines
hw/ppc/pnv_i2c.c +1 -8
-        i2c->regs[I2C_WATERMARK_REG] = 0;
-        i2c->regs[I2C_INTR_MASK_REG] = 0;
-        i2c->regs[I2C_INTR_COND_REG] = 0;
-        i2c->regs[I2C_INTR_RAW_COND_REG] = 0;
-        i2c->regs[I2C_STAT_REG] = 0;
-        i2c->regs[I2C_RESIDUAL_LEN_REG] = 0;
-        i2c->regs[I2C_EXTD_STAT_REG] &=
-            (I2C_EXTD_STAT_FIFO_SIZE |
 I2C_EXTD_STAT_I2C_VERSION);
+        pnv_i2c_reset(i2c);

or simply call device_cold_reset()

Quoted 4 lines

Thanks,

C.

Quoted 9 lines

The device_cold_reset() function performs a recursive reset, which I believe performs a reset on the specified device as well as a reset
on all child devices. For the case of doing an "immediate reset" of
the i2c controller, I think we just want to reset the i2c controller
and not any child devices, so I think I prefer leaving it how it is if that is ok.

Quoted 6 lines

OK. Is is a fix for 8.2 ?

Thanks,

C.

Yes, I will send out a v3 stating that.

Thanks,

Glenn

Quoted 34 lines
Quoted 34 lines

Thanks,

Glenn

Quoted 29 lines
Quoted 29 lines
           break;
   
       case I2C_RESET_ERRORS:
hw/ppc/pnv_i2c.c +0 -0
@@ -620,20 +628,6 @@ static int

pnv_i2c_dt_xscom(PnvXScomInterface
*dev, void *fdt,

       return 0;

}

hw/ppc/pnv_i2c.c +0 -9
-static void pnv_i2c_reset(void *dev)
-{
-    PnvI2C *i2c = PNV_I2C(dev);
-
-    memset(i2c->regs, 0, sizeof(i2c->regs));
-
-    i2c->regs[I2C_STAT_REG] = I2C_STAT_CMD_COMP;
-    i2c->regs[I2C_EXTD_STAT_REG] =
-        SETFIELD(I2C_EXTD_STAT_FIFO_SIZE, 0ull,

PNV_I2C_FIFO_SIZE)
- SETFIELD(I2C_EXTD_STAT_I2C_VERSION, 0ull, 23); /* last
version */

hw/ppc/pnv_i2c.c +0 -4
-
-    fifo8_reset(&i2c->fifo);
-}
-
   static void pnv_i2c_realize(DeviceState *dev, Error **errp)
   {
       PnvI2C *i2c = PNV_I2C(dev);
#13 lore raw

PATCH v2 5/8 ppc/pnv: Use resettable interface to reset child I2C buses

In reply to Glenn Miles

The QEMU I2C buses and devices use the resettable interface for resetting while the PNV I2C controller and parent buses and devices have not yet transitioned to this new interface and use the old reset strategy. This was preventing the I2C buses and devices wired to the PNV I2C controller from being reset.

The short term fix for this is to have the PNV I2C Controller's reset function explicitly call the resettable interface function, bus_cold_reset(), on all child I2C buses.

The long term fix should be to transition all PNV parent devices and buses to use the resettable interface so that all child buses and devices are automatically reset.

---
 hw/ppc/pnv_i2c.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
hw/ppc/pnv_i2c.c +14 -1
index f80589157b..9ced596b98 100644
@@ -628,6 +628,19 @@ static int pnv_i2c_dt_xscom(PnvXScomInterface *dev, void *fdt,
     return 0;
 }
 
+static void pnv_i2c_sys_reset(void *dev)
+{
+    int port;
+    PnvI2C *i2c = PNV_I2C(dev);
+
+    pnv_i2c_reset(dev);
+
+    /* reset all buses connected to this i2c controller */
+    for (port = 0; port < i2c->num_busses; port++) {
+        bus_cold_reset(BUS(i2c->busses[port]));
+    }
+}
+
 static void pnv_i2c_realize(DeviceState *dev, Error **errp)
 {
     PnvI2C *i2c = PNV_I2C(dev);
@@ -648,7 +661,7 @@ static void pnv_i2c_realize(DeviceState *dev, Error **errp)
 
     fifo8_create(&i2c->fifo, PNV_I2C_FIFO_SIZE);
 
-    qemu_register_reset(pnv_i2c_reset, dev);
+    qemu_register_reset(pnv_i2c_sys_reset, dev);
 
     qdev_init_gpio_out(DEVICE(dev), &i2c->psi_irq, 1);
 }
Signature · 1 line
2.31.1
#14 lore raw

PATCH v2 6/8 misc: Add a pca9554 GPIO device model

In reply to Glenn Miles

Specs are available here:

    https://www.nxp.com/docs/en/data-sheet/PCA9554_9554A.pdf

This is a simple model supporting the basic registers for GPIO mode. The device also supports an interrupt output line but the model does not yet support this.

---
 MAINTAINERS                    |   2 +
 hw/misc/pca9554.c              | 328 +++++++++++++++++++++++++++++++++
 include/hw/misc/pca9554.h      |  36 ++++
 include/hw/misc/pca9554_regs.h |  19 ++
 4 files changed, 385 insertions(+)
 create mode 100644 hw/misc/pca9554.c
 create mode 100644 include/hw/misc/pca9554.h
 create mode 100644 include/hw/misc/pca9554_regs.h
MAINTAINERS +2 -0
index e73a3ff544..209080e1a0 100644
@@ -1504,8 +1504,10 @@ F: hw/ppc/pnv*
 F: hw/intc/pnv*
 F: hw/intc/xics_pnv.c
 F: hw/pci-host/pnv*
+F: hw/misc/pca9554.c
 F: include/hw/ppc/pnv*
 F: include/hw/pci-host/pnv*
+F: include/hw/misc/pca9554*.h
 F: pc-bios/skiboot.lid
 F: tests/qtest/pnv*
 
hw/misc/pca9554.c new file +328 -0

328 lines not on this page · raw message

include/hw/misc/pca9554.h new file +36 -0
new file mode 100644
index 0000000000..54bfc4c4c7
@@ -0,0 +1,36 @@
+/*
+ * PCA9554 I/O port
+ *
+ * Copyright (c) 2023, IBM Corporation.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef PCA9554_H
+#define PCA9554_H
+
+#include "hw/i2c/i2c.h"
+#include "qom/object.h"
+
+#define TYPE_PCA9554 "pca9554"
+typedef struct PCA9554State PCA9554State;
+DECLARE_INSTANCE_CHECKER(PCA9554State, PCA9554,
+                         TYPE_PCA9554)
+
+#define PCA9554_NR_REGS 4
+#define PCA9554_PIN_COUNT 8
+
+struct PCA9554State {
+    /*< private >*/
+    I2CSlave i2c;
+    /*< public >*/
+
+    uint8_t len;
+    uint8_t pointer;
+
+    uint8_t regs[PCA9554_NR_REGS];
+    qemu_irq gpio_out[PCA9554_PIN_COUNT];
+    uint8_t ext_state[PCA9554_PIN_COUNT];
+    char *description; /* For debugging purpose only */
+};
+
+#endif
include/hw/misc/pca9554_regs.h new file +19 -0
new file mode 100644
index 0000000000..602c4a90e0
@@ -0,0 +1,19 @@
+/*
+ * PCA9554 I/O port registers
+ *
+ * Copyright (c) 2023, IBM Corporation.
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+#ifndef PCA9554_REGS_H
+#define PCA9554_REGS_H
+
+/*
+ * Bits [0:1] are used to address a specific register.
+ */
+#define PCA9554_INPUT       0 /* read only input register */
+#define PCA9554_OUTPUT      1 /* read/write pin output state */
+#define PCA9554_POLARITY    2 /* Set polarity of input register */
+#define PCA9554_CONFIG      3 /* Set pins as inputs our ouputs */
+
+#endif
Signature · 1 line
2.31.1
#15 lore raw

PATCH v2 7/8 ppc/pnv: Add a pca9554 I2C device to powernv10

In reply to Glenn Miles

The Power Hypervisor code expects to see a pca9554 device connected to the 3rd PNV I2C engine on port 1 at I2C address 0x25 (or left- justified address of 0x4A). This is used by the hypervisor code to detect if a "Cable Card" is present.

---
 hw/misc/Kconfig     | 4 ++++
 hw/misc/meson.build | 1 +
 hw/ppc/Kconfig      | 1 +
 hw/ppc/pnv.c        | 5 +++++
 4 files changed, 11 insertions(+)
hw/misc/Kconfig +4 -0
index cc8a8c1418..c347a132c2 100644
@@ -34,6 +34,10 @@ config PCA9552
     bool
     depends on I2C
 
+config PCA9554
+    bool
+    depends on I2C
+
 config I2C_ECHO
     bool
     default y if TEST_DEVICES
hw/misc/meson.build +1 -0
index 36c20d5637..c39410e4a7 100644
@@ -4,6 +4,7 @@ system_ss.add(when: 'CONFIG_FW_CFG_DMA', if_true: files('vmcoreinfo.c'))
 system_ss.add(when: 'CONFIG_ISA_DEBUG', if_true: files('debugexit.c'))
 system_ss.add(when: 'CONFIG_ISA_TESTDEV', if_true: files('pc-testdev.c'))
 system_ss.add(when: 'CONFIG_PCA9552', if_true: files('pca9552.c'))
+system_ss.add(when: 'CONFIG_PCA9554', if_true: files('pca9554.c'))
 system_ss.add(when: 'CONFIG_PCI_TESTDEV', if_true: files('pci-testdev.c'))
 system_ss.add(when: 'CONFIG_UNIMP', if_true: files('unimp.c'))
 system_ss.add(when: 'CONFIG_EMPTY_SLOT', if_true: files('empty_slot.c'))
hw/ppc/Kconfig +1 -0
index f77ca773cf..2302778265 100644
@@ -33,6 +33,7 @@ config POWERNV
     select FDT_PPC
     select PCI_POWERNV
     select PCA9552
+    select PCA9554
 
 config PPC405
     bool
hw/ppc/pnv.c +5 -0
index 516434bc9c..b6b4164d78 100644
@@ -1903,6 +1903,11 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)
     qdev_connect_gpio_out(DEVICE(hotplug), 4,
                           qdev_get_gpio_in(DEVICE(hotplug), 9));
 
+    /*
+     * Add a PCA9554 I2C device for cable card presence detection
+     * to engine 2, bus 1, address 0x25
+     */
+    i2c_slave_create_simple(chip10->i2c[2].busses[1], "pca9554", 0x25);
 }
 
 static uint32_t pnv_chip_power10_xscom_pcba(PnvChip *chip, uint64_t addr)
Signature · 1 line
2.31.1
#16 lore raw

PATCH v2 8/8 ppc/pnv: Test pnv i2c master and connected devices

In reply to Glenn Miles

Tests the following for both P9 and P10:
- I2C master POR status
- I2C master status after immediate reset

Tests the following for P10 only:
- Config pca9552 hotplug device pins as inputs then Read the INPUT0/1 registers to verify all pins are high
- Connected GPIO pin tests of P10 PCA9552 device. Tests output of pins 0-4 affect input of pins 5-9 respectively.
- PCA9554 GPIO pins test. Tests input and ouput functionality.

---
 tests/qtest/meson.build         |   1 +
 tests/qtest/pnv-host-i2c-test.c | 653 ++++++++++++++++++++++++++++++++
 2 files changed, 654 insertions(+)
 create mode 100644 tests/qtest/pnv-host-i2c-test.c
tests/qtest/meson.build +1 -0
index 47dabf91d0..fbb0bd204c 100644
@@ -163,6 +163,7 @@ qtests_ppc64 = \
   qtests_ppc + \
   (config_all_devices.has_key('CONFIG_PSERIES') ? ['device-plug-test'] : []) +               \
   (config_all_devices.has_key('CONFIG_POWERNV') ? ['pnv-xscom-test'] : []) +                 \
+  (config_all_devices.has_key('CONFIG_POWERNV') ? ['pnv-host-i2c-test'] : []) +              \
   (config_all_devices.has_key('CONFIG_PSERIES') ? ['rtas-test'] : []) +                      \
   (slirp.found() ? ['pxe-test'] : []) +              \
   (config_all_devices.has_key('CONFIG_USB_UHCI') ? ['usb-hcd-uhci-test'] : []) +             \
tests/qtest/pnv-host-i2c-test.c new file +653 -0

653 lines not on this page · raw message

Signature · 1 line
2.31.1