diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2008-08-18 15:38:00 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2008-10-20 13:53:41 -0400 |
commit | 0235c4fc7fc6f621dc0dd89eba102ad5aa373390 (patch) | |
tree | 8947ae0efda2a1c9d69f3b6399d3e847307786a5 /drivers | |
parent | 3d137310245e4cdc3e8c8ba1bea2e145a87ae8e3 (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')
-rw-r--r-- | drivers/pci/pci.c | 22 |
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 | */ | ||
1143 | int 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); | |||
1942 | EXPORT_SYMBOL(pci_pme_capable); | 1963 | EXPORT_SYMBOL(pci_pme_capable); |
1943 | EXPORT_SYMBOL(pci_pme_active); | 1964 | EXPORT_SYMBOL(pci_pme_active); |
1944 | EXPORT_SYMBOL(pci_enable_wake); | 1965 | EXPORT_SYMBOL(pci_enable_wake); |
1966 | EXPORT_SYMBOL(pci_wake_from_d3); | ||
1945 | EXPORT_SYMBOL(pci_target_state); | 1967 | EXPORT_SYMBOL(pci_target_state); |
1946 | EXPORT_SYMBOL(pci_prepare_to_sleep); | 1968 | EXPORT_SYMBOL(pci_prepare_to_sleep); |
1947 | EXPORT_SYMBOL(pci_back_from_sleep); | 1969 | EXPORT_SYMBOL(pci_back_from_sleep); |