Replace direct NVIC_*PendingIRQ()/NVIC_EnableIRQ()/NVIC_DisableIRQ()
calls with k_irq_clear_pending()/k_irq_set_pending()/k_irq_is_pending() and
irq_enable()/irq_disable(), dropping the driver's dependency on
cmsis_core.h where nothing else needed it.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
The CMSDK APB watchdog supports only channel 0, but its feed callback
ignores channel_id. Requests for invalid channels therefore reload
the watchdog instead of returning -EINVAL.
Assisted-by: Codex:gpt-5.6-sol
Signed-off-by: ShiRong Liu <sheltonliu.work@outlook.com>
CONFIG_SOC_SERIES_LPC54XXX selects a CLOCK_SetClkDiv(kCLOCK_DivWdtClk)
call, but neither SoC in the series has a WDTCLKDIV register, so
neither SDK defines kCLOCK_DivWdtClk and the branch does not compile.
The watchdog is fed by the dedicated watchdog oscillator; its only
divider is the DIVSEL field of WDTOSCCTRL, which selects the
oscillator frequency together with FREQSEL rather than dividing a
clock routed to the peripheral. CLOCK_GetWdtOscFreq() already accounts
for it, so the rate the driver reads stays correct.
The branch has never been built: it is guarded on an enabled wwdt node
and no LPC54xxx board had one. Enabling the watchdog on lpcxpresso54628
is what turns it into a build error.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Marvin Gnad <marvin.gnad@gmail.com>
Add a CONFIG_PM_DEVICE handler that stops the WDT on suspend and
restarts it with a fresh timeout on resume, gated on the
WDT_OPT_PAUSE_IN_SLEEP option (previously rejected with -ENOTSUP).
Behavior is unchanged when the option is not requested.
Signed-off-by: Manimaran A <manimaran.a@microchip.com>
Assisted-by: Claude:claude-opus-4-8
iwdg_stm32_isr() is only connected with IRQ_CONNECT() in this file,
nothing outside the file references it.
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
TOVAL and WIN are 16-bit registers, but the driver computed the tick
count with 32-bit arithmetic and assigned it to the 16-bit config
fields, so a value above 65535 was truncated without any error. On an
MCXW71 the SoC node runs the watchdog from the 32.768 kHz RTCOSC with
clk-divider 1, so the counter can hold at most 1999 ms; a task watchdog
configured for 2000 + 100 ms asked for 68812 ticks and got 3276, a
100 ms window. Every long interrupt-locked flash erase then reset the
SoC (an MCUboot image upload, first chunk, every time).
Compute the ticks in 64 bits, so that a megahertz-class clock times a
multi-second timeout cannot wrap either, and return -EINVAL with a log
line naming the largest window this clock and divider allow.
Tested on a u-blox NINA-B506 (MCXW716C): the 2100 ms request at
divider 1 is now refused at install time; at divider 256 it programs
TOVAL 268 and a starved task watchdog channel resets the SoC 2.1 s
after its trip, as configured.
Fixes#121398
Assisted-by: Claude:claude-fable-5-1
Signed-off-by: Joern Ihlenburg <ihlenburg@ihlems.de>
Stop active Xen domain watchdog timers during device PM suspend and
recreate them on resume. The PM path keeps the watchdog setup state
owned by the public watchdog API: suspend only records PM state and
tears down the Xen timers temporarily, while disable remains the path
that clears installed channel configuration.
Reject setup, disable, and timeout installation while the device is
suspended. This prevents public API calls from racing with PM resume and
losing a Xen timer ID or re-arming a watchdog that the application meant
to disable.
Use a non-blocking take of the device-wide setup/teardown semaphore in
the PM callback and return -EBUSY if another watchdog operation owns it.
The suspend path also uses non-blocking per-channel locks before
tearing down active Xen timers, so it reports -EBUSY instead of waiting
for an in-flight feed operation.
Signed-off-by: Vladyslav Goncharuk <vladyslav_goncharuk@epam.com>
Assisted-by: Codex:gpt-5
Expose Xen domain watchdog timers through Zephyr's watchdog driver API.
The backend maps each Zephyr channel to the Xen watchdog ID returned by
xen_sched_watchdog(), converts Zephyr millisecond timeouts to Xen's
second-based timeout values, and takes the number of exposed channels
from devicetree.
Xen owns the actual timer and applies the domain watchdog policy when
the guest misses a feed, so unsupported Zephyr features are rejected
explicitly: callbacks, windowed timeouts, pause options, reset semantics
other than domain reset, and timeout windows shorter than one second.
Track installed and active channel state with atomics so feed operations
can run without taking the setup/teardown semaphore. Feed and teardown
of the same channel use a per-channel semaphore, so teardown blocks in
the scheduler while a feed hypercall is in progress instead of spinning
on a manually tracked in-flight count.
Map watchdog API failures to the documented errno values. Timeout
installation reports -ENOMEM when no channel is available, and feed
reports -EINVAL for invalid or inactive channels.
Signed-off-by: Vladyslav Goncharuk <vladyslav_goncharuk@epam.com>
Assisted-by: Codex:gpt-5
Add driver for Silicon Labs Series 3 WDOG peripheral. The
driver supports window min/max as well as a warning interrupt
(multistage).
Signed-off-by: Aksel Skauge Mellbye <aksel.mellbye@silabs.com>
On MCXW SoCs the EWM is clock gated. Until the MCXW clock control driver
was introduced, soc.c opened the gate unconditionally.
PR #101937 removed that hardcoded initialization and described the
gate in dts instead, but wdt_nxp_ewm never consumed the new "clocks"
property. The gate is left closed and the first register write in
nxp_ewm_init() takes a precise bus error.
Enable the clock during init for instances that describe one. SoCs that
do not gate the EWM have no "clocks" property and keep the previous
behaviour.
Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
install_timeout() derives the window value by subtracting the lower
window bound from the timeout, both unsigned, so a config with
window.min above window.max underflowed into a huge window value instead
of being rejected. Validate the window before converting it.
Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
install_timeout() only stored the callback inside the branch taken for a
non-NULL one, so installing a timeout without a callback after a
disable() silently kept the previously installed one, and a caller that
deliberately drops its callback would still be called back. Assign it
unconditionally and turn the unsupported combination into an early
return.
Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
install_timeout() only stored the callback when a non-NULL one was
passed, so installing a timeout without a callback silently kept the
previously installed one, and a caller that deliberately drops its
callback would still be called back. Assign it unconditionally.
The same condition also compared cfg->window.min >= 0 on an unsigned
field, which is always true; drop it.
Signed-off-by: Yves Wang <zhengjia.wang@nxp.com>
This commit enables the new clock managers by switching the device
tree to use the new bindings. It also moves some initialization code
from the old clock manager to soc_early_init_hook() since some clocks
configuration needs to be done before the clock drivers are initialized.
Signed-off-by: Martin Hoff <martin.hoff@silabs.com>
IRQ_CONNECT() is passed DT_INST_IRQ(i, flags), which requires the
interrupt controller binding to define a flags cell. The ARM NVIC
binding defines only irq and priority, so a ti,j7-rti-wdt node with an
interrupts property fails to build on Cortex-M.
Pass the flags cell where it exists and 0 otherwise.
Signed-off-by: Chrispine Tinega <dev@chrispinetinega.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending(), dropping the dependency on
cmsis_core.h where nothing else needed it.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Use controller/peripheral and SDO/SDI terminology in the remaining
SPI-using drivers (audio, auxdisplay, bluetooth HCI, dac, eeprom,
ethernet, flash, fpga, gpio, haptics, hdlc_rcp_if, ieee802154,
input, led, led_strip, lora, mfd, misc, mux, rtc, sdhc, stepper,
video, watchdog, wifi) and the ec_host_cmd SPI STM32 backend,
following coding guideline rule A.2: switch to
SPI_OP_MODE_CONTROLLER/PERIPHERAL and SPI_SDO_OVERRUN_DT, rename
Zephyr-owned identifiers (the HCI SPI header buffers, the winc1500
bus wrapper transfer parameters), and update comments, log messages
and Kconfig help prose.
Vendor and out-of-scope identifiers keep their names: STM32
LL_SPI_MODE_SLAVE in the ec_host_cmd backend, the ATWINC1500 SDK I2C
SLAVE_ADDRESS definition, and the I2S codec clock-role variable in
tlv320aic26.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Two-line copyright notices were wrapped in the SPDX "<text>...</text>"
construct, which is only valid in an SPDX document, not a file header.
The REUSE tool then folds the literal "<text>" into the holder name
and drops the second line from the SBOM.
Remove the markers and tag the continuation line. Holder, year and
e-mail are left unchanged; only the syntax is fixed.
Signed-off-by: Parthiban Nallathambi <parthiban@linumiz.com>
install_timeout() reports the timeout it settled on with LOG_ERR, on every
call, whether or not anything was rounded, and the message carries an
embedded newline that breaks the log's own framing.
Nothing here is an error: the driver granularity is fixed and a requested
window that does not land on it is rounded by design. Warn instead, only
when a value actually changed, and say what was asked for beside what was
installed - which is the part a caller needs and the old message left out.
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
The driver waits one millisecond for TCC_SYNCBUSY-style synchronization to
finish, but the watchdog is clocked from the internal ultra low power
oscillator, which reaches the peripheral at about 1.024 kHz on parts of
this family. A single synchronization therefore costs milliseconds rather
than microseconds: enabling the watchdog on a PIC32CM GC00 was measured at
1.12 ms.
The consequence is not only a logged timeout on every boot. The wait
returns while the peripheral is still synchronizing and the driver carries
on writing registers the hardware discards in that state, so the
configuration that ends up in the watchdog is not the one that was asked
for.
Five milliseconds covers the measured value with margin and costs nothing
on a part whose synchronization is quicker, because the wait ends on the
flag rather than on the timeout.
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
Four properties are read with DT_PROP(DT_NODELABEL(wdt), ...), so the
driver compiles only against a devicetree that labels its watchdog node
exactly `wdt`. Nothing in the binding says so, and a board that picks
another label gets an unknown-node error out of the devicetree macros
rather than anything pointing at the cause. Every other property in the
driver already comes through DT_INST.
The driver is single instance in practice - it defines DT_DRV_COMPAT and
iterates with DT_INST_FOREACH_STATUS_OKAY, but these four values size a
structure and bound a loop at compile time, so they cannot vary per
instance without a larger change. DT_INST_PROP(0, ...) keeps that
restriction exactly as it is and drops the dependency on a label.
Left alone deliberately, and worth a maintainer's eye: the neighbouring
WDT_FLAG_ONLY_ONE_TIMEOUT_VALUE_SUPPORTED reads
only_one_timeout_val_supported_flag from DT_NODELABEL(wdog), a label no
devicetree in the tree defines, and the property appears in no binding.
It survives only because it is tested with #if defined(), which is true
for any object-like macro, so the code it guards is compiled
unconditionally and the macro itself is never expanded. Making the guard
honest would change behaviour on every part this driver serves, which is
not a change to make from one board.
Signed-off-by: Arkadiusz Grzelka <devitwise@gmail.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending(), dropping the dependency on
cmsis_core.h where nothing else needed it.
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Replace direct NVIC pending-state calls with k_irq_set_pending()/
k_irq_is_pending()/k_irq_clear_pending().
Assisted-by: Claude:claude-opus-5
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This adds support for the ARM Corstone System Architecture Specification
Ma2 (ARM CRSAS-MA2) Watchdog Timers.
Signed-off-by: Mike J. Chen <mjchen@google.com>
Co-authored-by: Wojciech Sipak <wsipak@antmicro.com>
Signed-off-by: Wojciech Sipak <wsipak@antmicro.com>
Header file include/zephyr/sys_clock.h is deprecated and will be removed
someday. Update the whole file tree to include zephyr/sys/clock.h
straight instead of zephyr/sys_clock.h.
This change was made running the sed shell command below:
$ sed -i 's/zephyr\/sys_clock\.h/zephyr\/sys\/clock\.h/' \
`grep -rsl "zephyr/sys_clock\.h" drivers/watchdog`
Signed-off-by: Etienne Carriere <etienne.carriere@st.com>
The RTWDOG driver previously rejected WDT_OPT_PAUSE_IN_SLEEP with
-ENOTSUP, even though the hardware supports stopping the counter
in low-power modes via workMode.enableWait and workMode.enableStop.
Map WDT_OPT_PAUSE_IN_SLEEP to both enableWait and enableStop fields.
Assisted-by: Claude:opus-4.6
Signed-off-by: Jason Yu <zejiang.yu@nxp.com>
Keep the timeout calculation in 64-bit arithmetic through the hardware
range validation so that oversized timeouts are rejected instead of being
truncated.
Signed-off-by: Kevin Wang <kevinwang821020@gmail.com>
(options & A) || (options & B) is equivalent to options & (A | B).
Collapse the two WDT_OPT_PAUSE_IN_SLEEP / WDT_OPT_PAUSE_HALTED_BY_DBG
tests into a single masked check.
Signed-off-by: Flavio Ceolin <flavio@hubble.com>
The reset flags are a two-bit enumerated field, not independent
bits, so testing flags with a bitwise AND against
WDT_FLAG_RESET_CPU_CORE left WDT_FLAG_RESET_SOC without reset
enabled. The flag was also never cleared on re-install. Derive
allow_reset from the masked field on every install.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The window lookup indices are computed against the closest
achievable period, which can be smaller than the requested window
bounds, producing index 5 and reading one past the end of the
five-entry lookup tables. Clamp the indices so an out-of-range
start hits the invalid sentinel and the end saturates at 100%.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The period calculation bailed out when the clock rate was
non-zero, i.e. on every successful clock query, so the computed
period was always zero and install_timeout() always failed with
-EINVAL. Bail out on a zero rate instead.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
The millisecond timeout was multiplied by the external clock
frequency in 32-bit arithmetic, overflowing for timeouts above
131 seconds and programming a much shorter period than requested.
Do the conversion in 64-bit.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
Add a spinlock-protected `enabled` flag to the driver data struct to
eliminate the race between wdt_nrf_gswdt_disable() and
wdt_nrf_gswdt_feed(). The spinlock is held across both the state check
and mbox_send_dt() in the feed path, and across the flag update in the
setup and disable paths, ensuring a consistent view of the enabled
state. Sending feed when wdt was not enabled would cause watchdog
to start counting down the timeout.
Signed-off-by: Łukasz Stępnicki <lukasz.stepnicki@nordicsemi.no>
- Removes the compile-time guard so the peripheral clock is always
enabled in the driver init path, ensuring the WWDT registers
are accessible.
Otherwise, at least for MCXA, WWDT register access by
mcux_wwdt_config_func()->WWDT_ClearStatusFlags() triggers
data bus fault.
- Tested on frdm-mcxa266.
Signed-off-by: Andrej Butok <andrey.butok@nxp.com>
Add WWDT (Windowed WatchDog Timer) support for all LPC55Sxx variants
(LPC55S06/S16/S28/S36/S69):
DTS / board changes:
- Add wwdt0 node (compatible = "nxp,lpc-wwdt", reg = 0xc000) and
watchdog0 alias to nxp_lpc55S0x/S1x/S3x_common.dtsi
- Enable wwdt0 and add watchdog to supported features on
lpcxpresso55s06, lpcxpresso55s16, lpcxpresso55s36 boards
SoC / clock:
- soc.c: call CLOCK_SetClkDiv(kCLOCK_DivWdtClk, 1U, true) when
wwdt0 is enabled, alongside the existing FRO1MHz enable
Driver hardening (per hakehuang review):
- Add `bool started` flag to mcux_wwdt_data to track post-setup state
- Set started=true in mcux_wwdt_setup(), clear in mcux_wwdt_disable()
and PM_DEVICE_ACTION_TURN_OFF
- Guard mcux_wwdt_isr() with early return when !started, preventing
spurious callbacks from warm-reset stale WWDT status on LPC55S36
- Clear WWDT status flags + NVIC pending bit before irq_enable() in
the IRQ init macro
Tests:
- Add per-board .conf files for wdt_basic_api; lpcxpresso55s06/s16
use SRAMX noinit section to survive TrustZone NS Boot ROM clears;
all boards enable WDT_MCUX_WWDT_WARNING_INTERRUPT_CFG=10
- Update testcase.yaml filter to allow SOC_SERIES_LPC55XXX and
exclude lpcxpresso55s69 NS variant
Tested with tests/drivers/watchdog/wdt_basic_api on lpcxpresso55s36:
SUITE PASS 100% [wdt_basic_test_suite]: pass=1, fail=0, skip=0
Signed-off-by: Peter Wang <chaoyi.wang@nxp.com>
Added option to nrf gswdt drivers to be able to configure
maximum timeout window and also to be able to stop gswdt.
This features are only available when gswdt service is
supported by local domain, otherwise gswdt can still be
used but with fixed timeout and cant be stopped.
Signed-off-by: Łukasz Stępnicki <lukasz.stepnicki@nordicsemi.no>
New driver based on sysctrl acting as a watchdog.
After global software watchdog setup sysctrl will monitor
pings from particular local domain and reset SOC if ping
doesnt arrive before 6s timeout expires.
This software watchdog will be active only if local
domain will do wdt setup procedure.'
Signed-off-by: Łukasz Stępnicki <lukasz.stepnicki@nordicsemi.no>
- Kconfigs in modules/ should not define configs with an SOC_ prefix.
Furthermore, these options are SDK specific, not SoC specific.
- The simplicity_sdk configs do the same.
Signed-off-by: Michael Zimmermann <michael.zimmermann@sevenlab.de>
ESP32-P4 does not provide soc/rtc_cntl_reg.h. Skip including
it on P4 along with the existing skip for C5/C6/H2.
Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>