Skip to contentSkip to conversation

hw/gpio: Convert GPIO devices to Resettable interface

PATCH New Oscar Alejandro Sánchez Lucero 1 participant 13 messages Dec 2

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover hw/gpio: Convert GPIO devices to Resettable interface

Convert all remaining GPIO device models in hw/gpio away from the deprecated device_class_set_legacy_reset() wrapper to the ResettableClass interface (hold phase), moving towards removing the legacy_reset callback from DeviceClass once all callers are migrated (as noted in include/hw/core/qdev.h).

---
Oscar Alejandro Sánchez Lucero (12):
hw/gpio/allwinner-gpio: Convert to Resettable interface hw/gpio/bcm2835_gpio: Convert to Resettable interface hw/gpio/bcm2838_gpio: Convert to Resettable interface hw/gpio/cadence_gpio: Convert to Resettable interface hw/gpio/gpio_key: Convert to Resettable interface hw/gpio/imx_gpio: Convert to Resettable interface hw/gpio/mpc8xxx: Convert to Resettable interface hw/gpio/nrf51_gpio: Convert to Resettable interface hw/gpio/omap_gpio: Convert to Resettable interface hw/gpio/pca9554: Convert to Resettable interface hw/gpio/pcf8574: Convert to Resettable interface hw/gpio/sifive_gpio: Convert to Resettable interface

 hw/gpio/allwinner-gpio.c | 7 ++++---
 hw/gpio/bcm2835_gpio.c   | 7 ++++---
 hw/gpio/bcm2838_gpio.c   | 7 ++++---
 hw/gpio/cadence_gpio.c   | 7 ++++---
 hw/gpio/gpio_key.c       | 7 ++++---
 hw/gpio/imx_gpio.c       | 7 ++++---
 hw/gpio/mpc8xxx.c        | 7 ++++---
 hw/gpio/nrf51_gpio.c     | 7 ++++---
 hw/gpio/omap_gpio.c      | 7 ++++---
 hw/gpio/pca9554.c        | 7 ++++---
 hw/gpio/pcf8574.c        | 7 ++++---
 hw/gpio/sifive_gpio.c    | 7 ++++---
 12 files changed, 48 insertions(+), 36 deletions(-)

---
base-commit: bbece0805c03c25f51a8cd89c39142f4f76a6567
change-id: 20261202-gpio-resettable-48db03e05854

Best regards,

Signature · 1 line
Oscar Alejandro Sánchez Lucero <[email protected]>
#1 lore raw

PATCH 1/12 hw/gpio/allwinner-gpio: Convert to Resettable interface

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in allwinner_gpio_reset_hold().

---
 hw/gpio/allwinner-gpio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/allwinner-gpio.c +4 -3
index 19176e7..e995c35 100644
@@ -391,9 +391,9 @@ static const VMStateDescription vmstate_allwinner_gpio = {
     }
 };
 
-static void allwinner_gpio_reset(DeviceState *dev)
+static void allwinner_gpio_reset_hold(Object *obj, ResetType type)
 {
-    AWGPIOState *s = AW_GPIO(dev);
+    AWGPIOState *s = AW_GPIO(obj);
     AWPortsOverlay *o = (AWPortsOverlay *)s->regs;
 
     memset(s->regs, 0, AW_GPIO_IOSIZE);
@@ -428,9 +428,10 @@ static void allwinner_gpio_realize(DeviceState *dev, Error **errp)
 static void allwinner_gpio_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->realize = allwinner_gpio_realize;
-    device_class_set_legacy_reset(dc, allwinner_gpio_reset);
+    rc->phases.hold = allwinner_gpio_reset_hold;
     dc->vmsd = &vmstate_allwinner_gpio;
     dc->desc = "Allwinner GPIO controller";
 }
Signature · 1 line
2.53.0
#2 lore raw

PATCH 2/12 hw/gpio/bcm2835_gpio: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in bcm2835_gpio_reset_hold().

---
 hw/gpio/bcm2835_gpio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/bcm2835_gpio.c +4 -3
index d7c44ea..eb1f032 100644
@@ -256,9 +256,9 @@ err_out:
             __func__, offset);
 }
 
-static void bcm2835_gpio_reset(DeviceState *dev)
+static void bcm2835_gpio_reset_hold(Object *obj, ResetType type)
 {
-    BCM2835GpioState *s = BCM2835_GPIO(dev);
+    BCM2835GpioState *s = BCM2835_GPIO(obj);
 
     int i;
     for (i = 0; i < 6; i++) {
@@ -322,10 +322,11 @@ static void bcm2835_gpio_realize(DeviceState *dev, Error **errp)
 static void bcm2835_gpio_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->vmsd = &vmstate_bcm2835_gpio;
     dc->realize = &bcm2835_gpio_realize;
-    device_class_set_legacy_reset(dc, bcm2835_gpio_reset);
+    rc->phases.hold = bcm2835_gpio_reset_hold;
 }
 
 static const TypeInfo bcm2835_gpio_info = {
Signature · 1 line
2.53.0
#3 lore raw

PATCH 3/12 hw/gpio/bcm2838_gpio: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in bcm2838_gpio_reset_hold().

---
 hw/gpio/bcm2838_gpio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/bcm2838_gpio.c +4 -3
index 4ae7706..d02a3ca 100644
@@ -295,9 +295,9 @@ static void bcm2838_gpio_write(void *opaque, hwaddr offset, uint64_t value,
     }
 }
 
-static void bcm2838_gpio_reset(DeviceState *dev)
+static void bcm2838_gpio_reset_hold(Object *obj, ResetType type)
 {
-    BCM2838GpioState *s = BCM2838_GPIO(dev);
+    BCM2838GpioState *s = BCM2838_GPIO(obj);
 
     memset(s->fsel, 0, sizeof(s->fsel));
 
@@ -367,10 +367,11 @@ static void bcm2838_gpio_realize(DeviceState *dev, Error **errp)
 static void bcm2838_gpio_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->vmsd = &vmstate_bcm2838_gpio;
     dc->realize = &bcm2838_gpio_realize;
-    device_class_set_legacy_reset(dc, bcm2838_gpio_reset);
+    rc->phases.hold = bcm2838_gpio_reset_hold;
 }
 
 static const TypeInfo bcm2838_gpio_info = {
Signature · 1 line
2.53.0
#4 lore raw

PATCH 4/12 hw/gpio/cadence_gpio: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in cdns_gpio_reset_hold().

---
 hw/gpio/cadence_gpio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/cadence_gpio.c +4 -3
index ce8256b..da46872 100644
@@ -237,9 +237,9 @@ static const VMStateDescription vmstate_cdns_gpio = {
     }
 };
 
-static void cdns_gpio_reset(DeviceState *dev)
+static void cdns_gpio_reset_hold(Object *obj, ResetType type)
 {
-    CadenceGPIOState *s = CADENCE_GPIO(dev);
+    CadenceGPIOState *s = CADENCE_GPIO(obj);
 
     s->bmr      = 0;
     s->dmr      = 0;
@@ -270,8 +270,9 @@ static void cdns_gpio_init(Object *obj)
 static void cdns_gpio_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
-    device_class_set_legacy_reset(dc, cdns_gpio_reset);
+    rc->phases.hold = cdns_gpio_reset_hold;
     dc->vmsd = &vmstate_cdns_gpio;
     dc->desc = "Cadence GPIO controller";
 }
Signature · 1 line
2.53.0
#5 lore raw

PATCH 5/12 hw/gpio/gpio_key: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in gpio_key_reset_hold().

---
 hw/gpio/gpio_key.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/gpio_key.c +4 -3
index 14e0fb9..f7f1c31 100644
@@ -51,9 +51,9 @@ static const VMStateDescription vmstate_gpio_key = {
     }
 };
 
-static void gpio_key_reset(DeviceState *dev)
+static void gpio_key_reset_hold(Object *obj, ResetType type)
 {
-    GPIOKEYState *s = GPIOKEY(dev);
+    GPIOKEYState *s = GPIOKEY(obj);
 
     timer_del(s->timer);
 }
@@ -88,10 +88,11 @@ static void gpio_key_realize(DeviceState *dev, Error **errp)
 static void gpio_key_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->realize = gpio_key_realize;
     dc->vmsd = &vmstate_gpio_key;
-    device_class_set_legacy_reset(dc, gpio_key_reset);
+    rc->phases.hold = gpio_key_reset_hold;
 }
 
 static const TypeInfo gpio_key_info = {
Signature · 1 line
2.53.0
#6 lore raw

PATCH 6/12 hw/gpio/imx_gpio: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in imx_gpio_reset_hold().

---
 hw/gpio/imx_gpio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/imx_gpio.c +4 -3
index 5abf208..2b7ea7e 100644
@@ -290,9 +290,9 @@ static const Property imx_gpio_properties[] = {
                      false),
 };
 
-static void imx_gpio_reset(DeviceState *dev)
+static void imx_gpio_reset_hold(Object *obj, ResetType type)
 {
-    IMXGPIOState *s = IMX_GPIO(dev);
+    IMXGPIOState *s = IMX_GPIO(obj);
 
     s->dr       = 0;
     s->gdir     = 0;
@@ -324,9 +324,10 @@ static void imx_gpio_realize(DeviceState *dev, Error **errp)
 static void imx_gpio_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->realize = imx_gpio_realize;
-    device_class_set_legacy_reset(dc, imx_gpio_reset);
+    rc->phases.hold = imx_gpio_reset_hold;
     device_class_set_props(dc, imx_gpio_properties);
     dc->vmsd = &vmstate_imx_gpio;
     dc->desc = "i.MX GPIO controller";
Signature · 1 line
2.53.0
#7 lore raw

PATCH 7/12 hw/gpio/mpc8xxx: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in mpc8xxx_gpio_reset_hold().

---
 hw/gpio/mpc8xxx.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/mpc8xxx.c +4 -3
index 2e88232..e78eaca 100644
@@ -146,9 +146,9 @@ static void mpc8xxx_gpio_write(void *opaque, hwaddr offset,
     mpc8xxx_gpio_update(s);
 }
 
-static void mpc8xxx_gpio_reset(DeviceState *dev)
+static void mpc8xxx_gpio_reset_hold(Object *obj, ResetType type)
 {
-    MPC8XXXGPIOState *s = MPC8XXX_GPIO(dev);
+    MPC8XXXGPIOState *s = MPC8XXX_GPIO(obj);
 
     s->dir = 0;
     s->odr = 0;
@@ -202,9 +202,10 @@ static void mpc8xxx_gpio_initfn(Object *obj)
 static void mpc8xxx_gpio_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->vmsd = &vmstate_mpc8xxx_gpio;
-    device_class_set_legacy_reset(dc, mpc8xxx_gpio_reset);
+    rc->phases.hold = mpc8xxx_gpio_reset_hold;
 }
 
 static const TypeInfo mpc8xxx_gpio_types[] = {
Signature · 1 line
2.53.0
#8 lore raw

PATCH 8/12 hw/gpio/nrf51_gpio: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in nrf51_gpio_reset_hold().

---
 hw/gpio/nrf51_gpio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/nrf51_gpio.c +4 -3
index 567eb1f..bb46ac1 100644
@@ -258,9 +258,9 @@ static void nrf51_gpio_set(void *opaque, int line, int value)
     update_state(s);
 }
 
-static void nrf51_gpio_reset(DeviceState *dev)
+static void nrf51_gpio_reset_hold(Object *obj, ResetType type)
 {
-    NRF51GPIOState *s = NRF51_GPIO(dev);
+    NRF51GPIOState *s = NRF51_GPIO(obj);
     size_t i;
 
     s->out = 0;
@@ -307,9 +307,10 @@ static void nrf51_gpio_init(Object *obj)
 static void nrf51_gpio_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->vmsd = &vmstate_nrf51_gpio;
-    device_class_set_legacy_reset(dc, nrf51_gpio_reset);
+    rc->phases.hold = nrf51_gpio_reset_hold;
     dc->desc = "nRF51 GPIO";
 }
 
Signature · 1 line
2.53.0
#9 lore raw

PATCH 9/12 hw/gpio/omap_gpio: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in omap_gpif_reset_hold().

---
 hw/gpio/omap_gpio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/omap_gpio.c +4 -3
index 16da9a8..3ab357f 100644
@@ -192,9 +192,9 @@ static void omap_gpio_reset(struct omap_gpio_s *s)
     s->pins = ~0;
 }
 
-static void omap_gpif_reset(DeviceState *dev)
+static void omap_gpif_reset_hold(Object *obj, ResetType type)
 {
-    Omap1GpioState *s = OMAP1_GPIO(dev);
+    Omap1GpioState *s = OMAP1_GPIO(obj);
 
     omap_gpio_reset(&s->omap1);
 }
@@ -230,9 +230,10 @@ void omap_gpio_set_clk(Omap1GpioState *gpio, omap_clk clk)
 static void omap_gpio_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     dc->realize = omap_gpio_realize;
-    device_class_set_legacy_reset(dc, omap_gpif_reset);
+    rc->phases.hold = omap_gpif_reset_hold;
     /* Reason: pointer property "clk" */
     dc->user_creatable = false;
 }
Signature · 1 line
2.53.0
#10 lore raw

PATCH 10/12 hw/gpio/pca9554: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in pca9554_reset_hold().

---
 hw/gpio/pca9554.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/pca9554.c +4 -3
index 07bb00b..9dd3d15 100644
@@ -254,9 +254,9 @@ static const VMStateDescription pca9554_vmstate = {
     }
 };
 
-static void pca9554_reset(DeviceState *dev)
+static void pca9554_reset_hold(Object *obj, ResetType type)
 {
-    PCA9554State *s = PCA9554(dev);
+    PCA9554State *s = PCA9554(obj);
     PCA9554Class *pc = PCA9554_GET_CLASS(s);
     uint8_t pin_mask = (1 << pc->pin_count) - 1;
 
@@ -320,12 +320,13 @@ static void pca9554_class_init(ObjectClass *klass, const void *data)
     DeviceClass *dc = DEVICE_CLASS(klass);
     I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
     PCA9554Class *pc = PCA9554_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     k->event = pca9554_event;
     k->recv = pca9554_recv;
     k->send = pca9554_send;
     dc->realize = pca9554_realize;
-    device_class_set_legacy_reset(dc, pca9554_reset);
+    rc->phases.hold = pca9554_reset_hold;
     dc->vmsd = &pca9554_vmstate;
     device_class_set_props(dc, pca9554_properties);
 
Signature · 1 line
2.53.0
#11 lore raw

PATCH 11/12 hw/gpio/pcf8574: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in pcf8574_reset_hold().

---
 hw/gpio/pcf8574.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/pcf8574.c +4 -3
index f871f1e..ee1798b 100644
@@ -47,9 +47,9 @@ struct PCF8574State {
     qemu_irq intrq;      /* External irq request */
 };
 
-static void pcf8574_reset(DeviceState *dev)
+static void pcf8574_reset_hold(Object *obj, ResetType type)
 {
-    PCF8574State *s = PCF8574(dev);
+    PCF8574State *s = PCF8574(obj);
     s->lastrq = MAKE_64BIT_MASK(0, PORTS_COUNT);
     s->input  = MAKE_64BIT_MASK(0, PORTS_COUNT);
     s->output = MAKE_64BIT_MASK(0, PORTS_COUNT);
@@ -142,11 +142,12 @@ static void pcf8574_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass   *dc = DEVICE_CLASS(klass);
     I2CSlaveClass *k  = I2C_SLAVE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     k->recv     = pcf8574_rx;
     k->send     = pcf8574_tx;
     dc->realize = pcf8574_realize;
-    device_class_set_legacy_reset(dc, pcf8574_reset);
+    rc->phases.hold = pcf8574_reset_hold;
     dc->vmsd    = &vmstate_pcf8574;
 }
 
Signature · 1 line
2.53.0
#12 lore raw

PATCH 12/12 hw/gpio/sifive_gpio: Convert to Resettable interface

In reply to Oscar Alejandro Sánchez Lucero

Replace the deprecated device_class_set_legacy_reset() with the Resettable interface by implementing the hold phase in sifive_gpio_reset_hold().

---
 hw/gpio/sifive_gpio.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
hw/gpio/sifive_gpio.c +4 -3
index b7a5693..3b9e15a 100644
@@ -297,9 +297,9 @@ static void sifive_gpio_set(void *opaque, int line, int value)
     update_state(s);
 }
 
-static void sifive_gpio_reset(DeviceState *dev)
+static void sifive_gpio_reset_hold(Object *obj, ResetType type)
 {
-    SIFIVEGPIOState *s = SIFIVE_GPIO(dev);
+    SIFIVEGPIOState *s = SIFIVE_GPIO(obj);
 
     s->value = 0;
     s->input_en = 0;
@@ -373,11 +373,12 @@ static void sifive_gpio_realize(DeviceState *dev, Error **errp)
 static void sifive_gpio_class_init(ObjectClass *klass, const void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    ResettableClass *rc = RESETTABLE_CLASS(klass);
 
     device_class_set_props(dc, sifive_gpio_properties);
     dc->vmsd = &vmstate_sifive_gpio;
     dc->realize = sifive_gpio_realize;
-    device_class_set_legacy_reset(dc, sifive_gpio_reset);
+    rc->phases.hold = sifive_gpio_reset_hold;
     dc->desc = "SiFive GPIO";
 }
 
Signature · 1 line
2.53.0