20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22 #include <linux/module.h>
24 #include <linux/types.h>
25 #include <linux/kernel.h>
29 #include <linux/watchdog.h>
31 #include <linux/reboot.h>
35 #define WATCHDOG_TIMEOUT 30
36 #define WATCHDOG_COUNT_FREQUENCY 68000000U
37 #define PNX_WATCHDOG_TIMEOUT (WATCHDOG_TIMEOUT * WATCHDOG_COUNT_FREQUENCY)
38 #define PNX_TIMEOUT_VALUE 2040000000U
41 #define PNX833X_CONFIG (0x07000U)
42 #define PNX833X_CONFIG_CPU_WATCHDOG (0x54)
43 #define PNX833X_CONFIG_CPU_WATCHDOG_COMPARE (0x58)
44 #define PNX833X_CONFIG_CPU_COUNTERS_CONTROL (0x1c)
47 #define PNX833X_RESET (0x08000U)
48 #define PNX833X_RESET_CONFIG (0x08)
50 static int pnx833x_wdt_alive;
60 MODULE_PARM_DESC(nowayout,
"Watchdog cannot be stopped once started (default="
63 #define START_DEFAULT 1
69 static void pnx833x_wdt_start(
void)
80 pr_info(
"Started watchdog timer\n");
83 static void pnx833x_wdt_stop(
void)
91 pr_info(
"Stopped watchdog timer\n");
94 static void pnx833x_wdt_ping(
void)
117 pr_info(
"Started watchdog timer\n");
122 static int pnx833x_wdt_release(
struct inode *inode,
struct file *file)
133 static ssize_t pnx833x_wdt_write(
struct file *file,
const char *
data,
size_t len, loff_t *ppos)
142 static long pnx833x_wdt_ioctl(
struct file *file,
unsigned int cmd,
150 .firmware_version = 0,
151 .identity =
"Hardware Watchdog for PNX833x",
160 &ident,
sizeof(ident)))
186 if (
get_user(new_timeout, (
int *)arg))
189 pnx833x_wdt_timeout = new_timeout;
192 return put_user(new_timeout, (
int *)arg);
198 return put_user(timeout, (
int *)arg);
203 return put_user(timeout_left, (
int *)arg);
220 .write = pnx833x_wdt_write,
221 .unlocked_ioctl = pnx833x_wdt_ioctl,
222 .open = pnx833x_wdt_open,
223 .release = pnx833x_wdt_release,
226 static struct miscdevice pnx833x_wdt_miscdev = {
229 .fops = &pnx833x_wdt_fops,
233 .notifier_call = pnx833x_wdt_notify_sys,
236 static int __init watchdog_init(
void)
243 if (cause & 0x80000000) {
244 pr_info(
"The system was previously reset due to the watchdog firing - please investigate...\n");
249 pr_err(
"cannot register reboot notifier (err=%d)\n", ret);
255 pr_err(
"cannot register miscdev on minor=%d (err=%d)\n",
261 pr_info(
"Hardware Watchdog Timer for PNX833x: Version 0.1\n");
269 static void __exit watchdog_exit(
void)