summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx31/debug-imx31.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/target/arm/imx31/debug-imx31.c')
-rw-r--r--firmware/target/arm/imx31/debug-imx31.c112
1 files changed, 43 insertions, 69 deletions
diff --git a/firmware/target/arm/imx31/debug-imx31.c b/firmware/target/arm/imx31/debug-imx31.c
index cc1e200c11..dc3c293495 100644
--- a/firmware/target/arm/imx31/debug-imx31.c
+++ b/firmware/target/arm/imx31/debug-imx31.c
@@ -32,7 +32,6 @@
32 32
33bool __dbg_hw_info(void) 33bool __dbg_hw_info(void)
34{ 34{
35 char buf[50];
36 int line; 35 int line;
37 unsigned int pllref; 36 unsigned int pllref;
38 unsigned int mcu_pllfreq, ser_pllfreq, usb_pllfreq; 37 unsigned int mcu_pllfreq, ser_pllfreq, usb_pllfreq;
@@ -46,9 +45,8 @@ bool __dbg_hw_info(void)
46 while (1) 45 while (1)
47 { 46 {
48 line = 0; 47 line = 0;
49 snprintf(buf, sizeof (buf), "Sys Rev Code: 0x%02X", 48 lcd_putsf(0, line++, "Sys Rev Code: 0x%02X", iim_system_rev());
50 iim_system_rev()); 49 line++;
51 lcd_puts(0, line++, buf); line++;
52 50
53 mpctl = CCM_MPCTL; 51 mpctl = CCM_MPCTL;
54 spctl = CCM_SPCTL; 52 spctl = CCM_SPCTL;
@@ -60,69 +58,55 @@ bool __dbg_hw_info(void)
60 ser_pllfreq = ccm_get_pll(PLL_SERIAL); 58 ser_pllfreq = ccm_get_pll(PLL_SERIAL);
61 usb_pllfreq = ccm_get_pll(PLL_USB); 59 usb_pllfreq = ccm_get_pll(PLL_USB);
62 60
63 snprintf(buf, sizeof (buf), "pll_ref_clk: %u", pllref); 61 lcd_putsf(0, line++, "pll_ref_clk: %u", pllref);
64 lcd_puts(0, line++, buf); line++; 62 line++;
65 63
66 /* MCU clock domain */ 64 /* MCU clock domain */
67 snprintf(buf, sizeof (buf), "MPCTL: %08lX", mpctl); 65 lcd_putsf(0, line++, "MPCTL: %08lX", mpctl);
68 lcd_puts(0, line++, buf);
69 66
70 snprintf(buf, sizeof (buf), " mpl_dpdgck_clk: %u", mcu_pllfreq); 67 lcd_putsf(0, line++, " mpl_dpdgck_clk: %u", mcu_pllfreq);
71 lcd_puts(0, line++, buf); line++; 68 line++;
72 69
73 regval = CCM_PDR0; 70 regval = CCM_PDR0;
74 snprintf(buf, sizeof (buf), " PDR0: %08lX", regval); 71 lcd_putsf(0, line++, " PDR0: %08lX", regval);
75 lcd_puts(0, line++, buf);
76 72
77 freq = mcu_pllfreq / (((regval & 0x7) + 1)); 73 freq = mcu_pllfreq / (((regval & 0x7) + 1));
78 snprintf(buf, sizeof (buf), " mcu_clk: %u", freq); 74 lcd_putsf(0, line++, " mcu_clk: %u", freq);
79 lcd_puts(0, line++, buf);
80 75
81 freq = mcu_pllfreq / (((regval >> 11) & 0x7) + 1); 76 freq = mcu_pllfreq / (((regval >> 11) & 0x7) + 1);
82 snprintf(buf, sizeof (buf), " hsp_clk: %u", freq); 77 lcd_putsf(0, line++, " hsp_clk: %u", freq);
83 lcd_puts(0, line++, buf);
84 78
85 freq = mcu_pllfreq / (((regval >> 3) & 0x7) + 1); 79 freq = mcu_pllfreq / (((regval >> 3) & 0x7) + 1);
86 snprintf(buf, sizeof (buf), " hclk_clk: %u", freq); 80 lcd_putsf(0, line++, " hclk_clk: %u", freq);
87 lcd_puts(0, line++, buf);
88 81
89 snprintf(buf, sizeof (buf), " ipg_clk: %u", 82 lcd_putsf(0, line++, " ipg_clk: %u",
90 freq / (unsigned)(((regval >> 6) & 0x3) + 1)); 83 freq / (unsigned)(((regval >> 6) & 0x3) + 1));
91 lcd_puts(0, line++, buf);
92 84
93 snprintf(buf, sizeof (buf), " nfc_clk: %u", 85 lcd_putsf(0, line++, " nfc_clk: %u",
94 freq / (unsigned)(((regval >> 8) & 0x7) + 1)); 86 freq / (unsigned)(((regval >> 8) & 0x7) + 1));
95 lcd_puts(0, line++, buf);
96 87
97 line++; 88 line++;
98 89
99 /* Serial clock domain */ 90 /* Serial clock domain */
100 snprintf(buf, sizeof (buf), "SPCTL: %08lX", spctl); 91 lcd_putsf(0, line++, "SPCTL: %08lX", spctl);
101 lcd_puts(0, line++, buf); 92 lcd_putsf(0, line++, " spl_dpdgck_clk: %u", ser_pllfreq);
102 snprintf(buf, sizeof (buf), " spl_dpdgck_clk: %u", ser_pllfreq);
103 lcd_puts(0, line++, buf);
104 93
105 line++; 94 line++;
106 95
107 /* USB clock domain */ 96 /* USB clock domain */
108 snprintf(buf, sizeof (buf), "UPCTL: %08lX", upctl); 97 lcd_putsf(0, line++, "UPCTL: %08lX", upctl);
109 lcd_puts(0, line++, buf);
110 98
111 snprintf(buf, sizeof (buf), " upl_dpdgck_clk: %u", usb_pllfreq); 99 lcd_putsf(0, line++, " upl_dpdgck_clk: %u", usb_pllfreq);
112 lcd_puts(0, line++, buf); line++;
113 100
114 regval = CCM_PDR1; 101 regval = CCM_PDR1;
115 snprintf(buf, sizeof (buf), " PDR1: %08lX", regval); 102 lcd_putsf(0, line++, " PDR1: %08lX", regval);
116 lcd_puts(0, line++, buf);
117 103
118 freq = usb_pllfreq / 104 freq = usb_pllfreq /
119 ((((regval >> 30) & 0x3) + 1) * (((regval >> 27) & 0x7) + 1)); 105 ((((regval >> 30) & 0x3) + 1) * (((regval >> 27) & 0x7) + 1));
120 snprintf(buf, sizeof (buf), " usb_clk: %u", freq); 106 lcd_putsf(0, line++, " usb_clk: %u", freq);
121 lcd_puts(0, line++, buf);
122 107
123 freq = usb_pllfreq / (((CCM_PDR0 >> 16) & 0x1f) + 1); 108 freq = usb_pllfreq / (((CCM_PDR0 >> 16) & 0x1f) + 1);
124 snprintf(buf, sizeof (buf), " ipg_per_baud: %u", freq); 109 lcd_putsf(0, line++, " ipg_per_baud: %u", freq);
125 lcd_puts(0, line++, buf);
126 110
127 lcd_update(); 111 lcd_update();
128 112
@@ -133,7 +117,6 @@ bool __dbg_hw_info(void)
133 117
134bool __dbg_ports(void) 118bool __dbg_ports(void)
135{ 119{
136 char buf[50];
137 int line; 120 int line;
138 int i; 121 int i;
139 122
@@ -171,71 +154,62 @@ bool __dbg_ports(void)
171 while(1) 154 while(1)
172 { 155 {
173 line = 0; 156 line = 0;
174 snprintf(buf, sizeof(buf), "[Ports and Registers]"); 157 lcd_puts(0, line++, "[Ports and Registers]");
175 lcd_puts(0, line++, buf); line++; 158 line++;
176 159
177 /* GPIO1 */ 160 /* GPIO1 */
178 snprintf(buf, sizeof(buf), "GPIO1: DR: %08lx GDIR: %08lx", GPIO1_DR, GPIO1_GDIR); 161 lcd_putsf(0, line++, "GPIO1: DR: %08lx GDIR: %08lx", GPIO1_DR, GPIO1_GDIR);
179 lcd_puts(0, line++, buf);
180 162
181 snprintf(buf, sizeof(buf), " PSR: %08lx ICR1: %08lx", GPIO1_PSR, GPIO1_ICR1); 163 lcd_putsf(0, line++, " PSR: %08lx ICR1: %08lx", GPIO1_PSR, GPIO1_ICR1);
182 lcd_puts(0, line++, buf);
183 164
184 snprintf(buf, sizeof(buf), " ICR2: %08lx IMR: %08lx", GPIO1_ICR2, GPIO1_IMR); 165 lcd_putsf(0, line++, " ICR2: %08lx IMR: %08lx", GPIO1_ICR2, GPIO1_IMR);
185 lcd_puts(0, line++, buf);
186 166
187 snprintf(buf, sizeof(buf), " ISR: %08lx", GPIO1_ISR); 167 lcd_putsf(0, line++, " ISR: %08lx", GPIO1_ISR);
188 lcd_puts(0, line++, buf); line++; 168 line++;
189 169
190 /* GPIO2 */ 170 /* GPIO2 */
191 snprintf(buf, sizeof(buf), "GPIO2: DR: %08lx GDIR: %08lx", GPIO2_DR, GPIO2_GDIR); 171 lcd_putsf(0, line++, "GPIO2: DR: %08lx GDIR: %08lx", GPIO2_DR, GPIO2_GDIR);
192 lcd_puts(0, line++, buf);
193 172
194 snprintf(buf, sizeof(buf), " PSR: %08lx ICR1: %08lx", GPIO2_PSR, GPIO2_ICR1); 173 lcd_putsf(0, line++, " PSR: %08lx ICR1: %08lx", GPIO2_PSR, GPIO2_ICR1);
195 lcd_puts(0, line++, buf);
196 174
197 snprintf(buf, sizeof(buf), " ICR2: %08lx IMR: %08lx", GPIO2_ICR2, GPIO2_IMR); 175 lcd_putsf(0, line++, " ICR2: %08lx IMR: %08lx", GPIO2_ICR2, GPIO2_IMR);
198 lcd_puts(0, line++, buf);
199 176
200 snprintf(buf, sizeof(buf), " ISR: %08lx", GPIO2_ISR); 177 lcd_putsf(0, line++, " ISR: %08lx", GPIO2_ISR);
201 lcd_puts(0, line++, buf); line++; 178 line++;
202 179
203 /* GPIO3 */ 180 /* GPIO3 */
204 snprintf(buf, sizeof(buf), "GPIO3: DR: %08lx GDIR: %08lx", GPIO3_DR, GPIO3_GDIR); 181 lcd_putsf(0, line++, "GPIO3: DR: %08lx GDIR: %08lx", GPIO3_DR, GPIO3_GDIR);
205 lcd_puts(0, line++, buf);
206 182
207 snprintf(buf, sizeof(buf), " PSR: %08lx ICR1: %08lx", GPIO3_PSR, GPIO3_ICR1); 183 lcd_putsf(0, line++, " PSR: %08lx ICR1: %08lx", GPIO3_PSR, GPIO3_ICR1);
208 lcd_puts(0, line++, buf);
209 184
210 snprintf(buf, sizeof(buf), " ICR2: %08lx IMR: %08lx", GPIO3_ICR2, GPIO3_IMR); 185 lcd_putsf(0, line++, " ICR2: %08lx IMR: %08lx", GPIO3_ICR2, GPIO3_IMR);
211 lcd_puts(0, line++, buf);
212 186
213 snprintf(buf, sizeof(buf), " ISR: %08lx", GPIO3_ISR); 187 lcd_putsf(0, line++, " ISR: %08lx", GPIO3_ISR);
214 lcd_puts(0, line++, buf); line++; 188 line++;
215 189
216 lcd_puts(0, line++, "PMIC Registers"); line++; 190 lcd_puts(0, line++, "PMIC Registers");
191 line++;
217 192
218 mc13783_read_regset(pmic_regset, pmic_regs, ARRAYLEN(pmic_regs)); 193 mc13783_read_regset(pmic_regset, pmic_regs, ARRAYLEN(pmic_regs));
219 194
220 for (i = 0; i < (int)ARRAYLEN(pmic_regs); i++) 195 for (i = 0; i < (int)ARRAYLEN(pmic_regs); i++)
221 { 196 {
222 snprintf(buf, sizeof(buf), "%s: %08lx", pmic_regnames[i], pmic_regs[i]); 197 lcd_putsf(0, line++, "%s: %08lx", pmic_regnames[i], pmic_regs[i]);
223 lcd_puts(0, line++, buf);
224 } 198 }
225 199
226 line++; 200 line++;
227 201
228 lcd_puts(0, line++, "ADC"); line++; 202 lcd_puts(0, line++, "ADC");
203 line++;
229 204
230 for (i = 0; i < NUM_ADC_CHANNELS; i += 4) 205 for (i = 0; i < NUM_ADC_CHANNELS; i += 4)
231 { 206 {
232 snprintf(buf, sizeof(buf), 207 lcd_putsf(0, line++,
233 "CH%02d:%04u CH%02d:%04u CH%02d:%04u CH%02d:%04u", 208 "CH%02d:%04u CH%02d:%04u CH%02d:%04u CH%02d:%04u",
234 i+0, adc_read(i+0), 209 i+0, adc_read(i+0),
235 i+1, adc_read(i+1), 210 i+1, adc_read(i+1),
236 i+2, adc_read(i+2), 211 i+2, adc_read(i+2),
237 i+3, adc_read(i+3)); 212 i+3, adc_read(i+3));
238 lcd_puts(0, line++, buf);
239 } 213 }
240 214
241 lcd_update(); 215 lcd_update();