summaryrefslogtreecommitdiffstats
path: root/firmware/target/mips/ingenic_jz47xx
diff options
context:
space:
mode:
authorSolomon Peachy <pizza@shaftnet.org>2018-08-29 21:56:10 -0400
committerSolomon Peachy <pizza@shaftnet.org>2018-09-20 18:59:19 -0400
commit72820d8b2d5ebe8405f8c4833f2ff54fe6324faa (patch)
tree1c9ef29e5b76fbb17f5a9625390cd70277030071 /firmware/target/mips/ingenic_jz47xx
parent08ab3aea4f43c733af0e78ee306780e2dbb12970 (diff)
downloadrockbox-72820d8b2d5ebe8405f8c4833f2ff54fe6324faa.tar.gz
rockbox-72820d8b2d5ebe8405f8c4833f2ff54fe6324faa.tar.bz2
rockbox-72820d8b2d5ebe8405f8c4833f2ff54fe6324faa.zip
jz4760: Greatly enhance debug code and silence some compilation warnings.
Change-Id: I1746d67c818ad099edea83e6242ffd5c79be0000
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx')
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c4
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-sd-jz4760.c5
-rw-r--r--firmware/target/mips/ingenic_jz47xx/debug-jz4760.c225
-rw-r--r--firmware/target/mips/ingenic_jz47xx/i2c-jz4760.c13
4 files changed, 138 insertions, 109 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
index 9215d7d08a..4de35367ba 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4740.c
@@ -38,7 +38,7 @@ static int sd_drive_nr = 0;
static tCardInfo card;
static struct mutex sd_mtx;
-static struct semaphore sd_wakeup;
+//static struct semaphore sd_wakeup;
static int use_4bit;
static int num_6;
@@ -1218,7 +1218,7 @@ int sd_init(void)
static bool inited = false;
if(!inited)
{
- semaphore_init(&sd_wakeup, 1, 0);
+// semaphore_init(&sd_wakeup, 1, 0);
mutex_init(&sd_mtx);
inited = true;
}
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4760.c b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4760.c
index c34f74a202..a80e3ec919 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4760.c
+++ b/firmware/target/mips/ingenic_jz47xx/ata-sd-jz4760.c
@@ -34,7 +34,7 @@ static long last_disk_activity = -1;
static tCardInfo card[NUM_DRIVES];
static struct mutex sd_mtx;
-static struct semaphore sd_wakeup;
+//static struct semaphore sd_wakeup;
static int use_4bit[NUM_DRIVES];
static int num_6[NUM_DRIVES];
@@ -1229,7 +1229,7 @@ int sd_init(void)
if(!inited)
{
- semaphore_init(&sd_wakeup, 1, 0);
+// semaphore_init(&sd_wakeup, 1, 0);
mutex_init(&sd_mtx);
inited = true;
}
@@ -1457,6 +1457,7 @@ bool sd_present(const int drive)
#ifdef CONFIG_STORAGE_MULTI
int sd_num_drives(int first_drive)
{
+ (void)first_drive;
return NUM_DRIVES;
}
#endif /* CONFIG_STORAGE_MULTI */
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 @@
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
- * $Id$
*
- * Copyright (C) 2016 by Roman Stolyarov
+ * Copyright (C) 2018 by Solomon Peachy
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -30,117 +29,143 @@
#include "button.h"
#include "timefuncs.h"
-#define CFG_UART_BASE UART1_BASE /* Base of the UART channel */
+static int line = 0;
-void serial_putc (const char c)
-{
- volatile u8 *uart_lsr = (volatile u8 *)(CFG_UART_BASE + OFF_LSR);
- volatile u8 *uart_tdr = (volatile u8 *)(CFG_UART_BASE + OFF_TDR);
-
- if (c == '\n') serial_putc ('\r');
-
- /* Wait for fifo to shift out some bytes */
- while ( !((*uart_lsr & (UARTLSR_TDRQ | UARTLSR_TEMT)) == 0x60) );
+/*
+ * Clock Generation Module
+ */
+#define TO_MHZ(x) ((x)/1000000), ((x)%1000000)/10000
+#define TO_KHZ(x) ((x)/1000), ((x)%1000)/10
- *uart_tdr = (u8)c;
-}
-
-void serial_puts (const char *s)
+static void display_clocks(void)
{
- while (*s) {
- serial_putc (*s++);
- }
+ unsigned int cppcr0 = REG_CPM_CPPCR0; /* PLL Control Register */
+ unsigned int cppcr1 = REG_CPM_CPPCR1; /* PLL Control Register */
+ unsigned int div[] = {1, 2, 3, 4, 6, 8, 12, 16, 24, 32};
+ unsigned int od[4] = {1, 2, 2, 4};
+
+ lcd_putsf(0, line++, "CPPCR0:0x%08x", cppcr0);
+ lcd_putsf(0, line++, "PLL0 :%s", (cppcr0 & CPPCR0_PLLEN) ? "ON" : "OFF");
+ lcd_putsf(0, line++, "PLL0 :%3d.%02d MHz", TO_MHZ(__cpm_get_pllout()));
+ lcd_putsf(0, line++, "m:n:o :%d:%d:%d",
+ __cpm_get_pllm() + 2,
+ __cpm_get_plln() + 2,
+ od[__cpm_get_pllod()]
+ );
+
+ lcd_putsf(0, line++, "CPPCR1:0x%08x", cppcr1);
+
+ lcd_putsf(0, line++, "PLL1 :%s", (cppcr1 & CPPCR1_PLL1EN) ? "ON" : "OFF");
+ lcd_putsf(0, line++, "PLL1 :%3d.%02d MHz", TO_MHZ(__cpm_get_pll1out()));
+ lcd_putsf(0, line++, "m:n:o :%d:%d:%d",
+ __cpm_get_pll1m() + 2,
+ __cpm_get_pll1n() + 2,
+ od[__cpm_get_pll1od()]
+ );
+
+ lcd_putsf(0, line++, "C:H:M:P:%d:%d:%d:%d",
+ div[__cpm_get_cdiv()],
+ div[__cpm_get_hdiv()],
+ div[__cpm_get_mdiv()],
+ div[__cpm_get_pdiv()]
+ );
+ lcd_putsf(0, line++, "I:P:M : %d:%d:%d",
+ __cpm_get_i2sdiv()+1,
+ __cpm_get_pixdiv()+1,
+ __cpm_get_mscdiv()+1
+ );
+ lcd_putsf(0, line++, "CCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_cclk()));
+ lcd_putsf(0, line++, "HCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_hclk()));
+ lcd_putsf(0, line++, "MCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_mclk()));
+ lcd_putsf(0, line++, "PCLK :%3d.%02d MHz", TO_MHZ(__cpm_get_pclk()));
+ lcd_putsf(0, line++, "PIXCLK:%6d.%02d KHz", TO_KHZ(__cpm_get_pixclk()));
+ lcd_putsf(0, line++, "I2SCLK:%3d.%02d MHz", TO_MHZ(__cpm_get_i2sclk()));
+ lcd_putsf(0, line++, "MSCCLK:%3d.%02d MHz", TO_MHZ(__cpm_get_mscclk()));
+ lcd_putsf(0, line++, "EXTALCLK:%3d.%02d MHz", TO_MHZ(__cpm_get_extalclk()));
+ lcd_putsf(0, line++, "RTCCLK:%3d.%02d KHz", TO_KHZ(__cpm_get_rtcclk()));
}
-void serial_putsf(const char *format, ...)
+static void display_enabled_clocks(void)
{
- static char printfbuf[256];
- int len;
- unsigned char *ptr;
- va_list ap;
- va_start(ap, format);
-
- ptr = printfbuf;
- len = vsnprintf(ptr, sizeof(printfbuf), format, ap);
- va_end(ap);
-
- serial_puts(ptr);
- serial_putc('\n');
-}
-
-void serial_put_hex(unsigned int d)
-{
- char c[12];
- int i;
- for(i = 0; i < 8;i++)
- {
- c[i] = (d >> ((7 - i) * 4)) & 0xf;
- if(c[i] < 10)
- c[i] += 0x30;
- else
- c[i] += (0x41 - 10);
- }
- c[8] = '\n';
- c[9] = 0;
- serial_puts(c);
-
-}
-
-void serial_put_dec(unsigned int d)
-{
- char c[16];
- int i;
- int j = 0;
- int x = d;
-
- while (x /= 10)
- j++;
-
- for (i = j; i >= 0; i--) {
- c[i] = d % 10;
- c[i] += 0x30;
- d /= 10;
- }
- c[j + 1] = '\n';
- c[j + 2] = 0;
- serial_puts(c);
-}
-
-void serial_dump_data(unsigned char* data, int len)
-{
- int i;
- for(i=0; i<len; i++)
- {
- unsigned char a = ((*data)>>4) & 0xf;
- if(a < 10)
- a += 0x30;
- else
- a += (0x41 - 10);
- serial_putc( a );
-
- a = (*data) & 0xf;
- if(a < 10)
- a += 0x30;
- else
- a += (0x41 - 10);
- serial_putc( a );
-
- serial_putc( ' ' );
-
- data++;
- }
-
- serial_putc( '\n' );
+ unsigned long lcr = REG_CPM_LCR;
+ unsigned long clkgr0 = REG_CPM_CLKGR0;
+
+ lcd_putsf(0, line++, "Low Power Mode : %s",
+ ((lcr & LCR_LPM_MASK) == LCR_LPM_IDLE) ?
+ "IDLE" : (((lcr & LCR_LPM_MASK) == LCR_LPM_SLEEP) ? "SLEEP" : "HIBERNATE")
+ );
+
+ lcd_putsf(0, line++, "Doze Mode : %s",
+ (lcr & LCR_DOZE) ? "ON" : "OFF");
+ if (lcr & LCR_DOZE)
+ lcd_putsf(0, line++, " duty : %d", (int)((lcr & LCR_DUTY_MASK) >> LCR_DUTY_LSB));
+
+ lcd_putsf(0, line++, "IPU : %s",
+ (clkgr0 & CLKGR0_IPU) ? "stopped" : "running");
+ lcd_putsf(0, line++, "DMAC : %s",
+ (clkgr0 & CLKGR0_DMAC) ? "stopped" : "running");
+ lcd_putsf(0, line++, "UHC : %s",
+ (clkgr0 & CLKGR0_UHC) ? "stopped" : "running");
+ lcd_putsf(0, line++, "LCD : %s",
+ (clkgr0 & CLKGR0_LCD) ? "stopped" : "running");
+ lcd_putsf(0, line++, "CIM : %s",
+ (clkgr0 & CLKGR0_CIM) ? "stopped" : "running");
+ lcd_putsf(0, line++, "SADC : %s",
+ (clkgr0 & CLKGR0_SADC) ? "stopped" : "running");
+ lcd_putsf(0, line++, "MSC0 : %s",
+ (clkgr0 & CLKGR0_MSC0) ? "stopped" : "running");
+ lcd_putsf(0, line++, "MSC1 : %s",
+ (clkgr0 & CLKGR0_MSC1) ? "stopped" : "running");
+ lcd_putsf(0, line++, "MSC2 : %s",
+ (clkgr0 & CLKGR0_MSC2) ? "stopped" : "running");
+ lcd_putsf(0, line++, "AIC : %s",
+ (clkgr0 & CLKGR0_AIC) ? "stopped" : "running");
+ lcd_putsf(0, line++, "SSI1 : %s",
+ (clkgr0 & CLKGR0_SSI1) ? "stopped" : "running");
+ lcd_putsf(0, line++, "SSI2 : %s",
+ (clkgr0 & CLKGR0_SSI2) ? "stopped" : "running");
+ lcd_putsf(0, line++, "I2C0 : %s",
+ (clkgr0 & CLKGR0_I2C0) ? "stopped" : "running");
+ lcd_putsf(0, line++, "I2C1 : %s",
+ (clkgr0 & CLKGR0_I2C1) ? "stopped" : "running");
+ lcd_putsf(0, line++, "UART1 : %s",
+ (clkgr0 & CLKGR0_UART1) ? "stopped" : "running");
+ lcd_putsf(0, line++, "UART0 : %s",
+ (clkgr0 & CLKGR0_UART0) ? "stopped" : "running");
}
bool dbg_ports(void)
{
- serial_puts("dbg_ports\n");
return false;
}
bool dbg_hw_info(void)
{
- serial_puts("dbg_hw_info\n");
- return false;
+ int btn = 0;
+#ifdef HAVE_TOUCHSCREEN
+ int touch;
+#endif
+ struct tm *cur_time;
+
+ lcd_setfont(FONT_UI);
+ while(btn ^ BUTTON_POWER)
+ {
+ lcd_clear_display();
+ line = 0;
+ display_clocks();
+ display_enabled_clocks();
+#ifdef HAVE_TOUCHSCREEN
+ btn = button_read_device(&touch);
+ lcd_putsf(0, line++, "X: %d Y: %d BTN: 0x%X", touch>>16, touch&0xFFFF, btn);
+#else
+ btn = button_read_device();
+#endif
+ cur_time = get_time();
+ lcd_putsf(0, line++, "%02d/%02d/%04d %02d:%02d:%02d", cur_time->tm_mday,
+ cur_time->tm_mon, cur_time->tm_year, cur_time->tm_hour,
+ cur_time->tm_min, cur_time->tm_sec);
+ lcd_update();
+ sleep(HZ/16);
+ }
+ return true;
}
diff --git a/firmware/target/mips/ingenic_jz47xx/i2c-jz4760.c b/firmware/target/mips/ingenic_jz47xx/i2c-jz4760.c
index e35fe7a091..cf67b9d1f6 100644
--- a/firmware/target/mips/ingenic_jz47xx/i2c-jz4760.c
+++ b/firmware/target/mips/ingenic_jz47xx/i2c-jz4760.c
@@ -57,6 +57,7 @@ void I2C1(void)
cmd_flag = -1;
__i2c_clear_interrupts(ret,I2C_CHN);
REG_I2C_INTM(I2C_CHN) = 0x0;
+ (void)ret;
return;
}
@@ -83,7 +84,7 @@ void I2C1(void)
}
cmd_cnt--;
-
+
if (!(cmd_cnt)) {
REG_I2C_INTM(I2C_CHN) = 0x0;
cmd_flag = 2;
@@ -198,9 +199,9 @@ int xfer_read_subaddr(unsigned char subaddr, unsigned char device, unsigned char
i2c_rwflags = I2C_M_RD;
i2c_ctrl_rest = I2C_CTRL_REST;
i2c_init_as_master(device);
-
+
REG_I2C_DC(I2C_CHN) = (I2C_WRITE << 8) | subaddr;
-
+
cmd_flag = 0;
REG_I2C_INTM(I2C_CHN) = 0x10;
timeout = TIMEOUT;
@@ -224,6 +225,7 @@ int xfer_read_subaddr(unsigned char subaddr, unsigned char device, unsigned char
int ret;
r_i = 2;
__i2c_clear_interrupts(ret,I2C_CHN);
+ (void)ret;
goto R_dev_err;
}
}
@@ -269,14 +271,14 @@ int xfer_write_subaddr(unsigned char subaddr, unsigned char device, const unsign
i2c_rwflags = I2C_M_WR;
i2c_ctrl_rest = I2C_CTRL_REST;
i2c_init_as_master(device);
-
+
REG_I2C_DC(I2C_CHN) = (I2C_WRITE << 8) | subaddr;
cmd_flag = 0;
REG_I2C_INTM(I2C_CHN) = 0x10;
timeout = TIMEOUT;
- while ((cmd_flag != 2) && (--timeout))
+ while ((cmd_flag != 2) && (--timeout))
{
if (cmd_flag == -1){
w_i = 1;
@@ -308,6 +310,7 @@ int xfer_write_subaddr(unsigned char subaddr, unsigned char device, const unsign
int ret;
w_i = 5;
__i2c_clear_interrupts(ret,I2C_CHN);
+ (void)ret;
goto W_dev_err;
}