]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
watchdog: arm_smc_wdt: get wdt status through SMCWD_GET_TIMELEFT
authorAntonio Borneo <antonio.borneo@foss.st.com>
Fri, 23 May 2025 09:46:56 +0000 (11:46 +0200)
committerStefan Roese <stefan.roese@mailbox.org>
Wed, 30 Jul 2025 06:01:11 +0000 (08:01 +0200)
The optional SMCWD_GET_TIMELEFT command can be used to detect if
the watchdog has already been started.
See the implementation in OP-TEE secure OS [1].

At probe time, check if the watchdog is already started and then
call wdt_set_force_autostart(). This will keep U-Boot pinging the
watchdog even when the property 'u-boot,noautostart' is present.

Link: https://github.com/OP-TEE/optee_os/commit/a7f2d4bd8632
Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
Reviewed-by: Patrice Chotard <patrice.chotard@foss.st.com>
drivers/watchdog/arm_smc_wdt.c

index 0ea4444570078b2265a98ce987bef4f1cc386187..f6854aa9ac931cb8b0b0111e8d31763939c5e2ed 100644 (file)
@@ -46,6 +46,8 @@ static int smcwd_call(struct udevice *dev, enum smcwd_call call,
                return -ENODEV;
        if (res->a0 == PSCI_RET_INVALID_PARAMS)
                return -EINVAL;
+       if (res->a0 == PSCI_RET_DISABLED)
+               return -ENODATA;
        if (res->a0 != PSCI_RET_SUCCESS)
                return -EIO;
 
@@ -99,6 +101,21 @@ static int smcwd_probe(struct udevice *dev)
        priv->min_timeout = res.a1;
        priv->max_timeout = res.a2;
 
+       /* If already started, then force u-boot to use it */
+       err = smcwd_call(dev, SMCWD_GET_TIMELEFT, 0, NULL);
+       switch (err) {
+       case 0:
+               dev_dbg(dev, "Already started\n");
+               wdt_set_force_autostart(dev);
+               break;
+       case -ENODATA:
+               dev_dbg(dev, "Not already started\n");
+               break;
+       default:
+               /* Optional SMCWD_GET_TIMELEFT not implemented */
+               break;
+       }
+
        return 0;
 }