hw/arm: Add WDT to Allwinner-H3 and Orangepi-PC

This patch adds WDT to Allwinner-H3 and Orangepi-PC.
WDT is added as an overlay to the Timer module memory area.

Signed-off-by: Strahinja Jankovic <strahinja.p.jankovic@gmail.com>
Reviewed-by: Niek Linnenbank <nieklinnenbank@gmail.com>
Message-id: 20230326202256.22980-4-strahinja.p.jankovic@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Strahinja Jankovic 2023-04-20 10:21:14 +01:00 committed by Peter Maydell
parent 470f9f2d93
commit c663fc9fbc
4 changed files with 14 additions and 1 deletions

View File

@ -26,6 +26,7 @@ The Orange Pi PC machine supports the following devices:
* System Control module * System Control module
* Security Identifier device * Security Identifier device
* TWI (I2C) * TWI (I2C)
* Watchdog timer
Limitations Limitations
""""""""""" """""""""""

View File

@ -337,6 +337,7 @@ config ALLWINNER_H3
select ALLWINNER_A10_PIT select ALLWINNER_A10_PIT
select ALLWINNER_SUN8I_EMAC select ALLWINNER_SUN8I_EMAC
select ALLWINNER_I2C select ALLWINNER_I2C
select ALLWINNER_WDT
select SERIAL select SERIAL
select ARM_TIMER select ARM_TIMER
select ARM_GIC select ARM_GIC

View File

@ -49,6 +49,7 @@ const hwaddr allwinner_h3_memmap[] = {
[AW_H3_DEV_OHCI3] = 0x01c1d400, [AW_H3_DEV_OHCI3] = 0x01c1d400,
[AW_H3_DEV_CCU] = 0x01c20000, [AW_H3_DEV_CCU] = 0x01c20000,
[AW_H3_DEV_PIT] = 0x01c20c00, [AW_H3_DEV_PIT] = 0x01c20c00,
[AW_H3_DEV_WDT] = 0x01c20ca0,
[AW_H3_DEV_UART0] = 0x01c28000, [AW_H3_DEV_UART0] = 0x01c28000,
[AW_H3_DEV_UART1] = 0x01c28400, [AW_H3_DEV_UART1] = 0x01c28400,
[AW_H3_DEV_UART2] = 0x01c28800, [AW_H3_DEV_UART2] = 0x01c28800,
@ -234,6 +235,8 @@ static void allwinner_h3_init(Object *obj)
object_initialize_child(obj, "twi1", &s->i2c1, TYPE_AW_I2C_SUN6I); object_initialize_child(obj, "twi1", &s->i2c1, TYPE_AW_I2C_SUN6I);
object_initialize_child(obj, "twi2", &s->i2c2, TYPE_AW_I2C_SUN6I); object_initialize_child(obj, "twi2", &s->i2c2, TYPE_AW_I2C_SUN6I);
object_initialize_child(obj, "r_twi", &s->r_twi, TYPE_AW_I2C_SUN6I); object_initialize_child(obj, "r_twi", &s->r_twi, TYPE_AW_I2C_SUN6I);
object_initialize_child(obj, "wdt", &s->wdt, TYPE_AW_WDT_SUN6I);
} }
static void allwinner_h3_realize(DeviceState *dev, Error **errp) static void allwinner_h3_realize(DeviceState *dev, Error **errp)
@ -453,6 +456,11 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp)
sysbus_connect_irq(SYS_BUS_DEVICE(&s->r_twi), 0, sysbus_connect_irq(SYS_BUS_DEVICE(&s->r_twi), 0,
qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_R_TWI)); qdev_get_gpio_in(DEVICE(&s->gic), AW_H3_GIC_SPI_R_TWI));
/* WDT */
sysbus_realize(SYS_BUS_DEVICE(&s->wdt), &error_fatal);
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->wdt), 0,
s->memmap[AW_H3_DEV_WDT], 1);
/* Unimplemented devices */ /* Unimplemented devices */
for (i = 0; i < ARRAY_SIZE(unimplemented); i++) { for (i = 0; i < ARRAY_SIZE(unimplemented); i++) {
create_unimplemented_device(unimplemented[i].device_name, create_unimplemented_device(unimplemented[i].device_name,

View File

@ -48,6 +48,7 @@
#include "hw/net/allwinner-sun8i-emac.h" #include "hw/net/allwinner-sun8i-emac.h"
#include "hw/rtc/allwinner-rtc.h" #include "hw/rtc/allwinner-rtc.h"
#include "hw/i2c/allwinner-i2c.h" #include "hw/i2c/allwinner-i2c.h"
#include "hw/watchdog/allwinner-wdt.h"
#include "target/arm/cpu.h" #include "target/arm/cpu.h"
#include "sysemu/block-backend.h" #include "sysemu/block-backend.h"
@ -96,7 +97,8 @@ enum {
AW_H3_DEV_RTC, AW_H3_DEV_RTC,
AW_H3_DEV_CPUCFG, AW_H3_DEV_CPUCFG,
AW_H3_DEV_R_TWI, AW_H3_DEV_R_TWI,
AW_H3_DEV_SDRAM AW_H3_DEV_SDRAM,
AW_H3_DEV_WDT
}; };
/** Total number of CPU cores in the H3 SoC */ /** Total number of CPU cores in the H3 SoC */
@ -141,6 +143,7 @@ struct AwH3State {
AWI2CState r_twi; AWI2CState r_twi;
AwSun8iEmacState emac; AwSun8iEmacState emac;
AwRtcState rtc; AwRtcState rtc;
AwWdtState wdt;
GICState gic; GICState gic;
MemoryRegion sram_a1; MemoryRegion sram_a1;
MemoryRegion sram_a2; MemoryRegion sram_a2;