[PATCH v2 3/3] watchdog: gpio_wdt: implement support for optional "delay" clock

From: Rasmus Villemoes
Date: Thu Mar 04 2021 - 17:13:31 EST


[DO NOT MERGE - see cover letter]

We have a board where the reset output from the ADM706S is split in
two: directly routed to an interrupt, and also to start a ripple
counter, which 64 ms later than pulls the SOC's reset pin. That ripple
counter only works if the RTC's 32kHz output is enabled, and since
linux by default disables unused clocks, that effectively renders the
watchdog useless.

Add driver support for an optional "delay" clock, as documented in the
preceding patch.

Signed-off-by: Rasmus Villemoes <linux@xxxxxxxxxxxxxxxxxx>
---
drivers/watchdog/gpio_wdt.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/watchdog/gpio_wdt.c b/drivers/watchdog/gpio_wdt.c
index 0923201ce874..f812c39bc1e8 100644
--- a/drivers/watchdog/gpio_wdt.c
+++ b/drivers/watchdog/gpio_wdt.c
@@ -6,6 +6,7 @@
*/

#include <linux/err.h>
+#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/gpio/consumer.h>
@@ -111,6 +112,7 @@ static int gpio_wdt_probe(struct platform_device *pdev)
enum gpiod_flags gflags;
unsigned int hw_margin;
const char *algo;
+ struct clk *clk;
int ret;

priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
@@ -164,6 +166,13 @@ static int gpio_wdt_probe(struct platform_device *pdev)
if (priv->always_running)
gpio_wdt_start(&priv->wdd);

+ clk = devm_clk_get_optional(dev, "delay");
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+ ret = devm_clk_prepare_enable(dev, clk);
+ if (ret)
+ return ret;
+
return devm_watchdog_register_device(dev, &priv->wdd);
}

--
2.29.2