diff mbox series

[RFC,5/6] hw/gpio/npcm7xx: init GPIO transmitter allowlist

Message ID 20211216015417.1234812-6-komlodi@google.com (mailing list archive)
State New, archived
Headers show
Series Introduce GPIO transmitter and connect to NPCM7xx | expand

Commit Message

Joe Komlodi Dec. 16, 2021, 1:54 a.m. UTC
For the GPIO transmitter to properly transmit on pin changes, it must
know the initial state of the GPIO pins on the controller.

Signed-off-by: Joe Komlodi <komlodi@google.com>
---
 hw/gpio/npcm7xx_gpio.c | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/hw/gpio/npcm7xx_gpio.c b/hw/gpio/npcm7xx_gpio.c
index 0d683903a2..64a74c87a5 100644
--- a/hw/gpio/npcm7xx_gpio.c
+++ b/hw/gpio/npcm7xx_gpio.c
@@ -370,6 +370,14 @@  static void npcm7xx_gpio_hold_reset(Object *obj)
     npcm7xx_gpio_update_pins(s, -1);
 }
 
+static void npcm7xx_gpio_realize(DeviceState *dev, Error **errp)
+{
+    NPCM7xxGPIOState *s = NPCM7XX_GPIO(dev);
+    uint32_t state = s->regs[NPCM7XX_GPIO_DOUT] | s->regs[NPCM7XX_GPIO_DIN];
+
+    google_gpio_tx_state_init(s->txs, s->controller_num, state);
+}
+
 static void npcm7xx_gpio_init(Object *obj)
 {
     NPCM7xxGPIOState *s = NPCM7XX_GPIO(obj);
@@ -423,6 +431,7 @@  static void npcm7xx_gpio_class_init(ObjectClass *klass, void *data)
 
     dc->desc = "NPCM7xx GPIO Controller";
     dc->vmsd = &vmstate_npcm7xx_gpio;
+    dc->realize = npcm7xx_gpio_realize;
     reset->phases.enter = npcm7xx_gpio_enter_reset;
     reset->phases.hold = npcm7xx_gpio_hold_reset;
     device_class_set_props(dc, npcm7xx_gpio_properties);