]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pci/pci-acpi.c
PCI ACPI: Fix comment describing acpi_pci_choose_state
[linux-2.6-omap-h63xx.git] / drivers / pci / pci-acpi.c
index c8062494009f8fdb692adbbe15bb741a870064cd..e818e52dc39ab373e164feec754200f0eac0d1e7 100644 (file)
@@ -156,13 +156,13 @@ run_osc_out:
 }
 
 /**
- * pci_osc_support_set - register OS support to Firmware
+ * __pci_osc_support_set - register OS support to Firmware
  * @flags: OS support bits
  *
  * Update OS support fields and doing a _OSC Query to obtain an update
  * from Firmware on supported control bits.
  **/
-acpi_status pci_osc_support_set(u32 flags)
+acpi_status __pci_osc_support_set(u32 flags, const char *hid)
 {
        u32 temp;
        acpi_status retval;
@@ -176,7 +176,7 @@ acpi_status pci_osc_support_set(u32 flags)
        temp = ctrlset_buf[OSC_CONTROL_TYPE];
        ctrlset_buf[OSC_QUERY_TYPE] = OSC_QUERY_ENABLE;
        ctrlset_buf[OSC_CONTROL_TYPE] = OSC_CONTROL_MASKS;
-       acpi_get_devices ( PCI_ROOT_HID_STRING,
+       acpi_get_devices(hid,
                        acpi_query_osc,
                        ctrlset_buf,
                        (void **) &retval );
@@ -188,7 +188,6 @@ acpi_status pci_osc_support_set(u32 flags)
        }
        return AE_OK;
 }
-EXPORT_SYMBOL(pci_osc_support_set);
 
 /**
  * pci_osc_control_set - commit requested control to Firmware
@@ -220,6 +219,7 @@ acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
 }
 EXPORT_SYMBOL(pci_osc_control_set);
 
+#ifdef CONFIG_ACPI_SLEEP
 /*
  * _SxD returns the D-state with the highest power
  * (lowest D-state number) supported in the S-state "x".
@@ -241,20 +241,36 @@ EXPORT_SYMBOL(pci_osc_control_set);
  *     choose from highest power _SxD to lowest power _SxW
  * else // no _PRW at S-state x
  *     choose highest power _SxD or any lower power
- *
- * currently we simply return _SxD, if present.
  */
 
-static int acpi_pci_choose_state(struct pci_dev *pdev, pm_message_t state)
+static pci_power_t acpi_pci_choose_state(struct pci_dev *pdev,
+       pm_message_t state)
 {
-       /* TBD */
-
-       return -ENODEV;
+       int acpi_state;
+
+       acpi_state = acpi_pm_device_sleep_state(&pdev->dev,
+               device_may_wakeup(&pdev->dev), NULL);
+       if (acpi_state < 0)
+               return PCI_POWER_ERROR;
+
+       switch (acpi_state) {
+       case ACPI_STATE_D0:
+               return PCI_D0;
+       case ACPI_STATE_D1:
+               return PCI_D1;
+       case ACPI_STATE_D2:
+               return PCI_D2;
+       case ACPI_STATE_D3:
+               return PCI_D3hot;
+       }
+       return PCI_POWER_ERROR;
 }
+#endif
 
 static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
 {
        acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
+       acpi_handle tmp;
        static int state_conv[] = {
                [0] = 0,
                [1] = 1,
@@ -266,6 +282,9 @@ static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
 
        if (!handle)
                return -ENODEV;
+       /* If the ACPI device has _EJ0, ignore the device */
+       if (ACPI_SUCCESS(acpi_get_handle(handle, "_EJ0", &tmp)))
+               return 0;
        return acpi_bus_set_power(handle, acpi_state);
 }
 
@@ -320,7 +339,9 @@ static int __init acpi_pci_init(void)
        ret = register_acpi_bus_type(&acpi_pci_bus);
        if (ret)
                return 0;
+#ifdef CONFIG_ACPI_SLEEP
        platform_pci_choose_state = acpi_pci_choose_state;
+#endif
        platform_pci_set_power_state = acpi_pci_set_power_state;
        return 0;
 }