1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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 ****************************************************************************/
24 #include "debug-target.h"
31 #include "timefuncs.h"
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",
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()],
62 lcd_putsf(0, line
++, "U:L:I:P:M : %d:%d:%d:%d:%d",
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");
137 bool __dbg_hw_info(void)
140 #ifdef HAVE_TOUCHSCREEN
145 lcd_setfont(FONT_SYSFIXED
);
146 while(btn
^ BUTTON_POWER
)
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
);
156 btn
= button_read_device();
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
);