diff options
Diffstat (limited to 'drivers/watchdog/imx_watchdog.c')
-rw-r--r-- | drivers/watchdog/imx_watchdog.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/drivers/watchdog/imx_watchdog.c b/drivers/watchdog/imx_watchdog.c index 53a3e9f5c7..c030360c21 100644 --- a/drivers/watchdog/imx_watchdog.c +++ b/drivers/watchdog/imx_watchdog.c @@ -15,15 +15,23 @@ #endif #include <fsl_wdog.h> -static void imx_watchdog_expire_now(struct watchdog_regs *wdog) +static void imx_watchdog_expire_now(struct watchdog_regs *wdog, bool ext_reset) { - clrsetbits_le16(&wdog->wcr, WCR_WT_MSK, WCR_WDE); + u16 wcr = WCR_WDE; + + if (ext_reset) + wcr |= WCR_SRS; /* do not assert internal reset */ + else + wcr |= WCR_WDA; /* do not assert external reset */ + + /* Write 3 times to ensure it works, due to IMX6Q errata ERR004346 */ + writew(wcr, &wdog->wcr); + writew(wcr, &wdog->wcr); + writew(wcr, &wdog->wcr); - writew(0x5555, &wdog->wsr); - writew(0xaaaa, &wdog->wsr); /* load minimum 1/2 second timeout */ while (1) { /* - * spin for .5 seconds before reset + * spin before reset */ } } @@ -34,7 +42,7 @@ void __attribute__((weak)) reset_cpu(ulong addr) { struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR; - imx_watchdog_expire_now(wdog); + imx_watchdog_expire_now(wdog, true); } #endif @@ -47,9 +55,10 @@ static void imx_watchdog_reset(struct watchdog_regs *wdog) #endif /* CONFIG_WATCHDOG_RESET_DISABLE*/ } -static void imx_watchdog_init(struct watchdog_regs *wdog) +static void imx_watchdog_init(struct watchdog_regs *wdog, bool ext_reset) { u16 timeout; + u16 wcr; /* * The timer watchdog can be set between @@ -61,11 +70,14 @@ static void imx_watchdog_init(struct watchdog_regs *wdog) #endif timeout = (CONFIG_WATCHDOG_TIMEOUT_MSECS / 500) - 1; #ifdef CONFIG_FSL_LSCH2 - writew((WCR_WDA | WCR_SRS | WCR_WDE) << 8 | timeout, &wdog->wcr); + wcr = (WCR_WDA | WCR_SRS | WCR_WDE) << 8 | timeout; #else - writew(WCR_WDZST | WCR_WDBG | WCR_WDE | WCR_WDT | WCR_SRS | - WCR_WDA | SET_WCR_WT(timeout), &wdog->wcr); + wcr = WCR_WDZST | WCR_WDBG | WCR_WDE | WCR_SRS | + WCR_WDA | SET_WCR_WT(timeout); + if (ext_reset) + wcr |= WCR_WDT; #endif /* CONFIG_FSL_LSCH2*/ + writew(wcr, &wdog->wcr); imx_watchdog_reset(wdog); } @@ -81,11 +93,12 @@ void hw_watchdog_init(void) { struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR; - imx_watchdog_init(wdog); + imx_watchdog_init(wdog, true); } #else struct imx_wdt_priv { void __iomem *base; + bool ext_reset; }; static int imx_wdt_reset(struct udevice *dev) @@ -101,7 +114,7 @@ static int imx_wdt_expire_now(struct udevice *dev, ulong flags) { struct imx_wdt_priv *priv = dev_get_priv(dev); - imx_watchdog_expire_now(priv->base); + imx_watchdog_expire_now(priv->base, priv->ext_reset); hang(); return 0; @@ -111,7 +124,7 @@ static int imx_wdt_start(struct udevice *dev, u64 timeout, ulong flags) { struct imx_wdt_priv *priv = dev_get_priv(dev); - imx_watchdog_init(priv->base); + imx_watchdog_init(priv->base, priv->ext_reset); return 0; } @@ -124,6 +137,8 @@ static int imx_wdt_probe(struct udevice *dev) if (!priv->base) return -ENOENT; + priv->ext_reset = dev_read_bool(dev, "fsl,ext-reset-output"); + return 0; } |