From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH v2 3/4] watchdog: imxwd: support .running device parameter on i.MX2+
Date: Mon, 4 Nov 2019 23:14:06 +0100 [thread overview]
Message-ID: <20191104221407.14791-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20191104221407.14791-1-a.fatoum@pengutronix.de>
The i.MX can be fused to start the watchdog on power-on reset.
To give users an easy way to determine whether the watchdog is running,
implement support for WDOG_HW_RUNNING.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
Use new WDOG_HW_RUNNING_SUPPORTED
---
drivers/watchdog/imxwd.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/watchdog/imxwd.c b/drivers/watchdog/imxwd.c
index 77a3bd76cefa..e4a4b5ee71f5 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,12 @@ static int imx_wd_probe(struct device_d *dev)
"fsl,ext-reset-output");
if (IS_ENABLED(CONFIG_WATCHDOG_IMX)) {
+ if (priv->ops->is_running) {
+ set_bit(WDOG_HW_RUNNING_SUPPORTED, &priv->wd.status);
+ if (priv->ops->is_running(priv))
+ set_bit(WDOG_HW_RUNNING, &priv->wd.status);
+ }
+
ret = watchdog_register(&priv->wd);
if (ret)
goto on_error;
@@ -277,6 +289,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,
};
--
2.24.0.rc1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2019-11-04 22:14 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-04 22:14 [PATCH v2 1/4] watchdog: always populate watchdog priority from device tree if possible Ahmad Fatoum
2019-11-04 22:14 ` [PATCH v2 2/4] watchdog: implement generic support for .running device parameter Ahmad Fatoum
2019-11-05 10:40 ` Sascha Hauer
2019-11-05 10:46 ` Ahmad Fatoum
2019-11-05 10:51 ` Sascha Hauer
2019-11-05 11:10 ` Ahmad Fatoum
2019-11-05 11:18 ` Sascha Hauer
2019-11-08 11:04 ` Ahmad Fatoum
2019-11-04 22:14 ` Ahmad Fatoum [this message]
2019-11-04 22:14 ` [PATCH v2 4/4] watchdog: f71808e: support " Ahmad Fatoum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191104221407.14791-3-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox