Lines Matching refs:adev
133 static int acpi_dev_pm_explicit_set(struct acpi_device *adev, int state) in acpi_dev_pm_explicit_set() argument
135 if (adev->power.states[state].flags.explicit_set) { in acpi_dev_pm_explicit_set()
139 status = acpi_evaluate_object(adev->handle, method, NULL, NULL); in acpi_dev_pm_explicit_set()
373 struct acpi_device *adev; in acpi_pm_notify_handler() local
378 adev = acpi_bus_get_acpi_device(handle); in acpi_pm_notify_handler()
379 if (!adev) in acpi_pm_notify_handler()
384 if (adev->wakeup.flags.notifier_present) { in acpi_pm_notify_handler()
385 __pm_wakeup_event(adev->wakeup.ws, 0); in acpi_pm_notify_handler()
386 if (adev->wakeup.context.work.func) in acpi_pm_notify_handler()
387 queue_pm_work(&adev->wakeup.context.work); in acpi_pm_notify_handler()
392 acpi_bus_put_acpi_device(adev); in acpi_pm_notify_handler()
406 acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev, in acpi_add_pm_notifier() argument
416 if (adev->wakeup.flags.notifier_present) in acpi_add_pm_notifier()
419 adev->wakeup.ws = wakeup_source_register(dev_name(&adev->dev)); in acpi_add_pm_notifier()
420 adev->wakeup.context.dev = dev; in acpi_add_pm_notifier()
422 INIT_WORK(&adev->wakeup.context.work, work_func); in acpi_add_pm_notifier()
424 status = acpi_install_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY, in acpi_add_pm_notifier()
429 adev->wakeup.flags.notifier_present = true; in acpi_add_pm_notifier()
440 acpi_status acpi_remove_pm_notifier(struct acpi_device *adev) in acpi_remove_pm_notifier() argument
446 if (!adev->wakeup.flags.notifier_present) in acpi_remove_pm_notifier()
449 status = acpi_remove_notify_handler(adev->handle, in acpi_remove_pm_notifier()
455 if (adev->wakeup.context.work.func) { in acpi_remove_pm_notifier()
456 cancel_work_sync(&adev->wakeup.context.work); in acpi_remove_pm_notifier()
457 adev->wakeup.context.work.func = NULL; in acpi_remove_pm_notifier()
459 adev->wakeup.context.dev = NULL; in acpi_remove_pm_notifier()
460 wakeup_source_unregister(adev->wakeup.ws); in acpi_remove_pm_notifier()
462 adev->wakeup.flags.notifier_present = false; in acpi_remove_pm_notifier()
500 static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev, in acpi_dev_pm_get_state() argument
504 acpi_handle handle = adev->handle; in acpi_dev_pm_get_state()
540 if (!adev->power.states[ret].flags.valid) { in acpi_dev_pm_get_state()
547 wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid in acpi_dev_pm_get_state()
548 && adev->wakeup.sleep_state >= target_state; in acpi_dev_pm_get_state()
551 wakeup = adev->wakeup.flags.valid; in acpi_dev_pm_get_state()
569 if (!adev->power.states[ret].flags.valid) in acpi_dev_pm_get_state()
600 struct acpi_device *adev; in acpi_pm_device_sleep_state() local
614 adev = ACPI_COMPANION(dev); in acpi_pm_device_sleep_state()
615 if (!adev) { in acpi_pm_device_sleep_state()
620 ret = acpi_dev_pm_get_state(dev, adev, acpi_target_system_state(), in acpi_pm_device_sleep_state()
630 if (adev->power.states[d_max].flags.valid) in acpi_pm_device_sleep_state()
670 static int acpi_device_wakeup(struct acpi_device *adev, u32 target_state, in acpi_device_wakeup() argument
673 struct acpi_device_wakeup *wakeup = &adev->wakeup; in acpi_device_wakeup()
679 error = acpi_enable_wakeup_device_power(adev, target_state); in acpi_device_wakeup()
683 if (adev->wakeup.flags.enabled) in acpi_device_wakeup()
688 adev->wakeup.flags.enabled = 1; in acpi_device_wakeup()
690 acpi_disable_wakeup_device_power(adev); in acpi_device_wakeup()
694 if (adev->wakeup.flags.enabled) { in acpi_device_wakeup()
696 adev->wakeup.flags.enabled = 0; in acpi_device_wakeup()
698 acpi_disable_wakeup_device_power(adev); in acpi_device_wakeup()
710 struct acpi_device *adev; in acpi_pm_device_run_wake() local
715 adev = ACPI_COMPANION(phys_dev); in acpi_pm_device_run_wake()
716 if (!adev) { in acpi_pm_device_run_wake()
721 return acpi_device_wakeup(adev, ACPI_STATE_S0, enable); in acpi_pm_device_run_wake()
733 struct acpi_device *adev; in acpi_pm_device_sleep_wake() local
739 adev = ACPI_COMPANION(dev); in acpi_pm_device_sleep_wake()
740 if (!adev) { in acpi_pm_device_sleep_wake()
745 error = acpi_device_wakeup(adev, acpi_target_system_state(), enable); in acpi_pm_device_sleep_wake()
760 static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev, in acpi_dev_pm_low_power() argument
765 if (!acpi_device_power_manageable(adev)) in acpi_dev_pm_low_power()
768 ret = acpi_dev_pm_get_state(dev, adev, system_state, NULL, &state); in acpi_dev_pm_low_power()
769 return ret ? ret : acpi_device_set_power(adev, state); in acpi_dev_pm_low_power()
776 static int acpi_dev_pm_full_power(struct acpi_device *adev) in acpi_dev_pm_full_power() argument
778 return acpi_device_power_manageable(adev) ? in acpi_dev_pm_full_power()
779 acpi_device_set_power(adev, ACPI_STATE_D0) : 0; in acpi_dev_pm_full_power()
793 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_runtime_suspend() local
797 if (!adev) in acpi_dev_runtime_suspend()
802 error = acpi_device_wakeup(adev, ACPI_STATE_S0, remote_wakeup); in acpi_dev_runtime_suspend()
806 error = acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); in acpi_dev_runtime_suspend()
808 acpi_device_wakeup(adev, ACPI_STATE_S0, false); in acpi_dev_runtime_suspend()
824 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_runtime_resume() local
827 if (!adev) in acpi_dev_runtime_resume()
830 error = acpi_dev_pm_full_power(adev); in acpi_dev_runtime_resume()
831 acpi_device_wakeup(adev, ACPI_STATE_S0, false); in acpi_dev_runtime_resume()
876 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_suspend_late() local
881 if (!adev) in acpi_dev_suspend_late()
885 wakeup = device_may_wakeup(dev) && acpi_device_can_wakeup(adev); in acpi_dev_suspend_late()
886 error = acpi_device_wakeup(adev, target_state, wakeup); in acpi_dev_suspend_late()
890 error = acpi_dev_pm_low_power(dev, adev, target_state); in acpi_dev_suspend_late()
892 acpi_device_wakeup(adev, ACPI_STATE_UNKNOWN, false); in acpi_dev_suspend_late()
908 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_resume_early() local
911 if (!adev) in acpi_dev_resume_early()
914 error = acpi_dev_pm_full_power(adev); in acpi_dev_resume_early()
915 acpi_device_wakeup(adev, ACPI_STATE_UNKNOWN, false); in acpi_dev_resume_early()
926 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_subsys_prepare() local
934 if (!adev || !pm_runtime_suspended(dev) in acpi_subsys_prepare()
935 || device_may_wakeup(dev) != !!adev->wakeup.prepare_count) in acpi_subsys_prepare()
942 if (adev->power.flags.dsw_present) in acpi_subsys_prepare()
945 ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state); in acpi_subsys_prepare()
946 return !ret && state == adev->power.state; in acpi_subsys_prepare()
1061 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_pm_detach() local
1063 if (adev && dev->pm_domain == &acpi_general_pm_domain) { in acpi_dev_pm_detach()
1065 acpi_remove_pm_notifier(adev); in acpi_dev_pm_detach()
1075 acpi_device_wakeup(adev, ACPI_STATE_S0, false); in acpi_dev_pm_detach()
1076 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0); in acpi_dev_pm_detach()
1099 struct acpi_device *adev = ACPI_COMPANION(dev); in acpi_dev_pm_attach() local
1101 if (!adev) in acpi_dev_pm_attach()
1107 acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func); in acpi_dev_pm_attach()
1110 acpi_dev_pm_full_power(adev); in acpi_dev_pm_attach()
1111 acpi_device_wakeup(adev, ACPI_STATE_S0, false); in acpi_dev_pm_attach()