Add powernv10 I2C devices and tests
v3 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 Fixes: tag to commits 3 and 4
- Fixed formatting errors in commits 2 and 8
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 | 650 ++++++++++++++++++++++++++++++++ 11 files changed, 1103 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
PATCH v3 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
No changes from v2
hw/ppc/Kconfig | 1 + hw/ppc/pnv.c | 7 +++++++ 2 files changed, 8 insertions(+)
hw/ppc/Kconfig +1 -0
@@ -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
@@ -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
Re: [PATCH v3 1/8] ppc/pnv: Add pca9552 to powernv10 for PCIe hotplug power control
Quoted 33 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 of0xC6). This is used by hypervisor code to control PCIe slot power during hotplug events.Signed-off-by Glenn Miles <[email protected]>---
Based-on: <[email protected]> [PATCH v3 2/2] misc/pca9552: Let external devices set pca9552 inputsNo changes from v2
hw/ppc/Kconfig | 1 + hw/ppc/pnv.c | 7 +++++++ 2 files changed, 8 insertions(+)hw/ppc/Kconfig +1
-0@@ -32,6 +32,7 @@ config POWERNV select XIVE select FDT_PPC select PCI_POWERNV + select PCA9552 config PPC405 boolhw/ppc/pnv.c +0
-0
hw/ppc/pnv.c static void pnv_chip_power10_realize(DeviceState *dev, Error **errp) · line 1885
Quoted 9 lines
hw/ppc/pnv.c +6
-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 );
You didn't answer my question in v2. Is this a P10 chip device or a board/machine device ?
Thanks,
C.
Quoted 3 lines
hw/ppc/pnv.c +0
-0}static uint32_t pnv_chip_power10_xscom_pcba (PnvChip *chip,uint64_t addr)
Re: [PATCH v3 1/8] ppc/pnv: Add pca9552 to powernv10 for PCIe hotplug power control
Quoted 49 lines · Cédric Le Goater
Quoted 46 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 of0xC6). This is used by hypervisor code to control PCIe slot power during hotplug events.Signed-off-by Glenn Miles <[email protected]>---
Based-on: <[email protected]> [PATCH v3 2/2] misc/pca9552: Let external devices set pca9552 inputsNo changes from v2
hw/ppc/Kconfig | 1 + hw/ppc/pnv.c | 7 +++++++ 2 files changed, 8 insertions(+)hw/ppc/Kconfig +1
-0@@ -32,6 +32,7 @@ config POWERNV select XIVE select FDT_PPC select PCI_POWERNV + select PCA9552 config PPC405 boolhw/ppc/pnv.c +6
-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",Quoted 1 line
0x63);
Quoted 8 lines
You didn't answer my question in v2. Is this a P10 chip device or a board/machine device ?
Thanks,
C.
Sorry, you're right, I did miss that one, and after looking at the Denali spec, I see that the topology is indeed different from Rainier (which is what I have been modeling). For the Denali, the PCA9552 has a different I2C address (0x62 instead of 0x63) and the GPIO connections are also different. Also, there is no PCA9554 chip because it looks like they were able to cover all of the functionality with just the GPIO's of the PCA9552. So, good catch!
I'll look at what they did on the Aspeed machines like you suggested.
Thanks,
Glenn
Quoted 5 lines
Quoted 5 lines
}static
uint32_tpnv_chip_power10_xscom_pcba(PnvChip *chip,uint64_taddr)
Re: [PATCH v3 1/8] ppc/pnv: Add pca9552 to powernv10 for PCIe hotplug power control
Quoted 67 lines · Miles Glenn
Quoted 49 lines · Cédric Le Goater
Quoted 46 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 of0xC6). This is used by hypervisor code to control PCIe slot power during hotplug events.Signed-off-by Glenn Miles <[email protected]>---
Based-on: <[email protected]> [PATCH v3 2/2] misc/pca9552: Let external devices set pca9552 inputsNo changes from v2
hw/ppc/Kconfig | 1 + hw/ppc/pnv.c | 7 +++++++ 2 files changed, 8 insertions(+)hw/ppc/Kconfig +1
-0@@ -32,6 +32,7 @@ config POWERNV select XIVE select FDT_PPC select PCI_POWERNV + select PCA9552 config PPC405 boolhw/ppc/pnv.c +6
-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",Quoted 1 line
0x63);Quoted 8 lines
You didn't answer my question in v2. Is this a P10 chip device or a board/machine device ?
Thanks,
C.
Sorry, you're right, I did miss that one, and after looking at the Denali spec, I see that the topology is indeed different from Rainier (which is what I have been modeling). For the Denali, the PCA9552 has a different I2C address (
0x62instead of0x63) and the GPIO connections are also different. Also, there is no PCA9554 chip because it looks like they were able to cover all of the functionality with just the GPIO's of the PCA9552. So, good catch!
Quoted 1 line
I'll look at what they did on the Aspeed machines like you suggested.
It should be a machine class extension with an i2c_setup handler and a new "powernv10-rainier" machine modeling the board layout. The rest looks good.
Please include the pca9552 series in the respin. The pca9554 model will need a MAINTAINER (you?) I would be happy to let you take over pca9552 if you agree.
First, let's get patch 3 and 4 in QEMU 8.2.
Thanks,
C.
Quoted 11 lines
Thanks,
Glenn
Quoted 5 lines
Quoted 5 lines
}static
uint32_tpnv_chip_power10_xscom_pcba(PnvChip *chip,uint64_taddr)
Re: [PATCH v3 1/8] ppc/pnv: Add pca9552 to powernv10 for PCIe hotplug power control
Quoted 89 lines · Cédric Le Goater
Quoted 75 lines · Miles Glenn
Quoted 54 lines · Cédric Le Goater
Quoted 50 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 address0x63(or left-
justified address of0xC6). This is used by hypervisor code to control PCIe slot power during hotplug events.Signed-off-by Glenn Miles <[email protected]>---
Based-on: <[email protected]> [PATCH v3 2/2] misc/pca9552: Let external devices set pca9552 inputsNo changes from v2
hw/ppc/Kconfig | 1 + hw/ppc/pnv.c | 7 +++++++ 2 files changed, 8 insertions(+)hw/ppc/Kconfig +1
-0@@ -32,6 +32,7 @@ config POWERNV select XIVE select FDT_PPC select PCI_POWERNV + select PCA9552 config PPC405 boolhw/ppc/pnv.c +0
-0@@ -1877,6 +1877,13 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp) qdev_get_gpio_in(DEVICE(&chip10-
Quoted 1 line
psi),
PSIHB9_IRQ_SBE_I2C)); }hw/ppc/pnv.c +6
-0+ +/* +* 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],Quoted 2 lines
"pca9552",
0x63);Quoted 9 lines
You didn't answer my question in v2. Is this a P10 chip device or a
board/machine device ?Thanks,
C.
Sorry, you're right, I did miss that one, and after looking at the Denali spec, I see that the topology is indeed different from Rainier
(which is what I have been modeling). For the Denali, the PCA9552 has a different I2C address (0x62instead of0x63) and the GPIO connections are also different. Also, there is no PCA9554 chip because
it looks like they were able to cover all of the functionality with just the GPIO's of the PCA9552. So, good catch!Quoted 2 lines
I'll look at what they did on the Aspeed machines like you suggested.
It should be a machine class extension with an
i2c_setuphandler and a new "powernv10-rainier" machine modeling the board layout. The rest looks good.Please include the pca9552 series in the respin. The pca9554 model will
need a MAINTAINER (you?) I would be happy to let you take over pca9552
if you agree.
Quoted 7 lines
First, let's get patch 3 and 4 in QEMU 8.2.
Thanks,
C.
Well, I was hoping to sweep the pca9554 model under the PowerNV maintainership (like pca9552 is under the BMC aspeed maintainership). I did update the PowerNV list to include it, but perhaps that was presumptuous of me. :-)
I would be ok with being added as a reviewer under the PowerNV list, but I wonder if I shouldn't have more opensource experience before becoming a maintainer? TBH, I have no idea what that would entail.
As for patches 3 and 4, it sounds like I should split those changes out from the current patch series so that they can make it into QEMU 8.2. Correct?
Thanks,
Glenn
Quoted 10 lines
Quoted 10 lines
Thanks,
Glenn
Quoted 4 lines
Quoted 4 lines
}static
uint32_tpnv_chip_power10_xscom_pcba(PnvChip *chip,uint64_taddr)
Re: [PATCH v3 1/8] ppc/pnv: Add pca9552 to powernv10 for PCIe hotplug power control
Quoted 5 lines
Well, I was hoping to sweep the pca9554 model under the PowerNV maintainership (like pca9552 is under the BMC aspeed maintainership). I did update the PowerNV list to include it, but perhaps that was presumptuous of me. :-)
Well, you are the person who has the most knowledge on both and you have access to HW to check changes !
Quoted 3 lines
I would be ok with being added as a reviewer under the PowerNV list, but I wonder if I shouldn't have more opensource experience before becoming a maintainer? TBH, I have no idea what that would entail.
For these devices, mostly acking the changes. I don't think anyone will ask you to send PRs. This can be handled through some other tree, PPC or Aspeed.
Quoted 3 lines
As for patches 3 and 4, it sounds like I should split those changes out from the current patch series so that they can make it into QEMU 8.2. Correct?
I don't think this is needed. They can be picked in the series and merged in the ppc tree independently.
Thanks,
C.
Re: [PATCH v3 1/8] ppc/pnv: Add pca9552 to powernv10 for PCIe hotplug power control
Quoted 9 lines · Cédric Le Goater
Quoted 5 lines
Well, I was hoping to sweep the pca9554 model under the PowerNV maintainership (like pca9552 is under the BMC aspeed maintainership).
I did update the PowerNV list to include it, but perhaps that was presumptuous of me. :-)Well, you are the person who has the most knowledge on both and you have access to HW to check changes !
Quoted 9 lines
Quoted 4 lines
I would be ok with being added as a reviewer under the PowerNV list,
but I wonder if I shouldn't have more opensource experience before becoming a maintainer? TBH, I have no idea what that would entail.For these devices, mostly acking the changes. I don't think anyone will ask you to send PRs. This can be handled through some other tree, PPC or Aspeed.
Ok, that doesn't sound too bad. Sign me up!
Quoted 7 lines
Quoted 6 lines
As for patches 3 and 4, it sounds like I should split those changes out
from the current patch series so that they can make it into QEMU 8.2.
Correct?
Quoted 7 lines
I don't think this is needed. They can be picked in the series and merged in the ppc tree independently.
Thanks,
C.
Ok, sounds good.
Thanks,
Glenn
PATCH v3 2/8 ppc/pnv: Wire up pca9552 GPIO pins for PCIe hotplug power control
In reply to Glenn MilesFor 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.
---
Changes from previous version:
- Fixed formatting errors
hw/ppc/pnv.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
hw/ppc/pnv.c +18 -1
@@ -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
PATCH v3 3/8 ppc/pnv: PNV I2C engines assigned incorrect XSCOM addresses
In reply to Glenn MilesThe 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.
---
Changes from v2:
- Added Fixes: tag
hw/ppc/pnv.c | 6 ++++-- hw/ppc/pnv_i2c.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-)
hw/ppc/pnv.c +4 -2
@@ -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
@@ -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
Re: [PATCH v3 3/8] ppc/pnv: PNV I2C engines assigned incorrect XSCOM addresses
Quoted 11 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.
Fixes 1ceda19c28a1 ("ppc/pnv: Connect PNV I2C controller to powernv10)Signed-off-by Glenn Miles <[email protected]>---
This is 8.2 material.
Thanks,
C.
Quoted 45 lines
Changes from v2:
- Added Fixes: taghw/ppc/pnv.c | 6 ++++-- hw/ppc/pnv_i2c.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-)hw/ppc/pnv.c +4
-2@@ -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@@ -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 )
Cédric Le Goater
AppliedRe: [PATCH v3 3/8] ppc/pnv: PNV I2C engines assigned incorrect XSCOM addresses
In reply to Glenn MilesNick,
Since I started collecting fixes for 8.2 while you were away, I will finish this cycle with a last PR next week and let you take over 9.0.
Quoted 8 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 6 lines
Fixes 1ceda19c28a1 ("ppc/pnv: Connect PNV I2C controller to powernv10)Signed-off-by Glenn Miles <[email protected]>---
Changes from v2:
- Added Fixes: tag
Applied to ppc-next.
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@@ -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@@ -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 )
PATCH v3 4/8 ppc/pnv: Fix PNV I2C invalid status after reset
In reply to Glenn MilesThe 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.
---
Changes from v2:
-Added Fixes: tag
hw/ppc/pnv_i2c.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-)
hw/ppc/pnv_i2c.c +18 -24
@@ -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
Re: [PATCH v3 4/8] ppc/pnv: Fix PNV I2C invalid status after reset
Quoted 5 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.
Quoted 7 lines
Fixed this for resets caused by a system reset as well as from writing to the "Immediate Reset" register.
Fixes 263b81ee15af ("ppc/pnv: Add an I2C controller model")Signed-off-by Glenn Miles <[email protected]>---
This is 8.2 material.
Thanks,
C.
Quoted 73 lines
Changes from v2:
-Added Fixes: taghw/ppc/pnv_i2c.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-)hw/ppc/pnv_i2c.c +18
-24@@ -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);
Cédric Le Goater
AppliedRe: [PATCH v3 4/8] ppc/pnv: Fix PNV I2C invalid status after reset
In reply to Glenn MilesQuoted 11 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.
Fixes 263b81ee15af ("ppc/pnv: Add an I2C controller model")Signed-off-by Glenn Miles <[email protected]>---
Applied to ppc-next.
Thanks,
C.
Quoted 73 lines
Changes from v2:
-Added Fixes: taghw/ppc/pnv_i2c.c | 42 ++++++++++++++++++------------------------ 1 file changed, 18 insertions(+), 24 deletions(-)hw/ppc/pnv_i2c.c +18
-24@@ -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);
PATCH v3 5/8 ppc/pnv: Use resettable interface to reset child I2C buses
In reply to Glenn MilesThe 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.
---
No changes from v2
hw/ppc/pnv_i2c.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-)
hw/ppc/pnv_i2c.c +14 -1
@@ -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
PATCH v3 6/8 misc: Add a pca9554 GPIO device model
In reply to Glenn MilesSpecs 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.
---
No changes from v2
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
@@ -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
@@ -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
@@ -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
PATCH v3 7/8 ppc/pnv: Add a pca9554 I2C device to powernv10
In reply to Glenn MilesThe 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.
---
No changes from v2
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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v3 8/8 ppc/pnv: Test pnv i2c master and connected devices
In reply to Glenn MilesTests 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.
---
Changes from previous version:
- Fixed formatting errors
tests/qtest/meson.build | 1 + tests/qtest/pnv-host-i2c-test.c | 650 ++++++++++++++++++++++++++++++++ 2 files changed, 651 insertions(+) create mode 100644 tests/qtest/pnv-host-i2c-test.c
tests/qtest/meson.build +1 -0
@@ -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 +650 -0
650 lines not on this page · raw message
Signature · 1 line
2.31.1
Nick,
Quoted 10 lines · Glenn Miles
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 Fixes: tag to commits 3 and 4
Are you preparing a QEMU 8.2 PR for fixes ?
Thanks,
C.
Quoted 29 lines
- Fixed formatting errors in commits 2 and 8
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 devicesMAINTAINERS | 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 | 650 ++++++++++++++++++++++++++++++++ 11 files changed, 1103 insertions(+), 22 deletions(-)create mode 100644
hw/misc/pca9554.ccreate mode 100644include/hw/misc/pca9554.hcreate mode 100644include/hw/misc/pca9554_regs.hcreate mode 100644tests/qtest/pnv-host-i2c-test.c