Lines Matching refs:adev
128 static int acpi_dev_pm_explicit_set(struct acpi_device *adev, int state) in acpi_dev_pm_explicit_set() argument
130 if (adev->power.states[state].flags.explicit_set) { in acpi_dev_pm_explicit_set()
134 status = acpi_evaluate_object(adev->handle, method, NULL, NULL); in acpi_dev_pm_explicit_set()
388 struct acpi_device *adev; in acpi_pm_notify_handler() local
393 adev = acpi_bus_get_acpi_device(handle); in acpi_pm_notify_handler()
394 if (!adev) in acpi_pm_notify_handler()
399 if (adev->wakeup.flags.notifier_present) { in acpi_pm_notify_handler()
400 __pm_wakeup_event(adev->wakeup.ws, 0); in acpi_pm_notify_handler()
401 if (adev->wakeup.context.work.func) in acpi_pm_notify_handler()
402 queue_pm_work(&adev->wakeup.context.work); in acpi_pm_notify_handler()
407 acpi_bus_put_acpi_device(adev); in acpi_pm_notify_handler()
421 acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev, in acpi_add_pm_notifier() argument
431 if (adev->wakeup.flags.notifier_present) in acpi_add_pm_notifier()
434 adev->wakeup.ws = wakeup_source_register(dev_name(&adev->dev)); in acpi_add_pm_notifier()
435 adev->wakeup.context.dev = dev; in acpi_add_pm_notifier()
437 INIT_WORK(&adev->wakeup.context.work, work_func); in acpi_add_pm_notifier()
439 status = acpi_install_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY, in acpi_add_pm_notifier()
444 adev->wakeup.flags.notifier_present = true; in acpi_add_pm_notifier()
455 acpi_status acpi_remove_pm_notifier(struct acpi_device *adev) in acpi_remove_pm_notifier() argument
461 if (!adev->wakeup.flags.notifier_present) in acpi_remove_pm_notifier()
464 status = acpi_remove_notify_handler(adev->handle, in acpi_remove_pm_notifier()
470 if (adev->wakeup.context.work.func) { in acpi_remove_pm_notifier()
471 cancel_work_sync(&adev->wakeup.context.work); in acpi_remove_pm_notifier()
472 adev->wakeup.context.work.func = NULL; in acpi_remove_pm_notifier()
474 adev->wakeup.context.dev = NULL; in acpi_remove_pm_notifier()
475 wakeup_source_unregister(adev->wakeup.ws); in acpi_remove_pm_notifier()
477 adev->wakeup.flags.notifier_present = false; in acpi_remove_pm_notifier()
515 static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev, in acpi_dev_pm_get_state() argument
519 acpi_handle handle = adev->handle; in acpi_dev_pm_get_state()
555 if (!adev->power.states[ret].flags.valid) { in acpi_dev_pm_get_state()
562 wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid in acpi_dev_pm_get_state()
563 && adev->wakeup.sleep_state >= target_state; in acpi_dev_pm_get_state()
566 wakeup = adev->wakeup.flags.valid; in acpi_dev_pm_get_state()
584 if (!adev->power.states[ret].flags.valid) in acpi_dev_pm_get_state()
615 struct acpi_device *adev; in acpi_pm_device_sleep_state() local
629 adev = ACPI_COMPANION(dev); in acpi_pm_device_sleep_state()
630 if (!adev) { in acpi_pm_device_sleep_state()
635 ret = acpi_dev_pm_get_state(dev, adev, acpi_target_system_state(), in acpi_pm_device_sleep_state()
645 if (adev->power.states[d_max].flags.valid) in acpi_pm_device_sleep_state()
685 static int acpi_device_wakeup(struct acpi_device *adev, u32 target_state, in acpi_device_wakeup() argument
688 struct acpi_device_wakeup *wakeup = &adev->wakeup; in acpi_device_wakeup()
694 error = acpi_enable_wakeup_device_power(adev, target_state); in acpi_device_wakeup()
698 if (adev->wakeup.flags.enabled) in acpi_device_wakeup()
703 adev->wakeup.flags.enabled = 1; in acpi_device_wakeup()
705 acpi_disable_wakeup_device_power(adev); in acpi_device_wakeup()
709 if (adev->wakeup.flags.enabled) { in acpi_device_wakeup()
711 adev->wakeup.flags.enabled = 0; in acpi_device_wakeup()
713 acpi_disable_wakeup_device_power(adev); in acpi_device_wakeup()
725 struct acpi_device *adev; in acpi_pm_device_run_wake() local
730 adev = ACPI_COMPANION(phys_dev); in acpi_pm_device_run_wake()
731 if (!adev) { in acpi_pm_device_run_wake()
736 return acpi_device_wakeup(adev, ACPI_STATE_S0, enable); in acpi_pm_device_run_wake()
748 struct acpi_device *adev; in acpi_pm_device_sleep_wake() local
754 adev = ACPI_COMPANION(dev); in acpi_pm_device_sleep_wake()
755 if (!adev) { in acpi_pm_device_sleep_wake()
760 error = acpi_device_wakeup(adev, acpi_target_system_state(), enable); in acpi_pm_device_sleep_wake()
775 static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev, in acpi_dev_pm_low_power() argument
780 if (!acpi_device_power_manageable(adev)) in acpi_dev_pm_low_power()
783 ret = acpi_dev_pm_get_state(dev, adev, system_state, NULL, &state); in acpi_dev_pm_low_power()
784 return ret ? ret : acpi_device_set_power(adev, state); in acpi_dev_pm_low_power()
791 static int acpi_dev_pm_full_power(struct acpi_device *adev) in acpi_dev_pm_full_power() argument
793 return acpi_device_power_manageable(adev) ? in acpi_dev_pm_full_power()
794 acpi_device_set_power(adev, ACPI_STATE_D0) : 0; in acpi_dev_pm_full_power()
808 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_runtime_suspend() local
812 if (!adev) in acpi_dev_runtime_suspend()
817 error = acpi_device_wakeup(adev, ACPI_STATE_S0, remote_wakeup); in acpi_dev_runtime_suspend()
821 error = acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); in acpi_dev_runtime_suspend()
823 acpi_device_wakeup(adev, ACPI_STATE_S0, false); in acpi_dev_runtime_suspend()
839 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_runtime_resume() local
842 if (!adev) in acpi_dev_runtime_resume()
845 error = acpi_dev_pm_full_power(adev); in acpi_dev_runtime_resume()
846 acpi_device_wakeup(adev, ACPI_STATE_S0, false); in acpi_dev_runtime_resume()
891 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_suspend_late() local
896 if (!adev) in acpi_dev_suspend_late()
900 wakeup = device_may_wakeup(dev) && acpi_device_can_wakeup(adev); in acpi_dev_suspend_late()
901 error = acpi_device_wakeup(adev, target_state, wakeup); in acpi_dev_suspend_late()
905 error = acpi_dev_pm_low_power(dev, adev, target_state); in acpi_dev_suspend_late()
907 acpi_device_wakeup(adev, ACPI_STATE_UNKNOWN, false); in acpi_dev_suspend_late()
923 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_resume_early() local
926 if (!adev) in acpi_dev_resume_early()
929 error = acpi_dev_pm_full_power(adev); in acpi_dev_resume_early()
930 acpi_device_wakeup(adev, ACPI_STATE_UNKNOWN, false); in acpi_dev_resume_early()
941 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_subsys_prepare() local
949 if (!adev || !pm_runtime_suspended(dev) in acpi_subsys_prepare()
950 || device_may_wakeup(dev) != !!adev->wakeup.prepare_count) in acpi_subsys_prepare()
957 if (adev->power.flags.dsw_present) in acpi_subsys_prepare()
960 ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state); in acpi_subsys_prepare()
961 return !ret && state == adev->power.state; in acpi_subsys_prepare()
1059 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_pm_detach() local
1061 if (adev && dev->pm_domain == &acpi_general_pm_domain) { in acpi_dev_pm_detach()
1063 acpi_remove_pm_notifier(adev); in acpi_dev_pm_detach()
1073 acpi_device_wakeup(adev, ACPI_STATE_S0, false); in acpi_dev_pm_detach()
1074 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); in acpi_dev_pm_detach()
1097 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_pm_attach() local
1099 if (!adev) in acpi_dev_pm_attach()
1110 if (!acpi_device_is_first_physical_node(adev, dev)) in acpi_dev_pm_attach()
1113 acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func); in acpi_dev_pm_attach()
1116 acpi_dev_pm_full_power(adev); in acpi_dev_pm_attach()
1117 acpi_device_wakeup(adev, ACPI_STATE_S0, false); in acpi_dev_pm_attach()