14 #include <linux/module.h>
16 #include <linux/types.h>
17 #include <linux/kernel.h>
20 #include <linux/watchdog.h>
22 #include <linux/bitops.h>
27 #include <linux/device.h>
29 #include <linux/slab.h>
31 #define MODULE_NAME "DAVINCI-WDT: "
33 #define DEFAULT_HEARTBEAT 60
34 #define MAX_HEARTBEAT 600
48 #define ENAMODE12_DISABLED (0 << 6)
49 #define ENAMODE12_ONESHOT (1 << 6)
50 #define ENAMODE12_PERIODIC (2 << 6)
53 #define TIM12RS_UNRESET (1 << 0)
54 #define TIM34RS_UNRESET (1 << 1)
55 #define TIMMODE_64BIT_WDOG (2 << 2)
58 #define WDEN (1 << 14)
59 #define WDFLAG (1 << 15)
60 #define WDKEY_SEQ0 (0xa5c6 << 16)
61 #define WDKEY_SEQ1 (0xda7e << 16)
66 static unsigned long wdt_status;
68 #define WDT_OK_TO_CLOSE 1
69 #define WDT_REGION_INITED 2
70 #define WDT_DEVICE_INITED 3
76 static void wdt_service(
void)
88 static void wdt_enable(
void)
92 unsigned long wdt_freq;
108 timer_margin = (((
u64)
heartbeat * wdt_freq) & 0xffffffff);
137 davinci_wdt_write(
struct file *file,
const char *
data,
size_t len,
148 .identity =
"DaVinci Watchdog",
151 static long davinci_wdt_ioctl(
struct file *file,
152 unsigned int cmd,
unsigned long arg)
159 sizeof(ident)) ? -
EFAULT : 0;
179 static int davinci_wdt_release(
struct inode *inode,
struct file *file)
190 .write = davinci_wdt_write,
191 .unlocked_ioctl = davinci_wdt_ioctl,
192 .open = davinci_wdt_open,
193 .release = davinci_wdt_release,
196 static struct miscdevice davinci_wdt_miscdev = {
199 .fops = &davinci_wdt_fops,
209 return PTR_ERR(wdt_clk);
219 if (wdt_mem ==
NULL) {
220 dev_err(dev,
"failed to get memory region resource\n");
224 size = resource_size(wdt_mem);
226 dev_err(dev,
"failed to get memory region\n");
232 dev_err(dev,
"failed to map memory region\n");
240 dev_err(dev,
"cannot register misc device\n");
270 .probe = davinci_wdt_probe,
281 "Watchdog heartbeat period in seconds from 1 to "