13 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
15 #include <linux/bitops.h>
16 #include <linux/errno.h>
19 #include <linux/kernel.h>
21 #include <linux/module.h>
23 #include <linux/types.h>
25 #include <linux/watchdog.h>
29 #include <linux/ptrace.h>
30 #include <linux/resource.h>
38 #define PFX KBUILD_MODNAME
40 #define WDT_HZ 50000000
41 #define WDT_DEFAULT_TIME 30
42 #define WDT_MAX_TIME 256
57 MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default="
61 static void bcm63xx_wdt_hw_start(
void)
68 static void bcm63xx_wdt_hw_stop(
void)
74 static void bcm63xx_wdt_isr(
void *
data)
81 static void bcm63xx_timer_tick(
unsigned long unused)
84 bcm63xx_wdt_hw_start();
87 pr_crit(
"watchdog will restart system\n");
90 static void bcm63xx_wdt_pet(
void)
92 atomic_set(&bcm63xx_wdt_device.ticks, wdt_time);
95 static void bcm63xx_wdt_start(
void)
98 bcm63xx_timer_tick(0);
101 static void bcm63xx_wdt_pause(
void)
104 bcm63xx_wdt_hw_stop();
107 static int bcm63xx_wdt_settimeout(
int new_time)
126 static int bcm63xx_wdt_release(
struct inode *inode,
struct file *file)
128 if (expect_close == 42)
131 pr_crit(
"Unexpected close, not stopping watchdog!\n");
139 static ssize_t bcm63xx_wdt_write(
struct file *file,
const char *
data,
140 size_t len, loff_t *ppos)
149 for (i = 0; i != len; i++) {
170 static long bcm63xx_wdt_ioctl(
struct file *file,
unsigned int cmd,
180 sizeof(bcm63xx_wdt_info)) ? -
EFAULT : 0;
209 if (bcm63xx_wdt_settimeout(new_value))
226 .write = bcm63xx_wdt_write,
227 .unlocked_ioctl = bcm63xx_wdt_ioctl,
228 .open = bcm63xx_wdt_open,
229 .release = bcm63xx_wdt_release,
232 static struct miscdevice bcm63xx_wdt_miscdev = {
235 .fops = &bcm63xx_wdt_fops,
244 setup_timer(&bcm63xx_wdt_device.timer, bcm63xx_timer_tick, 0L);
248 dev_err(&pdev->
dev,
"failed to get resources\n");
253 if (!bcm63xx_wdt_device.regs) {
254 dev_err(&pdev->
dev,
"failed to remap I/O resources\n");
260 dev_err(&pdev->
dev,
"failed to register wdt timer isr\n");
264 if (bcm63xx_wdt_settimeout(wdt_time)) {
267 ": wdt_time value must be 1 <= wdt_time <= 256, using %d\n",
273 dev_err(&pdev->
dev,
"failed to register watchdog device\n");
274 goto unregister_timer;
277 dev_info(&pdev->
dev,
" started, timer margin: %d sec\n",
285 iounmap(bcm63xx_wdt_device.regs);
296 iounmap(bcm63xx_wdt_device.regs);
306 .probe = bcm63xx_wdt_probe,
308 .shutdown = bcm63xx_wdt_shutdown,
311 .name =
"bcm63xx-wdt",