[U-Boot] [PATCH v2 2/3] watchdog: mtk_wdt: fix timeout calculation
Weijie Gao
weijie.gao at mediatek.com
Thu May 16 09:19:38 UTC 2019
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.
Reviewed-by: Stefan Roese <sr at denx.de>
Reviewed-by: Ryder Lee <ryder.lee at mediatek.com>
Signed-off-by: Weijie Gao <weijie.gao at mediatek.com>
---
Changes since v1: none
---
drivers/watchdog/mtk_wdt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/watchdog/mtk_wdt.c b/drivers/watchdog/mtk_wdt.c
index 0b501733f2..19e3fde968 100644
--- a/drivers/watchdog/mtk_wdt.c
+++ b/drivers/watchdog/mtk_wdt.c
@@ -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);
--
2.18.0
More information about the U-Boot
mailing list