Commit bd3adca5 authored by Shaohua Li's avatar Shaohua Li Committed by Jeff Garzik

libata-acpi: add ACPI _PSx method

ACPI spec (ver 3.0a, p289) requires IDE power on/off executes ACPI _PSx
methods. As recently most PATA drivers use libata, this patch adds _PSx
method support in libata. ACPI spec doesn't mention if SATA requires the
same _PSx method.
Signed-off-by: default avatarShaohua Li <shaohua.li@intel.com>
Acked-by: default avatarLen Brown <len.brown@intel.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent ae8d4ee7
...@@ -775,6 +775,36 @@ void ata_acpi_on_resume(struct ata_port *ap) ...@@ -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 * ata_acpi_on_devcfg - ATA ACPI hook called on device donfiguration
* @dev: target ATA device * @dev: target ATA device
......
...@@ -2747,6 +2747,7 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap) ...@@ -2747,6 +2747,7 @@ static void ata_eh_handle_port_suspend(struct ata_port *ap)
if (ap->ops->port_suspend) if (ap->ops->port_suspend)
rc = ap->ops->port_suspend(ap, ap->pm_mesg); rc = ap->ops->port_suspend(ap, ap->pm_mesg);
ata_acpi_set_state(ap, PMSG_SUSPEND);
out: out:
/* report result */ /* report result */
spin_lock_irqsave(ap->lock, flags); spin_lock_irqsave(ap->lock, flags);
...@@ -2792,6 +2793,8 @@ static void ata_eh_handle_port_resume(struct ata_port *ap) ...@@ -2792,6 +2793,8 @@ static void ata_eh_handle_port_resume(struct ata_port *ap)
WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED)); WARN_ON(!(ap->pflags & ATA_PFLAG_SUSPENDED));
ata_acpi_set_state(ap, PMSG_ON);
if (ap->ops->port_resume) if (ap->ops->port_resume)
rc = ap->ops->port_resume(ap); rc = ap->ops->port_resume(ap);
......
...@@ -114,6 +114,7 @@ extern int ata_acpi_on_suspend(struct ata_port *ap); ...@@ -114,6 +114,7 @@ extern int ata_acpi_on_suspend(struct ata_port *ap);
extern void ata_acpi_on_resume(struct ata_port *ap); extern void ata_acpi_on_resume(struct ata_port *ap);
extern int ata_acpi_on_devcfg(struct ata_device *dev); extern int ata_acpi_on_devcfg(struct ata_device *dev);
extern void ata_acpi_on_disable(struct ata_device *dev); extern void ata_acpi_on_disable(struct ata_device *dev);
extern void ata_acpi_set_state(struct ata_port *ap, pm_message_t state);
#else #else
static inline void ata_acpi_associate_sata_port(struct ata_port *ap) { } static inline void ata_acpi_associate_sata_port(struct ata_port *ap) { }
static inline void ata_acpi_associate(struct ata_host *host) { } static inline void ata_acpi_associate(struct ata_host *host) { }
...@@ -122,6 +123,8 @@ static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } ...@@ -122,6 +123,8 @@ static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; }
static inline void ata_acpi_on_resume(struct ata_port *ap) { } static inline void ata_acpi_on_resume(struct ata_port *ap) { }
static inline int ata_acpi_on_devcfg(struct ata_device *dev) { return 0; } static inline int ata_acpi_on_devcfg(struct ata_device *dev) { return 0; }
static inline void ata_acpi_on_disable(struct ata_device *dev) { } static inline void ata_acpi_on_disable(struct ata_device *dev) { }
static inline void ata_acpi_set_state(struct ata_port *ap,
pm_message_t state) { }
#endif #endif
/* libata-scsi.c */ /* libata-scsi.c */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment