Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

watchdog: omap_wdt: implement get_timeleft

The omap watchdog hardware is able to read the watchdog timer counter
register. This implements this functionality in the omap_wdt driver, so
one is can read the time until the watchdog will trigger the reset in
seconds using WDIOC_GETTIMELEFT.

Signed-off-by: Lars Poeschel <poeschel@lemonage.de>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>

authored by

Lars Poeschel and committed by
Wim Van Sebroeck
452fafed 7a7cb009

+12
+11
drivers/watchdog/omap_wdt.c
··· 198 198 return 0; 199 199 } 200 200 201 + static unsigned int omap_wdt_get_timeleft(struct watchdog_device *wdog) 202 + { 203 + struct omap_wdt_dev *wdev = watchdog_get_drvdata(wdog); 204 + void __iomem *base = wdev->base; 205 + u32 value; 206 + 207 + value = readl_relaxed(base + OMAP_WATCHDOG_CRR); 208 + return GET_WCCR_SECS(value); 209 + } 210 + 201 211 static const struct watchdog_info omap_wdt_info = { 202 212 .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING, 203 213 .identity = "OMAP Watchdog", ··· 219 209 .stop = omap_wdt_stop, 220 210 .ping = omap_wdt_ping, 221 211 .set_timeout = omap_wdt_set_timeout, 212 + .get_timeleft = omap_wdt_get_timeleft, 222 213 }; 223 214 224 215 static int omap_wdt_probe(struct platform_device *pdev)
+1
drivers/watchdog/omap_wdt.h
··· 50 50 51 51 #define PTV 0 /* prescale */ 52 52 #define GET_WLDR_VAL(secs) (0xffffffff - ((secs) * (32768/(1<<PTV))) + 1) 53 + #define GET_WCCR_SECS(val) ((0xffffffff - (val) + 1) / (32768/(1<<PTV))) 53 54 54 55 #endif /* _OMAP_WATCHDOG_H */