Lines Matching refs:state
990 * pci_raw_set_power_state - Use PCI PM registers to set the power state of
993 * @state: PCI power state (D0, D1, D2, D3hot) to put the device into.
996 * -EINVAL if the requested state is invalid.
998 * wrong version, or device doesn't support the requested state.
999 * 0 if device already is in the requested state.
1000 * 0 if device's power state has been successfully changed.
1002 static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
1008 if (dev->current_state == state)
1014 if (state < PCI_D0 || state > PCI_D3hot)
1018 * Validate transition: We can enter D0 from any state, but if
1019 * we're already in a low-power state, we can only go deeper. E.g.,
1023 if (state != PCI_D0 && dev->current_state <= PCI_D3cold
1024 && dev->current_state > state) {
1027 pci_power_name(state));
1031 /* Check if this device supports the desired state */
1032 if ((state == PCI_D1 && !dev->d1_support)
1033 || (state == PCI_D2 && !dev->d2_support))
1038 pci_err(dev, "can't change power state from %s to %s (config space inaccessible)\n",
1040 pci_power_name(state));
1054 pmcsr |= state;
1068 /* Enter specified state */
1075 if (state == PCI_D3hot || dev->current_state == PCI_D3hot)
1077 else if (state == PCI_D2 || dev->current_state == PCI_D2)
1082 if (dev->current_state != state)
1083 pci_info_ratelimited(dev, "refused to change power state from %s to %s\n",
1085 pci_power_name(state));
1096 * devices in a D3hot state at boot. Consequently, we need to
1110 * pci_update_current_state - Read power state of given device and cache it
1112 * @state: State to cache in case the device doesn't have the PM capability
1114 * The power state is read from the PMCSR register, which however is
1117 * reports an incorrect state or the device isn't power manageable by the
1121 void pci_update_current_state(struct pci_dev *dev, pci_power_t state)
1132 dev->current_state = state;
1137 * pci_refresh_power_state - Refresh the given device's power state data
1140 * Ask the platform to refresh the devices power state information and invoke
1141 * pci_update_current_state() to update its current PCI power state.
1152 * pci_platform_power_transition - Use platform to change device power state
1154 * @state: State to put the device into.
1156 int pci_platform_power_transition(struct pci_dev *dev, pci_power_t state)
1161 error = platform_pci_set_power_state(dev, state);
1163 pci_update_current_state(dev, state);
1253 * may be powered on into D0uninitialized state, resume them to
1263 * __pci_dev_set_current_state - Set current state of a PCI device
1265 * @data: pointer to state to be set
1269 pci_power_t state = *(pci_power_t *)data;
1271 dev->current_state = state;
1276 * pci_bus_set_current_state - Walk given bus and set current state of devices
1278 * @state: state to be set
1280 void pci_bus_set_current_state(struct pci_bus *bus, pci_power_t state)
1283 pci_walk_bus(bus, __pci_dev_set_current_state, &state);
1287 * pci_set_power_state - Set the power state of a PCI device
1289 * @state: PCI power state (D0, D1, D2, D3hot) to put the device into.
1291 * Transition a device to a new power state, using the platform firmware and/or
1295 * -EINVAL if the requested state is invalid.
1297 * wrong version, or device doesn't support the requested state.
1299 * 0 if device already is in the requested state.
1301 * 0 if device's power state has been successfully changed.
1303 int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
1307 /* Bound the state we're entering */
1308 if (state > PCI_D3cold)
1309 state = PCI_D3cold;
1310 else if (state < PCI_D0)
1311 state = PCI_D0;
1312 else if ((state == PCI_D1 || state == PCI_D2) && pci_no_d1d2(dev))
1323 if (dev->current_state == state)
1326 if (state == PCI_D0)
1333 if (state >= PCI_D3hot && (dev->dev_flags & PCI_DEV_FLAGS_NO_D3))
1340 error = pci_raw_set_power_state(dev, state > PCI_D3hot ?
1341 PCI_D3hot : state);
1343 if (pci_platform_power_transition(dev, state))
1347 if (state == PCI_D3cold)
1355 * pci_choose_state - Choose the power state of a PCI device
1357 * @state: target sleep state for the whole system. This is the value
1360 * Returns PCI power state suitable for given device and given system
1363 pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
1374 switch (state.event) {
1385 state.event);
1656 * pci_restore_state - Restore the saved state of a PCI device
1686 /* Restore ACS and IOV configuration state */
1701 * the device saved state.
1704 * Return NULL if no state or error.
1708 struct pci_saved_state *state;
1716 size = sizeof(*state) + sizeof(struct pci_cap_saved_data);
1721 state = kzalloc(size, GFP_KERNEL);
1722 if (!state)
1725 memcpy(state->config_space, dev->saved_config_space,
1726 sizeof(state->config_space));
1728 cap = state->cap;
1736 return state;
1741 * pci_load_saved_state - Reload the provided save state into struct pci_dev.
1743 * @state: Saved state returned from pci_store_saved_state()
1746 struct pci_saved_state *state)
1752 if (!state)
1755 memcpy(dev->saved_config_space, state->config_space,
1756 sizeof(state->config_space));
1758 cap = state->cap;
1777 * pci_load_and_free_saved_state - Reload the save state pointed to by state,
1780 * @state: Pointer to saved state returned from pci_store_saved_state()
1783 struct pci_saved_state **state)
1785 int ret = pci_load_saved_state(dev, *state);
1786 kfree(*state);
1787 *state = NULL;
1875 * Power state could be unknown at this point, either due to a fresh
1876 * boot or a device removal call. So get the current power state
2156 * pcibios_set_pcie_reset_state - set reset state for device dev
2158 * @state: Reset state to enter into
2160 * Set the PCIe reset state for the device. This is the default
2164 enum pcie_reset_state state)
2170 * pci_set_pcie_reset_state - set reset state for device dev
2172 * @state: Reset state to enter into
2174 * Sets the PCI reset state for the device.
2176 int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
2178 return pcibios_set_pcie_reset_state(dev, state);
2268 * @state: PCI state from which device will issue PME#.
2270 bool pci_pme_capable(struct pci_dev *dev, pci_power_t state)
2275 return !!(dev->pme_support & (1 << state));
2290 * If bridge is in low power state, the
2422 * @state: PCI state from which device will issue wakeup events
2438 static int __pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable)
2468 * the current target state, because that will allow it to
2472 if (pci_pme_capable(dev, state) || pci_pme_capable(dev, PCI_D3cold))
2493 * @state: PCI state from which device will issue wakeup events
2499 int pci_enable_wake(struct pci_dev *pci_dev, pci_power_t state, bool enable)
2504 return __pci_enable_wake(pci_dev, state, enable);
2531 * pci_target_state - find an appropriate low power state for a given PCI dev
2535 * Use underlying platform code to find a supported low power state for @dev.
2536 * If the platform can't manage @dev, return the deepest state from which it
2545 * Call the platform to find the target state for the device.
2547 pci_power_t state = platform_pci_choose_state(dev);
2549 switch (state) {
2559 target_state = state;
2577 pci_power_t state = target_state;
2580 * Find the deepest state from which the device can generate
2583 while (state && !(dev->pme_support & (1 << state)))
2584 state--;
2586 if (state)
2587 return state;
2597 * into a sleep state
2600 * Choose the power state appropriate for the device depending on whether
2602 * (PCI_D3hot is the default) and put the device into that state.
2626 * into working state
2643 * power state.
2683 /* PME-capable in principle, but not from the target power state */
2713 * suspend, or the current power state of it is not suitable for the upcoming
2743 * Note that if the device's power state is D3cold and the platform check in
4665 * PCI_D0. If that's the case and the device is not in a low-power state
4921 * Devices on the secondary bus are left in power-on state.
5015 * to a non-D0 state anyway.
5145 * clears all the state associated with the device. This function differs
5146 * from __pci_reset_function_locked() in that it saves and restores device state
5180 * clears all the state associated with the device. This function differs
5181 * from __pci_reset_function_locked() in that it saves and restores device state
6039 * pci_set_vga_state - set VGA decode state on device and parents if requested