From 96342a866bac2ac118d87694367544eecbf59e72 Mon Sep 17 00:00:00 2001 From: hhb Date: Tue, 5 Nov 2013 16:16:36 +0800 Subject: [PATCH] rk watch dog: modify driver --- drivers/watchdog/rk29_wdt.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/watchdog/rk29_wdt.c b/drivers/watchdog/rk29_wdt.c index cbafbd3b6033..06a06c31e031 100644 --- a/drivers/watchdog/rk29_wdt.c +++ b/drivers/watchdog/rk29_wdt.c @@ -32,7 +32,6 @@ #include #include #include - #include @@ -146,14 +145,17 @@ void rk29_wdt_stop(void) /* timeout unit second */ int rk29_wdt_set_heartbeat(int timeout) { + unsigned int count = 0; + unsigned int torr = 0, acc = 1, maxtime = 0; unsigned int freq = clk_get_rate(wdt_clock); - unsigned int long count; - unsigned int torr = 0; - unsigned int acc = 1; if (timeout < 1) return -EINVAL; - + //0x80000000 is the max count of watch dog + maxtime = 0x80000000 / freq + 1; + if(timeout > maxtime) + timeout = maxtime; + count = timeout * freq; count /= 0x10000; @@ -164,7 +166,7 @@ int rk29_wdt_set_heartbeat(int timeout) if(torr > 15){ torr = 15; } - DBG("%s:%d\n", __func__, torr); + DBG("%s:torr:%d, count:%d, maxtime:%d s\n", __func__, torr, count, maxtime); wdt_writel(torr, RK29_WDT_TORR); return 0; } -- 2.34.1