[Linux-stm32] [RFC PATCH 2/3] watchdog: arm_smc_wdt: try every id of arm, smc-id
Mateusz Nowicki
mateusz.nowicki at posteo.net
Wed Nov 4 17:16:06 CET 2026
The SMC function id of the watchdog service is not discoverable, and
firmware for the same SoC does not always use the same one: on the
STM32MP2 SoCs it is 0xbc000000 (the OP-TEE default for the platform) or
0xb200005a. With a single id in the SoC dtsi, every board whose firmware
uses the other id loses its watchdog.
Read arm,smc-id as a list and use the first id for which SMCWD_INIT
succeeds. Go to the next id on any error: OP-TEE answers an unknown
function id with 0xffffffff in a0, which smcwd_call() reports as -EIO,
not -ENODEV. A missing property still means 0x82003D06.
Signed-off-by: Mateusz Nowicki <mateusz.nowicki at posteo.net>
---
drivers/watchdog/arm_smc_wdt.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/watchdog/arm_smc_wdt.c b/drivers/watchdog/arm_smc_wdt.c
index c73ed1dcdfcb..993c8f92c871 100644
--- a/drivers/watchdog/arm_smc_wdt.c
+++ b/drivers/watchdog/arm_smc_wdt.c
@@ -113,8 +113,9 @@ static const struct watchdog_ops smcwd_timeleft_ops = {
static int smcwd_probe(struct platform_device *pdev)
{
+ struct device_node *np = pdev->dev.of_node;
struct watchdog_device *wdd;
- int err;
+ int err, i, n;
struct arm_smccc_res res;
u32 smc_func_id;
@@ -123,12 +124,17 @@ static int smcwd_probe(struct platform_device *pdev)
return -ENOMEM;
platform_set_drvdata(pdev, wdd);
- if (of_property_read_u32(pdev->dev.of_node, "arm,smc-id",
- &smc_func_id))
- smc_func_id = 0x82003D06;
- watchdog_set_drvdata(wdd, (void *)(uintptr_t)smc_func_id);
+ /* The id is not discoverable: take the first one of the list the firmware accepts */
+ n = of_property_count_u32_elems(np, "arm,smc-id");
+ for (i = 0; i < max(n, 1); i++) {
+ if (of_property_read_u32_index(np, "arm,smc-id", i, &smc_func_id))
+ smc_func_id = 0x82003D06;
+ watchdog_set_drvdata(wdd, (void *)(uintptr_t)smc_func_id);
- err = smcwd_call(wdd, SMCWD_INIT, 0, &res);
+ err = smcwd_call(wdd, SMCWD_INIT, 0, &res);
+ if (!err)
+ break;
+ }
if (err < 0)
return err;
--
2.56.0
More information about the Linux-stm32
mailing list