Lines Matching defs:adev

141 static int acpi_dev_pm_explicit_set(struct acpi_device *adev, int state)
143 if (adev->power.states[state].flags.explicit_set) {
147 status = acpi_evaluate_object(adev->handle, method, NULL, NULL);
378 static int fix_up_power_if_applicable(struct acpi_device *adev, void *not_used)
380 if (adev->status.present && adev->status.enabled)
381 acpi_device_fix_up_power(adev);
388 * @adev: Parent device object whose power state is to be fixed up.
390 * Call acpi_device_fix_up_power() for @adev and its children so long as they
393 void acpi_device_fix_up_power_extended(struct acpi_device *adev)
395 acpi_device_fix_up_power(adev);
396 acpi_dev_for_each_child(adev, fix_up_power_if_applicable, NULL);
402 * @adev: Parent device object whose children's power state is to be fixed up.
404 * Call acpi_device_fix_up_power() for @adev's children so long as they
407 void acpi_device_fix_up_power_children(struct acpi_device *adev)
409 acpi_dev_for_each_child(adev, fix_up_power_if_applicable, NULL);
473 static int acpi_power_up_if_adr_present(struct acpi_device *adev, void *not_used)
475 if (!(adev->flags.power_manageable && adev->pnp.type.bus_address))
478 acpi_handle_debug(adev->handle, "Power state: %s\n",
479 acpi_power_state_string(adev->power.state));
481 if (adev->power.state == ACPI_STATE_D3_COLD)
482 return acpi_device_set_power(adev, ACPI_STATE_D0);
489 * @adev: Parent ACPI device object.
491 * Change the power states of the direct children of @adev that are in D3cold
495 void acpi_dev_power_up_children_with_adr(struct acpi_device *adev)
497 acpi_dev_for_each_child(adev, acpi_power_up_if_adr_present, NULL);
502 * @adev: ACPI companion of the target device.
504 * Evaluate _S0W for @adev and return the value produced by it or return
507 u8 acpi_dev_power_state_for_wake(struct acpi_device *adev)
512 status = acpi_evaluate_integer(adev->handle, "_S0W", NULL, &state);
531 struct acpi_device *adev;
538 adev = acpi_get_acpi_dev(handle);
539 if (!adev)
544 if (adev->wakeup.flags.notifier_present) {
545 pm_wakeup_ws_event(adev->wakeup.ws, 0, acpi_s2idle_wakeup());
546 if (adev->wakeup.context.func) {
548 adev->wakeup.context.func,
549 dev_name(adev->wakeup.context.dev));
550 adev->wakeup.context.func(&adev->wakeup.context);
556 acpi_put_acpi_dev(adev);
561 * @adev: ACPI device to add the notify handler for.
565 * NOTE: @adev need not be a run-wake or wakeup device to be a valid source of
570 acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev,
580 if (adev->wakeup.flags.notifier_present)
583 status = acpi_install_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY,
589 adev->wakeup.ws = wakeup_source_register(&adev->dev,
590 dev_name(&adev->dev));
591 adev->wakeup.context.dev = dev;
592 adev->wakeup.context.func = func;
593 adev->wakeup.flags.notifier_present = true;
603 * @adev: ACPI device to remove the notifier from.
605 acpi_status acpi_remove_pm_notifier(struct acpi_device *adev)
611 if (!adev->wakeup.flags.notifier_present)
614 status = acpi_remove_notify_handler(adev->handle,
621 adev->wakeup.context.func = NULL;
622 adev->wakeup.context.dev = NULL;
623 wakeup_source_unregister(adev->wakeup.ws);
624 adev->wakeup.flags.notifier_present = false;
642 struct acpi_device *adev = ACPI_COMPANION(dev);
644 return adev ? acpi_device_can_wakeup(adev) : false;
650 * @adev: ACPI device node corresponding to @dev.
661 * Callers must ensure that @dev and @adev are valid pointers and that @adev
668 static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev,
672 acpi_handle handle = adev->handle;
709 if (!adev->power.states[ret].flags.valid) {
720 wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid
721 && adev->wakeup.sleep_state >= target_state;
738 wakeup = adev->wakeup.flags.valid;
760 if (!adev->power.states[ret].flags.valid)
791 struct acpi_device *adev;
805 adev = ACPI_COMPANION(dev);
806 if (!adev) {
811 ret = acpi_dev_pm_get_state(dev, adev, acpi_target_system_state(),
821 if (adev->power.states[d_max].flags.valid)
849 static int __acpi_device_wakeup_enable(struct acpi_device *adev,
852 struct acpi_device_wakeup *wakeup = &adev->wakeup;
865 acpi_disable_wakeup_device_power(adev);
867 error = acpi_enable_wakeup_device_power(adev, target_state);
881 acpi_disable_wakeup_device_power(adev);
886 acpi_handle_debug(adev->handle, "GPE%2X enabled for wakeup\n",
893 acpi_handle_info(adev->handle, "Wakeup enable count out of bounds!\n");
902 * @adev: ACPI device to enable wakeup functionality for.
905 * Enable the GPE associated with @adev so that it can generate wakeup signals
909 * Callers must ensure that @adev is a valid ACPI device node before executing
912 static int acpi_device_wakeup_enable(struct acpi_device *adev, u32 target_state)
914 return __acpi_device_wakeup_enable(adev, target_state);
919 * @adev: ACPI device to disable wakeup functionality for.
921 * Disable the GPE associated with @adev and disable wakeup power for it.
923 * Callers must ensure that @adev is a valid ACPI device node before executing
926 static void acpi_device_wakeup_disable(struct acpi_device *adev)
928 struct acpi_device_wakeup *wakeup = &adev->wakeup;
936 acpi_disable_wakeup_device_power(adev);
951 struct acpi_device *adev;
954 adev = ACPI_COMPANION(dev);
955 if (!adev) {
960 if (!acpi_device_can_wakeup(adev))
964 acpi_device_wakeup_disable(adev);
969 error = __acpi_device_wakeup_enable(adev, acpi_target_system_state());
980 * @adev: ACPI device node corresponding to @dev.
983 static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev,
988 if (!acpi_device_power_manageable(adev))
991 ret = acpi_dev_pm_get_state(dev, adev, system_state, NULL, &state);
992 return ret ? ret : acpi_device_set_power(adev, state);
997 * @adev: ACPI device node to put into the full-power state.
999 static int acpi_dev_pm_full_power(struct acpi_device *adev)
1001 return acpi_device_power_manageable(adev) ?
1002 acpi_device_set_power(adev, ACPI_STATE_D0) : 0;
1017 struct acpi_device *adev = ACPI_COMPANION(dev);
1021 if (!adev)
1024 if (wakeup && acpi_device_can_wakeup(adev)) {
1025 error = acpi_device_wakeup_enable(adev, target_state);
1032 error = acpi_dev_pm_low_power(dev, adev, target_state);
1034 acpi_device_wakeup_disable(adev);
1049 struct acpi_device *adev = ACPI_COMPANION(dev);
1052 if (!adev)
1055 error = acpi_dev_pm_full_power(adev);
1056 acpi_device_wakeup_disable(adev);
1092 static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev)
1097 if (!pm_runtime_suspended(dev) || !adev || (adev->wakeup.flags.valid &&
1098 device_may_wakeup(dev) != !!adev->wakeup.prepare_count))
1104 if (adev->power.flags.dsw_present)
1107 ret = acpi_dev_pm_get_state(dev, adev, sys_target, NULL, &state);
1111 return state != adev->power.state;
1120 struct acpi_device *adev = ACPI_COMPANION(dev);
1132 return !acpi_dev_needs_resume(dev, adev);
1401 struct acpi_device *adev = ACPI_COMPANION(dev);
1403 if (adev && dev->pm_domain == &acpi_general_pm_domain) {
1405 acpi_remove_pm_notifier(adev);
1415 acpi_device_wakeup_disable(adev);
1416 acpi_dev_pm_low_power(dev, adev, ACPI_STATE_S0);
1448 struct acpi_device *adev = ACPI_COMPANION(dev);
1450 if (!adev || !acpi_match_device_ids(adev, special_pm_ids))
1458 if (!acpi_device_is_first_physical_node(adev, dev))
1461 acpi_add_pm_notifier(adev, dev, acpi_pm_notify_work_func);
1464 acpi_dev_pm_full_power(adev);
1465 acpi_device_wakeup_disable(adev);
1489 struct acpi_device *adev = ACPI_COMPANION(dev);
1495 if (!adev)
1497 if (fwnode_property_read_u8(acpi_fwnode_handle(adev), "StorageD3Enable",
1521 struct acpi_device *adev = ACPI_COMPANION(dev);
1523 if (!adev)
1526 return adev->power.state == ACPI_STATE_D0;