1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 by Michael Sevakis
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
28 #include "debug-target.h"
31 #include "clkctl-imx31.h"
33 bool __dbg_hw_info(void)
38 unsigned int mcu_pllfreq
, ser_pllfreq
, usb_pllfreq
;
39 uint32_t mpctl
, spctl
, upctl
;
44 lcd_setfont(FONT_SYSFIXED
);
49 snprintf(buf
, sizeof (buf
), "Sys Rev Code: 0x%02X",
51 lcd_puts(0, line
++, buf
); line
++;
57 pllref
= imx31_clkctl_get_pll_ref_clk();
59 mcu_pllfreq
= imx31_clkctl_get_pll(PLL_MCU
);
60 ser_pllfreq
= imx31_clkctl_get_pll(PLL_SERIAL
);
61 usb_pllfreq
= imx31_clkctl_get_pll(PLL_USB
);
63 snprintf(buf
, sizeof (buf
), "pll_ref_clk: %u", pllref
);
64 lcd_puts(0, line
++, buf
); line
++;
66 /* MCU clock domain */
67 snprintf(buf
, sizeof (buf
), "MPCTL: %08lX", mpctl
);
68 lcd_puts(0, line
++, buf
);
70 snprintf(buf
, sizeof (buf
), " mpl_dpdgck_clk: %u", mcu_pllfreq
);
71 lcd_puts(0, line
++, buf
); line
++;
74 snprintf(buf
, sizeof (buf
), " PDR0: %08lX", regval
);
75 lcd_puts(0, line
++, buf
);
77 freq
= mcu_pllfreq
/ (((regval
& 0x7) + 1));
78 snprintf(buf
, sizeof (buf
), " mcu_clk: %u", freq
);
79 lcd_puts(0, line
++, buf
);
81 freq
= mcu_pllfreq
/ (((regval
>> 11) & 0x7) + 1);
82 snprintf(buf
, sizeof (buf
), " hsp_clk: %u", freq
);
83 lcd_puts(0, line
++, buf
);
85 freq
= mcu_pllfreq
/ (((regval
>> 3) & 0x7) + 1);
86 snprintf(buf
, sizeof (buf
), " hclk_clk: %u", freq
);
87 lcd_puts(0, line
++, buf
);
89 snprintf(buf
, sizeof (buf
), " ipg_clk: %u",
90 freq
/ (unsigned)(((regval
>> 6) & 0x3) + 1));
91 lcd_puts(0, line
++, buf
);
93 snprintf(buf
, sizeof (buf
), " nfc_clk: %u",
94 freq
/ (unsigned)(((regval
>> 8) & 0x7) + 1));
95 lcd_puts(0, line
++, buf
);
99 /* Serial clock domain */
100 snprintf(buf
, sizeof (buf
), "SPCTL: %08lX", spctl
);
101 lcd_puts(0, line
++, buf
);
102 snprintf(buf
, sizeof (buf
), " spl_dpdgck_clk: %u", ser_pllfreq
);
103 lcd_puts(0, line
++, buf
);
107 /* USB clock domain */
108 snprintf(buf
, sizeof (buf
), "UPCTL: %08lX", upctl
);
109 lcd_puts(0, line
++, buf
);
111 snprintf(buf
, sizeof (buf
), " upl_dpdgck_clk: %u", usb_pllfreq
);
112 lcd_puts(0, line
++, buf
); line
++;
114 regval
= CLKCTL_PDR1
;
115 snprintf(buf
, sizeof (buf
), " PDR1: %08lX", regval
);
116 lcd_puts(0, line
++, buf
);
119 ((((regval
>> 30) & 0x3) + 1) * (((regval
>> 27) & 0x7) + 1));
120 snprintf(buf
, sizeof (buf
), " usb_clk: %u", freq
);
121 lcd_puts(0, line
++, buf
);
123 freq
= usb_pllfreq
/ (((CLKCTL_PDR0
>> 16) & 0x1f) + 1);
124 snprintf(buf
, sizeof (buf
), " ipg_per_baud: %u", freq
);
125 lcd_puts(0, line
++, buf
);
129 if (button_get(true) == (DEBUG_CANCEL
|BUTTON_REL
))
134 bool __dbg_ports(void)
140 static const char pmic_regset
[] =
142 MC13783_INTERRUPT_STATUS0
,
143 MC13783_INTERRUPT_SENSE0
,
144 MC13783_INTERRUPT_STATUS1
,
145 MC13783_INTERRUPT_SENSE1
,
150 MC13783_RTC_DAY_ALARM
,
153 static const char *pmic_regnames
[ARRAYLEN(pmic_regset
)] =
166 uint32_t pmic_regs
[ARRAYLEN(pmic_regset
)];
169 lcd_setfont(FONT_SYSFIXED
);
174 snprintf(buf
, sizeof(buf
), "[Ports and Registers]");
175 lcd_puts(0, line
++, buf
); line
++;
178 snprintf(buf
, sizeof(buf
), "GPIO1: DR: %08lx GDIR: %08lx", GPIO1_DR
, GPIO1_GDIR
);
179 lcd_puts(0, line
++, buf
);
181 snprintf(buf
, sizeof(buf
), " PSR: %08lx ICR1: %08lx", GPIO1_PSR
, GPIO1_ICR1
);
182 lcd_puts(0, line
++, buf
);
184 snprintf(buf
, sizeof(buf
), " ICR2: %08lx IMR: %08lx", GPIO1_ICR2
, GPIO1_IMR
);
185 lcd_puts(0, line
++, buf
);
187 snprintf(buf
, sizeof(buf
), " ISR: %08lx", GPIO1_ISR
);
188 lcd_puts(0, line
++, buf
); line
++;
191 snprintf(buf
, sizeof(buf
), "GPIO2: DR: %08lx GDIR: %08lx", GPIO2_DR
, GPIO2_GDIR
);
192 lcd_puts(0, line
++, buf
);
194 snprintf(buf
, sizeof(buf
), " PSR: %08lx ICR1: %08lx", GPIO2_PSR
, GPIO2_ICR1
);
195 lcd_puts(0, line
++, buf
);
197 snprintf(buf
, sizeof(buf
), " ICR2: %08lx IMR: %08lx", GPIO2_ICR2
, GPIO2_IMR
);
198 lcd_puts(0, line
++, buf
);
200 snprintf(buf
, sizeof(buf
), " ISR: %08lx", GPIO2_ISR
);
201 lcd_puts(0, line
++, buf
); line
++;
204 snprintf(buf
, sizeof(buf
), "GPIO3: DR: %08lx GDIR: %08lx", GPIO3_DR
, GPIO3_GDIR
);
205 lcd_puts(0, line
++, buf
);
207 snprintf(buf
, sizeof(buf
), " PSR: %08lx ICR1: %08lx", GPIO3_PSR
, GPIO3_ICR1
);
208 lcd_puts(0, line
++, buf
);
210 snprintf(buf
, sizeof(buf
), " ICR2: %08lx IMR: %08lx", GPIO3_ICR2
, GPIO3_IMR
);
211 lcd_puts(0, line
++, buf
);
213 snprintf(buf
, sizeof(buf
), " ISR: %08lx", GPIO3_ISR
);
214 lcd_puts(0, line
++, buf
); line
++;
216 lcd_puts(0, line
++, "PMIC Registers"); line
++;
218 mc13783_read_regset(pmic_regset
, pmic_regs
, ARRAYLEN(pmic_regs
));
220 for (i
= 0; i
< (int)ARRAYLEN(pmic_regs
); i
++)
222 snprintf(buf
, sizeof(buf
), "%s: %08lx", pmic_regnames
[i
], pmic_regs
[i
]);
223 lcd_puts(0, line
++, buf
);
228 lcd_puts(0, line
++, "ADC"); line
++;
230 for (i
= 0; i
< NUM_ADC_CHANNELS
; i
+= 4)
232 snprintf(buf
, sizeof(buf
),
233 "CH%02d:%04u CH%02d:%04u CH%02d:%04u CH%02d:%04u",
238 lcd_puts(0, line
++, buf
);
242 if (button_get_w_tmo(HZ
/10) == (DEBUG_CANCEL
|BUTTON_REL
))