[rulkc] [PATCH] hw/watchdog: Add BE-U1000 watchdog timer model
Nikita Shubin
nikita.shubin at maquefel.me
Mon Nov 23 10:42:58 MSK 2026
Hi Viktor!
Welcome, and thanks for taking the time to contribute this!
On Sun, 2026-11-22 at 13:05 +0300, Viktor Kutuzov wrote:
> Add a QEMU model of the BE-U1000 watchdog timer and wire both WDT0
> and WDT1 into the be-u1000 SoC. On timeout it performs a system
> reset; interrupt mode is not yet modelled.
>
> +static void be_u1000_wdt_write(void *opaque, hwaddr addr,
> + uint64_t value, unsigned int size)
> +{
> + BEU1000WdtState *s = BEU1000_WDT(opaque);
> +
> + trace_be_u1000_wdt_write(addr, value);
> +
> + switch (addr) {
> + case BEU1000_WDT_CR:
> + s->cr = value & (BEU1000_WDT_CR_RPL_MASK <<
> BEU1000_WDT_CR_RPL_SHIFT |
> + BEU1000_WDT_CR_RMOD |
> BEU1000_WDT_CR_WDT_EN);
> +
> + s->enabled = (s->cr & BEU1000_WDT_CR_WDT_EN) != 0;
The RM states in WDT_EN description:
"The WDT is used to prevent system lock-up. To prevent a software bug
from disabling the WDT, once this bit has been enabled, it can be
cleared only by a system reset."
Shouldn't we latch the WDT_EN on enable=1 and keep it until reset ?
> +
> + be_u1000_wdt_update_timer(s);
> + break;
> +
> + case BEU1000_WDT_TORR:
> + s->torr = value & BEU1000_WDT_TORR_TOP_MASK;
> +
> + s->timeout_value = be_u1000_wdt_calculate_timeout(s->torr);
> + s->current_count = s->timeout_value;
> +
> + if (s->enabled) {
> + be_u1000_wdt_update_timer(s);
"This field is used to select the timeout period from which the
watchdog counter restarts. A change of the timeout period takes effect
only after the next counter restart (kick)."
But as i see it takes effect immediately.
Also check if WDT1 (i think it shouldn't) is resetting the whole system
as it currently does in this patch same as WDT0 - if not make a
separate option explicitly set for WDT1 creation so WDT1 hit doesn't
affect the system.
With above issues fixed - LGTM.
Some TODOs for later patches:
- be_u1000_wdt_read() siletly returns zero for missing register, adding
qemu_log_mask(LOG_GUEST_ERROR, …) is desirable on default: path;
- WDTs should export some gpios/irqs so they can be connected to CLIC
or CRU.
- integrate with CRU:
- current freq for WDT is fixed, CRU clk should be used;
- on WDT0 reboot should set WDTHIT in SYSSR0 (check if only WDT0
should do it) - i think it should be done by separate gpio line
connected from WDT to CRU;
Yours,
Shubin.
More information about the rulkc
mailing list