13 #define pr_fmt(fmt) KBUILD_MODNAME " WATCHDOG: " fmt
15 #include <linux/module.h>
16 #include <linux/types.h>
18 #include <linux/watchdog.h>
30 static unsigned int margin = 60;
31 static unsigned long wdt_status;
35 #define WDT_OK_TO_CLOSE 1
37 #define COMMAND_PORT 0x4c
38 #define DATA_PORT 0x48
40 #define IFACE_ON_COMMAND 1
41 #define REBOOT_COMMAND 2
43 #define WATCHDOG_NAME "SBC-FITPC2 Watchdog"
45 static void wdt_send_data(
unsigned char command,
unsigned char data)
53 static void wdt_enable(
void)
61 static void wdt_disable(
void)
81 static ssize_t fitpc2_wdt_write(
struct file *file,
const char *
data,
82 size_t len, loff_t *ppos)
96 for (i = 0; i != len; i++) {
120 static long fitpc2_wdt_ioctl(
struct file *file,
unsigned int cmd,
129 sizeof(ident)) ? -
EFAULT : 0;
150 if (time < 31 || time > 255) {
167 static int fitpc2_wdt_release(
struct inode *inode,
struct file *file)
173 pr_warn(
"Device closed unexpectedly - timer will not stop\n");
187 .write = fitpc2_wdt_write,
188 .unlocked_ioctl = fitpc2_wdt_ioctl,
189 .open = fitpc2_wdt_open,
190 .release = fitpc2_wdt_release,
193 static struct miscdevice fitpc2_wdt_miscdev = {
196 .fops = &fitpc2_wdt_fops,
199 static int __init fitpc2_wdt_init(
void)
202 const char *brd_name;
206 if (!brd_name || !
strstr(brd_name,
"SBC-FITPC2"))
209 pr_info(
"%s found\n", brd_name);
222 if (margin < 31 || margin > 255) {
223 pr_err(
"margin must be in range 31 - 255 seconds, you tried to set %d\n",
231 pr_err(
"cannot register miscdev on minor=%d (err=%d)\n",
246 static void __exit fitpc2_wdt_exit(
void)