summaryrefslogtreecommitdiffstats
path: root/drivers/watchdog/imxwd.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2019-12-10 05:41:45 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2019-12-10 05:41:45 +0100
commit28e374e062aede65b6bb6f341376f196e5ac4fc7 (patch)
tree603f97f7495cc6c234482424fcb4b39dc77369da /drivers/watchdog/imxwd.c
parent4b05f14d96afde2fb8e7e9a92893ca3c684870d0 (diff)
parentaade8d53cf6cccf7958d2c11e5791dfcd85a584f (diff)
downloadbarebox-28e374e062aede65b6bb6f341376f196e5ac4fc7.tar.gz
barebox-28e374e062aede65b6bb6f341376f196e5ac4fc7.tar.xz
Merge branch 'for-next/watchdog'
Diffstat (limited to 'drivers/watchdog/imxwd.c')
-rw-r--r--drivers/watchdog/imxwd.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c
index 77a3bd76ce..b2cfd1cd3a 100644
--- a/drivers/watchdog/imxwd.c
+++ b/drivers/watchdog/imxwd.c
@@ -28,6 +28,7 @@ struct imx_wd_ops {
int (*set_timeout)(struct imx_wd *, unsigned);
void (*soc_reset)(struct imx_wd *);
int (*init)(struct imx_wd *);
+ bool (*is_running)(struct imx_wd *);
unsigned int timeout_max;
};
@@ -111,6 +112,11 @@ static void imx1_soc_reset(struct imx_wd *priv)
writew(IMX1_WDOG_WCR_WDE, priv->base + IMX1_WDOG_WCR);
}
+static inline bool imx21_watchdog_is_running(struct imx_wd *priv)
+{
+ return imxwd_read(priv, IMX21_WDOG_WCR) & IMX21_WDOG_WCR_WDE;
+}
+
static int imx21_watchdog_set_timeout(struct imx_wd *priv, unsigned timeout)
{
u16 val;
@@ -243,6 +249,13 @@ static int imx_wd_probe(struct device_d *dev)
"fsl,ext-reset-output");
if (IS_ENABLED(CONFIG_WATCHDOG_IMX)) {
+ if (priv->ops->is_running) {
+ if (priv->ops->is_running(priv))
+ priv->wd.running = WDOG_HW_RUNNING;
+ else
+ priv->wd.running = WDOG_HW_NOT_RUNNING;
+ }
+
ret = watchdog_register(&priv->wd);
if (ret)
goto on_error;
@@ -277,6 +290,7 @@ static const struct imx_wd_ops imx21_wd_ops = {
.set_timeout = imx21_watchdog_set_timeout,
.soc_reset = imx21_soc_reset,
.init = imx21_wd_init,
+ .is_running = imx21_watchdog_is_running,
.timeout_max = 128,
};