Skip to contentSkip to conversation

watchdog: mtk_wdt: fix timeout calculation

PATCH Superseded Weijie Gao 2 participants 2 messages May 16, 2019

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Weijie Gao

author
#0 lore raw

PATCH 2/3 watchdog: mtk_wdt: fix timeout calculation

U-Boot passes timeout in milliseconds for ops->start. However the driver treats this value as seconds. This will cause an overflow on writing wdt register.

This patch divides the timeout by 1000 before writing to wdt register.

---
 drivers/watchdog/mtk_wdt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/watchdog/mtk_wdt.c +1 -1
index 0b501733f2..19e3fde968 100644
@@ -78,7 +78,7 @@ static void mtk_wdt_set_timeout(struct udevice *dev, unsigned int timeout)
 	 * One bit is the value of 512 ticks
 	 * The clock has 32 KHz
 	 */
-	timeout = WDT_LENGTH_TIMEOUT(timeout << 6) | WDT_LENGTH_KEY;
+	timeout = WDT_LENGTH_TIMEOUT((timeout << 6) / 1000) | WDT_LENGTH_KEY;
 	writel(timeout, priv->base + MTK_WDT_LENGTH);
 
 	mtk_wdt_reset(dev);
Signature · 1 line
2.18.0