aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/watchdog/moxart_wdt.c32
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
34static struct moxart_wdt_dev *moxart_restart_ctx;
35
36static int heartbeat; 35static int heartbeat;
37 36
38static void moxart_wdt_restart(enum reboot_mode reboot_mode, const char *cmd) 37static 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
45static int moxart_wdt_stop(struct watchdog_device *wdt_dev) 50static 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}