aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Riegel <damien.riegel@savoirfairelinux.com>2015-11-16 12:28:10 -0500
committerWim Van Sebroeck <wim@iguana.be>2015-12-13 09:29:57 -0500
commitc71f5cd25f946fe1eb13bb25230ce0a957c9ac16 (patch)
tree16d99708cfe8593c5d99f92f6cc838b6eb8b3735
parent80969a68ffed12f82e2a29908306ff43a6861a61 (diff)
watchdog: s3c2410_wdt: use core restart handler
Get rid of the custom restart handler by using the one provided by the watchdog core. Signed-off-by: Damien Riegel <damien.riegel@savoirfairelinux.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
-rw-r--r--drivers/watchdog/s3c2410_wdt.c60
1 files changed, 25 insertions, 35 deletions
diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c
index d781000c7825..0093450441fe 100644
--- a/drivers/watchdog/s3c2410_wdt.c
+++ b/drivers/watchdog/s3c2410_wdt.c
@@ -41,7 +41,6 @@
41#include <linux/of.h> 41#include <linux/of.h>
42#include <linux/mfd/syscon.h> 42#include <linux/mfd/syscon.h>
43#include <linux/regmap.h> 43#include <linux/regmap.h>
44#include <linux/reboot.h>
45#include <linux/delay.h> 44#include <linux/delay.h>
46 45
47#define S3C2410_WTCON 0x00 46#define S3C2410_WTCON 0x00
@@ -130,7 +129,6 @@ struct s3c2410_wdt {
130 unsigned long wtdat_save; 129 unsigned long wtdat_save;
131 struct watchdog_device wdt_device; 130 struct watchdog_device wdt_device;
132 struct notifier_block freq_transition; 131 struct notifier_block freq_transition;
133 struct notifier_block restart_handler;
134 struct s3c2410_wdt_variant *drv_data; 132 struct s3c2410_wdt_variant *drv_data;
135 struct regmap *pmureg; 133 struct regmap *pmureg;
136}; 134};
@@ -351,6 +349,29 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd, unsigned timeou
351 return 0; 349 return 0;
352} 350}
353 351
352static int s3c2410wdt_restart(struct watchdog_device *wdd)
353{
354 struct s3c2410_wdt *wdt = watchdog_get_drvdata(wdd);
355 void __iomem *wdt_base = wdt->reg_base;
356
357 /* disable watchdog, to be safe */
358 writel(0, wdt_base + S3C2410_WTCON);
359
360 /* put initial values into count and data */
361 writel(0x80, wdt_base + S3C2410_WTCNT);
362 writel(0x80, wdt_base + S3C2410_WTDAT);
363
364 /* set the watchdog to go and reset... */
365 writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV16 |
366 S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x20),
367 wdt_base + S3C2410_WTCON);
368
369 /* wait for reset to assert... */
370 mdelay(500);
371
372 return 0;
373}
374
354#define OPTIONS (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE) 375#define OPTIONS (WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | WDIOF_MAGICCLOSE)
355 376
356static const struct watchdog_info s3c2410_wdt_ident = { 377static const struct watchdog_info s3c2410_wdt_ident = {
@@ -365,6 +386,7 @@ static struct watchdog_ops s3c2410wdt_ops = {
365 .stop = s3c2410wdt_stop, 386 .stop = s3c2410wdt_stop,
366 .ping = s3c2410wdt_keepalive, 387 .ping = s3c2410wdt_keepalive,
367 .set_timeout = s3c2410wdt_set_heartbeat, 388 .set_timeout = s3c2410wdt_set_heartbeat,
389 .restart = s3c2410wdt_restart,
368}; 390};
369 391
370static struct watchdog_device s3c2410_wdd = { 392static struct watchdog_device s3c2410_wdd = {
@@ -452,31 +474,6 @@ static inline void s3c2410wdt_cpufreq_deregister(struct s3c2410_wdt *wdt)
452} 474}
453#endif 475#endif
454 476
455static int s3c2410wdt_restart(struct notifier_block *this,
456 unsigned long mode, void *cmd)
457{
458 struct s3c2410_wdt *wdt = container_of(this, struct s3c2410_wdt,
459 restart_handler);
460 void __iomem *wdt_base = wdt->reg_base;
461
462 /* disable watchdog, to be safe */
463 writel(0, wdt_base + S3C2410_WTCON);
464
465 /* put initial values into count and data */
466 writel(0x80, wdt_base + S3C2410_WTCNT);
467 writel(0x80, wdt_base + S3C2410_WTDAT);
468
469 /* set the watchdog to go and reset... */
470 writel(S3C2410_WTCON_ENABLE | S3C2410_WTCON_DIV16 |
471 S3C2410_WTCON_RSTEN | S3C2410_WTCON_PRESCALE(0x20),
472 wdt_base + S3C2410_WTCON);
473
474 /* wait for reset to assert... */
475 mdelay(500);
476
477 return NOTIFY_DONE;
478}
479
480static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt) 477static inline unsigned int s3c2410wdt_get_bootstatus(struct s3c2410_wdt *wdt)
481{ 478{
482 unsigned int rst_stat; 479 unsigned int rst_stat;
@@ -605,6 +602,7 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
605 } 602 }
606 603
607 watchdog_set_nowayout(&wdt->wdt_device, nowayout); 604 watchdog_set_nowayout(&wdt->wdt_device, nowayout);
605 watchdog_set_restart_priority(&wdt->wdt_device, 128);
608 606
609 wdt->wdt_device.bootstatus = s3c2410wdt_get_bootstatus(wdt); 607 wdt->wdt_device.bootstatus = s3c2410wdt_get_bootstatus(wdt);
610 wdt->wdt_device.parent = &pdev->dev; 608 wdt->wdt_device.parent = &pdev->dev;
@@ -632,12 +630,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev)
632 630
633 platform_set_drvdata(pdev, wdt); 631 platform_set_drvdata(pdev, wdt);
634 632
635 wdt->restart_handler.notifier_call = s3c2410wdt_restart;
636 wdt->restart_handler.priority = 128;
637 ret = register_restart_handler(&wdt->restart_handler);
638 if (ret)
639 pr_err("cannot register restart handler, %d\n", ret);
640
641 /* print out a statement of readiness */ 633 /* print out a statement of readiness */
642 634
643 wtcon = readl(wdt->reg_base + S3C2410_WTCON); 635 wtcon = readl(wdt->reg_base + S3C2410_WTCON);
@@ -667,8 +659,6 @@ static int s3c2410wdt_remove(struct platform_device *dev)
667 int ret; 659 int ret;
668 struct s3c2410_wdt *wdt = platform_get_drvdata(dev); 660 struct s3c2410_wdt *wdt = platform_get_drvdata(dev);
669 661
670 unregister_restart_handler(&wdt->restart_handler);
671
672 ret = s3c2410wdt_mask_and_disable_reset(wdt, true); 662 ret = s3c2410wdt_mask_and_disable_reset(wdt, true);
673 if (ret < 0) 663 if (ret < 0)
674 return ret; 664 return ret;