diff options
Diffstat (limited to 'firmware/target/arm/pp/debug-pp.c')
-rw-r--r-- | firmware/target/arm/pp/debug-pp.c | 232 |
1 files changed, 232 insertions, 0 deletions
diff --git a/firmware/target/arm/pp/debug-pp.c b/firmware/target/arm/pp/debug-pp.c new file mode 100644 index 0000000000..5f252db417 --- /dev/null +++ b/firmware/target/arm/pp/debug-pp.c | |||
@@ -0,0 +1,232 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 Dave Chapman | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "config.h" | ||
23 | #include "system.h" | ||
24 | #include <stdbool.h> | ||
25 | #include "font.h" | ||
26 | #include "lcd.h" | ||
27 | #include "button.h" | ||
28 | #include "powermgmt.h" | ||
29 | #include "adc.h" | ||
30 | #include "iap.h" | ||
31 | #include "hwcompat.h" | ||
32 | #include "debug-target.h" | ||
33 | |||
34 | static int perfcheck(void) | ||
35 | { | ||
36 | int result; | ||
37 | |||
38 | asm ( | ||
39 | "mrs r2, CPSR \n" | ||
40 | "orr r0, r2, #0xc0 \n" /* disable IRQ and FIQ */ | ||
41 | "msr CPSR_c, r0 \n" | ||
42 | "mov %[res], #0 \n" | ||
43 | "ldr r0, [%[timr]] \n" | ||
44 | "add r0, r0, %[tmo] \n" | ||
45 | "1: \n" | ||
46 | "add %[res], %[res], #1 \n" | ||
47 | "ldr r1, [%[timr]] \n" | ||
48 | "cmp r1, r0 \n" | ||
49 | "bmi 1b \n" | ||
50 | "msr CPSR_c, r2 \n" /* reset IRQ and FIQ state */ | ||
51 | : | ||
52 | [res]"=&r"(result) | ||
53 | : | ||
54 | [timr]"r"(&USEC_TIMER), | ||
55 | [tmo]"r"( | ||
56 | #if CONFIG_CPU == PP5002 | ||
57 | 16000 | ||
58 | #else /* PP5020/5022/5024 */ | ||
59 | 10226 | ||
60 | #endif | ||
61 | ) | ||
62 | : | ||
63 | "r0", "r1", "r2" | ||
64 | ); | ||
65 | return result; | ||
66 | } | ||
67 | |||
68 | bool dbg_ports(void) | ||
69 | { | ||
70 | int line; | ||
71 | |||
72 | lcd_clear_display(); | ||
73 | lcd_setfont(FONT_SYSFIXED); | ||
74 | |||
75 | while(1) | ||
76 | { | ||
77 | line = 0; | ||
78 | #if defined(CPU_PP502x) | ||
79 | #if (LCD_HEIGHT >= 176) /* Only for displays with appropriate height. */ | ||
80 | lcd_puts(0, line++, "GPIO ENABLE:"); | ||
81 | lcd_putsf(0, line++, "A: %02x E: %02x I: %02x", | ||
82 | (unsigned int)GPIOA_ENABLE, | ||
83 | (unsigned int)GPIOE_ENABLE, | ||
84 | (unsigned int)GPIOI_ENABLE); | ||
85 | lcd_putsf(0, line++, "B: %02x F: %02x J: %02x", | ||
86 | (unsigned int)GPIOB_ENABLE, | ||
87 | (unsigned int)GPIOF_ENABLE, | ||
88 | (unsigned int)GPIOJ_ENABLE); | ||
89 | lcd_putsf(0, line++, "C: %02x G: %02x K: %02x", | ||
90 | (unsigned int)GPIOC_ENABLE, | ||
91 | (unsigned int)GPIOG_ENABLE, | ||
92 | (unsigned int)GPIOK_ENABLE); | ||
93 | lcd_putsf(0, line++, "D: %02x H: %02x L: %02x", | ||
94 | (unsigned int)GPIOD_ENABLE, | ||
95 | (unsigned int)GPIOH_ENABLE, | ||
96 | (unsigned int)GPIOL_ENABLE); | ||
97 | line++; | ||
98 | #endif | ||
99 | lcd_puts(0, line++, "GPIO INPUT VAL:"); | ||
100 | lcd_putsf(0, line++, "A: %02x E: %02x I: %02x", | ||
101 | (unsigned int)GPIOA_INPUT_VAL, | ||
102 | (unsigned int)GPIOE_INPUT_VAL, | ||
103 | (unsigned int)GPIOI_INPUT_VAL); | ||
104 | lcd_putsf(0, line++, "B: %02x F: %02x J: %02x", | ||
105 | (unsigned int)GPIOB_INPUT_VAL, | ||
106 | (unsigned int)GPIOF_INPUT_VAL, | ||
107 | (unsigned int)GPIOJ_INPUT_VAL); | ||
108 | lcd_putsf(0, line++, "C: %02x G: %02x K: %02x", | ||
109 | (unsigned int)GPIOC_INPUT_VAL, | ||
110 | (unsigned int)GPIOG_INPUT_VAL, | ||
111 | (unsigned int)GPIOK_INPUT_VAL); | ||
112 | lcd_putsf(0, line++, "D: %02x H: %02x L: %02x", | ||
113 | (unsigned int)GPIOD_INPUT_VAL, | ||
114 | (unsigned int)GPIOH_INPUT_VAL, | ||
115 | (unsigned int)GPIOL_INPUT_VAL); | ||
116 | line++; | ||
117 | lcd_putsf(0, line++, "GPO32_VAL: %08lx", GPO32_VAL); | ||
118 | lcd_putsf(0, line++, "GPO32_EN: %08lx", GPO32_ENABLE); | ||
119 | lcd_putsf(0, line++, "DEV_EN: %08lx", DEV_EN); | ||
120 | lcd_putsf(0, line++, "DEV_EN2: %08lx", DEV_EN2); | ||
121 | lcd_putsf(0, line++, "DEV_EN3: %08lx", inl(0x60006044)); /* to be verified */ | ||
122 | lcd_putsf(0, line++, "DEV_INIT1: %08lx", DEV_INIT1); | ||
123 | lcd_putsf(0, line++, "DEV_INIT2: %08lx", DEV_INIT2); | ||
124 | #ifdef ADC_ACCESSORY | ||
125 | lcd_putsf(0, line++, "ACCESSORY: %d", adc_read(ADC_ACCESSORY)); | ||
126 | #endif | ||
127 | #if defined(IPOD_VIDEO) || defined(IPOD_NANO) | ||
128 | lcd_putsf(0, line++, "4066_ISTAT: %d", adc_read(ADC_4066_ISTAT)); | ||
129 | #endif | ||
130 | |||
131 | #if defined(IPOD_ACCESSORY_PROTOCOL) | ||
132 | const unsigned char *serbuf = iap_get_serbuf(); | ||
133 | lcd_putsf(0, line++, "IAP: %02x %02x %02x %02x %02x %02x %02x %02x", | ||
134 | serbuf[0], serbuf[1], serbuf[2], serbuf[3], serbuf[4], serbuf[5], | ||
135 | serbuf[6], serbuf[7]); | ||
136 | #endif | ||
137 | |||
138 | #if defined(IRIVER_H10) || defined(IRIVER_H10_5GB) | ||
139 | line++; | ||
140 | lcd_putsf(0, line++, "BATT: %03x UNK1: %03x", | ||
141 | adc_read(ADC_BATTERY), adc_read(ADC_UNKNOWN_1)); | ||
142 | lcd_putsf(0, line++, "REM: %03x PAD: %03x", | ||
143 | adc_read(ADC_REMOTE), adc_read(ADC_SCROLLPAD)); | ||
144 | #elif defined(PHILIPS_HDD1630) || defined(PHILIPS_HDD6330) | ||
145 | line++; | ||
146 | lcd_putsf(0, line++, "BATT: %03x UNK1: %03x", | ||
147 | adc_read(ADC_BATTERY), adc_read(ADC_UNKNOWN_1)); | ||
148 | #elif defined(SANSA_E200) || defined(PHILIPS_SA9200) | ||
149 | lcd_putsf(0, line++, "ADC_BVDD: %4d", adc_read(ADC_BVDD)); | ||
150 | lcd_putsf(0, line++, "ADC_RTCSUP: %4d", adc_read(ADC_RTCSUP)); | ||
151 | lcd_putsf(0, line++, "ADC_UVDD: %4d", adc_read(ADC_UVDD)); | ||
152 | lcd_putsf(0, line++, "ADC_CHG_IN: %4d", adc_read(ADC_CHG_IN)); | ||
153 | lcd_putsf(0, line++, "ADC_CVDD: %4d", adc_read(ADC_CVDD)); | ||
154 | lcd_putsf(0, line++, "ADC_BATTEMP: %4d", adc_read(ADC_BATTEMP)); | ||
155 | lcd_putsf(0, line++, "ADC_MICSUP1: %4d", adc_read(ADC_MICSUP1)); | ||
156 | lcd_putsf(0, line++, "ADC_MICSUP2: %4d", adc_read(ADC_MICSUP2)); | ||
157 | lcd_putsf(0, line++, "ADC_VBE1: %4d", adc_read(ADC_VBE1)); | ||
158 | lcd_putsf(0, line++, "ADC_VBE2: %4d", adc_read(ADC_VBE2)); | ||
159 | lcd_putsf(0, line++, "ADC_I_MICSUP1:%4d", adc_read(ADC_I_MICSUP1)); | ||
160 | #if !defined(PHILIPS_SA9200) | ||
161 | lcd_putsf(0, line++, "ADC_I_MICSUP2:%4d", adc_read(ADC_I_MICSUP2)); | ||
162 | lcd_putsf(0, line++, "ADC_VBAT: %4d", adc_read(ADC_VBAT)); | ||
163 | #endif | ||
164 | #endif | ||
165 | |||
166 | #elif CONFIG_CPU == PP5002 | ||
167 | lcd_putsf(0, line++, "GPIO_A: %02x GPIO_B: %02x", | ||
168 | (unsigned int)GPIOA_INPUT_VAL, (unsigned int)GPIOB_INPUT_VAL); | ||
169 | lcd_putsf(0, line++, "GPIO_C: %02x GPIO_D: %02x", | ||
170 | (unsigned int)GPIOC_INPUT_VAL, (unsigned int)GPIOD_INPUT_VAL); | ||
171 | |||
172 | lcd_putsf(0, line++, "DEV_EN: %08lx", DEV_EN); | ||
173 | lcd_putsf(0, line++, "CLOCK_ENABLE: %08lx", CLOCK_ENABLE); | ||
174 | lcd_putsf(0, line++, "CLOCK_SOURCE: %08lx", CLOCK_SOURCE); | ||
175 | lcd_putsf(0, line++, "PLL_CONTROL: %08lx", PLL_CONTROL); | ||
176 | lcd_putsf(0, line++, "PLL_DIV: %08lx", PLL_DIV); | ||
177 | lcd_putsf(0, line++, "PLL_MULT: %08lx", PLL_MULT); | ||
178 | lcd_putsf(0, line++, "TIMING1_CTL: %08lx", TIMING1_CTL); | ||
179 | lcd_putsf(0, line++, "TIMING2_CTL: %08lx", TIMING2_CTL); | ||
180 | #endif | ||
181 | lcd_update(); | ||
182 | if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL)) | ||
183 | { | ||
184 | lcd_setfont(FONT_UI); | ||
185 | return false; | ||
186 | } | ||
187 | } | ||
188 | return false; | ||
189 | } | ||
190 | |||
191 | bool dbg_hw_info(void) | ||
192 | { | ||
193 | int line = 0; | ||
194 | #if defined(CPU_PP502x) | ||
195 | char pp_version[] = { (PP_VER2 >> 24) & 0xff, (PP_VER2 >> 16) & 0xff, | ||
196 | (PP_VER2 >> 8) & 0xff, (PP_VER2) & 0xff, | ||
197 | (PP_VER1 >> 24) & 0xff, (PP_VER1 >> 16) & 0xff, | ||
198 | (PP_VER1 >> 8) & 0xff, (PP_VER1) & 0xff, '\0' }; | ||
199 | #elif CONFIG_CPU == PP5002 | ||
200 | char pp_version[] = { (PP_VER4 >> 8) & 0xff, PP_VER4 & 0xff, | ||
201 | (PP_VER3 >> 8) & 0xff, PP_VER3 & 0xff, | ||
202 | (PP_VER2 >> 8) & 0xff, PP_VER2 & 0xff, | ||
203 | (PP_VER1 >> 8) & 0xff, PP_VER1 & 0xff, '\0' }; | ||
204 | #endif | ||
205 | |||
206 | lcd_setfont(FONT_SYSFIXED); | ||
207 | lcd_clear_display(); | ||
208 | |||
209 | lcd_puts(0, line++, "[Hardware info]"); | ||
210 | |||
211 | #ifdef IPOD_ARCH | ||
212 | lcd_putsf(0, line++, "HW rev: 0x%08lx", IPOD_HW_REVISION); | ||
213 | #endif | ||
214 | |||
215 | #if defined(IPOD_COLOR) || defined(IPOD_NANO) | ||
216 | extern int lcd_type; /* Defined in lcd-colornano.c */ | ||
217 | |||
218 | lcd_putsf(0, line++, "LCD type: %d", lcd_type); | ||
219 | #endif | ||
220 | |||
221 | lcd_putsf(0, line++, "PP version: %s", pp_version); | ||
222 | |||
223 | lcd_putsf(0, line++, "Est. clock (kHz): %d", perfcheck()); | ||
224 | |||
225 | lcd_update(); | ||
226 | |||
227 | /* wait for exit */ | ||
228 | while (button_get_w_tmo(HZ/10) != (DEBUG_CANCEL|BUTTON_REL)); | ||
229 | |||
230 | lcd_setfont(FONT_UI); | ||
231 | return false; | ||
232 | } | ||