diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-19 19:35:51 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-03-19 19:35:51 -0700 |
commit | 1e75a9f34a5ed5902707fb74b468356c55142b71 (patch) | |
tree | 810ff2a5e9d393242e663b321c8a80a17cebe11d /drivers/watchdog/imx2_wdt.c | |
parent | 1c3d770043583d99118d52cad309f586ef8e7d4a (diff) | |
parent | d1ed3ba4e3d76b4ebec239c64f990c26d7935700 (diff) | |
download | talos-op-linux-1e75a9f34a5ed5902707fb74b468356c55142b71.tar.gz talos-op-linux-1e75a9f34a5ed5902707fb74b468356c55142b71.zip |
Merge git://www.linux-watchdog.org/linux-watchdog
Pull watchdog updates from Wim Van Sebroeck:
- new drivers for: NI 903x/913x watchdog driver, WinSystems EBC-C384
watchdog timer and ARM SBSA watchdog driver
- Support for NCT6102D devices
- Improvements of the generic watchdog framework (improve restart
handler, make set_timeout optional, introduce infrastructure
triggered keepalives, ...
- improvements on the pnx4008 watchdog driver
- several smaller fixes and improvements
* git://www.linux-watchdog.org/linux-watchdog: (28 commits)
watchdog: Ensure that wdd is not dereferenced if NULL
watchdog: imx2: Convert to use infrastructure triggered keepalives
watchdog: dw_wdt: Convert to use watchdog infrastructure
watchdog: Add support for minimum time between heartbeats
watchdog: Make stop function optional
watchdog: Introduce WDOG_HW_RUNNING flag
watchdog: Introduce hardware maximum heartbeat in watchdog core
watchdog: Make set_timeout function optional
arm: lpc32xx: remove restart handler
arm: lpc32xx: phy3250 remove restart hook
watchdog: pnx4008: restart: support "cmd" from userspace
watchdog: pnx4008: add support for soft reset
watchdog: pnx4008: add restart handler
watchdog: pnx4008: update logging during power-on
watchdog: tangox_wdt: test clock rate to avoid division by 0
watchdog: atlas7_wdt: test clock rate to avoid division by 0
watchdog: s3c2410_wdt: Add max and min timeout values
Watchdog: introduce ARM SBSA watchdog driver
Documentation: add sbsa-gwdt driver documentation
watchdog: Add watchdog timer support for the WinSystems EBC-C384
...
Diffstat (limited to 'drivers/watchdog/imx2_wdt.c')
-rw-r--r-- | drivers/watchdog/imx2_wdt.c | 77 |
1 files changed, 15 insertions, 62 deletions
diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index e47966aa2db0..331aed831dac 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -25,14 +25,12 @@ #include <linux/delay.h> #include <linux/init.h> #include <linux/io.h> -#include <linux/jiffies.h> #include <linux/kernel.h> #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/of_address.h> #include <linux/platform_device.h> #include <linux/regmap.h> -#include <linux/timer.h> #include <linux/watchdog.h> #define DRIVER_NAME "imx2-wdt" @@ -60,7 +58,6 @@ struct imx2_wdt_device { struct clk *clk; struct regmap *regmap; - struct timer_list timer; /* Pings the watchdog when closed */ struct watchdog_device wdog; }; @@ -80,7 +77,8 @@ static const struct watchdog_info imx2_wdt_info = { .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, }; -static int imx2_wdt_restart(struct watchdog_device *wdog) +static int imx2_wdt_restart(struct watchdog_device *wdog, unsigned long action, + void *data) { struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); unsigned int wcr_enable = IMX2_WDT_WCR_WDE; @@ -146,16 +144,6 @@ static int imx2_wdt_ping(struct watchdog_device *wdog) return 0; } -static void imx2_wdt_timer_ping(unsigned long arg) -{ - struct watchdog_device *wdog = (struct watchdog_device *)arg; - struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); - - /* ping it every wdog->timeout / 2 seconds to prevent reboot */ - imx2_wdt_ping(wdog); - mod_timer(&wdev->timer, jiffies + wdog->timeout * HZ / 2); -} - static int imx2_wdt_set_timeout(struct watchdog_device *wdog, unsigned int new_timeout) { @@ -172,40 +160,19 @@ static int imx2_wdt_start(struct watchdog_device *wdog) { struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); - if (imx2_wdt_is_running(wdev)) { - /* delete the timer that pings the watchdog after close */ - del_timer_sync(&wdev->timer); + if (imx2_wdt_is_running(wdev)) imx2_wdt_set_timeout(wdog, wdog->timeout); - } else + else imx2_wdt_setup(wdog); - return imx2_wdt_ping(wdog); -} - -static int imx2_wdt_stop(struct watchdog_device *wdog) -{ - /* - * We don't need a clk_disable, it cannot be disabled once started. - * We use a timer to ping the watchdog while /dev/watchdog is closed - */ - imx2_wdt_timer_ping((unsigned long)wdog); - return 0; -} - -static inline void imx2_wdt_ping_if_active(struct watchdog_device *wdog) -{ - struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); + set_bit(WDOG_HW_RUNNING, &wdog->status); - if (imx2_wdt_is_running(wdev)) { - imx2_wdt_set_timeout(wdog, wdog->timeout); - imx2_wdt_timer_ping((unsigned long)wdog); - } + return imx2_wdt_ping(wdog); } static const struct watchdog_ops imx2_wdt_ops = { .owner = THIS_MODULE, .start = imx2_wdt_start, - .stop = imx2_wdt_stop, .ping = imx2_wdt_ping, .set_timeout = imx2_wdt_set_timeout, .restart = imx2_wdt_restart, @@ -253,7 +220,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) wdog->info = &imx2_wdt_info; wdog->ops = &imx2_wdt_ops; wdog->min_timeout = 1; - wdog->max_timeout = IMX2_WDT_MAX_TIME; + wdog->max_hw_heartbeat_ms = IMX2_WDT_MAX_TIME * 1000; wdog->parent = &pdev->dev; ret = clk_prepare_enable(wdev->clk); @@ -274,9 +241,10 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) watchdog_set_restart_priority(wdog, 128); watchdog_init_timeout(wdog, timeout, &pdev->dev); - setup_timer(&wdev->timer, imx2_wdt_timer_ping, (unsigned long)wdog); - - imx2_wdt_ping_if_active(wdog); + if (imx2_wdt_is_running(wdev)) { + imx2_wdt_set_timeout(wdog, wdog->timeout); + set_bit(WDOG_HW_RUNNING, &wdog->status); + } /* * Disable the watchdog power down counter at boot. Otherwise the power @@ -309,7 +277,6 @@ static int __exit imx2_wdt_remove(struct platform_device *pdev) watchdog_unregister_device(wdog); if (imx2_wdt_is_running(wdev)) { - del_timer_sync(&wdev->timer); imx2_wdt_ping(wdog); dev_crit(&pdev->dev, "Device removed: Expect reboot!\n"); } @@ -323,10 +290,9 @@ static void imx2_wdt_shutdown(struct platform_device *pdev) if (imx2_wdt_is_running(wdev)) { /* - * We are running, we need to delete the timer but will - * give max timeout before reboot will take place + * We are running, configure max timeout before reboot + * will take place. */ - del_timer_sync(&wdev->timer); imx2_wdt_set_timeout(wdog, IMX2_WDT_MAX_TIME); imx2_wdt_ping(wdog); dev_crit(&pdev->dev, "Device shutdown: Expect reboot!\n"); @@ -344,10 +310,6 @@ static int imx2_wdt_suspend(struct device *dev) if (imx2_wdt_is_running(wdev)) { imx2_wdt_set_timeout(wdog, IMX2_WDT_MAX_TIME); imx2_wdt_ping(wdog); - - /* The watchdog is not active */ - if (!watchdog_active(wdog)) - del_timer_sync(&wdev->timer); } clk_disable_unprepare(wdev->clk); @@ -373,19 +335,10 @@ static int imx2_wdt_resume(struct device *dev) * watchdog again. */ imx2_wdt_setup(wdog); + } + if (imx2_wdt_is_running(wdev)) { imx2_wdt_set_timeout(wdog, wdog->timeout); imx2_wdt_ping(wdog); - } else if (imx2_wdt_is_running(wdev)) { - /* Resuming from non-deep sleep state. */ - imx2_wdt_set_timeout(wdog, wdog->timeout); - imx2_wdt_ping(wdog); - /* - * But the watchdog is not active, then start - * the timer again. - */ - if (!watchdog_active(wdog)) - mod_timer(&wdev->timer, - jiffies + wdog->timeout * HZ / 2); } return 0; |