octeon-wdt-main.c 16 KB

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