cpwd.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  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. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  17. #include <linux/kernel.h>
  18. #include <linux/module.h>
  19. #include <linux/fs.h>
  20. #include <linux/errno.h>
  21. #include <linux/major.h>
  22. #include <linux/miscdevice.h>
  23. #include <linux/interrupt.h>
  24. #include <linux/ioport.h>
  25. #include <linux/timer.h>
  26. #include <linux/slab.h>
  27. #include <linux/mutex.h>
  28. #include <linux/io.h>
  29. #include <linux/of.h>
  30. #include <linux/of_device.h>
  31. #include <linux/uaccess.h>
  32. #include <asm/irq.h>
  33. #include <asm/watchdog.h>
  34. #define DRIVER_NAME "cpwd"
  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 DEFINE_MUTEX(cpwd_mutex);
  77. static struct cpwd *cpwd_device;
  78. /* Sun uses Altera PLD EPF8820ATC144-4
  79. * providing three hardware watchdogs:
  80. *
  81. * 1) RIC - sends an interrupt when triggered
  82. * 2) XIR - asserts XIR_B_RESET when triggered, resets CPU
  83. * 3) POR - asserts POR_B_RESET when triggered, resets CPU, backplane, board
  84. *
  85. *** Timer register block definition (struct wd_timer_regblk)
  86. *
  87. * dcntr and limit registers (halfword access):
  88. * -------------------
  89. * | 15 | ...| 1 | 0 |
  90. * -------------------
  91. * |- counter val -|
  92. * -------------------
  93. * dcntr - Current 16-bit downcounter value.
  94. * When downcounter reaches '0' watchdog expires.
  95. * Reading this register resets downcounter with
  96. * 'limit' value.
  97. * limit - 16-bit countdown value in 1/10th second increments.
  98. * Writing this register begins countdown with input value.
  99. * Reading from this register does not affect counter.
  100. * NOTES: After watchdog reset, dcntr and limit contain '1'
  101. *
  102. * status register (byte access):
  103. * ---------------------------
  104. * | 7 | ... | 2 | 1 | 0 |
  105. * --------------+------------
  106. * |- UNUSED -| EXP | RUN |
  107. * ---------------------------
  108. * status- Bit 0 - Watchdog is running
  109. * Bit 1 - Watchdog has expired
  110. *
  111. *** PLD register block definition (struct wd_pld_regblk)
  112. *
  113. * intr_mask register (byte access):
  114. * ---------------------------------
  115. * | 7 | ... | 3 | 2 | 1 | 0 |
  116. * +-------------+------------------
  117. * |- UNUSED -| WD3 | WD2 | WD1 |
  118. * ---------------------------------
  119. * WD3 - 1 == Interrupt disabled for watchdog 3
  120. * WD2 - 1 == Interrupt disabled for watchdog 2
  121. * WD1 - 1 == Interrupt disabled for watchdog 1
  122. *
  123. * pld_status register (byte access):
  124. * UNKNOWN, MAGICAL MYSTERY REGISTER
  125. *
  126. */
  127. #define WD_TIMER_REGSZ 16
  128. #define WD0_OFF 0
  129. #define WD1_OFF (WD_TIMER_REGSZ * 1)
  130. #define WD2_OFF (WD_TIMER_REGSZ * 2)
  131. #define PLD_OFF (WD_TIMER_REGSZ * 3)
  132. #define WD_DCNTR 0x00
  133. #define WD_LIMIT 0x04
  134. #define WD_STATUS 0x08
  135. #define PLD_IMASK (PLD_OFF + 0x00)
  136. #define PLD_STATUS (PLD_OFF + 0x04)
  137. static struct timer_list cpwd_timer;
  138. static int wd0_timeout;
  139. static int wd1_timeout;
  140. static int wd2_timeout;
  141. module_param(wd0_timeout, int, 0);
  142. MODULE_PARM_DESC(wd0_timeout, "Default watchdog0 timeout in 1/10secs");
  143. module_param(wd1_timeout, int, 0);
  144. MODULE_PARM_DESC(wd1_timeout, "Default watchdog1 timeout in 1/10secs");
  145. module_param(wd2_timeout, int, 0);
  146. MODULE_PARM_DESC(wd2_timeout, "Default watchdog2 timeout in 1/10secs");
  147. MODULE_AUTHOR("Eric Brower <ebrower@usa.net>");
  148. MODULE_DESCRIPTION("Hardware watchdog driver for Sun Microsystems CP1400/1500");
  149. MODULE_LICENSE("GPL");
  150. MODULE_SUPPORTED_DEVICE("watchdog");
  151. static void cpwd_writew(u16 val, void __iomem *addr)
  152. {
  153. writew(cpu_to_le16(val), addr);
  154. }
  155. static u16 cpwd_readw(void __iomem *addr)
  156. {
  157. u16 val = readw(addr);
  158. return le16_to_cpu(val);
  159. }
  160. static void cpwd_writeb(u8 val, void __iomem *addr)
  161. {
  162. writeb(val, addr);
  163. }
  164. static u8 cpwd_readb(void __iomem *addr)
  165. {
  166. return readb(addr);
  167. }
  168. /* Enable or disable watchdog interrupts
  169. * Because of the CP1400 defect this should only be
  170. * called during initialzation or by wd_[start|stop]timer()
  171. *
  172. * index - sub-device index, or -1 for 'all'
  173. * enable - non-zero to enable interrupts, zero to disable
  174. */
  175. static void cpwd_toggleintr(struct cpwd *p, int index, int enable)
  176. {
  177. unsigned char curregs = cpwd_readb(p->regs + PLD_IMASK);
  178. unsigned char setregs =
  179. (index == -1) ?
  180. (WD0_INTR_MASK | WD1_INTR_MASK | WD2_INTR_MASK) :
  181. (p->devs[index].intr_mask);
  182. if (enable == WD_INTR_ON)
  183. curregs &= ~setregs;
  184. else
  185. curregs |= setregs;
  186. cpwd_writeb(curregs, p->regs + PLD_IMASK);
  187. }
  188. /* Restarts timer with maximum limit value and
  189. * does not unset 'brokenstop' value.
  190. */
  191. static void cpwd_resetbrokentimer(struct cpwd *p, int index)
  192. {
  193. cpwd_toggleintr(p, index, WD_INTR_ON);
  194. cpwd_writew(WD_BLIMIT, p->devs[index].regs + WD_LIMIT);
  195. }
  196. /* Timer method called to reset stopped watchdogs--
  197. * because of the PLD bug on CP1400, we cannot mask
  198. * interrupts within the PLD so me must continually
  199. * reset the timers ad infinitum.
  200. */
  201. static void cpwd_brokentimer(unsigned long data)
  202. {
  203. struct cpwd *p = (struct cpwd *) data;
  204. int id, tripped = 0;
  205. /* kill a running timer instance, in case we
  206. * were called directly instead of by kernel timer
  207. */
  208. if (timer_pending(&cpwd_timer))
  209. del_timer(&cpwd_timer);
  210. for (id = 0; id < WD_NUMDEVS; id++) {
  211. if (p->devs[id].runstatus & WD_STAT_BSTOP) {
  212. ++tripped;
  213. cpwd_resetbrokentimer(p, id);
  214. }
  215. }
  216. if (tripped) {
  217. /* there is at least one timer brokenstopped-- reschedule */
  218. cpwd_timer.expires = WD_BTIMEOUT;
  219. add_timer(&cpwd_timer);
  220. }
  221. }
  222. /* Reset countdown timer with 'limit' value and continue countdown.
  223. * This will not start a stopped timer.
  224. */
  225. static void cpwd_pingtimer(struct cpwd *p, int index)
  226. {
  227. if (cpwd_readb(p->devs[index].regs + WD_STATUS) & WD_S_RUNNING)
  228. cpwd_readw(p->devs[index].regs + WD_DCNTR);
  229. }
  230. /* Stop a running watchdog timer-- the timer actually keeps
  231. * running, but the interrupt is masked so that no action is
  232. * taken upon expiration.
  233. */
  234. static void cpwd_stoptimer(struct cpwd *p, int index)
  235. {
  236. if (cpwd_readb(p->devs[index].regs + WD_STATUS) & WD_S_RUNNING) {
  237. cpwd_toggleintr(p, index, WD_INTR_OFF);
  238. if (p->broken) {
  239. p->devs[index].runstatus |= WD_STAT_BSTOP;
  240. cpwd_brokentimer((unsigned long) p);
  241. }
  242. }
  243. }
  244. /* Start a watchdog timer with the specified limit value
  245. * If the watchdog is running, it will be restarted with
  246. * the provided limit value.
  247. *
  248. * This function will enable interrupts on the specified
  249. * watchdog.
  250. */
  251. static void cpwd_starttimer(struct cpwd *p, int index)
  252. {
  253. if (p->broken)
  254. p->devs[index].runstatus &= ~WD_STAT_BSTOP;
  255. p->devs[index].runstatus &= ~WD_STAT_SVCD;
  256. cpwd_writew(p->devs[index].timeout, p->devs[index].regs + WD_LIMIT);
  257. cpwd_toggleintr(p, index, WD_INTR_ON);
  258. }
  259. static int cpwd_getstatus(struct cpwd *p, int index)
  260. {
  261. unsigned char stat = cpwd_readb(p->devs[index].regs + WD_STATUS);
  262. unsigned char intr = cpwd_readb(p->devs[index].regs + PLD_IMASK);
  263. unsigned char ret = WD_STOPPED;
  264. /* determine STOPPED */
  265. if (!stat)
  266. return ret;
  267. /* determine EXPIRED vs FREERUN vs RUNNING */
  268. else if (WD_S_EXPIRED & stat) {
  269. ret = WD_EXPIRED;
  270. } else if (WD_S_RUNNING & stat) {
  271. if (intr & p->devs[index].intr_mask) {
  272. ret = WD_FREERUN;
  273. } else {
  274. /* Fudge WD_EXPIRED status for defective CP1400--
  275. * IF timer is running
  276. * AND brokenstop is set
  277. * AND an interrupt has been serviced
  278. * we are WD_EXPIRED.
  279. *
  280. * IF timer is running
  281. * AND brokenstop is set
  282. * AND no interrupt has been serviced
  283. * we are WD_FREERUN.
  284. */
  285. if (p->broken &&
  286. (p->devs[index].runstatus & WD_STAT_BSTOP)) {
  287. if (p->devs[index].runstatus & WD_STAT_SVCD) {
  288. ret = WD_EXPIRED;
  289. } else {
  290. /* we could as well pretend
  291. * we are expired */
  292. ret = WD_FREERUN;
  293. }
  294. } else {
  295. ret = WD_RUNNING;
  296. }
  297. }
  298. }
  299. /* determine SERVICED */
  300. if (p->devs[index].runstatus & WD_STAT_SVCD)
  301. ret |= WD_SERVICED;
  302. return ret;
  303. }
  304. static irqreturn_t cpwd_interrupt(int irq, void *dev_id)
  305. {
  306. struct cpwd *p = dev_id;
  307. /* Only WD0 will interrupt-- others are NMI and we won't
  308. * see them here....
  309. */
  310. spin_lock_irq(&p->lock);
  311. cpwd_stoptimer(p, WD0_ID);
  312. p->devs[WD0_ID].runstatus |= WD_STAT_SVCD;
  313. spin_unlock_irq(&p->lock);
  314. return IRQ_HANDLED;
  315. }
  316. static int cpwd_open(struct inode *inode, struct file *f)
  317. {
  318. struct cpwd *p = cpwd_device;
  319. mutex_lock(&cpwd_mutex);
  320. switch (iminor(inode)) {
  321. case WD0_MINOR:
  322. case WD1_MINOR:
  323. case WD2_MINOR:
  324. break;
  325. default:
  326. mutex_unlock(&cpwd_mutex);
  327. return -ENODEV;
  328. }
  329. /* Register IRQ on first open of device */
  330. if (!p->initialized) {
  331. if (request_irq(p->irq, &cpwd_interrupt,
  332. IRQF_SHARED, DRIVER_NAME, p)) {
  333. pr_err("Cannot register IRQ %d\n", p->irq);
  334. mutex_unlock(&cpwd_mutex);
  335. return -EBUSY;
  336. }
  337. p->initialized = true;
  338. }
  339. mutex_unlock(&cpwd_mutex);
  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 const 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_inode(file);
  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. mutex_lock(&cpwd_mutex);
  414. rval = cpwd_ioctl(file, cmd, arg);
  415. mutex_unlock(&cpwd_mutex);
  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_inode(file);
  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. .llseek = no_llseek,
  449. };
  450. static int cpwd_probe(struct platform_device *op)
  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. pr_err("Unable to allocate struct cpwd\n");
  463. goto out;
  464. }
  465. p->irq = op->archdata.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. pr_err("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. pr_err("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->dev.of_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. pr_err("Could not register misc device for dev %d\n",
  513. 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. pr_info("PLD defect workaround enabled for model %s\n",
  523. WD_BADMODEL);
  524. }
  525. platform_set_drvdata(op, 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 cpwd_remove(struct platform_device *op)
  540. {
  541. struct cpwd *p = platform_get_drvdata(op);
  542. int i;
  543. for (i = 0; i < WD_NUMDEVS; 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 platform_driver cpwd_driver = {
  568. .driver = {
  569. .name = DRIVER_NAME,
  570. .of_match_table = cpwd_match,
  571. },
  572. .probe = cpwd_probe,
  573. .remove = cpwd_remove,
  574. };
  575. module_platform_driver(cpwd_driver);