cpwd.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /* cpwd.c - driver implementation for hardware watchdog
  2. * timers found on Sun Microsystems CP1400 and CP1500 boards.
  3. *
  4. * This device supports both the generic Linux watchdog
  5. * interface and Solaris-compatible ioctls as best it is
  6. * able.
  7. *
  8. * NOTE: CP1400 systems appear to have a defective intr_mask
  9. * register on the PLD, preventing the disabling of
  10. * timer interrupts. We use a timer to periodically
  11. * reset 'stopped' watchdogs on affected platforms.
  12. *
  13. * Copyright (c) 2000 Eric Brower (ebrower@usa.net)
  14. * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include <linux/fs.h>
  19. #include <linux/errno.h>
  20. #include <linux/major.h>
  21. #include <linux/init.h>
  22. #include <linux/miscdevice.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/ioport.h>
  25. #include <linux/timer.h>
  26. #include <linux/smp_lock.h>
  27. #include <linux/io.h>
  28. #include <linux/of.h>
  29. #include <linux/of_device.h>
  30. #include <linux/uaccess.h>
  31. #include <asm/irq.h>
  32. #include <asm/watchdog.h>
  33. #define DRIVER_NAME "cpwd"
  34. #define PFX DRIVER_NAME ": "
  35. #define WD_OBPNAME "watchdog"
  36. #define WD_BADMODEL "SUNW,501-5336"
  37. #define WD_BTIMEOUT (jiffies + (HZ * 1000))
  38. #define WD_BLIMIT 0xFFFF
  39. #define WD0_MINOR 212
  40. #define WD1_MINOR 213
  41. #define WD2_MINOR 214
  42. /* Internal driver definitions. */
  43. #define WD0_ID 0
  44. #define WD1_ID 1
  45. #define WD2_ID 2
  46. #define WD_NUMDEVS 3
  47. #define WD_INTR_OFF 0
  48. #define WD_INTR_ON 1
  49. #define WD_STAT_INIT 0x01 /* Watchdog timer is initialized */
  50. #define WD_STAT_BSTOP 0x02 /* Watchdog timer is brokenstopped */
  51. #define WD_STAT_SVCD 0x04 /* Watchdog interrupt occurred */
  52. /* Register value definitions
  53. */
  54. #define WD0_INTR_MASK 0x01 /* Watchdog device interrupt masks */
  55. #define WD1_INTR_MASK 0x02
  56. #define WD2_INTR_MASK 0x04
  57. #define WD_S_RUNNING 0x01 /* Watchdog device status running */
  58. #define WD_S_EXPIRED 0x02 /* Watchdog device status expired */
  59. struct cpwd {
  60. void __iomem *regs;
  61. spinlock_t lock;
  62. unsigned int irq;
  63. unsigned long timeout;
  64. bool enabled;
  65. bool reboot;
  66. bool broken;
  67. bool initialized;
  68. struct {
  69. struct miscdevice misc;
  70. void __iomem *regs;
  71. u8 intr_mask;
  72. u8 runstatus;
  73. u16 timeout;
  74. } devs[WD_NUMDEVS];
  75. };
  76. static struct cpwd *cpwd_device;
  77. /* Sun uses Altera PLD EPF8820ATC144-4
  78. * providing three hardware watchdogs:
  79. *
  80. * 1) RIC - sends an interrupt when triggered
  81. * 2) XIR - asserts XIR_B_RESET when triggered, resets CPU
  82. * 3) POR - asserts POR_B_RESET when triggered, resets CPU, backplane, board
  83. *
  84. *** Timer register block definition (struct wd_timer_regblk)
  85. *
  86. * dcntr and limit registers (halfword access):
  87. * -------------------
  88. * | 15 | ...| 1 | 0 |
  89. * -------------------
  90. * |- counter val -|
  91. * -------------------
  92. * dcntr - Current 16-bit downcounter value.
  93. * When downcounter reaches '0' watchdog expires.
  94. * Reading this register resets downcounter with
  95. * 'limit' value.
  96. * limit - 16-bit countdown value in 1/10th second increments.
  97. * Writing this register begins countdown with input value.
  98. * Reading from this register does not affect counter.
  99. * NOTES: After watchdog reset, dcntr and limit contain '1'
  100. *
  101. * status register (byte access):
  102. * ---------------------------
  103. * | 7 | ... | 2 | 1 | 0 |
  104. * --------------+------------
  105. * |- UNUSED -| EXP | RUN |
  106. * ---------------------------
  107. * status- Bit 0 - Watchdog is running
  108. * Bit 1 - Watchdog has expired
  109. *
  110. *** PLD register block definition (struct wd_pld_regblk)
  111. *
  112. * intr_mask register (byte access):
  113. * ---------------------------------
  114. * | 7 | ... | 3 | 2 | 1 | 0 |
  115. * +-------------+------------------
  116. * |- UNUSED -| WD3 | WD2 | WD1 |
  117. * ---------------------------------
  118. * WD3 - 1 == Interrupt disabled for watchdog 3
  119. * WD2 - 1 == Interrupt disabled for watchdog 2
  120. * WD1 - 1 == Interrupt disabled for watchdog 1
  121. *
  122. * pld_status register (byte access):
  123. * UNKNOWN, MAGICAL MYSTERY REGISTER
  124. *
  125. */
  126. #define WD_TIMER_REGSZ 16
  127. #define WD0_OFF 0
  128. #define WD1_OFF (WD_TIMER_REGSZ * 1)
  129. #define WD2_OFF (WD_TIMER_REGSZ * 2)
  130. #define PLD_OFF (WD_TIMER_REGSZ * 3)
  131. #define WD_DCNTR 0x00
  132. #define WD_LIMIT 0x04
  133. #define WD_STATUS 0x08
  134. #define PLD_IMASK (PLD_OFF + 0x00)
  135. #define PLD_STATUS (PLD_OFF + 0x04)
  136. static struct timer_list cpwd_timer;
  137. static int wd0_timeout = 0;
  138. static int wd1_timeout = 0;
  139. static int wd2_timeout = 0;
  140. module_param(wd0_timeout, int, 0);
  141. MODULE_PARM_DESC(wd0_timeout, "Default watchdog0 timeout in 1/10secs");
  142. module_param(wd1_timeout, int, 0);
  143. MODULE_PARM_DESC(wd1_timeout, "Default watchdog1 timeout in 1/10secs");
  144. module_param(wd2_timeout, int, 0);
  145. MODULE_PARM_DESC(wd2_timeout, "Default watchdog2 timeout in 1/10secs");
  146. MODULE_AUTHOR("Eric Brower <ebrower@usa.net>");
  147. MODULE_DESCRIPTION("Hardware watchdog driver for Sun Microsystems CP1400/1500");
  148. MODULE_LICENSE("GPL");
  149. MODULE_SUPPORTED_DEVICE("watchdog");
  150. static void cpwd_writew(u16 val, void __iomem *addr)
  151. {
  152. writew(cpu_to_le16(val), addr);
  153. }
  154. static u16 cpwd_readw(void __iomem *addr)
  155. {
  156. u16 val = readw(addr);
  157. return le16_to_cpu(val);
  158. }
  159. static void cpwd_writeb(u8 val, void __iomem *addr)
  160. {
  161. writeb(val, addr);
  162. }
  163. static u8 cpwd_readb(void __iomem *addr)
  164. {
  165. return readb(addr);
  166. }
  167. /* Enable or disable watchdog interrupts
  168. * Because of the CP1400 defect this should only be
  169. * called during initialzation or by wd_[start|stop]timer()
  170. *
  171. * index - sub-device index, or -1 for 'all'
  172. * enable - non-zero to enable interrupts, zero to disable
  173. */
  174. static void cpwd_toggleintr(struct cpwd *p, int index, int enable)
  175. {
  176. unsigned char curregs = cpwd_readb(p->regs + PLD_IMASK);
  177. unsigned char setregs =
  178. (index == -1) ?
  179. (WD0_INTR_MASK | WD1_INTR_MASK | WD2_INTR_MASK) :
  180. (p->devs[index].intr_mask);
  181. if (enable == WD_INTR_ON)
  182. curregs &= ~setregs;
  183. else
  184. curregs |= setregs;
  185. cpwd_writeb(curregs, p->regs + PLD_IMASK);
  186. }
  187. /* Restarts timer with maximum limit value and
  188. * does not unset 'brokenstop' value.
  189. */
  190. static void cpwd_resetbrokentimer(struct cpwd *p, int index)
  191. {
  192. cpwd_toggleintr(p, index, WD_INTR_ON);
  193. cpwd_writew(WD_BLIMIT, p->devs[index].regs + WD_LIMIT);
  194. }
  195. /* Timer method called to reset stopped watchdogs--
  196. * because of the PLD bug on CP1400, we cannot mask
  197. * interrupts within the PLD so me must continually
  198. * reset the timers ad infinitum.
  199. */
  200. static void cpwd_brokentimer(unsigned long data)
  201. {
  202. struct cpwd *p = (struct cpwd *) data;
  203. int id, tripped = 0;
  204. /* kill a running timer instance, in case we
  205. * were called directly instead of by kernel timer
  206. */
  207. if (timer_pending(&cpwd_timer))
  208. del_timer(&cpwd_timer);
  209. for (id = 0; id < WD_NUMDEVS; id++) {
  210. if (p->devs[id].runstatus & WD_STAT_BSTOP) {
  211. ++tripped;
  212. cpwd_resetbrokentimer(p, id);
  213. }
  214. }
  215. if (tripped) {
  216. /* there is at least one timer brokenstopped-- reschedule */
  217. cpwd_timer.expires = WD_BTIMEOUT;
  218. add_timer(&cpwd_timer);
  219. }
  220. }
  221. /* Reset countdown timer with 'limit' value and continue countdown.
  222. * This will not start a stopped timer.
  223. */
  224. static void cpwd_pingtimer(struct cpwd *p, int index)
  225. {
  226. if (cpwd_readb(p->devs[index].regs + WD_STATUS) & WD_S_RUNNING)
  227. cpwd_readw(p->devs[index].regs + WD_DCNTR);
  228. }
  229. /* Stop a running watchdog timer-- the timer actually keeps
  230. * running, but the interrupt is masked so that no action is
  231. * taken upon expiration.
  232. */
  233. static void cpwd_stoptimer(struct cpwd *p, int index)
  234. {
  235. if (cpwd_readb(p->devs[index].regs + WD_STATUS) & WD_S_RUNNING) {
  236. cpwd_toggleintr(p, index, WD_INTR_OFF);
  237. if (p->broken) {
  238. p->devs[index].runstatus |= WD_STAT_BSTOP;
  239. cpwd_brokentimer((unsigned long) p);
  240. }
  241. }
  242. }
  243. /* Start a watchdog timer with the specified limit value
  244. * If the watchdog is running, it will be restarted with
  245. * the provided limit value.
  246. *
  247. * This function will enable interrupts on the specified
  248. * watchdog.
  249. */
  250. static void cpwd_starttimer(struct cpwd *p, int index)
  251. {
  252. if (p->broken)
  253. p->devs[index].runstatus &= ~WD_STAT_BSTOP;
  254. p->devs[index].runstatus &= ~WD_STAT_SVCD;
  255. cpwd_writew(p->devs[index].timeout, p->devs[index].regs + WD_LIMIT);
  256. cpwd_toggleintr(p, index, WD_INTR_ON);
  257. }
  258. static int cpwd_getstatus(struct cpwd *p, int index)
  259. {
  260. unsigned char stat = cpwd_readb(p->devs[index].regs + WD_STATUS);
  261. unsigned char intr = cpwd_readb(p->devs[index].regs + PLD_IMASK);
  262. unsigned char ret = WD_STOPPED;
  263. /* determine STOPPED */
  264. if (!stat)
  265. return ret;
  266. /* determine EXPIRED vs FREERUN vs RUNNING */
  267. else if (WD_S_EXPIRED & stat) {
  268. ret = WD_EXPIRED;
  269. } else if (WD_S_RUNNING & stat) {
  270. if (intr & p->devs[index].intr_mask) {
  271. ret = WD_FREERUN;
  272. } else {
  273. /* Fudge WD_EXPIRED status for defective CP1400--
  274. * IF timer is running
  275. * AND brokenstop is set
  276. * AND an interrupt has been serviced
  277. * we are WD_EXPIRED.
  278. *
  279. * IF timer is running
  280. * AND brokenstop is set
  281. * AND no interrupt has been serviced
  282. * we are WD_FREERUN.
  283. */
  284. if (p->broken &&
  285. (p->devs[index].runstatus & WD_STAT_BSTOP)) {
  286. if (p->devs[index].runstatus & WD_STAT_SVCD) {
  287. ret = WD_EXPIRED;
  288. } else {
  289. /* we could as well pretend
  290. * we are expired */
  291. ret = WD_FREERUN;
  292. }
  293. } else {
  294. ret = WD_RUNNING;
  295. }
  296. }
  297. }
  298. /* determine SERVICED */
  299. if (p->devs[index].runstatus & WD_STAT_SVCD)
  300. ret |= WD_SERVICED;
  301. return ret;
  302. }
  303. static irqreturn_t cpwd_interrupt(int irq, void *dev_id)
  304. {
  305. struct cpwd *p = dev_id;
  306. /* Only WD0 will interrupt-- others are NMI and we won't
  307. * see them here....
  308. */
  309. spin_lock_irq(&p->lock);
  310. cpwd_stoptimer(p, WD0_ID);
  311. p->devs[WD0_ID].runstatus |= WD_STAT_SVCD;
  312. spin_unlock_irq(&p->lock);
  313. return IRQ_HANDLED;
  314. }
  315. static int cpwd_open(struct inode *inode, struct file *f)
  316. {
  317. struct cpwd *p = cpwd_device;
  318. lock_kernel();
  319. switch (iminor(inode)) {
  320. case WD0_MINOR:
  321. case WD1_MINOR:
  322. case WD2_MINOR:
  323. break;
  324. default:
  325. unlock_kernel();
  326. return -ENODEV;
  327. }
  328. /* Register IRQ on first open of device */
  329. if (!p->initialized) {
  330. if (request_irq(p->irq, &cpwd_interrupt,
  331. IRQF_SHARED, DRIVER_NAME, p)) {
  332. printk(KERN_ERR PFX "Cannot register IRQ %d\n",
  333. p->irq);
  334. unlock_kernel();
  335. return -EBUSY;
  336. }
  337. p->initialized = true;
  338. }
  339. unlock_kernel();
  340. return nonseekable_open(inode, f);
  341. }
  342. static int cpwd_release(struct inode *inode, struct file *file)
  343. {
  344. return 0;
  345. }
  346. static long cpwd_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
  347. {
  348. static struct watchdog_info info = {
  349. .options = WDIOF_SETTIMEOUT,
  350. .firmware_version = 1,
  351. .identity = DRIVER_NAME,
  352. };
  353. void __user *argp = (void __user *)arg;
  354. struct inode *inode = file->f_path.dentry->d_inode;
  355. int index = iminor(inode) - WD0_MINOR;
  356. struct cpwd *p = cpwd_device;
  357. int setopt = 0;
  358. switch (cmd) {
  359. /* Generic Linux IOCTLs */
  360. case WDIOC_GETSUPPORT:
  361. if (copy_to_user(argp, &info, sizeof(struct watchdog_info)))
  362. return -EFAULT;
  363. break;
  364. case WDIOC_GETSTATUS:
  365. case WDIOC_GETBOOTSTATUS:
  366. if (put_user(0, (int __user *)argp))
  367. return -EFAULT;
  368. break;
  369. case WDIOC_KEEPALIVE:
  370. cpwd_pingtimer(p, index);
  371. break;
  372. case WDIOC_SETOPTIONS:
  373. if (copy_from_user(&setopt, argp, sizeof(unsigned int)))
  374. return -EFAULT;
  375. if (setopt & WDIOS_DISABLECARD) {
  376. if (p->enabled)
  377. return -EINVAL;
  378. cpwd_stoptimer(p, index);
  379. } else if (setopt & WDIOS_ENABLECARD) {
  380. cpwd_starttimer(p, index);
  381. } else {
  382. return -EINVAL;
  383. }
  384. break;
  385. /* Solaris-compatible IOCTLs */
  386. case WIOCGSTAT:
  387. setopt = cpwd_getstatus(p, index);
  388. if (copy_to_user(argp, &setopt, sizeof(unsigned int)))
  389. return -EFAULT;
  390. break;
  391. case WIOCSTART:
  392. cpwd_starttimer(p, index);
  393. break;
  394. case WIOCSTOP:
  395. if (p->enabled)
  396. return -EINVAL;
  397. cpwd_stoptimer(p, index);
  398. break;
  399. default:
  400. return -EINVAL;
  401. }
  402. return 0;
  403. }
  404. static long cpwd_compat_ioctl(struct file *file, unsigned int cmd,
  405. unsigned long arg)
  406. {
  407. int rval = -ENOIOCTLCMD;
  408. switch (cmd) {
  409. /* solaris ioctls are specific to this driver */
  410. case WIOCSTART:
  411. case WIOCSTOP:
  412. case WIOCGSTAT:
  413. lock_kernel();
  414. rval = cpwd_ioctl(file, cmd, arg);
  415. unlock_kernel();
  416. break;
  417. /* everything else is handled by the generic compat layer */
  418. default:
  419. break;
  420. }
  421. return rval;
  422. }
  423. static ssize_t cpwd_write(struct file *file, const char __user *buf,
  424. size_t count, loff_t *ppos)
  425. {
  426. struct inode *inode = file->f_path.dentry->d_inode;
  427. struct cpwd *p = cpwd_device;
  428. int index = iminor(inode);
  429. if (count) {
  430. cpwd_pingtimer(p, index);
  431. return 1;
  432. }
  433. return 0;
  434. }
  435. static ssize_t cpwd_read(struct file *file, char __user *buffer,
  436. size_t count, loff_t *ppos)
  437. {
  438. return -EINVAL;
  439. }
  440. static const struct file_operations cpwd_fops = {
  441. .owner = THIS_MODULE,
  442. .unlocked_ioctl = cpwd_ioctl,
  443. .compat_ioctl = cpwd_compat_ioctl,
  444. .open = cpwd_open,
  445. .write = cpwd_write,
  446. .read = cpwd_read,
  447. .release = cpwd_release,
  448. };
  449. static int __devinit cpwd_probe(struct of_device *op,
  450. const struct of_device_id *match)
  451. {
  452. struct device_node *options;
  453. const char *str_prop;
  454. const void *prop_val;
  455. int i, err = -EINVAL;
  456. struct cpwd *p;
  457. if (cpwd_device)
  458. return -EINVAL;
  459. p = kzalloc(sizeof(*p), GFP_KERNEL);
  460. err = -ENOMEM;
  461. if (!p) {
  462. printk(KERN_ERR PFX "Unable to allocate struct cpwd.\n");
  463. goto out;
  464. }
  465. p->irq = op->irqs[0];
  466. spin_lock_init(&p->lock);
  467. p->regs = of_ioremap(&op->resource[0], 0,
  468. 4 * WD_TIMER_REGSZ, DRIVER_NAME);
  469. if (!p->regs) {
  470. printk(KERN_ERR PFX "Unable to map registers.\n");
  471. goto out_free;
  472. }
  473. options = of_find_node_by_path("/options");
  474. err = -ENODEV;
  475. if (!options) {
  476. printk(KERN_ERR PFX "Unable to find /options node.\n");
  477. goto out_iounmap;
  478. }
  479. prop_val = of_get_property(options, "watchdog-enable?", NULL);
  480. p->enabled = (prop_val ? true : false);
  481. prop_val = of_get_property(options, "watchdog-reboot?", NULL);
  482. p->reboot = (prop_val ? true : false);
  483. str_prop = of_get_property(options, "watchdog-timeout", NULL);
  484. if (str_prop)
  485. p->timeout = simple_strtoul(str_prop, NULL, 10);
  486. /* CP1400s seem to have broken PLD implementations-- the
  487. * interrupt_mask register cannot be written, so no timer
  488. * interrupts can be masked within the PLD.
  489. */
  490. str_prop = of_get_property(op->node, "model", NULL);
  491. p->broken = (str_prop && !strcmp(str_prop, WD_BADMODEL));
  492. if (!p->enabled)
  493. cpwd_toggleintr(p, -1, WD_INTR_OFF);
  494. for (i = 0; i < WD_NUMDEVS; i++) {
  495. static const char *cpwd_names[] = { "RIC", "XIR", "POR" };
  496. static int *parms[] = { &wd0_timeout,
  497. &wd1_timeout,
  498. &wd2_timeout };
  499. struct miscdevice *mp = &p->devs[i].misc;
  500. mp->minor = WD0_MINOR + i;
  501. mp->name = cpwd_names[i];
  502. mp->fops = &cpwd_fops;
  503. p->devs[i].regs = p->regs + (i * WD_TIMER_REGSZ);
  504. p->devs[i].intr_mask = (WD0_INTR_MASK << i);
  505. p->devs[i].runstatus &= ~WD_STAT_BSTOP;
  506. p->devs[i].runstatus |= WD_STAT_INIT;
  507. p->devs[i].timeout = p->timeout;
  508. if (*parms[i])
  509. p->devs[i].timeout = *parms[i];
  510. err = misc_register(&p->devs[i].misc);
  511. if (err) {
  512. printk(KERN_ERR "Could not register misc device for "
  513. "dev %d\n", i);
  514. goto out_unregister;
  515. }
  516. }
  517. if (p->broken) {
  518. init_timer(&cpwd_timer);
  519. cpwd_timer.function = cpwd_brokentimer;
  520. cpwd_timer.data = (unsigned long) p;
  521. cpwd_timer.expires = WD_BTIMEOUT;
  522. printk(KERN_INFO PFX "PLD defect workaround enabled for "
  523. "model " WD_BADMODEL ".\n");
  524. }
  525. dev_set_drvdata(&op->dev, p);
  526. cpwd_device = p;
  527. err = 0;
  528. out:
  529. return err;
  530. out_unregister:
  531. for (i--; i >= 0; i--)
  532. misc_deregister(&p->devs[i].misc);
  533. out_iounmap:
  534. of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ);
  535. out_free:
  536. kfree(p);
  537. goto out;
  538. }
  539. static int __devexit cpwd_remove(struct of_device *op)
  540. {
  541. struct cpwd *p = dev_get_drvdata(&op->dev);
  542. int i;
  543. for (i = 0; i < 4; i++) {
  544. misc_deregister(&p->devs[i].misc);
  545. if (!p->enabled) {
  546. cpwd_stoptimer(p, i);
  547. if (p->devs[i].runstatus & WD_STAT_BSTOP)
  548. cpwd_resetbrokentimer(p, i);
  549. }
  550. }
  551. if (p->broken)
  552. del_timer_sync(&cpwd_timer);
  553. if (p->initialized)
  554. free_irq(p->irq, p);
  555. of_iounmap(&op->resource[0], p->regs, 4 * WD_TIMER_REGSZ);
  556. kfree(p);
  557. cpwd_device = NULL;
  558. return 0;
  559. }
  560. static const struct of_device_id cpwd_match[] = {
  561. {
  562. .name = "watchdog",
  563. },
  564. {},
  565. };
  566. MODULE_DEVICE_TABLE(of, cpwd_match);
  567. static struct of_platform_driver cpwd_driver = {
  568. .name = DRIVER_NAME,
  569. .match_table = cpwd_match,
  570. .probe = cpwd_probe,
  571. .remove = __devexit_p(cpwd_remove),
  572. };
  573. static int __init cpwd_init(void)
  574. {
  575. return of_register_driver(&cpwd_driver, &of_bus_type);
  576. }
  577. static void __exit cpwd_exit(void)
  578. {
  579. of_unregister_driver(&cpwd_driver);
  580. }
  581. module_init(cpwd_init);
  582. module_exit(cpwd_exit);