summaryrefslogtreecommitdiff
path: root/drivers/watchdog/imgpdc_wdt.c
diff options
context:
space:
mode:
authorAndrew Bresticker <abrestic@chromium.org>2015-04-03 10:05:21 -0700
committerWim Van Sebroeck <wim@iguana.be>2015-06-22 15:54:13 +0200
commit8aa453a533faf383fe711aa8dedcf421563ddf66 (patch)
tree288bfe8c63ea47880cd87501d6b6be605e944447 /drivers/watchdog/imgpdc_wdt.c
parent7094e1dd2ba98f1eb534c262deebbc65e34fe132 (diff)
downloadlwn-8aa453a533faf383fe711aa8dedcf421563ddf66.tar.gz
lwn-8aa453a533faf383fe711aa8dedcf421563ddf66.zip
watchdog: imgpdc: Set timeout before starting watchdog
Set up the watchdog for the specified timeout before attempting to start it. Signed-off-by: Naidu Tellapati <naidu.tellapati@imgtec.com> Signed-off-by: Andrew Bresticker <abrestic@chromium.org> Reviewed-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com> Tested-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com> Cc: James Hogan <james.hogan@imgtec.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog/imgpdc_wdt.c')
-rw-r--r--drivers/watchdog/imgpdc_wdt.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/watchdog/imgpdc_wdt.c b/drivers/watchdog/imgpdc_wdt.c
index d6826a6dfc81..ffeb1bf85252 100644
--- a/drivers/watchdog/imgpdc_wdt.c
+++ b/drivers/watchdog/imgpdc_wdt.c
@@ -84,18 +84,24 @@ static int pdc_wdt_stop(struct watchdog_device *wdt_dev)
return 0;
}
+static void __pdc_wdt_set_timeout(struct pdc_wdt_dev *wdt)
+{
+ unsigned long clk_rate = clk_get_rate(wdt->wdt_clk);
+ unsigned int val;
+
+ val = readl(wdt->base + PDC_WDT_CONFIG) & ~PDC_WDT_CONFIG_DELAY_MASK;
+ val |= order_base_2(wdt->wdt_dev.timeout * clk_rate) - 1;
+ writel(val, wdt->base + PDC_WDT_CONFIG);
+}
+
static int pdc_wdt_set_timeout(struct watchdog_device *wdt_dev,
unsigned int new_timeout)
{
- unsigned int val;
struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev);
- unsigned long clk_rate = clk_get_rate(wdt->wdt_clk);
wdt->wdt_dev.timeout = new_timeout;
- val = readl(wdt->base + PDC_WDT_CONFIG) & ~PDC_WDT_CONFIG_DELAY_MASK;
- val |= order_base_2(new_timeout * clk_rate) - 1;
- writel(val, wdt->base + PDC_WDT_CONFIG);
+ __pdc_wdt_set_timeout(wdt);
return 0;
}
@@ -106,6 +112,8 @@ static int pdc_wdt_start(struct watchdog_device *wdt_dev)
unsigned int val;
struct pdc_wdt_dev *wdt = watchdog_get_drvdata(wdt_dev);
+ __pdc_wdt_set_timeout(wdt);
+
val = readl(wdt->base + PDC_WDT_CONFIG);
val |= PDC_WDT_CONFIG_ENABLE;
writel(val, wdt->base + PDC_WDT_CONFIG);