diff options
-rw-r--r-- | firmware/export/system.h | 2 | ||||
-rw-r--r-- | firmware/system.c | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/firmware/export/system.h b/firmware/export/system.h index 56fee6bdab..f379b325d3 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h | |||
@@ -33,9 +33,11 @@ extern long cpu_frequency; | |||
33 | #define FREQ cpu_frequency | 33 | #define FREQ cpu_frequency |
34 | void set_cpu_frequency(long frequency); | 34 | void set_cpu_frequency(long frequency); |
35 | void cpu_boost(bool on_off); | 35 | void cpu_boost(bool on_off); |
36 | void cpu_idle_mode(bool on_off); | ||
36 | #else | 37 | #else |
37 | #define FREQ CPU_FREQ | 38 | #define FREQ CPU_FREQ |
38 | #define cpu_boost(on_off) | 39 | #define cpu_boost(on_off) |
40 | #define cpu_idle_mode(on_off) | ||
39 | #endif | 41 | #endif |
40 | 42 | ||
41 | #define BAUDRATE 9600 | 43 | #define BAUDRATE 9600 |
diff --git a/firmware/system.c b/firmware/system.c index 66bd90f71b..c01d1270d7 100644 --- a/firmware/system.c +++ b/firmware/system.c | |||
@@ -30,6 +30,7 @@ long cpu_frequency = CPU_FREQ; | |||
30 | 30 | ||
31 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | 31 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ |
32 | int boost_counter = 0; | 32 | int boost_counter = 0; |
33 | bool cpu_idle = false; | ||
33 | void cpu_boost(bool on_off) | 34 | void cpu_boost(bool on_off) |
34 | { | 35 | { |
35 | if(on_off) | 36 | if(on_off) |
@@ -45,7 +46,10 @@ void cpu_boost(bool on_off) | |||
45 | /* Lower the frequency if the counter reaches 0 */ | 46 | /* Lower the frequency if the counter reaches 0 */ |
46 | if(--boost_counter == 0) | 47 | if(--boost_counter == 0) |
47 | { | 48 | { |
48 | set_cpu_frequency(CPUFREQ_NORMAL); | 49 | if(cpu_idle) |
50 | set_cpu_frequency(CPUFREQ_DEFAULT); | ||
51 | else | ||
52 | set_cpu_frequency(CPUFREQ_NORMAL); | ||
49 | } | 53 | } |
50 | 54 | ||
51 | /* Safety measure */ | 55 | /* Safety measure */ |
@@ -53,6 +57,22 @@ void cpu_boost(bool on_off) | |||
53 | boost_counter = 0; | 57 | boost_counter = 0; |
54 | } | 58 | } |
55 | } | 59 | } |
60 | |||
61 | void cpu_idle_mode(bool on_off) | ||
62 | { | ||
63 | cpu_idle = on_off; | ||
64 | |||
65 | /* We need to adjust the frequency immediately if the CPU | ||
66 | isn't boosted */ | ||
67 | if(boost_counter == 0) | ||
68 | { | ||
69 | if(cpu_idle) | ||
70 | set_cpu_frequency(CPUFREQ_DEFAULT); | ||
71 | else | ||
72 | set_cpu_frequency(CPUFREQ_NORMAL); | ||
73 | } | ||
74 | } | ||
75 | |||
56 | #endif | 76 | #endif |
57 | 77 | ||
58 | #if CONFIG_CPU == TCC730 | 78 | #if CONFIG_CPU == TCC730 |