aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ide/ide-acpi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/ide/ide-acpi.c')
-rw-r--r--drivers/ide/ide-acpi.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/drivers/ide/ide-acpi.c b/drivers/ide/ide-acpi.c
index 17aea65d7dd2..6bff81a58bf3 100644
--- a/drivers/ide/ide-acpi.c
+++ b/drivers/ide/ide-acpi.c
@@ -612,6 +612,46 @@ void ide_acpi_push_timing(ide_hwif_t *hwif)
612EXPORT_SYMBOL_GPL(ide_acpi_push_timing); 612EXPORT_SYMBOL_GPL(ide_acpi_push_timing);
613 613
614/** 614/**
615 * ide_acpi_set_state - set the channel power state
616 * @hwif: target IDE interface
617 * @on: state, on/off
618 *
619 * This function executes the _PS0/_PS3 ACPI method to set the power state.
620 * ACPI spec requires _PS0 when IDE power on and _PS3 when power off
621 */
622void ide_acpi_set_state(ide_hwif_t *hwif, int on)
623{
624 int unit;
625
626 if (ide_noacpi)
627 return;
628
629 DEBPRINT("ENTER:\n");
630
631 if (!hwif->acpidata) {
632 DEBPRINT("no ACPI data for %s\n", hwif->name);
633 return;
634 }
635 /* channel first and then drives for power on and verse versa for power off */
636 if (on)
637 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D0);
638 for (unit = 0; unit < MAX_DRIVES; ++unit) {
639 ide_drive_t *drive = &hwif->drives[unit];
640
641 if (!drive->acpidata->obj_handle)
642 drive->acpidata->obj_handle = ide_acpi_drive_get_handle(drive);
643
644 if (drive->acpidata->obj_handle && drive->present) {
645 acpi_bus_set_power(drive->acpidata->obj_handle,
646 on? ACPI_STATE_D0: ACPI_STATE_D3);
647 }
648 }
649 if (!on)
650 acpi_bus_set_power(hwif->acpidata->obj_handle, ACPI_STATE_D3);
651}
652EXPORT_SYMBOL_GPL(ide_acpi_set_state);
653
654/**
615 * ide_acpi_init - initialize the ACPI link for an IDE interface 655 * ide_acpi_init - initialize the ACPI link for an IDE interface
616 * @hwif: target IDE interface (channel) 656 * @hwif: target IDE interface (channel)
617 * 657 *
@@ -679,6 +719,8 @@ void ide_acpi_init(ide_hwif_t *hwif)
679 return; 719 return;
680 } 720 }
681 721
722 /* ACPI _PS0 before _STM */
723 ide_acpi_set_state(hwif, 1);
682 /* 724 /*
683 * ACPI requires us to call _STM on startup 725 * ACPI requires us to call _STM on startup
684 */ 726 */