From e26a3717f93c940b9a8c43bc931983eab02d009a Mon Sep 17 00:00:00 2001 From: Calin Crisan Date: Sun, 5 Jun 2016 12:46:08 +0300 Subject: [PATCH] raspberrypi: added a cpu frequency startup script --- .../raspberrypi/overlay/etc/init.d/S05cpufreq | 36 +++++++++++++++++++ .../overlay/etc/init.d/S05cpufreq | 36 +++++++++++++++++++ .../overlay/etc/init.d/S11brownout | 13 +++---- .../overlay/etc/init.d/S05cpufreq | 36 +++++++++++++++++++ .../overlay/etc/init.d/S11brownout | 13 +++---- 5 files changed, 116 insertions(+), 18 deletions(-) create mode 100755 board/raspberrypi/overlay/etc/init.d/S05cpufreq create mode 100755 board/raspberrypi2/overlay/etc/init.d/S05cpufreq create mode 100755 board/raspberrypi3/overlay/etc/init.d/S05cpufreq diff --git a/board/raspberrypi/overlay/etc/init.d/S05cpufreq b/board/raspberrypi/overlay/etc/init.d/S05cpufreq new file mode 100755 index 0000000000..b0ac2ef671 --- /dev/null +++ b/board/raspberrypi/overlay/etc/init.d/S05cpufreq @@ -0,0 +1,36 @@ +#!/bin/bash + +test -n "$os_version" || source /etc/init.d/base + +gov="ondemand" +cpufreqdir="/sys/devices/system/cpu/cpu0/cpufreq" +govdir="/sys/devices/system/cpu/cpufreq/$gov" + +configure() { + echo $gov > $cpufreqdir/scaling_governor + if [ $gov == "ondemand" ]; then + echo 50 > $govdir/up_threshold + echo 100000 > $govdir/sampling_rate + echo 50 > $govdir/sampling_down_factor + echo 1 > $govdir/io_is_busy + fi +} + +case "$1" in + start) + msg_begin "Configuring CPU Frequency" + configure + test $? == 0 && msg_done || msg_fail + ;; + + stop) + true + ;; + + *) + echo $"Usage: $0 {start}" + exit 1 +esac + +exit $? + diff --git a/board/raspberrypi2/overlay/etc/init.d/S05cpufreq b/board/raspberrypi2/overlay/etc/init.d/S05cpufreq new file mode 100755 index 0000000000..b0ac2ef671 --- /dev/null +++ b/board/raspberrypi2/overlay/etc/init.d/S05cpufreq @@ -0,0 +1,36 @@ +#!/bin/bash + +test -n "$os_version" || source /etc/init.d/base + +gov="ondemand" +cpufreqdir="/sys/devices/system/cpu/cpu0/cpufreq" +govdir="/sys/devices/system/cpu/cpufreq/$gov" + +configure() { + echo $gov > $cpufreqdir/scaling_governor + if [ $gov == "ondemand" ]; then + echo 50 > $govdir/up_threshold + echo 100000 > $govdir/sampling_rate + echo 50 > $govdir/sampling_down_factor + echo 1 > $govdir/io_is_busy + fi +} + +case "$1" in + start) + msg_begin "Configuring CPU Frequency" + configure + test $? == 0 && msg_done || msg_fail + ;; + + stop) + true + ;; + + *) + echo $"Usage: $0 {start}" + exit 1 +esac + +exit $? + diff --git a/board/raspberrypi2/overlay/etc/init.d/S11brownout b/board/raspberrypi2/overlay/etc/init.d/S11brownout index 798f1a15b4..80a256d157 100755 --- a/board/raspberrypi2/overlay/etc/init.d/S11brownout +++ b/board/raspberrypi2/overlay/etc/init.d/S11brownout @@ -1,16 +1,12 @@ #!/bin/bash -gpio=35 check_interval=30 -export=/sys/class/gpio/export -readv=/sys/class/gpio/gpio$gpio/value +readv=/sys/class/leds/led1/brightness + +test -e "$readv" || exit 0 test -n "$os_version" || source /etc/init.d/base -configure() { - echo $gpio > $export -} - watch() { while true; do if [ "$(cat $readv)" == "0" ]; then @@ -23,9 +19,8 @@ watch() { case "$1" in start) msg_begin "Starting brownout detector" - configure - test $? == 0 && msg_done || msg_fail watch & + test $? == 0 && msg_done || msg_fail ;; stop) diff --git a/board/raspberrypi3/overlay/etc/init.d/S05cpufreq b/board/raspberrypi3/overlay/etc/init.d/S05cpufreq new file mode 100755 index 0000000000..b0ac2ef671 --- /dev/null +++ b/board/raspberrypi3/overlay/etc/init.d/S05cpufreq @@ -0,0 +1,36 @@ +#!/bin/bash + +test -n "$os_version" || source /etc/init.d/base + +gov="ondemand" +cpufreqdir="/sys/devices/system/cpu/cpu0/cpufreq" +govdir="/sys/devices/system/cpu/cpufreq/$gov" + +configure() { + echo $gov > $cpufreqdir/scaling_governor + if [ $gov == "ondemand" ]; then + echo 50 > $govdir/up_threshold + echo 100000 > $govdir/sampling_rate + echo 50 > $govdir/sampling_down_factor + echo 1 > $govdir/io_is_busy + fi +} + +case "$1" in + start) + msg_begin "Configuring CPU Frequency" + configure + test $? == 0 && msg_done || msg_fail + ;; + + stop) + true + ;; + + *) + echo $"Usage: $0 {start}" + exit 1 +esac + +exit $? + diff --git a/board/raspberrypi3/overlay/etc/init.d/S11brownout b/board/raspberrypi3/overlay/etc/init.d/S11brownout index 798f1a15b4..80a256d157 100755 --- a/board/raspberrypi3/overlay/etc/init.d/S11brownout +++ b/board/raspberrypi3/overlay/etc/init.d/S11brownout @@ -1,16 +1,12 @@ #!/bin/bash -gpio=35 check_interval=30 -export=/sys/class/gpio/export -readv=/sys/class/gpio/gpio$gpio/value +readv=/sys/class/leds/led1/brightness + +test -e "$readv" || exit 0 test -n "$os_version" || source /etc/init.d/base -configure() { - echo $gpio > $export -} - watch() { while true; do if [ "$(cat $readv)" == "0" ]; then @@ -23,9 +19,8 @@ watch() { case "$1" in start) msg_begin "Starting brownout detector" - configure - test $? == 0 && msg_done || msg_fail watch & + test $? == 0 && msg_done || msg_fail ;; stop)