watchdog: sp805: add restart handler
PATCH 1/1 watchdog: sp805: add restart handler
Add restart handler for SP805 watchdog so that the driver can be used to reboot the system.
--- drivers/watchdog/sp805_wdt.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/watchdog/sp805_wdt.c +19 -0
@@ -23,6 +23,7 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/pm.h> +#include <linux/reboot.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/types.h>
@@ -67,6 +68,7 @@ struct sp805_wdt {struct clk *clk;struct amba_device *adev;unsigned int load_val; +struct notifier_block restart; };static bool nowayout =WATCHDOG_NOWAYOUT ;
@@ -200,6 +202,18 @@ static const struct watchdog_ops wdt_ops = { .get_timeleft = wdt_timeleft, }; +static int +wdt_restart (struct notifier_block *this,unsigned long mode,void *cmd) +{ + struct sp805_wdt *wdt = container_of(this, struct sp805_wdt, restart); + +writel_relaxed (0 , wdt->base +WDTCONTROL ); +writel_relaxed (0 , wdt->base +WDTLOAD ); +writel_relaxed (INT_ENABLE |RESET_ENABLE , wdt->base +WDTCONTROL ); + +return 0 ; +} +static int sp805_wdt_probe (struct amba_device *adev,const struct amba_id *id) {
@@ -241,6 +255,10 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) }amba_set_drvdata (adev, wdt); + wdt->restart.notifier_call = wdt_restart; + wdt->restart.priority =128 ; +register_restart_handler (&wdt->restart); +dev_info (&adev->dev,"registration successful\n" );return 0 ;
@@ -253,6 +271,7 @@ static int sp805_wdt_remove(struct amba_device *adev) {struct sp805_wdt *wdt =amba_get_drvdata (adev); +unregister_restart_handler (&wdt->restart);watchdog_unregister_device (&wdt->wdd);watchdog_set_drvdata (&wdt->wdd,NULL );
Signature · 1 line
2.14.1
Guenter Roeck
maintainerQuoted 48 lines · Jongsung Kim
Add restart handler for SP805 watchdog so that the driver can be used to reboot the system.
Signed-off-by Jongsung Kim <[email protected]>--- drivers/watchdog/sp805_wdt.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/watchdog/sp805_wdt.c +14
-0@@ -23,6 +23,7 @@#include <linux/module.h> #include <linux/moduleparam.h> #include <linux/pm.h> +#include <linux/reboot.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/types.h> @@ -67,6 +68,7 @@ struct sp805_wdt {struct clk *clk;struct amba_device *adev;unsigned int load_val; +struct notifier_block restart; };static bool nowayout =WATCHDOG_NOWAYOUT ;@@ -200,6 +202,18 @@ static const struct watchdog_ops wdt_ops = { .get_timeleft = wdt_timeleft, }; +static int +wdt_restart (struct notifier_block *this,unsigned long mode,void *cmd) +{ + struct sp805_wdt *wdt = container_of(this, struct sp805_wdt, restart); + +writel_relaxed (0 , wdt->base +WDTCONTROL ); +writel_relaxed (0 , wdt->base +WDTLOAD ); +writel_relaxed (INT_ENABLE |RESET_ENABLE , wdt->base +WDTCONTROL ); + +return 0 ; +} +static int sp805_wdt_probe (struct amba_device *adev,const struct amba_id *id) {
drivers/watchdog/sp805_wdt.c sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) · line 261
Quoted 7 lines
drivers/watchdog/sp805_wdt.c +4
-0@@ -241,6 +255,10 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) }amba_set_drvdata (adev, wdt); + wdt->restart.notifier_call = wdt_restart; + wdt->restart.priority =128 ; +register_restart_handler (&wdt->restart); +
Why not use the watchdog core ?
Guenter
Quoted 12 lines
drivers/watchdog/sp805_wdt.c +1
-0dev_info (&adev->dev,"registration successful\n" );return 0 ;@@ -253,6 +271,7 @@ static int sp805_wdt_remove(struct amba_device *adev) {struct sp805_wdt *wdt =amba_get_drvdata (adev); +unregister_restart_handler (&wdt->restart);watchdog_unregister_device (&wdt->wdd);watchdog_set_drvdata (&wdt->wdd,NULL );
Quoted 47 lines · Guenter Roeck
Quoted 46 lines · Jongsung Kim
Add restart handler for SP805 watchdog so that the driver can be used to reboot the system.
Signed-off-by Jongsung Kim <[email protected]>---
drivers/watchdog/sp805_wdt.c| 19 +++++++++++++++++++1 file changed, 19 insertions(+)drivers/watchdog/sp805_wdt.c +2
-0@@ -23,6 +23,7 @@ #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/pm.h> +#include <linux/reboot.h> #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/types.h>@@ -67,6 +68,7 @@ struct sp805_wdt { struct clk *clk; struct amba_device *adev; unsigned int load_val; + struct notifier_block restart; }; static bool nowayout = WATCHDOG_NOWAYOUT;@@ -200,6 +202,18 @@ static const struct watchdog_ops wdt_ops = { .get_timeleft = wdt_timeleft, };+static int
drivers/watchdog/sp805_wdt.c +11
-0+wdt_restart(struct notifier_block *this, unsigned long mode, void *cmd) +{ + struct sp805_wdt *wdt = container_of(this, struct sp805_wdt, restart); + + writel_relaxed(0, wdt->base + WDTCONTROL); + writel_relaxed(0, wdt->base + WDTLOAD); + writel_relaxed(INT_ENABLE | RESET_ENABLE, wdt->base + WDTCONTROL); + + return 0; +} +static int
sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id){drivers/watchdog/sp805_wdt.c +0
-0@@ -241,6 +255,10 @@ sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id)
Quoted 8 lines
drivers/watchdog/sp805_wdt.c sp805_wdt_probe(struct amba_device *adev, const struct amba_id *id) · line 261
Quoted 6 lines
drivers/watchdog/sp805_wdt.c +3
-0} amba_set_drvdata(adev, wdt); + wdt->restart.notifier_call = wdt_restart; + wdt->restart.priority = 128; + register_restart_handler(&wdt->restart); +Why not use the watchdog core ?
Thank you for pointing this. I didn't noticed core changes about restart function because I'm still using old v4.4.xx..
Quoted 14 lines
Guenter
Quoted 9 lines
drivers/watchdog/sp805_wdt.c +0
-0dev_info(&adev->dev, "registration successful\n"); return 0; @@ -253,6 +271,7 @@ static int sp805_wdt_remove(struct amba_device *adev){
structsp805_wdt*wdt =amba_get_drvdata(adev); +unregister_restart_handler(&wdt->restart);watchdog_unregister_device(&wdt->wdd);watchdog_set_drvdata(&wdt->wdd, NULL);