blob: 7887bcac1eb51c167215d67512d28e0225a25e5e [file] [log] [blame]
Karl Kurbjun0082da72007-11-10 22:16:15 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Karl Kurbjun
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Karl Kurbjun0082da72007-11-10 22:16:15 +000016 *
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 "cpu.h"
24#include "system.h"
25#include "string.h"
26#include <stdbool.h>
27#include "button.h"
28#include "lcd.h"
29#include "sprintf.h"
30#include "font.h"
31#include "debug-target.h"
Maurus Cuelenaere95167e02008-04-24 20:08:28 +000032#include "lcd-target.h"
Karl Kurbjun0082da72007-11-10 22:16:15 +000033
Karl Kurbjund185f9e2007-11-10 23:13:27 +000034bool __dbg_ports(void)
35{
36 return false;
37}
38
Maurus Cuelenaeree031db42008-05-14 18:55:19 +000039#ifndef CREATIVE_ZVx
Karl Kurbjund3d0b262007-11-15 06:44:35 +000040extern char r_buffer[5];
41extern int r_button;
Maurus Cuelenaere95167e02008-04-24 20:08:28 +000042#endif
Karl Kurbjun0082da72007-11-10 22:16:15 +000043bool __dbg_hw_info(void)
44{
Maurus Cuelenaere95167e02008-04-24 20:08:28 +000045 int line = 0, oldline;
46 int button;
Maurus Cuelenaeree031db42008-05-14 18:55:19 +000047#ifndef CREATIVE_ZVx
Karl Kurbjun0082da72007-11-10 22:16:15 +000048 int *address=0x0;
Maurus Cuelenaere95167e02008-04-24 20:08:28 +000049#endif
Karl Kurbjun0082da72007-11-10 22:16:15 +000050 bool done=false;
51 char buf[100];
Karl Kurbjund3d0b262007-11-15 06:44:35 +000052
Karl Kurbjun0082da72007-11-10 22:16:15 +000053 lcd_setfont(FONT_SYSFIXED);
54 lcd_clear_display();
Karl Kurbjund3d0b262007-11-15 06:44:35 +000055
Karl Kurbjun59a28622007-11-11 03:31:24 +000056 /* Put all the static text befor the while loop */
Karl Kurbjun0082da72007-11-10 22:16:15 +000057 lcd_puts(0, line++, "[Hardware info]");
Karl Kurbjund3d0b262007-11-15 06:44:35 +000058
Karl Kurbjun59a28622007-11-11 03:31:24 +000059 lcd_puts(0, line++, "Clock info:");
Maurus Cuelenaere95167e02008-04-24 20:08:28 +000060#if LCD_WIDTH > 320
Karl Kurbjun59a28622007-11-11 03:31:24 +000061 snprintf(buf, sizeof(buf), "IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x",
62 IO_CLK_PLLA, IO_CLK_PLLB, IO_CLK_SEL0, IO_CLK_SEL1); lcd_puts(0, line++, buf);
63 snprintf(buf, sizeof(buf), "IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x",
64 IO_CLK_SEL2, IO_CLK_DIV0, IO_CLK_DIV1, IO_CLK_DIV2); lcd_puts(0, line++, buf);
65 snprintf(buf, sizeof(buf), "IO_CLK_DIV3: 0x%04x IO_CLK_DIV4: 0x%04x IO_CLK_BYP : 0x%04x IO_CLK_INV : 0x%04x",
66 IO_CLK_DIV3, IO_CLK_DIV4, IO_CLK_BYP, IO_CLK_INV); lcd_puts(0, line++, buf);
67 snprintf(buf, sizeof(buf), "IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x",
68 IO_CLK_MOD0, IO_CLK_MOD1, IO_CLK_MOD2, IO_CLK_LPCTL0); lcd_puts(0, line++, buf);
Maurus Cuelenaere95167e02008-04-24 20:08:28 +000069#else
70 snprintf(buf, sizeof(buf), " IO_CLK_PLLA: 0x%04x IO_CLK_PLLB: 0x%04x", IO_CLK_PLLA, IO_CLK_PLLB);
71 lcd_puts(0, line++, buf);
72 snprintf(buf, sizeof(buf), " IO_CLK_SEL0: 0x%04x IO_CLK_SEL1: 0x%04x", IO_CLK_SEL0, IO_CLK_SEL1);
73 lcd_puts(0, line++, buf);
74 snprintf(buf, sizeof(buf), " IO_CLK_SEL2: 0x%04x IO_CLK_DIV0: 0x%04x", IO_CLK_SEL2, IO_CLK_DIV0);
75 lcd_puts(0, line++, buf);
76 snprintf(buf, sizeof(buf), " IO_CLK_DIV1: 0x%04x IO_CLK_DIV2: 0x%04x", IO_CLK_DIV1, IO_CLK_DIV2);
77 lcd_puts(0, line++, buf);
78 snprintf(buf, sizeof(buf), " IO_CLK_DIV3: 0x%04x IO_CLK_DIV4: 0x%04x", IO_CLK_DIV3, IO_CLK_DIV4);
79 lcd_puts(0, line++, buf);
80 snprintf(buf, sizeof(buf), " IO_CLK_BYP : 0x%04x IO_CLK_INV : 0x%04x", IO_CLK_BYP, IO_CLK_INV);
81 lcd_puts(0, line++, buf);
82 snprintf(buf, sizeof(buf), " IO_CLK_MOD0: 0x%04x IO_CLK_MOD1: 0x%04x ", IO_CLK_MOD0, IO_CLK_MOD1);
83 lcd_puts(0, line++, buf);
84 snprintf(buf, sizeof(buf), " IO_CLK_MOD2: 0x%04x IO_CLK_LPCTL0: 0x%04x ", IO_CLK_MOD2, IO_CLK_LPCTL0);
85 lcd_puts(0, line++, buf);
Maurus Cuelenaereed5f1ed2008-05-03 14:43:43 +000086 lcd_puts(0, line++, "Interrupt info:");
87 snprintf(buf, sizeof(buf), " IO_INTC_EINT0: 0x%04x IO_INTC_EINT1: 0x%04x ", IO_INTC_EINT0, IO_INTC_EINT1);
88 lcd_puts(0, line++, buf);
89 snprintf(buf, sizeof(buf), " IO_INTC_EINT2: 0x%04x IO_INTC_IRQ0: 0x%04x ", IO_INTC_EINT2, IO_INTC_IRQ0);
90 lcd_puts(0, line++, buf);
91 snprintf(buf, sizeof(buf), " IO_INTC_IRQ1: 0x%04x IO_INTC_IRQ2: 0x%04x ", IO_INTC_IRQ1, IO_INTC_IRQ2);
92 lcd_puts(0, line++, buf);
Maurus Cuelenaere95167e02008-04-24 20:08:28 +000093#endif
94
95 lcd_puts(0, line++, "Board revision:");
96 switch (IO_BUSC_REVR) {
97 case 0x0010:
98 lcd_puts(0, line++, " DM320 Rev. A");
99 break;
100 case 0x0011:
101 lcd_puts(0, line++, " DM320 Rev. B/C");
102 break;
103 default:
104 lcd_puts(0, line++, " Unknown DM320 Chip ID");
105 }
Karl Kurbjun0082da72007-11-10 22:16:15 +0000106
Maurus Cuelenaeree031db42008-05-14 18:55:19 +0000107#ifndef CREATIVE_ZVx
Karl Kurbjun59a28622007-11-11 03:31:24 +0000108 line++;
Maurus Cuelenaere95167e02008-04-24 20:08:28 +0000109#endif
Karl Kurbjun59a28622007-11-11 03:31:24 +0000110 oldline=line;
Karl Kurbjun0082da72007-11-10 22:16:15 +0000111 while(!done)
112 {
Karl Kurbjun59a28622007-11-11 03:31:24 +0000113 line = oldline;
Maurus Cuelenaeree031db42008-05-14 18:55:19 +0000114#ifndef CREATIVE_ZVx
Karl Kurbjun0082da72007-11-10 22:16:15 +0000115 button = button_get(false);
116 button&=~BUTTON_REPEAT;
117 if (button == BUTTON_POWER)
118 done=true;
119 if(button==BUTTON_RC_PLAY)
120 address+=0x01;
121 else if (button==BUTTON_RC_DOWN)
122 address-=0x01;
123 else if (button==BUTTON_RC_FF)
124 address+=0x800;
125 else if (button==BUTTON_RC_REW)
126 address-=0x800;
127
Karl Kurbjund3d0b262007-11-15 06:44:35 +0000128 snprintf(buf, sizeof(buf), "Buffer: 0x%02x%02x%02x%02x%02x",
129 r_buffer[0], r_buffer[1], r_buffer[2], r_buffer[3],r_buffer[4] ); lcd_puts(0, line++, buf);
130 snprintf(buf, sizeof(buf), "Button: 0x%08x, HWread: 0x%08x",
131 (unsigned int)button, r_button); lcd_puts(0, line++, buf);
Maurus Cuelenaere95167e02008-04-24 20:08:28 +0000132#else
133 button = button_get(false);
134 if(button & BUTTON_POWER)
135 done = true;
136 else if(button & BUTTON_LEFT)
137 lcd_set_direct_fb(false);
138 else if(button & BUTTON_RIGHT)
139 lcd_set_direct_fb(true);
140
Maurus Cuelenaere95167e02008-04-24 20:08:28 +0000141 lcd_puts(0, line++, "LCD info:");
142 snprintf(buf, sizeof(buf), " LCD direct FB access? %s", (lcd_get_direct_fb() ? "yes" : "no"));
143 lcd_puts(0, line++, buf);
144 line++;
145#endif
146 lcd_puts(0, line++, "[Rockbox info]");
Karl Kurbjun59a28622007-11-11 03:31:24 +0000147 snprintf(buf, sizeof(buf), "current tick: %08x Seconds running: %08d",
148 (unsigned int)current_tick, (unsigned int)current_tick/100); lcd_puts(0, line++, buf);
Maurus Cuelenaeree031db42008-05-14 18:55:19 +0000149#ifndef CREATIVE_ZVx
Karl Kurbjun59a28622007-11-11 03:31:24 +0000150 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x",
151 (unsigned int)address, *address); lcd_puts(0, line++, buf);
152 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x",
153 (unsigned int)(address+1), *(address+1)); lcd_puts(0, line++, buf);
154 snprintf(buf, sizeof(buf), "Address: 0x%08x Data: 0x%08x",
155 (unsigned int)(address+2), *(address+2)); lcd_puts(0, line++, buf);
Maurus Cuelenaere95167e02008-04-24 20:08:28 +0000156#endif
Karl Kurbjun0082da72007-11-10 22:16:15 +0000157
158 lcd_update();
159 }
160 return false;
161}