9 #include <linux/module.h>
10 #include <linux/types.h>
11 #include <linux/watchdog.h>
16 #include <linux/bitops.h>
21 #define DRV_NAME "WDOG COH 901 327"
28 #define U300_WDOG_FR 0x00
29 #define U300_WDOG_FR_FEED_RESTART_TIMER 0xFEEDU
31 #define U300_WDOG_TR 0x04
32 #define U300_WDOG_TR_TIMEOUT_MASK 0x7FFFU
34 #define U300_WDOG_D1R 0x08
35 #define U300_WDOG_D1R_DISABLE1_DISABLE_TIMER 0x2BADU
37 #define U300_WDOG_D2R 0x0C
38 #define U300_WDOG_D2R_DISABLE2_DISABLE_TIMER 0xCAFEU
39 #define U300_WDOG_D2R_DISABLE_STATUS_DISABLED 0xDABEU
40 #define U300_WDOG_D2R_DISABLE_STATUS_ENABLED 0x0000U
42 #define U300_WDOG_SR 0x10
43 #define U300_WDOG_SR_STATUS_TIMED_OUT 0xCFE8U
44 #define U300_WDOG_SR_STATUS_NORMAL 0x0000U
45 #define U300_WDOG_SR_RESET_STATUS_RESET 0xE8B4U
47 #define U300_WDOG_CR 0x14
48 #define U300_WDOG_CR_VALID_IND 0x8000U
49 #define U300_WDOG_CR_VALID_STABLE 0x0000U
50 #define U300_WDOG_CR_COUNT_VALUE_MASK 0x7FFFU
52 #define U300_WDOG_JOR 0x18
53 #define U300_WDOG_JOR_JTAG_MODE_IND 0x0002U
54 #define U300_WDOG_JOR_JTAG_WATCHDOG_ENABLE 0x0001U
56 #define U300_WDOG_RR 0x1C
57 #define U300_WDOG_RR_RESTART_VALUE_RESUME 0xACEDU
59 #define U300_WDOG_IER 0x20
60 #define U300_WDOG_IER_WILL_BARK_IRQ_EVENT_IND 0x0001U
61 #define U300_WDOG_IER_WILL_BARK_IRQ_ACK_ENABLE 0x0001U
63 #define U300_WDOG_IMR 0x24
64 #define U300_WDOG_IMR_WILL_BARK_IRQ_ENABLE 0x0001U
66 #define U300_WDOG_IFR 0x28
67 #define U300_WDOG_IFR_WILL_BARK_IRQ_FORCE_ENABLE 0x0001U
70 static unsigned int margin = 60;
87 static void coh901327_enable(
u16 timeout)
91 unsigned long delay_ns;
108 delay_ns = 3 * delay_ns;
124 "%s(): watchdog not enabled! D2R value %04x\n",
128 static void coh901327_disable(
void)
150 "%s(): watchdog not disabled! D2R value %04x\n",
156 coh901327_enable(wdt_dev->
timeout * 100);
190 static unsigned int coh901327_gettimeleft(
struct watchdog_device *wdt_dev)
231 dev_crit(parent,
"watchdog is barking!\n");
242 .start = coh901327_start,
243 .stop = coh901327_stop,
244 .ping = coh901327_ping,
245 .set_timeout = coh901327_settimeout,
246 .get_timeleft = coh901327_gettimeleft,
250 .info = &coh901327_ident,
251 .ops = &coh901327_ops,
284 physize = resource_size(res);
285 phybase = res->
start;
292 virtbase =
ioremap(phybase, physize);
304 ret = clk_prepare_enable(clk);
306 dev_err(&pdev->
dev,
"could not prepare and enable clock\n");
307 goto out_no_clk_enable;
314 "watchdog timed out since last chip reset!\n");
320 "in normal status, no timeouts have occurred.\n");
324 "contains an illegal status code (%08x)\n", val);
335 "currently enabled! (disabling it now)\n");
340 "contains an illegal enable/disable code (%08x)\n",
357 if (margin < 1 || margin > 327)
359 coh901327_wdt.
timeout = margin;
364 "initialized. timer margin=%d sec\n", margin);
373 clk_disable_unprepare(clk);
386 static u16 wdogenablestore;
387 static u16 irqmaskstore;
413 #define coh901327_suspend NULL
414 #define coh901327_resume NULL
440 coh901327_enable(500);
447 .name =
"coh901327_wdog",
449 .remove =
__exit_p(coh901327_remove),
454 static int __init coh901327_init(
void)
460 static void __exit coh901327_exit(
void)