aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2008-08-18 15:38:00 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2008-10-20 13:53:41 -0400
commit0235c4fc7fc6f621dc0dd89eba102ad5aa373390 (patch)
tree8947ae0efda2a1c9d69f3b6399d3e847307786a5 /drivers/pci/pci.c
parent3d137310245e4cdc3e8c8ba1bea2e145a87ae8e3 (diff)
PCI PM: Introduce function pci_wake_from_d3
Many device drivers use the following sequence of statements to enable the device to wake up the system while being in the D3_hot or D3_cold low power state: pci_enable_wake(pdev, PCI_D3hot, 1); pci_enable_wake(pdev, PCI_D3cold, 1); However, the second call is not necessary if the first one succeeds (the ordering of the statements above doesn't matter here) and it may even be harmful, because we are not supposed to enable PME# after the wake-up power has been enabled for the device. To allow drivers to overcome this problem, introduce function pci_wake_from_d3() that will enable the device to wake up the system from any of D3_hot and D3_cold as long as the wake-up from at least one of them is supported. Acked-by: Pavel Machek <pavel@suse.cz> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index dbe9f39f4436..2797112c9400 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1127,6 +1127,27 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable)
1127} 1127}
1128 1128
1129/** 1129/**
1130 * pci_wake_from_d3 - enable/disable device to wake up from D3_hot or D3_cold
1131 * @dev: PCI device to prepare
1132 * @enable: True to enable wake-up event generation; false to disable
1133 *
1134 * Many drivers want the device to wake up the system from D3_hot or D3_cold
1135 * and this function allows them to set that up cleanly - pci_enable_wake()
1136 * should not be called twice in a row to enable wake-up due to PCI PM vs ACPI
1137 * ordering constraints.
1138 *
1139 * This function only returns error code if the device is not capable of
1140 * generating PME# from both D3_hot and D3_cold, and the platform is unable to
1141 * enable wake-up power for it.
1142 */
1143int pci_wake_from_d3(struct pci_dev *dev, bool enable)
1144{
1145 return pci_pme_capable(dev, PCI_D3cold) ?
1146 pci_enable_wake(dev, PCI_D3cold, enable) :
1147 pci_enable_wake(dev, PCI_D3hot, enable);
1148}
1149
1150/**
1130 * pci_target_state - find an appropriate low power state for a given PCI dev 1151 * pci_target_state - find an appropriate low power state for a given PCI dev
1131 * @dev: PCI device 1152 * @dev: PCI device
1132 * 1153 *
@@ -1942,6 +1963,7 @@ EXPORT_SYMBOL(pci_restore_state);
1942EXPORT_SYMBOL(pci_pme_capable); 1963EXPORT_SYMBOL(pci_pme_capable);
1943EXPORT_SYMBOL(pci_pme_active); 1964EXPORT_SYMBOL(pci_pme_active);
1944EXPORT_SYMBOL(pci_enable_wake); 1965EXPORT_SYMBOL(pci_enable_wake);
1966EXPORT_SYMBOL(pci_wake_from_d3);
1945EXPORT_SYMBOL(pci_target_state); 1967EXPORT_SYMBOL(pci_target_state);
1946EXPORT_SYMBOL(pci_prepare_to_sleep); 1968EXPORT_SYMBOL(pci_prepare_to_sleep);
1947EXPORT_SYMBOL(pci_back_from_sleep); 1969EXPORT_SYMBOL(pci_back_from_sleep);