summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/export/system.h2
-rw-r--r--firmware/system.c22
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
34void set_cpu_frequency(long frequency); 34void set_cpu_frequency(long frequency);
35void cpu_boost(bool on_off); 35void cpu_boost(bool on_off);
36void 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
32int boost_counter = 0; 32int boost_counter = 0;
33bool cpu_idle = false;
33void cpu_boost(bool on_off) 34void 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
61void 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