diff options
Diffstat (limited to 'firmware/target/arm/imx233/debug-imx233.c')
-rw-r--r-- | firmware/target/arm/imx233/debug-imx233.c | 122 |
1 files changed, 120 insertions, 2 deletions
diff --git a/firmware/target/arm/imx233/debug-imx233.c b/firmware/target/arm/imx233/debug-imx233.c index 7eacbf7523..e6b07aef58 100644 --- a/firmware/target/arm/imx233/debug-imx233.c +++ b/firmware/target/arm/imx233/debug-imx233.c | |||
@@ -28,7 +28,9 @@ | |||
28 | #include "adc.h" | 28 | #include "adc.h" |
29 | #include "adc-imx233.h" | 29 | #include "adc-imx233.h" |
30 | #include "power-imx233.h" | 30 | #include "power-imx233.h" |
31 | #include "clkctrl-imx233.h" | ||
31 | #include "powermgmt.h" | 32 | #include "powermgmt.h" |
33 | #include "string.h" | ||
32 | 34 | ||
33 | static struct | 35 | static struct |
34 | { | 36 | { |
@@ -88,7 +90,7 @@ bool dbg_hw_info_power(void) | |||
88 | 90 | ||
89 | while(1) | 91 | while(1) |
90 | { | 92 | { |
91 | int button = get_action(CONTEXT_STD, HZ / 25); | 93 | int button = get_action(CONTEXT_STD, HZ / 10); |
92 | switch(button) | 94 | switch(button) |
93 | { | 95 | { |
94 | case ACTION_STD_NEXT: | 96 | case ACTION_STD_NEXT: |
@@ -151,9 +153,125 @@ bool dbg_hw_info_adc(void) | |||
151 | } | 153 | } |
152 | } | 154 | } |
153 | 155 | ||
156 | static struct | ||
157 | { | ||
158 | enum imx233_clock_t clk; | ||
159 | const char *name; | ||
160 | bool has_enable; | ||
161 | bool has_bypass; | ||
162 | bool has_idiv; | ||
163 | bool has_fdiv; | ||
164 | bool has_freq; | ||
165 | } dbg_clk[] = | ||
166 | { | ||
167 | { CLK_PLL, "pll", true, false, false, false, true}, | ||
168 | { CLK_XTAL, "xtal", false, false, false, false, true}, | ||
169 | { CLK_PIX, "pix", true, true, true, true, true }, | ||
170 | { CLK_SSP, "ssp", true, true, true, false, true }, | ||
171 | { CLK_IO, "io", false, false, false, true, true }, | ||
172 | { CLK_CPU, "cpu", false, true, true, true, true }, | ||
173 | { CLK_HBUS, "hbus", false, false, true, true, true }, | ||
174 | { CLK_EMI, "emi", false, true, true, true, true }, | ||
175 | { CLK_XBUS, "xbus", false, false, true, false, true } | ||
176 | }; | ||
177 | |||
178 | static struct | ||
179 | { | ||
180 | enum imx233_as_monitor_t monitor; | ||
181 | const char *name; | ||
182 | } dbg_as_monitor[] = | ||
183 | { | ||
184 | { AS_CPU_INSTR, "cpu inst" }, | ||
185 | { AS_CPU_DATA, "cpu data" }, | ||
186 | { AS_TRAFFIC, "traffic" }, | ||
187 | { AS_TRAFFIC_JAM, "traffic jam" }, | ||
188 | { AS_APBXDMA, "apbx" }, | ||
189 | { AS_APBHDMA, "apbh" }, | ||
190 | { AS_PXP, "pxp" }, | ||
191 | { AS_DCP, "dcp" } | ||
192 | }; | ||
193 | |||
194 | bool dbg_hw_info_clkctrl(void) | ||
195 | { | ||
196 | lcd_setfont(FONT_SYSFIXED); | ||
197 | imx233_enable_auto_slow_monitor(AS_CPU_INSTR, true); | ||
198 | imx233_enable_auto_slow_monitor(AS_CPU_DATA, true); | ||
199 | imx233_enable_auto_slow_monitor(AS_TRAFFIC, true); | ||
200 | imx233_enable_auto_slow_monitor(AS_TRAFFIC_JAM, true); | ||
201 | imx233_enable_auto_slow_monitor(AS_APBXDMA, true); | ||
202 | imx233_enable_auto_slow_monitor(AS_APBHDMA, true); | ||
203 | |||
204 | while(1) | ||
205 | { | ||
206 | int button = get_action(CONTEXT_STD, HZ / 10); | ||
207 | switch(button) | ||
208 | { | ||
209 | case ACTION_STD_NEXT: | ||
210 | case ACTION_STD_PREV: | ||
211 | case ACTION_STD_OK: | ||
212 | case ACTION_STD_MENU: | ||
213 | lcd_setfont(FONT_UI); | ||
214 | return true; | ||
215 | case ACTION_STD_CANCEL: | ||
216 | lcd_setfont(FONT_UI); | ||
217 | return false; | ||
218 | } | ||
219 | |||
220 | lcd_clear_display(); | ||
221 | |||
222 | /* 012345678901234567890123456789 */ | ||
223 | lcd_putsf(0, 0, "name en by idiv fdiv frequency"); | ||
224 | for(unsigned i = 0; i < ARRAYLEN(dbg_clk); i++) | ||
225 | { | ||
226 | #define c dbg_clk[i] | ||
227 | lcd_putsf(0, i + 1, "%4s", c.name); | ||
228 | if(c.has_enable) | ||
229 | lcd_putsf(5, i + 1, "%2d", imx233_is_clock_enable(c.clk)); | ||
230 | if(c.has_bypass) | ||
231 | lcd_putsf(8, i + 1, "%2d", imx233_get_bypass_pll(c.clk)); | ||
232 | if(c.has_idiv && imx233_get_clock_divisor(c.clk) != 0) | ||
233 | lcd_putsf(10, i + 1, "%4d", imx233_get_clock_divisor(c.clk)); | ||
234 | if(c.has_fdiv && imx233_get_fractional_divisor(c.clk) != 0) | ||
235 | lcd_putsf(16, i + 1, "%4d", imx233_get_fractional_divisor(c.clk)); | ||
236 | if(c.has_freq) | ||
237 | lcd_putsf(21, i + 1, "%9d", imx233_get_clock_freq(c.clk)); | ||
238 | #undef c | ||
239 | } | ||
240 | int line = ARRAYLEN(dbg_clk) + 1; | ||
241 | lcd_putsf(0, line, "auto slow: %d", imx233_is_auto_slow_enable()); | ||
242 | line++; | ||
243 | lcd_putsf(0, line, "as monitor: "); | ||
244 | int x_off = 12; | ||
245 | bool first = true; | ||
246 | unsigned line_w = lcd_getwidth() / font_get_width(font_get(lcd_getfont()), ' '); | ||
247 | for(unsigned i = 0; i < ARRAYLEN(dbg_as_monitor); i++) | ||
248 | { | ||
249 | if(!imx233_is_auto_slow_monitor_enable(dbg_as_monitor[i].monitor)) | ||
250 | continue; | ||
251 | if(!first) | ||
252 | { | ||
253 | lcd_putsf(x_off, line, ", "); | ||
254 | x_off += 2; | ||
255 | } | ||
256 | first = false; | ||
257 | if((x_off + strlen(dbg_as_monitor[i].name)) > line_w) | ||
258 | { | ||
259 | x_off = 1; | ||
260 | line++; | ||
261 | } | ||
262 | lcd_putsf(x_off, line, "%s", dbg_as_monitor[i].name); | ||
263 | x_off += strlen(dbg_as_monitor[i].name); | ||
264 | } | ||
265 | line++; | ||
266 | |||
267 | lcd_update(); | ||
268 | yield(); | ||
269 | } | ||
270 | } | ||
271 | |||
154 | bool dbg_hw_info(void) | 272 | bool dbg_hw_info(void) |
155 | { | 273 | { |
156 | return dbg_hw_info_dma() && dbg_hw_info_adc() && dbg_hw_info_power() && | 274 | return dbg_hw_info_clkctrl() && dbg_hw_info_dma() && dbg_hw_info_adc() && dbg_hw_info_power() && |
157 | dbg_hw_target_info(); | 275 | dbg_hw_target_info(); |
158 | } | 276 | } |
159 | 277 | ||