[COMMON] watchdog: s3c2410_wdt: add set_emergency_reset function
authorHyunki Koo <hyunki00.koo@samsung.com>
Sat, 24 Oct 2015 10:29:22 +0000 (19:29 +0900)
committerJaehyoung Choi <jkkkkk.choi@samsung.com>
Wed, 9 May 2018 11:27:47 +0000 (20:27 +0900)
This patch add set_emergency_reset function for safe panic handler

Change-Id: Ief3672cfc1ab90178c8b36aa17db310946555ad3
Signed-off-by: Hyunki Koo <hyunki00.koo@samsung.com>
drivers/watchdog/s3c2410_wdt.c

index f4dac67d005a65f209a98b924ad252570b38b61d..78dc75275c239553e1eaa97328ad0a360b85986a 100644 (file)
@@ -599,6 +599,26 @@ static int s3c2410wdt_panic_handler(struct notifier_block *nb,
        return 0;
 }
 
+int s3c2410wdt_set_emergency_reset(unsigned int timeout_cnt)
+{
+       struct s3c2410_wdt *wdt = s3c_wdt;
+       unsigned int wtdat = 0x100;
+       unsigned int wtcnt = wtdat + timeout_cnt;
+       unsigned long wtcon;
+
+       if (!s3c_wdt)
+               return -ENODEV;
+
+       /* emergency reset with wdt reset */
+       wtcon = readl(wdt->reg_base + S3C2410_WTCON);
+       wtcon |= S3C2410_WTCON_RSTEN | S3C2410_WTCON_ENABLE;
+
+       writel(wtdat, wdt->reg_base + S3C2410_WTDAT);
+       writel(wtcnt, wdt->reg_base + S3C2410_WTCNT);
+       writel(wtcon, wdt->reg_base + S3C2410_WTCON);
+
+       return 0;
+}
 static struct notifier_block nb_panic_block = {
        .notifier_call = s3c2410wdt_panic_handler,
 };