blob: f07330575a14c1f45a50462277800c13c108d51f (
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# Copyright (C) 2012, Linaro Limited.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Author: Amit Pundir <amit.pundir@linaro.org>
# Modified-by: Naresh Kamboju <naresh.kamboju@linaro.org>
#
usage()
{
echo ""
echo "usage: $0 -c <cpu number> [Optional Arguments...]"
echo "Options: -c operate on this cpu, this option can be specified multiple times"
echo ""
echo "Example: $0 -c 0 -c 1 ... -c $large_cpu_number"
exit 1
}
check_kernel_oops()
{
KERNEL_ERR=`dmesg | grep "Unable to handle kernel "`
if [ -n "$KERNEL_ERR" ]; then
echo "Kernel OOPS. Abort!!"
exit 1
fi
}
insert_bl_module()
{
ANDROID_MOD_PATH=/system/modules
UBUNTU_MOD_PATH=/lib/modules/`uname -r`/kernel/drivers/cpufreq
if [ -d $ANDROID_MOD_PATH ]; then
MOD_LOCATION=$ANDROID_MOD_PATH/arm-bl-cpufreq.ko
else if [ -d $UBUNTU_MOD_PATH ]; then
MOD_LOCATION=$UBUNTU_MOD_PATH/arm-bl-cpufreq.ko
else
echo "ERROR: No arm-bl-cpufreq.ko module found"
exit 1
fi
fi
CPU_FREQ_KM=`lsmod | grep cpufreq | awk '{print $1}'`
if [ -z "$CPU_FREQ_KM" ]; then
insmod $MOD_LOCATION
fi
check_kernel_oops
}
switch()
{
CUR_FREQ=`cat /sys/devices/system/cpu/cpu"$CPU_NUM"/cpufreq/cpuinfo_cur_freq`
if [ -z $CUR_FREQ ]; then
echo "Unable to get current operating frequency"
exit 1
fi
if [ "$CUR_FREQ" -eq "$LITTLE" ]; then
echo "cpu$CPU_NUM is LITTLE"
else if [ "$CUR_FREQ" -eq "$BIG" ]; then
echo "cpu$CPU_NUM is big. Switching to LITTLE.."
bl-agitator -f little -c $CPU_NUM
ERR_CODE=$?
if [ $ERR_CODE -ne 0 ]; then
echo "bigLITTLE switcher failed for cpu$CPU_NUM. Abort!!"
exit 1
else
echo "cpu$CPU_NUM successfully switched to LITTLE."
fi
else if [ "$CUR_FREQ" -lt "$BIG" ]; then
if [ "$CUR_FREQ" -gt "$LITTLE" ]; then
echo "cpu$CPU_NUM is big. Switching to LITTLE.."
bl-agitator -f little -c $CPU_NUM
ERR_CODE=$?
if [ $ERR_CODE -ne 0 ]; then
echo "bigLITTLE switcher failed for cpu$CPU_NUM. Abort!!"
exit 1
else
echo "cpu$CPU_NUM successfully switched to LITTLE."
fi
fi
else
echo "cpu$CPU_NUM operating at Current Frequency = $CUR_FREQ"
exit 1
fi
fi
fi
}
TOTAL_ACTIVE_CPUS=`ls /sys/devices/system/cpu/cpu*/online | wc -l`
large_cpu_number=$((TOTAL_ACTIVE_CPUS-1))
if [ $(echo "$2" | grep -E "^[0-$large_cpu_number]+$") ]; then
echo "Running $0 $1 $2"
else
echo "Error: Specify the number of CPU core (0-$large_cpu_number) to be switched to the desired frequency"
usage
fi
# insert bl module is intended for RTSM
MODEL=`cat /proc/device-tree/model`
if [ "$MODEL" = "RTSM_VE_CortexA15x4-A7x4" ]; then
echo "insert bl module from boot-a7.sh"
insert_bl_module
fi
BIG=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq`
LITTLE=`cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_min_freq`
while [ "$1" ]; do
case "$1" in
-c|--cpu-num)
if [ -z "$2" ]; then
echo "Error: Specify the CPU core (0-$large_cpu_number) to be switched to the desired frequency"
usage
fi
if [ $(echo "$2" | grep -E "^[0-$large_cpu_number]+$") ]; then
CPU_NUM=$2;
switch
shift;
else
usage
fi
;;
-h | --help | *)
usage
;;
esac
shift;
done
check_kernel_oops
exit 0
|