Wiki > Main > DynamicCPUFrequency (compare)
Difference: DynamicCPUFrequency (r9 vs. r8)
To save battery power. We want to run the CPU on the lowest frequency possible as much as possible. When there isn't much to do, the CPU should draw as little power as possible.
The general idea is that tasks that need raw CPU power should run at the maximum speed until the task is done, and then switch back to the idle frequency as soon as possible. The typical case is when the CODEC wants to decode a chunk of data to fill the PCM buffer. We conserve battery by running at the idle frequency as much as possible.
First of all, it draws more power. Secondly, the frequency switch itself takes time, and the tick timer will lose accuracy. On the Coldfire, the PLL takes up to 10ms to lock on the new frequency. Because of this, we should not switch frequency too often.
There are two modes of operation, normal and idle. The idle mode uses the idle frequency when not boosted instead if the normal frequency to save power, for example when in USB mode.
Whenever a thread wants some CPU power, it calls cpu_boost with a true argument:
cpu_boost(true); /* Gimme da raw powah! */
and when it is done, it calls it again with a false argument:
cpu_boost(false); /* Done for now, let's relax */
The cpu_boost() function keeps track of the number of calls, and will not step down the CPU frequency until all callers have reported that they are done. Make sure you call cpu_boost(false) when you're done, otherwise the CPU will continue to run at the maximum frequency, draining the battery.
When you want to save power, like when in USB mode, you call cpu_idle_mode():
cpu_idle_mode(true); /* Let's be calm for a while */
and we call it again to go back to normal:
cpu_idle_mode(false); /* Back to work */
r9 - 21 Aug 2007 - 06:33:01 - JensArnoldRevision r9 - 21 Aug 2007 - 06:33 - JensArnold
Revision r8 - 22 Mar 2007 - 03:16 - PaulLouden
Copyright © by the contributing authors.