rk watch dog: modify driver
authorhhb <hhb@rock-chips.com>
Tue, 5 Nov 2013 08:16:36 +0000 (16:16 +0800)
committerhhb <hhb@rock-chips.com>
Tue, 5 Nov 2013 08:16:36 +0000 (16:16 +0800)
drivers/watchdog/rk29_wdt.c

index cbafbd3b6033a867754edca17b0c5d215b1e224f..06a06c31e031fdc40b4dcac571e76f54374f45a9 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/clk.h>\r
 #include <linux/uaccess.h>\r
 #include <linux/io.h>\r
-\r
 #include <asm/mach/map.h>\r
 \r
 \r
@@ -146,14 +145,17 @@ void rk29_wdt_stop(void)
 /* timeout unit second */\r
 int rk29_wdt_set_heartbeat(int timeout)\r
 {\r
+       unsigned int count = 0;\r
+       unsigned int torr = 0, acc = 1, maxtime = 0;    \r
        unsigned int freq = clk_get_rate(wdt_clock);\r
-       unsigned int long count;\r
-       unsigned int torr = 0;\r
-       unsigned int acc = 1;\r
 \r
        if (timeout < 1)\r
                return -EINVAL;\r
-\r
+       //0x80000000 is the max count of watch dog\r
+       maxtime = 0x80000000 / freq + 1;\r
+       if(timeout > maxtime)\r
+               timeout = maxtime;\r
+               \r
        count = timeout * freq;\r
        count /= 0x10000;\r
 \r
@@ -164,7 +166,7 @@ int rk29_wdt_set_heartbeat(int timeout)
        if(torr > 15){\r
                torr = 15;\r
        }\r
-       DBG("%s:%d\n", __func__, torr);\r
+       DBG("%s:torr:%d, count:%d, maxtime:%d s\n", __func__, torr, count, maxtime);\r
        wdt_writel(torr, RK29_WDT_TORR);\r
        return 0;\r
 }\r