All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] watchdog: omap_wdt: implement get_timeleft
@ 2015-06-17  8:58 poeschel
  2015-06-18 16:38 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: poeschel @ 2015-06-17  8:58 UTC (permalink / raw)
  To: wim, linux-watchdog, linux-kernel; +Cc: Lars Poeschel

From: Lars Poeschel <poeschel@lemonage.de>

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>
---
 drivers/watchdog/omap_wdt.c | 11 +++++++++++
 drivers/watchdog/omap_wdt.h |  1 +
 2 files changed, 12 insertions(+)

diff --git a/drivers/watchdog/omap_wdt.c b/drivers/watchdog/omap_wdt.c
index 1e6be9e..2480a27 100644
--- a/drivers/watchdog/omap_wdt.c
+++ b/drivers/watchdog/omap_wdt.c
@@ -188,6 +188,16 @@ static int omap_wdt_set_timeout(struct watchdog_device *wdog,
 	return 0;
 }
 
+static unsigned int omap_wdt_get_timeleft(struct watchdog_device *wdog)
+{
+	struct omap_wdt_dev *wdev = watchdog_get_drvdata(wdog);
+	void __iomem *base = wdev->base;
+	u32 value;
+
+	value = readl_relaxed(base + OMAP_WATCHDOG_CRR);
+	return GET_WCCR_SECS(value);
+}
+
 static const struct watchdog_info omap_wdt_info = {
 	.options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
 	.identity = "OMAP Watchdog",
@@ -199,6 +209,7 @@ static const struct watchdog_ops omap_wdt_ops = {
 	.stop		= omap_wdt_stop,
 	.ping		= omap_wdt_ping,
 	.set_timeout	= omap_wdt_set_timeout,
+	.get_timeleft	= omap_wdt_get_timeleft,
 };
 
 static int omap_wdt_probe(struct platform_device *pdev)
diff --git a/drivers/watchdog/omap_wdt.h b/drivers/watchdog/omap_wdt.h
index 09b774c..42f31ec 100644
--- a/drivers/watchdog/omap_wdt.h
+++ b/drivers/watchdog/omap_wdt.h
@@ -50,5 +50,6 @@
 
 #define PTV			0	/* prescale */
 #define GET_WLDR_VAL(secs)	(0xffffffff - ((secs) * (32768/(1<<PTV))) + 1)
+#define GET_WCCR_SECS(val)	((0xffffffff - (val) + 1) / (32768/(1<<PTV)))
 
 #endif				/* _OMAP_WATCHDOG_H */
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: watchdog: omap_wdt: implement get_timeleft
  2015-06-17  8:58 [PATCH] watchdog: omap_wdt: implement get_timeleft poeschel
@ 2015-06-18 16:38 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2015-06-18 16:38 UTC (permalink / raw)
  To: poeschel; +Cc: wim, linux-watchdog, linux-kernel

On Wed, Jun 17, 2015 at 10:58:59AM +0200, poeschel@lemonage.de wrote:
> From: Lars Poeschel <poeschel@lemonage.de>
> 
> 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>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-18 16:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-17  8:58 [PATCH] watchdog: omap_wdt: implement get_timeleft poeschel
2015-06-18 16:38 ` Guenter Roeck

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.