aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/pci-acpi.c28
-rw-r--r--drivers/pci/pci.c8
-rw-r--r--drivers/pci/pci.h2
3 files changed, 29 insertions, 9 deletions
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index c8062494009f..67c63d1f1582 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -245,16 +245,33 @@ EXPORT_SYMBOL(pci_osc_control_set);
245 * currently we simply return _SxD, if present. 245 * currently we simply return _SxD, if present.
246 */ 246 */
247 247
248static int acpi_pci_choose_state(struct pci_dev *pdev, pm_message_t state) 248static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev,
249 pm_message_t state)
249{ 250{
250 /* TBD */ 251 int acpi_state;
251 252
252 return -ENODEV; 253 acpi_state = acpi_pm_device_sleep_state(&pdev->dev,
254 device_may_wakeup(&pdev->dev), NULL);
255 if (acpi_state < 0)
256 return PCI_POWER_ERROR;
257
258 switch (acpi_state) {
259 case ACPI_STATE_D0:
260 return PCI_D0;
261 case ACPI_STATE_D1:
262 return PCI_D1;
263 case ACPI_STATE_D2:
264 return PCI_D2;
265 case ACPI_STATE_D3:
266 return PCI_D3hot;
267 }
268 return PCI_POWER_ERROR;
253} 269}
254 270
255static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state) 271static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
256{ 272{
257 acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev); 273 acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
274 acpi_handle tmp;
258 static int state_conv[] = { 275 static int state_conv[] = {
259 [0] = 0, 276 [0] = 0,
260 [1] = 1, 277 [1] = 1,
@@ -266,6 +283,9 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
266 283
267 if (!handle) 284 if (!handle)
268 return -ENODEV; 285 return -ENODEV;
286 /* If the ACPI device has _EJ0, ignore the device */
287 if (ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0", &tmp)))
288 return 0;
269 return acpi_bus_set_power(handle, acpi_state); 289 return acpi_bus_set_power(handle, acpi_state);
270} 290}
271 291
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index c95485398687..fba319d6fcc8 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -499,7 +499,7 @@ pci_set_power_state(struct pci_dev *dev, pci_power_t state)
499 return 0; 499 return 0;
500} 500}
501 501
502int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state); 502pci_power_t (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
503 503
504/** 504/**
505 * pci_choose_state - Choose the power state of a PCI device 505 * pci_choose_state - Choose the power state of a PCI device
@@ -513,15 +513,15 @@ int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
513 513
514pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state) 514pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
515{ 515{
516 int ret; 516 pci_power_t ret;
517 517
518 if (!pci_find_capability(dev, PCI_CAP_ID_PM)) 518 if (!pci_find_capability(dev, PCI_CAP_ID_PM))
519 return PCI_D0; 519 return PCI_D0;
520 520
521 if (platform_pci_choose_state) { 521 if (platform_pci_choose_state) {
522 ret = platform_pci_choose_state(dev, state); 522 ret = platform_pci_choose_state(dev, state);
523 if (ret >= 0) 523 if (ret != PCI_POWER_ERROR)
524 state.event = ret; 524 return ret;
525 } 525 }
526 526
527 switch (state.event) { 527 switch (state.event) {
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 7b696cd66dc5..c6e132d7c0f7 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -12,7 +12,7 @@ extern int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
12 resource_size_t, resource_size_t), 12 resource_size_t, resource_size_t),
13 void *alignf_data); 13 void *alignf_data);
14/* Firmware callbacks */ 14/* Firmware callbacks */
15extern int (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state); 15extern pci_power_t (*platform_pci_choose_state)(struct pci_dev *dev, pm_message_t state);
16extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state); 16extern int (*platform_pci_set_power_state)(struct pci_dev *dev, pci_power_t state);
17 17
18extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val); 18extern int pci_user_read_config_byte(struct pci_dev *dev, int where, u8 *val);