Move c/h files implementing/defining standard library stuff into a new libc directory...
[kugel-rb.git] / firmware / target / arm / tms320dm320 / debug-dm320.c
blob8bf170048e3705b0235d2990e385cbd9fcf5aa20
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2007, 2009 by Karl Kurbjun
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 ****************************************************************************/
22 #include "config.h"
23 #include "cpu.h"
24 #include "system.h"
25 #include "string.h"
26 #include <stdbool.h>
27 #include "button.h"
28 #include "lcd.h"
29 #include "debug.h"
30 #include "font.h"
31 #include "lcd-target.h"
33 #if defined(MROBE_500)
34 #include "tsc2100.h"
35 #include "m66591.h"
36 #endif
38 bool __dbg_ports(void)
40 #if defined(MROBE_500)
41 int line = 0;
42 int i;
43 int button;
44 bool done=false;
46 lcd_setfont(FONT_SYSFIXED);
47 lcd_clear_display();
49 while(!done)
51 line = 0;
52 button = button_get(false);
53 button&=~BUTTON_REPEAT;
54 if (button == BUTTON_POWER)
55 done=true;
57 lcd_puts(0, line++, "[USB Information]");
59 lcd_putsf(0, line++, "TRN_CTRL: 0x%04x TRN_LNSTAT: 0x%04x",
60 M66591_TRN_CTRL, M66591_TRN_LNSTAT);
61 lcd_putsf(0, line++, "HSFS: 0x%04x TESTMODE: 0x%04x",
62 M66591_HSFS, M66591_TESTMODE);
63 lcd_putsf(0, line++, "PIN_CFG0: 0x%04x PIN_CFG1: 0x%04x",
64 M66591_PIN_CFG0, M66591_PIN_CFG1);
65 lcd_putsf(0, line++, "PIN_CFG2: 0x%04x", M66591_PIN_CFG2);
66 lcd_putsf(0, line++, "DCP_CTRLEN: 0x%04x", M66591_DCP_CTRLEN);
67 lcd_putsf(0, line++, "CPORT_CTRL0: 0x%04x CPORT_CTRL1: 0x%04x",
68 M66591_CPORT_CTRL0, M66591_CPORT_CTRL1);
69 lcd_putsf(0, line++, "CPORT_CTRL2: 0x%04x DPORT_CTRL0: 0x%04x",
70 M66591_CPORT_CTRL2, M66591_DPORT_CTRL0);
71 lcd_putsf(0, line++, "DPORT_CTRL1: 0x%04x DPORT_CTRL2: 0x%04x",
72 M66591_DPORT_CTRL1, M66591_DPORT_CTRL2);
73 lcd_putsf(0, line++, "INTCFG_MAIN: 0x%04x INTCFG_OUT: 0x%04x",
74 M66591_INTCFG_MAIN, M66591_INTCFG_OUT);
75 lcd_putsf(0, line++, "INTCFG_RDY: 0x%04x INTCFG_NRDY: 0x%04x",
76 M66591_INTCFG_RDY, M66591_INTCFG_NRDY);
77 lcd_putsf(0, line++, "INTCFG_EMP: 0x%04x INTSTAT_MAIN: 0x%04x",
78 M66591_INTCFG_EMP, M66591_INTSTAT_MAIN);
79 lcd_putsf(0, line++, "INTSTAT_RDY: 0x%04x INTSTAT_NRDY: 0x%04x",
80 M66591_INTSTAT_RDY, M66591_INTSTAT_NRDY);
81 lcd_putsf(0, line++, "INTSTAT_EMP: 0x%04x USB_ADDRESS: 0x%04x",
82 M66591_INTSTAT_EMP, M66591_USB_ADDRESS);
83 lcd_putsf(0, line++, "USB_REQ0: 0x%04x USB_REQ1: 0x%04x",
84 M66591_USB_REQ0, M66591_USB_REQ1);
85 lcd_putsf(0, line++, "USB_REQ2: 0x%04x USB_REQ3: 0x%04x",
86 M66591_USB_REQ2, M66591_USB_REQ3);
87 lcd_putsf(0, line++, "DCP_CNTMD: 0x%04x DCP_MXPKSZ: 0x%04x",
88 M66591_DCP_CNTMD, M66591_DCP_MXPKSZ);
89 lcd_putsf(0, line++, "DCPCTRL: 0x%04x", M66591_DCPCTRL);
91 line++;
92 for(i=1; i<6; i++) {
93 M66591_PIPE_CFGWND=i;
94 lcd_putsf(0, line++, "PIPE_CFGSEL:0x%04x PIPE_CFGWND: 0x%04x",
95 M66591_PIPE_CFGSEL, M66591_PIPE_CFGWND);
97 line++;
99 lcd_putsf(0, line++, "PIPECTRL1: 0x%04x PIPECTRL2: 0x%04x",
100 M66591_PIPECTRL1, M66591_PIPECTRL2);
101 lcd_putsf(0, line++, "PIPECTRL3: 0x%04x PIPECTRL4: 0x%04x",
102 M66591_PIPECTRL3, M66591_PIPECTRL4);
103 lcd_putsf(0, line++, "PIPECTRL5: 0x%04x PIPECTRL6: 0x%04x",
104 M66591_PIPECTRL5, M66591_PIPECTRL6);
106 lcd_putsf(0, line++, "GIO_BITSET0: 0x%04x GIO_BITSET1: 0x%04x",
107 IO_GIO_BITSET0, IO_GIO_BITSET1);
109 lcd_putsf(0, line++, "GIO_BITSET2: 0x%04x", IO_GIO_BITSET2);
111 lcd_putsf(0, line++, "SDRAM_SDMODE: 0x%04x SDRAM_REFCTL: 0x%04x",
112 IO_SDRAM_SDMODE, IO_SDRAM_REFCTL);
114 lcd_putsf(0, line++, "EMIF_CS4CTRL1:0x%04x EMIF_CS4CTRL2:0x%04x",
115 IO_EMIF_CS4CTRL1, IO_EMIF_CS4CTRL2);
117 lcd_update();
119 #endif
120 return false;
123 bool __dbg_hw_info(void)
125 int line = 0, oldline;
126 int button;
127 #if defined(MROBE_500)
128 int *address=0x0;
129 #endif
130 bool done=false;
132 lcd_setfont(FONT_SYSFIXED);
133 lcd_clear_display();
135 /* Put all the static text befor the while loop */
136 lcd_puts(0, line++, "[Hardware info]");
138 lcd_puts(0, line++, "Clock info:");
139 #if LCD_WIDTH > 320
140 lcd_putsf(0, line++, "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x "
141 "IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x",
142 IO_CLK_PLLA, IO_CLK_PLLB, IO_CLK_SEL0, IO_CLK_SEL1);
143 lcd_putsf(0, line++, "IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x "
144 "IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x",
145 IO_CLK_SEL2, IO_CLK_DIV0, IO_CLK_DIV1, IO_CLK_DIV2);
146 lcd_putsf(0, line++, "IO_CLK_DIV3: 0x%04x IO_CLK_DIV4: 0x%04x "
147 "IO_CLK_BYP : 0x%04x IO_CLK_INV : 0x%04x",
148 IO_CLK_DIV3, IO_CLK_DIV4, IO_CLK_BYP, IO_CLK_INV);
149 lcd_putsf(0, line++, "IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x "
150 "IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x",
151 IO_CLK_MOD0, IO_CLK_MOD1, IO_CLK_MOD2, IO_CLK_LPCTL0);
152 #else
153 lcd_putsf(0, line++, " IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x",
154 IO_CLK_PLLA, IO_CLK_PLLB);
155 lcd_putsf(0, line++, " IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x",
156 IO_CLK_SEL0, IO_CLK_SEL1);
157 lcd_putsf(0, line++, " IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x",
158 IO_CLK_SEL2, IO_CLK_DIV0);
159 lcd_putsf(0, line++, " IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x",
160 IO_CLK_DIV1, IO_CLK_DIV2);
161 lcd_putsf(0, line++, " IO_CLK_DIV3: 0x%04x IO_CLK_DIV4: 0x%04x",
162 IO_CLK_DIV3, IO_CLK_DIV4);
163 lcd_putsf(0, line++, " IO_CLK_BYP : 0x%04x IO_CLK_INV : 0x%04x",
164 IO_CLK_BYP, IO_CLK_INV);
165 lcd_putsf(0, line++, " IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x ",
166 IO_CLK_MOD0, IO_CLK_MOD1);
167 lcd_putsf(0, line++, " IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x ",
168 IO_CLK_MOD2, IO_CLK_LPCTL0);
169 #endif
170 lcd_puts(0, line++, "Interrupt info:");
171 lcd_putsf(0, line++, " IO_INTC_EINT0: 0x%04x IO_INTC_EINT1: 0x%04x ",
172 IO_INTC_EINT0, IO_INTC_EINT1);
173 lcd_putsf(0, line++, " IO_INTC_EINT2: 0x%04x IO_INTC_IRQ0: 0x%04x ",
174 IO_INTC_EINT2, IO_INTC_IRQ0);
175 lcd_putsf(0, line++, " IO_INTC_IRQ1: 0x%04x IO_INTC_IRQ2: 0x%04x ",
176 IO_INTC_IRQ1, IO_INTC_IRQ2);
178 lcd_puts(0, line++, "Board revision:");
179 switch (IO_BUSC_REVR) {
180 case 0x0010:
181 lcd_puts(0, line++, " DM320 Rev. A");
182 break;
183 case 0x0011:
184 lcd_puts(0, line++, " DM320 Rev. B/C");
185 break;
186 default:
187 lcd_puts(0, line++, " Unknown DM320 Chip ID");
190 #if defined(MROBE_500)
191 line++;
192 #endif
193 oldline=line;
194 while(!done)
196 line = oldline;
197 #if defined(MROBE_500)
198 button = button_get(false);
199 button&=~BUTTON_REPEAT;
200 if (button == BUTTON_POWER)
201 done=true;
202 if(button==BUTTON_RC_PLAY)
203 address+=0x01;
204 else if (button==BUTTON_RC_DOWN)
205 address-=0x01;
206 else if (button==BUTTON_RC_FF)
207 address+=0x800;
208 else if (button==BUTTON_RC_REW)
209 address-=0x800;
210 #else
211 button = button_get(false);
212 if(button & BUTTON_POWER)
213 done = true;
214 else if(button & BUTTON_LEFT)
215 lcd_set_direct_fb(false);
216 else if(button & BUTTON_RIGHT)
217 lcd_set_direct_fb(true);
219 lcd_puts(0, line++, "LCD info:");
220 lcd_putsf(0, line++, " LCD direct FB access? %s",
221 (lcd_get_direct_fb() ? "yes" : "no"));
222 line++;
223 #endif
224 lcd_puts(0, line++, "[Rockbox info]");
225 lcd_putsf(0, line++, "current tick: %08x Seconds running: %08d",
226 (unsigned int)current_tick, (unsigned int)current_tick/100);
227 #if defined(MROBE_500)
228 lcd_putsf(0, line++, "Address: 0x%08x Data: 0x%08x",
229 (unsigned int)address, *address);
230 lcd_putsf(0, line++, "Address: 0x%08x Data: 0x%08x",
231 (unsigned int)(address+1), *(address+1));
232 lcd_putsf(0, line++, "Address: 0x%08x Data: 0x%08x",
233 (unsigned int)(address+2), *(address+2));
234 #endif
236 lcd_update();
238 return false;