diff options
Diffstat (limited to 'firmware/target/mips/ingenic_x1000')
4 files changed, 19 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_x1000/debug-x1000.c b/firmware/target/mips/ingenic_x1000/debug-x1000.c index fed586691c..74bbcd77a6 100644 --- a/firmware/target/mips/ingenic_x1000/debug-x1000.c +++ b/firmware/target/mips/ingenic_x1000/debug-x1000.c | |||
@@ -130,6 +130,7 @@ static bool dbg_audio(void) | |||
130 | return false; | 130 | return false; |
131 | } | 131 | } |
132 | 132 | ||
133 | #ifdef X1000_CPUIDLE_STATS | ||
133 | static bool dbg_cpuidle(void) | 134 | static bool dbg_cpuidle(void) |
134 | { | 135 | { |
135 | do { | 136 | do { |
@@ -143,6 +144,7 @@ static bool dbg_cpuidle(void) | |||
143 | 144 | ||
144 | return false; | 145 | return false; |
145 | } | 146 | } |
147 | #endif | ||
146 | 148 | ||
147 | #ifdef FIIO_M3K | 149 | #ifdef FIIO_M3K |
148 | extern bool dbg_fiiom3k_touchpad(void); | 150 | extern bool dbg_fiiom3k_touchpad(void); |
@@ -156,7 +158,9 @@ static const struct { | |||
156 | } menuitems[] = { | 158 | } menuitems[] = { |
157 | {"Clocks", &dbg_clocks}, | 159 | {"Clocks", &dbg_clocks}, |
158 | {"GPIOs", &dbg_gpios}, | 160 | {"GPIOs", &dbg_gpios}, |
161 | #ifdef X1000_CPUIDLE_STATS | ||
159 | {"CPU idle", &dbg_cpuidle}, | 162 | {"CPU idle", &dbg_cpuidle}, |
163 | #endif | ||
160 | {"Audio", &dbg_audio}, | 164 | {"Audio", &dbg_audio}, |
161 | #ifdef FIIO_M3K | 165 | #ifdef FIIO_M3K |
162 | {"Touchpad", &dbg_fiiom3k_touchpad}, | 166 | {"Touchpad", &dbg_fiiom3k_touchpad}, |
diff --git a/firmware/target/mips/ingenic_x1000/kernel-x1000.c b/firmware/target/mips/ingenic_x1000/kernel-x1000.c index c8105a3446..eb7c3d6124 100644 --- a/firmware/target/mips/ingenic_x1000/kernel-x1000.c +++ b/firmware/target/mips/ingenic_x1000/kernel-x1000.c | |||
@@ -57,6 +57,7 @@ void tick_start(unsigned interval_in_ms) | |||
57 | 57 | ||
58 | void OST(void) | 58 | void OST(void) |
59 | { | 59 | { |
60 | #ifdef X1000_CPUIDLE_STATS | ||
60 | /* CPU idle time accounting */ | 61 | /* CPU idle time accounting */ |
61 | uint32_t now = __ost_read32(); | 62 | uint32_t now = __ost_read32(); |
62 | uint32_t div = now - __cpu_idle_reftick; | 63 | uint32_t div = now - __cpu_idle_reftick; |
@@ -67,6 +68,7 @@ void OST(void) | |||
67 | __cpu_idle_ticks = 0; | 68 | __cpu_idle_ticks = 0; |
68 | __cpu_idle_reftick = now; | 69 | __cpu_idle_reftick = now; |
69 | } | 70 | } |
71 | #endif | ||
70 | 72 | ||
71 | /* Call regular kernel tick */ | 73 | /* Call regular kernel tick */ |
72 | jz_write(OST_1FLG, 0); | 74 | jz_write(OST_1FLG, 0); |
diff --git a/firmware/target/mips/ingenic_x1000/system-target.h b/firmware/target/mips/ingenic_x1000/system-target.h index 050afcca9e..45a1eab1ff 100644 --- a/firmware/target/mips/ingenic_x1000/system-target.h +++ b/firmware/target/mips/ingenic_x1000/system-target.h | |||
@@ -37,6 +37,11 @@ | |||
37 | # define MIPS_CACHEFUNC_ATTR | 37 | # define MIPS_CACHEFUNC_ATTR |
38 | #endif | 38 | #endif |
39 | 39 | ||
40 | #ifdef DEBUG | ||
41 | /* Define this to get CPU idle stats, visible in the debug menu. */ | ||
42 | # define X1000_CPUIDLE_STATS | ||
43 | #endif | ||
44 | |||
40 | #include "mmu-mips.h" | 45 | #include "mmu-mips.h" |
41 | #include "mipsregs.h" | 46 | #include "mipsregs.h" |
42 | #include "mipsr2-endian.h" | 47 | #include "mipsr2-endian.h" |
@@ -66,16 +71,20 @@ static inline int set_irq_level(int lev) | |||
66 | return oldreg; | 71 | return oldreg; |
67 | } | 72 | } |
68 | 73 | ||
74 | #ifdef X1000_CPUIDLE_STATS | ||
69 | /* CPU idle stats, updated each kernel tick in kernel-x1000.c */ | 75 | /* CPU idle stats, updated each kernel tick in kernel-x1000.c */ |
70 | extern int __cpu_idle_avg; | 76 | extern int __cpu_idle_avg; |
71 | extern int __cpu_idle_cur; | 77 | extern int __cpu_idle_cur; |
72 | extern uint32_t __cpu_idle_ticks; | 78 | extern uint32_t __cpu_idle_ticks; |
73 | extern uint32_t __cpu_idle_reftick; | 79 | extern uint32_t __cpu_idle_reftick; |
80 | #endif | ||
74 | 81 | ||
75 | static inline uint32_t __ost_read32(void); | 82 | static inline uint32_t __ost_read32(void); |
76 | static inline void core_sleep(void) | 83 | static inline void core_sleep(void) |
77 | { | 84 | { |
85 | #ifdef X1000_CPUIDLE_STATS | ||
78 | uint32_t t1 = __ost_read32(); | 86 | uint32_t t1 = __ost_read32(); |
87 | #endif | ||
79 | 88 | ||
80 | __asm__ __volatile__( | 89 | __asm__ __volatile__( |
81 | ".set push\n\t" | 90 | ".set push\n\t" |
@@ -90,8 +99,10 @@ static inline void core_sleep(void) | |||
90 | ".set pop\n\t" | 99 | ".set pop\n\t" |
91 | ::: "t0", "t1", "t2"); | 100 | ::: "t0", "t1", "t2"); |
92 | 101 | ||
102 | #ifdef X1000_CPUIDLE_STATS | ||
93 | uint32_t t2 = __ost_read32(); | 103 | uint32_t t2 = __ost_read32(); |
94 | __cpu_idle_ticks += t2 - t1; | 104 | __cpu_idle_ticks += t2 - t1; |
105 | #endif | ||
95 | 106 | ||
96 | enable_irq(); | 107 | enable_irq(); |
97 | } | 108 | } |
diff --git a/firmware/target/mips/ingenic_x1000/system-x1000.c b/firmware/target/mips/ingenic_x1000/system-x1000.c index d841a274ed..33d8db7222 100644 --- a/firmware/target/mips/ingenic_x1000/system-x1000.c +++ b/firmware/target/mips/ingenic_x1000/system-x1000.c | |||
@@ -35,10 +35,12 @@ | |||
35 | #include "x1000/msc.h" | 35 | #include "x1000/msc.h" |
36 | #include "x1000/aic.h" | 36 | #include "x1000/aic.h" |
37 | 37 | ||
38 | #ifdef X1000_CPUIDLE_STATS | ||
38 | int __cpu_idle_avg = 0; | 39 | int __cpu_idle_avg = 0; |
39 | int __cpu_idle_cur = 0; | 40 | int __cpu_idle_cur = 0; |
40 | uint32_t __cpu_idle_ticks = 0; | 41 | uint32_t __cpu_idle_ticks = 0; |
41 | uint32_t __cpu_idle_reftick = 0; | 42 | uint32_t __cpu_idle_reftick = 0; |
43 | #endif | ||
42 | 44 | ||
43 | /* Prepare the CPU to process interrupts, but don't enable them yet */ | 45 | /* Prepare the CPU to process interrupts, but don't enable them yet */ |
44 | static void system_init_irq(void) | 46 | static void system_init_irq(void) |