[COMMON] watchdog: s3c2410_wdt: Only watchdog kicking for suspend
authorChangki Kim <changki.kim@samsung.com>
Mon, 6 Mar 2017 05:42:41 +0000 (14:42 +0900)
committerJaehyoung Choi <jkkkkk.choi@samsung.com>
Wed, 9 May 2018 11:27:47 +0000 (20:27 +0900)
When the system is stuck, it must be reset.
This patch gurantees the reset before entering the suspend.

Change-Id: Ic31244748fc9e8232faa7837e7bbb9ed7c52f209
Signed-off-by: Changki Kim <changki.kim@samsung.com>
drivers/watchdog/s3c2410_wdt.c

index dcd29dc8c27f874a1461af6721a34557b3bbfcb5..eb338f049026c25e6bea8d092658cdf8979aa2be 100644 (file)
@@ -381,7 +381,7 @@ static int s3c2410wdt_set_heartbeat(struct watchdog_device *wdd,
 
                if (divisor > 0x100) {
                        dev_err(wdt->dev, "timeout %d too big\n", timeout);
-                       return -EINVAL;
+                       divisor = 0x100;
                }
        }
 
@@ -578,13 +578,18 @@ int s3c2410wdt_set_emergency_stop(void)
        return 0;
 }
 
-int s3c2410wdt_keepalive_emergency(void)
+int s3c2410wdt_keepalive_emergency(bool reset)
 {
        struct s3c2410_wdt *wdt = s3c_wdt;
 
        if (!wdt)
                return -ENODEV;
 
+       if (reset) {
+               pr_emerg("watchdog reset is started to 30secs\n");
+               s3c2410wdt_set_heartbeat(&wdt->wdt_device, 30);
+               s3c2410wdt_start(&wdt->wdt_device);
+       }
        /* This Function must be called during panic sequence only */
        writel(wdt->count, wdt->reg_base + S3C2410_WTCNT);
        return 0;
@@ -646,22 +651,17 @@ static struct notifier_block nb_panic_block = {
 #ifdef CONFIG_PM
 static int s3c2410wdt_suspend(void)
 {
-       int ret = 0;
        struct s3c2410_wdt *wdt = s3c_wdt;
 
        if (!wdt)
-               return ret;
+               return 0;
 
+       s3c2410wdt_keepalive(&wdt->wdt_device);
        /* Save watchdog state, and turn it off. */
        wdt->wtcon_save = readl(wdt->reg_base + S3C2410_WTCON);
        wdt->wtdat_save = readl(wdt->reg_base + S3C2410_WTDAT);
 
-       /* Note that WTCNT doesn't need to be saved. */
-       s3c2410wdt_stop(&wdt->wdt_device);
-
-       ret = s3c2410wdt_mask_wdt_reset(wdt, true);
-
-       return ret;
+       return 0;
 }
 
 static void s3c2410wdt_resume(void)