Linux Dynamic Frequency Scaling
You need to make a kernel with the CPUfreq drivers built inside :
$ make linux-menuconfig
CPU Power Management ---> [*] CPU Frequency scaling [*] Enable CPUfreq debugging <*> CPU frequency translation statistics [ ] CPU frequency translation statistics details Default CPUFreq governor (performance) ---> -*- 'performance' governor <*> 'powersave' governor <*> 'userspace' governor for userspace frequency scaling <*> 'ondemand' cpufreq policy governor <*> 'conservative' cpufreq governor <*> CPUfreq driver for i.MX CPUs or <*> i.MX27 frequency driver
frequency scaling handling is done in arch/arm/plat-mxc/cpufreq.c or arch/arm/mach-mx2/cpufreq_imx27.c
To know whether the driver is working
# dmesg | grep freq i.MXC CPU frequency driver
- all is here:
# cd /sys/devices/system/cpu/cpu0/cpufreq/ # ls
- identify the current governor:
# cat scaling_governor performance
- list available governors:
# cat scaling_available_governors conservative ondemand userspace powersave performance
- change governor:
# echo powersave > scaling_governor
- change frequency manually (here 133MHz). Requires userspace governor ! :
# echo 133000 > /sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed
- To know current CPU frequency (here 160MHz):
# cat cpuinfo_cur_freq 160000
- To know how much time CPU has spent in its different state (here 160MHz and 800MHz):
# cat stats/time_in_state 160000 243595 800000 585
Effect on current consumption
When there is little activity, the CPU frequency has nearly no visible effect on the current consumed.
This is caused by the "doze mode" : when all processes are sleeping, the kernel turns off the CPU clock until the next IO or timer event.
When there is a 100% CPU activity, the effect of the CPU frequency can be observed with a ammeter.
The % CPU activity per process can be checked with the top command, which is supported by Busybox (but it may be necessary to configure and rebuild busybox to have it)
- To Be Continued...