On 4/15/24 15:48, Marek Vasut wrote:
The STM32MP15xx IWDG adds registers which permit this IP to generate
pretimeout interrupt. This interrupt can also be used to wake the CPU
from suspend. Implement support for generating this interrupt and let
userspace configure the pretimeout. In case the pretimeout is not
configured by user, set pretimeout to 3/4 of the WDT timeout cycle.
Reviewed-by: Clément Le Goffic <clement.legoffic@xxxxxxxxxxx>
Tested-by: Clément Le Goffic <clement.legoffic@xxxxxxxxxxx>
Signed-off-by: Marek Vasut <marex@xxxxxxx>
---
Cc: Alexandre Torgue <alexandre.torgue@xxxxxxxxxxx>
Cc: Guenter Roeck <linux@xxxxxxxxxxxx>
Cc: Maxime Coquelin <mcoquelin.stm32@xxxxxxxxx>
Cc: Wim Van Sebroeck <wim@xxxxxxxxxxxxxxxxxx>
Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
Cc: linux-stm32@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
Cc: linux-watchdog@xxxxxxxxxxxxxxx
---
V2: - Subtract the pretimeout value from timeout value before writing it
into the IWDG pretimeout register, because the watchdog counter
register is counting down, and the pretimeout interrupt triggers
when watchdog counter register matches the pretimeout register
content.
- Set default pretimeout to 3/4 of timeout .
V3: - Use dev instead of pdev->dev
- Swap order of ret/return 0
- Split this from the DT changes, which are orthogonal
- Uh, this patch got stuck in upstreaming queue, sorry
V4: - Update commit message to match V2 default pretimeout to 3/4
- Add RB/TB from Clément
---
drivers/watchdog/stm32_iwdg.c | 95 ++++++++++++++++++++++++++++++++++-
1 file changed, 94 insertions(+), 1 deletion(-)
diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
index 5404e03876202..d700e0d49bb95 100644
--- a/drivers/watchdog/stm32_iwdg.c
+++ b/drivers/watchdog/stm32_iwdg.c
[.....]
+
+ irq = platform_get_irq(pdev, 0);
+ if (irq <= 0)
+ return 0;
Hi Marek,
After re-evaluating this patch, it seems it lacks of a dt-bindings
update that tackles the 'interrupts' property you are adding.
That said, the interrupt line should not be mandatory for the driver to
probe. For backward compatibility with existing DT, I recommend to use
the 'platform_get_irq_optional()' API to not fail during the probe of
the driver.
Best regards,
Clément