On 6/21/20 12:58 AM, Philippe Mathieu-Daudé wrote: > The PCA9552 has 16 GPIOs which can be used as input, > output or PWM mode. QEMU models the output GPIO with > the qemu_irq type. Let the device expose the 16 GPIOs > to allow us to later connect LEDs to these outputs. > > Signed-off-by: Philippe Mathieu-Daudé <f4...@amsat.org>
Reviewed-by: Cédric Le Goater <c...@kaod.org> > --- > include/hw/misc/pca9552.h | 1 + > hw/misc/pca9552.c | 4 ++++ > 2 files changed, 5 insertions(+) > > diff --git a/include/hw/misc/pca9552.h b/include/hw/misc/pca9552.h > index 755be2e8e5..2545087da3 100644 > --- a/include/hw/misc/pca9552.h > +++ b/include/hw/misc/pca9552.h > @@ -30,6 +30,7 @@ typedef struct PCA9552State { > uint8_t max_reg; > char *description; /* For debugging purpose only */ > uint8_t nr_leds; > + qemu_irq gpio[PCA9552_PIN_COUNT]; > } PCA9552State; > > #endif > diff --git a/hw/misc/pca9552.c b/hw/misc/pca9552.c > index 85557b78d9..8f0ce19b74 100644 > --- a/hw/misc/pca9552.c > +++ b/hw/misc/pca9552.c > @@ -16,6 +16,7 @@ > #include "hw/qdev-properties.h" > #include "hw/misc/pca9552.h" > #include "hw/misc/pca9552_regs.h" > +#include "hw/irq.h" > #include "migration/vmstate.h" > #include "qapi/error.h" > #include "qapi/visitor.h" > @@ -88,9 +89,11 @@ static void pca9552_update_pin_input(PCA9552State *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: > + qemu_set_irq(s->gpio[i], 0); > s->regs[input_reg] &= ~(1 << input_shift); > break; > case PCA9552_LED_PWM0: > @@ -360,6 +363,7 @@ static void pca9552_realize(DeviceState *dev, Error > **errp) > if (!s->description) { > s->description = g_strdup("pca-unspecified"); > } > + qdev_init_gpio_out(dev, s->gpio, s->nr_leds); > } > > static Property pca9552_properties[] = { >