diff options
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx/debug-jz4760.c')
-rw-r--r-- | firmware/target/mips/ingenic_jz47xx/debug-jz4760.c | 225 |
1 files changed, 125 insertions, 100 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c index 88fc351946..848fa5343e 100644 --- a/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c +++ b/firmware/target/mips/ingenic_jz47xx/debug-jz4760.c | |||
@@ -5,9 +5,8 @@ | |||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | 5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < |
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | 6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ |
7 | * \/ \/ \/ \/ \/ | 7 | * \/ \/ \/ \/ \/ |
8 | * $Id$ | ||
9 | * | 8 | * |
10 | * Copyright (C) 2016 by Roman Stolyarov | 9 | * Copyright (C) 2018 by Solomon Peachy |
11 | * | 10 | * |
12 | * This program is free software; you can redistribute it and/or | 11 | * This program is free software; you can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 12 | * modify it under the terms of the GNU General Public License |
@@ -30,117 +29,143 @@ | |||
30 | #include "button.h" | 29 | #include "button.h" |
31 | #include "timefuncs.h" | 30 | #include "timefuncs.h" |
32 | 31 | ||
33 | #define CFG_UART_BASE UART1_BASE /* Base of the UART channel */ | 32 | static int line = 0; |
34 | 33 | ||
35 | void serial_putc (const char c) | 34 | /* |
36 | { | 35 | * Clock Generation Module |
37 | volatile u8 *uart_lsr = (volatile u8 *)(CFG_UART_BASE + OFF_LSR); | 36 | */ |
38 | volatile u8 *uart_tdr = (volatile u8 *)(CFG_UART_BASE + OFF_TDR); | 37 | #define TO_MHZ(x) ((x)/1000000), ((x)%1000000)/10000 |
39 | 38 | #define TO_KHZ(x) ((x)/1000), ((x)%1000)/10 | |
40 | if (c == '\n') serial_putc ('\r'); | ||
41 | |||
42 | /* Wait for fifo to shift out some bytes */ | ||
43 | while ( !((*uart_lsr & (UARTLSR_TDRQ | UARTLSR_TEMT)) == 0x60) ); | ||
44 | 39 | ||
45 | *uart_tdr = (u8)c; | 40 | static void display_clocks(void) |
46 | } | ||
47 | |||
48 | void serial_puts (const char *s) | ||
49 | { | 41 | { |
50 | while (*s) { | 42 | unsigned int cppcr0 = REG_CPM_CPPCR0; /* PLL Control Register */ |
51 | serial_putc (*s++); | 43 | unsigned int cppcr1 = REG_CPM_CPPCR1; /* PLL Control Register */ |
52 | } | 44 | unsigned int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32}; |
45 | unsigned int od[4] = {1, 2, 2, 4}; | ||
46 | |||
47 | lcd_putsf(0, line++, "CPPCR0:0x%08x", cppcr0); | ||
48 | lcd_putsf(0, line++, "PLL0 :%s", (cppcr0 & CPPCR0_PLLEN) ? "ON" : "OFF"); | ||
49 | lcd_putsf(0, line++, "PLL0 :%3d.%02d MHz", TO_MHZ(__cpm_get_pllout())); | ||
50 | lcd_putsf(0, line++, "m:n:o :%d:%d:%d", | ||
51 | __cpm_get_pllm() + 2, | ||
52 | __cpm_get_plln() + 2, | ||
53 | od[__cpm_get_pllod()] | ||
54 | ); | ||
55 | |||
56 | lcd_putsf(0, line++, "CPPCR1:0x%08x", cppcr1); | ||
57 | |||
58 | lcd_putsf(0, line++, "PLL1 :%s", (cppcr1 & CPPCR1_PLL1EN) ? "ON" : "OFF"); | ||
59 | lcd_putsf(0, line++, "PLL1 :%3d.%02d MHz", TO_MHZ(__cpm_get_pll1out())); | ||
60 | lcd_putsf(0, line++, "m:n:o :%d:%d:%d", | ||
61 | __cpm_get_pll1m() + 2, | ||
62 | __cpm_get_pll1n() + 2, | ||
63 | od[__cpm_get_pll1od()] | ||
64 | ); | ||
65 | |||
66 | lcd_putsf(0, line++, "C:H:M:P:%d:%d:%d:%d", | ||
67 | div[__cpm_get_cdiv()], | ||
68 | div[__cpm_get_hdiv()], | ||
69 | div[__cpm_get_mdiv()], | ||
70 | div[__cpm_get_pdiv()] | ||
71 | ); | ||
72 | lcd_putsf(0, line++, "I:P:M : %d:%d:%d", | ||
73 | __cpm_get_i2sdiv()+1, | ||
74 | __cpm_get_pixdiv()+1, | ||
75 | __cpm_get_mscdiv()+1 | ||
76 | ); | ||
77 | lcd_putsf(0, line++, "CCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_cclk())); | ||
78 | lcd_putsf(0, line++, "HCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_hclk())); | ||
79 | lcd_putsf(0, line++, "MCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_mclk())); | ||
80 | lcd_putsf(0, line++, "PCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_pclk())); | ||
81 | lcd_putsf(0, line++, "PIXCLK:%6d.%02d KHz", TO_KHZ(__cpm_get_pixclk())); | ||
82 | lcd_putsf(0, line++, "I2SCLK:%3d.%02d MHz", TO_MHZ(__cpm_get_i2sclk())); | ||
83 | lcd_putsf(0, line++, "MSCCLK:%3d.%02d MHz", TO_MHZ(__cpm_get_mscclk())); | ||
84 | lcd_putsf(0, line++, "EXTALCLK:%3d.%02d MHz", TO_MHZ(__cpm_get_extalclk())); | ||
85 | lcd_putsf(0, line++, "RTCCLK:%3d.%02d KHz", TO_KHZ(__cpm_get_rtcclk())); | ||
53 | } | 86 | } |
54 | 87 | ||
55 | void serial_putsf(const char *format, ...) | 88 | static void display_enabled_clocks(void) |
56 | { | 89 | { |
57 | static char printfbuf[256]; | 90 | unsigned long lcr = REG_CPM_LCR; |
58 | int len; | 91 | unsigned long clkgr0 = REG_CPM_CLKGR0; |
59 | unsigned char *ptr; | 92 | |
60 | va_list ap; | 93 | lcd_putsf(0, line++, "Low Power Mode : %s", |
61 | va_start(ap, format); | 94 | ((lcr & LCR_LPM_MASK) == LCR_LPM_IDLE) ? |
62 | 95 | "IDLE" : (((lcr & LCR_LPM_MASK) == LCR_LPM_SLEEP) ? "SLEEP" : "HIBERNATE") | |
63 | ptr = printfbuf; | 96 | ); |
64 | len = vsnprintf(ptr, sizeof(printfbuf), format, ap); | 97 | |
65 | va_end(ap); | 98 | lcd_putsf(0, line++, "Doze Mode : %s", |
66 | 99 | (lcr & LCR_DOZE) ? "ON" : "OFF"); | |
67 | serial_puts(ptr); | 100 | if (lcr & LCR_DOZE) |
68 | serial_putc('\n'); | 101 | lcd_putsf(0, line++, " duty : %d", (int)((lcr & LCR_DUTY_MASK) >> LCR_DUTY_LSB)); |
69 | } | 102 | |
70 | 103 | lcd_putsf(0, line++, "IPU : %s", | |
71 | void serial_put_hex(unsigned int d) | 104 | (clkgr0 & CLKGR0_IPU) ? "stopped" : "running"); |
72 | { | 105 | lcd_putsf(0, line++, "DMAC : %s", |
73 | char c[12]; | 106 | (clkgr0 & CLKGR0_DMAC) ? "stopped" : "running"); |
74 | int i; | 107 | lcd_putsf(0, line++, "UHC : %s", |
75 | for(i = 0; i < 8;i++) | 108 | (clkgr0 & CLKGR0_UHC) ? "stopped" : "running"); |
76 | { | 109 | lcd_putsf(0, line++, "LCD : %s", |
77 | c[i] = (d >> ((7 - i) * 4)) & 0xf; | 110 | (clkgr0 & CLKGR0_LCD) ? "stopped" : "running"); |
78 | if(c[i] < 10) | 111 | lcd_putsf(0, line++, "CIM : %s", |
79 | c[i] += 0x30; | 112 | (clkgr0 & CLKGR0_CIM) ? "stopped" : "running"); |
80 | else | 113 | lcd_putsf(0, line++, "SADC : %s", |
81 | c[i] += (0x41 - 10); | 114 | (clkgr0 & CLKGR0_SADC) ? "stopped" : "running"); |
82 | } | 115 | lcd_putsf(0, line++, "MSC0 : %s", |
83 | c[8] = '\n'; | 116 | (clkgr0 & CLKGR0_MSC0) ? "stopped" : "running"); |
84 | c[9] = 0; | 117 | lcd_putsf(0, line++, "MSC1 : %s", |
85 | serial_puts(c); | 118 | (clkgr0 & CLKGR0_MSC1) ? "stopped" : "running"); |
86 | 119 | lcd_putsf(0, line++, "MSC2 : %s", | |
87 | } | 120 | (clkgr0 & CLKGR0_MSC2) ? "stopped" : "running"); |
88 | 121 | lcd_putsf(0, line++, "AIC : %s", | |
89 | void serial_put_dec(unsigned int d) | 122 | (clkgr0 & CLKGR0_AIC) ? "stopped" : "running"); |
90 | { | 123 | lcd_putsf(0, line++, "SSI1 : %s", |
91 | char c[16]; | 124 | (clkgr0 & CLKGR0_SSI1) ? "stopped" : "running"); |
92 | int i; | 125 | lcd_putsf(0, line++, "SSI2 : %s", |
93 | int j = 0; | 126 | (clkgr0 & CLKGR0_SSI2) ? "stopped" : "running"); |
94 | int x = d; | 127 | lcd_putsf(0, line++, "I2C0 : %s", |
95 | 128 | (clkgr0 & CLKGR0_I2C0) ? "stopped" : "running"); | |
96 | while (x /= 10) | 129 | lcd_putsf(0, line++, "I2C1 : %s", |
97 | j++; | 130 | (clkgr0 & CLKGR0_I2C1) ? "stopped" : "running"); |
98 | 131 | lcd_putsf(0, line++, "UART1 : %s", | |
99 | for (i = j; i >= 0; i--) { | 132 | (clkgr0 & CLKGR0_UART1) ? "stopped" : "running"); |
100 | c[i] = d % 10; | 133 | lcd_putsf(0, line++, "UART0 : %s", |
101 | c[i] += 0x30; | 134 | (clkgr0 & CLKGR0_UART0) ? "stopped" : "running"); |
102 | d /= 10; | ||
103 | } | ||
104 | c[j + 1] = '\n'; | ||
105 | c[j + 2] = 0; | ||
106 | serial_puts(c); | ||
107 | } | ||
108 | |||
109 | void serial_dump_data(unsigned char* data, int len) | ||
110 | { | ||
111 | int i; | ||
112 | for(i=0; i<len; i++) | ||
113 | { | ||
114 | unsigned char a = ((*data)>>4) & 0xf; | ||
115 | if(a < 10) | ||
116 | a += 0x30; | ||
117 | else | ||
118 | a += (0x41 - 10); | ||
119 | serial_putc( a ); | ||
120 | |||
121 | a = (*data) & 0xf; | ||
122 | if(a < 10) | ||
123 | a += 0x30; | ||
124 | else | ||
125 | a += (0x41 - 10); | ||
126 | serial_putc( a ); | ||
127 | |||
128 | serial_putc( ' ' ); | ||
129 | |||
130 | data++; | ||
131 | } | ||
132 | |||
133 | serial_putc( '\n' ); | ||
134 | } | 135 | } |
135 | 136 | ||
136 | bool dbg_ports(void) | 137 | bool dbg_ports(void) |
137 | { | 138 | { |
138 | serial_puts("dbg_ports\n"); | ||
139 | return false; | 139 | return false; |
140 | } | 140 | } |
141 | 141 | ||
142 | bool dbg_hw_info(void) | 142 | bool dbg_hw_info(void) |
143 | { | 143 | { |
144 | serial_puts("dbg_hw_info\n"); | 144 | int btn = 0; |
145 | return false; | 145 | #ifdef HAVE_TOUCHSCREEN |
146 | int touch; | ||
147 | #endif | ||
148 | struct tm *cur_time; | ||
149 | |||
150 | lcd_setfont(FONT_UI); | ||
151 | while(btn ^ BUTTON_POWER) | ||
152 | { | ||
153 | lcd_clear_display(); | ||
154 | line = 0; | ||
155 | display_clocks(); | ||
156 | display_enabled_clocks(); | ||
157 | #ifdef HAVE_TOUCHSCREEN | ||
158 | btn = button_read_device(&touch); | ||
159 | lcd_putsf(0, line++, "X: %d Y: %d BTN: 0x%X", touch>>16, touch&0xFFFF, btn); | ||
160 | #else | ||
161 | btn = button_read_device(); | ||
162 | #endif | ||
163 | cur_time = get_time(); | ||
164 | lcd_putsf(0, line++, "%02d/%02d/%04d %02d:%02d:%02d", cur_time->tm_mday, | ||
165 | cur_time->tm_mon, cur_time->tm_year, cur_time->tm_hour, | ||
166 | cur_time->tm_min, cur_time->tm_sec); | ||
167 | lcd_update(); | ||
168 | sleep(HZ/16); | ||
169 | } | ||
170 | return true; | ||
146 | } | 171 | } |