Commit e5899e1b authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Jesse Barnes

PCI PM: make more PCI PM core functionality available to drivers

Make more PCI PM core functionality available to drivers

* Export pci_pme_capable() so that it can be called directly by
  drivers (for example, tg3 needs that).

* Move the state choosing part of pci_prepare_to_sleep() to a
  separate function, pci_target_state(), that can be called directly
  by drivers (for example, tg3 needs that).
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
parent f42e86d9
...@@ -1040,7 +1040,7 @@ int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state) ...@@ -1040,7 +1040,7 @@ int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
* @dev: PCI device to handle. * @dev: PCI device to handle.
* @state: PCI state from which device will issue PME#. * @state: PCI state from which device will issue PME#.
*/ */
static bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) bool pci_pme_capable(struct pci_dev *dev, pci_power_t state)
{ {
if (!dev->pm_cap) if (!dev->pm_cap)
return false; return false;
...@@ -1123,17 +1123,10 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable) ...@@ -1123,17 +1123,10 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable)
} }
/** /**
* pci_prepare_to_sleep - prepare PCI device for system-wide transition into a sleep state
* @dev: Device to handle.
*
* Choose the power state appropriate for the device depending on whether
* it can wake up the system and/or is power manageable by the platform
* (PCI_D3hot is the default) and put the device into that state.
*/ */
int pci_prepare_to_sleep(struct pci_dev *dev) pci_power_t pci_target_state(struct pci_dev *dev)
{ {
pci_power_t target_state = PCI_D3hot; pci_power_t target_state = PCI_D3hot;
int error;
if (platform_pci_power_manageable(dev)) { if (platform_pci_power_manageable(dev)) {
/* /*
...@@ -1160,7 +1153,7 @@ int pci_prepare_to_sleep(struct pci_dev *dev) ...@@ -1160,7 +1153,7 @@ int pci_prepare_to_sleep(struct pci_dev *dev)
* to generate PME#. * to generate PME#.
*/ */
if (!dev->pm_cap) if (!dev->pm_cap)
return -EIO; return PCI_POWER_ERROR;
if (dev->pme_support) { if (dev->pme_support) {
while (target_state while (target_state
...@@ -1169,6 +1162,25 @@ int pci_prepare_to_sleep(struct pci_dev *dev) ...@@ -1169,6 +1162,25 @@ int pci_prepare_to_sleep(struct pci_dev *dev)
} }
} }
return target_state;
}
/**
* pci_prepare_to_sleep - prepare PCI device for system-wide transition into a sleep state
* @dev: Device to handle.
*
* Choose the power state appropriate for the device depending on whether
* it can wake up the system and/or is power manageable by the platform
* (PCI_D3hot is the default) and put the device into that state.
*/
int pci_prepare_to_sleep(struct pci_dev *dev)
{
pci_power_t target_state = pci_target_state(dev);
int error;
if (target_state == PCI_POWER_ERROR)
return -EIO;
pci_enable_wake(dev, target_state, true); pci_enable_wake(dev, target_state, true);
error = pci_set_power_state(dev, target_state); error = pci_set_power_state(dev, target_state);
...@@ -1918,7 +1930,9 @@ EXPORT_SYMBOL(pci_select_bars); ...@@ -1918,7 +1930,9 @@ EXPORT_SYMBOL(pci_select_bars);
EXPORT_SYMBOL(pci_set_power_state); EXPORT_SYMBOL(pci_set_power_state);
EXPORT_SYMBOL(pci_save_state); EXPORT_SYMBOL(pci_save_state);
EXPORT_SYMBOL(pci_restore_state); EXPORT_SYMBOL(pci_restore_state);
EXPORT_SYMBOL(pci_pme_capable);
EXPORT_SYMBOL(pci_enable_wake); EXPORT_SYMBOL(pci_enable_wake);
EXPORT_SYMBOL(pci_target_state);
EXPORT_SYMBOL(pci_prepare_to_sleep); EXPORT_SYMBOL(pci_prepare_to_sleep);
EXPORT_SYMBOL(pci_back_from_sleep); EXPORT_SYMBOL(pci_back_from_sleep);
EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state); EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
......
...@@ -638,7 +638,9 @@ int pci_save_state(struct pci_dev *dev); ...@@ -638,7 +638,9 @@ int pci_save_state(struct pci_dev *dev);
int pci_restore_state(struct pci_dev *dev); int pci_restore_state(struct pci_dev *dev);
int pci_set_power_state(struct pci_dev *dev, pci_power_t state); int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable);
pci_power_t pci_target_state(struct pci_dev *dev);
int pci_prepare_to_sleep(struct pci_dev *dev); int pci_prepare_to_sleep(struct pci_dev *dev);
int pci_back_from_sleep(struct pci_dev *dev); int pci_back_from_sleep(struct pci_dev *dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment