FS#8961 - Anti-Aliased Fonts.
[kugel-rb.git] / firmware / target / mips / ingenic_jz47xx / debug-jz4740.c
blob07b3802bf2fbcdee05d088cc2bfd25450b7ed3c5
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2009 by Maurus Cuelenaere
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 "jz4740.h"
24 #include "debug-target.h"
25 #include <stdarg.h>
26 #include <stdio.h>
27 #include "lcd.h"
28 #include "kernel.h"
29 #include "font.h"
30 #include "button.h"
31 #include "timefuncs.h"
33 static int line = 0;
34 static void printf(const char *format, ...)
36 int len;
37 unsigned char *ptr;
38 char printfbuf[256];
39 va_list ap;
40 va_start(ap, format);
42 ptr = printfbuf;
43 len = vsnprintf(ptr, sizeof(printfbuf), format, ap);
44 va_end(ap);
46 lcd_puts(0, line++, ptr);
50 * Clock Generation Module
52 #define TO_MHZ(x) ((x)/1000000), ((x)%1000000)/10000
53 #define TO_KHZ(x) ((x)/1000), ((x)%1000)/10
55 static void display_clocks(void)
57 unsigned int cppcr = REG_CPM_CPPCR; /* PLL Control Register */
58 unsigned int cpccr = REG_CPM_CPCCR; /* Clock Control Register */
59 unsigned int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
60 unsigned int od[4] = {1, 2, 2, 4};
62 printf("CPPCR : 0x%08x", cppcr);
63 printf("CPCCR : 0x%08x", cpccr);
64 printf("PLL : %s", (cppcr & CPM_CPPCR_PLLEN) ? "ON" : "OFF");
65 printf("m:n:o : %d:%d:%d",
66 __cpm_get_pllm() + 2,
67 __cpm_get_plln() + 2,
68 od[__cpm_get_pllod()]
70 printf("C:H:M:P : %d:%d:%d:%d",
71 div[__cpm_get_cdiv()],
72 div[__cpm_get_hdiv()],
73 div[__cpm_get_mdiv()],
74 div[__cpm_get_pdiv()]
76 printf("U:L:I:P:M : %d:%d:%d:%d:%d",
77 __cpm_get_udiv() + 1,
78 __cpm_get_ldiv() + 1,
79 __cpm_get_i2sdiv()+1,
80 __cpm_get_pixdiv()+1,
81 __cpm_get_mscdiv()+1
83 printf("PLL Freq: %3d.%02d MHz", TO_MHZ(__cpm_get_pllout()));
84 printf("CCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_cclk()));
85 printf("HCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_hclk()));
86 printf("MCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_mclk()));
87 printf("PCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_pclk()));
88 printf("LCDCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_lcdclk()));
89 printf("PIXCLK : %6d.%02d KHz", TO_KHZ(__cpm_get_pixclk()));
90 printf("I2SCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_i2sclk()));
91 printf("USBCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_usbclk()));
92 printf("MSCCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_mscclk()));
93 printf("EXTALCLK: %3d.%02d MHz", TO_MHZ(__cpm_get_extalclk()));
94 printf("RTCCLK : %3d.%02d KHz", TO_KHZ(__cpm_get_rtcclk()));
97 static void display_enabled_clocks(void)
99 unsigned long lcr = REG_CPM_LCR;
100 unsigned long clkgr = REG_CPM_CLKGR;
102 printf("Low Power Mode : %s",
103 ((lcr & CPM_LCR_LPM_MASK) == CPM_LCR_LPM_IDLE) ?
104 "IDLE" : (((lcr & CPM_LCR_LPM_MASK) == CPM_LCR_LPM_SLEEP) ? "SLEEP" : "HIBERNATE")
107 printf("Doze Mode : %s",
108 (lcr & CPM_LCR_DOZE_ON) ? "ON" : "OFF");
109 if (lcr & CPM_LCR_DOZE_ON)
110 printf(" duty : %d", (int)((lcr & CPM_LCR_DOZE_DUTY_MASK) >> CPM_LCR_DOZE_DUTY_BIT));
112 printf("IPU : %s",
113 (clkgr & CPM_CLKGR_IPU) ? "stopped" : "running");
114 printf("DMAC : %s",
115 (clkgr & CPM_CLKGR_DMAC) ? "stopped" : "running");
116 printf("UHC : %s",
117 (clkgr & CPM_CLKGR_UHC) ? "stopped" : "running");
118 printf("UDC : %s",
119 (clkgr & CPM_CLKGR_UDC) ? "stopped" : "running");
120 printf("LCD : %s",
121 (clkgr & CPM_CLKGR_LCD) ? "stopped" : "running");
122 printf("CIM : %s",
123 (clkgr & CPM_CLKGR_CIM) ? "stopped" : "running");
124 printf("SADC : %s",
125 (clkgr & CPM_CLKGR_SADC) ? "stopped" : "running");
126 printf("MSC : %s",
127 (clkgr & CPM_CLKGR_MSC) ? "stopped" : "running");
128 printf("AIC1 : %s",
129 (clkgr & CPM_CLKGR_AIC1) ? "stopped" : "running");
130 printf("AIC2 : %s",
131 (clkgr & CPM_CLKGR_AIC2) ? "stopped" : "running");
132 printf("SSI : %s",
133 (clkgr & CPM_CLKGR_SSI) ? "stopped" : "running");
134 printf("I2C : %s",
135 (clkgr & CPM_CLKGR_I2C) ? "stopped" : "running");
136 printf("RTC : %s",
137 (clkgr & CPM_CLKGR_RTC) ? "stopped" : "running");
138 printf("TCU : %s",
139 (clkgr & CPM_CLKGR_TCU) ? "stopped" : "running");
140 printf("UART1 : %s",
141 (clkgr & CPM_CLKGR_UART1) ? "stopped" : "running");
142 printf("UART0 : %s",
143 (clkgr & CPM_CLKGR_UART0) ? "stopped" : "running");
146 bool __dbg_ports(void)
148 return false;
151 bool __dbg_hw_info(void)
153 int btn = 0;
154 #ifdef HAVE_TOUCHSCREEN
155 int touch;
156 #endif
157 struct tm *cur_time;
159 lcd_setfont(FONT_SYSFIXED);
160 while(btn ^ BUTTON_POWER)
162 lcd_clear_display();
163 line = 0;
164 display_clocks();
165 display_enabled_clocks();
166 #ifdef HAVE_TOUCHSCREEN
167 btn = button_read_device(&touch);
168 printf("X: %d Y: %d BTN: 0x%X", touch>>16, touch&0xFFFF, btn);
169 #else
170 btn = button_read_device();
171 #endif
172 cur_time = get_time();
173 printf("%02d/%02d/%04d %02d:%02d:%02d", cur_time->tm_mday,
174 cur_time->tm_mon, cur_time->tm_year, cur_time->tm_hour,
175 cur_time->tm_min, cur_time->tm_sec);
176 lcd_update();
177 sleep(HZ/16);
179 return true;