Nano2G __dbg_hw_info (courtesy of Franz-Josef Haider)
[kugel-rb.git] / firmware / target / arm / s5l8700 / debug-s5l8700.c
blobfc8b58240809eed2ca2f988d0a72789f803771ac
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright © 2008 Rafaël Carré
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 <stdbool.h>
23 #include "config.h"
24 #include "kernel.h"
25 #include "debug-target.h"
26 #include "button.h"
27 #include "lcd.h"
28 #include "font.h"
29 #include "sprintf.h"
30 #include "storage.h"
31 #include "action.h"
32 #ifdef IPOD_NANO2G
33 #include "power.h"
34 #include "pmu-target.h"
35 #include "nand-target.h"
36 #endif
38 /* Skeleton for adding target specific debug info to the debug menu
41 #define _DEBUG_PRINTF(a,varargs...) do { \
42 snprintf(buf, sizeof(buf), (a), ##varargs); lcd_puts(0,line++,buf); \
43 } while(0)
45 extern int lcd_type;
46 extern uint32_t nand_type[4];
48 bool __dbg_hw_info(void)
50 char buf[50];
51 int line;
52 int i;
53 #ifdef IPOD_NANO2G
54 unsigned int state;
55 const unsigned int max_states=2;
56 int nand_bank_count;
57 struct storage_info info;
58 const struct nand_device_info_type *nand_devicetype[4];
59 nand_get_info(&info);
60 nand_bank_count = 0;
61 for(i=0;i<4;i++)
63 nand_devicetype[i] = nand_get_device_type(i);
64 if(nand_devicetype[i] != NULL) nand_bank_count++;
66 state=0;
67 #endif
69 lcd_clear_display();
70 lcd_setfont(FONT_SYSFIXED);
72 state=0;
74 while(1)
76 lcd_clear_display();
77 line = 0;
79 /* _DEBUG_PRINTF statements can be added here to show debug info */
80 #ifdef IPOD_NANO2G
82 if(state == 0)
84 _DEBUG_PRINTF("CPU:");
85 _DEBUG_PRINTF("current_tick: %d", (unsigned int)current_tick);
86 line++;
88 _DEBUG_PRINTF("LCD:");
89 _DEBUG_PRINTF("type: %d, %s", lcd_type, lcd_type ? "(7) LDS176" : "(2) ILI9320");
90 line++;
92 _DEBUG_PRINTF("NAND:");
93 _DEBUG_PRINTF("banks: %d",nand_bank_count);
95 for(i=0;i<4;i++)
97 if(nand_devicetype[i] != NULL)
99 _DEBUG_PRINTF("bank: %d, id: %08X", i, (unsigned int)(*nand_devicetype[i]).id);
103 _DEBUG_PRINTF("sectors: %d", info.num_sectors);
104 _DEBUG_PRINTF("sector size: %d", info.sector_size);
105 _DEBUG_PRINTF("last disk activity: %d", (unsigned int)nand_last_disk_activity());
107 else if(state==1)
109 _DEBUG_PRINTF("PMU:");
110 for(i=0;i<7;i++)
112 if(i == 1)
114 _DEBUG_PRINTF("ldo %d: %dmV (CLICKWHEEL)",i,900 + pmu_read(0x2d + (i << 1))*100);
116 else if(i == 3)
118 _DEBUG_PRINTF("ldo %d: %dmV (AUDIO)",i,900 + pmu_read(0x2d + (i << 1))*100);
120 else if(i == 4)
122 _DEBUG_PRINTF("ldo %d: %dmV (NAND)",i,900 + pmu_read(0x2d + (i << 1))*100);
124 else
126 _DEBUG_PRINTF("ldo %d: %dmV",i,900 + pmu_read(0x2d + (i << 1))*100);
129 _DEBUG_PRINTF("cpu voltage: %dmV",625 + pmu_read(0x1e)*25);
130 _DEBUG_PRINTF("memory voltage: %dmV",625 + pmu_read(0x22)*25);
131 line++;
132 _DEBUG_PRINTF("charging: %s", charging_state() ? "true" : "false");
133 _DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off");
134 _DEBUG_PRINTF("brightness value: %d", pmu_read(0x28));
136 else
138 state=0;
141 #else
142 _DEBUG_PRINTF("__dbg_hw_info");
143 #endif
145 lcd_update();
146 switch(get_action(CONTEXT_STD,HZ/20))
148 case ACTION_STD_PREV:
149 if(state!=0) state--;
150 break;
152 case ACTION_STD_NEXT:
153 if(state!=max_states-1)
155 state++;
157 break;
159 case ACTION_STD_CANCEL:
160 lcd_setfont(FONT_UI);
161 return false;
165 lcd_setfont(FONT_UI);
166 return false;
169 bool __dbg_ports(void)
171 char buf[32];
172 int line;
174 lcd_setfont(FONT_SYSFIXED);
176 while(1)
178 lcd_clear_display();
179 line = 0;
181 _DEBUG_PRINTF("GPIO 0: %08x",(unsigned int)PDAT0);
182 _DEBUG_PRINTF("GPIO 1: %08x",(unsigned int)PDAT1);
183 _DEBUG_PRINTF("GPIO 2: %08x",(unsigned int)PDAT2);
184 _DEBUG_PRINTF("GPIO 3: %08x",(unsigned int)PDAT3);
185 _DEBUG_PRINTF("GPIO 4: %08x",(unsigned int)PDAT4);
186 _DEBUG_PRINTF("GPIO 5: %08x",(unsigned int)PDAT5);
187 _DEBUG_PRINTF("GPIO 6: %08x",(unsigned int)PDAT6);
188 _DEBUG_PRINTF("GPIO 7: %08x",(unsigned int)PDAT7);
189 _DEBUG_PRINTF("GPIO 10: %08x",(unsigned int)PDAT10);
190 _DEBUG_PRINTF("GPIO 11: %08x",(unsigned int)PDAT11);
191 _DEBUG_PRINTF("GPIO 13: %08x",(unsigned int)PDAT13);
192 _DEBUG_PRINTF("GPIO 14: %08x",(unsigned int)PDAT14);
193 _DEBUG_PRINTF("5USEC : %08x",(unsigned int)FIVE_USEC_TIMER);
194 _DEBUG_PRINTF("USEC : %08x",(unsigned int)USEC_TIMER);
195 _DEBUG_PRINTF("USECREG: %08x",(unsigned int)(*(REG32_PTR_T)(0x3C700084)));
197 lcd_update();
198 if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
199 break;
201 lcd_setfont(FONT_UI);
202 return false;