Move c/h files implementing/defining standard library stuff into a new libc directory...
[kugel-rb.git] / firmware / target / arm / s5l8700 / debug-s5l8700.c
blob96df1546ef688ad9879b6fa9085717efd6a33930
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 "storage.h"
30 #ifdef IPOD_NANO2G
31 #include "power.h"
32 #include "pmu-target.h"
33 #include "nand-target.h"
34 #endif
36 /* Skeleton for adding target specific debug info to the debug menu
39 #define _DEBUG_PRINTF(a, varargs...) lcd_putsf(0, line++, (a), ##varargs);
41 extern int lcd_type;
42 extern uint32_t nand_type[4];
44 bool __dbg_hw_info(void)
46 int line;
47 int i;
48 #ifdef IPOD_NANO2G
49 unsigned int state = 0;
50 const unsigned int max_states=2;
51 int nand_bank_count;
52 struct storage_info info;
53 const struct nand_device_info_type *nand_devicetype[4];
54 nand_get_info(&info);
55 nand_bank_count = 0;
56 for(i=0;i<4;i++)
58 nand_devicetype[i] = nand_get_device_type(i);
59 if(nand_devicetype[i] != NULL) nand_bank_count++;
61 #endif
63 lcd_clear_display();
64 lcd_setfont(FONT_SYSFIXED);
66 state=0;
67 while(1)
69 lcd_clear_display();
70 line = 0;
72 /* _DEBUG_PRINTF statements can be added here to show debug info */
73 #ifdef IPOD_NANO2G
75 if(state == 0)
77 _DEBUG_PRINTF("CPU:");
78 _DEBUG_PRINTF("current_tick: %d", (unsigned int)current_tick);
79 line++;
81 _DEBUG_PRINTF("LCD:");
82 _DEBUG_PRINTF("type: %d, %s", lcd_type, lcd_type ? "(7) LDS176" : "(2) ILI9320");
83 line++;
85 _DEBUG_PRINTF("NAND:");
86 _DEBUG_PRINTF("banks: %d",nand_bank_count);
88 for(i=0;i<4;i++)
90 if(nand_devicetype[i] != NULL)
92 _DEBUG_PRINTF("bank: %d, id: %08X", i, (unsigned int)(*nand_devicetype[i]).id);
96 _DEBUG_PRINTF("sectors: %d", info.num_sectors);
97 _DEBUG_PRINTF("sector size: %d", info.sector_size);
98 _DEBUG_PRINTF("last disk activity: %d", (unsigned int)nand_last_disk_activity());
100 else if(state==1)
102 _DEBUG_PRINTF("PMU:");
103 for(i=0;i<7;i++)
105 if(i == 1)
107 _DEBUG_PRINTF("ldo %d: %dmV (CLICKWHEEL)",i,900 + pmu_read(0x2d + (i << 1))*100);
109 else if(i == 3)
111 _DEBUG_PRINTF("ldo %d: %dmV (AUDIO)",i,900 + pmu_read(0x2d + (i << 1))*100);
113 else if(i == 4)
115 _DEBUG_PRINTF("ldo %d: %dmV (NAND)",i,900 + pmu_read(0x2d + (i << 1))*100);
117 else
119 _DEBUG_PRINTF("ldo %d: %dmV",i,900 + pmu_read(0x2d + (i << 1))*100);
122 _DEBUG_PRINTF("cpu voltage: %dmV",625 + pmu_read(0x1e)*25);
123 _DEBUG_PRINTF("memory voltage: %dmV",625 + pmu_read(0x22)*25);
124 line++;
125 _DEBUG_PRINTF("charging: %s", charging_state() ? "true" : "false");
126 _DEBUG_PRINTF("backlight: %s", pmu_read(0x29) ? "on" : "off");
127 _DEBUG_PRINTF("brightness value: %d", pmu_read(0x28));
129 else
131 state=0;
134 #else
135 _DEBUG_PRINTF("__dbg_hw_info");
136 #endif
138 lcd_update();
139 switch(button_get_w_tmo(HZ/20))
141 case BUTTON_SCROLL_BACK:
142 if(state!=0) state--;
143 break;
145 case BUTTON_SCROLL_FWD:
146 if(state!=max_states-1)
148 state++;
150 break;
152 case DEBUG_CANCEL:
153 case BUTTON_REL:
154 lcd_setfont(FONT_UI);
155 return false;
159 lcd_setfont(FONT_UI);
160 return false;
163 bool __dbg_ports(void)
165 int line;
167 lcd_setfont(FONT_SYSFIXED);
169 while(1)
171 lcd_clear_display();
172 line = 0;
174 _DEBUG_PRINTF("GPIO 0: %08x",(unsigned int)PDAT0);
175 _DEBUG_PRINTF("GPIO 1: %08x",(unsigned int)PDAT1);
176 _DEBUG_PRINTF("GPIO 2: %08x",(unsigned int)PDAT2);
177 _DEBUG_PRINTF("GPIO 3: %08x",(unsigned int)PDAT3);
178 _DEBUG_PRINTF("GPIO 4: %08x",(unsigned int)PDAT4);
179 _DEBUG_PRINTF("GPIO 5: %08x",(unsigned int)PDAT5);
180 _DEBUG_PRINTF("GPIO 6: %08x",(unsigned int)PDAT6);
181 _DEBUG_PRINTF("GPIO 7: %08x",(unsigned int)PDAT7);
182 _DEBUG_PRINTF("GPIO 10: %08x",(unsigned int)PDAT10);
183 _DEBUG_PRINTF("GPIO 11: %08x",(unsigned int)PDAT11);
184 _DEBUG_PRINTF("GPIO 13: %08x",(unsigned int)PDAT13);
185 _DEBUG_PRINTF("GPIO 14: %08x",(unsigned int)PDAT14);
186 _DEBUG_PRINTF("5USEC : %08x",(unsigned int)FIVE_USEC_TIMER);
187 _DEBUG_PRINTF("USEC : %08x",(unsigned int)USEC_TIMER);
188 _DEBUG_PRINTF("USECREG: %08x",(unsigned int)(*(REG32_PTR_T)(0x3C700084)));
190 lcd_update();
191 if (button_get_w_tmo(HZ/10) == (DEBUG_CANCEL|BUTTON_REL))
192 break;
194 lcd_setfont(FONT_UI);
195 return false;