Add powernv10 I2C devices and tests
v4 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:
- Pulled in fixes/changes for pca9552 devices
- Created new powernv10-rainier machine type
- Adds pca9552/pca9554 devices to powernv10-rainier machine
- Modified MAINTAINERS to make myself maintainer of the pca955x devices
Glenn Miles (11):
misc/pca9552: Fix inverted input status
misc/pca9552: Let external devices set pca9552 inputs ppc/pnv: New powernv10-rainier machine type
ppc/pnv: Add pca9552 to powernv10-rainier 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-rainier ppc/pnv: Test pnv i2c master and connected devices
MAINTAINERS | 10 +- hw/misc/Kconfig | 4 + hw/misc/meson.build | 1 + hw/misc/pca9552.c | 58 ++- hw/misc/pca9554.c | 328 ++++++++++++++++ hw/ppc/Kconfig | 2 + hw/ppc/pnv.c | 83 +++- hw/ppc/pnv_i2c.c | 47 ++- include/hw/misc/pca9552.h | 3 +- include/hw/misc/pca9554.h | 36 ++ include/hw/misc/pca9554_regs.h | 19 + include/hw/ppc/pnv.h | 1 + tests/qtest/meson.build | 1 + tests/qtest/pca9552-test.c | 6 +- tests/qtest/pnv-host-i2c-test.c | 650 ++++++++++++++++++++++++++++++++ 15 files changed, 1212 insertions(+), 37 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 v4 1/11 misc/pca9552: Fix inverted input status
The pca9552 INPUT0 and INPUT1 registers are supposed to hold the logical values of the LED pins. A logical 0 should be seen in the INPUT0/1 registers for a pin when its corresponding LSn bits are set to 0, which is also the state needed for turning on an LED in a typical usage scenario. Existing code was doing the opposite and setting INPUT0/1 bit to a 1 when the LSn bit was set to 0, so this commit fixes that.
---
No changes from previous version
hw/misc/pca9552.c | 18 +++++++++++++----- tests/qtest/pca9552-test.c | 6 +++--- 2 files changed, 16 insertions(+), 8 deletions(-)
hw/misc/pca9552.c +13 -5
@@ -36,7 +36,10 @@ typedef struct PCA955xClass PCA955xClass;DECLARE_CLASS_CHECKERS (PCA955xClass,PCA955X ,TYPE_PCA955X ) - +/* +* Note: The LED_ON and LED_OFF configuration values for the PCA955X +* chips are the reverse of the PCA953X family of chips. + */#define PCA9552_LED_ON 0x0#define PCA9552_LED_OFF 0x1#define PCA9552_LED_PWM0 0x2
@@ -112,13 +115,18 @@ static void pca955x_update_pin_input(PCA955xState *s)switch (config) {case PCA9552_LED_ON : -qemu_set_irq (s->gpio[i],1 ); - s->regs[input_reg] |=1 << input_shift; -break ; -case PCA9552_LED_OFF : +/* Pin is set to 0V to turn on LED */ qemu_set_irq (s->gpio[i],0 ); s->regs[input_reg] &= ~(1 << input_shift);break ; +case PCA9552_LED_OFF : +/* +* Pin is set to Hi-Z to turn off LED and +* pullup sets it to a logical 1. +*/ +qemu_set_irq (s->gpio[i],1 ); + s->regs[input_reg] |=1 << input_shift; +break ;case PCA9552_LED_PWM0 :case PCA9552_LED_PWM1 :/* TODO */
tests/qtest/pca9552-test.c +3 -3
@@ -60,7 +60,7 @@ static void send_and_receive(void *obj, void *data, QGuestAllocator *alloc) g_assert_cmphex(value, ==, 0x55); value =i2c_get8 (i2cdev,PCA9552_INPUT0 ); - g_assert_cmphex(value, ==, 0x0); + g_assert_cmphex(value, ==, 0xFF);pca9552_init (i2cdev);
@@ -68,13 +68,13 @@ static void send_and_receive(void *obj, void *data, QGuestAllocator *alloc) g_assert_cmphex(value, ==, 0x54); value =i2c_get8 (i2cdev,PCA9552_INPUT0 ); - g_assert_cmphex(value, ==, 0x01); + g_assert_cmphex(value, ==, 0xFE); value =i2c_get8 (i2cdev,PCA9552_LS3 ); g_assert_cmphex(value, ==, 0x54); value =i2c_get8 (i2cdev,PCA9552_INPUT1 ); - g_assert_cmphex(value, ==, 0x10); + g_assert_cmphex(value, ==, 0xEF); }static void pca9552_register_nodes (void )
Signature · 1 line
2.31.1
PATCH v4 2/11 misc/pca9552: Let external devices set pca9552 inputs
In reply to Glenn MilesAllow external devices to drive pca9552 input pins by adding input GPIO's to the model. This allows a device to connect its output GPIO's to the pca9552 input GPIO's.
In order for an external device to set the state of a pca9552 pin, the pin must first be configured for high impedance (LED is off). If the pca9552 pin is configured to drive the pin low (LED is on), then external input will be ignored.
Here is a table describing the logical state of a pca9552 pin given the state being driven by the pca9552 and an external device:
PCA9552
Configured
State
| Hi-Z | Low |
------+------+-----+
External Hi-Z | Hi | Low |
Device ------+------+-----+
State Low | Low | Low |
------+------+-----+---
No changes from previous version
hw/misc/pca9552.c | 50 +++++++++++++++++++++++++++++++++------ include/hw/misc/pca9552.h | 3 ++- 2 files changed, 45 insertions(+), 8 deletions(-)
hw/misc/pca9552.c +43 -7
@@ -44,6 +44,8 @@ DECLARE_CLASS_CHECKERS(PCA955xClass, PCA955X,#define PCA9552_LED_OFF 0x1#define PCA9552_LED_PWM0 0x2#define PCA9552_LED_PWM1 0x3 +#define PCA9552_PIN_LOW 0x0 +#define PCA9552_PIN_HIZ 0x1static const char *led_state[] = {"on" ,"off" ,"pwm0" ,"pwm1" };
@@ -110,22 +112,27 @@ static void pca955x_update_pin_input(PCA955xState *s)for (i =0 ; i < k->pin_count; i++) {uint8_t input_reg =PCA9552_INPUT0 + (i /8 ); -uint8_t input_shift = (i %8 ); +uint8_t bit_mask =1 << (i %8 );uint8_t config =pca955x_pin_get_config (s, i); +uint8_t old_value = s->regs[input_reg] & bit_mask; +uint8_t new_value;switch (config) {case PCA9552_LED_ON :/* Pin is set to 0V to turn on LED */ -qemu_set_irq (s->gpio[i],0 ); - s->regs[input_reg] &= ~(1 << input_shift); + s->regs[input_reg] &= ~bit_mask;break ;case PCA9552_LED_OFF :/* * Pin is set to Hi-Z to turn off LED and -* pullup sets it to a logical 1. +* pullup sets it to a logical 1 unless +* external device drives it low. */ -qemu_set_irq (s->gpio[i],1 ); - s->regs[input_reg] |=1 << input_shift; +if (s->ext_state[i] ==PCA9552_PIN_LOW ) { + s->regs[input_reg] &= ~bit_mask; + }else { + s->regs[input_reg] |= bit_mask; + }break ;case PCA9552_LED_PWM0 :case PCA9552_LED_PWM1 :
@@ -133,6 +140,12 @@ static void pca955x_update_pin_input(PCA955xState *s)default :break ; } + +/* update irq state only if pin state changed */ + new_value = s->regs[input_reg] & bit_mask; +if (new_value != old_value) { +qemu_set_irq (s->gpio_out[i], !!new_value); + } } }
@@ -340,6 +353,7 @@ static const VMStateDescription pca9552_vmstate = {VMSTATE_UINT8 (len, PCA955xState),VMSTATE_UINT8 (pointer, PCA955xState),VMSTATE_UINT8_ARRAY (regs, PCA955xState,PCA955X_NR_REGS ), +VMSTATE_UINT8_ARRAY (ext_state, PCA955xState,PCA955X_PIN_COUNT_MAX ),VMSTATE_I2C_SLAVE (i2c, PCA955xState), VMSTATE_END_OF_LIST() }
@@ -358,6 +372,7 @@ static void pca9552_reset(DeviceState *dev) s->regs[PCA9552_LS2 ] =0x55 ; s->regs[PCA9552_LS3 ] =0x55 ; +memset (s->ext_state,PCA9552_PIN_HIZ ,PCA955X_PIN_COUNT_MAX );pca955x_update_pin_input (s); s->pointer =0xFF ;
@@ -380,6 +395,26 @@ static void pca955x_initfn(Object *obj) } } +static void pca955x_set_ext_state (PCA955xState *s,int pin,int level) +{ +if (s->ext_state[pin] != level) { +uint16_t pins_status =pca955x_pins_get_status (s); + s->ext_state[pin] = level; +pca955x_update_pin_input (s); +pca955x_display_pins_status (s, pins_status); + } +} + +static void pca955x_gpio_in_handler (void *opaque,int pin,int level) +{ + +PCA955xState *s =PCA955X (opaque); +PCA955xClass *k =PCA955X_GET_CLASS (s); + +assert ((pin >=0 ) && (pin < k->pin_count)); +pca955x_set_ext_state (s, pin, level); +} +static void pca955x_realize (DeviceState *dev,Error **errp) {PCA955xClass *k =PCA955X_GET_CLASS (dev);
@@ -389,7 +424,8 @@ static void pca955x_realize(DeviceState *dev, Error **errp) s->description =g_strdup ("pca-unspecified" ); } -qdev_init_gpio_out (dev, s->gpio, k->pin_count); +qdev_init_gpio_out (dev, s->gpio_out, k->pin_count); +qdev_init_gpio_in (dev, pca955x_gpio_in_handler, k->pin_count); }static Property pca955x_properties[] = {
include/hw/misc/pca9552.h +2 -1
@@ -30,7 +30,8 @@ struct PCA955xState {uint8_t pointer;uint8_t regs[PCA955X_NR_REGS ]; -qemu_irq gpio[PCA955X_PIN_COUNT_MAX ]; +qemu_irq gpio_out[PCA955X_PIN_COUNT_MAX ]; +uint8_t ext_state[PCA955X_PIN_COUNT_MAX ];char *description;/* For debugging purpose only */ };
Signature · 1 line
2.31.1
PATCH v4 3/11 ppc/pnv: New powernv10-rainier machine type
In reply to Glenn MilesCreate a new powernv machine type, powernv10-rainier, that will contain rainier-specific devices.
--- hw/ppc/pnv.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)
hw/ppc/pnv.c +27 -2
@@ -2249,7 +2249,7 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } -static void pnv_machine_power10_class_init (ObjectClass *oc,void *data) +static void pnv_machine_p10_common_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);PnvMachineClass *pmc =PNV_MACHINE_CLASS (oc);
@@ -2261,7 +2261,6 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) { TYPE_PNV_PHB_ROOT_PORT, "version", "5" }, }; - mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("power10_v2.0" );compat_props_add (mc->compat_props, phb_compat,G_N_ELEMENTS (phb_compat));
@@ -2274,6 +2273,23 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } +static void pnv_machine_power10_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; + +} + +static void pnv_machine_p10_rainier_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10 rainier" ; +} +static bool pnv_machine_get_hb (Object *obj,Error **errp) {PnvMachineState *pnv =PNV_MACHINE (obj);
@@ -2379,6 +2395,15 @@ static void pnv_machine_class_init(ObjectClass *oc, void *data) }static const TypeInfo types[] = { + { + .name =MACHINE_TYPE_NAME ("powernv10-rainier" ), + .parent =TYPE_PNV_MACHINE , + .class_init = pnv_machine_p10_rainier_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_XIVE_FABRIC }, + { }, + }, + }, { .name =MACHINE_TYPE_NAME ("powernv10" ), .parent =TYPE_PNV_MACHINE ,
Signature · 1 line
2.31.1
Re: [PATCH v4 03/11] ppc/pnv: New powernv10-rainier machine type
Quoted 2 lines · Glenn Miles
Create a new powernv machine type, powernv10-rainier, that will contain rainier-specific devices.
Is the plan to have a base powernv10 common to all and then powernv10-rainier looks like a Rainier? Or would powernv10 just be a rainier?
It's fine to structure code this way, I'm just wondering about the machine types available to user. Is a base powernv10 machine useful to run?
Thanks,
Nick
Quoted 67 lines
Signed-off-by Glenn Miles <[email protected]>--- hw/ppc/pnv.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)hw/ppc/pnv.c +27
-2@@ -2249,7 +2249,7 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } -static void pnv_machine_power10_class_init (ObjectClass *oc,void *data) +static void pnv_machine_p10_common_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);PnvMachineClass *pmc =PNV_MACHINE_CLASS (oc);@@ -2261,7 +2261,6 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) { TYPE_PNV_PHB_ROOT_PORT, "version", "5" }, }; - mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("power10_v2.0" );compat_props_add (mc->compat_props, phb_compat,G_N_ELEMENTS (phb_compat));@@ -2274,6 +2273,23 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } +static void pnv_machine_power10_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; + +} + +static void pnv_machine_p10_rainier_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10 rainier" ; +} +static bool pnv_machine_get_hb (Object *obj,Error **errp) {PnvMachineState *pnv =PNV_MACHINE (obj);@@ -2379,6 +2395,15 @@ static void pnv_machine_class_init(ObjectClass *oc, void *data) }static const TypeInfo types[] = { + { + .name =MACHINE_TYPE_NAME ("powernv10-rainier" ), + .parent =TYPE_PNV_MACHINE , + .class_init = pnv_machine_p10_rainier_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_XIVE_FABRIC }, + { }, + }, + }, { .name =MACHINE_TYPE_NAME ("powernv10" ), .parent =TYPE_PNV_MACHINE ,
Re: [PATCH v4 03/11] ppc/pnv: New powernv10-rainier machine type
Quoted 11 lines · Nicholas Piggin
Quoted 2 lines · Glenn Miles
Create a new powernv machine type, powernv10-rainier, that will contain rainier-specific devices.
Is the plan to have a base powernv10 common to all and then powernv10-rainier looks like a Rainier? Or would powernv10 just be a rainier?
It's fine to structure code this way, I'm just wondering about the machine types available to user. Is a base powernv10 machine useful to run?
There are multiple P10 boards defined in Linux :
aspeed-bmc-ibm-bonnell.dts
aspeed-bmc-ibm-everest.dts
aspeed-bmc-ibm-rainier-1s4u.dts
aspeed-bmc-ibm-rainier-4u.dts
aspeed-bmc-ibm-rainier.dts
and we could model the machines above with a fixed number of sockets. The "powernv10" would be the generic system that can be customized at will on the command line, even I2C devices. There is also the P10 Denali which is FSP based. This QEMU machine would certainly be very different. I thought of doing the same for P9 with a -zaius and include NPU2 models for it. I lacked time and the interest was small at the time of OpenPOWER.
Anyhow, adding a new machine makes sense and it prepares ground for possible new ones. I am OK with or without. As primary users, you are the ones that can tell if there will be a second machine.
Thanks,
C.
Quoted 69 lines
Quoted 68 lines
Signed-off-by Glenn Miles <[email protected]>--- hw/ppc/pnv.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)hw/ppc/pnv.c +27
-2@@ -2249,7 +2249,7 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } -static void pnv_machine_power10_class_init (ObjectClass *oc,void *data) +static void pnv_machine_p10_common_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);PnvMachineClass *pmc =PNV_MACHINE_CLASS (oc);@@ -2261,7 +2261,6 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) { TYPE_PNV_PHB_ROOT_PORT, "version", "5" }, }; - mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("power10_v2.0" );compat_props_add (mc->compat_props, phb_compat,G_N_ELEMENTS (phb_compat));@@ -2274,6 +2273,23 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } +static void pnv_machine_power10_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; + +} + +static void pnv_machine_p10_rainier_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10 rainier" ; +} +static bool pnv_machine_get_hb (Object *obj,Error **errp) {PnvMachineState *pnv =PNV_MACHINE (obj);@@ -2379,6 +2395,15 @@ static void pnv_machine_class_init(ObjectClass *oc, void *data) }static const TypeInfo types[] = { + { + .name =MACHINE_TYPE_NAME ("powernv10-rainier" ), + .parent =TYPE_PNV_MACHINE , + .class_init = pnv_machine_p10_rainier_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_XIVE_FABRIC }, + { }, + }, + }, { .name =MACHINE_TYPE_NAME ("powernv10" ), .parent =TYPE_PNV_MACHINE ,
Re: [PATCH v4 03/11] ppc/pnv: New powernv10-rainier machine type
Quoted 29 lines · Cédric Le Goater
Quoted 11 lines · Nicholas Piggin
Quoted 2 lines · Glenn Miles
Create a new powernv machine type, powernv10-rainier, that will contain rainier-specific devices.
Is the plan to have a base powernv10 common to all and then powernv10-rainier looks like a Rainier? Or would powernv10 just be a rainier?
It's fine to structure code this way, I'm just wondering about the machine types available to user. Is a base powernv10 machine useful to run?
There are multiple P10 boards defined in Linux :
aspeed-bmc-ibm-bonnell.dts
aspeed-bmc-ibm-everest.dts
aspeed-bmc-ibm-rainier-1s4u.dts
aspeed-bmc-ibm-rainier-4u.dts
aspeed-bmc-ibm-rainier.dtsand we could model the machines above with a fixed number of sockets. The "powernv10" would be the generic system that can be customized at will on the command line, even I2C devices. There is also the P10 Denali which is FSP based. This QEMU machine would certainly be very different. I thought of doing the same for P9 with a -zaius and include NPU2 models for it. I lacked time and the interest was small at the time of OpenPOWER.
Quoted 8 lines
Anyhow, adding a new machine makes sense and it prepares ground for possible new ones. I am OK with or without. As primary users, you are the ones that can tell if there will be a second machine.
Thanks,
C.
I am not sure what the powernv10 machine would be used for. The only reason I kept it was because I didn't want to break anyone out there that might be using it.
My preference would have been to just make powernv10-rainier an alias of the powernv10 machine, but only one alias name per machine is supported and there is already a plan to make "powernv" an alias for the powernv10 machine.
Thanks,
Glenn
Quoted 77 lines
Quoted 77 lines
Quoted 77 lines
Signed-off-by Glenn Miles <[email protected]>--- hw/ppc/pnv.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)hw/ppc/pnv.c +1
-1@@ -2249,7 +2249,7 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } -static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) +static void pnv_machine_p10_common_class_init (ObjectClass *oc,void *data){ MachineClass *mc = MACHINE_CLASS(oc); PnvMachineClass *pmc = PNV_MACHINE_CLASS(oc);hw/ppc/pnv.c +0
-1@@ -2261,7 +2261,6 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) { TYPE_PNV_PHB_ROOT_PORT, "version", "5" }, }; - mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("power10_v2.0" );compat_props_add(mc->compat_props, phb_compat,
G_N_ELEMENTS(phb_compat));hw/ppc/pnv.c +17
-0@@ -2274,6 +2273,23 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } +static void pnv_machine_power10_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; + +} + +static void pnv_machine_p10_rainier_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10 rainier" ; +} +static bool pnv_machine_get_hb(Object *obj, Error **errp) { PnvMachineState *pnv = PNV_MACHINE(obj);hw/ppc/pnv.c +9
-0@@ -2379,6 +2395,15 @@ static void pnv_machine_class_init(ObjectClass *oc, void *data) }static const TypeInfo types[] = { + { + .name =MACHINE_TYPE_NAME ("powernv10-rainier" ), + .parent =TYPE_PNV_MACHINE , + .class_init = pnv_machine_p10_rainier_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_XIVE_FABRIC }, + { }, + }, + }, { .name =MACHINE_TYPE_NAME ("powernv10" ),.parent =
TYPE_PNV_MACHINE,
Re: [PATCH v4 03/11] ppc/pnv: New powernv10-rainier machine type
Quoted 34 lines · Miles Glenn
Quoted 33 lines · Cédric Le Goater
Quoted 11 lines · Nicholas Piggin
Quoted 2 lines · Glenn Miles
Create a new powernv machine type, powernv10-rainier, that will contain rainier-specific devices.
Is the plan to have a base powernv10 common to all and then powernv10-rainier looks like a Rainier? Or would powernv10 just be a rainier?
It's fine to structure code this way, I'm just wondering about the machine types available to user. Is a base powernv10 machine useful to run?
There are multiple P10 boards defined in Linux :
aspeed-bmc-ibm-bonnell.dts
aspeed-bmc-ibm-everest.dts
aspeed-bmc-ibm-rainier-1s4u.dts
aspeed-bmc-ibm-rainier-4u.dts
aspeed-bmc-ibm-rainier.dtsand we could model the machines above with a fixed number of sockets. The "powernv10" would be the generic system that can be customized at will on the command line, even I2C devices. There is also the P10 Denali which is FSP based. This QEMU machine would certainly be very different. I thought of doing the same for P9 with a -zaius and include NPU2 models for it. I lacked time and the interest was small at the time of OpenPOWER.
Anyhow, adding a new machine makes sense and it prepares ground for possible new ones. I am OK with or without. As primary users, you are the ones that can tell if there will be a second machine.
Quoted 6 lines
Quoted 4 lines
Thanks,
C.
I am not sure what the powernv10 machine would be used for.
This would be an empty board with only POWER10 processors, no platform devices.
Thanks,
C.
Quoted 91 lines
The
only reason I kept it was because I didn't want to break anyone out there that might be using it.My preference would have been to just make powernv10-rainier an alias of the powernv10 machine, but only one alias name per machine is supported and there is already a plan to make "powernv" an alias for the powernv10 machine.
Thanks,
Glenn
Quoted 77 lines
Quoted 77 lines
Quoted 77 lines
Signed-off-by Glenn Miles <[email protected]>--- hw/ppc/pnv.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)hw/ppc/pnv.c +1
-1@@ -2249,7 +2249,7 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } -static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) +static void pnv_machine_p10_common_class_init (ObjectClass *oc,void *data){ MachineClass *mc = MACHINE_CLASS(oc); PnvMachineClass *pmc = PNV_MACHINE_CLASS(oc);hw/ppc/pnv.c +0
-1@@ -2261,7 +2261,6 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) { TYPE_PNV_PHB_ROOT_PORT, "version", "5" }, }; - mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("power10_v2.0" );compat_props_add(mc->compat_props, phb_compat,
G_N_ELEMENTS(phb_compat));hw/ppc/pnv.c +17
-0@@ -2274,6 +2273,23 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } +static void pnv_machine_power10_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; + +} + +static void pnv_machine_p10_rainier_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10 rainier" ; +} +static bool pnv_machine_get_hb(Object *obj, Error **errp) { PnvMachineState *pnv = PNV_MACHINE(obj);hw/ppc/pnv.c +9
-0@@ -2379,6 +2395,15 @@ static void pnv_machine_class_init(ObjectClass *oc, void *data) }static const TypeInfo types[] = { + { + .name =MACHINE_TYPE_NAME ("powernv10-rainier" ), + .parent =TYPE_PNV_MACHINE , + .class_init = pnv_machine_p10_rainier_class_init, + .interfaces = (InterfaceInfo []) { + {TYPE_XIVE_FABRIC }, + { }, + }, + }, { .name =MACHINE_TYPE_NAME ("powernv10" ),.parent =
TYPE_PNV_MACHINE,
Re: [PATCH v4 03/11] ppc/pnv: New powernv10-rainier machine type
In reply to Miles GlennQuoted 34 lines · Miles Glenn
Quoted 33 lines · Cédric Le Goater
Quoted 11 lines · Nicholas Piggin
Quoted 2 lines · Glenn Miles
Create a new powernv machine type, powernv10-rainier, that will contain rainier-specific devices.
Is the plan to have a base powernv10 common to all and then powernv10-rainier looks like a Rainier? Or would powernv10 just be a rainier?
It's fine to structure code this way, I'm just wondering about the machine types available to user. Is a base powernv10 machine useful to run?
There are multiple P10 boards defined in Linux :
aspeed-bmc-ibm-bonnell.dts
aspeed-bmc-ibm-everest.dts
aspeed-bmc-ibm-rainier-1s4u.dts
aspeed-bmc-ibm-rainier-4u.dts
aspeed-bmc-ibm-rainier.dtsand we could model the machines above with a fixed number of sockets. The "powernv10" would be the generic system that can be customized at will on the command line, even I2C devices. There is also the P10 Denali which is FSP based. This QEMU machine would certainly be very different. I thought of doing the same for P9 with a -zaius and include NPU2 models for it. I lacked time and the interest was small at the time of OpenPOWER.
Anyhow, adding a new machine makes sense and it prepares ground for possible new ones. I am OK with or without. As primary users, you are the ones that can tell if there will be a second machine.
Quoted 8 lines
Quoted 4 lines
Thanks,
C.
I am not sure what the powernv10 machine would be used for. The only reason I kept it was because I didn't want to break anyone out there that might be using it.
(previous email sent to fast)
You would need to go through the deprecation process [1] if you want to remove the machine. I suggest keeping it for now since it is two lines of type definition.
Quoted 4 lines
My preference would have been to just make powernv10-rainier an alias of the powernv10 machine, but only one alias name per machine is supported and there is already a plan to make "powernv" an alias for the powernv10 machine.
yes. It might be time now for PowerNV and pSeries to update the default processor. Let's address that in the QEMU 9.0 cycle.
Thanks,
C.
[1] https://qemu.readthedocs.io/en/v8.1.0/about/deprecated.html
Re: [PATCH v4 03/11] ppc/pnv: New powernv10-rainier machine type
Quoted 47 lines · Cédric Le Goater
Quoted 46 lines · Miles Glenn
Quoted 44 lines · Cédric Le Goater
Quoted 4 lines · Nicholas Piggin
Quoted 2 lines · Glenn Miles
Create a new powernv machine type, powernv10-rainier, that will contain rainier-specific devices.
Quoted 8 lines
Is the plan to have a base powernv10 common to all and then powernv10-rainier looks like a Rainier? Or would powernv10 just be a rainier?
It's fine to structure code this way, I'm just wondering about the machine types available to user. Is a base powernv10 machine
useful to run?There are multiple P10 boards defined in Linux :
aspeed-bmc-ibm-bonnell.dts
aspeed-bmc-ibm-everest.dts
aspeed-bmc-ibm-rainier-1s4u.dts
aspeed-bmc-ibm-rainier-4u.dts
aspeed-bmc-ibm-rainier.dtsand we could model the machines above with a fixed number of sockets.
The "powernv10" would be the generic system that can be customized
at will on the command line, even I2C devices. There is also the P10 Denali which is FSP based. This QEMU machine would certainly be
very different. I thought of doing the same for P9 with a -zaius and include NPU2 models for it. I lacked time and the interest was
small at the time of OpenPOWER.Anyhow, adding a new machine makes sense and it prepares ground for
possible new ones. I am OK with or without. As primary users, you are
the ones that can tell if there will be a second machine.Thanks,
C.
Quoted 9 lines
Quoted 3 lines
I am not sure what the powernv10 machine would be used for. The only reason I kept it was because I didn't want to break anyone out there that might be using it.
(previous email sent to fast)
You would need to go through the deprecation process [1] if you want to remove the machine. I suggest keeping it for now since it is two lines of type definition.
Yes, I agree.
Quoted 5 lines
Quoted 4 lines
My preference would have been to just make powernv10-rainier an alias of the powernv10 machine, but only one alias name per machine is supported and there is already a plan to make "powernv" an alias for the powernv10 machine.
Quoted 9 lines
yes. It might be time now for PowerNV and pSeries to update the default processor. Let's address that in the QEMU 9.0 cycle.
Thanks,
C.
[1] https://qemu.readthedocs.io/en/v8.1.0/about/deprecated.html
Sounds good, thanks!
Glenn
Re: [PATCH v4 03/11] ppc/pnv: New powernv10-rainier machine type
In reply to Cédric Le GoaterQuoted 21 lines · Cédric Le Goater
Quoted 11 lines · Nicholas Piggin
Quoted 2 lines · Glenn Miles
Create a new powernv machine type, powernv10-rainier, that will contain rainier-specific devices.
Is the plan to have a base powernv10 common to all and then powernv10-rainier looks like a Rainier? Or would powernv10 just be a rainier?
It's fine to structure code this way, I'm just wondering about the machine types available to user. Is a base powernv10 machine useful to run?
There are multiple P10 boards defined in Linux :
aspeed-bmc-ibm-bonnell.dts
aspeed-bmc-ibm-everest.dts
aspeed-bmc-ibm-rainier-1s4u.dts
aspeed-bmc-ibm-rainier-4u.dts
aspeed-bmc-ibm-rainier.dts
Quoted 3 lines
and we could model the machines above with a fixed number of sockets. The "powernv10" would be the generic system that can be customized at will on the command line, even I2C devices.
If a bare qemu machine could be useful, I don't have a problem with it. I'm more thinking of what an average OPAL/PowerNV Linux user developer would want, they (I) would probably want to use powernv, powernv9, or powernv10, and just get a reasonable "realistic" machine.
The bare system could be powernv10-generic or powernv10-minimal for those who know what they're doing.
Quoted 9 lines
There is also the
P10 Denali which is FSP based. This QEMU machine would certainly be very different. I thought of doing the same for P9 with a -zaius and include NPU2 models for it. I lacked time and the interest was small at the time of OpenPOWER.Anyhow, adding a new machine makes sense and it prepares ground for possible new ones. I am OK with or without. As primary users, you are the ones that can tell if there will be a second machine.
Yeah we will want to add other machines at some point, I think this does make sense, my only real concern is what we call them.
Thanks,
Nick
Re: [PATCH v4 03/11] ppc/pnv: New powernv10-rainier machine type
In reply to Glenn MilesQuoted 22 lines · Glenn Miles
Create a new powernv machine type, powernv10-rainier, that will contain rainier-specific devices.
Signed-off-by Glenn Miles <[email protected]>--- hw/ppc/pnv.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)hw/ppc/pnv.c +1
-1@@ -2249,7 +2249,7 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } -static void pnv_machine_power10_class_init (ObjectClass *oc,void *data) +static void pnv_machine_p10_common_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc);PnvMachineClass *pmc =PNV_MACHINE_CLASS (oc);
hw/ppc/pnv.c static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) · line 2264
Quoted 4 lines
hw/ppc/pnv.c +0
-1@@ -2261,7 +2261,6 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) { TYPE_PNV_PHB_ROOT_PORT, "version", "5" }, }; - mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ;
I would keep this description because the "powernv10" machine still can be used, without I2C devices. Unless we don't want to ?
Quoted 4 lines
hw/ppc/pnv.c +0
-0mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("power10_v2.0" );compat_props_add (mc->compat_props, phb_compat,G_N_ELEMENTS (phb_compat));
hw/ppc/pnv.c static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) · line 2282
Quoted 10 lines
hw/ppc/pnv.c +7
-0@@ -2274,6 +2273,23 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } +static void pnv_machine_power10_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; +
Superfluous white line.
Quoted 14 lines
hw/ppc/pnv.c +10
-0+} + +static void pnv_machine_p10_rainier_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10 rainier" ; +} +static bool pnv_machine_get_hb (Object *obj,Error **errp) {PnvMachineState *pnv =PNV_MACHINE (obj);
hw/ppc/pnv.c static void pnv_machine_class_init(ObjectClass *oc, void *data) · line 2400
Quoted 6 lines
hw/ppc/pnv.c +3
-0@@ -2379,6 +2395,15 @@ static void pnv_machine_class_init(ObjectClass *oc, void *data) }static const TypeInfo types[] = { + { + .name =MACHINE_TYPE_NAME ("powernv10-rainier" ), + .parent =TYPE_PNV_MACHINE ,
Could the parent be :
.parent = MACHINE_TYPE_NAME("powernv10"),
This should avoid the definition of the .interfaces below.
Thanks,
C.
Quoted 9 lines
hw/ppc/pnv.c +6
-0+ .class_init = pnv_machine_p10_rainier_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_XIVE_FABRIC }, + { }, + }, + }, { .name = MACHINE_TYPE_NAME("powernv10"), .parent = TYPE_PNV_MACHINE,
Re: [PATCH v4 03/11] ppc/pnv: New powernv10-rainier machine type
Quoted 30 lines · Cédric Le Goater
Quoted 29 lines · Glenn Miles
Create a new powernv machine type, powernv10-rainier, that will contain rainier-specific devices.
Signed-off-by Glenn Miles <[email protected]>--- hw/ppc/pnv.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-)hw/ppc/pnv.c +1
-1@@ -2249,7 +2249,7 @@ static void pnv_machine_power9_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); } -static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) +static void pnv_machine_p10_common_class_init (ObjectClass *oc,void *data){ MachineClass *mc = MACHINE_CLASS(oc); PnvMachineClass *pmc = PNV_MACHINE_CLASS(oc);hw/ppc/pnv.c +0
-0@@ -2261,7 +2261,6 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) { TYPE_PNV_PHB_ROOT_PORT, "version", "5" }, };
Quoted 6 lines
hw/ppc/pnv.c static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) · line 2264
Quoted 1 line
hw/ppc/pnv.c +0
-1- mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ;I would keep this description because the "powernv10" machine still can
be used, without I2C devices. Unless we don't want to ?
I'm not sure about the usefulness of the powernv10 machine, but the description still exists in the pnv_machine_power10_class_init function (and is unchanged). The pnv_machine_p10_common_class_init function was created to hold initialization of things that are common between all P10 machines, and is called by all power10 based machines (powernv10 and powernv10-rainier so far).
Quoted 9 lines
Quoted 9 lines
hw/ppc/pnv.c +0
-0mc->default_cpu_type =POWERPC_CPU_TYPE_NAME ("power10_v2.0" ); compat_props_add(mc->compat_props, phb_compat,
G_N_ELEMENTS(phb_compat));hw/ppc/pnv.c +0
-0@@ -2274,6 +2273,23 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)machine_class_allow_dynamic_sysbus_dev (mc,TYPE_PNV_PHB ); }
Quoted 11 lines
hw/ppc/pnv.c static void pnv_machine_power10_class_init(ObjectClass *oc, void *data) · line 2282
Quoted 8 lines
hw/ppc/pnv.c +7
-0+static void pnv_machine_power10_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10" ; +Superfluous white line.
Removed in v5.
Quoted 25 lines
Quoted 15 lines
hw/ppc/pnv.c +10
-0+} + +static void pnv_machine_p10_rainier_class_init (ObjectClass *oc,void *data) +{ +MachineClass *mc =MACHINE_CLASS (oc); + +pnv_machine_p10_common_class_init (oc, data); + mc->desc ="IBM PowerNV (Non-Virtualized) POWER10 rainier" ; +} +static bool pnv_machine_get_hb(Object *obj, Error **errp) { PnvMachineState *pnv = PNV_MACHINE(obj);hw/ppc/pnv.c static void · line 2401
Quoted 7 lines
hw/ppc/pnv.c +3
-0@@ -2379,6 +2395,15 @@ static void pnv_machine_class_init(ObjectClass *oc, void *data) }static const TypeInfo types[] = { + { + .name =MACHINE_TYPE_NAME ("powernv10-rainier" ), + .parent =TYPE_PNV_MACHINE ,Could the parent be :
Quoted 8 lines
.parent =
MACHINE_TYPE_NAME("powernv10"),This should avoid the definition of the .interfaces below.
Thanks,
C.
Changed as suggested in v5.
Thanks,
Glenn
Quoted 11 lines
Quoted 11 lines
hw/ppc/pnv.c +6
-0+ .class_init = pnv_machine_p10_rainier_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_XIVE_FABRIC }, + { }, + }, + }, { .name = MACHINE_TYPE_NAME("powernv10"),.parent =
TYPE_PNV_MACHINE,
PATCH v4 4/11 ppc/pnv: Add pca9552 to powernv10-rainier for PCIe hotplug power control
In reply to Glenn MilesThe 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.
---
Changes from previous version:
- Code moved from pnv_chip_power10_realize to pnv_rainier_i2c_init
hw/ppc/Kconfig | 1 + hw/ppc/pnv.c | 26 ++++++++++++++++++++++++++ include/hw/ppc/pnv.h | 1 + 3 files changed, 28 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 +26 -0
@@ -790,6 +790,7 @@ static void pnv_init(MachineState *machine)const char *bios_name = machine->firmware ?:FW_FILE_NAME ;PnvMachineState *pnv =PNV_MACHINE (machine);MachineClass *mc =MACHINE_GET_CLASS (machine); +PnvMachineClass *pmc =PNV_MACHINE_GET_CLASS (machine);char *fw_filename;long fw_size;uint64_t chip_ram_start =0 ;
@@ -979,6 +980,13 @@ static void pnv_init(MachineState *machine)*/ pnv->powerdown_notifier.notify = pnv_powerdown_notify;qemu_register_powerdown_notifier (&pnv->powerdown_notifier); + +/* +* Create/Connect any machine-specific I2C devices +*/ +if (pmc->i2c_init) { + pmc->i2c_init (pnv); + } }/*
@@ -1877,6 +1885,22 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)qdev_get_gpio_in (DEVICE (&chip10->psi), PSIHB9_IRQ_SBE_I2C)); } + +} + +static void pnv_rainier_i2c_init (PnvMachineState *pnv) +{ +int i; +for (i =0 ; i < pnv->num_chips; i++) { +Pnv10Chip *chip10 =PNV10_CHIP (pnv->chips[i]); + +/* +* 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)
@@ -2285,9 +2309,11 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)static void pnv_machine_p10_rainier_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PnvMachineClass *pmc =PNV_MACHINE_CLASS (oc);pnv_machine_p10_common_class_init (oc, data); mc->desc ="IBM PowerNV (Non-Virtualized) POWER10 rainier" ; + pmc->i2c_init = pnv_rainier_i2c_init; }static bool pnv_machine_get_hb (Object *obj,Error **errp)
include/hw/ppc/pnv.h +1 -0
@@ -76,6 +76,7 @@ struct PnvMachineClass {int compat_size;void (*dt_power_mgt)(PnvMachineState *pnv,void *fdt); +void (*i2c_init)(PnvMachineState *pnv); };struct PnvMachineState {
Signature · 1 line
2.31.1
Re: [PATCH v4 04/11] ppc/pnv: Add pca9552 to powernv10-rainier for PCIe hotplug power control
Quoted 63 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]>---
Changes from previous version:
- Code moved frompnv_chip_power10_realizetopnv_rainier_i2c_inithw/ppc/Kconfig | 1 + hw/ppc/pnv.c | 26 ++++++++++++++++++++++++++ include/hw/ppc/pnv.h | 1 + 3 files changed, 28 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 +13
-0@@ -790,6 +790,7 @@ static void pnv_init(MachineState *machine)const char *bios_name = machine->firmware ?:FW_FILE_NAME ;PnvMachineState *pnv =PNV_MACHINE (machine);MachineClass *mc =MACHINE_GET_CLASS (machine); +PnvMachineClass *pmc =PNV_MACHINE_GET_CLASS (machine);char *fw_filename;long fw_size;uint64_t chip_ram_start =0 ;@@ -979,6 +980,13 @@ static void pnv_init(MachineState *machine)*/ pnv->powerdown_notifier.notify = pnv_powerdown_notify;qemu_register_powerdown_notifier (&pnv->powerdown_notifier); + +/* +* Create/Connect any machine-specific I2C devices +*/ +if (pmc->i2c_init) { + pmc->i2c_init (pnv); + } }/* @@ -1877,6 +1885,22 @@ static void pnv_chip_power10_realize(DeviceState *dev, Error **errp)qdev_get_gpio_in (DEVICE (&chip10->psi), PSIHB9_IRQ_SBE_I2C)); } + +} + +static void pnv_rainier_i2c_init (PnvMachineState *pnv) +{
hw/ppc/pnv.c static void pnv_chip_power10_realize(DeviceState *dev, Error **errp) · line 1902
Quoted 10 lines
hw/ppc/pnv.c +10
-0+int i; +for (i =0 ; i < pnv->num_chips; i++) { +Pnv10Chip *chip10 =PNV10_CHIP (pnv->chips[i]); + +/* +* 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 );
This could fit on one line.
The rest looks good.
Thanks,
C.
Quoted 28 lines
hw/ppc/pnv.c +3
-0+ } }static uint32_t pnv_chip_power10_xscom_pcba (PnvChip *chip,uint64_t addr)@@ -2285,9 +2309,11 @@ static void pnv_machine_power10_class_init(ObjectClass *oc, void *data)static void pnv_machine_p10_rainier_class_init (ObjectClass *oc,void *data) {MachineClass *mc =MACHINE_CLASS (oc); +PnvMachineClass *pmc =PNV_MACHINE_CLASS (oc);pnv_machine_p10_common_class_init (oc, data); mc->desc ="IBM PowerNV (Non-Virtualized) POWER10 rainier" ; + pmc->i2c_init = pnv_rainier_i2c_init; }static bool pnv_machine_get_hb (Object *obj,Error **errp)include/hw/ppc/pnv.h +1
-0@@ -76,6 +76,7 @@ struct PnvMachineClass {int compat_size;void (*dt_power_mgt)(PnvMachineState *pnv,void *fdt); +void (*i2c_init)(PnvMachineState *pnv); };struct PnvMachineState {
PATCH v4 5/11 ppc/pnv: Wire up pca9552 GPIO pins for PCIe hotplug power control
In reply to Glenn MilesFor power10-rainier, 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:
- Code moved from pnv_chip_power10_realize to pnv_rainier_i2c_init
hw/ppc/pnv.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
hw/ppc/pnv.c +18 -2
@@ -1898,8 +1898,24 @@ static void pnv_rainier_i2c_init(PnvMachineState *pnv)* 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
Re: [PATCH v4 05/11] ppc/pnv: Wire up pca9552 GPIO pins for PCIe hotplug power control
Quoted 5 lines · Glenn Miles
For power10-rainier, 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.
And this is what OPAL is not doing :
https://github.com/open-power/skiboot/blob/master/platforms/astbmc/rainier.c#L65
Correct ?
Quoted 32 lines
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 theSLOTx_PGpin 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 theSLOTx_ENoutput.
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.Signed-off-by Glenn Miles <[email protected]>---
Changes from previous version:
- Code moved frompnv_chip_power10_realizetopnv_rainier_i2c_inithw/ppc/pnv.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)hw/ppc/pnv.c +0
-0
hw/ppc/pnv.c static void pnv_rainier_i2c_init(PnvMachineState *pnv) · line 1902
Quoted 7 lines
hw/ppc/pnv.c +2
-2@@ -1898,8 +1898,24 @@ static void pnv_rainier_i2c_init(PnvMachineState *pnv)* 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 );
hotplug ? why not dev simply ?
Thanks,
C.
Quoted 19 lines
hw/ppc/pnv.c +16
-0+ +/* +* 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 )); } }
Re: [PATCH v4 05/11] ppc/pnv: Wire up pca9552 GPIO pins for PCIe hotplug power control
Quoted 8 lines · Cédric Le Goater
Quoted 6 lines · Glenn Miles
For power10-rainier, 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.
Quoted 7 lines
And this is what OPAL is not doing :
https://github.com/open-power/skiboot/blob/master/platforms/astbmc/rainier.c#L65
Correct ?
Ah, yes, I believe you are correct!
Quoted 41 lines
Quoted 41 lines
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 theSLOTx_PGpin 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 theSLOTx_ENoutput.
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.Signed-off-by Glenn Miles <[email protected]>---
Changes from previous version:
- Code moved frompnv_chip_power10_realizetopnv_rainier_i2c_inithw/ppc/pnv.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)hw/ppc/pnv.c +1
-2@@ -1898,8 +1898,24 @@ static voidpnv_rainier_i2c_init(PnvMachineState *pnv) * 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],
Quoted 10 lines
hw/ppc/pnv.c static void pnv_rainier_i2c_init(PnvMachineState *pnv) · line 1902
Quoted 1 line
hw/ppc/pnv.c +1
-0+ "pca9552", 0x63);hotplug ? why not dev simply ?
Thanks,
C.
Sure, dev is fine. I'll change it.
Thanks,
Glenn
Quoted 27 lines
Quoted 27 lines
hw/ppc/pnv.c +3
-0+ +/* +* 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 slotshw/ppc/pnv.c +4
-0+* after hypervisor code sets a SLOTx_EN pin high. +*/ + qdev_connect_gpio_out(DEVICE(hotplug), 0, + qdev_get_gpio_in(DEVICE(hotplug),5));
hw/ppc/pnv.c +2
-0+ qdev_connect_gpio_out(DEVICE(hotplug), 1, + qdev_get_gpio_in(DEVICE(hotplug),6));
hw/ppc/pnv.c +2
-0+ qdev_connect_gpio_out(DEVICE(hotplug), 2, + qdev_get_gpio_in(DEVICE(hotplug),7));
hw/ppc/pnv.c +2
-0+ qdev_connect_gpio_out(DEVICE(hotplug), 3, + qdev_get_gpio_in(DEVICE(hotplug),8));
hw/ppc/pnv.c +2
-0+ qdev_connect_gpio_out(DEVICE(hotplug), 4, + qdev_get_gpio_in(DEVICE(hotplug),9)); }}
Re: [PATCH v4 05/11] ppc/pnv: Wire up pca9552 GPIO pins for PCIe hotplug power control
Adding Reza.
Quoted 12 lines · Miles Glenn
Quoted 11 lines · Cédric Le Goater
Quoted 6 lines · Glenn Miles
For power10-rainier, 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.And this is what OPAL is not doing :
Quoted 6 lines
Quoted 4 lines
https://github.com/open-power/skiboot/blob/master/platforms/astbmc/rainier.c#L65
Correct ?
Ah, yes, I believe you are correct!
Thanks,
C.
PATCH v4 6/11 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.
---
No changes from previous version
hw/ppc/pnv.c | 6 ++++-- hw/ppc/pnv_i2c.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-)
hw/ppc/pnv.c +4 -2
@@ -1631,7 +1631,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),
@@ -1879,7 +1880,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 v4 06/11] ppc/pnv: PNV I2C engines assigned incorrect XSCOM addresses
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
Reviewed-by Cédric Le Goater <[email protected]>Fixes 1ceda19c28a1 ("ppc/pnv: Connect PNV I2C controller to powernv10)Signed-off-by Glenn Miles <[email protected]>---
No changes from previous version
This patch was merged upstream now.
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@@ -1631,7 +1631,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),@@ -1879,7 +1880,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 v4 7/11 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.
---
No changes from previous version
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 v4 07/11] ppc/pnv: Fix PNV I2C invalid status after reset
Quoted 8 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.
Quoted 6 lines
Reviewed-by Cédric Le Goater <[email protected]>Fixes 263b81ee15af ("ppc/pnv: Add an I2C controller model")Signed-off-by Glenn Miles <[email protected]>---
No changes from previous version
This patch was merged upstream now.
C.
Quoted 71 lines
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);
PATCH v4 8/11 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 previous version
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
Re: [PATCH v4 08/11] ppc/pnv: Use resettable interface to reset child I2C buses
Quoted 12 lines · 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.
Quoted 6 lines
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.
Signed-off-by Glenn Miles <[email protected]>---
Thanks,
C.
Quoted 39 lines
No changes from previous version
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 ); }
PATCH v4 9/11 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.
---
Changes from previous version:
- Makes myself maintainer of the pca955* models
MAINTAINERS | 10 +- hw/misc/pca9554.c | 328 +++++++++++++++++++++++++++++++++ include/hw/misc/pca9554.h | 36 ++++ include/hw/misc/pca9554_regs.h | 19 ++ 4 files changed, 391 insertions(+), 2 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
MAINTAINERS +8 -2
@@ -1138,9 +1138,7 @@ R: Joel Stanley <[email protected]> L: [email protected] S: Maintained F: hw/*/*aspeed* -F: hw/misc/pca9552.c F: include/hw/*/*aspeed* -F: include/hw/misc/pca9552*.h F: hw/net/ftgmac100.c F: include/hw/net/ftgmac100.h F: docs/system/arm/aspeed.rst
@@ -1509,6 +1507,14 @@ F: include/hw/pci-host/pnv* F: pc-bios/skiboot.lid F: tests/qtest/pnv* +pca955x +M: Glenn Miles <[email protected]> +L: [email protected] +L: [email protected] +S: Odd Fixes +F: hw/misc/pca955*.c +F: include/hw/misc/pca955*.h + virtex_ml507 M: Edgar E. Iglesias <[email protected]> L: [email protected]
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 v4 10/11 ppc/pnv: Add a pca9554 I2C device to powernv10-rainier
In reply to Glenn MilesFor powernv10-rainier, 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.
---
Changes from previous version:
- Code moved from pnv_chip_power10_realize to pnv_rainier_i2c_init
hw/misc/Kconfig | 4 ++++ hw/misc/meson.build | 1 + hw/ppc/Kconfig | 1 + hw/ppc/pnv.c | 6 ++++++ 4 files changed, 12 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 +6 -0
@@ -1918,6 +1918,12 @@ static void pnv_rainier_i2c_init(PnvMachineState *pnv) qdev_get_gpio_in(DEVICE(hotplug), 8));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 ); } }
Signature · 1 line
2.31.1
Re: [PATCH v4 10/11] ppc/pnv: Add a pca9554 I2C device to powernv10-rainier
Quoted 6 lines · Glenn Miles
For powernv10-rainier, 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 of0x4A). This is used by the hypervisor code to detect if a "Cable Card" is present.Signed-off-by Glenn Miles <[email protected]>
Thanks,
C.
Quoted 67 lines
---
Changes from previous version:
- Code moved frompnv_chip_power10_realizetopnv_rainier_i2c_inithw/misc/Kconfig | 4 ++++ hw/misc/meson.build | 1 + hw/ppc/Kconfig | 1 + hw/ppc/pnv.c | 6 ++++++ 4 files changed, 12 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_DEVICEShw/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 boolhw/ppc/pnv.c +6
-0@@ -1918,6 +1918,12 @@ static void pnv_rainier_i2c_init(PnvMachineState *pnv) qdev_get_gpio_in(DEVICE(hotplug), 8));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 ); } }
PATCH v4 11/11 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 powernv10-ranier 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:
- Changed test to target powernv10-rainier for power10
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