39 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
41 #include <linux/module.h>
42 #include <linux/types.h>
44 #include <linux/watchdog.h>
49 #include <linux/reboot.h>
57 static unsigned long sbc8360_is_open;
126 static int wd_times[64][2] = {
193 #define SBC8360_ENABLE 0x120
194 #define SBC8360_BASETIME 0x121
197 static int wd_margin = 0xB;
198 static int wd_multiplier = 2;
202 MODULE_PARM_DESC(timeout,
"Index into timeout table (0-63) (default=27 (60s))");
205 "Watchdog cannot be stopped once started (default="
213 static void sbc8360_activate(
void)
227 static void sbc8360_ping(
void)
234 static void sbc8360_stop(
void)
242 size_t count, loff_t *ppos)
251 for (i = 0; i !=
count; i++) {
264 static int sbc8360_open(
struct inode *
inode,
struct file *file)
277 static int sbc8360_close(
struct inode *inode,
struct file *file)
279 if (expect_close == 42)
282 pr_crit(
"SBC8360 device closed unexpectedly. SBC8360 will not stop!\n");
309 .write = sbc8360_write,
310 .open = sbc8360_open,
311 .release = sbc8360_close,
317 .fops = &sbc8360_fops,
326 .notifier_call = sbc8360_notify_sys,
329 static int __init sbc8360_init(
void)
332 unsigned long int mseconds = 60000;
334 if (timeout < 0 || timeout > 63) {
335 pr_err(
"Invalid timeout index (must be 0-63)\n");
341 pr_err(
"ENABLE method I/O %X is not available\n",
347 pr_err(
"BASETIME method I/O %X is not available\n",
350 goto out_nobasetimereg;
355 pr_err(
"Failed to register reboot notifier\n");
361 pr_err(
"failed to register misc device\n");
365 wd_margin = wd_times[
timeout][0];
366 wd_multiplier = wd_times[
timeout][1];
368 if (wd_multiplier == 1)
369 mseconds = (wd_margin + 1) * 500;
370 else if (wd_multiplier == 2)
371 mseconds = (wd_margin + 1) * 5000;
372 else if (wd_multiplier == 3)
373 mseconds = (wd_margin + 1) * 50000;
374 else if (wd_multiplier == 4)
375 mseconds = (wd_margin + 1) * 100000;
378 pr_info(
"Timeout set at %ld ms\n", mseconds);
392 static void __exit sbc8360_exit(
void)