Lines Matching refs:sc
122 struct scmi_syspower_conf *sc = reboot_nb_to_sconf(nb); in scmi_reboot_notifier() local
124 mutex_lock(&sc->state_mtx); in scmi_reboot_notifier()
128 if (sc->required_transition == SCMI_SYSTEM_SHUTDOWN) in scmi_reboot_notifier()
129 sc->state = SCMI_SYSPOWER_REBOOTING; in scmi_reboot_notifier()
132 if (sc->required_transition == SCMI_SYSTEM_COLDRESET || in scmi_reboot_notifier()
133 sc->required_transition == SCMI_SYSTEM_WARMRESET) in scmi_reboot_notifier()
134 sc->state = SCMI_SYSPOWER_REBOOTING; in scmi_reboot_notifier()
140 if (sc->state == SCMI_SYSPOWER_REBOOTING) { in scmi_reboot_notifier()
141 dev_dbg(sc->dev, "Reboot in progress...cancel delayed work.\n"); in scmi_reboot_notifier()
142 cancel_delayed_work_sync(&sc->forceful_work); in scmi_reboot_notifier()
144 mutex_unlock(&sc->state_mtx); in scmi_reboot_notifier()
158 scmi_request_forceful_transition(struct scmi_syspower_conf *sc) in scmi_request_forceful_transition() argument
160 dev_dbg(sc->dev, "Serving forceful request:%d\n", in scmi_request_forceful_transition()
161 sc->required_transition); in scmi_request_forceful_transition()
166 switch (sc->required_transition) { in scmi_request_forceful_transition()
181 struct scmi_syspower_conf *sc; in scmi_forceful_work_func() local
188 sc = dwork_to_sconf(dwork); in scmi_forceful_work_func()
190 dev_dbg(sc->dev, "Graceful request timed out...forcing !\n"); in scmi_forceful_work_func()
191 mutex_lock(&sc->state_mtx); in scmi_forceful_work_func()
193 unregister_reboot_notifier(&sc->reboot_nb); in scmi_forceful_work_func()
194 if (sc->state == SCMI_SYSPOWER_IN_PROGRESS) in scmi_forceful_work_func()
195 scmi_request_forceful_transition(sc); in scmi_forceful_work_func()
196 mutex_unlock(&sc->state_mtx); in scmi_forceful_work_func()
213 static void scmi_request_graceful_transition(struct scmi_syspower_conf *sc, in scmi_request_graceful_transition() argument
221 sc->reboot_nb.notifier_call = &scmi_reboot_notifier; in scmi_request_graceful_transition()
222 ret = register_reboot_notifier(&sc->reboot_nb); in scmi_request_graceful_transition()
226 INIT_DELAYED_WORK(&sc->forceful_work, in scmi_request_graceful_transition()
228 schedule_delayed_work(&sc->forceful_work, in scmi_request_graceful_transition()
232 dev_warn(sc->dev, in scmi_request_graceful_transition()
237 dev_dbg(sc->dev, in scmi_request_graceful_transition()
239 sc->required_transition, timeout_ms, adj_timeout_ms); in scmi_request_graceful_transition()
241 switch (sc->required_transition) { in scmi_request_graceful_transition()
256 schedule_work(&sc->suspend_work); in scmi_request_graceful_transition()
284 struct scmi_syspower_conf *sc = userspace_nb_to_sconf(nb); in scmi_userspace_notifier() local
288 dev_err(sc->dev, "Ignoring unsupported system_state: 0x%X\n", in scmi_userspace_notifier()
294 dev_err(sc->dev, "Ignoring forceful notification.\n"); in scmi_userspace_notifier()
304 mutex_lock(&sc->state_mtx); in scmi_userspace_notifier()
305 if (sc->state != SCMI_SYSPOWER_IDLE) { in scmi_userspace_notifier()
306 dev_dbg(sc->dev, in scmi_userspace_notifier()
308 mutex_unlock(&sc->state_mtx); in scmi_userspace_notifier()
311 sc->state = SCMI_SYSPOWER_IN_PROGRESS; in scmi_userspace_notifier()
312 mutex_unlock(&sc->state_mtx); in scmi_userspace_notifier()
314 sc->required_transition = er->system_state; in scmi_userspace_notifier()
317 dev_info(sc->dev, "Serving shutdown/reboot request: %d\n", in scmi_userspace_notifier()
318 sc->required_transition); in scmi_userspace_notifier()
320 scmi_request_graceful_transition(sc, er->timeout); in scmi_userspace_notifier()
327 struct scmi_syspower_conf *sc = in scmi_suspend_work_func() local
332 sc->state = SCMI_SYSPOWER_IDLE; in scmi_suspend_work_func()
338 struct scmi_syspower_conf *sc; in scmi_syspower_probe() local
348 sc = devm_kzalloc(&sdev->dev, sizeof(*sc), GFP_KERNEL); in scmi_syspower_probe()
349 if (!sc) in scmi_syspower_probe()
352 sc->state = SCMI_SYSPOWER_IDLE; in scmi_syspower_probe()
353 mutex_init(&sc->state_mtx); in scmi_syspower_probe()
354 sc->required_transition = SCMI_SYSTEM_MAX; in scmi_syspower_probe()
355 sc->userspace_nb.notifier_call = &scmi_userspace_notifier; in scmi_syspower_probe()
356 sc->dev = &sdev->dev; in scmi_syspower_probe()
358 INIT_WORK(&sc->suspend_work, scmi_suspend_work_func); in scmi_syspower_probe()
363 NULL, &sc->userspace_nb); in scmi_syspower_probe()