Lines Matching full:device
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()
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
80 if (!device || !state) in acpi_device_get_power()
83 if (!device->flags.power_manageable) { in acpi_device_get_power()
85 *state = device->parent ? in acpi_device_get_power()
86 device->parent->power.state : ACPI_STATE_D0; in acpi_device_get_power()
91 * Get the device's power state from power resources settings and _PSC, in acpi_device_get_power()
94 if (device->power.flags.power_resources) { in acpi_device_get_power()
95 error = acpi_power_get_inferred_state(device, &result); in acpi_device_get_power()
99 if (device->power.flags.explicit_get) { in acpi_device_get_power()
102 error = acpi_dev_pm_explicit_get(device, &psc); in acpi_device_get_power()
108 * shallower than the actual power state of the device, because in acpi_device_get_power()
121 * If we were unsure about the device parent's power state up to this in acpi_device_get_power()
122 * point, the fact that the device is in D0 implies that the parent has in acpi_device_get_power()
125 if (!device->power.flags.ignore_parent && device->parent in acpi_device_get_power()
126 && device->parent->power.state == ACPI_STATE_UNKNOWN in acpi_device_get_power()
128 device->parent->power.state = ACPI_STATE_D0; in acpi_device_get_power()
133 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] power state is %s\n", in acpi_device_get_power()
134 device->pnp.bus_id, acpi_power_state_string(*state))); in acpi_device_get_power()
153 * acpi_device_set_power - Set power state of an ACPI device.
154 * @device: Device to set the power state of.
157 * Callers must ensure that the device is power manageable before using this
160 int acpi_device_set_power(struct acpi_device *device, int state) in acpi_device_set_power() argument
165 if (!device || !device->flags.power_manageable in acpi_device_set_power()
169 acpi_handle_debug(device->handle, "Power state change: %s -> %s\n", in acpi_device_set_power()
170 acpi_power_state_string(device->power.state), in acpi_device_set_power()
176 if (state > ACPI_STATE_D0 && state == device->power.state) { in acpi_device_set_power()
177 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Device [%s] already in %s\n", in acpi_device_set_power()
178 device->pnp.bus_id, in acpi_device_set_power()
190 if (!device->power.states[ACPI_STATE_D3_COLD].flags.valid) in acpi_device_set_power()
192 } else if (!device->power.states[state].flags.valid) { in acpi_device_set_power()
193 dev_warn(&device->dev, "Power state %s not supported\n", in acpi_device_set_power()
198 if (!device->power.flags.ignore_parent && in acpi_device_set_power()
199 device->parent && (state < device->parent->power.state)) { in acpi_device_set_power()
200 dev_warn(&device->dev, in acpi_device_set_power()
203 acpi_power_state_string(device->parent->power.state)); in acpi_device_set_power()
219 if (state < device->power.state) { in acpi_device_set_power()
220 dev_warn(&device->dev, "Cannot transition from %s to %s\n", in acpi_device_set_power()
221 acpi_power_state_string(device->power.state), in acpi_device_set_power()
227 * If the device goes from D3hot to D3cold, _PS3 has been in acpi_device_set_power()
230 if (device->power.state < ACPI_STATE_D3_HOT) { in acpi_device_set_power()
231 result = acpi_dev_pm_explicit_set(device, state); in acpi_device_set_power()
236 if (device->power.flags.power_resources) in acpi_device_set_power()
237 result = acpi_power_transition(device, target_state); in acpi_device_set_power()
239 int cur_state = device->power.state; in acpi_device_set_power()
241 if (device->power.flags.power_resources) { in acpi_device_set_power()
242 result = acpi_power_transition(device, ACPI_STATE_D0); in acpi_device_set_power()
251 if (!device->power.flags.explicit_get) in acpi_device_set_power()
255 * The power state of the device was set to D0 last in acpi_device_set_power()
259 * for the device here. However, use extra care here in acpi_device_set_power()
260 * and evaluate _PSC to check the device's current power in acpi_device_set_power()
265 result = acpi_dev_pm_explicit_get(device, &psc); in acpi_device_set_power()
270 result = acpi_dev_pm_explicit_set(device, ACPI_STATE_D0); in acpi_device_set_power()
275 dev_warn(&device->dev, "Failed to change power state to %s\n", in acpi_device_set_power()
278 device->power.state = target_state; in acpi_device_set_power()
280 "Device [%s] transitioned to %s\n", in acpi_device_set_power()
281 device->pnp.bus_id, in acpi_device_set_power()
291 struct acpi_device *device; in acpi_bus_set_power() local
294 result = acpi_bus_get_device(handle, &device); in acpi_bus_set_power()
298 return acpi_device_set_power(device, state); in acpi_bus_set_power()
302 int acpi_bus_init_power(struct acpi_device *device) in acpi_bus_init_power() argument
307 if (!device) in acpi_bus_init_power()
310 device->power.state = ACPI_STATE_UNKNOWN; in acpi_bus_init_power()
311 if (!acpi_device_is_present(device)) { in acpi_bus_init_power()
312 device->flags.initialized = false; in acpi_bus_init_power()
316 result = acpi_device_get_power(device, &state); in acpi_bus_init_power()
320 if (state < ACPI_STATE_D3_COLD && device->power.flags.power_resources) { in acpi_bus_init_power()
322 result = acpi_power_on_resources(device, state); in acpi_bus_init_power()
331 * another device using the same power resources may in acpi_bus_init_power()
335 result = acpi_dev_pm_explicit_set(device, state); in acpi_bus_init_power()
342 * it D0 in hope that this is what the BIOS put the device into. in acpi_bus_init_power()
348 device->power.state = state; in acpi_bus_init_power()
353 * acpi_device_fix_up_power - Force device with missing _PSC into D0.
354 * @device: Device object whose power state is to be fixed up.
360 int acpi_device_fix_up_power(struct acpi_device *device) in acpi_device_fix_up_power() argument
364 if (!device->power.flags.power_resources in acpi_device_fix_up_power()
365 && !device->power.flags.explicit_get in acpi_device_fix_up_power()
366 && device->power.state == ACPI_STATE_D0) in acpi_device_fix_up_power()
367 ret = acpi_dev_pm_explicit_set(device, ACPI_STATE_D0); in acpi_device_fix_up_power()
373 int acpi_device_update_power(struct acpi_device *device, int *state_p) in acpi_device_update_power() argument
378 if (device->power.state == ACPI_STATE_UNKNOWN) { in acpi_device_update_power()
379 result = acpi_bus_init_power(device); in acpi_device_update_power()
381 *state_p = device->power.state; in acpi_device_update_power()
386 result = acpi_device_get_power(device, &state); in acpi_device_update_power()
392 result = acpi_device_set_power(device, state); in acpi_device_update_power()
396 if (device->power.flags.power_resources) { in acpi_device_update_power()
401 result = acpi_power_transition(device, state); in acpi_device_update_power()
405 device->power.state = state; in acpi_device_update_power()
416 struct acpi_device *device; in acpi_bus_update_power() local
419 result = acpi_bus_get_device(handle, &device); in acpi_bus_update_power()
420 return result ? result : acpi_device_update_power(device, state_p); in acpi_bus_update_power()
426 struct acpi_device *device; in acpi_bus_power_manageable() local
429 result = acpi_bus_get_device(handle, &device); in acpi_bus_power_manageable()
430 return result ? false : device->flags.power_manageable; in acpi_bus_power_manageable()
438 void acpi_pm_wakeup_event(struct device *dev) in acpi_pm_wakeup_event()
475 * acpi_add_pm_notifier - Register PM notify handler for given ACPI device.
476 * @adev: ACPI device to add the notify handler for.
477 * @dev: Device to generate a wakeup event for while handling the notification.
480 * NOTE: @adev need not be a run-wake or wakeup device to be a valid source of
485 acpi_status acpi_add_pm_notifier(struct acpi_device *adev, struct device *dev, in acpi_add_pm_notifier()
517 * acpi_remove_pm_notifier - Unregister PM notifier from given ACPI device.
518 * @adev: ACPI device to remove the notifier from.
549 struct acpi_device *device; in acpi_bus_can_wakeup() local
552 result = acpi_bus_get_device(handle, &device); in acpi_bus_can_wakeup()
553 return result ? false : device->wakeup.flags.valid; in acpi_bus_can_wakeup()
557 bool acpi_pm_device_can_wakeup(struct device *dev) in acpi_pm_device_can_wakeup()
565 * acpi_dev_pm_get_state - Get preferred power state of ACPI device.
566 * @dev: Device whose preferred target power state to return.
567 * @adev: ACPI device node corresponding to @dev.
568 * @target_state: System state to match the resultant device state.
569 * @d_min_p: Location to store the highest power state available to the device.
570 * @d_max_p: Location to store the lowest power state available to the device.
573 * device power states that the device can be in while the system is in the
585 static int acpi_dev_pm_get_state(struct device *dev, struct acpi_device *adev, in acpi_dev_pm_get_state()
597 * If the system state is S0, the lowest power state the device can be in acpi_dev_pm_get_state()
598 * in is D3cold, unless the device has _S0W and is supposed to signal in acpi_dev_pm_get_state()
600 * lowest power state available to the device. in acpi_dev_pm_get_state()
681 * acpi_pm_device_sleep_state - Get preferred power state of ACPI device.
682 * @dev: Device whose preferred target power state to return.
685 * Return value: Preferred power state of the device on success, -ENODEV
691 int acpi_pm_device_sleep_state(struct device *dev, int *d_min_p, int d_max_in) in acpi_pm_device_sleep_state()
737 * @context: Device wakeup context.
741 struct device *dev = context->dev; in acpi_pm_notify_work_func()
789 * acpi_device_wakeup_enable - Enable wakeup functionality for device.
790 * @adev: ACPI device to enable wakeup functionality for.
794 * for the device in response to external (remote) events and enable wakeup
797 * Callers must ensure that @adev is a valid ACPI device node before executing
806 * acpi_device_wakeup_disable - Disable wakeup functionality for device.
807 * @adev: ACPI device to disable wakeup functionality for.
811 * Callers must ensure that @adev is a valid ACPI device node before executing
832 static int __acpi_pm_set_device_wakeup(struct device *dev, bool enable, in __acpi_pm_set_device_wakeup()
862 * acpi_pm_set_device_wakeup - Enable/disable remote wakeup for given device.
863 * @dev: Device to enable/disable to generate wakeup events.
866 int acpi_pm_set_device_wakeup(struct device *dev, bool enable) in acpi_pm_set_device_wakeup()
874 * @dev: Bridge device to enable/disable to generate wakeup events.
877 int acpi_pm_set_bridge_wakeup(struct device *dev, bool enable) in acpi_pm_set_bridge_wakeup()
884 * acpi_dev_pm_low_power - Put ACPI device into a low-power state.
885 * @dev: Device to put into a low-power state.
886 * @adev: ACPI device node corresponding to @dev.
887 * @system_state: System state to choose the device state for.
889 static int acpi_dev_pm_low_power(struct device *dev, struct acpi_device *adev, in acpi_dev_pm_low_power()
902 * acpi_dev_pm_full_power - Put ACPI device into the full-power state.
903 * @adev: ACPI device node to put into the full-power state.
912 * acpi_dev_suspend - Put device into a low-power state using ACPI.
913 * @dev: Device to put into a low-power state.
914 * @wakeup: Whether or not to enable wakeup for the device.
916 * Put the given device into a low-power state using the standard ACPI
918 * device into (this checks if remote wakeup is expected to work too), and set
919 * the power state of the device.
921 int acpi_dev_suspend(struct device *dev, bool wakeup) in acpi_dev_suspend()
947 * acpi_dev_resume - Put device into the full-power state using ACPI.
948 * @dev: Device to put into the full-power state.
950 * Put the given device into the full-power state using the standard ACPI
951 * mechanism. Set the power state of the device to ACPI D0 and disable wakeup.
953 int acpi_dev_resume(struct device *dev) in acpi_dev_resume()
968 * acpi_subsys_runtime_suspend - Suspend device using ACPI.
969 * @dev: Device to suspend.
974 int acpi_subsys_runtime_suspend(struct device *dev) in acpi_subsys_runtime_suspend()
982 * acpi_subsys_runtime_resume - Resume device using ACPI.
983 * @dev: Device to Resume.
985 * Use ACPI to put the given device into the full-power state and carry out the
988 int acpi_subsys_runtime_resume(struct device *dev) in acpi_subsys_runtime_resume()
996 static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev) in acpi_dev_needs_resume()
1019 * acpi_subsys_prepare - Prepare device for system transition to a sleep state.
1020 * @dev: Device to prepare.
1022 int acpi_subsys_prepare(struct device *dev) in acpi_subsys_prepare()
1041 * acpi_subsys_complete - Finalize device's resume during system resume.
1042 * @dev: Device to handle.
1044 void acpi_subsys_complete(struct device *dev) in acpi_subsys_complete()
1048 * If the device had been runtime-suspended before the system went into in acpi_subsys_complete()
1058 * acpi_subsys_suspend - Run the device driver's suspend callback.
1059 * @dev: Device to handle.
1066 int acpi_subsys_suspend(struct device *dev) in acpi_subsys_suspend()
1077 * acpi_subsys_suspend_late - Suspend device using ACPI.
1078 * @dev: Device to suspend.
1083 int acpi_subsys_suspend_late(struct device *dev) in acpi_subsys_suspend_late()
1096 * acpi_subsys_suspend_noirq - Run the device driver's "noirq" suspend callback.
1097 * @dev: Device to suspend.
1099 int acpi_subsys_suspend_noirq(struct device *dev) in acpi_subsys_suspend_noirq()
1112 * to check whether or not the device's wakeup settings are good for in acpi_subsys_suspend_noirq()
1114 * acpi_subsys_complete() to take care of fixing up the device's state in acpi_subsys_suspend_noirq()
1125 * acpi_subsys_resume_noirq - Run the device driver's "noirq" resume callback.
1126 * @dev: Device to handle.
1128 static int acpi_subsys_resume_noirq(struct device *dev) in acpi_subsys_resume_noirq()
1137 * acpi_subsys_resume_early - Resume device using ACPI.
1138 * @dev: Device to Resume.
1140 * Use ACPI to put the given device into the full-power state and carry out the
1144 static int acpi_subsys_resume_early(struct device *dev) in acpi_subsys_resume_early()
1156 * acpi_subsys_freeze - Run the device driver's freeze callback.
1157 * @dev: Device to handle.
1159 int acpi_subsys_freeze(struct device *dev) in acpi_subsys_freeze()
1176 * acpi_subsys_restore_early - Restore device using ACPI.
1177 * @dev: Device to restore.
1179 int acpi_subsys_restore_early(struct device *dev) in acpi_subsys_restore_early()
1187 * acpi_subsys_poweroff - Run the device driver's poweroff callback.
1188 * @dev: Device to handle.
1195 int acpi_subsys_poweroff(struct device *dev) in acpi_subsys_poweroff()
1206 * acpi_subsys_poweroff_late - Run the device driver's poweroff callback.
1207 * @dev: Device to handle.
1212 static int acpi_subsys_poweroff_late(struct device *dev) in acpi_subsys_poweroff_late()
1228 * @dev: Device to suspend.
1230 static int acpi_subsys_poweroff_noirq(struct device *dev) in acpi_subsys_poweroff_noirq()
1261 * acpi_dev_pm_detach - Remove ACPI power management from the device.
1262 * @dev: Device to take care of.
1263 * @power_off: Whether or not to try to remove power from the device.
1265 * Remove the device from the general ACPI PM domain and remove its wakeup
1266 * notifier. If @power_off is set, additionally remove power from the device if
1272 static void acpi_dev_pm_detach(struct device *dev, bool power_off) in acpi_dev_pm_detach()
1281 * If the device's PM QoS resume latency limit or flags in acpi_dev_pm_detach()
1284 * choice of the low-power state to put the device into. in acpi_dev_pm_detach()
1295 * acpi_dev_pm_attach - Prepare device for ACPI power management.
1296 * @dev: Device to prepare.
1297 * @power_on: Whether or not to power on the device.
1300 * attached to it, install a wakeup notification handler for the device and
1301 * add it to the general ACPI PM domain. If @power_on is set, the device will
1310 int acpi_dev_pm_attach(struct device *dev, bool power_on) in acpi_dev_pm_attach()
1313 * Skip devices whose ACPI companions match the device IDs below, in acpi_dev_pm_attach()
1329 * Only attach the power domain to the first device if the in acpi_dev_pm_attach()