aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci/pci.c')
-rw-r--r--drivers/pci/pci.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index f04b9ffe4153..1b34fc56067e 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -235,7 +235,7 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
235 * -EIO if device does not support PCI PM. 235 * -EIO if device does not support PCI PM.
236 * 0 if we can successfully change the power state. 236 * 0 if we can successfully change the power state.
237 */ 237 */
238 238int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t t);
239int 239int
240pci_set_power_state(struct pci_dev *dev, pci_power_t state) 240pci_set_power_state(struct pci_dev *dev, pci_power_t state)
241{ 241{
@@ -299,11 +299,20 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state)
299 msleep(10); 299 msleep(10);
300 else if (state == PCI_D2 || dev->current_state == PCI_D2) 300 else if (state == PCI_D2 || dev->current_state == PCI_D2)
301 udelay(200); 301 udelay(200);
302 dev->current_state = state;
303 302
303 /*
304 * Give firmware a chance to be called, such as ACPI _PRx, _PSx
305 * Firmware method after natice method ?
306 */
307 if (platform_pci_set_power_state)
308 platform_pci_set_power_state(dev, state);
309
310 dev->current_state = state;
304 return 0; 311 return 0;
305} 312}
306 313
314int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
315
307/** 316/**
308 * pci_choose_state - Choose the power state of a PCI device 317 * pci_choose_state - Choose the power state of a PCI device
309 * @dev: PCI device to be suspended 318 * @dev: PCI device to be suspended
@@ -316,10 +325,17 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state)
316 325
317pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) 326pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
318{ 327{
328 int ret;
329
319 if (!pci_find_capability(dev, PCI_CAP_ID_PM)) 330 if (!pci_find_capability(dev, PCI_CAP_ID_PM))
320 return PCI_D0; 331 return PCI_D0;
321 332
322 switch (state) { 333 if (platform_pci_choose_state) {
334 ret = platform_pci_choose_state(dev, state);
335 if (ret >= 0)
336 state = ret;
337 }
338 switch (state) {
323 case 0: return PCI_D0; 339 case 0: return PCI_D0;
324 case 3: return PCI_D3hot; 340 case 3: return PCI_D3hot;
325 default: 341 default:
@@ -334,10 +350,6 @@ EXPORT_SYMBOL(pci_choose_state);
334/** 350/**
335 * pci_save_state - save the PCI configuration space of a device before suspending 351 * pci_save_state - save the PCI configuration space of a device before suspending
336 * @dev: - PCI device that we're dealing with 352 * @dev: - PCI device that we're dealing with
337 * @buffer: - buffer to hold config space context
338 *
339 * @buffer must be large enough to hold the entire PCI 2.2 config space
340 * (>= 64 bytes).
341 */ 353 */
342int 354int
343pci_save_state(struct pci_dev *dev) 355pci_save_state(struct pci_dev *dev)
@@ -352,8 +364,6 @@ pci_save_state(struct pci_dev *dev)
352/** 364/**
353 * pci_restore_state - Restore the saved state of a PCI device 365 * pci_restore_state - Restore the saved state of a PCI device
354 * @dev: - PCI device that we're dealing with 366 * @dev: - PCI device that we're dealing with
355 * @buffer: - saved PCI config space
356 *
357 */ 367 */
358int 368int
359pci_restore_state(struct pci_dev *dev) 369pci_restore_state(struct pci_dev *dev)