Lines Matching +full:device +full:- +full:handle

1 // SPDX-License-Identifier: GPL-2.0-only
3 * drivers/acpi/device_pm.c - ACPI device power management routines.
27 * acpi_power_state_string - String representation of ACPI device power state.
28 * @state: ACPI device power state to return the string representation of.
48 static int acpi_dev_pm_explicit_get(struct acpi_device *device, int *state) in acpi_dev_pm_explicit_get() argument
53 status = acpi_evaluate_integer(device->handle, "_PSC", NULL, &psc); in acpi_dev_pm_explicit_get()
55 return -ENODEV; in acpi_dev_pm_explicit_get()
62 * acpi_device_get_power - Get power state of an ACPI device.
63 * @device: Device to get the power state of.
64 * @state: Place to store the power state of the device.
66 * This function does not update the device's power.state field, but it may
68 * unknown and the device's power state turns out to be D0).
72 * state shallower than previously set by acpi_device_set_power() for @device
75 int acpi_device_get_power(struct acpi_device *device, int *state) in acpi_device_get_power() argument
81 if (!device || !state) in acpi_device_get_power()
82 return -EINVAL; in acpi_device_get_power()
84 parent = acpi_dev_parent(device); in acpi_device_get_power()
86 if (!device->flags.power_manageable) { in acpi_device_get_power()
87 /* TBD: Non-recursive algorithm for walking up hierarchy. */ in acpi_device_get_power()
88 *state = parent ? parent->power.state : ACPI_STATE_D0; in acpi_device_get_power()
93 * Get the device's power state from power resources settings and _PSC, in acpi_device_get_power()
96 if (device->power.flags.power_resources) { in acpi_device_get_power()
97 error = acpi_power_get_inferred_state(device, &result); in acpi_device_get_power()
101 if (device->power.flags.explicit_get) { in acpi_device_get_power()
104 error = acpi_dev_pm_explicit_get(device, &psc); in acpi_device_get_power()
110 * shallower than the actual power state of the device, because in acpi_device_get_power()
123 * If we were unsure about the device parent's power state up to this in acpi_device_get_power()
124 * point, the fact that the device is in D0 implies that the parent has in acpi_device_get_power()
127 if (!device->power.flags.ignore_parent && parent && in acpi_device_get_power()
128 parent->power.state == ACPI_STATE_UNKNOWN && in acpi_device_get_power()
130 parent->power.state = ACPI_STATE_D0; in acpi_device_get_power()
135 acpi_handle_debug(device->handle, "Power state: %s\n", in acpi_device_get_power()
143 if (adev->power.states[state].flags.explicit_set) { in acpi_dev_pm_explicit_set()
147 status = acpi_evaluate_object(adev->handle, method, NULL, NULL); in acpi_dev_pm_explicit_set()
149 return -ENODEV; in acpi_dev_pm_explicit_set()
155 * acpi_device_set_power - Set power state of an ACPI device.
156 * @device: Device to set the power state of.
159 * Callers must ensure that the device is power manageable before using this
162 int acpi_device_set_power(struct acpi_device *device, int state) in acpi_device_set_power() argument
167 if (!device || !device->flags.power_manageable in acpi_device_set_power()
169 return -EINVAL; in acpi_device_set_power()
171 acpi_handle_debug(device->handle, "Power state change: %s -> %s\n", in acpi_device_set_power()
172 acpi_power_state_string(device->power.state), in acpi_device_set_power()
178 if (state > ACPI_STATE_D0 && state == device->power.state) in acpi_device_set_power()
188 if (!device->power.states[ACPI_STATE_D3_COLD].flags.valid) in acpi_device_set_power()
190 } else if (!device->power.states[state].flags.valid) { in acpi_device_set_power()
191 acpi_handle_debug(device->handle, "Power state %s not supported\n", in acpi_device_set_power()
193 return -ENODEV; in acpi_device_set_power()
196 if (!device->power.flags.ignore_parent) { in acpi_device_set_power()
199 parent = acpi_dev_parent(device); in acpi_device_set_power()
200 if (parent && state < parent->power.state) { in acpi_device_set_power()
201 acpi_handle_debug(device->handle, in acpi_device_set_power()
204 acpi_power_state_string(parent->power.state)); in acpi_device_set_power()
205 return -ENODEV; in acpi_device_set_power()
211 * ---------------- in acpi_device_set_power()
218 * According to ACPI 6, devices cannot go from lower-power in acpi_device_set_power()
219 * (deeper) states to higher-power (shallower) states. in acpi_device_set_power()
221 if (state < device->power.state) { in acpi_device_set_power()
222 acpi_handle_debug(device->handle, in acpi_device_set_power()
224 acpi_power_state_string(device->power.state), in acpi_device_set_power()
226 return -ENODEV; in acpi_device_set_power()
230 * If the device goes from D3hot to D3cold, _PS3 has been in acpi_device_set_power()
233 if (device->power.state < ACPI_STATE_D3_HOT) { in acpi_device_set_power()
234 result = acpi_dev_pm_explicit_set(device, state); in acpi_device_set_power()
239 if (device->power.flags.power_resources) in acpi_device_set_power()
240 result = acpi_power_transition(device, target_state); in acpi_device_set_power()
242 int cur_state = device->power.state; in acpi_device_set_power()
244 if (device->power.flags.power_resources) { in acpi_device_set_power()
245 result = acpi_power_transition(device, ACPI_STATE_D0); in acpi_device_set_power()
254 if (!device->power.flags.explicit_get) in acpi_device_set_power()
258 * The power state of the device was set to D0 last in acpi_device_set_power()
260 * system-wide transition involving the platform in acpi_device_set_power()
262 * for the device here. However, use extra care here in acpi_device_set_power()
263 * and evaluate _PSC to check the device's current power in acpi_device_set_power()
268 result = acpi_dev_pm_explicit_get(device, &psc); in acpi_device_set_power()
273 result = acpi_dev_pm_explicit_set(device, ACPI_STATE_D0); in acpi_device_set_power()
278 acpi_handle_debug(device->handle, in acpi_device_set_power()
282 device->power.state = target_state; in acpi_device_set_power()
283 acpi_handle_debug(device->handle, "Power state changed to %s\n", in acpi_device_set_power()
290 acpi_handle_debug(device->handle, "Already in %s\n", in acpi_device_set_power()
296 int acpi_bus_set_power(acpi_handle handle, int state) in acpi_bus_set_power() argument
298 struct acpi_device *device = acpi_fetch_acpi_dev(handle); in acpi_bus_set_power() local
300 if (device) in acpi_bus_set_power()
301 return acpi_device_set_power(device, state); in acpi_bus_set_power()
303 return -ENODEV; in acpi_bus_set_power()
307 int acpi_bus_init_power(struct acpi_device *device) in acpi_bus_init_power() argument
312 if (!device) in acpi_bus_init_power()
313 return -EINVAL; in acpi_bus_init_power()
315 device->power.state = ACPI_STATE_UNKNOWN; in acpi_bus_init_power()
316 if (!acpi_device_is_present(device)) { in acpi_bus_init_power()
317 device->flags.initialized = false; in acpi_bus_init_power()
318 return -ENXIO; in acpi_bus_init_power()
321 result = acpi_device_get_power(device, &state); in acpi_bus_init_power()
325 if (state < ACPI_STATE_D3_COLD && device->power.flags.power_resources) { in acpi_bus_init_power()
327 result = acpi_power_on_resources(device, state); in acpi_bus_init_power()
336 * another device using the same power resources may in acpi_bus_init_power()
340 result = acpi_dev_pm_explicit_set(device, state); in acpi_bus_init_power()
347 * it D0 in hope that this is what the BIOS put the device into. in acpi_bus_init_power()
349 * Toshiba P870-303 in a nasty way.] in acpi_bus_init_power()
353 device->power.state = state; in acpi_bus_init_power()
358 * acpi_device_fix_up_power - Force device with missing _PSC into D0.
359 * @device: Device object whose power state is to be fixed up.
365 int acpi_device_fix_up_power(struct acpi_device *device) in acpi_device_fix_up_power() argument
369 if (!device->power.flags.power_resources in acpi_device_fix_up_power()
370 && !device->power.flags.explicit_get in acpi_device_fix_up_power()
371 && device->power.state == ACPI_STATE_D0) in acpi_device_fix_up_power()
372 ret = acpi_dev_pm_explicit_set(device, ACPI_STATE_D0); in acpi_device_fix_up_power()
380 if (adev->status.present && adev->status.enabled) in fix_up_power_if_applicable()
387 * acpi_device_fix_up_power_extended - Force device and its children into D0.
388 * @adev: Parent device object whose power state is to be fixed up.
401 * acpi_device_fix_up_power_children - Force a device's children into D0.
402 * @adev: Parent device object whose children's power state is to be fixed up.
413 int acpi_device_update_power(struct acpi_device *device, int *state_p) in acpi_device_update_power() argument
418 if (device->power.state == ACPI_STATE_UNKNOWN) { in acpi_device_update_power()
419 result = acpi_bus_init_power(device); in acpi_device_update_power()
421 *state_p = device->power.state; in acpi_device_update_power()
426 result = acpi_device_get_power(device, &state); in acpi_device_update_power()
432 result = acpi_device_set_power(device, state); in acpi_device_update_power()
436 if (device->power.flags.power_resources) { in acpi_device_update_power()
441 result = acpi_power_transition(device, state); in acpi_device_update_power()
445 device->power.state = state; in acpi_device_update_power()
454 int acpi_bus_update_power(acpi_handle handle, int *state_p) in acpi_bus_update_power() argument
456 struct acpi_device *device = acpi_fetch_acpi_dev(handle); in acpi_bus_update_power() local
458 if (device) in acpi_bus_update_power()
459 return acpi_device_update_power(device, state_p); in acpi_bus_update_power()
461 return -ENODEV; in acpi_bus_update_power()
465 bool acpi_bus_power_manageable(acpi_handle handle) in acpi_bus_power_manageable() argument
467 struct acpi_device *device = acpi_fetch_acpi_dev(handle); in acpi_bus_power_manageable() local
469 return device && device->flags.power_manageable; in acpi_bus_power_manageable()
475 if (!(adev->flags.power_manageable && adev->pnp.type.bus_address)) in acpi_power_up_if_adr_present()
478 acpi_handle_debug(adev->handle, "Power state: %s\n", in acpi_power_up_if_adr_present()
479 acpi_power_state_string(adev->power.state)); in acpi_power_up_if_adr_present()
481 if (adev->power.state == ACPI_STATE_D3_COLD) in acpi_power_up_if_adr_present()
488 * acpi_dev_power_up_children_with_adr - Power up childres with valid _ADR
489 * @adev: Parent ACPI device object.
501 * acpi_dev_power_state_for_wake - Deepest power state for wakeup signaling
502 * @adev: ACPI companion of the target device.
512 status = acpi_evaluate_integer(adev->handle, "_S0W", NULL, &state); in acpi_dev_power_state_for_wake()
523 void acpi_pm_wakeup_event(struct device *dev) in acpi_pm_wakeup_event()
529 static void acpi_pm_notify_handler(acpi_handle handle, u32 val, void *not_used) in acpi_pm_notify_handler() argument
536 acpi_handle_debug(handle, "Wake notify\n"); in acpi_pm_notify_handler()
538 adev = acpi_get_acpi_dev(handle); in acpi_pm_notify_handler()
544 if (adev->wakeup.flags.notifier_present) { in acpi_pm_notify_handler()
545 pm_wakeup_ws_event(adev->wakeup.ws, 0, acpi_s2idle_wakeup()); in acpi_pm_notify_handler()
546 if (adev->wakeup.context.func) { in acpi_pm_notify_handler()
547 acpi_handle_debug(handle, "Running %pS for %s\n", in acpi_pm_notify_handler()
548 adev->wakeup.context.func, in acpi_pm_notify_handler()
549 dev_name(adev->wakeup.context.dev)); in acpi_pm_notify_handler()
550 adev->wakeup.context.func(&adev->wakeup.context); in acpi_pm_notify_handler()
560 * acpi_add_pm_notifier - Register PM notify handler for given ACPI device.
561 * @adev: ACPI device to add the notify handler for.
562 * @dev: Device to generate a wakeup event for while handling the notification.
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, in acpi_add_pm_notifier()
580 if (adev->wakeup.flags.notifier_present) in acpi_add_pm_notifier()
583 status = acpi_install_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY, in acpi_add_pm_notifier()
589 adev->wakeup.ws = wakeup_source_register(&adev->dev, in acpi_add_pm_notifier()
590 dev_name(&adev->dev)); in acpi_add_pm_notifier()
591 adev->wakeup.context.dev = dev; in acpi_add_pm_notifier()
592 adev->wakeup.context.func = func; in acpi_add_pm_notifier()
593 adev->wakeup.flags.notifier_present = true; in acpi_add_pm_notifier()
602 * acpi_remove_pm_notifier - Unregister PM notifier from given ACPI device.
603 * @adev: ACPI device to remove the notifier from.
611 if (!adev->wakeup.flags.notifier_present) in acpi_remove_pm_notifier()
614 status = acpi_remove_notify_handler(adev->handle, in acpi_remove_pm_notifier()
621 adev->wakeup.context.func = NULL; in acpi_remove_pm_notifier()
622 adev->wakeup.context.dev = NULL; in acpi_remove_pm_notifier()
623 wakeup_source_unregister(adev->wakeup.ws); in acpi_remove_pm_notifier()
624 adev->wakeup.flags.notifier_present = false; in acpi_remove_pm_notifier()
632 bool acpi_bus_can_wakeup(acpi_handle handle) in acpi_bus_can_wakeup() argument
634 struct acpi_device *device = acpi_fetch_acpi_dev(handle); in acpi_bus_can_wakeup() local
636 return device && device->wakeup.flags.valid; in acpi_bus_can_wakeup()
640 bool acpi_pm_device_can_wakeup(struct device *dev) in acpi_pm_device_can_wakeup()
648 * acpi_dev_pm_get_state - Get preferred power state of ACPI device.
649 * @dev: Device whose preferred target power state to return.
650 * @adev: ACPI device node corresponding to @dev.
651 * @target_state: System state to match the resultant device state.
652 * @d_min_p: Location to store the highest power state available to the device.
653 * @d_max_p: Location to store the lowest power state available to the device.
656 * device power states that the device can be in while the system is in the
664 * Returns 0 on success or -ENODATA when one of the ACPI methods fails or
668 static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev, in acpi_dev_pm_get_state()
672 acpi_handle handle = adev->handle; in acpi_dev_pm_get_state() local
680 * If the system state is S0, the lowest power state the device can be in acpi_dev_pm_get_state()
681 * in is D3cold, unless the device has _S0W and is supposed to signal in acpi_dev_pm_get_state()
683 * lowest power state available to the device. in acpi_dev_pm_get_state()
689 * If present, _SxD methods return the minimum D-state (highest power in acpi_dev_pm_get_state()
690 * state) we can use for the corresponding S-states. Otherwise, the in acpi_dev_pm_get_state()
691 * minimum D-state is D0 (ACPI 3.x). in acpi_dev_pm_get_state()
699 status = acpi_evaluate_integer(handle, method, NULL, &ret); in acpi_dev_pm_get_state()
702 return -ENODATA; in acpi_dev_pm_get_state()
705 * We need to handle legacy systems where D3hot and D3cold are in acpi_dev_pm_get_state()
709 if (!adev->power.states[ret].flags.valid) { in acpi_dev_pm_get_state()
713 return -ENODATA; in acpi_dev_pm_get_state()
720 wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid in acpi_dev_pm_get_state()
721 && adev->wakeup.sleep_state >= target_state; in acpi_dev_pm_get_state()
722 } else if (device_may_wakeup(dev) && dev->power.wakeirq) { in acpi_dev_pm_get_state()
730 * If a device has a wake IRQ attached we need to check the in acpi_dev_pm_get_state()
731 * _S0W method to get the correct wake D-state. Otherwise we in acpi_dev_pm_get_state()
732 * end up putting the device into D3Cold which will more than in acpi_dev_pm_get_state()
738 wakeup = adev->wakeup.flags.valid; in acpi_dev_pm_get_state()
743 * the D-state returned by _SxD is sufficient for that (we assume a in acpi_dev_pm_get_state()
744 * wakeup-aware driver if wake is set). Still, if _SxW exists in acpi_dev_pm_get_state()
745 * (ACPI 3.x), it should return the maximum (lowest power) D-state that in acpi_dev_pm_get_state()
750 status = acpi_evaluate_integer(handle, method, NULL, &ret); in acpi_dev_pm_get_state()
760 if (!adev->power.states[ret].flags.valid) in acpi_dev_pm_get_state()
765 return -ENODATA; in acpi_dev_pm_get_state()
779 * acpi_pm_device_sleep_state - Get preferred power state of ACPI device.
780 * @dev: Device whose preferred target power state to return.
782 * @d_max_in: Deepest low-power state to take into consideration.
783 * Return value: Preferred power state of the device on success, -ENODEV
784 * if there's no 'struct acpi_device' for @dev, -EINVAL if @d_max_in is
785 * incorrect, or -ENODATA on ACPI method failure.
789 int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in) in acpi_pm_device_sleep_state()
795 return -EINVAL; in acpi_pm_device_sleep_state()
808 return -ENODEV; in acpi_pm_device_sleep_state()
817 return -EINVAL; in acpi_pm_device_sleep_state()
820 for (d_max = d_max_in; d_max > d_min; d_max--) { in acpi_pm_device_sleep_state()
821 if (adev->power.states[d_max].flags.valid) in acpi_pm_device_sleep_state()
834 * acpi_pm_notify_work_func - ACPI devices wakeup notification work function.
835 * @context: Device wakeup context.
839 struct device *dev = context->dev; in acpi_pm_notify_work_func()
852 struct acpi_device_wakeup *wakeup = &adev->wakeup; in __acpi_device_wakeup_enable()
859 * If the device wakeup power is already enabled, disable it and enable in __acpi_device_wakeup_enable()
864 if (wakeup->enable_count > 0) in __acpi_device_wakeup_enable()
869 if (wakeup->enable_count > 0) { in __acpi_device_wakeup_enable()
870 acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); in __acpi_device_wakeup_enable()
871 wakeup->enable_count = 0; in __acpi_device_wakeup_enable()
876 if (wakeup->enable_count > 0) in __acpi_device_wakeup_enable()
879 status = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number); in __acpi_device_wakeup_enable()
882 error = -EIO; in __acpi_device_wakeup_enable()
886 acpi_handle_debug(adev->handle, "GPE%2X enabled for wakeup\n", in __acpi_device_wakeup_enable()
887 (unsigned int)wakeup->gpe_number); in __acpi_device_wakeup_enable()
890 if (wakeup->enable_count < INT_MAX) in __acpi_device_wakeup_enable()
891 wakeup->enable_count++; in __acpi_device_wakeup_enable()
893 acpi_handle_info(adev->handle, "Wakeup enable count out of bounds!\n"); in __acpi_device_wakeup_enable()
901 * acpi_device_wakeup_enable - Enable wakeup functionality for device.
902 * @adev: ACPI device to enable wakeup functionality for.
906 * for the device in response to external (remote) events and enable wakeup
909 * Callers must ensure that @adev is a valid ACPI device node before executing
918 * acpi_device_wakeup_disable - Disable wakeup functionality for device.
919 * @adev: ACPI device to disable wakeup functionality for.
923 * Callers must ensure that @adev is a valid ACPI device node before executing
928 struct acpi_device_wakeup *wakeup = &adev->wakeup; in acpi_device_wakeup_disable()
932 if (!wakeup->enable_count) in acpi_device_wakeup_disable()
935 acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); in acpi_device_wakeup_disable()
938 wakeup->enable_count--; in acpi_device_wakeup_disable()
945 * acpi_pm_set_device_wakeup - Enable/disable remote wakeup for given device.
946 * @dev: Device to enable/disable to generate wakeup events.
949 int acpi_pm_set_device_wakeup(struct device *dev, bool enable) in acpi_pm_set_device_wakeup()
957 return -ENODEV; in acpi_pm_set_device_wakeup()
961 return -EINVAL; in acpi_pm_set_device_wakeup()
978 * acpi_dev_pm_low_power - Put ACPI device into a low-power state.
979 * @dev: Device to put into a low-power state.
980 * @adev: ACPI device node corresponding to @dev.
981 * @system_state: System state to choose the device state for.
983 static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev, in acpi_dev_pm_low_power()
996 * acpi_dev_pm_full_power - Put ACPI device into the full-power state.
997 * @adev: ACPI device node to put into the full-power state.
1006 * acpi_dev_suspend - Put device into a low-power state using ACPI.
1007 * @dev: Device to put into a low-power state.
1008 * @wakeup: Whether or not to enable wakeup for the device.
1010 * Put the given device into a low-power state using the standard ACPI
1012 * device into (this checks if remote wakeup is expected to work too), and set
1013 * the power state of the device.
1015 int acpi_dev_suspend(struct device *dev, bool wakeup) in acpi_dev_suspend()
1027 return -EAGAIN; in acpi_dev_suspend()
1041 * acpi_dev_resume - Put device into the full-power state using ACPI.
1042 * @dev: Device to put into the full-power state.
1044 * Put the given device into the full-power state using the standard ACPI
1045 * mechanism. Set the power state of the device to ACPI D0 and disable wakeup.
1047 int acpi_dev_resume(struct device *dev) in acpi_dev_resume()
1062 * acpi_subsys_runtime_suspend - Suspend device using ACPI.
1063 * @dev: Device to suspend.
1066 * it into a runtime low-power state.
1068 int acpi_subsys_runtime_suspend(struct device *dev) in acpi_subsys_runtime_suspend()
1077 * acpi_subsys_runtime_resume - Resume device using ACPI.
1078 * @dev: Device to Resume.
1080 * Use ACPI to put the given device into the full-power state and carry out the
1083 int acpi_subsys_runtime_resume(struct device *dev) in acpi_subsys_runtime_resume()
1092 static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev) in acpi_dev_needs_resume()
1097 if (!pm_runtime_suspended(dev) || !adev || (adev->wakeup.flags.valid && in acpi_dev_needs_resume()
1098 device_may_wakeup(dev) != !!adev->wakeup.prepare_count)) in acpi_dev_needs_resume()
1104 if (adev->power.flags.dsw_present) in acpi_dev_needs_resume()
1111 return state != adev->power.state; in acpi_dev_needs_resume()
1115 * acpi_subsys_prepare - Prepare device for system transition to a sleep state.
1116 * @dev: Device to prepare.
1118 int acpi_subsys_prepare(struct device *dev) in acpi_subsys_prepare()
1122 if (dev->driver && dev->driver->pm && dev->driver->pm->prepare) { in acpi_subsys_prepare()
1123 int ret = dev->driver->pm->prepare(dev); in acpi_subsys_prepare()
1137 * acpi_subsys_complete - Finalize device's resume during system resume.
1138 * @dev: Device to handle.
1140 void acpi_subsys_complete(struct device *dev) in acpi_subsys_complete()
1144 * If the device had been runtime-suspended before the system went into in acpi_subsys_complete()
1154 * acpi_subsys_suspend - Run the device driver's suspend callback.
1155 * @dev: Device to handle.
1158 * system suspend callbacks, unless the driver can cope with runtime-suspended
1159 * devices during system suspend and there are no ACPI-specific reasons for
1162 int acpi_subsys_suspend(struct device *dev) in acpi_subsys_suspend()
1173 * acpi_subsys_suspend_late - Suspend device using ACPI.
1174 * @dev: Device to suspend.
1177 * it into a low-power state during system transition into a sleep state.
1179 int acpi_subsys_suspend_late(struct device *dev) in acpi_subsys_suspend_late()
1192 * acpi_subsys_suspend_noirq - Run the device driver's "noirq" suspend callback.
1193 * @dev: Device to suspend.
1195 int acpi_subsys_suspend_noirq(struct device *dev) in acpi_subsys_suspend_noirq()
1207 * If the target system sleep state is suspend-to-idle, it is sufficient in acpi_subsys_suspend_noirq()
1208 * to check whether or not the device's wakeup settings are good for in acpi_subsys_suspend_noirq()
1210 * acpi_subsys_complete() to take care of fixing up the device's state in acpi_subsys_suspend_noirq()
1214 dev->power.may_skip_resume = false; in acpi_subsys_suspend_noirq()
1221 * acpi_subsys_resume_noirq - Run the device driver's "noirq" resume callback.
1222 * @dev: Device to handle.
1224 static int acpi_subsys_resume_noirq(struct device *dev) in acpi_subsys_resume_noirq()
1233 * acpi_subsys_resume_early - Resume device using ACPI.
1234 * @dev: Device to Resume.
1236 * Use ACPI to put the given device into the full-power state and carry out the
1238 * working state, but only do that if device either defines early resume
1240 * of the device is postponed to the normal resume phase.
1242 static int acpi_subsys_resume_early(struct device *dev) in acpi_subsys_resume_early()
1244 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; in acpi_subsys_resume_early()
1250 if (pm && !pm->resume_early) { in acpi_subsys_resume_early()
1260 * acpi_subsys_resume - Resume device using ACPI.
1261 * @dev: Device to Resume.
1263 * Use ACPI to put the given device into the full-power state if it has not been
1267 static int acpi_subsys_resume(struct device *dev) in acpi_subsys_resume()
1269 const struct dev_pm_ops *pm = dev->driver ? dev->driver->pm : NULL; in acpi_subsys_resume()
1272 if (!dev_pm_skip_resume(dev) && pm && !pm->resume_early) { in acpi_subsys_resume()
1281 * acpi_subsys_freeze - Run the device driver's freeze callback.
1282 * @dev: Device to handle.
1284 int acpi_subsys_freeze(struct device *dev) in acpi_subsys_freeze()
1287 * Resume all runtime-suspended devices before creating a snapshot in acpi_subsys_freeze()
1289 * be expected to always handle them consistently and they need to be in acpi_subsys_freeze()
1290 * put into the runtime-active metastate during system resume anyway, in acpi_subsys_freeze()
1301 * acpi_subsys_restore_early - Restore device using ACPI.
1302 * @dev: Device to restore.
1304 int acpi_subsys_restore_early(struct device *dev) in acpi_subsys_restore_early()
1313 * acpi_subsys_poweroff - Run the device driver's poweroff callback.
1314 * @dev: Device to handle.
1317 * system poweroff callbacks, unless the driver can cope with runtime-suspended
1318 * devices during system suspend and there are no ACPI-specific reasons for
1321 int acpi_subsys_poweroff(struct device *dev) in acpi_subsys_poweroff()
1332 * acpi_subsys_poweroff_late - Run the device driver's poweroff callback.
1333 * @dev: Device to handle.
1336 * it into a low-power state during system transition into a sleep state.
1338 static int acpi_subsys_poweroff_late(struct device *dev) in acpi_subsys_poweroff_late()
1353 * acpi_subsys_poweroff_noirq - Run the driver's "noirq" poweroff callback.
1354 * @dev: Device to suspend.
1356 static int acpi_subsys_poweroff_noirq(struct device *dev) in acpi_subsys_poweroff_noirq()
1388 * acpi_dev_pm_detach - Remove ACPI power management from the device.
1389 * @dev: Device to take care of.
1390 * @power_off: Whether or not to try to remove power from the device.
1392 * Remove the device from the general ACPI PM domain and remove its wakeup
1393 * notifier. If @power_off is set, additionally remove power from the device if
1399 static void acpi_dev_pm_detach(struct device *dev, bool power_off) in acpi_dev_pm_detach()
1403 if (adev && dev->pm_domain == &acpi_general_pm_domain) { in acpi_dev_pm_detach()
1408 * If the device's PM QoS resume latency limit or flags in acpi_dev_pm_detach()
1411 * choice of the low-power state to put the device into. in acpi_dev_pm_detach()
1422 * acpi_dev_pm_attach - Prepare device for ACPI power management.
1423 * @dev: Device to prepare.
1424 * @power_on: Whether or not to power on the device.
1426 * If @dev has a valid ACPI handle that has a valid struct acpi_device object
1427 * attached to it, install a wakeup notification handler for the device and
1428 * add it to the general ACPI PM domain. If @power_on is set, the device will
1437 int acpi_dev_pm_attach(struct device *dev, bool power_on) in acpi_dev_pm_attach()
1440 * Skip devices whose ACPI companions match the device IDs below, in acpi_dev_pm_attach()
1454 * Only attach the power domain to the first device if the in acpi_dev_pm_attach()
1468 dev->pm_domain->detach = acpi_dev_pm_detach; in acpi_dev_pm_attach()
1474 * acpi_storage_d3 - Check if D3 should be used in the suspend path
1475 * @dev: Device to check
1484 * applied to the PCIe slot and plugging in a non-storage device the
1487 bool acpi_storage_d3(struct device *dev) in acpi_storage_d3()
1505 * acpi_dev_state_d0 - Tell if the device is in D0 power state
1506 * @dev: Physical device the ACPI power state of which to check
1509 * the current ACPI power state of the device is D0, or false otherwise.
1511 * Note that the power state of a device is not well-defined after it has been
1513 * not valid to ask for the ACPI power state of the device in that time frame.
1516 * function. See Documentation/firmware-guide/acpi/non-d0-probe.rst for
1519 bool acpi_dev_state_d0(struct device *dev) in acpi_dev_state_d0()
1526 return adev->power.state == ACPI_STATE_D0; in acpi_dev_state_d0()