Lines Matching +full:low +full:- +full:power +full:- +full:disable
2 * drivers/acpi/device_pm.c - ACPI device power management routines.
35 * acpi_power_state_string - String representation of ACPI device power state.
36 * @state: ACPI device power state to return the string representation of.
57 * acpi_device_get_power - Get power state of an ACPI device.
58 * @device: Device to get the power state of.
59 * @state: Place to store the power state of the device.
61 * This function does not update the device's power.state field, but it may
62 * update its parent's power.state field (when the parent's power state is
63 * unknown and the device's power state turns out to be D0).
70 return -EINVAL; in acpi_device_get_power()
72 if (!device->flags.power_manageable) { in acpi_device_get_power()
73 /* TBD: Non-recursive algorithm for walking up hierarchy. */ in acpi_device_get_power()
74 *state = device->parent ? in acpi_device_get_power()
75 device->parent->power.state : ACPI_STATE_D0; in acpi_device_get_power()
80 * Get the device's power state from power resources settings and _PSC, in acpi_device_get_power()
83 if (device->power.flags.power_resources) { in acpi_device_get_power()
88 if (device->power.flags.explicit_get) { in acpi_device_get_power()
89 acpi_handle handle = device->handle; in acpi_device_get_power()
95 return -ENODEV; in acpi_device_get_power()
98 * The power resources settings may indicate a power state in acpi_device_get_power()
99 * shallower than the actual power state of the device, because in acpi_device_get_power()
100 * the same power resources may be referenced by other devices. in acpi_device_get_power()
112 * If we were unsure about the device parent's power state up to this in acpi_device_get_power()
116 if (!device->power.flags.ignore_parent && device->parent in acpi_device_get_power()
117 && device->parent->power.state == ACPI_STATE_UNKNOWN in acpi_device_get_power()
119 device->parent->power.state = ACPI_STATE_D0; in acpi_device_get_power()
124 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is %s\n", in acpi_device_get_power()
125 device->pnp.bus_id, acpi_power_state_string(*state))); in acpi_device_get_power()
132 if (adev->power.states[state].flags.explicit_set) { in acpi_dev_pm_explicit_set()
136 status = acpi_evaluate_object(adev->handle, method, NULL, NULL); in acpi_dev_pm_explicit_set()
138 return -ENODEV; in acpi_dev_pm_explicit_set()
144 * acpi_device_set_power - Set power state of an ACPI device.
145 * @device: Device to set the power state of.
146 * @state: New power state to set.
148 * Callers must ensure that the device is power manageable before using this
156 if (!device || !device->flags.power_manageable in acpi_device_set_power()
158 return -EINVAL; in acpi_device_set_power()
162 if (state == device->power.state) { in acpi_device_set_power()
164 device->pnp.bus_id, in acpi_device_set_power()
172 * possibly drop references to the power resources in use. in acpi_device_set_power()
176 if (!device->power.states[ACPI_STATE_D3_COLD].flags.valid) in acpi_device_set_power()
178 } else if (!device->power.states[state].flags.valid) { in acpi_device_set_power()
179 dev_warn(&device->dev, "Power state %s not supported\n", in acpi_device_set_power()
181 return -ENODEV; in acpi_device_set_power()
184 if (!device->power.flags.ignore_parent && in acpi_device_set_power()
185 device->parent && (state < device->parent->power.state)) { in acpi_device_set_power()
186 dev_warn(&device->dev, in acpi_device_set_power()
187 "Cannot transition to power state %s for parent in %s\n", in acpi_device_set_power()
189 acpi_power_state_string(device->parent->power.state)); in acpi_device_set_power()
190 return -ENODEV; in acpi_device_set_power()
194 * Transition Power in acpi_device_set_power()
195 * ---------------- in acpi_device_set_power()
196 * In accordance with ACPI 6, _PSx is executed before manipulating power in acpi_device_set_power()
198 * supposed to be executed after turning the power resources on. in acpi_device_set_power()
202 * According to ACPI 6, devices cannot go from lower-power in acpi_device_set_power()
203 * (deeper) states to higher-power (shallower) states. in acpi_device_set_power()
205 if (state < device->power.state) { in acpi_device_set_power()
206 dev_warn(&device->dev, "Cannot transition from %s to %s\n", in acpi_device_set_power()
207 acpi_power_state_string(device->power.state), in acpi_device_set_power()
209 return -ENODEV; in acpi_device_set_power()
216 if (device->power.flags.power_resources) in acpi_device_set_power()
219 if (device->power.flags.power_resources) { in acpi_device_set_power()
229 dev_warn(&device->dev, "Failed to change power state to %s\n", in acpi_device_set_power()
232 device->power.state = target_state; in acpi_device_set_power()
235 device->pnp.bus_id, in acpi_device_set_power()
262 return -EINVAL; in acpi_bus_init_power()
264 device->power.state = ACPI_STATE_UNKNOWN; in acpi_bus_init_power()
266 device->flags.initialized = false; in acpi_bus_init_power()
267 return -ENXIO; in acpi_bus_init_power()
274 if (state < ACPI_STATE_D3_COLD && device->power.flags.power_resources) { in acpi_bus_init_power()
275 /* Reference count the power resources. */ in acpi_bus_init_power()
283 * power resources appears to be D0, it still may be in acpi_bus_init_power()
285 * another device using the same power resources may in acpi_bus_init_power()
295 * No power resources and missing _PSC? Cross fingers and make in acpi_bus_init_power()
298 * Toshiba P870-303 in a nasty way.] in acpi_bus_init_power()
302 device->power.state = state; in acpi_bus_init_power()
307 * acpi_device_fix_up_power - Force device with missing _PSC into D0.
308 * @device: Device object whose power state is to be fixed up.
310 * Devices without power resources and _PSC, but having _PS0 and _PS3 defined,
318 if (!device->power.flags.power_resources in acpi_device_fix_up_power()
319 && !device->power.flags.explicit_get in acpi_device_fix_up_power()
320 && device->power.state == ACPI_STATE_D0) in acpi_device_fix_up_power()
332 if (device->power.state == ACPI_STATE_UNKNOWN) { in acpi_device_update_power()
335 *state_p = device->power.state; in acpi_device_update_power()
350 if (device->power.flags.power_resources) { in acpi_device_update_power()
353 * to update the power resources' reference counters. in acpi_device_update_power()
359 device->power.state = state; in acpi_device_update_power()
384 return result ? false : device->flags.power_manageable; in acpi_bus_power_manageable()
413 if (adev->wakeup.flags.notifier_present) { in acpi_pm_notify_handler()
414 pm_wakeup_ws_event(adev->wakeup.ws, 0, acpi_s2idle_wakeup()); in acpi_pm_notify_handler()
415 if (adev->wakeup.context.func) { in acpi_pm_notify_handler()
417 adev->wakeup.context.func, in acpi_pm_notify_handler()
418 dev_name(adev->wakeup.context.dev)); in acpi_pm_notify_handler()
419 adev->wakeup.context.func(&adev->wakeup.context); in acpi_pm_notify_handler()
429 * acpi_add_pm_notifier - Register PM notify handler for given ACPI device.
434 * NOTE: @adev need not be a run-wake or wakeup device to be a valid source of
449 if (adev->wakeup.flags.notifier_present) in acpi_add_pm_notifier()
452 status = acpi_install_notify_handler(adev->handle, ACPI_SYSTEM_NOTIFY, in acpi_add_pm_notifier()
458 adev->wakeup.ws = wakeup_source_register(dev_name(&adev->dev)); in acpi_add_pm_notifier()
459 adev->wakeup.context.dev = dev; in acpi_add_pm_notifier()
460 adev->wakeup.context.func = func; in acpi_add_pm_notifier()
461 adev->wakeup.flags.notifier_present = true; in acpi_add_pm_notifier()
470 * acpi_remove_pm_notifier - Unregister PM notifier from given ACPI device.
479 if (!adev->wakeup.flags.notifier_present) in acpi_remove_pm_notifier()
482 status = acpi_remove_notify_handler(adev->handle, in acpi_remove_pm_notifier()
489 adev->wakeup.context.func = NULL; in acpi_remove_pm_notifier()
490 adev->wakeup.context.dev = NULL; in acpi_remove_pm_notifier()
491 wakeup_source_unregister(adev->wakeup.ws); in acpi_remove_pm_notifier()
492 adev->wakeup.flags.notifier_present = false; in acpi_remove_pm_notifier()
506 return result ? false : device->wakeup.flags.valid; in acpi_bus_can_wakeup()
518 * acpi_dev_pm_get_state - Get preferred power state of ACPI device.
519 * @dev: Device whose preferred target power state to return.
522 * @d_min_p: Location to store the highest power state available to the device.
523 * @d_max_p: Location to store the lowest power state available to the device.
525 * Find the lowest power (highest number) and highest power (lowest number) ACPI
526 * device power states that the device can be in while the system is in the
534 * Returns 0 on success or -ENODATA when one of the ACPI methods fails or
542 acpi_handle handle = adev->handle; in acpi_dev_pm_get_state()
550 * If the system state is S0, the lowest power state the device can be in acpi_dev_pm_get_state()
553 * lowest power state available to the device. in acpi_dev_pm_get_state()
559 * If present, _SxD methods return the minimum D-state (highest power in acpi_dev_pm_get_state()
560 * state) we can use for the corresponding S-states. Otherwise, the in acpi_dev_pm_get_state()
561 * minimum D-state is D0 (ACPI 3.x). in acpi_dev_pm_get_state()
572 return -ENODATA; in acpi_dev_pm_get_state()
579 if (!adev->power.states[ret].flags.valid) { in acpi_dev_pm_get_state()
583 return -ENODATA; in acpi_dev_pm_get_state()
590 wakeup = device_may_wakeup(dev) && adev->wakeup.flags.valid in acpi_dev_pm_get_state()
591 && adev->wakeup.sleep_state >= target_state; in acpi_dev_pm_get_state()
593 wakeup = adev->wakeup.flags.valid; in acpi_dev_pm_get_state()
598 * the D-state returned by _SxD is sufficient for that (we assume a in acpi_dev_pm_get_state()
599 * wakeup-aware driver if wake is set). Still, if _SxW exists in acpi_dev_pm_get_state()
600 * (ACPI 3.x), it should return the maximum (lowest power) D-state that in acpi_dev_pm_get_state()
608 * must not go into any power state deeper than the in acpi_dev_pm_get_state()
615 if (!adev->power.states[ret].flags.valid) in acpi_dev_pm_get_state()
620 return -ENODATA; in acpi_dev_pm_get_state()
634 * acpi_pm_device_sleep_state - Get preferred power state of ACPI device.
635 * @dev: Device whose preferred target power state to return.
637 * @d_max_in: Deepest low-power state to take into consideration.
638 * Return value: Preferred power state of the device on success, -ENODEV
639 * if there's no 'struct acpi_device' for @dev, -EINVAL if @d_max_in is
640 * incorrect, or -ENODATA on ACPI method failure.
650 return -EINVAL; in acpi_pm_device_sleep_state()
663 return -ENODEV; in acpi_pm_device_sleep_state()
672 return -EINVAL; in acpi_pm_device_sleep_state()
675 for (d_max = d_max_in; d_max > d_min; d_max--) { in acpi_pm_device_sleep_state()
676 if (adev->power.states[d_max].flags.valid) in acpi_pm_device_sleep_state()
689 * acpi_pm_notify_work_func - ACPI devices wakeup notification work function.
694 struct device *dev = context->dev; in acpi_pm_notify_work_func()
707 struct acpi_device_wakeup *wakeup = &adev->wakeup; in __acpi_device_wakeup_enable()
713 if (wakeup->enable_count >= max_count) in __acpi_device_wakeup_enable()
716 if (wakeup->enable_count > 0) in __acpi_device_wakeup_enable()
723 status = acpi_enable_gpe(wakeup->gpe_device, wakeup->gpe_number); in __acpi_device_wakeup_enable()
726 error = -EIO; in __acpi_device_wakeup_enable()
731 wakeup->enable_count++; in __acpi_device_wakeup_enable()
739 * acpi_device_wakeup_enable - Enable wakeup functionality for device.
745 * power for it.
756 * acpi_device_wakeup_disable - Disable wakeup functionality for device.
757 * @adev: ACPI device to disable wakeup functionality for.
759 * Disable the GPE associated with @adev and disable wakeup power for it.
766 struct acpi_device_wakeup *wakeup = &adev->wakeup; in acpi_device_wakeup_disable()
770 if (!wakeup->enable_count) in acpi_device_wakeup_disable()
773 acpi_disable_gpe(wakeup->gpe_device, wakeup->gpe_number); in acpi_device_wakeup_disable()
776 wakeup->enable_count--; in acpi_device_wakeup_disable()
791 return -ENODEV; in __acpi_pm_set_device_wakeup()
795 return -EINVAL; in __acpi_pm_set_device_wakeup()
812 * acpi_pm_set_device_wakeup - Enable/disable remote wakeup for given device.
813 * @dev: Device to enable/disable to generate wakeup events.
814 * @enable: Whether to enable or disable the wakeup functionality.
823 * acpi_pm_set_bridge_wakeup - Enable/disable remote wakeup for given bridge.
824 * @dev: Bridge device to enable/disable to generate wakeup events.
825 * @enable: Whether to enable or disable the wakeup functionality.
834 * acpi_dev_pm_low_power - Put ACPI device into a low-power state.
835 * @dev: Device to put into a low-power state.
852 * acpi_dev_pm_full_power - Put ACPI device into the full-power state.
853 * @adev: ACPI device node to put into the full-power state.
862 * acpi_dev_suspend - Put device into a low-power state using ACPI.
863 * @dev: Device to put into a low-power state.
866 * Put the given device into a low-power state using the standard ACPI
869 * the power state of the device.
883 return -EAGAIN; in acpi_dev_suspend()
897 * acpi_dev_resume - Put device into the full-power state using ACPI.
898 * @dev: Device to put into the full-power state.
900 * Put the given device into the full-power state using the standard ACPI
901 * mechanism. Set the power state of the device to ACPI D0 and disable wakeup.
918 * acpi_subsys_runtime_suspend - Suspend device using ACPI.
922 * it into a runtime low-power state.
932 * acpi_subsys_runtime_resume - Resume device using ACPI.
935 * Use ACPI to put the given device into the full-power state and carry out the
951 if (!pm_runtime_suspended(dev) || !adev || (adev->wakeup.flags.valid && in acpi_dev_needs_resume()
952 device_may_wakeup(dev) != !!adev->wakeup.prepare_count)) in acpi_dev_needs_resume()
958 if (adev->power.flags.dsw_present) in acpi_dev_needs_resume()
965 return state != adev->power.state; in acpi_dev_needs_resume()
969 * acpi_subsys_prepare - Prepare device for system transition to a sleep state.
976 if (dev->driver && dev->driver->pm && dev->driver->pm->prepare) { in acpi_subsys_prepare()
977 int ret = dev->driver->pm->prepare(dev); in acpi_subsys_prepare()
991 * acpi_subsys_complete - Finalize device's resume during system resume.
998 * If the device had been runtime-suspended before the system went into in acpi_subsys_complete()
1008 * acpi_subsys_suspend - Run the device driver's suspend callback.
1012 * system suspend callbacks, unless the driver can cope with runtime-suspended
1013 * devices during system suspend and there are no ACPI-specific reasons for
1027 * acpi_subsys_suspend_late - Suspend device using ACPI.
1031 * it into a low-power state during system transition into a sleep state.
1046 * acpi_subsys_suspend_noirq - Run the device driver's "noirq" suspend callback.
1054 dev->power.may_skip_resume = true; in acpi_subsys_suspend_noirq()
1063 * If the target system sleep state is suspend-to-idle, it is sufficient in acpi_subsys_suspend_noirq()
1069 dev->power.may_skip_resume = device_may_wakeup(dev) || in acpi_subsys_suspend_noirq()
1077 * acpi_subsys_resume_noirq - Run the device driver's "noirq" resume callback.
1097 * acpi_subsys_resume_early - Resume device using ACPI.
1100 * Use ACPI to put the given device into the full-power state and carry out the
1111 * acpi_subsys_freeze - Run the device driver's freeze callback.
1117 * Resume all runtime-suspended devices before creating a snapshot in acpi_subsys_freeze()
1120 * put into the runtime-active metastate during system resume anyway, in acpi_subsys_freeze()
1131 * acpi_subsys_restore_early - Restore device using ACPI.
1142 * acpi_subsys_poweroff - Run the device driver's poweroff callback.
1146 * system poweroff callbacks, unless the driver can cope with runtime-suspended
1147 * devices during system suspend and there are no ACPI-specific reasons for
1161 * acpi_subsys_poweroff_late - Run the device driver's poweroff callback.
1165 * it into a low-power state during system transition into a sleep state.
1182 * acpi_subsys_poweroff_noirq - Run the driver's "noirq" poweroff callback.
1216 * acpi_dev_pm_detach - Remove ACPI power management from the device.
1218 * @power_off: Whether or not to try to remove power from the device.
1221 * notifier. If @power_off is set, additionally remove power from the device if
1224 * Callers must ensure proper synchronization of this function with power
1231 if (adev && dev->pm_domain == &acpi_general_pm_domain) { in acpi_dev_pm_detach()
1239 * choice of the low-power state to put the device into. in acpi_dev_pm_detach()
1250 * acpi_dev_pm_attach - Prepare device for ACPI power management.
1252 * @power_on: Whether or not to power on the device.
1259 * This assumes that the @dev's bus type uses generic power management callbacks
1260 * (or doesn't use any power management callbacks at all).
1262 * Callers must ensure proper synchronization of this function with power
1269 * because they require special power management handling incompatible in acpi_dev_pm_attach()
1283 * Only attach the power domain to the first device if the in acpi_dev_pm_attach()
1284 * companion is shared by multiple. This is to prevent doing power in acpi_dev_pm_attach()
1297 dev->pm_domain->detach = acpi_dev_pm_detach; in acpi_dev_pm_attach()