move dbg_ports() from apps/menu_debug.c to target tree. FS#11712 by me.
[kugel-rb.git] / firmware / target / mips / ingenic_jz47xx / debug-jz4740.c
blob5bdd4c4de975ea9ba54fab661c227aa310f9bb12
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;
36 * Clock Generation Module
38 #define TO_MHZ(x) ((x)/1000000), ((x)%1000000)/10000
39 #define TO_KHZ(x) ((x)/1000), ((x)%1000)/10
41 static void display_clocks(void)
43 unsigned int cppcr = REG_CPM_CPPCR; /* PLL Control Register */
44 unsigned int cpccr = REG_CPM_CPCCR; /* Clock Control Register */
45 unsigned int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
46 unsigned int od[4] = {1, 2, 2, 4};
48 lcd_putsf(0, line++, "CPPCR : 0x%08x", cppcr);
49 lcd_putsf(0, line++, "CPCCR : 0x%08x", cpccr);
50 lcd_putsf(0, line++, "PLL : %s", (cppcr & CPM_CPPCR_PLLEN) ? "ON" : "OFF");
51 lcd_putsf(0, line++, "m:n:o : %d:%d:%d",
52 __cpm_get_pllm() + 2,
53 __cpm_get_plln() + 2,
54 od[__cpm_get_pllod()]
56 lcd_putsf(0, line++, "C:H:M:P : %d:%d:%d:%d",
57 div[__cpm_get_cdiv()],
58 div[__cpm_get_hdiv()],
59 div[__cpm_get_mdiv()],
60 div[__cpm_get_pdiv()]
62 lcd_putsf(0, line++, "U:L:I:P:M : %d:%d:%d:%d:%d",
63 __cpm_get_udiv() + 1,
64 __cpm_get_ldiv() + 1,
65 __cpm_get_i2sdiv()+1,
66 __cpm_get_pixdiv()+1,
67 __cpm_get_mscdiv()+1
69 lcd_putsf(0, line++, "PLL Freq: %3d.%02d MHz", TO_MHZ(__cpm_get_pllout()));
70 lcd_putsf(0, line++, "CCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_cclk()));
71 lcd_putsf(0, line++, "HCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_hclk()));
72 lcd_putsf(0, line++, "MCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_mclk()));
73 lcd_putsf(0, line++, "PCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_pclk()));
74 lcd_putsf(0, line++, "LCDCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_lcdclk()));
75 lcd_putsf(0, line++, "PIXCLK : %6d.%02d KHz", TO_KHZ(__cpm_get_pixclk()));
76 lcd_putsf(0, line++, "I2SCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_i2sclk()));
77 lcd_putsf(0, line++, "USBCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_usbclk()));
78 lcd_putsf(0, line++, "MSCCLK : %3d.%02d MHz", TO_MHZ(__cpm_get_mscclk()));
79 lcd_putsf(0, line++, "EXTALCLK: %3d.%02d MHz", TO_MHZ(__cpm_get_extalclk()));
80 lcd_putsf(0, line++, "RTCCLK : %3d.%02d KHz", TO_KHZ(__cpm_get_rtcclk()));
83 static void display_enabled_clocks(void)
85 unsigned long lcr = REG_CPM_LCR;
86 unsigned long clkgr = REG_CPM_CLKGR;
88 lcd_putsf(0, line++, "Low Power Mode : %s",
89 ((lcr & CPM_LCR_LPM_MASK) == CPM_LCR_LPM_IDLE) ?
90 "IDLE" : (((lcr & CPM_LCR_LPM_MASK) == CPM_LCR_LPM_SLEEP) ? "SLEEP" : "HIBERNATE")
93 lcd_putsf(0, line++, "Doze Mode : %s",
94 (lcr & CPM_LCR_DOZE_ON) ? "ON" : "OFF");
95 if (lcr & CPM_LCR_DOZE_ON)
96 lcd_putsf(0, line++, " duty : %d", (int)((lcr & CPM_LCR_DOZE_DUTY_MASK) >> CPM_LCR_DOZE_DUTY_BIT));
98 lcd_putsf(0, line++, "IPU : %s",
99 (clkgr & CPM_CLKGR_IPU) ? "stopped" : "running");
100 lcd_putsf(0, line++, "DMAC : %s",
101 (clkgr & CPM_CLKGR_DMAC) ? "stopped" : "running");
102 lcd_putsf(0, line++, "UHC : %s",
103 (clkgr & CPM_CLKGR_UHC) ? "stopped" : "running");
104 lcd_putsf(0, line++, "UDC : %s",
105 (clkgr & CPM_CLKGR_UDC) ? "stopped" : "running");
106 lcd_putsf(0, line++, "LCD : %s",
107 (clkgr & CPM_CLKGR_LCD) ? "stopped" : "running");
108 lcd_putsf(0, line++, "CIM : %s",
109 (clkgr & CPM_CLKGR_CIM) ? "stopped" : "running");
110 lcd_putsf(0, line++, "SADC : %s",
111 (clkgr & CPM_CLKGR_SADC) ? "stopped" : "running");
112 lcd_putsf(0, line++, "MSC : %s",
113 (clkgr & CPM_CLKGR_MSC) ? "stopped" : "running");
114 lcd_putsf(0, line++, "AIC1 : %s",
115 (clkgr & CPM_CLKGR_AIC1) ? "stopped" : "running");
116 lcd_putsf(0, line++, "AIC2 : %s",
117 (clkgr & CPM_CLKGR_AIC2) ? "stopped" : "running");
118 lcd_putsf(0, line++, "SSI : %s",
119 (clkgr & CPM_CLKGR_SSI) ? "stopped" : "running");
120 lcd_putsf(0, line++, "I2C : %s",
121 (clkgr & CPM_CLKGR_I2C) ? "stopped" : "running");
122 lcd_putsf(0, line++, "RTC : %s",
123 (clkgr & CPM_CLKGR_RTC) ? "stopped" : "running");
124 lcd_putsf(0, line++, "TCU : %s",
125 (clkgr & CPM_CLKGR_TCU) ? "stopped" : "running");
126 lcd_putsf(0, line++, "UART1 : %s",
127 (clkgr & CPM_CLKGR_UART1) ? "stopped" : "running");
128 lcd_putsf(0, line++, "UART0 : %s",
129 (clkgr & CPM_CLKGR_UART0) ? "stopped" : "running");
132 bool dbg_ports(void)
134 return false;
137 bool __dbg_hw_info(void)
139 int btn = 0;
140 #ifdef HAVE_TOUCHSCREEN
141 int touch;
142 #endif
143 struct tm *cur_time;
145 lcd_setfont(FONT_SYSFIXED);
146 while(btn ^ BUTTON_POWER)
148 lcd_clear_display();
149 line = 0;
150 display_clocks();
151 display_enabled_clocks();
152 #ifdef HAVE_TOUCHSCREEN
153 btn = button_read_device(&touch);
154 lcd_putsf(0, line++, "X: %d Y: %d BTN: 0x%X", touch>>16, touch&0xFFFF, btn);
155 #else
156 btn = button_read_device();
157 #endif
158 cur_time = get_time();
159 lcd_putsf(0, line++, "%02d/%02d/%04d %02d:%02d:%02d", cur_time->tm_mday,
160 cur_time->tm_mon, cur_time->tm_year, cur_time->tm_hour,
161 cur_time->tm_min, cur_time->tm_sec);
162 lcd_update();
163 sleep(HZ/16);
165 return true;