diff options
author | Charles Frey <charles.frey@c-s.fr> | 2020-02-19 16:50:15 +0000 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2020-04-24 10:09:59 -0400 |
commit | ea8de984e5d77a755c7802833a4808c65d380fb0 (patch) | |
tree | a32c82b6d792351c4d276c1ea47f90056143530a | |
parent | dbfd9e0e61ff1f9c65703959ed8e3ceb410d1e7e (diff) | |
download | u-boot-ea8de984e5d77a755c7802833a4808c65d380fb0.zip u-boot-ea8de984e5d77a755c7802833a4808c65d380fb0.tar.gz u-boot-ea8de984e5d77a755c7802833a4808c65d380fb0.tar.bz2 |
watchdog: mpc8xx_wdt: Allow selection of watchdog mode through environment
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>
-rw-r--r-- | drivers/watchdog/mpc8xx_wdt.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/watchdog/mpc8xx_wdt.c b/drivers/watchdog/mpc8xx_wdt.c index 30758ae..c8b104d 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 @@ 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; |