]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/pci/pci-acpi.c
Merge branch 'origin'
[linux-2.6-omap-h63xx.git] / drivers / pci / pci-acpi.c
index 8eb599708de8b9053bddeb88419da294eec8f9b8..6917c6cb091287a407a6274fa7ebdd382237bed5 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * File:       pci-acpi.c
- * Purpose:    Provde PCI support in ACPI
+ * Purpose:    Provide PCI support in ACPI
  *
  * Copyright (C) 2005 David Shaohua Li <shaohua.li@intel.com>
  * Copyright (C) 2004 Tom Long Nguyen <tom.l.nguyen@intel.com>
@@ -91,9 +91,7 @@ acpi_query_osc (
 static acpi_status  
 acpi_run_osc (
        acpi_handle     handle,
-       u32             level,
-       void            *context,
-       void            **retval )
+       void            *context)
 {
        acpi_status             status;
        struct acpi_object_list input;
@@ -180,11 +178,12 @@ EXPORT_SYMBOL(pci_osc_support_set);
 
 /**
  * pci_osc_control_set - commit requested control to Firmware
+ * @handle: acpi_handle for the target ACPI object
  * @flags: driver's requested control bits
  *
  * Attempt to take control from Firmware on requested control bits.
  **/
-acpi_status pci_osc_control_set(u32 flags)
+acpi_status pci_osc_control_set(acpi_handle handle, u32 flags)
 {
        acpi_status     status;
        u32             ctrlset;
@@ -198,10 +197,7 @@ acpi_status pci_osc_control_set(u32 flags)
                return AE_SUPPORT;
        }
        ctrlset_buf[OSC_CONTROL_TYPE] |= ctrlset;
-       status = acpi_get_devices ( PCI_ROOT_HID_STRING,
-                               acpi_run_osc,
-                               ctrlset_buf,
-                               NULL );
+       status = acpi_run_osc(handle, ctrlset_buf);
        if (ACPI_FAILURE (status)) {
                ctrlset_buf[OSC_CONTROL_TYPE] &= ~ctrlset;
        }
@@ -237,22 +233,29 @@ EXPORT_SYMBOL(pci_osc_control_set);
 
 static int acpi_pci_choose_state(struct pci_dev *pdev, pm_message_t state)
 {
-       char dstate_str[] = "_S0D";
-       acpi_status status;
-       unsigned long val;
-       struct device *dev = &pdev->dev;
+       /* TBD */
 
-       /* Fixme: the check is wrong after pm_message_t is a struct */
-       if ((state >= PM_SUSPEND_MAX) || !DEVICE_ACPI_HANDLE(dev))
-               return -EINVAL;
-       dstate_str[2] += state; /* _S1D, _S2D, _S3D, _S4D */
-       status = acpi_evaluate_integer(DEVICE_ACPI_HANDLE(dev), dstate_str,
-               NULL, &val);
-       if (ACPI_SUCCESS(status))
-               return val;
        return -ENODEV;
 }
 
+static int acpi_pci_set_power_state(struct pci_dev *dev, pci_power_t state)
+{
+       acpi_handle handle = DEVICE_ACPI_HANDLE(&dev->dev);
+       static int state_conv[] = {
+               [0] = 0,
+               [1] = 1,
+               [2] = 2,
+               [3] = 3,
+               [4] = 3
+       };
+       int acpi_state = state_conv[(int __force) state];
+
+       if (!handle)
+               return -ENODEV;
+       return acpi_bus_set_power(handle, acpi_state);
+}
+
+
 /* ACPI bus type */
 static int pci_acpi_find_device(struct device *dev, acpi_handle *handle)
 {
@@ -300,6 +303,7 @@ static int __init pci_acpi_init(void)
        if (ret)
                return 0;
        platform_pci_choose_state = acpi_pci_choose_state;
+       platform_pci_set_power_state = acpi_pci_set_power_state;
        return 0;
 }
 arch_initcall(pci_acpi_init);