10 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
12 #include <linux/module.h>
15 #include <linux/watchdog.h>
21 #include <lantiq_soc.h>
31 #define LTQ_WDT_PW1 0x00BE0000
32 #define LTQ_WDT_PW2 0x00DC0000
34 #define LTQ_WDT_CR 0x0
35 #define LTQ_WDT_SR 0x8
37 #define LTQ_WDT_SR_EN (0x1 << 31)
38 #define LTQ_WDT_SR_PWD (0x3 << 26)
39 #define LTQ_WDT_SR_CLKDIV (0x3 << 24)
41 #define LTQ_WDT_DIVIDER 0x40000
42 #define LTQ_MAX_TIMEOUT ((1 << 16) - 1)
46 static void __iomem *ltq_wdt_membase;
47 static unsigned long ltq_io_region_clk_rate;
49 static unsigned long ltq_wdt_bootstatus;
50 static unsigned long ltq_wdt_in_use;
51 static int ltq_wdt_timeout = 30;
52 static int ltq_wdt_ok_to_close;
57 unsigned long int timeout = ltq_wdt_timeout *
82 ltq_wdt_write(
struct file *
file,
const char __user *
data,
83 size_t len, loff_t *ppos)
89 ltq_wdt_ok_to_close = 0;
90 for (i = 0; i != len; i++) {
96 ltq_wdt_ok_to_close = 1;
98 ltq_wdt_ok_to_close = 0;
110 .identity =
"ltq_wdt",
114 ltq_wdt_ioctl(
struct file *file,
115 unsigned int cmd,
unsigned long arg)
122 sizeof(ident)) ? -
EFAULT : 0;
126 ret =
put_user(ltq_wdt_bootstatus, (
int __user *)arg);
130 ret =
put_user(0, (
int __user *)arg);
134 ret =
get_user(ltq_wdt_timeout, (
int __user *)arg);
139 ret =
put_user(ltq_wdt_timeout, (
int __user *)arg);
151 ltq_wdt_open(
struct inode *
inode,
struct file *file)
162 ltq_wdt_release(
struct inode *inode,
struct file *file)
164 if (ltq_wdt_ok_to_close)
167 pr_err(
"watchdog closed without warning\n");
168 ltq_wdt_ok_to_close = 0;
176 .write = ltq_wdt_write,
177 .unlocked_ioctl = ltq_wdt_ioctl,
178 .open = ltq_wdt_open,
179 .release = ltq_wdt_release,
186 .fops = <q_wdt_fops,
196 dev_err(&pdev->
dev,
"cannot obtain I/O memory region");
201 if (!ltq_wdt_membase) {
202 dev_err(&pdev->
dev,
"cannot remap I/O memory region\n");
232 { .compatible =
"lantiq,wdt" },
238 .probe = ltq_wdt_probe,
243 .of_match_table = ltq_wdt_match,