Lines Matching +full:timer +full:- +full:watchdog
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Intel_SCU 0.2: An Intel SCU IOH Based Watchdog Device
5 * - AF82MP20 PCH
7 * Copyright (C) 2009-2010 Intel Corporation. All rights reserved.
17 #include <linux/watchdog.h>
35 #include <asm/intel-mid.h>
48 "Watchdog timer margin"
56 "Default Watchdog timer setting"
61 /* After watchdog device is closed, check force_boot. If:
62 * force_boot == 0, then force boot on next watchdog interrupt after close,
69 "the system immediately if the /dev/watchdog device is closed"
70 "A value of 0 means that when /dev/watchdog device is closed"
71 "the watchdog timer will be refreshed for one more interval"
73 "watchdog timer will reset the system."
92 pr_crit("System will reset when watchdog timer times out!\n"); in watchdog_fire()
99 (new_margin > MAX_TIME - timer_set)) { in check_timer_margin()
101 new_margin, MIN_TIME_CYCLE, MAX_TIME - timer_set); in check_timer_margin()
102 return -EINVAL; in check_timer_margin()
129 pr_err("Error setting SCU watchdog timer: %x\n", ipc_ret); in watchdog_set_ipc()
138 /* timer interrupt handler */
149 /* has the timer been started? If not, then this is spurious */ in watchdog_timer_interrupt()
155 /* temporarily disable the timer */ in watchdog_timer_interrupt()
158 /* set the timer to the threshold */ in watchdog_timer_interrupt()
162 /* allow the timer to run */ in watchdog_timer_interrupt()
171 /* read eoi register - clears interrupt */ in intel_scu_keepalive()
174 /* temporarily disable the timer */ in intel_scu_keepalive()
177 /* set the timer to the soft_threshold */ in intel_scu_keepalive()
181 /* allow the timer to run */ in intel_scu_keepalive()
202 timer_margin * watchdog_device.timer_tbl_ptr->freq_hz; in intel_scu_set_heartbeat()
204 (watchdog_device.timer_set - timer_margin) in intel_scu_set_heartbeat()
205 * watchdog_device.timer_tbl_ptr->freq_hz; in intel_scu_set_heartbeat()
207 pr_debug("set_heartbeat: timer freq is %d\n", in intel_scu_set_heartbeat()
208 watchdog_device.timer_tbl_ptr->freq_hz); in intel_scu_set_heartbeat()
218 /* watchdog timing come out right. */ in intel_scu_set_heartbeat()
224 /* temporarily disable the timer */ in intel_scu_set_heartbeat()
232 /* Make sure the watchdog timer is stopped */ in intel_scu_set_heartbeat()
245 /* Make sure timer is stopped */ in intel_scu_set_heartbeat()
249 /* Unable to set timer value */ in intel_scu_set_heartbeat()
250 pr_err("Unable to set timer\n"); in intel_scu_set_heartbeat()
251 return -ENODEV; in intel_scu_set_heartbeat()
254 /* set the timer to the soft threshold */ in intel_scu_set_heartbeat()
258 /* read count value before starting timer */ in intel_scu_set_heartbeat()
261 /* Start the timer */ in intel_scu_set_heartbeat()
277 * /dev/watchdog handling
283 /* Set flag to indicate that watchdog device is open */ in intel_scu_open()
285 return -EBUSY; in intel_scu_open()
289 return -EPERM; in intel_scu_open()
297 * This watchdog should not be closed, after the timer in intel_scu_release()
300 * immediate reset. If force_boot is not set, the watchdog in intel_scu_release()
301 * timer is refreshed for one more interval. At the end in intel_scu_release()
302 * of that interval, the watchdog timer will reset the system. in intel_scu_release()
307 return -ENOTTY; in intel_scu_release()
311 /* Just close, since timer has not been started */ in intel_scu_release()
312 pr_debug("closed, without starting timer\n"); in intel_scu_release()
316 pr_crit("Unexpected close of /dev/watchdog!\n"); in intel_scu_release()
318 /* Since the timer was started, prevent future reopens */ in intel_scu_release()
321 /* Refresh the timer for one more interval */ in intel_scu_release()
338 /* Watchdog already started, keep it alive */ in intel_scu_write()
341 /* Start watchdog with timer value set by init */ in intel_scu_write()
361 .identity = "Intel_SCU IOH Watchdog" /* len < 32 */ in intel_scu_ioctl()
368 sizeof(ident)) ? -EFAULT : 0; in intel_scu_ioctl()
378 return -EFAULT; in intel_scu_ioctl()
381 return -EINVAL; in intel_scu_ioctl()
384 return -EINVAL; in intel_scu_ioctl()
390 return -ENOTTY; in intel_scu_ioctl()
402 /* Turn off the watchdog timer. */ in intel_scu_notify_sys()
426 * We don't really need to check this as the SFI timer get will fail in intel_scu_watchdog_init()
429 * If it isn't an intel MID device then it doesn't have this watchdog in intel_scu_watchdog_init()
432 return -ENODEV; in intel_scu_watchdog_init()
438 (timer_set > MAX_TIME - MIN_TIME_CYCLE)) { in intel_scu_watchdog_init()
440 timer_set, MIN_TIME_CYCLE, MAX_TIME - MIN_TIME_CYCLE); in intel_scu_watchdog_init()
441 return -EINVAL; in intel_scu_watchdog_init()
446 return -EINVAL; in intel_scu_watchdog_init()
448 watchdog_device.timer_tbl_ptr = sfi_get_mtmr(sfi_mtimer_num-1); in intel_scu_watchdog_init()
451 pr_debug("timer is not available\n"); in intel_scu_watchdog_init()
452 return -ENODEV; in intel_scu_watchdog_init()
454 /* make sure the timer exists */ in intel_scu_watchdog_init()
455 if (watchdog_device.timer_tbl_ptr->phys_addr == 0) { in intel_scu_watchdog_init()
456 pr_debug("timer %d does not have valid physical memory\n", in intel_scu_watchdog_init()
458 return -ENODEV; in intel_scu_watchdog_init()
461 if (watchdog_device.timer_tbl_ptr->irq == 0) { in intel_scu_watchdog_init()
462 pr_debug("timer %d invalid irq\n", sfi_mtimer_num); in intel_scu_watchdog_init()
463 return -ENODEV; in intel_scu_watchdog_init()
466 tmp_addr = ioremap(watchdog_device.timer_tbl_ptr->phys_addr, in intel_scu_watchdog_init()
470 pr_debug("timer unable to ioremap\n"); in intel_scu_watchdog_init()
471 return -ENOMEM; in intel_scu_watchdog_init()
484 timer_margin * watchdog_device.timer_tbl_ptr->freq_hz; in intel_scu_watchdog_init()
486 (watchdog_device.timer_set - timer_margin) in intel_scu_watchdog_init()
487 * watchdog_device.timer_tbl_ptr->freq_hz; in intel_scu_watchdog_init()
500 watchdog_device.miscdev.name = "watchdog"; in intel_scu_watchdog_init()
510 ret = request_irq((unsigned int)watchdog_device.timer_tbl_ptr->irq, in intel_scu_watchdog_init()
512 IRQF_SHARED, "watchdog", in intel_scu_watchdog_init()
518 /* Make sure timer is disabled before returning */ in intel_scu_watchdog_init()