Skip to contentSkip to conversation

watchdog: sp805: fix restart handler

PATCH In review Michael Walle 2 participants 2 messages Mar 27, 2020 Watchdog device drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 watchdog: sp805: fix restart handler

The restart handler is missing two things, first, the registers has to be unlocked and second there is no synchronization for the write_relaxed() calls.

This was tested on a custom board with the NXP LS1028A SoC.

Fixes 6c5c0d48b686c ("watchdog: sp805: add restart handler")
---
 drivers/watchdog/sp805_wdt.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/watchdog/sp805_wdt.c +4 -0
index 53e04926a7b2..190d26e2e75f 100644
@@ -137,10 +137,14 @@ wdt_restart(struct watchdog_device *wdd, unsigned long mode, void *cmd)
 {
 	struct sp805_wdt *wdt = watchdog_get_drvdata(wdd);
 
+	writel_relaxed(UNLOCK, wdt->base + WDTLOCK);
 	writel_relaxed(0, wdt->base + WDTCONTROL);
 	writel_relaxed(0, wdt->base + WDTLOAD);
 	writel_relaxed(INT_ENABLE | RESET_ENABLE, wdt->base + WDTCONTROL);
 
+	/* Flush posted writes. */
+	readl_relaxed(wdt->base + WDTLOCK);
+
 	return 0;
 }
 
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Michael Walle

The restart handler is missing two things, first, the registers has to be unlocked and second there is no synchronization for the write_relaxed() calls.

This was tested on a custom board with the NXP LS1028A SoC.

Fixes 6c5c0d48b686c ("watchdog: sp805: add restart handler")
Quoted 24 lines
---
 drivers/watchdog/sp805_wdt.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/watchdog/sp805_wdt.c +4 -0
index 53e04926a7b2..190d26e2e75f 100644
@@ -137,10 +137,14 @@ wdt_restart(struct watchdog_device *wdd, unsigned long mode, void *cmd)
 {
 	struct sp805_wdt *wdt = watchdog_get_drvdata(wdd);
 
+	writel_relaxed(UNLOCK, wdt->base + WDTLOCK);
 	writel_relaxed(0, wdt->base + WDTCONTROL);
 	writel_relaxed(0, wdt->base + WDTLOAD);
 	writel_relaxed(INT_ENABLE | RESET_ENABLE, wdt->base + WDTCONTROL);
 
+	/* Flush posted writes. */
+	readl_relaxed(wdt->base + WDTLOCK);
+
 	return 0;
 }