[PATCH qemu] aspeed: Register all three watchdogs
Cédric Le Goater
clg at kaod.org
Tue Jun 27 23:44:30 AEST 2017
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 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.
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;
>
More information about the openbmc
mailing list