]> err.no Git - linux-2.6/blobdiff - drivers/ata/libata-acpi.c
libata-acpi: add ACPI _PSx method
[linux-2.6] / drivers / ata / libata-acpi.c
index 7bf4befd96bced87785d35c6903b3c38c23d23bc..ebc4dfcf2f19bd4beb1e1d2cb48c671385a7b9a8 100644 (file)
@@ -775,6 +775,36 @@ void ata_acpi_on_resume(struct ata_port *ap)
        }
 }
 
+/**
+ * ata_acpi_set_state - set the port power state
+ * @ap: target ATA port
+ * @state: state, on/off
+ *
+ * This function executes the _PS0/_PS3 ACPI method to set the power state.
+ * ACPI spec requires _PS0 when IDE power on and _PS3 when power off
+ */
+void ata_acpi_set_state(struct ata_port *ap, pm_message_t state)
+{
+       struct ata_device *dev;
+
+       if (!ap->acpi_handle || (ap->flags & ATA_FLAG_ACPI_SATA))
+               return;
+
+       /* channel first and then drives for power on and vica versa
+          for power off */
+       if (state.event == PM_EVENT_ON)
+               acpi_bus_set_power(ap->acpi_handle, ACPI_STATE_D0);
+
+       ata_link_for_each_dev(dev, &ap->link) {
+               if (dev->acpi_handle && ata_dev_enabled(dev))
+                       acpi_bus_set_power(dev->acpi_handle,
+                               state.event == PM_EVENT_ON ?
+                                       ACPI_STATE_D0 : ACPI_STATE_D3);
+       }
+       if (state.event != PM_EVENT_ON)
+               acpi_bus_set_power(ap->acpi_handle, ACPI_STATE_D3);
+}
+
 /**
  * ata_acpi_on_devcfg - ATA ACPI hook called on device donfiguration
  * @dev: target ATA device