On 5/23/25 11:46, Antonio Borneo wrote:
> The watchdog could have been already started by a previous boot
> stage (e.g. bootrom or secure OS). U-Boot has to start and kick
> the watchdog even when CONFIG_WATCHDOG_AUTOSTART is not enabled
> or when the DT property u-boot,noautostart is present.
>
> Add the helper wdt_set_force_autostart() that can be called by the
> driver's probe() when it detects that the watchdog has already
> been started and is running.
>
> Co-developed-by: Patrice Chotard <patrice.chot...@foss.st.com>
> Signed-off-by: Patrice Chotard <patrice.chot...@foss.st.com>
> Signed-off-by: Antonio Borneo <antonio.bor...@foss.st.com>
> ---
> drivers/watchdog/wdt-uclass.c | 9 +++++++++
> include/wdt.h | 9 +++++++++
> 2 files changed, 18 insertions(+)
>
> diff --git a/drivers/watchdog/wdt-uclass.c b/drivers/watchdog/wdt-uclass.c
> index 10be334e9ed..b32590069d9 100644
> --- a/drivers/watchdog/wdt-uclass.c
> +++ b/drivers/watchdog/wdt-uclass.c
> @@ -46,6 +46,15 @@ struct wdt_priv {
> struct cyclic_info cyclic;
> };
>
> +int wdt_set_force_autostart(struct udevice *dev)
> +{
> + struct wdt_priv *priv = dev_get_uclass_priv(dev);
> +
> + priv->autostart = true;
> +
> + return 0;
> +}
> +
> static void wdt_cyclic(struct cyclic_info *c)
> {
> struct wdt_priv *priv = container_of(c, struct wdt_priv, cyclic);
> diff --git a/include/wdt.h b/include/wdt.h
> index 5026f5a6db4..1ef656585c4 100644
> --- a/include/wdt.h
> +++ b/include/wdt.h
> @@ -18,6 +18,15 @@ struct udevice;
> * which typically include placing the system in a safe, known state.
> */
>
> +/*
> + * Force watchdog start during init. Called by driver's probe when the
> watchdog
> + * is detected as already started.
> + *
> + * @dev: WDT Device
> + * @return: 0 if OK, -ve on error
> + */
> +int wdt_set_force_autostart(struct udevice *dev);
> +
> /*
> * Start the timer
> *
Reviewed-by: Patrice Chotard <patrice.chot...@foss.st.com>
Thanks
Patrice