linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] watchdog: sama5d4: readout initial state
@ 2023-08-19  8:47 Mathieu Othacehe
  2023-08-19 12:09 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Mathieu Othacehe @ 2023-08-19  8:47 UTC (permalink / raw)
  To: nicolas.ferre, alexandre.belloni, claudiu.beznea, wim, linux
  Cc: linux-arm-kernel, linux-watchdog, linux-kernel, Mathieu Othacehe

Readout the AT91_WDT_MR bit at probe so that it becomes possible to get the
pre-userspace handler working.

Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>
---
 drivers/watchdog/sama5d4_wdt.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
index aeee934ca51b..7d31bb6f6204 100644
--- a/drivers/watchdog/sama5d4_wdt.c
+++ b/drivers/watchdog/sama5d4_wdt.c
@@ -255,6 +255,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
 	struct sama5d4_wdt *wdt;
 	void __iomem *regs;
 	u32 irq = 0;
+	u32 reg;
 	int ret;
 
 	wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
@@ -305,6 +306,12 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
 
 	watchdog_init_timeout(wdd, wdt_timeout, dev);
 
+	reg = wdt_read(wdt, AT91_WDT_MR);
+	if (!(reg & AT91_WDT_WDDIS)) {
+		wdt->mr &= ~AT91_WDT_WDDIS;
+		set_bit(WDOG_HW_RUNNING, &wdd->status);
+	}
+
 	ret = sama5d4_wdt_init(wdt);
 	if (ret)
 		return ret;
-- 
2.41.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] watchdog: sama5d4: readout initial state
  2023-08-19  8:47 [PATCH] watchdog: sama5d4: readout initial state Mathieu Othacehe
@ 2023-08-19 12:09 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2023-08-19 12:09 UTC (permalink / raw)
  To: Mathieu Othacehe
  Cc: alexandre.belloni, linux-watchdog, linux-kernel, claudiu.beznea,
	wim, linux-arm-kernel

On Sat, Aug 19, 2023 at 10:47:26AM +0200, Mathieu Othacehe wrote:
> Readout the AT91_WDT_MR bit at probe so that it becomes possible to get the
> pre-userspace handler working.
> 
> Signed-off-by: Mathieu Othacehe <othacehe@gnu.org>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/sama5d4_wdt.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
> index aeee934ca51b..7d31bb6f6204 100644
> --- a/drivers/watchdog/sama5d4_wdt.c
> +++ b/drivers/watchdog/sama5d4_wdt.c
> @@ -255,6 +255,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
>  	struct sama5d4_wdt *wdt;
>  	void __iomem *regs;
>  	u32 irq = 0;
> +	u32 reg;
>  	int ret;
>  
>  	wdt = devm_kzalloc(dev, sizeof(*wdt), GFP_KERNEL);
> @@ -305,6 +306,12 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
>  
>  	watchdog_init_timeout(wdd, wdt_timeout, dev);
>  
> +	reg = wdt_read(wdt, AT91_WDT_MR);
> +	if (!(reg & AT91_WDT_WDDIS)) {
> +		wdt->mr &= ~AT91_WDT_WDDIS;
> +		set_bit(WDOG_HW_RUNNING, &wdd->status);
> +	}
> +
>  	ret = sama5d4_wdt_init(wdt);
>  	if (ret)
>  		return ret;
> -- 
> 2.41.0
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-19 12:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-19  8:47 [PATCH] watchdog: sama5d4: readout initial state Mathieu Othacehe
2023-08-19 12:09 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).