Commit 0baf7db9 authored by Thomas Schäfer's avatar Thomas Schäfer
Browse files

watchdog: imx_wdt: add variable timeout support



- Current driver only allows to define a fixed timeout value in the
  board config file.
- Extend 'imx_watchdog_init' parameter list with timeout value as
  received by 'imx_wdt_start' function. Calculate timeout value and
  write appropriate value into WCR register.
- For legacy use, the fixed CONFIG_WATCHDOG_TIMEOUT_MSECS from board
  config is still evaluated.
Signed-off-by: Thomas Schäfer's avatarThomas Schaefer <thomas.schaefer@kontron.com>
parent 883448af
......@@ -57,9 +57,8 @@ static void imx_watchdog_reset(struct watchdog_regs *wdog)
#endif /* CONFIG_WATCHDOG_RESET_DISABLE*/
}
static void imx_watchdog_init(struct watchdog_regs *wdog, bool ext_reset)
static void imx_watchdog_init(u64 timeout, struct watchdog_regs *wdog, bool ext_reset)
{
u16 timeout;
u16 wcr;
/*
......@@ -67,10 +66,14 @@ static void imx_watchdog_init(struct watchdog_regs *wdog, bool ext_reset)
* 0.5 and 128 Seconds. If not defined
* in configuration file, sets 128 Seconds
*/
if (timeout != 0) {
timeout = (timeout / 500) - 1;
} else {
#ifndef CONFIG_WATCHDOG_TIMEOUT_MSECS
#define CONFIG_WATCHDOG_TIMEOUT_MSECS 128000
#endif
timeout = (CONFIG_WATCHDOG_TIMEOUT_MSECS / 500) - 1;
timeout = (CONFIG_WATCHDOG_TIMEOUT_MSECS / 500) - 1;
}
#ifdef CONFIG_FSL_LSCH2
wcr = (WCR_WDA | WCR_SRS | WCR_WDE) << 8 | timeout;
#else
......@@ -95,7 +98,7 @@ void hw_watchdog_init(void)
{
struct watchdog_regs *wdog = (struct watchdog_regs *)WDOG1_BASE_ADDR;
imx_watchdog_init(wdog, true);
imx_watchdog_init(0, wdog, true);
}
#else
struct imx_wdt_priv {
......@@ -126,7 +129,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, priv->ext_reset);
imx_watchdog_init(timeout, priv->base, priv->ext_reset);
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment