cpwd.c 16 KB

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