octeon-wdt-main.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Octeon Watchdog driver
  4. *
  5. * Copyright (C) 2007-2017 Cavium, Inc.
  6. *
  7. * Converted to use WATCHDOG_CORE by Aaro Koskinen <aaro.koskinen@iki.fi>.
  8. *
  9. * Some parts derived from wdt.c
  10. *
  11. * (c) Copyright 1996-1997 Alan Cox <alan@lxorguk.ukuu.org.uk>,
  12. * All Rights Reserved.
  13. *
  14. * Neither Alan Cox nor CymruNet Ltd. admit liability nor provide
  15. * warranty for any of this software. This material is provided
  16. * "AS-IS" and at no charge.
  17. *
  18. * (c) Copyright 1995 Alan Cox <alan@lxorguk.ukuu.org.uk>
  19. *
  20. * The OCTEON watchdog has a maximum timeout of 2^32 * io_clock.
  21. * For most systems this is less than 10 seconds, so to allow for
  22. * software to request longer watchdog heartbeats, we maintain software
  23. * counters to count multiples of the base rate. If the system locks
  24. * up in such a manner that we can not run the software counters, the
  25. * only result is a watchdog reset sooner than was requested. But
  26. * that is OK, because in this case userspace would likely not be able
  27. * to do anything anyhow.
  28. *
  29. * The hardware watchdog interval we call the period. The OCTEON
  30. * watchdog goes through several stages, after the first period an
  31. * irq is asserted, then if it is not reset, after the next period NMI
  32. * is asserted, then after an additional period a chip wide soft reset.
  33. * So for the software counters, we reset watchdog after each period
  34. * and decrement the counter. But for the last two periods we need to
  35. * let the watchdog progress to the NMI stage so we disable the irq
  36. * and let it proceed. Once in the NMI, we print the register state
  37. * to the serial port and then wait for the reset.
  38. *
  39. * A watchdog is maintained for each CPU in the system, that way if
  40. * one CPU suffers a lockup, we also get a register dump and reset.
  41. * The userspace ping resets the watchdog on all CPUs.
  42. *
  43. * Before userspace opens the watchdog device, we still run the
  44. * watchdogs to catch any lockups that may be kernel related.
  45. *
  46. */
  47. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  48. #include <linux/interrupt.h>
  49. #include <linux/watchdog.h>
  50. #include <linux/cpumask.h>
  51. #include <linux/module.h>
  52. #include <linux/delay.h>
  53. #include <linux/cpu.h>
  54. #include <linux/irq.h>
  55. #include <asm/mipsregs.h>
  56. #include <asm/uasm.h>
  57. #include <asm/octeon/octeon.h>
  58. #include <asm/octeon/cvmx-boot-vector.h>
  59. #include <asm/octeon/cvmx-ciu2-defs.h>
  60. #include <asm/octeon/cvmx-rst-defs.h>
  61. /* Watchdog interrupt major block number (8 MSBs of intsn) */
  62. #define WD_BLOCK_NUMBER 0x01
  63. static int divisor;
  64. /* The count needed to achieve timeout_sec. */
  65. static unsigned int timeout_cnt;
  66. /* The maximum period supported. */
  67. static unsigned int max_timeout_sec;
  68. /* The current period. */
  69. static unsigned int timeout_sec;
  70. /* Set to non-zero when userspace countdown mode active */
  71. static bool do_countdown;
  72. static unsigned int countdown_reset;
  73. static unsigned int per_cpu_countdown[NR_CPUS];
  74. static cpumask_t irq_enabled_cpus;
  75. #define WD_TIMO 60 /* Default heartbeat = 60 seconds */
  76. #define CVMX_GSERX_SCRATCH(offset) (CVMX_ADD_IO_SEG(0x0001180090000020ull) + ((offset) & 15) * 0x1000000ull)
  77. static int heartbeat = WD_TIMO;
  78. module_param(heartbeat, int, 0444);
  79. MODULE_PARM_DESC(heartbeat,
  80. "Watchdog heartbeat in seconds. (0 < heartbeat, default="
  81. __MODULE_STRING(WD_TIMO) ")");
  82. static bool nowayout = WATCHDOG_NOWAYOUT;
  83. module_param(nowayout, bool, 0444);
  84. MODULE_PARM_DESC(nowayout,
  85. "Watchdog cannot be stopped once started (default="
  86. __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
  87. static int disable;
  88. module_param(disable, int, 0444);
  89. MODULE_PARM_DESC(disable,
  90. "Disable the watchdog entirely (default=0)");
  91. static struct cvmx_boot_vector_element *octeon_wdt_bootvector;
  92. void octeon_wdt_nmi_stage2(void);
  93. static int cpu2core(int cpu)
  94. {
  95. #ifdef CONFIG_SMP
  96. return cpu_logical_map(cpu) & 0x3f;
  97. #else
  98. return cvmx_get_core_num();
  99. #endif
  100. }
  101. /**
  102. * Poke the watchdog when an interrupt is received
  103. *
  104. * @cpl:
  105. * @dev_id:
  106. *
  107. * Returns
  108. */
  109. static irqreturn_t octeon_wdt_poke_irq(int cpl, void *dev_id)
  110. {
  111. int cpu = raw_smp_processor_id();
  112. unsigned int core = cpu2core(cpu);
  113. int node = cpu_to_node(cpu);
  114. if (do_countdown) {
  115. if (per_cpu_countdown[cpu] > 0) {
  116. /* We're alive, poke the watchdog */
  117. cvmx_write_csr_node(node, CVMX_CIU_PP_POKEX(core), 1);
  118. per_cpu_countdown[cpu]--;
  119. } else {
  120. /* Bad news, you are about to reboot. */
  121. disable_irq_nosync(cpl);
  122. cpumask_clear_cpu(cpu, &irq_enabled_cpus);
  123. }
  124. } else {
  125. /* Not open, just ping away... */
  126. cvmx_write_csr_node(node, CVMX_CIU_PP_POKEX(core), 1);
  127. }
  128. return IRQ_HANDLED;
  129. }
  130. /* From setup.c */
  131. extern int prom_putchar(char c);
  132. /**
  133. * Write a string to the uart
  134. *
  135. * @str: String to write
  136. */
  137. static void octeon_wdt_write_string(const char *str)
  138. {
  139. /* Just loop writing one byte at a time */
  140. while (*str)
  141. prom_putchar(*str++);
  142. }
  143. /**
  144. * Write a hex number out of the uart
  145. *
  146. * @value: Number to display
  147. * @digits: Number of digits to print (1 to 16)
  148. */
  149. static void octeon_wdt_write_hex(u64 value, int digits)
  150. {
  151. int d;
  152. int v;
  153. for (d = 0; d < digits; d++) {
  154. v = (value >> ((digits - d - 1) * 4)) & 0xf;
  155. if (v >= 10)
  156. prom_putchar('a' + v - 10);
  157. else
  158. prom_putchar('0' + v);
  159. }
  160. }
  161. static const char reg_name[][3] = {
  162. "$0", "at", "v0", "v1", "a0", "a1", "a2", "a3",
  163. "a4", "a5", "a6", "a7", "t0", "t1", "t2", "t3",
  164. "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7",
  165. "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra"
  166. };
  167. /**
  168. * NMI stage 3 handler. NMIs are handled in the following manner:
  169. * 1) The first NMI handler enables CVMSEG and transfers from
  170. * the bootbus region into normal memory. It is careful to not
  171. * destroy any registers.
  172. * 2) The second stage handler uses CVMSEG to save the registers
  173. * and create a stack for C code. It then calls the third level
  174. * handler with one argument, a pointer to the register values.
  175. * 3) The third, and final, level handler is the following C
  176. * function that prints out some useful infomration.
  177. *
  178. * @reg: Pointer to register state before the NMI
  179. */
  180. void octeon_wdt_nmi_stage3(u64 reg[32])
  181. {
  182. u64 i;
  183. unsigned int coreid = cvmx_get_core_num();
  184. /*
  185. * Save status and cause early to get them before any changes
  186. * might happen.
  187. */
  188. u64 cp0_cause = read_c0_cause();
  189. u64 cp0_status = read_c0_status();
  190. u64 cp0_error_epc = read_c0_errorepc();
  191. u64 cp0_epc = read_c0_epc();
  192. /* Delay so output from all cores output is not jumbled together. */
  193. udelay(85000 * coreid);
  194. octeon_wdt_write_string("\r\n*** NMI Watchdog interrupt on Core 0x");
  195. octeon_wdt_write_hex(coreid, 2);
  196. octeon_wdt_write_string(" ***\r\n");
  197. for (i = 0; i < 32; i++) {
  198. octeon_wdt_write_string("\t");
  199. octeon_wdt_write_string(reg_name[i]);
  200. octeon_wdt_write_string("\t0x");
  201. octeon_wdt_write_hex(reg[i], 16);
  202. if (i & 1)
  203. octeon_wdt_write_string("\r\n");
  204. }
  205. octeon_wdt_write_string("\terr_epc\t0x");
  206. octeon_wdt_write_hex(cp0_error_epc, 16);
  207. octeon_wdt_write_string("\tepc\t0x");
  208. octeon_wdt_write_hex(cp0_epc, 16);
  209. octeon_wdt_write_string("\r\n");
  210. octeon_wdt_write_string("\tstatus\t0x");
  211. octeon_wdt_write_hex(cp0_status, 16);
  212. octeon_wdt_write_string("\tcause\t0x");
  213. octeon_wdt_write_hex(cp0_cause, 16);
  214. octeon_wdt_write_string("\r\n");
  215. /* The CIU register is different for each Octeon model. */
  216. if (OCTEON_IS_MODEL(OCTEON_CN68XX)) {
  217. octeon_wdt_write_string("\tsrc_wd\t0x");
  218. octeon_wdt_write_hex(cvmx_read_csr(CVMX_CIU2_SRC_PPX_IP2_WDOG(coreid)), 16);
  219. octeon_wdt_write_string("\ten_wd\t0x");
  220. octeon_wdt_write_hex(cvmx_read_csr(CVMX_CIU2_EN_PPX_IP2_WDOG(coreid)), 16);
  221. octeon_wdt_write_string("\r\n");
  222. octeon_wdt_write_string("\tsrc_rml\t0x");
  223. octeon_wdt_write_hex(cvmx_read_csr(CVMX_CIU2_SRC_PPX_IP2_RML(coreid)), 16);
  224. octeon_wdt_write_string("\ten_rml\t0x");
  225. octeon_wdt_write_hex(cvmx_read_csr(CVMX_CIU2_EN_PPX_IP2_RML(coreid)), 16);
  226. octeon_wdt_write_string("\r\n");
  227. octeon_wdt_write_string("\tsum\t0x");
  228. octeon_wdt_write_hex(cvmx_read_csr(CVMX_CIU2_SUM_PPX_IP2(coreid)), 16);
  229. octeon_wdt_write_string("\r\n");
  230. } else if (!octeon_has_feature(OCTEON_FEATURE_CIU3)) {
  231. octeon_wdt_write_string("\tsum0\t0x");
  232. octeon_wdt_write_hex(cvmx_read_csr(CVMX_CIU_INTX_SUM0(coreid * 2)), 16);
  233. octeon_wdt_write_string("\ten0\t0x");
  234. octeon_wdt_write_hex(cvmx_read_csr(CVMX_CIU_INTX_EN0(coreid * 2)), 16);
  235. octeon_wdt_write_string("\r\n");
  236. }
  237. octeon_wdt_write_string("*** Chip soft reset soon ***\r\n");
  238. /*
  239. * G-30204: We must trigger a soft reset before watchdog
  240. * does an incomplete job of doing it.
  241. */
  242. if (OCTEON_IS_OCTEON3() && !OCTEON_IS_MODEL(OCTEON_CN70XX)) {
  243. u64 scr;
  244. unsigned int node = cvmx_get_node_num();
  245. unsigned int lcore = cvmx_get_local_core_num();
  246. union cvmx_ciu_wdogx ciu_wdog;
  247. /*
  248. * Wait for other cores to print out information, but
  249. * not too long. Do the soft reset before watchdog
  250. * can trigger it.
  251. */
  252. do {
  253. ciu_wdog.u64 = cvmx_read_csr_node(node, CVMX_CIU_WDOGX(lcore));
  254. } while (ciu_wdog.s.cnt > 0x10000);
  255. scr = cvmx_read_csr_node(0, CVMX_GSERX_SCRATCH(0));
  256. scr |= 1 << 11; /* Indicate watchdog in bit 11 */
  257. cvmx_write_csr_node(0, CVMX_GSERX_SCRATCH(0), scr);
  258. cvmx_write_csr_node(0, CVMX_RST_SOFT_RST, 1);
  259. }
  260. }
  261. static int octeon_wdt_cpu_to_irq(int cpu)
  262. {
  263. unsigned int coreid;
  264. int node;
  265. int irq;
  266. coreid = cpu2core(cpu);
  267. node = cpu_to_node(cpu);
  268. if (octeon_has_feature(OCTEON_FEATURE_CIU3)) {
  269. struct irq_domain *domain;
  270. int hwirq;
  271. domain = octeon_irq_get_block_domain(node,
  272. WD_BLOCK_NUMBER);
  273. hwirq = WD_BLOCK_NUMBER << 12 | 0x200 | coreid;
  274. irq = irq_find_mapping(domain, hwirq);
  275. } else {
  276. irq = OCTEON_IRQ_WDOG0 + coreid;
  277. }
  278. return irq;
  279. }
  280. static int octeon_wdt_cpu_pre_down(unsigned int cpu)
  281. {
  282. unsigned int core;
  283. int node;
  284. union cvmx_ciu_wdogx ciu_wdog;
  285. core = cpu2core(cpu);
  286. node = cpu_to_node(cpu);
  287. /* Poke the watchdog to clear out its state */
  288. cvmx_write_csr_node(node, CVMX_CIU_PP_POKEX(core), 1);
  289. /* Disable the hardware. */
  290. ciu_wdog.u64 = 0;
  291. cvmx_write_csr_node(node, CVMX_CIU_WDOGX(core), ciu_wdog.u64);
  292. free_irq(octeon_wdt_cpu_to_irq(cpu), octeon_wdt_poke_irq);
  293. return 0;
  294. }
  295. static int octeon_wdt_cpu_online(unsigned int cpu)
  296. {
  297. unsigned int core;
  298. unsigned int irq;
  299. union cvmx_ciu_wdogx ciu_wdog;
  300. int node;
  301. struct irq_domain *domain;
  302. int hwirq;
  303. core = cpu2core(cpu);
  304. node = cpu_to_node(cpu);
  305. octeon_wdt_bootvector[core].target_ptr = (u64)octeon_wdt_nmi_stage2;
  306. /* Disable it before doing anything with the interrupts. */
  307. ciu_wdog.u64 = 0;
  308. cvmx_write_csr_node(node, CVMX_CIU_WDOGX(core), ciu_wdog.u64);
  309. per_cpu_countdown[cpu] = countdown_reset;
  310. if (octeon_has_feature(OCTEON_FEATURE_CIU3)) {
  311. /* Must get the domain for the watchdog block */
  312. domain = octeon_irq_get_block_domain(node, WD_BLOCK_NUMBER);
  313. /* Get a irq for the wd intsn (hardware interrupt) */
  314. hwirq = WD_BLOCK_NUMBER << 12 | 0x200 | core;
  315. irq = irq_create_mapping(domain, hwirq);
  316. irqd_set_trigger_type(irq_get_irq_data(irq),
  317. IRQ_TYPE_EDGE_RISING);
  318. } else
  319. irq = OCTEON_IRQ_WDOG0 + core;
  320. if (request_irq(irq, octeon_wdt_poke_irq,
  321. IRQF_NO_THREAD, "octeon_wdt", octeon_wdt_poke_irq))
  322. panic("octeon_wdt: Couldn't obtain irq %d", irq);
  323. /* Must set the irq affinity here */
  324. if (octeon_has_feature(OCTEON_FEATURE_CIU3)) {
  325. cpumask_t mask;
  326. cpumask_clear(&mask);
  327. cpumask_set_cpu(cpu, &mask);
  328. irq_set_affinity(irq, &mask);
  329. }
  330. cpumask_set_cpu(cpu, &irq_enabled_cpus);
  331. /* Poke the watchdog to clear out its state */
  332. cvmx_write_csr_node(node, CVMX_CIU_PP_POKEX(core), 1);
  333. /* Finally enable the watchdog now that all handlers are installed */
  334. ciu_wdog.u64 = 0;
  335. ciu_wdog.s.len = timeout_cnt;
  336. ciu_wdog.s.mode = 3; /* 3 = Interrupt + NMI + Soft-Reset */
  337. cvmx_write_csr_node(node, CVMX_CIU_WDOGX(core), ciu_wdog.u64);
  338. return 0;
  339. }
  340. static int octeon_wdt_ping(struct watchdog_device __always_unused *wdog)
  341. {
  342. int cpu;
  343. int coreid;
  344. int node;
  345. if (disable)
  346. return 0;
  347. for_each_online_cpu(cpu) {
  348. coreid = cpu2core(cpu);
  349. node = cpu_to_node(cpu);
  350. cvmx_write_csr_node(node, CVMX_CIU_PP_POKEX(coreid), 1);
  351. per_cpu_countdown[cpu] = countdown_reset;
  352. if ((countdown_reset || !do_countdown) &&
  353. !cpumask_test_cpu(cpu, &irq_enabled_cpus)) {
  354. /* We have to enable the irq */
  355. enable_irq(octeon_wdt_cpu_to_irq(cpu));
  356. cpumask_set_cpu(cpu, &irq_enabled_cpus);
  357. }
  358. }
  359. return 0;
  360. }
  361. static void octeon_wdt_calc_parameters(int t)
  362. {
  363. unsigned int periods;
  364. timeout_sec = max_timeout_sec;
  365. /*
  366. * Find the largest interrupt period, that can evenly divide
  367. * the requested heartbeat time.
  368. */
  369. while ((t % timeout_sec) != 0)
  370. timeout_sec--;
  371. periods = t / timeout_sec;
  372. /*
  373. * The last two periods are after the irq is disabled, and
  374. * then to the nmi, so we subtract them off.
  375. */
  376. countdown_reset = periods > 2 ? periods - 2 : 0;
  377. heartbeat = t;
  378. timeout_cnt = ((octeon_get_io_clock_rate() / divisor) * timeout_sec) >> 8;
  379. }
  380. static int octeon_wdt_set_timeout(struct watchdog_device *wdog,
  381. unsigned int t)
  382. {
  383. int cpu;
  384. int coreid;
  385. union cvmx_ciu_wdogx ciu_wdog;
  386. int node;
  387. if (t <= 0)
  388. return -1;
  389. octeon_wdt_calc_parameters(t);
  390. if (disable)
  391. return 0;
  392. for_each_online_cpu(cpu) {
  393. coreid = cpu2core(cpu);
  394. node = cpu_to_node(cpu);
  395. cvmx_write_csr_node(node, CVMX_CIU_PP_POKEX(coreid), 1);
  396. ciu_wdog.u64 = 0;
  397. ciu_wdog.s.len = timeout_cnt;
  398. ciu_wdog.s.mode = 3; /* 3 = Interrupt + NMI + Soft-Reset */
  399. cvmx_write_csr_node(node, CVMX_CIU_WDOGX(coreid), ciu_wdog.u64);
  400. cvmx_write_csr_node(node, CVMX_CIU_PP_POKEX(coreid), 1);
  401. }
  402. octeon_wdt_ping(wdog); /* Get the irqs back on. */
  403. return 0;
  404. }
  405. static int octeon_wdt_start(struct watchdog_device *wdog)
  406. {
  407. octeon_wdt_ping(wdog);
  408. do_countdown = 1;
  409. return 0;
  410. }
  411. static int octeon_wdt_stop(struct watchdog_device *wdog)
  412. {
  413. do_countdown = 0;
  414. octeon_wdt_ping(wdog);
  415. return 0;
  416. }
  417. static const struct watchdog_info octeon_wdt_info = {
  418. .options = WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE | WDIOF_KEEPALIVEPING,
  419. .identity = "OCTEON",
  420. };
  421. static const struct watchdog_ops octeon_wdt_ops = {
  422. .owner = THIS_MODULE,
  423. .start = octeon_wdt_start,
  424. .stop = octeon_wdt_stop,
  425. .ping = octeon_wdt_ping,
  426. .set_timeout = octeon_wdt_set_timeout,
  427. };
  428. static struct watchdog_device octeon_wdt = {
  429. .info = &octeon_wdt_info,
  430. .ops = &octeon_wdt_ops,
  431. };
  432. static enum cpuhp_state octeon_wdt_online;
  433. /**
  434. * Module/ driver initialization.
  435. *
  436. * Returns Zero on success
  437. */
  438. static int __init octeon_wdt_init(void)
  439. {
  440. int ret;
  441. octeon_wdt_bootvector = cvmx_boot_vector_get();
  442. if (!octeon_wdt_bootvector) {
  443. pr_err("Error: Cannot allocate boot vector.\n");
  444. return -ENOMEM;
  445. }
  446. if (OCTEON_IS_MODEL(OCTEON_CN68XX))
  447. divisor = 0x200;
  448. else if (OCTEON_IS_MODEL(OCTEON_CN78XX))
  449. divisor = 0x400;
  450. else
  451. divisor = 0x100;
  452. /*
  453. * Watchdog time expiration length = The 16 bits of LEN
  454. * represent the most significant bits of a 24 bit decrementer
  455. * that decrements every divisor cycle.
  456. *
  457. * Try for a timeout of 5 sec, if that fails a smaller number
  458. * of even seconds,
  459. */
  460. max_timeout_sec = 6;
  461. do {
  462. max_timeout_sec--;
  463. timeout_cnt = ((octeon_get_io_clock_rate() / divisor) * max_timeout_sec) >> 8;
  464. } while (timeout_cnt > 65535);
  465. BUG_ON(timeout_cnt == 0);
  466. octeon_wdt_calc_parameters(heartbeat);
  467. pr_info("Initial granularity %d Sec\n", timeout_sec);
  468. octeon_wdt.timeout = timeout_sec;
  469. octeon_wdt.max_timeout = UINT_MAX;
  470. watchdog_set_nowayout(&octeon_wdt, nowayout);
  471. ret = watchdog_register_device(&octeon_wdt);
  472. if (ret) {
  473. pr_err("watchdog_register_device() failed: %d\n", ret);
  474. return ret;
  475. }
  476. if (disable) {
  477. pr_notice("disabled\n");
  478. return 0;
  479. }
  480. cpumask_clear(&irq_enabled_cpus);
  481. ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "watchdog/octeon:online",
  482. octeon_wdt_cpu_online, octeon_wdt_cpu_pre_down);
  483. if (ret < 0)
  484. goto err;
  485. octeon_wdt_online = ret;
  486. return 0;
  487. err:
  488. cvmx_write_csr(CVMX_MIO_BOOT_LOC_CFGX(0), 0);
  489. watchdog_unregister_device(&octeon_wdt);
  490. return ret;
  491. }
  492. /**
  493. * Module / driver shutdown
  494. */
  495. static void __exit octeon_wdt_cleanup(void)
  496. {
  497. watchdog_unregister_device(&octeon_wdt);
  498. if (disable)
  499. return;
  500. cpuhp_remove_state(octeon_wdt_online);
  501. /*
  502. * Disable the boot-bus memory, the code it points to is soon
  503. * to go missing.
  504. */
  505. cvmx_write_csr(CVMX_MIO_BOOT_LOC_CFGX(0), 0);
  506. }
  507. MODULE_LICENSE("GPL");
  508. MODULE_AUTHOR("Cavium Inc. <support@cavium.com>");
  509. MODULE_DESCRIPTION("Cavium Inc. OCTEON Watchdog driver.");
  510. module_init(octeon_wdt_init);
  511. module_exit(octeon_wdt_cleanup);