diff --git a/devlib/bin/scripts/shutils.in b/devlib/bin/scripts/shutils.in index 1ae9a4f..0023a5e 100755 --- a/devlib/bin/scripts/shutils.in +++ b/devlib/bin/scripts/shutils.in @@ -18,6 +18,11 @@ cpufreq_set_all_frequencies() { done } +cpufreq_get_all_frequencies() { + $GREP '' /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq | \ + $SED -e 's|/sys/devices/system/cpu/cpu||' -e 's|/cpufreq/scaling_cur_freq:| |' +} + cpufreq_set_all_governors() { GOV=$1 for CPU in /sys/devices/system/cpu/cpu[0-9]*; do @@ -25,6 +30,11 @@ cpufreq_set_all_governors() { done } +cpufreq_get_all_governors() { + $GREP '' /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor | \ + $SED -e 's|/sys/devices/system/cpu/cpu||' -e 's|/cpufreq/scaling_governor:| |' +} + cpufreq_trace_all_frequencies() { FREQS=$(cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_cur_freq) CPU=0; for F in $FREQS; do @@ -41,9 +51,15 @@ case $CMD in cpufreq_set_all_frequencies) cpufreq_set_all_frequencies $* ;; +cpufreq_get_all_frequencies) + cpufreq_get_all_frequencies + ;; cpufreq_set_all_governors) cpufreq_set_all_governors $* ;; +cpufreq_get_all_governors) + cpufreq_get_all_governors + ;; cpufreq_trace_all_frequencies) cpufreq_trace_all_frequencies $* ;; diff --git a/devlib/module/cpufreq.py b/devlib/module/cpufreq.py index ed2f2e5..31aa9db 100644 --- a/devlib/module/cpufreq.py +++ b/devlib/module/cpufreq.py @@ -357,6 +357,19 @@ class CpufreqModule(Module): 'cpufreq_set_all_frequencies {}'.format(freq), as_root=True) + def get_all_frequencies(self): + """ + Get the current frequency for all the (online) CPUs + """ + output = self.target._execute_util( + 'cpufreq_get_all_frequencies', as_root=True) + frequencies = {} + for x in output.splitlines(): + kv = x.split(' ') + if kv[0] == '': + break + frequencies[kv[0]] = kv[1] + return frequencies def set_all_governors(self, governor): """ @@ -366,6 +379,19 @@ class CpufreqModule(Module): 'cpufreq_set_all_governors {}'.format(governor), as_root=True) + def get_all_governors(self): + """ + Get the current governor for all the (online) CPUs + """ + output = self.target._execute_util( + 'cpufreq_get_all_governors', as_root=True) + governors = {} + for x in output.splitlines(): + kv = x.split(' ') + if kv[0] == '': + break + governors[kv[0]] = kv[1] + return governors def trace_frequencies(self): """