qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RFC PATCH 3/6] hw/gpio/npcm7xx: Number controllers


From: Joe Komlodi
Subject: [RFC PATCH 3/6] hw/gpio/npcm7xx: Number controllers
Date: Thu, 16 Dec 2021 01:54:14 +0000

For transmitting the GPIO state to the outside world, the GPIO transmitter will
need to know which controller's state has been updated.

To do this, we'll just number each controller at initialization.

Signed-off-by: Joe Komlodi <komlodi@google.com>
---
 hw/arm/npcm7xx.c               | 1 +
 hw/gpio/npcm7xx_gpio.c         | 2 ++
 include/hw/gpio/npcm7xx_gpio.h | 1 +
 3 files changed, 4 insertions(+)

diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c
index ace21d8943..6a48a9a6d4 100644
--- a/hw/arm/npcm7xx.c
+++ b/hw/arm/npcm7xx.c
@@ -595,6 +595,7 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp)
     for (i = 0; i < ARRAY_SIZE(s->gpio); i++) {
         Object *obj = OBJECT(&s->gpio[i]);
 
+        object_property_set_uint(obj, "controller-num", i, &error_abort);
         object_property_set_uint(obj, "reset-pullup",
                                  npcm7xx_gpio[i].reset_pu, &error_abort);
         object_property_set_uint(obj, "reset-pulldown",
diff --git a/hw/gpio/npcm7xx_gpio.c b/hw/gpio/npcm7xx_gpio.c
index 3376901ab1..5075f61b3b 100644
--- a/hw/gpio/npcm7xx_gpio.c
+++ b/hw/gpio/npcm7xx_gpio.c
@@ -387,6 +387,8 @@ static const VMStateDescription vmstate_npcm7xx_gpio = {
 };
 
 static Property npcm7xx_gpio_properties[] = {
+    /* The GPIO controller number (out of 8) */
+    DEFINE_PROP_UINT8("controller-num", NPCM7xxGPIOState, controller_num, 0),
     /* Bit n set => pin n has pullup enabled by default. */
     DEFINE_PROP_UINT32("reset-pullup", NPCM7xxGPIOState, reset_pu, 0),
     /* Bit n set => pin n has pulldown enabled by default. */
diff --git a/include/hw/gpio/npcm7xx_gpio.h b/include/hw/gpio/npcm7xx_gpio.h
index b1d771bd77..b065bba1c5 100644
--- a/include/hw/gpio/npcm7xx_gpio.h
+++ b/include/hw/gpio/npcm7xx_gpio.h
@@ -35,6 +35,7 @@ typedef struct NPCM7xxGPIOState {
     uint32_t reset_pd;
     uint32_t reset_osrc;
     uint32_t reset_odsc;
+    uint8_t  controller_num;
 
     MemoryRegion mmio;
 
-- 
2.34.1.173.g76aa8bc2d0-goog




reply via email to

[Prev in Thread] Current Thread [Next in Thread]