diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2010-02-17 17:44:58 -0500 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2010-02-22 19:21:19 -0500 |
commit | 6cbf82148ff286ec22a55be6836c3a5bffc489c1 (patch) | |
tree | 77b1b0097f9c2389d56734ec4c022611aa1bd9db /drivers/pci/pci.c | |
parent | 552be54cc4232dc5acc49ccb372129d6f1b6923f (diff) |
PCI PM: Run-time callbacks for PCI bus type
Introduce run-time PM callbacks for the PCI bus type. Make the new
callbacks work in analogy with the existing system sleep PM
callbacks, so that the drivers already converted to struct dev_pm_ops
can use their suspend and resume routines for run-time PM without
modifications.
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.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index df55a2f351b3..d62a5de81672 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -1302,9 +1302,10 @@ void pci_pme_active(struct pci_dev *dev, bool enable) | |||
1302 | } | 1302 | } |
1303 | 1303 | ||
1304 | /** | 1304 | /** |
1305 | * pci_enable_wake - enable PCI device as wakeup event source | 1305 | * __pci_enable_wake - enable PCI device as wakeup event source |
1306 | * @dev: PCI device affected | 1306 | * @dev: PCI device affected |
1307 | * @state: PCI state from which device will issue wakeup events | 1307 | * @state: PCI state from which device will issue wakeup events |
1308 | * @runtime: True if the events are to be generated at run time | ||
1308 | * @enable: True to enable event generation; false to disable | 1309 | * @enable: True to enable event generation; false to disable |
1309 | * | 1310 | * |
1310 | * This enables the device as a wakeup event source, or disables it. | 1311 | * This enables the device as a wakeup event source, or disables it. |
@@ -1320,11 +1321,12 @@ void pci_pme_active(struct pci_dev *dev, bool enable) | |||
1320 | * Error code depending on the platform is returned if both the platform and | 1321 | * Error code depending on the platform is returned if both the platform and |
1321 | * the native mechanism fail to enable the generation of wake-up events | 1322 | * the native mechanism fail to enable the generation of wake-up events |
1322 | */ | 1323 | */ |
1323 | int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) | 1324 | int __pci_enable_wake(struct pci_dev *dev, pci_power_t state, |
1325 | bool runtime, bool enable) | ||
1324 | { | 1326 | { |
1325 | int ret = 0; | 1327 | int ret = 0; |
1326 | 1328 | ||
1327 | if (enable && !device_may_wakeup(&dev->dev)) | 1329 | if (enable && !runtime && !device_may_wakeup(&dev->dev)) |
1328 | return -EINVAL; | 1330 | return -EINVAL; |
1329 | 1331 | ||
1330 | /* Don't do the same thing twice in a row for one device. */ | 1332 | /* Don't do the same thing twice in a row for one device. */ |
@@ -1344,19 +1346,24 @@ int pci_enable_wake(struct pci_dev *dev, pci_power_t state, bool enable) | |||
1344 | pci_pme_active(dev, true); | 1346 | pci_pme_active(dev, true); |
1345 | else | 1347 | else |
1346 | ret = 1; | 1348 | ret = 1; |
1347 | error = platform_pci_sleep_wake(dev, true); | 1349 | error = runtime ? platform_pci_run_wake(dev, true) : |
1350 | platform_pci_sleep_wake(dev, true); | ||
1348 | if (ret) | 1351 | if (ret) |
1349 | ret = error; | 1352 | ret = error; |
1350 | if (!ret) | 1353 | if (!ret) |
1351 | dev->wakeup_prepared = true; | 1354 | dev->wakeup_prepared = true; |
1352 | } else { | 1355 | } else { |
1353 | platform_pci_sleep_wake(dev, false); | 1356 | if (runtime) |
1357 | platform_pci_run_wake(dev, false); | ||
1358 | else | ||
1359 | platform_pci_sleep_wake(dev, false); | ||
1354 | pci_pme_active(dev, false); | 1360 | pci_pme_active(dev, false); |
1355 | dev->wakeup_prepared = false; | 1361 | dev->wakeup_prepared = false; |
1356 | } | 1362 | } |
1357 | 1363 | ||
1358 | return ret; | 1364 | return ret; |
1359 | } | 1365 | } |
1366 | EXPORT_SYMBOL(__pci_enable_wake); | ||
1360 | 1367 | ||
1361 | /** | 1368 | /** |
1362 | * pci_wake_from_d3 - enable/disable device to wake up from D3_hot or D3_cold | 1369 | * pci_wake_from_d3 - enable/disable device to wake up from D3_hot or D3_cold |
@@ -1466,6 +1473,31 @@ int pci_back_from_sleep(struct pci_dev *dev) | |||
1466 | } | 1473 | } |
1467 | 1474 | ||
1468 | /** | 1475 | /** |
1476 | * pci_finish_runtime_suspend - Carry out PCI-specific part of runtime suspend. | ||
1477 | * @dev: PCI device being suspended. | ||
1478 | * | ||
1479 | * Prepare @dev to generate wake-up events at run time and put it into a low | ||
1480 | * power state. | ||
1481 | */ | ||
1482 | int pci_finish_runtime_suspend(struct pci_dev *dev) | ||
1483 | { | ||
1484 | pci_power_t target_state = pci_target_state(dev); | ||
1485 | int error; | ||
1486 | |||
1487 | if (target_state == PCI_POWER_ERROR) | ||
1488 | return -EIO; | ||
1489 | |||
1490 | __pci_enable_wake(dev, target_state, true, pci_dev_run_wake(dev)); | ||
1491 | |||
1492 | error = pci_set_power_state(dev, target_state); | ||
1493 | |||
1494 | if (error) | ||
1495 | __pci_enable_wake(dev, target_state, true, false); | ||
1496 | |||
1497 | return error; | ||
1498 | } | ||
1499 | |||
1500 | /** | ||
1469 | * pci_dev_run_wake - Check if device can generate run-time wake-up events. | 1501 | * pci_dev_run_wake - Check if device can generate run-time wake-up events. |
1470 | * @dev: Device to check. | 1502 | * @dev: Device to check. |
1471 | * | 1503 | * |
@@ -2978,7 +3010,6 @@ EXPORT_SYMBOL(pci_save_state); | |||
2978 | EXPORT_SYMBOL(pci_restore_state); | 3010 | EXPORT_SYMBOL(pci_restore_state); |
2979 | EXPORT_SYMBOL(pci_pme_capable); | 3011 | EXPORT_SYMBOL(pci_pme_capable); |
2980 | EXPORT_SYMBOL(pci_pme_active); | 3012 | EXPORT_SYMBOL(pci_pme_active); |
2981 | EXPORT_SYMBOL(pci_enable_wake); | ||
2982 | EXPORT_SYMBOL(pci_wake_from_d3); | 3013 | EXPORT_SYMBOL(pci_wake_from_d3); |
2983 | EXPORT_SYMBOL(pci_target_state); | 3014 | EXPORT_SYMBOL(pci_target_state); |
2984 | EXPORT_SYMBOL(pci_prepare_to_sleep); | 3015 | EXPORT_SYMBOL(pci_prepare_to_sleep); |