/** * rave_sp_wdt_configure - Configure watchdog device * * @wdd: Device to configure * @on: Desired state of the watchdog timer (ON/OFF) * * This function configures two aspects of the watchdog timer: * * - Wheither it is ON or OFF * - Its timeout duration * * with first aspect specified via function argument and second via * the value of 'wdd->timeout'.
*/ staticint rave_sp_wdt_configure(struct watchdog_device *wdd, bool on)
{ return to_rave_sp_wdt(wdd)->variant->configure(wdd, on);
}
staticint rave_sp_wdt_reboot_notifier(struct notifier_block *nb, unsignedlong action, void *data)
{ /* * Restart handler is called in atomic context which means we * can't communicate to SP via UART. Luckily for use SP will * wait 500ms before actually resetting us, so we ask it to do * so here and let the rest of the system go on wrapping * things up.
*/ if (action == SYS_DOWN || action == SYS_HALT) { struct rave_sp_wdt *sp_wd =
container_of(nb, struct rave_sp_wdt, reboot_notifier);
constint ret = sp_wd->variant->restart(&sp_wd->wdd);
if (ret < 0)
dev_err(sp_wd->wdd.parent, "Failed to issue restart command (%d)", ret); return NOTIFY_OK;
}
return NOTIFY_DONE;
}
staticint rave_sp_wdt_restart(struct watchdog_device *wdd, unsignedlong action, void *data)
{ /* * The actual work was done by reboot notifier above. SP * firmware waits 500 ms before issuing reset, so let's hang * here for twice that delay and hopefuly we'd never reach * the return statement.
*/
mdelay(2 * RAVE_SP_RESET_DELAY_MS);
return -EIO;
}
staticint rave_sp_wdt_start(struct watchdog_device *wdd)
{ int ret;
ret = rave_sp_wdt_configure(wdd, true); if (!ret)
set_bit(WDOG_HW_RUNNING, &wdd->status);
sp_wd->reboot_notifier.notifier_call = rave_sp_wdt_reboot_notifier;
ret = devm_register_reboot_notifier(dev, &sp_wd->reboot_notifier); if (ret) {
dev_err(dev, "Failed to register reboot notifier\n"); return ret;
}
/* * We don't know if watchdog is running now. To be sure, let's * start it and depend on watchdog core to ping it
*/
wdd->max_hw_heartbeat_ms = wdd->max_timeout * 1000;
ret = rave_sp_wdt_start(wdd); if (ret) {
dev_err(dev, "Watchdog didn't start\n"); return ret;
}
ret = devm_watchdog_register_device(dev, wdd); if (ret) {
rave_sp_wdt_stop(wdd); return ret;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.