summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorHauke Mehrtens <hauke@hauke-m.de>2018-09-14 00:32:11 +0300
committerWim Van Sebroeck <wim@linux-watchdog.org>2018-10-02 14:32:27 +0300
commitc99d9df1d3c312759c43a3da0d2f17b4aecc05c8 (patch)
tree79787f7b6b0139851d1d6055b0eaeb099882bba0 /drivers
parentdcd7e04e8e2f5f887dd9692f5ff3e0d0c26c8e3f (diff)
downloadlinux-c99d9df1d3c312759c43a3da0d2f17b4aecc05c8.tar.xz
watchdog: lantiq: add get_timeleft callback
This callback will provide the current time left. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/watchdog/lantiq_wdt.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/watchdog/lantiq_wdt.c b/drivers/watchdog/lantiq_wdt.c
index c2f14d2bd695..83da84d6074b 100644
--- a/drivers/watchdog/lantiq_wdt.c
+++ b/drivers/watchdog/lantiq_wdt.c
@@ -50,6 +50,7 @@
#define LTQ_WDT_CR_MAX_TIMEOUT ((1 << 16) - 1) /* The reload field is 16 bit */
#define LTQ_WDT_SR 0x8 /* watchdog status register */
#define LTQ_WDT_SR_EN BIT(31) /* Enable */
+#define LTQ_WDT_SR_VALUE_MASK GENMASK(15, 0) /* Timer value */
#define LTQ_WDT_DIVIDER 0x40000
@@ -139,11 +140,21 @@ static int ltq_wdt_ping(struct watchdog_device *wdt)
return 0;
}
+static unsigned int ltq_wdt_get_timeleft(struct watchdog_device *wdt)
+{
+ struct ltq_wdt_priv *priv = ltq_wdt_get_priv(wdt);
+ u64 timeout;
+
+ timeout = ltq_wdt_r32(priv, LTQ_WDT_SR) & LTQ_WDT_SR_VALUE_MASK;
+ return do_div(timeout, priv->clk_rate);
+}
+
static const struct watchdog_ops ltq_wdt_ops = {
.owner = THIS_MODULE,
.start = ltq_wdt_start,
.stop = ltq_wdt_stop,
.ping = ltq_wdt_ping,
+ .get_timeleft = ltq_wdt_get_timeleft,
};
static int ltq_wdt_xrx_bootstatus_get(struct device *dev)