* [PATCH qemu] aspeed: Register all three watchdogs
@ 2017-06-27 11:54 Joel Stanley
2017-06-27 13:44 ` Cédric Le Goater
0 siblings, 1 reply; 2+ messages in thread
From: Joel Stanley @ 2017-06-27 11:54 UTC (permalink / raw)
To: openbmc; +Cc: Cédric Le Goater, Andrew Jeffery
The ast2500 contains three watchdogs. Instatite the model three times to
the correct address.
Signed-off-by: Joel Stanley <joel@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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH qemu] aspeed: Register all three watchdogs
2017-06-27 11:54 [PATCH qemu] aspeed: Register all three watchdogs Joel Stanley
@ 2017-06-27 13:44 ` Cédric Le Goater
0 siblings, 0 replies; 2+ messages in thread
From: Cédric Le Goater @ 2017-06-27 13:44 UTC (permalink / raw)
To: Joel Stanley, openbmc; +Cc: Andrew Jeffery
On 06/27/2017 01:54 PM, Joel Stanley wrote:
> The ast2500 contains three watchdogs. Instatite the model three times to
> the correct address.
>
> Signed-off-by: Joel Stanley <joel@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.
take a look at the spi controllers. briefly speaking :
- add an array of 'AspeedWDTState' under AspeedSoCState.
- modify 'static const AspeedSoCInfo aspeed_socs' to include the
number of watchdogs.
- initialize and realize only the number of watchdogs you need
for a SoC
Some comments below,
>
> 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++) {
replace ARRAY_SIZE(s->wdt) by 'sc->info->wdt_count'. Pick the name you want.
> + 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);
drop the fprintf
> + 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);
This line is too long.
> }
> - 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];
use a define may be ? no big deal as we won't use it anywhere
else I think.
Thanks,
C.
> FTGMAC100State ftgmac100;
> AspeedIBTState ibt;
> } AspeedSoCState;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-06-27 13:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27 11:54 [PATCH qemu] aspeed: Register all three watchdogs Joel Stanley
2017-06-27 13:44 ` Cédric Le Goater
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.