aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/watchdog
diff options
context:
space:
mode:
authorIvan Khoronzhuk <ivan.khoronzhuk@ti.com>2013-12-04 14:39:28 -0500
committerWim Van Sebroeck <wim@iguana.be>2014-01-28 15:19:58 -0500
commita771994901bde73779c94ec558b95c75bc2c7518 (patch)
treec48c68bf5d83148ec647e83d38844e1b0910356d /drivers/watchdog
parent6d9a6cf5c63fe4f08b05fc53f7a17048df86d3ac (diff)
watchdog: davinci: add GET_TIMELEFT option support
Currently, the davinci watchdog can be read while counting, so we can add ability to report the remaining time before the system will reboot. Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@ti.com> Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog')
-rw-r--r--drivers/watchdog/davinci_wdt.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/watchdog/davinci_wdt.c b/drivers/watchdog/davinci_wdt.c
index 6d76fcf00525..dbe28343e749 100644
--- a/drivers/watchdog/davinci_wdt.c
+++ b/drivers/watchdog/davinci_wdt.c
@@ -116,6 +116,31 @@ static int davinci_wdt_ping(struct watchdog_device *wdd)
116 return 0; 116 return 0;
117} 117}
118 118
119static unsigned int davinci_wdt_get_timeleft(struct watchdog_device *wdd)
120{
121 u64 timer_counter;
122 unsigned long freq;
123 u32 val;
124 struct davinci_wdt_device *davinci_wdt = watchdog_get_drvdata(wdd);
125
126 /* if timeout has occured then return 0 */
127 val = ioread32(davinci_wdt->base + WDTCR);
128 if (val & WDFLAG)
129 return 0;
130
131 freq = clk_get_rate(davinci_wdt->clk);
132
133 if (!freq)
134 return 0;
135
136 timer_counter = ioread32(davinci_wdt->base + TIM12);
137 timer_counter |= ((u64)ioread32(davinci_wdt->base + TIM34) << 32);
138
139 do_div(timer_counter, freq);
140
141 return wdd->timeout - timer_counter;
142}
143
119static const struct watchdog_info davinci_wdt_info = { 144static const struct watchdog_info davinci_wdt_info = {
120 .options = WDIOF_KEEPALIVEPING, 145 .options = WDIOF_KEEPALIVEPING,
121 .identity = "DaVinci Watchdog", 146 .identity = "DaVinci Watchdog",
@@ -126,6 +151,7 @@ static const struct watchdog_ops davinci_wdt_ops = {
126 .start = davinci_wdt_start, 151 .start = davinci_wdt_start,
127 .stop = davinci_wdt_ping, 152 .stop = davinci_wdt_ping,
128 .ping = davinci_wdt_ping, 153 .ping = davinci_wdt_ping,
154 .get_timeleft = davinci_wdt_get_timeleft,
129}; 155};
130 156
131static int davinci_wdt_probe(struct platform_device *pdev) 157static int davinci_wdt_probe(struct platform_device *pdev)