diff options
author | Guenter Roeck <linux@roeck-us.net> | 2014-09-25 20:03:17 -0400 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2014-09-26 03:00:27 -0400 |
commit | ad0e0e6810b339ddeb97ab9ae24e996db5c11bac (patch) | |
tree | 11059e3b1729f77af832c7dbcba33e9ed9a5cf50 | |
parent | 1a9607a3be14a43868c5e6a35962e7f6be9bcfe1 (diff) |
watchdog: moxart: register restart handler with kernel restart handler
The kernel now provides an API to trigger a system restart. Register with
it instead of setting arm_pm_restart.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: David Woodhouse <dwmw2@infradead.org>
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jonas Jensen <jonas.jensen@gmail.com>
Cc: Maxime Ripard <maxime.ripard@free-electrons.com>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Tomasz Figa <t.figa@samsung.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Wim Van Sebroeck <wim@iguana.be>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
-rw-r--r-- | drivers/watchdog/moxart_wdt.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/drivers/watchdog/moxart_wdt.c b/drivers/watchdog/moxart_wdt.c index 4aa3a8a876fe..a64405b82596 100644 --- a/drivers/watchdog/moxart_wdt.c +++ b/drivers/watchdog/moxart_wdt.c | |||
@@ -15,12 +15,12 @@ | |||
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
18 | #include <linux/notifier.h> | ||
18 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
20 | #include <linux/reboot.h> | ||
19 | #include <linux/watchdog.h> | 21 | #include <linux/watchdog.h> |
20 | #include <linux/moduleparam.h> | 22 | #include <linux/moduleparam.h> |
21 | 23 | ||
22 | #include <asm/system_misc.h> | ||
23 | |||
24 | #define REG_COUNT 0x4 | 24 | #define REG_COUNT 0x4 |
25 | #define REG_MODE 0x8 | 25 | #define REG_MODE 0x8 |
26 | #define REG_ENABLE 0xC | 26 | #define REG_ENABLE 0xC |
@@ -29,17 +29,22 @@ struct moxart_wdt_dev { | |||
29 | struct watchdog_device dev; | 29 | struct watchdog_device dev; |
30 | void __iomem *base; | 30 | void __iomem *base; |
31 | unsigned int clock_frequency; | 31 | unsigned int clock_frequency; |
32 | struct notifier_block restart_handler; | ||
32 | }; | 33 | }; |
33 | 34 | ||
34 | static struct moxart_wdt_dev *moxart_restart_ctx; | ||
35 | |||
36 | static int heartbeat; | 35 | static int heartbeat; |
37 | 36 | ||
38 | static void moxart_wdt_restart(enum reboot_mode reboot_mode, const char *cmd) | 37 | static int moxart_restart_handle(struct notifier_block *this, |
38 | unsigned long mode, void *cmd) | ||
39 | { | 39 | { |
40 | writel(1, moxart_restart_ctx->base + REG_COUNT); | 40 | struct moxart_wdt_dev *moxart_wdt = container_of(this, |
41 | writel(0x5ab9, moxart_restart_ctx->base + REG_MODE); | 41 | struct moxart_wdt_dev, |
42 | writel(0x03, moxart_restart_ctx->base + REG_ENABLE); | 42 | restart_handler); |
43 | writel(1, moxart_wdt->base + REG_COUNT); | ||
44 | writel(0x5ab9, moxart_wdt->base + REG_MODE); | ||
45 | writel(0x03, moxart_wdt->base + REG_ENABLE); | ||
46 | |||
47 | return NOTIFY_DONE; | ||
43 | } | 48 | } |
44 | 49 | ||
45 | static int moxart_wdt_stop(struct watchdog_device *wdt_dev) | 50 | static int moxart_wdt_stop(struct watchdog_device *wdt_dev) |
@@ -136,8 +141,12 @@ static int moxart_wdt_probe(struct platform_device *pdev) | |||
136 | if (err) | 141 | if (err) |
137 | return err; | 142 | return err; |
138 | 143 | ||
139 | moxart_restart_ctx = moxart_wdt; | 144 | moxart_wdt->restart_handler.notifier_call = moxart_restart_handle; |
140 | arm_pm_restart = moxart_wdt_restart; | 145 | moxart_wdt->restart_handler.priority = 128; |
146 | err = register_restart_handler(&moxart_wdt->restart_handler); | ||
147 | if (err) | ||
148 | dev_err(dev, "cannot register restart notifier (err=%d)\n", | ||
149 | err); | ||
141 | 150 | ||
142 | dev_dbg(dev, "Watchdog enabled (heartbeat=%d sec, nowayout=%d)\n", | 151 | dev_dbg(dev, "Watchdog enabled (heartbeat=%d sec, nowayout=%d)\n", |
143 | moxart_wdt->dev.timeout, nowayout); | 152 | moxart_wdt->dev.timeout, nowayout); |
@@ -149,9 +158,8 @@ static int moxart_wdt_remove(struct platform_device *pdev) | |||
149 | { | 158 | { |
150 | struct moxart_wdt_dev *moxart_wdt = platform_get_drvdata(pdev); | 159 | struct moxart_wdt_dev *moxart_wdt = platform_get_drvdata(pdev); |
151 | 160 | ||
152 | arm_pm_restart = NULL; | 161 | unregister_restart_handler(&moxart_wdt->restart_handler); |
153 | moxart_wdt_stop(&moxart_wdt->dev); | 162 | moxart_wdt_stop(&moxart_wdt->dev); |
154 | watchdog_unregister_device(&moxart_wdt->dev); | ||
155 | 163 | ||
156 | return 0; | 164 | return 0; |
157 | } | 165 | } |