[PATCH qemu] aspeed: Register all three watchdogs

Joel Stanley joel at jms.id.au
Tue Jun 27 21:54:11 AEST 2017


The ast2500 contains three watchdogs. Instatite the model three times to
the correct address.

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
Tested with dev-4.10 with multiple watchdogs enabled in the device tree.

Note that the ast2400 only has two watchdogs, but I'm not sure how to account for that.

 hw/arm/aspeed_soc.c         | 25 +++++++++++++++----------
 include/hw/arm/aspeed_soc.h |  2 +-
 2 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/hw/arm/aspeed_soc.c b/hw/arm/aspeed_soc.c
index 77b95e8e8092..522cdba3bf9d 100644
--- a/hw/arm/aspeed_soc.c
+++ b/hw/arm/aspeed_soc.c
@@ -178,11 +178,13 @@ static void aspeed_soc_init(Object *obj)
     object_property_add_alias(obj, "ram-size", OBJECT(&s->sdmc),
                               "ram-size", &error_abort);
 
-    object_initialize(&s->wdt, sizeof(s->wdt), TYPE_ASPEED_WDT);
-    object_property_add_child(obj, "wdt", OBJECT(&s->wdt), NULL);
-    qdev_set_parent_bus(DEVICE(&s->wdt), sysbus_get_default());
-    object_property_add_const_link(OBJECT(&s->wdt), "scu", OBJECT(&s->scu),
-                                   NULL);
+    for (i = 0; i < ARRAY_SIZE(s->wdt); i++) {
+	    object_initialize(&s->wdt[i], sizeof(s->wdt[i]), TYPE_ASPEED_WDT);
+	    object_property_add_child(obj, "wdt", OBJECT(&s->wdt[i]), NULL);
+	    qdev_set_parent_bus(DEVICE(&s->wdt[i]), sysbus_get_default());
+	    object_property_add_const_link(OBJECT(&s->wdt[i]), "scu",
+			    OBJECT(&s->scu), NULL);
+    }
 
     object_initialize(&s->ftgmac100, sizeof(s->ftgmac100), TYPE_FTGMAC100);
     object_property_add_child(obj, "ftgmac100", OBJECT(&s->ftgmac100), NULL);
@@ -340,12 +342,15 @@ static void aspeed_soc_realize(DeviceState *dev, Error **errp)
     sysbus_mmio_map(SYS_BUS_DEVICE(&s->sdmc), 0, ASPEED_SOC_SDMC_BASE);
 
     /* Watch dog */
-    object_property_set_bool(OBJECT(&s->wdt), true, "realized", &err);
-    if (err) {
-        error_propagate(errp, err);
-        return;
+    for (i = 0; i < ARRAY_SIZE(s->wdt); i++) {
+	    fprintf(stderr, "regisering wdt %d at %08x\n", i, ASPEED_SOC_WDT_BASE + i * 0x20); 
+	    object_property_set_bool(OBJECT(&s->wdt[i]), true, "realized", &err);
+	    if (err) {
+		    error_propagate(errp, err);
+		    return;
+	    }
+	    sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt[i]), 0, ASPEED_SOC_WDT_BASE + i * 0x20);
     }
-    sysbus_mmio_map(SYS_BUS_DEVICE(&s->wdt), 0, ASPEED_SOC_WDT_BASE);
 
     /* Net */
     qdev_set_nic_properties(DEVICE(&s->ftgmac100), &nd_table[0]);
diff --git a/include/hw/arm/aspeed_soc.h b/include/hw/arm/aspeed_soc.h
index d16205c66b5f..8a550dafd737 100644
--- a/include/hw/arm/aspeed_soc.h
+++ b/include/hw/arm/aspeed_soc.h
@@ -40,7 +40,7 @@ typedef struct AspeedSoCState {
     AspeedSMCState fmc;
     AspeedSMCState spi[ASPEED_SPIS_NUM];
     AspeedSDMCState sdmc;
-    AspeedWDTState wdt;
+    AspeedWDTState wdt[3];
     FTGMAC100State ftgmac100;
     AspeedIBTState ibt;
 } AspeedSoCState;
-- 
2.13.1



More information about the openbmc mailing list