LeMaker Guitar:CPU frequency scaling
According to your different demands, it is very important for Lemaker Guitar to be able to achieve both high-performance as well as energy efficiency. CPU frequency scaling plays an important role. The lower the clock speed, the slower the device and the less energy it consumes (and vice versa). Even the voltage available to the ARM core(s) will be adjusted depending on the clock speed, there existed a mapping called dvfs_table between clock speeds and voltage. Now in mainline kernel this is done inside the kernel by defining similar operating-points (the higher the CPU is clocked the more voltage it needs to keep its operations reliable).
Not only to define a set of CPU frequency/voltage mappings and upper/lower limits but also strategies to switch between them are needed. These so called cpufreq governors are responsible for that. LeMaker Guitar Linux kernel supports cpu frequency scaling, you can get the list of available governors, the list of available frequencies and current frequency as below:
List available frequencies:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_frequencies 408000 720000 900000 1104000 1308000
Show current frequency:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 900000
List available governors:
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors conservative ondemand userspace powersave interactive performance
The CPUfreq governor "ondemand" sets the CPU depending on the current usage. To do this the CPU must have the capability to switch the frequency very quickly.
The CPUfreq governor "conservative", much like the "ondemand" governor, sets the CPU depending on the current usage. It differs in behaviour in that it gracefully increases and decreases the CPU speed rather than jumping to max speed the moment there is any load on the CPU. This behaviour is more suitable in a battery powered environment.
The CPUfreq governor "userspace" allows the user, or any userspace program running with UID "root", to set the CPU to a specific frequency by making a sysfs file "scaling_setspeed" available in the CPU-device directory.
The CPUfreq governor "powersave" sets the CPU statically to the lowest frequency within the borders of scaling_min_freq and scaling_max_freq.
The CPUfreq governor "performance" sets the CPU statically to the highest frequency within the borders of scaling_min_freq andscaling_max_freq.
Locking CPU frequency
Both the governor chosen as well as the cpufreq limits can have a huge impact on power consumption, performance and even functionality. You can lock the cpufreq as below:
echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor echo 900000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq echo 900000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq echo 35 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold echo 10 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy
And then you can check the settings
cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 900000 cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 900000 cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq 900000 cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ondemand
The default configuration of CPU frequency scaling is saved in /etc/rc.local
cat /etc/rc.local !/bin/sh -e echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor echo 45 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold echo 15 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor echo 1 > /sys/devices/system/cpu/cpufreq/ondemand/io_is_busy exit 0