summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--firmware/export/jz4760b.h148
-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
5 files changed, 215 insertions, 180 deletions
diff --git a/firmware/export/jz4760b.h b/firmware/export/jz4760b.h
index c523cc64c9..c35e26767f 100644
--- a/firmware/export/jz4760b.h
+++ b/firmware/export/jz4760b.h
@@ -1332,7 +1332,7 @@ do { \
1332#define DMAC_DCCSR_CT (1 << 1) /* count terminated */ 1332#define DMAC_DCCSR_CT (1 << 1) /* count terminated */
1333#define DMAC_DCCSR_EN (1 << 0) /* channel enable bit */ 1333#define DMAC_DCCSR_EN (1 << 0) /* channel enable bit */
1334 1334
1335// DMA channel command register 1335// DMA channel command register
1336#define DMAC_DCMD_EACKS_LOW (1 << 31) /* External DACK Output Level Select, active low */ 1336#define DMAC_DCMD_EACKS_LOW (1 << 31) /* External DACK Output Level Select, active low */
1337#define DMAC_DCMD_EACKS_HIGH (0 << 31) /* External DACK Output Level Select, active high */ 1337#define DMAC_DCMD_EACKS_HIGH (0 << 31) /* External DACK Output Level Select, active high */
1338#define DMAC_DCMD_EACKM_WRITE (1 << 30) /* External DACK Output Mode Select, output in write cycle */ 1338#define DMAC_DCMD_EACKM_WRITE (1 << 30) /* External DACK Output Mode Select, output in write cycle */
@@ -3090,7 +3090,7 @@ static __inline__ int __bdmac_get_irq(void)
3090#define CIM_CTRL_RXF_TRIGM (1 << 9) 3090#define CIM_CTRL_RXF_TRIGM (1 << 9)
3091#define CIM_CTRL_RXF_OFM (1 << 8) 3091#define CIM_CTRL_RXF_OFM (1 << 8)
3092#define CIM_CTRL_DMA_SYNC (1 << 7) /*when change DA, do frame sync */ 3092#define CIM_CTRL_DMA_SYNC (1 << 7) /*when change DA, do frame sync */
3093#define CIM_CTRL_H_SYNC (1 << 6) /*Enable horizental sync when CIMCFG.SEP is 1*/ 3093#define CIM_CTRL_H_SYNC (1 << 6) /*Enable horizental sync when CIMCFG.SEP is 1*/
3094 3094
3095#define CIM_CTRL_PPW_BIT 3 3095#define CIM_CTRL_PPW_BIT 3
3096#define CIM_CTRL_PPW_MASK (0x3 << CIM_CTRL_PPW_BIT) 3096#define CIM_CTRL_PPW_MASK (0x3 << CIM_CTRL_PPW_BIT)
@@ -3632,7 +3632,7 @@ static __inline__ int __bdmac_get_irq(void)
3632#define USBCDR_OTGDIV_LSB 0 /* USBCDR bit */ 3632#define USBCDR_OTGDIV_LSB 0 /* USBCDR bit */
3633#define USBCDR_OTGDIV_MASK BITS_H2L(5, USBCDR_OTGDIV_LSB) 3633#define USBCDR_OTGDIV_MASK BITS_H2L(5, USBCDR_OTGDIV_LSB)
3634 3634
3635/* I2S device clock divider register(I2SCDR) */ 3635/* I2S device clock divider register(I2SCDR) */
3636#define I2SCDR_I2CS BIT31 3636#define I2SCDR_I2CS BIT31
3637#define I2SCDR_I2PCS BIT30 3637#define I2SCDR_I2PCS BIT30
3638 3638
@@ -4114,6 +4114,12 @@ static inline void __cpm_select_msc_clk(int sd)
4114 REG_CPM_CPCCR |= CPCCR_CE; 4114 REG_CPM_CPCCR |= CPCCR_CE;
4115} 4115}
4116 4116
4117/* MSC clock */
4118static __inline__ unsigned int __cpm_get_mscclk(void)
4119{
4120 return __cpm_get_pllout2() / (__cpm_get_mscdiv() + 1);
4121}
4122
4117#endif /* __MIPS_ASSEMBLER */ 4123#endif /* __MIPS_ASSEMBLER */
4118 4124
4119#define DDRC_BASE 0xB3020000 4125#define DDRC_BASE 0xB3020000
@@ -4163,7 +4169,7 @@ static inline void __cpm_select_msc_clk(int sd)
4163/* DDRC Status Register */ 4169/* DDRC Status Register */
4164#define DDRC_ST_ENDIAN (1 << 7) /* 0 Little data endian 4170#define DDRC_ST_ENDIAN (1 << 7) /* 0 Little data endian
4165 1 Big data endian */ 4171 1 Big data endian */
4166#define DDRC_ST_MISS (1 << 6) 4172#define DDRC_ST_MISS (1 << 6)
4167 4173
4168#define DDRC_ST_DPDN (1 << 5) /* 0 DDR memory is NOT in deep-power-down state 4174#define DDRC_ST_DPDN (1 << 5) /* 0 DDR memory is NOT in deep-power-down state
4169 1 DDR memory is in deep-power-down state */ 4175 1 DDR memory is in deep-power-down state */
@@ -4289,14 +4295,14 @@ static inline void __cpm_select_msc_clk(int sd)
4289 defined by CMD field */ 4295 defined by CMD field */
4290/* DDRC Mode Register Set */ 4296/* DDRC Mode Register Set */
4291#define DDR_MRS_PD_BIT (1 << 10) /* Active power down exit time */ 4297#define DDR_MRS_PD_BIT (1 << 10) /* Active power down exit time */
4292#define DDR_MRS_PD_MASK (1 << DDR_MRS_PD_BIT) 4298#define DDR_MRS_PD_MASK (1 << DDR_MRS_PD_BIT)
4293#define DDR_MRS_PD_FAST_EXIT (0 << 10) 4299#define DDR_MRS_PD_FAST_EXIT (0 << 10)
4294#define DDR_MRS_PD_SLOW_EXIT (1 << 10) 4300#define DDR_MRS_PD_SLOW_EXIT (1 << 10)
4295#define DDR_MRS_WR_BIT (1 << 9) /* Write Recovery for autoprecharge */ 4301#define DDR_MRS_WR_BIT (1 << 9) /* Write Recovery for autoprecharge */
4296#define DDR_MRS_WR_MASK (7 << DDR_MRS_WR_BIT) 4302#define DDR_MRS_WR_MASK (7 << DDR_MRS_WR_BIT)
4297#define DDR_MRS_DLL_RST (1 << 8) /* DLL Reset */ 4303#define DDR_MRS_DLL_RST (1 << 8) /* DLL Reset */
4298#define DDR_MRS_TM_BIT 7 /* Operating Mode */ 4304#define DDR_MRS_TM_BIT 7 /* Operating Mode */
4299#define DDR_MRS_TM_MASK (1 << DDR_MRS_OM_BIT) 4305#define DDR_MRS_TM_MASK (1 << DDR_MRS_OM_BIT)
4300#define DDR_MRS_TM_NORMAL (0 << DDR_MRS_OM_BIT) 4306#define DDR_MRS_TM_NORMAL (0 << DDR_MRS_OM_BIT)
4301#define DDR_MRS_TM_TEST (1 << DDR_MRS_OM_BIT) 4307#define DDR_MRS_TM_TEST (1 << DDR_MRS_OM_BIT)
4302#define DDR_MRS_CAS_BIT 4 /* CAS Latency */ 4308#define DDR_MRS_CAS_BIT 4 /* CAS Latency */
@@ -4423,11 +4429,11 @@ static inline void __cpm_select_msc_clk(int sd)
4423#define DDRC_DQS_DET (1 << 24) /* Start delay detecting. */ 4429#define DDRC_DQS_DET (1 << 24) /* Start delay detecting. */
4424#define DDRC_DQS_AUTO (1 << 23) /* Hardware auto-detect & set delay line */ 4430#define DDRC_DQS_AUTO (1 << 23) /* Hardware auto-detect & set delay line */
4425#define DDRC_DQS_CLKD_BIT 16 /* CLKD is reference value for setting WDQS and RDQS.*/ 4431#define DDRC_DQS_CLKD_BIT 16 /* CLKD is reference value for setting WDQS and RDQS.*/
4426#define DDRC_DQS_CLKD_MASK (0x3f << DDRC_DQS_CLKD_BIT) 4432#define DDRC_DQS_CLKD_MASK (0x3f << DDRC_DQS_CLKD_BIT)
4427#define DDRC_DQS_WDQS_BIT 8 /* Set delay element number to write DQS delay-line. */ 4433#define DDRC_DQS_WDQS_BIT 8 /* Set delay element number to write DQS delay-line. */
4428#define DDRC_DQS_WDQS_MASK (0x3f << DDRC_DQS_WDQS_BIT) 4434#define DDRC_DQS_WDQS_MASK (0x3f << DDRC_DQS_WDQS_BIT)
4429#define DDRC_DQS_RDQS_BIT 0 /* Set delay element number to read DQS delay-line. */ 4435#define DDRC_DQS_RDQS_BIT 0 /* Set delay element number to read DQS delay-line. */
4430#define DDRC_DQS_RDQS_MASK (0x3f << DDRC_DQS_RDQS_BIT) 4436#define DDRC_DQS_RDQS_MASK (0x3f << DDRC_DQS_RDQS_BIT)
4431 4437
4432/* DDRC DQS Delay Adjust Register */ 4438/* DDRC DQS Delay Adjust Register */
4433#define DDRC_DQS_ADJDQSCON_BIT 16 4439#define DDRC_DQS_ADJDQSCON_BIT 16
@@ -4443,7 +4449,7 @@ static inline void __cpm_select_msc_clk(int sd)
4443#define DDRC_MMAP_BASE_BIT 8 /* base address */ 4449#define DDRC_MMAP_BASE_BIT 8 /* base address */
4444#define DDRC_MMAP_BASE_MASK (0xff << DDRC_MMAP_BASE_BIT) 4450#define DDRC_MMAP_BASE_MASK (0xff << DDRC_MMAP_BASE_BIT)
4445#define DDRC_MMAP_MASK_BIT 0 /* address mask */ 4451#define DDRC_MMAP_MASK_BIT 0 /* address mask */
4446#define DDRC_MMAP_MASK_MASK (0xff << DDRC_MMAP_MASK_BIT) 4452#define DDRC_MMAP_MASK_MASK (0xff << DDRC_MMAP_MASK_BIT)
4447 4453
4448#define DDRC_MMAP0_BASE (0x20 << DDRC_MMAP_BASE_BIT) 4454#define DDRC_MMAP0_BASE (0x20 << DDRC_MMAP_BASE_BIT)
4449#define DDRC_MMAP1_BASE_64M (0x24 << DDRC_MMAP_BASE_BIT) /*when bank0 is 128M*/ 4455#define DDRC_MMAP1_BASE_64M (0x24 << DDRC_MMAP_BASE_BIT) /*when bank0 is 128M*/
@@ -4609,8 +4615,8 @@ static inline void __cpm_select_msc_clk(int sd)
4609 * EMC (External Memory Controller) 4615 * EMC (External Memory Controller)
4610 *************************************************************************/ 4616 *************************************************************************/
4611#define EMC_BCR (EMC_BASE + 0x00) /* Bus Control Register */ 4617#define EMC_BCR (EMC_BASE + 0x00) /* Bus Control Register */
4612#define EMC_PMEMBS1 (EMC_BASE + 0x6004) 4618#define EMC_PMEMBS1 (EMC_BASE + 0x6004)
4613#define EMC_PMEMBS0 (EMC_BASE + 0x6008) 4619#define EMC_PMEMBS0 (EMC_BASE + 0x6008)
4614#define EMC_SMCR0 (EMC_BASE + 0x10) /* Static Memory Control Register 0 ??? */ 4620#define EMC_SMCR0 (EMC_BASE + 0x10) /* Static Memory Control Register 0 ??? */
4615#define EMC_SMCR1 (EMC_BASE + 0x14) /* Static Memory Control Register 1 */ 4621#define EMC_SMCR1 (EMC_BASE + 0x14) /* Static Memory Control Register 1 */
4616#define EMC_SMCR2 (EMC_BASE + 0x18) /* Static Memory Control Register 2 */ 4622#define EMC_SMCR2 (EMC_BASE + 0x18) /* Static Memory Control Register 2 */
@@ -4874,7 +4880,7 @@ static inline void __cpm_select_msc_clk(int sd)
4874 4880
4875#define I2C_CTRL_STPHLD (1 << 7) /* Stop Hold Enable bit: when tx fifo empty, 0: send stop 1: never send stop*/ 4881#define I2C_CTRL_STPHLD (1 << 7) /* Stop Hold Enable bit: when tx fifo empty, 0: send stop 1: never send stop*/
4876#define I2C_CTRL_SLVDIS (1 << 6) /* after reset slave is disabled*/ 4882#define I2C_CTRL_SLVDIS (1 << 6) /* after reset slave is disabled*/
4877#define I2C_CTRL_REST (1 << 5) 4883#define I2C_CTRL_REST (1 << 5)
4878#define I2C_CTRL_MATP (1 << 4) /* 1: 10bit address 0: 7bit addressing*/ 4884#define I2C_CTRL_MATP (1 << 4) /* 1: 10bit address 0: 7bit addressing*/
4879#define I2C_CTRL_SATP (1 << 3) /* 1: 10bit address 0: 7bit address*/ 4885#define I2C_CTRL_SATP (1 << 3) /* 1: 10bit address 0: 7bit address*/
4880#define I2C_CTRL_SPDF (2 << 1) /* fast mode 400kbps */ 4886#define I2C_CTRL_SPDF (2 << 1) /* fast mode 400kbps */
@@ -4906,7 +4912,7 @@ static inline void __cpm_select_msc_clk(int sd)
4906#define I2C_INTST_ISTP (1 << 9) 4912#define I2C_INTST_ISTP (1 << 9)
4907#define I2C_INTST_IACT (1 << 8) 4913#define I2C_INTST_IACT (1 << 8)
4908#define I2C_INTST_RXDN (1 << 7) 4914#define I2C_INTST_RXDN (1 << 7)
4909#define I2C_INTST_TXABT (1 << 6) 4915#define I2C_INTST_TXABT (1 << 6)
4910#define I2C_INTST_RDREQ (1 << 5) 4916#define I2C_INTST_RDREQ (1 << 5)
4911#define I2C_INTST_TXEMP (1 << 4) 4917#define I2C_INTST_TXEMP (1 << 4)
4912#define I2C_INTST_TXOF (1 << 3) 4918#define I2C_INTST_TXOF (1 << 3)
@@ -4944,7 +4950,7 @@ static inline void __cpm_select_msc_clk(int sd)
4944 4950
4945/* I2C Enable (I2C_ENB) */ 4951/* I2C Enable (I2C_ENB) */
4946 4952
4947#define I2C_ENB_I2CENB (1 << 0) /* Enable the i2c */ 4953#define I2C_ENB_I2CENB (1 << 0) /* Enable the i2c */
4948 4954
4949/* I2C Status Register (I2C_STA) */ 4955/* I2C Status Register (I2C_STA) */
4950 4956
@@ -4992,8 +4998,8 @@ static inline void __cpm_select_msc_clk(int sd)
4992#define I2C_ENSTA_SLVRDLST (1 << 2) 4998#define I2C_ENSTA_SLVRDLST (1 << 2)
4993#define I2C_ENSTA_SLVDISB (1 << 1) 4999#define I2C_ENSTA_SLVDISB (1 << 1)
4994#define I2C_ENSTA_I2CEN (1 << 0) /* when read as 1, i2c is deemed to be in an enabled state 5000#define I2C_ENSTA_I2CEN (1 << 0) /* when read as 1, i2c is deemed to be in an enabled state
4995 when read as 0, i2c is deemed completely inactive. The cpu can 5001 when read as 0, i2c is deemed completely inactive. The cpu can
4996 safely read this bit anytime .When this bit is read as 0 ,the cpu can 5002 safely read this bit anytime .When this bit is read as 0 ,the cpu can
4997 safely read SLVRDLST and SLVDISB */ 5003 safely read SLVRDLST and SLVDISB */
4998 5004
4999/* I2C standard mode high count register(I2CSHCNT) */ 5005/* I2C standard mode high count register(I2CSHCNT) */
@@ -5036,7 +5042,7 @@ static inline void __cpm_select_msc_clk(int sd)
5036#define __i2c_nsend_stop(n) SETREG8(I2C_CTRL(n), I2C_CTRL_STPHLD) 5042#define __i2c_nsend_stop(n) SETREG8(I2C_CTRL(n), I2C_CTRL_STPHLD)
5037 5043
5038#define __i2c_set_dma_td_level(n,data) OUTREG8(I2C_DMATDLR(n),data) 5044#define __i2c_set_dma_td_level(n,data) OUTREG8(I2C_DMATDLR(n),data)
5039#define __i2c_set_dma_rd_level(n,data) OUTREG8(I2C_DMARDLR(n),data) 5045#define __i2c_set_dma_rd_level(n,data) OUTREG8(I2C_DMARDLR(n),data)
5040 5046
5041/* 5047/*
5042#define __i2c_set_clk(dev_clk, i2c_clk) \ 5048#define __i2c_set_clk(dev_clk, i2c_clk) \
@@ -5498,9 +5504,9 @@ do { \
5498#define REG_LCD_SIZE0 REG32(LCD_SIZE0) 5504#define REG_LCD_SIZE0 REG32(LCD_SIZE0)
5499#define REG_LCD_SIZE0_PART2 REG32(LCD_SIZE0_PART2) 5505#define REG_LCD_SIZE0_PART2 REG32(LCD_SIZE0_PART2)
5500#define REG_LCD_SIZE1 REG32(LCD_SIZE1) 5506#define REG_LCD_SIZE1 REG32(LCD_SIZE1)
5501 5507
5502#define REG_LCD_RGBC REG16(LCD_RGBC) 5508#define REG_LCD_RGBC REG16(LCD_RGBC)
5503 5509
5504#define REG_LCD_VSYNC REG32(LCD_VSYNC) 5510#define REG_LCD_VSYNC REG32(LCD_VSYNC)
5505#define REG_LCD_HSYNC REG32(LCD_HSYNC) 5511#define REG_LCD_HSYNC REG32(LCD_HSYNC)
5506#define REG_LCD_PS REG32(LCD_PS) 5512#define REG_LCD_PS REG32(LCD_PS)
@@ -5946,8 +5952,8 @@ do { \
5946 5952
5947#define __lcd_set_24_tftpnl() ( REG_LCD_CFG |= LCD_CFG_MODE_TFT_24BIT ) 5953#define __lcd_set_24_tftpnl() ( REG_LCD_CFG |= LCD_CFG_MODE_TFT_24BIT )
5948 5954
5949/* 5955/*
5950 * n=1,2,4,8 for single mono-STN 5956 * n=1,2,4,8 for single mono-STN
5951 * n=4,8 for dual mono-STN 5957 * n=4,8 for dual mono-STN
5952 */ 5958 */
5953#define __lcd_set_panel_datawidth(n) \ 5959#define __lcd_set_panel_datawidth(n) \
@@ -6706,12 +6712,12 @@ static __inline__ int __mdmac_get_irq(void)
6706#define MSC_CMDAT_SEND_AS_STOP (1 << 16) 6712#define MSC_CMDAT_SEND_AS_STOP (1 << 16)
6707#define MSC_CMDAT_RTRG_BIT 14 6713#define MSC_CMDAT_RTRG_BIT 14
6708#define MSC_CMDAT_RTRG_EQUALT_8 (0x0 << MSC_CMDAT_RTRG_BIT) /*reset value*/ 6714#define MSC_CMDAT_RTRG_EQUALT_8 (0x0 << MSC_CMDAT_RTRG_BIT) /*reset value*/
6709 #define MSC_CMDAT_RTRG_EQUALT_16 (0x1 << MSC_CMDAT_RTRG_BIT) 6715 #define MSC_CMDAT_RTRG_EQUALT_16 (0x1 << MSC_CMDAT_RTRG_BIT)
6710 #define MSC_CMDAT_RTRG_EQUALT_24 (0x2 << MSC_CMDAT_RTRG_BIT) 6716 #define MSC_CMDAT_RTRG_EQUALT_24 (0x2 << MSC_CMDAT_RTRG_BIT)
6711 6717
6712#define MSC_CMDAT_TTRG_BIT 12 6718#define MSC_CMDAT_TTRG_BIT 12
6713#define MSC_CMDAT_TTRG_LESS_8 (0x0 << MSC_CMDAT_TTRG_BIT) /*reset value*/ 6719#define MSC_CMDAT_TTRG_LESS_8 (0x0 << MSC_CMDAT_TTRG_BIT) /*reset value*/
6714 #define MSC_CMDAT_TTRG_LESS_16 (0x1 << MSC_CMDAT_TTRG_BIT) 6720 #define MSC_CMDAT_TTRG_LESS_16 (0x1 << MSC_CMDAT_TTRG_BIT)
6715 #define MSC_CMDAT_TTRG_LESS_24 (0x2 << MSC_CMDAT_TTRG_BIT) 6721 #define MSC_CMDAT_TTRG_LESS_24 (0x2 << MSC_CMDAT_TTRG_BIT)
6716#define MSC_CMDAT_STOP_ABORT (1 << 11) 6722#define MSC_CMDAT_STOP_ABORT (1 << 11)
6717#define MSC_CMDAT_BUS_WIDTH_BIT 9 6723#define MSC_CMDAT_BUS_WIDTH_BIT 9
@@ -7487,7 +7493,7 @@ do { \
7487#define WENR_WENPAT_WRITABLE (0xa55a) 7493#define WENR_WENPAT_WRITABLE (0xa55a)
7488 7494
7489/* Hibernate scratch pattern register(HSPR) */ 7495/* Hibernate scratch pattern register(HSPR) */
7490#define HSPR_RTCV 0x52544356 /* The value is 'RTCV', means rtc is valid */ 7496#define HSPR_RTCV 0x52544356 /* The value is 'RTCV', means rtc is valid */
7491 7497
7492#ifndef __MIPS_ASSEMBLER 7498#ifndef __MIPS_ASSEMBLER
7493 7499
@@ -7926,7 +7932,7 @@ do { \
7926 #define SSI_CR1_FMAT_MW1 (2 << SSI_CR1_FMAT_BIT) /* National Microwire 1 format */ 7932 #define SSI_CR1_FMAT_MW1 (2 << SSI_CR1_FMAT_BIT) /* National Microwire 1 format */
7927 #define SSI_CR1_FMAT_MW2 (3 << SSI_CR1_FMAT_BIT) /* National Microwire 2 format */ 7933 #define SSI_CR1_FMAT_MW2 (3 << SSI_CR1_FMAT_BIT) /* National Microwire 2 format */
7928#define SSI_CR1_TTRG_BIT 16 /* SSI1 TX trigger */ 7934#define SSI_CR1_TTRG_BIT 16 /* SSI1 TX trigger */
7929#define SSI_CR1_TTRG_MASK (0xf << SSI_CR1_TTRG_BIT) 7935#define SSI_CR1_TTRG_MASK (0xf << SSI_CR1_TTRG_BIT)
7930#define SSI_CR1_MCOM_BIT 12 7936#define SSI_CR1_MCOM_BIT 12
7931#define SSI_CR1_MCOM_MASK (0xf << SSI_CR1_MCOM_BIT) 7937#define SSI_CR1_MCOM_MASK (0xf << SSI_CR1_MCOM_BIT)
7932 #define SSI_CR1_MCOM_1BIT (0x0 << SSI_CR1_MCOM_BIT) /* 1-bit command selected */ 7938 #define SSI_CR1_MCOM_1BIT (0x0 << SSI_CR1_MCOM_BIT) /* 1-bit command selected */
@@ -8112,7 +8118,7 @@ do { \
8112/* frmhl,endian,mcom,flen,pha,pol MASK */ 8118/* frmhl,endian,mcom,flen,pha,pol MASK */
8113#define SSICR1_MISC_MASK \ 8119#define SSICR1_MISC_MASK \
8114 ( SSI_CR1_FRMHL_MASK | SSI_CR1_LFST | SSI_CR1_MCOM_MASK \ 8120 ( SSI_CR1_FRMHL_MASK | SSI_CR1_LFST | SSI_CR1_MCOM_MASK \
8115 | SSI_CR1_FLEN_MASK | SSI_CR1_PHA | SSI_CR1_POL ) 8121 | SSI_CR1_FLEN_MASK | SSI_CR1_PHA | SSI_CR1_POL )
8116 8122
8117#define __ssi_spi_set_misc(n,frmhl,endian,flen,mcom,pha,pol) \ 8123#define __ssi_spi_set_misc(n,frmhl,endian,flen,mcom,pha,pol) \
8118 do { \ 8124 do { \
@@ -8127,7 +8133,7 @@ do { \
8127#define __ssi_set_lsb(n) ( REG_SSI_CR1(n) |= SSI_CR1_LFST ) 8133#define __ssi_set_lsb(n) ( REG_SSI_CR1(n) |= SSI_CR1_LFST )
8128 8134
8129#define __ssi_set_frame_length(n, m) \ 8135#define __ssi_set_frame_length(n, m) \
8130 REG_SSI_CR1(n) = (REG_SSI_CR1(n) & ~SSI_CR1_FLEN_MASK) | (((m) - 2) << 4) 8136 REG_SSI_CR1(n) = (REG_SSI_CR1(n) & ~SSI_CR1_FLEN_MASK) | (((m) - 2) << 4)
8131 8137
8132/* m = 1 - 16 */ 8138/* m = 1 - 16 */
8133#define __ssi_set_microwire_command_length(n,m) \ 8139#define __ssi_set_microwire_command_length(n,m) \
@@ -8510,7 +8516,7 @@ do { \
8510#define TSSI_DCMD ( TSSI0_BASE + 0x6c ) 8516#define TSSI_DCMD ( TSSI0_BASE + 0x6c )
8511#define TSSI_DST ( TSSI0_BASE + 0x70 ) 8517#define TSSI_DST ( TSSI0_BASE + 0x70 )
8512#define TSSI_TC ( TSSI0_BASE + 0x74 ) 8518#define TSSI_TC ( TSSI0_BASE + 0x74 )
8513 8519
8514#define REG_TSSI_ENA REG8( TSSI_ENA ) 8520#define REG_TSSI_ENA REG8( TSSI_ENA )
8515#define REG_TSSI_CFG REG16( TSSI_CFG ) 8521#define REG_TSSI_CFG REG16( TSSI_CFG )
8516#define REG_TSSI_CTRL REG8( TSSI_CTRL ) 8522#define REG_TSSI_CTRL REG8( TSSI_CTRL )
@@ -8559,7 +8565,7 @@ do { \
8559 8565
8560/* mode of adding data 0 select bit */ 8566/* mode of adding data 0 select bit */
8561#define TSSI_CFG_TRANS_MD_BIT 10 8567#define TSSI_CFG_TRANS_MD_BIT 10
8562#define TSSI_CFG_TRANS_MD_MASK ( 0x3 << TSSI_CFG_TRANS_MD_BIT) 8568#define TSSI_CFG_TRANS_MD_MASK ( 0x3 << TSSI_CFG_TRANS_MD_BIT)
8563#define TSSI_CFG_TRANS_MD_0 (0 << TSSI_CFG_TRANS_MD_BIT) 8569#define TSSI_CFG_TRANS_MD_0 (0 << TSSI_CFG_TRANS_MD_BIT)
8564#define TSSI_CFG_TRANS_MD_1 (1 << TSSI_CFG_TRANS_MD_BIT) 8570#define TSSI_CFG_TRANS_MD_1 (1 << TSSI_CFG_TRANS_MD_BIT)
8565#define TSSI_CFG_TRANS_MD_2 (2 << TSSI_CFG_TRANS_MD_BIT) 8571#define TSSI_CFG_TRANS_MD_2 (2 << TSSI_CFG_TRANS_MD_BIT)
@@ -8592,37 +8598,37 @@ do { \
8592 8598
8593/* TSSI PID enable register */ 8599/* TSSI PID enable register */
8594#define TSSI_PEN_EN00 ( 1 << 0 ) /* enable PID n */ 8600#define TSSI_PEN_EN00 ( 1 << 0 ) /* enable PID n */
8595#define TSSI_PEN_EN10 ( 1 << 1 ) 8601#define TSSI_PEN_EN10 ( 1 << 1 )
8596#define TSSI_PEN_EN20 ( 1 << 2 ) 8602#define TSSI_PEN_EN20 ( 1 << 2 )
8597#define TSSI_PEN_EN30 ( 1 << 3 ) 8603#define TSSI_PEN_EN30 ( 1 << 3 )
8598#define TSSI_PEN_EN40 ( 1 << 4 ) 8604#define TSSI_PEN_EN40 ( 1 << 4 )
8599#define TSSI_PEN_EN50 ( 1 << 5 ) 8605#define TSSI_PEN_EN50 ( 1 << 5 )
8600#define TSSI_PEN_EN60 ( 1 << 6 ) 8606#define TSSI_PEN_EN60 ( 1 << 6 )
8601#define TSSI_PEN_EN70 ( 1 << 7 ) 8607#define TSSI_PEN_EN70 ( 1 << 7 )
8602#define TSSI_PEN_EN80 ( 1 << 8 ) 8608#define TSSI_PEN_EN80 ( 1 << 8 )
8603#define TSSI_PEN_EN90 ( 1 << 9 ) 8609#define TSSI_PEN_EN90 ( 1 << 9 )
8604#define TSSI_PEN_EN100 ( 1 << 10 ) 8610#define TSSI_PEN_EN100 ( 1 << 10 )
8605#define TSSI_PEN_EN110 ( 1 << 11 ) 8611#define TSSI_PEN_EN110 ( 1 << 11 )
8606#define TSSI_PEN_EN120 ( 1 << 12 ) 8612#define TSSI_PEN_EN120 ( 1 << 12 )
8607#define TSSI_PEN_EN130 ( 1 << 13 ) 8613#define TSSI_PEN_EN130 ( 1 << 13 )
8608#define TSSI_PEN_EN140 ( 1 << 14 ) 8614#define TSSI_PEN_EN140 ( 1 << 14 )
8609#define TSSI_PEN_EN150 ( 1 << 15 ) 8615#define TSSI_PEN_EN150 ( 1 << 15 )
8610#define TSSI_PEN_EN01 ( 1 << 16 ) 8616#define TSSI_PEN_EN01 ( 1 << 16 )
8611#define TSSI_PEN_EN11 ( 1 << 17 ) 8617#define TSSI_PEN_EN11 ( 1 << 17 )
8612#define TSSI_PEN_EN21 ( 1 << 18 ) 8618#define TSSI_PEN_EN21 ( 1 << 18 )
8613#define TSSI_PEN_EN31 ( 1 << 19 ) 8619#define TSSI_PEN_EN31 ( 1 << 19 )
8614#define TSSI_PEN_EN41 ( 1 << 20 ) 8620#define TSSI_PEN_EN41 ( 1 << 20 )
8615#define TSSI_PEN_EN51 ( 1 << 21 ) 8621#define TSSI_PEN_EN51 ( 1 << 21 )
8616#define TSSI_PEN_EN61 ( 1 << 22 ) 8622#define TSSI_PEN_EN61 ( 1 << 22 )
8617#define TSSI_PEN_EN71 ( 1 << 23 ) 8623#define TSSI_PEN_EN71 ( 1 << 23 )
8618#define TSSI_PEN_EN81 ( 1 << 24 ) 8624#define TSSI_PEN_EN81 ( 1 << 24 )
8619#define TSSI_PEN_EN91 ( 1 << 25 ) 8625#define TSSI_PEN_EN91 ( 1 << 25 )
8620#define TSSI_PEN_EN101 ( 1 << 26 ) 8626#define TSSI_PEN_EN101 ( 1 << 26 )
8621#define TSSI_PEN_EN111 ( 1 << 27 ) 8627#define TSSI_PEN_EN111 ( 1 << 27 )
8622#define TSSI_PEN_EN121 ( 1 << 28 ) 8628#define TSSI_PEN_EN121 ( 1 << 28 )
8623#define TSSI_PEN_EN131 ( 1 << 29 ) 8629#define TSSI_PEN_EN131 ( 1 << 29 )
8624#define TSSI_PEN_EN141 ( 1 << 30 ) 8630#define TSSI_PEN_EN141 ( 1 << 30 )
8625#define TSSI_PEN_EN151 ( 1 << 31 ) 8631#define TSSI_PEN_EN151 ( 1 << 31 )
8626//#define TSSI_PEN_PID0 ( 1 << 31 ) /* PID filter enable PID0 */ 8632//#define TSSI_PEN_PID0 ( 1 << 31 ) /* PID filter enable PID0 */
8627 8633
8628/* TSSI Data Number Registers */ 8634/* TSSI Data Number Registers */
@@ -8664,7 +8670,7 @@ do { \
8664/* TSSI Transfer Control Registers */ 8670/* TSSI Transfer Control Registers */
8665#define TSSI_TC_OP_BIT 4 8671#define TSSI_TC_OP_BIT 4
8666#define TSSI_TC_OP_MASK (0x3 << TSSI_TC_OP_BIT) 8672#define TSSI_TC_OP_MASK (0x3 << TSSI_TC_OP_BIT)
8667//////////////////#define TSSI_TC_OP_0 ( 8673//////////////////#define TSSI_TC_OP_0 (
8668#define TSSI_TC_OPE (1 << 2) 8674#define TSSI_TC_OPE (1 << 2)
8669#define TSSI_TC_EME (1 << 1) 8675#define TSSI_TC_EME (1 << 1)
8670#define TSSI_TC_APM (1 << 0) 8676#define TSSI_TC_APM (1 << 0)
@@ -8733,7 +8739,7 @@ do { \
8733#define __tssi_disable_ovrn_irq() ( REG_TSSI_CTRL |= TSSI_CTRL_OVRNM ) 8739#define __tssi_disable_ovrn_irq() ( REG_TSSI_CTRL |= TSSI_CTRL_OVRNM )
8734 8740
8735#define __tssi_enable_trig_irq() ( REG_TSSI_CTRL &= ~TSSI_CTRL_TRIGM ) 8741#define __tssi_enable_trig_irq() ( REG_TSSI_CTRL &= ~TSSI_CTRL_TRIGM )
8736#define __tssi_disable_trig_irq() ( REG_TSSI_CTRL |= TSSI_CTRL_TRIGM ) 8742#define __tssi_disable_trig_irq() ( REG_TSSI_CTRL |= TSSI_CTRL_TRIGM )
8737 8743
8738#define __tssi_state_is_dtr() ( REG_TSSI_STAT & TSSI_STAT_DTR ) 8744#define __tssi_state_is_dtr() ( REG_TSSI_STAT & TSSI_STAT_DTR )
8739#define __tssi_state_is_overrun() ( REG_TSSI_STAT & TSSI_STAT_OVRN ) 8745#define __tssi_state_is_overrun() ( REG_TSSI_STAT & TSSI_STAT_OVRN )
@@ -8790,7 +8796,7 @@ do { \
8790 8796
8791#endif /* __MIPS_ASSEMBLER */ 8797#endif /* __MIPS_ASSEMBLER */
8792 8798
8793#define TVE_BASE 0xB3050100 8799#define TVE_BASE 0xB3050100
8794 8800
8795/************************************************************************* 8801/*************************************************************************
8796 * TVE (TV Encoder Controller) 8802 * TVE (TV Encoder Controller)
@@ -8829,8 +8835,8 @@ do { \
8829#define TVE_CTRL_EYCBCR (1 << 25) /* YCbCr_enable */ 8835#define TVE_CTRL_EYCBCR (1 << 25) /* YCbCr_enable */
8830#define TVE_CTRL_ECVBS (1 << 24) /* 1: cvbs_enable 0: s-video*/ 8836#define TVE_CTRL_ECVBS (1 << 24) /* 1: cvbs_enable 0: s-video*/
8831#define TVE_CTRL_DAPD3 (1 << 23) /* DAC 3 power down */ 8837#define TVE_CTRL_DAPD3 (1 << 23) /* DAC 3 power down */
8832#define TVE_CTRL_DAPD2 (1 << 22) /* DAC 2 power down */ 8838#define TVE_CTRL_DAPD2 (1 << 22) /* DAC 2 power down */
8833#define TVE_CTRL_DAPD1 (1 << 21) /* DAC 1 power down */ 8839#define TVE_CTRL_DAPD1 (1 << 21) /* DAC 1 power down */
8834#define TVE_CTRL_DAPD (1 << 20) /* power down all DACs */ 8840#define TVE_CTRL_DAPD (1 << 20) /* power down all DACs */
8835#define TVE_CTRL_YCDLY_BIT 16 8841#define TVE_CTRL_YCDLY_BIT 16
8836#define TVE_CTRL_YCDLY_MASK (0x7 << TVE_CTRL_YCDLY_BIT) 8842#define TVE_CTRL_YCDLY_MASK (0x7 << TVE_CTRL_YCDLY_BIT)
@@ -9591,7 +9597,7 @@ do { \
9591#define AOSD_INT_AOSD_END (1 << 0) 9597#define AOSD_INT_AOSD_END (1 << 0)
9592 9598
9593#define __osd_enable_alpha() (REG_AOSD_CTRL |= AOSD_ALPHA_ENABLE) 9599#define __osd_enable_alpha() (REG_AOSD_CTRL |= AOSD_ALPHA_ENABLE)
9594#define __osd_alpha_start() (REG_AOSD_CTRL |= AOSD_CTRL_ALPHA_START) 9600#define __osd_alpha_start() (REG_AOSD_CTRL |= AOSD_CTRL_ALPHA_START)
9595 9601
9596/************************************************************************* 9602/*************************************************************************
9597 * COMPRESS 9603 * COMPRESS
@@ -9603,7 +9609,7 @@ do { \
9603#define COMPRESS_CTRL (AOSD_BASE + 0x3C) 9609#define COMPRESS_CTRL (AOSD_BASE + 0x3C)
9604#define COMPRESS_RATIO (AOSD_BASE + 0x40) 9610#define COMPRESS_RATIO (AOSD_BASE + 0x40)
9605#define COMPRESS_SRC_OFFSET (AOSD_BASE + 0x44) 9611#define COMPRESS_SRC_OFFSET (AOSD_BASE + 0x44)
9606 9612
9607#define REG_COMPRESS_SCR_ADDR REG32(COMPRESS_SCR_ADDR) 9613#define REG_COMPRESS_SCR_ADDR REG32(COMPRESS_SCR_ADDR)
9608#define REG_COMPRESS_DES_ADDR REG32(COMPRESS_DES_ADDR) 9614#define REG_COMPRESS_DES_ADDR REG32(COMPRESS_DES_ADDR)
9609#define REG_COMPRESS_DST_OFFSET REG32(COMPRESS_DST_OFFSET) 9615#define REG_COMPRESS_DST_OFFSET REG32(COMPRESS_DST_OFFSET)
@@ -9627,9 +9633,9 @@ do { \
9627#define COMPRESS_CTRL_ALIGNED_16_WORD (0 << COMPRESS_CTRL_ALIGNED_MODE_BIT) 9633#define COMPRESS_CTRL_ALIGNED_16_WORD (0 << COMPRESS_CTRL_ALIGNED_MODE_BIT)
9628#define COMPRESS_CTRL_ALIGNED_64_WORD (1 << COMPRESS_CTRL_ALIGNED_MODE_BIT) 9634#define COMPRESS_CTRL_ALIGNED_64_WORD (1 << COMPRESS_CTRL_ALIGNED_MODE_BIT)
9629 9635
9630#define __compress_enable() (REG_COMPRESS_CTRL |= COMPRESS_INT_AOSD_END) 9636#define __compress_enable() (REG_COMPRESS_CTRL |= COMPRESS_INT_AOSD_END)
9631#define __compress_start() (REG_COMPRESS_CTRL |= COMPRESS_CTRL_COMP_START) 9637#define __compress_start() (REG_COMPRESS_CTRL |= COMPRESS_CTRL_COMP_START)
9632#define __compress_with_alpha() (REG_COMPRESS_CTRL |= COMPRESS_CTRL_ALPHA_EN) 9638#define __compress_with_alpha() (REG_COMPRESS_CTRL |= COMPRESS_CTRL_ALPHA_EN)
9633 9639
9634/* Rockbox defines */ 9640/* Rockbox defines */
9635 9641
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;
38static tCardInfo card; 38static tCardInfo card;
39 39
40static struct mutex sd_mtx; 40static struct mutex sd_mtx;
41static struct semaphore sd_wakeup; 41//static struct semaphore sd_wakeup;
42 42
43static int use_4bit; 43static int use_4bit;
44static int num_6; 44static int num_6;
@@ -1218,7 +1218,7 @@ int sd_init(void)
1218 static bool inited = false; 1218 static bool inited = false;
1219 if(!inited) 1219 if(!inited)
1220 { 1220 {
1221 semaphore_init(&sd_wakeup, 1, 0); 1221// semaphore_init(&sd_wakeup, 1, 0);
1222 mutex_init(&sd_mtx); 1222 mutex_init(&sd_mtx);
1223 inited = true; 1223 inited = true;
1224 } 1224 }
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;
34static tCardInfo card[NUM_DRIVES]; 34static tCardInfo card[NUM_DRIVES];
35 35
36static struct mutex sd_mtx; 36static struct mutex sd_mtx;
37static struct semaphore sd_wakeup; 37//static struct semaphore sd_wakeup;
38 38
39static int use_4bit[NUM_DRIVES]; 39static int use_4bit[NUM_DRIVES];
40static int num_6[NUM_DRIVES]; 40static int num_6[NUM_DRIVES];
@@ -1229,7 +1229,7 @@ int sd_init(void)
1229 1229
1230 if(!inited) 1230 if(!inited)
1231 { 1231 {
1232 semaphore_init(&sd_wakeup, 1, 0); 1232// semaphore_init(&sd_wakeup, 1, 0);
1233 mutex_init(&sd_mtx); 1233 mutex_init(&sd_mtx);
1234 inited = true; 1234 inited = true;
1235 } 1235 }
@@ -1457,6 +1457,7 @@ bool sd_present(const int drive)
1457#ifdef CONFIG_STORAGE_MULTI 1457#ifdef CONFIG_STORAGE_MULTI
1458int sd_num_drives(int first_drive) 1458int sd_num_drives(int first_drive)
1459{ 1459{
1460 (void)first_drive;
1460 return NUM_DRIVES; 1461 return NUM_DRIVES;
1461} 1462}
1462#endif /* CONFIG_STORAGE_MULTI */ 1463#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 @@
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 */ 32static int line = 0;
34 33
35void 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; 40static void display_clocks(void)
46}
47
48void 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
55void serial_putsf(const char *format, ...) 88static 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",
71void 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",
89void 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
109void 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
136bool dbg_ports(void) 137bool dbg_ports(void)
137{ 138{
138 serial_puts("dbg_ports\n");
139 return false; 139 return false;
140} 140}
141 141
142bool dbg_hw_info(void) 142bool 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}
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)
57 cmd_flag = -1; 57 cmd_flag = -1;
58 __i2c_clear_interrupts(ret,I2C_CHN); 58 __i2c_clear_interrupts(ret,I2C_CHN);
59 REG_I2C_INTM(I2C_CHN) = 0x0; 59 REG_I2C_INTM(I2C_CHN) = 0x0;
60 (void)ret;
60 return; 61 return;
61 } 62 }
62 63
@@ -83,7 +84,7 @@ void I2C1(void)
83 } 84 }
84 85
85 cmd_cnt--; 86 cmd_cnt--;
86 87
87 if (!(cmd_cnt)) { 88 if (!(cmd_cnt)) {
88 REG_I2C_INTM(I2C_CHN) = 0x0; 89 REG_I2C_INTM(I2C_CHN) = 0x0;
89 cmd_flag = 2; 90 cmd_flag = 2;
@@ -198,9 +199,9 @@ int xfer_read_subaddr(unsigned char subaddr, unsigned char device, unsigned char
198 i2c_rwflags = I2C_M_RD; 199 i2c_rwflags = I2C_M_RD;
199 i2c_ctrl_rest = I2C_CTRL_REST; 200 i2c_ctrl_rest = I2C_CTRL_REST;
200 i2c_init_as_master(device); 201 i2c_init_as_master(device);
201 202
202 REG_I2C_DC(I2C_CHN) = (I2C_WRITE << 8) | subaddr; 203 REG_I2C_DC(I2C_CHN) = (I2C_WRITE << 8) | subaddr;
203 204
204 cmd_flag = 0; 205 cmd_flag = 0;
205 REG_I2C_INTM(I2C_CHN) = 0x10; 206 REG_I2C_INTM(I2C_CHN) = 0x10;
206 timeout = TIMEOUT; 207 timeout = TIMEOUT;
@@ -224,6 +225,7 @@ int xfer_read_subaddr(unsigned char subaddr, unsigned char device, unsigned char
224 int ret; 225 int ret;
225 r_i = 2; 226 r_i = 2;
226 __i2c_clear_interrupts(ret,I2C_CHN); 227 __i2c_clear_interrupts(ret,I2C_CHN);
228 (void)ret;
227 goto R_dev_err; 229 goto R_dev_err;
228 } 230 }
229 } 231 }
@@ -269,14 +271,14 @@ int xfer_write_subaddr(unsigned char subaddr, unsigned char device, const unsign
269 i2c_rwflags = I2C_M_WR; 271 i2c_rwflags = I2C_M_WR;
270 i2c_ctrl_rest = I2C_CTRL_REST; 272 i2c_ctrl_rest = I2C_CTRL_REST;
271 i2c_init_as_master(device); 273 i2c_init_as_master(device);
272 274
273 REG_I2C_DC(I2C_CHN) = (I2C_WRITE << 8) | subaddr; 275 REG_I2C_DC(I2C_CHN) = (I2C_WRITE << 8) | subaddr;
274 276
275 cmd_flag = 0; 277 cmd_flag = 0;
276 REG_I2C_INTM(I2C_CHN) = 0x10; 278 REG_I2C_INTM(I2C_CHN) = 0x10;
277 279
278 timeout = TIMEOUT; 280 timeout = TIMEOUT;
279 while ((cmd_flag != 2) && (--timeout)) 281 while ((cmd_flag != 2) && (--timeout))
280 { 282 {
281 if (cmd_flag == -1){ 283 if (cmd_flag == -1){
282 w_i = 1; 284 w_i = 1;
@@ -308,6 +310,7 @@ int xfer_write_subaddr(unsigned char subaddr, unsigned char device, const unsign
308 int ret; 310 int ret;
309 w_i = 5; 311 w_i = 5;
310 __i2c_clear_interrupts(ret,I2C_CHN); 312 __i2c_clear_interrupts(ret,I2C_CHN);
313 (void)ret;
311 goto W_dev_err; 314 goto W_dev_err;
312 } 315 }
313 316