aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael J. Wysocki <rjw@sisk.pl>2008-07-19 08:39:24 -0400
committerJesse Barnes <jbarnes@virtuousgeek.org>2008-07-22 17:25:38 -0400
commite5899e1b7d73e67de758a32174a859cc2586c0b9 (patch)
tree2bb80ed1e52fb9981c6f44f6b0e7baa105585787
parentf42e86d95fa53d3a62b2795515da18b4f41b0480 (diff)
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: Rafael J. Wysocki <rjw@sisk.pl> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
-rw-r--r--drivers/pci/pci.c34
-rw-r--r--include/linux/pci.h2
2 files changed, 26 insertions, 10 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index d00f0e0d8453..e9c356236d27 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1040,7 +1040,7 @@ int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
1040 * @dev: PCI device to handle. 1040 * @dev: PCI device to handle.
1041 * @state: PCI state from which device will issue PME#. 1041 * @state: PCI state from which device will issue PME#.
1042 */ 1042 */
1043static bool pci_pme_capable(struct pci_dev *dev, pci_power_t state) 1043bool pci_pme_capable(struct pci_dev *dev, pci_power_t state)
1044{ 1044{
1045 if (!dev->pm_cap) 1045 if (!dev->pm_cap)
1046 return false; 1046 return false;
@@ -1123,17 +1123,10 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable)
1123} 1123}
1124 1124
1125/** 1125/**
1126 * pci_prepare_to_sleep - prepare PCI device for system-wide transition into a sleep state
1127 * @dev: Device to handle.
1128 *
1129 * Choose the power state appropriate for the device depending on whether
1130 * it can wake up the system and/or is power manageable by the platform
1131 * (PCI_D3hot is the default) and put the device into that state.
1132 */ 1126 */
1133int pci_prepare_to_sleep(struct pci_dev *dev) 1127pci_power_t pci_target_state(struct pci_dev *dev)
1134{ 1128{
1135 pci_power_t target_state = PCI_D3hot; 1129 pci_power_t target_state = PCI_D3hot;
1136 int error;
1137 1130
1138 if (platform_pci_power_manageable(dev)) { 1131 if (platform_pci_power_manageable(dev)) {
1139 /* 1132 /*
@@ -1160,7 +1153,7 @@ int pci_prepare_to_sleep(struct pci_dev *dev)
1160 * to generate PME#. 1153 * to generate PME#.
1161 */ 1154 */
1162 if (!dev->pm_cap) 1155 if (!dev->pm_cap)
1163 return -EIO; 1156 return PCI_POWER_ERROR;
1164 1157
1165 if (dev->pme_support) { 1158 if (dev->pme_support) {
1166 while (target_state 1159 while (target_state
@@ -1169,6 +1162,25 @@ int pci_prepare_to_sleep(struct pci_dev *dev)
1169 } 1162 }
1170 } 1163 }
1171 1164
1165 return target_state;
1166}
1167
1168/**
1169 * pci_prepare_to_sleep - prepare PCI device for system-wide transition into a sleep state
1170 * @dev: Device to handle.
1171 *
1172 * Choose the power state appropriate for the device depending on whether
1173 * it can wake up the system and/or is power manageable by the platform
1174 * (PCI_D3hot is the default) and put the device into that state.
1175 */
1176int pci_prepare_to_sleep(struct pci_dev *dev)
1177{
1178 pci_power_t target_state = pci_target_state(dev);
1179 int error;
1180
1181 if (target_state == PCI_POWER_ERROR)
1182 return -EIO;
1183
1172 pci_enable_wake(dev, target_state, true); 1184 pci_enable_wake(dev, target_state, true);
1173 1185
1174 error = pci_set_power_state(dev, target_state); 1186 error = pci_set_power_state(dev, target_state);
@@ -1918,7 +1930,9 @@ EXPORT_SYMBOL(pci_select_bars);
1918EXPORT_SYMBOL(pci_set_power_state); 1930EXPORT_SYMBOL(pci_set_power_state);
1919EXPORT_SYMBOL(pci_save_state); 1931EXPORT_SYMBOL(pci_save_state);
1920EXPORT_SYMBOL(pci_restore_state); 1932EXPORT_SYMBOL(pci_restore_state);
1933EXPORT_SYMBOL(pci_pme_capable);
1921EXPORT_SYMBOL(pci_enable_wake); 1934EXPORT_SYMBOL(pci_enable_wake);
1935EXPORT_SYMBOL(pci_target_state);
1922EXPORT_SYMBOL(pci_prepare_to_sleep); 1936EXPORT_SYMBOL(pci_prepare_to_sleep);
1923EXPORT_SYMBOL(pci_back_from_sleep); 1937EXPORT_SYMBOL(pci_back_from_sleep);
1924EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state); 1938EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index a6a088e1a804..1d296d31abe0 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -638,7 +638,9 @@ int pci_save_state(struct pci_dev *dev);
638int pci_restore_state(struct pci_dev *dev); 638int pci_restore_state(struct pci_dev *dev);
639int pci_set_power_state(struct pci_dev *dev, pci_power_t state); 639int pci_set_power_state(struct pci_dev *dev, pci_power_t state);
640pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state); 640pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state);
641bool pci_pme_capable(struct pci_dev *dev, pci_power_t state);
641int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable); 642int pci_enable_wake(struct pci_dev *dev, pci_power_t state, int enable);
643pci_power_t pci_target_state(struct pci_dev *dev);
642int pci_prepare_to_sleep(struct pci_dev *dev); 644int pci_prepare_to_sleep(struct pci_dev *dev);
643int pci_back_from_sleep(struct pci_dev *dev); 645int pci_back_from_sleep(struct pci_dev *dev);
644 646