1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void set_cpu_frequency(long frequency)
{    if (frequency == CPUFREQ_MAX)
    {
        asm volatile("mov r0, #0\n"
            "mrc p15, 0, r0, c1, c0, 0\n"
            "bic r0, r0, #0xC0000000  \n" /* clear bus bits */
            "orr r0, r0, #0x40000000  \n" /* synchronous bus  */
            "mcr p15, 0, r0, c1, c0, 0" : : : "r0");

        cpu_frequency = CPUFREQ_MAX;
    }
    else
    {
        asm volatile("mov r0, #0\n"
            "mrc p15, 0, r0, c1, c0, 0\n"
            "bic r0, r0, #0xC0000000  \n" /* clear bus bits */
            "bic r0, r0, #3<<30\n" /* set to FastBus mode*/
            "mcr p15, 0, r0, c1, c0, 0" : : : "r0");

        cpu_frequency = CPUFREQ_NORMAL;
    }
}