10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
13 #include <linux/kernel.h>
16 #include <linux/watchdog.h>
20 #include <linux/module.h>
22 #include <mach/platform.h>
23 #include <mach/regs-rtc.h>
25 #define DEFAULT_HEARTBEAT 19
26 #define MAX_HEARTBEAT (0x10000000 >> 6)
29 #define BV_RTC_PERSISTENT1_GENERAL__RTC_FORCE_UPDATER 0x80000000
32 #define WDT_OK_TO_CLOSE 1
34 #define WDOG_COUNTER_RATE 1000
37 static unsigned long wdt_status;
44 spin_lock(&stmp3xxx_wdt_io_lock);
46 stmp3xxx_setl(BM_RTC_CTRL_WATCHDOGEN, REGS_RTC_BASE + HW_RTC_CTRL);
48 REGS_RTC_BASE + HW_RTC_PERSISTENT1);
49 spin_unlock(&stmp3xxx_wdt_io_lock);
52 static void wdt_disable(
void)
54 spin_lock(&stmp3xxx_wdt_io_lock);
56 REGS_RTC_BASE + HW_RTC_PERSISTENT1);
57 stmp3xxx_clearl(BM_RTC_CTRL_WATCHDOGEN, REGS_RTC_BASE + HW_RTC_CTRL);
58 spin_unlock(&stmp3xxx_wdt_io_lock);
61 static void wdt_ping(
void)
77 static ssize_t stmp3xxx_wdt_write(
struct file *file,
const char __user *
data,
78 size_t len, loff_t *ppos)
86 for (i = 0; i != len; i++) {
106 .identity =
"STMP3XXX Watchdog",
109 static long stmp3xxx_wdt_ioctl(
struct file *file,
unsigned int cmd,
114 int new_heartbeat,
opts;
140 pr_debug(
"%s: unknown option 0x%x\n", __func__, opts);
173 static int stmp3xxx_wdt_release(
struct inode *inode,
struct file *file)
180 pr_debug(
"%s: Device closed unexpectedly\n", __func__);
195 .write = stmp3xxx_wdt_write,
196 .unlocked_ioctl = stmp3xxx_wdt_ioctl,
197 .open = stmp3xxx_wdt_open,
198 .release = stmp3xxx_wdt_release,
201 static struct miscdevice stmp3xxx_wdt_miscdev = {
204 .fops = &stmp3xxx_wdt_fops,
218 REGS_RTC_BASE + HW_RTC_PERSISTENT1);
223 dev_err(&pdev->
dev,
"cannot register misc device\n");
239 static int wdt_suspended;
240 static u32 wdt_saved_time;
246 BM_RTC_CTRL_WATCHDOGEN) {
248 wdt_saved_time =
__raw_readl(REGS_RTC_BASE + HW_RTC_WATCHDOG);
257 wdt_enable(wdt_saved_time);
263 #define stmp3xxx_wdt_suspend NULL
264 #define stmp3xxx_wdt_resume NULL
269 .name =
"stmp3xxx_wdt",
271 .probe = stmp3xxx_wdt_probe,
284 "Watchdog heartbeat period in seconds from 1 to "