Lines Matching defs:wdat
64 static int wdat_wdt_read(struct wdat_wdt *wdat,
83 dev_dbg(&wdat->pdev->dev, "Read %#x from 0x%08llx\n", *value,
89 static int wdat_wdt_write(struct wdat_wdt *wdat,
108 dev_dbg(&wdat->pdev->dev, "Wrote %#x to 0x%08llx\n", value,
114 static int wdat_wdt_run_action(struct wdat_wdt *wdat, unsigned int action,
119 if (action >= ARRAY_SIZE(wdat->instructions))
122 if (!wdat->instructions[action])
125 dev_dbg(&wdat->pdev->dev, "Running action %#x\n", action);
128 list_for_each_entry(instr, wdat->instructions[action], node) {
144 ret = wdat_wdt_read(wdat, instr, &x);
154 ret = wdat_wdt_read(wdat, instr, &x);
167 ret = wdat_wdt_read(wdat, instr, &y);
173 ret = wdat_wdt_write(wdat, instr, x);
183 ret = wdat_wdt_read(wdat, instr, &y);
189 ret = wdat_wdt_write(wdat, instr, x);
195 dev_err(&wdat->pdev->dev, "Unknown instruction: %u\n",
204 static int wdat_wdt_enable_reboot(struct wdat_wdt *wdat)
214 ret = wdat_wdt_run_action(wdat, ACPI_WDAT_SET_REBOOT, 0, NULL);
216 dev_err(&wdat->pdev->dev,
224 static void wdat_wdt_boot_status(struct wdat_wdt *wdat)
229 ret = wdat_wdt_run_action(wdat, ACPI_WDAT_GET_STATUS, 0, &boot_status);
231 dev_err(&wdat->pdev->dev, "Failed to read boot status\n");
236 wdat->wdd.bootstatus = WDIOF_CARDRESET;
239 ret = wdat_wdt_run_action(wdat, ACPI_WDAT_SET_STATUS, 0, NULL);
241 dev_err(&wdat->pdev->dev, "Failed to clear boot status\n");
244 static void wdat_wdt_set_running(struct wdat_wdt *wdat)
249 ret = wdat_wdt_run_action(wdat, ACPI_WDAT_GET_RUNNING_STATE, 0,
252 dev_err(&wdat->pdev->dev, "Failed to read running state\n");
255 set_bit(WDOG_HW_RUNNING, &wdat->wdd.status);
278 struct wdat_wdt *wdat = to_wdat_wdt(wdd);
282 periods = timeout * 1000 / wdat->period;
283 ret = wdat_wdt_run_action(wdat, ACPI_WDAT_SET_COUNTDOWN, periods, NULL);
291 struct wdat_wdt *wdat = to_wdat_wdt(wdd);
294 wdat_wdt_run_action(wdat, ACPI_WDAT_GET_CURRENT_COUNTDOWN, 0, &periods);
295 return periods * wdat->period / 1000;
317 struct wdat_wdt *wdat;
328 wdat = devm_kzalloc(dev, sizeof(*wdat), GFP_KERNEL);
329 if (!wdat)
343 wdat->period = tbl->timer_period;
344 wdat->wdd.min_timeout = DIV_ROUND_UP(wdat->period * tbl->min_count, 1000);
345 wdat->wdd.max_timeout = wdat->period * tbl->max_count / 1000;
346 wdat->stopped_in_sleep = tbl->flags & ACPI_WDAT_STOPPED;
347 wdat->wdd.info = &wdat_wdt_info;
348 wdat->wdd.ops = &wdat_wdt_ops;
349 wdat->pdev = pdev;
423 instructions = wdat->instructions[action];
432 wdat->instructions[action] = instructions;
438 if (wdat->instructions[ACPI_WDAT_GET_CURRENT_COUNTDOWN])
441 wdat_wdt_boot_status(wdat);
442 wdat_wdt_set_running(wdat);
444 ret = wdat_wdt_enable_reboot(wdat);
448 platform_set_drvdata(pdev, wdat);
455 if (watchdog_timeout_invalid(&wdat->wdd, timeout)) {
461 ret = wdat_wdt_set_timeout(&wdat->wdd, timeout);
465 watchdog_set_nowayout(&wdat->wdd, nowayout);
466 watchdog_stop_on_reboot(&wdat->wdd);
467 watchdog_stop_on_unregister(&wdat->wdd);
468 return devm_watchdog_register_device(dev, &wdat->wdd);
473 struct wdat_wdt *wdat = dev_get_drvdata(dev);
476 if (!watchdog_active(&wdat->wdd))
485 wdat->stopped = false;
487 !wdat->stopped_in_sleep) {
488 ret = wdat_wdt_stop(&wdat->wdd);
490 wdat->stopped = true;
492 ret = wdat_wdt_ping(&wdat->wdd);
500 struct wdat_wdt *wdat = dev_get_drvdata(dev);
503 if (!watchdog_active(&wdat->wdd))
506 if (!wdat->stopped) {
512 ret = wdat_wdt_stop(&wdat->wdd);
516 ret = wdat_wdt_set_timeout(&wdat->wdd, wdat->wdd.timeout);
520 ret = wdat_wdt_enable_reboot(wdat);
524 ret = wdat_wdt_ping(&wdat->wdd);
529 return wdat_wdt_start(&wdat->wdd);