summaryrefslogtreecommitdiff
path: root/pm/power.d/sata_alpm
blob: 82c820132e1fd8f9d0feed65b7fccdd346d16106 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh

. "${PM_FUNCTIONS}"

SATA_ALPM_ENABLE=${SATA_ALPM_ENABLE:-true}

help() {
cat <<EOF
$0: SATA link power management

This hook tries to save power by allowing SATA controllers to
reduce power usage when the SATA subsystem is otherwise idle.

This adds a little bit of latency to drive accesses in
exchange for moderate power savings if you are not using the drive.

This hook has 1 parameter:
SATA_ALPM_ENABLE = whether to use SATA ALPM on battery.
Defaults to "true".

EOF
}

set_sata_alpm() {
    for f in /sys/class/scsi_host/host*/link_power_management_policy; do
	[ -w "$f" ] || continue
	echo "$1" > "$f"
    done
}

case $1 in
    true) [ "$SATA_ALPM_ENABLE" = true ] && set_sata_alpm min_power;;
    false) set_sata_alpm max_performance;;
    help) help;;
    *) exit $NA;;
esac

exit 0