summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cpufreq.init69
-rw-r--r--cpufreq.sysconfig12
2 files changed, 81 insertions, 0 deletions
diff --git a/cpufreq.init b/cpufreq.init
new file mode 100644
index 0000000..e3a1a8f
--- /dev/null
+++ b/cpufreq.init
@@ -0,0 +1,69 @@
+#!/bin/bash
+#
+### BEGIN INIT INFO
+# Provides: cpufreq
+# Default-Start: 2 3 4 5
+# Short-Description: Set CPU frequency settings
+# Description: Set CPU frequency settings
+### END INIT INFO
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+RETVAL=0
+
+start() {
+ gprintf "Setting CPU frequency settings: "
+ touch /var/lock/subsys/cpufreq
+ test -f /etc/sysconfig/cpufreq && . /etc/sysconfig/cpufreq
+ for cpu in /sys/devices/system/cpu/* ; do
+ [ "x$GOVERNOR" != "x" ] && [ -f $cpu/cpufreq/scaling_governor ] && echo $GOVERNOR > $cpu/cpufreq/scaling_governor
+ [ "x$MAX_FREQ" != "x" ] && [ -f $cpu/cpufreq/scaling_max_freq ] && echo $MAX_FREQ > $cpu/cpufreq/scaling_max_freq
+ [ "x$MIN_FREQ" != "x" ] && [ -f $cpu/cpufreq/scaling_min_freq ] && echo $MIN_FREQ > $cpu/cpufreq/scaling_min_freq
+ done
+ success
+ echo
+}
+
+real_stop() {
+ gprintf "Resetting CPU frequency settings: "
+ # make sure no governor module is in use first
+ # by switching to userspace governor (because it's built-in and won't modify frequency)
+ for cpu in /sys/devices/system/cpu/* ; do
+ [ -f $cpu/cpufreq/scaling_governor ] && echo userspace > $cpu/cpufreq/scaling_governor
+ done
+ rm -f /var/lock/subsys/cpufreq
+ success
+ echo
+}
+
+restart() {
+ real_stop
+ start
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ ;;
+ restart|reload)
+ restart
+ ;;
+ condrestart)
+ if [ -f /var/lock/subsys/cpufreq ]; then
+ restart
+ fi
+ ;;
+ status)
+ [ -f /var/lock/subsys/cpufreq ]
+ RETVAL=$?
+ ;;
+ *)
+ gprintf "Usage: %s {start|stop|restart|condrestart|status}\n" `basename $0`
+ RETVAL=1
+ ;;
+esac
+
+exit $RETVAL
diff --git a/cpufreq.sysconfig b/cpufreq.sysconfig
new file mode 100644
index 0000000..2e7b122
--- /dev/null
+++ b/cpufreq.sysconfig
@@ -0,0 +1,12 @@
+# set cpufreq governor if defined
+# possible choices are: ondemand powersave userspace performance
+GOVERNOR=ondemand
+
+# minimum frequency
+#MIN_FREQ=
+
+# maximum frequency
+#MAX_FREQ=
+
+# Uncomment to use acpi-cpufreq as fallback
+#USE_ACPI_CPUFREQ=yes