summaryrefslogtreecommitdiff
path: root/sys-power/pm-utils/files/power.d/pci_devices
diff options
context:
space:
mode:
Diffstat (limited to 'sys-power/pm-utils/files/power.d/pci_devices')
-rw-r--r--sys-power/pm-utils/files/power.d/pci_devices61
1 files changed, 61 insertions, 0 deletions
diff --git a/sys-power/pm-utils/files/power.d/pci_devices b/sys-power/pm-utils/files/power.d/pci_devices
new file mode 100644
index 000000000000..c06b706d82a7
--- /dev/null
+++ b/sys-power/pm-utils/files/power.d/pci_devices
@@ -0,0 +1,61 @@
+#!/bin/sh
+
+#
+# This script adjusts the power control of a set of PCI devices that
+# prove beneficial to enable power savings
+#
+
+PCI_DEVICES_PM_ENABLE="${PCI_DEVICES_PM_ENABLE:-true}"
+
+set_pci_device()
+{
+ for dev in /sys/bus/pci/devices/* ; do
+ if [ -e $dev/class -a -e $dev/power/control ]; then
+ id=`basename $dev`
+ case `cat $dev/class` in
+ 0x020000) # ethernet
+ echo "Setting Ethernet device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x028000) # wireless
+ echo "Setting Wireless device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x040300) # audio
+ echo "Setting Audio device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x060000) # host bridge
+ echo "Setting Host Bridge $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x080500) # SD card reader
+ echo "Setting SD card reader device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x088000|0x088001) # card reader
+ echo "Setting card reader device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ 0x0c0000|0x0c0010) # firewire
+ echo "Setting FireWire device $id to $1"
+ echo $1 > $dev/power/control
+ ;;
+ esac
+ fi
+ done
+}
+
+case "$1" in
+ true) # powersaving on
+ [ "$PCI_DEVICES_PM_ENABLE" = true ] && set_pci_device "auto"
+ ;;
+ false) # powersaving off
+ [ "$PCI_DEVICES_PM_ENABLE" = true ] && set_pci_device "on"
+ ;;
+ *)
+ exit 254
+ ;;
+esac
+
+exit 0