Message ID | 20230726132512.149618-11-sergey.kambalin@auriga.com |
---|---|
State | New |
Headers | show |
Series | Raspberry Pi 4B machine | expand |
On Wed, 26 Jul 2023 at 14:26, Sergey Kambalin <serg.oker@gmail.com> wrote: > > Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> > --- > hw/gpio/bcm2838_gpio.c | 17 +++++++++++++++++ > 1 file changed, 17 insertions(+) > > diff --git a/hw/gpio/bcm2838_gpio.c b/hw/gpio/bcm2838_gpio.c > index 7291e473dc..f1121f9c58 100644 > --- a/hw/gpio/bcm2838_gpio.c > +++ b/hw/gpio/bcm2838_gpio.c > @@ -17,6 +17,7 @@ > #include "qemu/timer.h" > #include "qapi/error.h" > #include "hw/sysbus.h" > +#include "migration/vmstate.h" > #include "hw/sd/sd.h" > #include "hw/gpio/bcm2838_gpio.h" > #include "hw/irq.h" > @@ -324,6 +325,21 @@ static const MemoryRegionOps bcm2838_gpio_ops = { > .endianness = DEVICE_NATIVE_ENDIAN, > }; > > +static const VMStateDescription vmstate_bcm2838_gpio = { > + .name = "bcm2838_gpio", > + .version_id = 1, > + .minimum_version_id = 1, > + .fields = (VMStateField[]) { > + VMSTATE_UINT8_ARRAY(fsel, BCM2838GpioState, BCM2838_GPIO_NUM), > + VMSTATE_UINT32(lev0, BCM2838GpioState), > + VMSTATE_UINT32(lev1, BCM2838GpioState), > + VMSTATE_UINT8(sd_fsel, BCM2838GpioState), > + VMSTATE_UINT32_ARRAY(pup_cntrl_reg, BCM2838GpioState, > + GPIO_PUP_PDN_CNTRL_NUM), > + VMSTATE_END_OF_LIST() > + } > +}; > + > static void bcm2838_gpio_init(Object *obj) > { > BCM2838GpioState *s = BCM2838_GPIO(obj); > @@ -355,6 +371,7 @@ static void bcm2838_gpio_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc = DEVICE_CLASS(klass); > > + dc->vmsd = &vmstate_bcm2838_gpio; > dc->realize = &bcm2838_gpio_realize; > dc->reset = &bcm2838_gpio_reset; Oh, this is where the vmstate struct ended up. I think I would suggest putting this in patch 6, since that's where you add the struct fields. (Define the sd_fsel field there too.) thanks -- PMM
diff --git a/hw/gpio/bcm2838_gpio.c b/hw/gpio/bcm2838_gpio.c index 7291e473dc..f1121f9c58 100644 --- a/hw/gpio/bcm2838_gpio.c +++ b/hw/gpio/bcm2838_gpio.c @@ -17,6 +17,7 @@ #include "qemu/timer.h" #include "qapi/error.h" #include "hw/sysbus.h" +#include "migration/vmstate.h" #include "hw/sd/sd.h" #include "hw/gpio/bcm2838_gpio.h" #include "hw/irq.h" @@ -324,6 +325,21 @@ static const MemoryRegionOps bcm2838_gpio_ops = { .endianness = DEVICE_NATIVE_ENDIAN, }; +static const VMStateDescription vmstate_bcm2838_gpio = { + .name = "bcm2838_gpio", + .version_id = 1, + .minimum_version_id = 1, + .fields = (VMStateField[]) { + VMSTATE_UINT8_ARRAY(fsel, BCM2838GpioState, BCM2838_GPIO_NUM), + VMSTATE_UINT32(lev0, BCM2838GpioState), + VMSTATE_UINT32(lev1, BCM2838GpioState), + VMSTATE_UINT8(sd_fsel, BCM2838GpioState), + VMSTATE_UINT32_ARRAY(pup_cntrl_reg, BCM2838GpioState, + GPIO_PUP_PDN_CNTRL_NUM), + VMSTATE_END_OF_LIST() + } +}; + static void bcm2838_gpio_init(Object *obj) { BCM2838GpioState *s = BCM2838_GPIO(obj); @@ -355,6 +371,7 @@ static void bcm2838_gpio_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); + dc->vmsd = &vmstate_bcm2838_gpio; dc->realize = &bcm2838_gpio_realize; dc->reset = &bcm2838_gpio_reset; }
Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com> --- hw/gpio/bcm2838_gpio.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)