* [PATCH] watchdog: mpc8xx_wdt: Allow selection of watchdog mode through environment
@ 2020-02-19 16:50 Christophe Leroy
2020-04-24 17:08 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Christophe Leroy @ 2020-02-19 16:50 UTC (permalink / raw)
To: u-boot
From: Charles Frey <charles.frey@c-s.fr>
The mpc8xx watchdog can work either in 'reset mode' or 'NMI mode'.
The selection can be done at startup only.
It is desirable to select the mode without rebuilding U-boot.
It is also desirable to disable the watchdog without rebuilding.
At watchdog startup, check environment variable 'watchdog_mode'.
If it is 'off', the watchdog is not started. If it is 'nmi',
the watchdog is started in NMI mode. Otherwise, it is started
in reset mode which is the default mode.
Signed-off-by: Charles Frey <charles.frey@c-s.fr>
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
---
drivers/watchdog/mpc8xx_wdt.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/watchdog/mpc8xx_wdt.c b/drivers/watchdog/mpc8xx_wdt.c
index 675b62d8b3..8a7a4c5bc6 100644
--- a/drivers/watchdog/mpc8xx_wdt.c
+++ b/drivers/watchdog/mpc8xx_wdt.c
@@ -4,6 +4,7 @@
*/
#include <common.h>
+#include <env.h>
#include <dm.h>
#include <wdt.h>
#include <mpc8xx.h>
@@ -21,8 +22,15 @@ static void hw_watchdog_reset(void)
static int mpc8xx_wdt_start(struct udevice *dev, u64 timeout, ulong flags)
{
immap_t __iomem *immap = (immap_t __iomem *)CONFIG_SYS_IMMR;
+ u32 val = CONFIG_SYS_SYPCR;
+ const char *mode = env_get("watchdog_mode");
- out_be32(&immap->im_siu_conf.sc_sypcr, CONFIG_SYS_SYPCR);
+ if (strcmp(mode, "off") == 0)
+ val = val & ~(SYPCR_SWE | SYPCR_SWRI);
+ else if (strcmp(mode, "nmi") == 0)
+ val = (val & ~SYPCR_SWRI) | SYPCR_SWE;
+
+ out_be32(&immap->im_siu_conf.sc_sypcr, val);
if (!(in_be32(&immap->im_siu_conf.sc_sypcr) & SYPCR_SWE))
return -EBUSY;
--
2.25.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] watchdog: mpc8xx_wdt: Allow selection of watchdog mode through environment
2020-02-19 16:50 [PATCH] watchdog: mpc8xx_wdt: Allow selection of watchdog mode through environment Christophe Leroy
@ 2020-04-24 17:08 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2020-04-24 17:08 UTC (permalink / raw)
To: u-boot
On Wed, Feb 19, 2020 at 04:50:15PM +0000, Christophe Leroy wrote:
> From: Charles Frey <charles.frey@c-s.fr>
>
> The mpc8xx watchdog can work either in 'reset mode' or 'NMI mode'.
> The selection can be done at startup only.
> It is desirable to select the mode without rebuilding U-boot.
> It is also desirable to disable the watchdog without rebuilding.
>
> At watchdog startup, check environment variable 'watchdog_mode'.
> If it is 'off', the watchdog is not started. If it is 'nmi',
> the watchdog is started in NMI mode. Otherwise, it is started
> in reset mode which is the default mode.
>
> Signed-off-by: Charles Frey <charles.frey@c-s.fr>
> Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200424/f71a5c26/attachment.sig>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-24 17:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 16:50 [PATCH] watchdog: mpc8xx_wdt: Allow selection of watchdog mode through environment Christophe Leroy
2020-04-24 17:08 ` Tom Rini
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.