Lines Matching refs:wdat
64 static int wdat_wdt_read(struct wdat_wdt *wdat, in wdat_wdt_read() argument
83 dev_dbg(&wdat->pdev->dev, "Read %#x from 0x%08llx\n", *value, in wdat_wdt_read()
89 static int wdat_wdt_write(struct wdat_wdt *wdat, in wdat_wdt_write() argument
108 dev_dbg(&wdat->pdev->dev, "Wrote %#x to 0x%08llx\n", value, in wdat_wdt_write()
114 static int wdat_wdt_run_action(struct wdat_wdt *wdat, unsigned int action, in wdat_wdt_run_action() argument
119 if (action >= ARRAY_SIZE(wdat->instructions)) in wdat_wdt_run_action()
122 if (!wdat->instructions[action]) in wdat_wdt_run_action()
125 dev_dbg(&wdat->pdev->dev, "Running action %#x\n", action); in wdat_wdt_run_action()
128 list_for_each_entry(instr, wdat->instructions[action], node) { in wdat_wdt_run_action()
144 ret = wdat_wdt_read(wdat, instr, &x); in wdat_wdt_run_action()
154 ret = wdat_wdt_read(wdat, instr, &x); in wdat_wdt_run_action()
167 ret = wdat_wdt_read(wdat, instr, &y); in wdat_wdt_run_action()
173 ret = wdat_wdt_write(wdat, instr, x); in wdat_wdt_run_action()
183 ret = wdat_wdt_read(wdat, instr, &y); in wdat_wdt_run_action()
189 ret = wdat_wdt_write(wdat, instr, x); in wdat_wdt_run_action()
195 dev_err(&wdat->pdev->dev, "Unknown instruction: %u\n", in wdat_wdt_run_action()
204 static int wdat_wdt_enable_reboot(struct wdat_wdt *wdat) in wdat_wdt_enable_reboot() argument
214 ret = wdat_wdt_run_action(wdat, ACPI_WDAT_SET_REBOOT, 0, NULL); in wdat_wdt_enable_reboot()
216 dev_err(&wdat->pdev->dev, in wdat_wdt_enable_reboot()
224 static void wdat_wdt_boot_status(struct wdat_wdt *wdat) in wdat_wdt_boot_status() argument
229 ret = wdat_wdt_run_action(wdat, ACPI_WDAT_GET_STATUS, 0, &boot_status); in wdat_wdt_boot_status()
231 dev_err(&wdat->pdev->dev, "Failed to read boot status\n"); in wdat_wdt_boot_status()
236 wdat->wdd.bootstatus = WDIOF_CARDRESET; in wdat_wdt_boot_status()
239 ret = wdat_wdt_run_action(wdat, ACPI_WDAT_SET_STATUS, 0, NULL); in wdat_wdt_boot_status()
241 dev_err(&wdat->pdev->dev, "Failed to clear boot status\n"); in wdat_wdt_boot_status()
244 static void wdat_wdt_set_running(struct wdat_wdt *wdat) in wdat_wdt_set_running() argument
249 ret = wdat_wdt_run_action(wdat, ACPI_WDAT_GET_RUNNING_STATE, 0, in wdat_wdt_set_running()
252 dev_err(&wdat->pdev->dev, "Failed to read running state\n"); in wdat_wdt_set_running()
255 set_bit(WDOG_HW_RUNNING, &wdat->wdd.status); in wdat_wdt_set_running()
278 struct wdat_wdt *wdat = to_wdat_wdt(wdd); in wdat_wdt_set_timeout() local
282 periods = timeout * 1000 / wdat->period; in wdat_wdt_set_timeout()
283 ret = wdat_wdt_run_action(wdat, ACPI_WDAT_SET_COUNTDOWN, periods, NULL); in wdat_wdt_set_timeout()
291 struct wdat_wdt *wdat = to_wdat_wdt(wdd); in wdat_wdt_get_timeleft() local
294 wdat_wdt_run_action(wdat, ACPI_WDAT_GET_CURRENT_COUNTDOWN, 0, &periods); in wdat_wdt_get_timeleft()
295 return periods * wdat->period / 1000; in wdat_wdt_get_timeleft()
318 struct wdat_wdt *wdat; in wdat_wdt_probe() local
329 wdat = devm_kzalloc(dev, sizeof(*wdat), GFP_KERNEL); in wdat_wdt_probe()
330 if (!wdat) in wdat_wdt_probe()
344 wdat->period = tbl->timer_period; in wdat_wdt_probe()
345 wdat->wdd.min_hw_heartbeat_ms = wdat->period * tbl->min_count; in wdat_wdt_probe()
346 wdat->wdd.max_hw_heartbeat_ms = wdat->period * tbl->max_count; in wdat_wdt_probe()
347 wdat->stopped_in_sleep = tbl->flags & ACPI_WDAT_STOPPED; in wdat_wdt_probe()
348 wdat->wdd.info = &wdat_wdt_info; in wdat_wdt_probe()
349 wdat->wdd.ops = &wdat_wdt_ops; in wdat_wdt_probe()
350 wdat->pdev = pdev; in wdat_wdt_probe()
424 instructions = wdat->instructions[action]; in wdat_wdt_probe()
433 wdat->instructions[action] = instructions; in wdat_wdt_probe()
439 wdat_wdt_boot_status(wdat); in wdat_wdt_probe()
440 wdat_wdt_set_running(wdat); in wdat_wdt_probe()
442 ret = wdat_wdt_enable_reboot(wdat); in wdat_wdt_probe()
446 platform_set_drvdata(pdev, wdat); in wdat_wdt_probe()
453 if (timeout * 1000 < wdat->wdd.min_hw_heartbeat_ms || in wdat_wdt_probe()
454 timeout * 1000 > wdat->wdd.max_hw_heartbeat_ms) { in wdat_wdt_probe()
460 ret = wdat_wdt_set_timeout(&wdat->wdd, timeout); in wdat_wdt_probe()
464 watchdog_set_nowayout(&wdat->wdd, nowayout); in wdat_wdt_probe()
465 watchdog_stop_on_reboot(&wdat->wdd); in wdat_wdt_probe()
466 return devm_watchdog_register_device(dev, &wdat->wdd); in wdat_wdt_probe()
472 struct wdat_wdt *wdat = dev_get_drvdata(dev); in wdat_wdt_suspend_noirq() local
475 if (!watchdog_active(&wdat->wdd)) in wdat_wdt_suspend_noirq()
484 wdat->stopped = false; in wdat_wdt_suspend_noirq()
486 !wdat->stopped_in_sleep) { in wdat_wdt_suspend_noirq()
487 ret = wdat_wdt_stop(&wdat->wdd); in wdat_wdt_suspend_noirq()
489 wdat->stopped = true; in wdat_wdt_suspend_noirq()
491 ret = wdat_wdt_ping(&wdat->wdd); in wdat_wdt_suspend_noirq()
499 struct wdat_wdt *wdat = dev_get_drvdata(dev); in wdat_wdt_resume_noirq() local
502 if (!watchdog_active(&wdat->wdd)) in wdat_wdt_resume_noirq()
505 if (!wdat->stopped) { in wdat_wdt_resume_noirq()
511 ret = wdat_wdt_stop(&wdat->wdd); in wdat_wdt_resume_noirq()
515 ret = wdat_wdt_set_timeout(&wdat->wdd, wdat->wdd.timeout); in wdat_wdt_resume_noirq()
519 ret = wdat_wdt_enable_reboot(wdat); in wdat_wdt_resume_noirq()
523 ret = wdat_wdt_ping(&wdat->wdd); in wdat_wdt_resume_noirq()
528 return wdat_wdt_start(&wdat->wdd); in wdat_wdt_resume_noirq()