From 321d0902362fadd4e3616e8810b9c5fb2749ddc1 Mon Sep 17 00:00:00 2001 From: Hyunki Koo Date: Sat, 24 Oct 2015 19:29:22 +0900 Subject: [PATCH] [COMMON] watchdog: s3c2410_wdt: add set_emergency_reset function This patch add set_emergency_reset function for safe panic handler Change-Id: Ief3672cfc1ab90178c8b36aa17db310946555ad3 Signed-off-by: Hyunki Koo --- drivers/watchdog/s3c2410_wdt.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/watchdog/s3c2410_wdt.c b/drivers/watchdog/s3c2410_wdt.c index f4dac67d005a..78dc75275c23 100644 --- a/drivers/watchdog/s3c2410_wdt.c +++ b/drivers/watchdog/s3c2410_wdt.c @@ -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, }; -- 2.20.1