Implement the watchdog timer of HiFive 1 rev b.
Subsystems (3)
v4 cover Implement the watchdog timer of HiFive 1 rev b.
The HiFive 1 rev b includes a watchdog module based on a 32-bit counter. The watchdog timer is in the always-on domain device of HiFive 1 rev b, so this patch added the AON device to the sifive_e machine. This patch only implemented the functionality of the watchdog timer, not all the functionality of the AON device.
You can test the patchset by the QTest tests/qtest/sifive-e-aon-watchdog-test.c
Changes since v1 ( Thank Alistair for the feedback ):
- Use the register field macro.
- Delete the public create function. The board creates the aon device itself.
- Keep all variable declarations at the top of the code block.
Changes since v2 ( Thank Alistair for the feedback ):
- Delete the declaration and definition of the create function.
Changes since v3 ( Thank Alistair and Thomas for the feedback ):
- Use device_class_set_props() for the properties in sifive_e_aon device.
- Add SPDX identifier in QTEST.
- Use libqtest.h in QTEST.
- Let the statements on one line as long as they still fit into 80 columns.
Tommy Wu (3):
hw/misc: sifive_e_aon: Support the watchdog timer of HiFive 1 rev b. hw/riscv: sifive_e: Support the watchdog timer of HiFive 1 rev b. tests/qtest: sifive-e-aon-watchdog-test.c: Add QTest of watchdog of
sifive_e
hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + hw/misc/sifive_e_aon.c | 326 ++++++++++++++++ hw/riscv/Kconfig | 1 + hw/riscv/sifive_e.c | 13 +- include/hw/misc/sifive_e_aon.h | 60 +++ include/hw/riscv/sifive_e.h | 8 +- tests/qtest/meson.build | 3 + tests/qtest/sifive-e-aon-watchdog-test.c | 450 +++++++++++++++++++++++ 9 files changed, 860 insertions(+), 5 deletions(-) create mode 100644 hw/misc/sifive_e_aon.c create mode 100644 include/hw/misc/sifive_e_aon.h create mode 100644 tests/qtest/sifive-e-aon-watchdog-test.c
Signature · 1 line
2.27.0
PATCH v4 1/3 hw/misc: sifive_e_aon: Support the watchdog timer of HiFive 1 rev b.
The watchdog timer is in the always-on domain device of HiFive 1 rev b, so this patch added the AON device to the sifive_e machine. This patch only implemented the functionality of the watchdog timer.
--- hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + hw/misc/sifive_e_aon.c | 326 +++++++++++++++++++++++++++++++++ include/hw/misc/sifive_e_aon.h | 60 ++++++ 4 files changed, 390 insertions(+) create mode 100644 hw/misc/sifive_e_aon.c create mode 100644 include/hw/misc/sifive_e_aon.h
hw/misc/Kconfig +3 -0
@@ -158,6 +158,9 @@ config SIFIVE_TEST config SIFIVE_E_PRCI bool +config SIFIVE_E_AON + bool + config SIFIVE_U_OTP bool
hw/misc/meson.build +1 -0
@@ -30,6 +30,7 @@ softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_IOSCB', if_true: files('mchp_pfsoc_ioscb softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_SYSREG', if_true: files('mchp_pfsoc_sysreg.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_TEST', if_true: files('sifive_test.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_E_PRCI', if_true: files('sifive_e_prci.c')) +softmmu_ss.add(when: 'CONFIG_SIFIVE_E_AON', if_true: files('sifive_e_aon.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_U_OTP', if_true: files('sifive_u_otp.c')) softmmu_ss.add(when: 'CONFIG_SIFIVE_U_PRCI', if_true: files('sifive_u_prci.c'))
hw/misc/sifive_e_aon.c new file +326 -0
326 lines not on this page · raw message
include/hw/misc/sifive_e_aon.h new file +60 -0
60 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH v4 1/3] hw/misc: sifive_e_aon: Support the watchdog timer of HiFive 1 rev b.
Hi Tommy,
Quoted 18 lines · Tommy Wu
The watchdog timer is in the always-on domain device of HiFive 1 rev b, so this patch added the AON device to the
sifive_emachine. This patch only implemented the functionality of the watchdog timer.Signed-off-by Tommy Wu <[email protected]>Reviewed-by Frank Chang <[email protected]>--- hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + hw/misc/sifive_e_aon.c | 326 +++++++++++++++++++++++++++++++++ include/hw/misc/sifive_e_aon.h | 60 ++++++ 4 files changed, 390 insertions(+)create mode 100644
hw/misc/sifive_e_aon.ccreate mode 100644include/hw/misc/sifive_e_aon.hhw/misc/sifive_e_aon.c new file +2
-0+REG32(AON_WDT_WDOGCFG, 0x0) +FIELD (AON_WDT_WDOGCFG ,SCALE ,0 ,4 )
hw/misc/sifive_e_aon.c line 41
Quoted 10 lines
hw/misc/sifive_e_aon.c new file +10
-0+ FIELD(AON_WDT_WDOGCFG, RSVD0, 4, 4) + FIELD(AON_WDT_WDOGCFG, RSTEN, 8, 1) + FIELD(AON_WDT_WDOGCFG, ZEROCMP, 9, 1) + FIELD(AON_WDT_WDOGCFG, RSVD1, 10, 2) + FIELD(AON_WDT_WDOGCFG, EN_ALWAYS, 12, 1) + FIELD(AON_WDT_WDOGCFG, EN_CORE_AWAKE, 13, 1) + FIELD(AON_WDT_WDOGCFG, RSVD2, 14, 14) + FIELD(AON_WDT_WDOGCFG, IP0, 28, 1) + FIELD(AON_WDT_WDOGCFG, RSVD3, 29, 3) +REG32 (AON_WDT_WDOGCOUNT ,0x8 )
Adding:
FIELD(AON_WDT_WDOGCOUNT, VALUE, 0, 31)
...
Quoted 9 lines
hw/misc/sifive_e_aon.c new file +9
-0+REG32(AON_WDT_WDOGS, 0x10) +REG32(AON_WDT_WDOGFEED, 0x18) +REG32(AON_WDT_WDOGKEY, 0x1c) +REG32(AON_WDT_WDOGCMP0, 0x20) + +static void sifive_e_aon_wdt_update_wdogcount (SiFiveEAONState *r) +{ +int64_t now; + if (0 == FIELD_EX32(r->wdogcfg, AON_WDT_WDOGCFG, EN_ALWAYS) &&
hw/misc/sifive_e_aon.c line 60
Quoted 10 lines
hw/misc/sifive_e_aon.c new file +10
-0+ 0 == FIELD_EX32(r->wdogcfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE)) { +return ; + } + + now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); + r->wdogcount +=muldiv64 (now - r->wdog_restart_time, + r->wdogclk_freq,NANOSECONDS_PER_SECOND ); + +/* Clean the most significant bit. */ + r->wdogcount = ((r->wdogcount <<1 ) >>1 );
... you could use:
r->wdogcount &= R_AON_WDT_WDOGCOUNT_VALUE_MASK
Quoted 11 lines
hw/misc/sifive_e_aon.c new file +11
-0+ r->wdog_restart_time = now; +} + +static void sifive_e_aon_wdt_update_state (SiFiveEAONState *r) +{ +uint16_t wdogs; +bool cmp_signal = false; +sifive_e_aon_wdt_update_wdogcount (r); + wdogs = (uint16_t )(r->wdogcount >> +FIELD_EX32 (r->wdogcfg,AON_WDT_WDOGCFG ,SCALE )); +
hw/misc/sifive_e_aon.c line 81
Quoted 10 lines
hw/misc/sifive_e_aon.c new file +10
-0+if (wdogs >= r->wdogcmp0) { + cmp_signal = true; +if (1 ==FIELD_EX32 (r->wdogcfg,AON_WDT_WDOGCFG ,ZEROCMP )) { + r->wdogcount =0 ; + wdogs =0 ; + } + } + +if (cmp_signal) { +if (1 ==FIELD_EX32 (r->wdogcfg,AON_WDT_WDOGCFG ,RSTEN )) {
You sometimes check bit equality, ...
hw/misc/sifive_e_aon.c line 90
Quoted 9 lines
hw/misc/sifive_e_aon.c new file +9
-0+watchdog_perform_action (); + } + r->wdogcfg =FIELD_DP32 (r->wdogcfg,AON_WDT_WDOGCFG ,IP0 ,1 ); + } + +qemu_set_irq (r->wdog_irq,FIELD_EX32 (r->wdogcfg,AON_WDT_WDOGCFG ,IP0 )); + + if (wdogs < r->wdogcmp0 && + (FIELD_EX32(r->wdogcfg, AON_WDT_WDOGCFG, EN_ALWAYS) ||
... sometimes you don't. Code style consistency would be better.
(Also, most of QEMU code base check equality using constant value on the right side of the comparaison).
Quoted 22 lines
hw/misc/sifive_e_aon.c new file +21
-0+ FIELD_EX32(r->wdogcfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE))) { +int64_t next =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); + next +=muldiv64 ((r->wdogcmp0 - wdogs) << +FIELD_EX32 (r->wdogcfg,AON_WDT_WDOGCFG ,SCALE ), +NANOSECONDS_PER_SECOND , r->wdogclk_freq); +timer_mod (r->wdog_timer, next); + } else { +timer_mod (r->wdog_timer,INT64_MAX ); + } +} +static void sifive_e_aon_init (Object *obj) +{ +SysBusDevice *sbd =SYS_BUS_DEVICE (obj); +SiFiveEAONState *r =SIFIVE_E_AON (obj); + +memory_region_init_io (&r->mmio,OBJECT (r), &sifive_e_aon_ops, r, +TYPE_SIFIVE_E_AON ,SIFIVE_E_AON_MAX ); +sysbus_init_mmio (sbd, &r->mmio); + +/* watchdog timer */ + r->wdogclk_freq =SIFIVE_E_LFCLK_DEFAULT_FREQ ;
hw/misc/sifive_e_aon.c
Quoted 10 lines
hw/misc/sifive_e_aon.c new file +10
-0+sysbus_init_irq (sbd, &r->wdog_irq); +} + +static void sifive_e_aon_realize (DeviceState *dev,Error **errp) +{ +SiFiveEAONState *r =SIFIVE_E_AON (dev); + +/* watchdog timer */ + r->wdog_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , + sifive_e_aon_wdt_expired_cb, r);
You should be able to create the timer in sifive_e_aon_init().
Quoted 1 line
+}
Regards,
Phil.
Re: [PATCH v4 1/3] hw/misc: sifive_e_aon: Support the watchdog timer of HiFive 1 rev b.
Hi Phil,
Thanks for all the suggestions, I'll send patch v5 to fix all the issues.
Best Regards,
Tommy
Quoted 144 lines · Philippe Mathieu-Daudé
Hi Tommy,
Quoted 18 lines · Tommy Wu
The watchdog timer is in the always-on domain device of HiFive 1 rev b, so this patch added the AON device to the
sifive_emachine. This patch only implemented the functionality of the watchdog timer.Signed-off-by Tommy Wu <[email protected]>Reviewed-by Frank Chang <[email protected]>--- hw/misc/Kconfig | 3 + hw/misc/meson.build | 1 + hw/misc/sifive_e_aon.c | 326 +++++++++++++++++++++++++++++++++ include/hw/misc/sifive_e_aon.h | 60 ++++++ 4 files changed, 390 insertions(+)create mode 100644
hw/misc/sifive_e_aon.ccreate mode 100644include/hw/misc/sifive_e_aon.hhw/misc/sifive_e_aon.c new file +2
-0+REG32(AON_WDT_WDOGCFG, 0x0) +FIELD (AON_WDT_WDOGCFG ,SCALE ,0 ,4 )hw/misc/sifive_e_aon.c line 41
Quoted 10 lines
hw/misc/sifive_e_aon.c new file +10
-0+ FIELD(AON_WDT_WDOGCFG, RSVD0, 4, 4) + FIELD(AON_WDT_WDOGCFG, RSTEN, 8, 1) + FIELD(AON_WDT_WDOGCFG, ZEROCMP, 9, 1) + FIELD(AON_WDT_WDOGCFG, RSVD1, 10, 2) + FIELD(AON_WDT_WDOGCFG, EN_ALWAYS, 12, 1) + FIELD(AON_WDT_WDOGCFG, EN_CORE_AWAKE, 13, 1) + FIELD(AON_WDT_WDOGCFG, RSVD2, 14, 14) + FIELD(AON_WDT_WDOGCFG, IP0, 28, 1) + FIELD(AON_WDT_WDOGCFG, RSVD3, 29, 3) +REG32 (AON_WDT_WDOGCOUNT ,0x8 )Adding:
FIELD(AON_WDT_WDOGCOUNT, VALUE, 0, 31)...
Quoted 9 lines
hw/misc/sifive_e_aon.c new file +9
-0+REG32(AON_WDT_WDOGS, 0x10) +REG32(AON_WDT_WDOGFEED, 0x18) +REG32(AON_WDT_WDOGKEY, 0x1c) +REG32(AON_WDT_WDOGCMP0, 0x20) + +static void sifive_e_aon_wdt_update_wdogcount (SiFiveEAONState *r) +{ +int64_t now; + if (0 == FIELD_EX32(r->wdogcfg, AON_WDT_WDOGCFG, EN_ALWAYS) &&hw/misc/sifive_e_aon.c line 60
Quoted 10 lines
hw/misc/sifive_e_aon.c new file +10
-0+ 0 == FIELD_EX32(r->wdogcfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE)) { +return ; + } + + now =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); + r->wdogcount +=muldiv64 (now - r->wdog_restart_time, + r->wdogclk_freq,NANOSECONDS_PER_SECOND ); + +/* Clean the most significant bit. */ + r->wdogcount = ((r->wdogcount <<1 ) >>1 );... you could use:
r->wdogcount &= R_AON_WDT_WDOGCOUNT_VALUE_MASKhw/misc/sifive_e_aon.c
Quoted 10 lines
hw/misc/sifive_e_aon.c new file +10
-0+ r->wdog_restart_time = now; +} + +static void sifive_e_aon_wdt_update_state(SiFiveEAONState *r) +{ + uint16_t wdogs; + bool cmp_signal = false; + sifive_e_aon_wdt_update_wdogcount(r); + wdogs = (uint16_t)(r->wdogcount >> + FIELD_EX32(r->wdogcfg, AON_WDT_WDOGCFG,SCALE));
hw/misc/sifive_e_aon.c line 81
Quoted 11 lines
hw/misc/sifive_e_aon.c new file +11
-0+ +if (wdogs >= r->wdogcmp0) { + cmp_signal = true; +if (1 ==FIELD_EX32 (r->wdogcfg,AON_WDT_WDOGCFG ,ZEROCMP )) { + r->wdogcount =0 ; + wdogs =0 ; + } + } + +if (cmp_signal) { +if (1 ==FIELD_EX32 (r->wdogcfg,AON_WDT_WDOGCFG ,RSTEN )) {You sometimes check bit equality, ...
hw/misc/sifive_e_aon.c
Quoted 6 lines
hw/misc/sifive_e_aon.c new file +6
-0+watchdog_perform_action (); + } + r->wdogcfg =FIELD_DP32 (r->wdogcfg,AON_WDT_WDOGCFG ,IP0 ,1 ); + } + + qemu_set_irq(r->wdog_irq, FIELD_EX32(r->wdogcfg, AON_WDT_WDOGCFG,IP0));
hw/misc/sifive_e_aon.c line 90
Quoted 3 lines
hw/misc/sifive_e_aon.c new file +3
-0+ + if (wdogs < r->wdogcmp0 && + (FIELD_EX32(r->wdogcfg, AON_WDT_WDOGCFG, EN_ALWAYS) ||... sometimes you don't. Code style consistency would be better.
(Also, most of QEMU code base check equality using constant value on the right side of the comparaison).
Quoted 22 lines
hw/misc/sifive_e_aon.c new file +21
-0+ FIELD_EX32(r->wdogcfg, AON_WDT_WDOGCFG, EN_CORE_AWAKE))) { +int64_t next =qemu_clock_get_ns (QEMU_CLOCK_VIRTUAL ); + next +=muldiv64 ((r->wdogcmp0 - wdogs) << +FIELD_EX32 (r->wdogcfg,AON_WDT_WDOGCFG ,SCALE ), +NANOSECONDS_PER_SECOND , r->wdogclk_freq); +timer_mod (r->wdog_timer, next); + } else { +timer_mod (r->wdog_timer,INT64_MAX ); + } +} +static void sifive_e_aon_init (Object *obj) +{ +SysBusDevice *sbd =SYS_BUS_DEVICE (obj); +SiFiveEAONState *r =SIFIVE_E_AON (obj); + +memory_region_init_io (&r->mmio,OBJECT (r), &sifive_e_aon_ops, r, +TYPE_SIFIVE_E_AON ,SIFIVE_E_AON_MAX ); +sysbus_init_mmio (sbd, &r->mmio); + +/* watchdog timer */ + r->wdogclk_freq =SIFIVE_E_LFCLK_DEFAULT_FREQ ;hw/misc/sifive_e_aon.c
Quoted 10 lines
hw/misc/sifive_e_aon.c new file +10
-0+sysbus_init_irq (sbd, &r->wdog_irq); +} + +static void sifive_e_aon_realize (DeviceState *dev,Error **errp) +{ +SiFiveEAONState *r =SIFIVE_E_AON (dev); + +/* watchdog timer */ + r->wdog_timer =timer_new_ns (QEMU_CLOCK_VIRTUAL , + sifive_e_aon_wdt_expired_cb, r);You should be able to create the timer in
sifive_e_aon_init().Quoted 1 line
+}
Regards,
Phil.
PATCH v4 2/3 hw/riscv: sifive_e: Support the watchdog timer of HiFive 1 rev b.
In reply to Tommy WuCreate the AON device when we realize the sifive_e machine. This patch only implemented the functionality of the watchdog timer, not all the functionality of the AON device.
--- hw/riscv/Kconfig | 1 + hw/riscv/sifive_e.c | 13 +++++++++++-- include/hw/riscv/sifive_e.h | 8 +++++--- 3 files changed, 17 insertions(+), 5 deletions(-)
hw/riscv/Kconfig +1 -0
@@ -60,6 +60,7 @@ config SIFIVE_E select SIFIVE_PLIC select SIFIVE_UART select SIFIVE_E_PRCI + select SIFIVE_E_AON select UNIMP config SIFIVE_U
hw/riscv/sifive_e.c +11 -2
@@ -45,6 +45,7 @@#include "hw/intc/riscv_aclint.h" #include "hw/intc/sifive_plic.h" #include "hw/misc/sifive_e_prci.h" +#include "hw/misc/sifive_e_aon.h" #include "chardev/char.h" #include "sysemu/sysemu.h"
@@ -223,8 +224,13 @@ static void sifive_e_soc_realize(DeviceState *dev, Error **errp)RISCV_ACLINT_DEFAULT_MTIMER_SIZE ,0 , ms->smp.cpus,RISCV_ACLINT_DEFAULT_MTIMECMP ,RISCV_ACLINT_DEFAULT_MTIME , RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ, false); -create_unimplemented_device ("riscv.sifive.e.aon" , - memmap[SIFIVE_E_DEV_AON ].base, memmap[SIFIVE_E_DEV_AON ].size); + + s->aon =qdev_new (TYPE_SIFIVE_E_AON ); +if (!sysbus_realize (SYS_BUS_DEVICE (s->aon), errp)) { +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (s->aon),0 , memmap[SIFIVE_E_DEV_AON ].base); +sifive_e_prci_create (memmap[SIFIVE_E_DEV_PRCI ].base);/* GPIO */
@@ -245,6 +251,9 @@ static void sifive_e_soc_realize(DeviceState *dev, Error **errp)qdev_get_gpio_in (DEVICE (s->plic), SIFIVE_E_GPIO0_IRQ0 + i)); } +sysbus_connect_irq (SYS_BUS_DEVICE (s->aon),0 , +qdev_get_gpio_in (DEVICE (s->plic), +SIFIVE_E_AON_WDT_IRQ ));sifive_uart_create (sys_mem, memmap[SIFIVE_E_DEV_UART0 ].base,serial_hd (0 ),qdev_get_gpio_in (DEVICE (s->plic),SIFIVE_E_UART0_IRQ ));
include/hw/riscv/sifive_e.h +5 -3
@@ -35,6 +35,7 @@ typedef struct SiFiveESoCState {/*< public >*/ RISCVHartArrayState cpus;DeviceState *plic; +DeviceState *aon;SIFIVEGPIOState gpio;MemoryRegion xip_mem;MemoryRegion mask_rom;
@@ -76,9 +77,10 @@ enum { };enum { -SIFIVE_E_UART0_IRQ =3 , -SIFIVE_E_UART1_IRQ =4 , -SIFIVE_E_GPIO0_IRQ0 =8 +SIFIVE_E_AON_WDT_IRQ =1 , +SIFIVE_E_UART0_IRQ =3 , +SIFIVE_E_UART1_IRQ =4 , +SIFIVE_E_GPIO0_IRQ0 =8 };#define SIFIVE_E_PLIC_HART_CONFIG "M"
Signature · 1 line
2.27.0
Re: [PATCH v4 2/3] hw/riscv: sifive_e: Support the watchdog timer of HiFive 1 rev b.
Quoted 7 lines · Tommy Wu
Create the AON device when we realize the
sifive_emachine. This patch only implemented the functionality of the watchdog timer, not all the functionality of the AON device.Signed-off-by Tommy Wu <[email protected]>Reviewed-by Frank Chang <[email protected]>
Alistair
Quoted 86 lines
--- hw/riscv/Kconfig | 1 + hw/riscv/sifive_e.c | 13 +++++++++++-- include/hw/riscv/sifive_e.h | 8 +++++--- 3 files changed, 17 insertions(+), 5 deletions(-)hw/riscv/Kconfig +1
-0@@ -60,6 +60,7 @@ config SIFIVE_E select SIFIVE_PLIC select SIFIVE_UART select SIFIVE_E_PRCI + select SIFIVE_E_AON select UNIMP config SIFIVE_Uhw/riscv/sifive_e.c +11
-2@@ -45,6 +45,7 @@#include "hw/intc/riscv_aclint.h" #include "hw/intc/sifive_plic.h" #include "hw/misc/sifive_e_prci.h" +#include "hw/misc/sifive_e_aon.h" #include "chardev/char.h" #include "sysemu/sysemu.h" @@ -223,8 +224,13 @@ static void sifive_e_soc_realize(DeviceState *dev, Error **errp)RISCV_ACLINT_DEFAULT_MTIMER_SIZE ,0 , ms->smp.cpus,RISCV_ACLINT_DEFAULT_MTIMECMP ,RISCV_ACLINT_DEFAULT_MTIME , RISCV_ACLINT_DEFAULT_TIMEBASE_FREQ, false); -create_unimplemented_device ("riscv.sifive.e.aon" , - memmap[SIFIVE_E_DEV_AON ].base, memmap[SIFIVE_E_DEV_AON ].size); + + s->aon =qdev_new (TYPE_SIFIVE_E_AON ); +if (!sysbus_realize (SYS_BUS_DEVICE (s->aon), errp)) { +return ; + } +sysbus_mmio_map (SYS_BUS_DEVICE (s->aon),0 , memmap[SIFIVE_E_DEV_AON ].base); +sifive_e_prci_create (memmap[SIFIVE_E_DEV_PRCI ].base);/* GPIO */ @@ -245,6 +251,9 @@ static void sifive_e_soc_realize(DeviceState *dev, Error **errp)qdev_get_gpio_in (DEVICE (s->plic), SIFIVE_E_GPIO0_IRQ0 + i)); } +sysbus_connect_irq (SYS_BUS_DEVICE (s->aon),0 , +qdev_get_gpio_in (DEVICE (s->plic), +SIFIVE_E_AON_WDT_IRQ ));sifive_uart_create (sys_mem, memmap[SIFIVE_E_DEV_UART0 ].base,serial_hd (0 ),qdev_get_gpio_in (DEVICE (s->plic),SIFIVE_E_UART0_IRQ ));include/hw/riscv/sifive_e.h +5
-4@@ -35,6 +35,7 @@ typedef struct SiFiveESoCState {/*< public >*/ RISCVHartArrayState cpus;DeviceState *plic; +DeviceState *aon;SIFIVEGPIOState gpio;MemoryRegion xip_mem;MemoryRegion mask_rom;@@ -76,9 +77,10 @@ enum { };enum { -SIFIVE_E_UART0_IRQ =3 , -SIFIVE_E_UART1_IRQ =4 , -SIFIVE_E_GPIO0_IRQ0 =8 +SIFIVE_E_AON_WDT_IRQ =1 , +SIFIVE_E_UART0_IRQ =3 , +SIFIVE_E_UART1_IRQ =4 , +SIFIVE_E_GPIO0_IRQ0 =8 };#define SIFIVE_E_PLIC_HART_CONFIG "M" --2.27.0
Re: [PATCH v4 2/3] hw/riscv: sifive_e: Support the watchdog timer of HiFive 1 rev b.
In reply to Tommy WuQuoted 18 lines · Tommy Wu
Create the AON device when we realize the
sifive_emachine. This patch only implemented the functionality of the watchdog timer, not all the functionality of the AON device.Signed-off-by Tommy Wu <[email protected]>Reviewed-by Frank Chang <[email protected]>--- hw/riscv/Kconfig | 1 + hw/riscv/sifive_e.c | 13 +++++++++++-- include/hw/riscv/sifive_e.h | 8 +++++--- 3 files changed, 17 insertions(+), 5 deletions(-)include/hw/riscv/sifive_e.h +0
-0
include/hw/riscv/sifive_e.h typedef struct SiFiveESoCState { · line 38
Quoted 4 lines
include/hw/riscv/sifive_e.h +1
-0@@ -35,6 +35,7 @@ typedef struct SiFiveESoCState {/*< public >*/ RISCVHartArrayState cpus;DeviceState *plic; +DeviceState *aon;
Preferably allocate the device state in the SoC, similar to gpio:
SiFiveEAONState aon;
Quoted 6 lines
include/hw/riscv/sifive_e.h +0
-0SIFIVEGPIOState gpio;MemoryRegion xip_mem;MemoryRegion mask_rom;@@ -76,9 +77,10 @@ enum { };
PATCH v4 3/3 tests/qtest: sifive-e-aon-watchdog-test.c: Add QTest of watchdog of sifive_e
In reply to Tommy WuAdd some simple tests of the watchdog timer in the always-on domain device of HiFive 1 rev b.
--- tests/qtest/meson.build | 3 + tests/qtest/sifive-e-aon-watchdog-test.c | 450 +++++++++++++++++++++++ 2 files changed, 453 insertions(+) create mode 100644 tests/qtest/sifive-e-aon-watchdog-test.c
tests/qtest/meson.build +3 -0
@@ -231,6 +231,9 @@ qtests_s390x = \ 'cpu-plug-test', 'migration-test'] +qtests_riscv32 = \ + (config_all_devices.has_key('CONFIG_SIFIVE_E_AON') ? ['sifive-e-aon-watchdog-test'] : []) + qos_test_ss = ss.source_set() qos_test_ss.add( 'ac97-test.c',
tests/qtest/sifive-e-aon-watchdog-test.c new file +450 -0
450 lines not on this page · raw message
Signature · 1 line
2.27.0
Re: [PATCH v4 3/3] tests/qtest: sifive-e-aon-watchdog-test.c: Add QTest of watchdog of sifive_e
Quoted 10 lines · Tommy Wu
Add some simple tests of the watchdog timer in the always-on domain device of HiFive 1 rev b.
Signed-off-by Tommy Wu <[email protected]>Reviewed-by Frank Chang <[email protected]>--- tests/qtest/meson.build | 3 + tests/qtest/sifive-e-aon-watchdog-test.c | 450 +++++++++++++++++++++++ 2 files changed, 453 insertions(+)create mode 100644
tests/qtest/sifive-e-aon-watchdog-test.c