summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-12-20 01:48:46 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-12-20 01:48:46 +0000
commitc983e3b1d25503e71d0d7cba7c921b16c216770b (patch)
treee0c0b53295106e144be44f93817c961d57e41174
parent0301ed559451ba4561b21e438d29b9ee29e31353 (diff)
downloadrockbox-c983e3b1d25503e71d0d7cba7c921b16c216770b.tar.gz
rockbox-c983e3b1d25503e71d0d7cba7c921b16c216770b.zip
Ingenic targets:
* LCD rework * Dynamic DMA enabling * PCM cleanup * USB: replace printf() with logf() * System: get rid of in_interrupt_mode() * Backlight: add support for software PWM git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19495 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/export/jz4740.h3
-rw-r--r--firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c8
-rw-r--r--firmware/target/mips/ingenic_jz47xx/kernel-jz4740.c18
-rw-r--r--firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c91
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c100
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h1
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c6
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/pcm-jz4740.c41
-rw-r--r--firmware/target/mips/ingenic_jz47xx/system-jz4740.c104
-rw-r--r--firmware/target/mips/ingenic_jz47xx/system-target.h5
-rw-r--r--firmware/target/mips/ingenic_jz47xx/usb-jz4740.c40
12 files changed, 253 insertions, 166 deletions
diff --git a/firmware/export/jz4740.h b/firmware/export/jz4740.h
index 505248a67a..afd10cef57 100644
--- a/firmware/export/jz4740.h
+++ b/firmware/export/jz4740.h
@@ -3025,7 +3025,8 @@ do { \
3025/* 3025/*
3026 * n = 0 ~ 7 3026 * n = 0 ~ 7
3027 */ 3027 */
3028#define __gpio_as_pwm(n) __gpio_as_pwm##n() 3028#define ___gpio_as_pwm(n) __gpio_as_pwm ## n()
3029#define __gpio_as_pwm(n) ___gpio_as_pwm(n)
3029 3030
3030//------------------------------------------- 3031//-------------------------------------------
3031// GPIO or Interrupt Mode 3032// GPIO or Interrupt Mode
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c
index 979a9067d3..a4b4a86a55 100644
--- a/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/ata-nand-jz4740.c
@@ -138,6 +138,8 @@ static void jz_nand_write_dma(void *source, unsigned int len, int bw)
138 138
139 if(((unsigned int)source < 0xa0000000) && len) 139 if(((unsigned int)source < 0xa0000000) && len)
140 dma_cache_wback_inv((unsigned long)source, len); 140 dma_cache_wback_inv((unsigned long)source, len);
141
142 dma_enable();
141 143
142 REG_DMAC_DCCSR(DMA_NAND_CHANNEL) = 0; 144 REG_DMAC_DCCSR(DMA_NAND_CHANNEL) = 0;
143 REG_DMAC_DSAR(DMA_NAND_CHANNEL) = PHYSADDR((unsigned long)source); 145 REG_DMAC_DSAR(DMA_NAND_CHANNEL) = PHYSADDR((unsigned long)source);
@@ -151,6 +153,8 @@ static void jz_nand_write_dma(void *source, unsigned int len, int bw)
151 while( REG_DMAC_DTCR(DMA_NAND_CHANNEL) ) 153 while( REG_DMAC_DTCR(DMA_NAND_CHANNEL) )
152 yield(); 154 yield();
153 155
156 dma_disable();
157
154 mutex_unlock(&nand_mtx); 158 mutex_unlock(&nand_mtx);
155} 159}
156 160
@@ -161,6 +165,8 @@ static void jz_nand_read_dma(void *target, unsigned int len, int bw)
161 if(((unsigned int)target < 0xa0000000) && len) 165 if(((unsigned int)target < 0xa0000000) && len)
162 dma_cache_wback_inv((unsigned long)target, len); 166 dma_cache_wback_inv((unsigned long)target, len);
163 167
168 dma_enable();
169
164 REG_DMAC_DCCSR(DMA_NAND_CHANNEL) = 0; 170 REG_DMAC_DCCSR(DMA_NAND_CHANNEL) = 0;
165 REG_DMAC_DSAR(DMA_NAND_CHANNEL) = PHYSADDR((unsigned long)NAND_DATAPORT); 171 REG_DMAC_DSAR(DMA_NAND_CHANNEL) = PHYSADDR((unsigned long)NAND_DATAPORT);
166 REG_DMAC_DTAR(DMA_NAND_CHANNEL) = PHYSADDR((unsigned long)target); 172 REG_DMAC_DTAR(DMA_NAND_CHANNEL) = PHYSADDR((unsigned long)target);
@@ -172,6 +178,8 @@ static void jz_nand_read_dma(void *target, unsigned int len, int bw)
172 while( REG_DMAC_DTCR(DMA_NAND_CHANNEL) ) 178 while( REG_DMAC_DTCR(DMA_NAND_CHANNEL) )
173 yield(); 179 yield();
174 180
181 dma_disable();
182
175 mutex_unlock(&nand_mtx); 183 mutex_unlock(&nand_mtx);
176} 184}
177 185
diff --git a/firmware/target/mips/ingenic_jz47xx/kernel-jz4740.c b/firmware/target/mips/ingenic_jz47xx/kernel-jz4740.c
index dcfdfd6a38..431af490da 100644
--- a/firmware/target/mips/ingenic_jz47xx/kernel-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/kernel-jz4740.c
@@ -24,38 +24,26 @@
24#include "kernel.h" 24#include "kernel.h"
25#include "jz4740.h" 25#include "jz4740.h"
26 26
27#define USE_RTC_CLOCK 0
28void tick_start(unsigned int interval_in_ms) 27void tick_start(unsigned int interval_in_ms)
29{ 28{
30 unsigned int tps = interval_in_ms;
31 unsigned int latch; 29 unsigned int latch;
30
32 __cpm_start_tcu(); 31 __cpm_start_tcu();
33 32
34 __tcu_stop_counter(0); 33 __tcu_stop_counter(0);
35 __tcu_disable_pwm_output(0); 34 __tcu_disable_pwm_output(0);
36 __tcu_stop_counter(1);
37 __tcu_disable_pwm_output(1);
38 __tcu_stop_counter(2);
39 __tcu_disable_pwm_output(2);
40 __tcu_clear_full_match_flag(2);
41 35
42 __tcu_mask_half_match_irq(0); 36 __tcu_mask_half_match_irq(0);
43 __tcu_unmask_full_match_irq(0); 37 __tcu_unmask_full_match_irq(0);
44 38
45#if USE_RTC_CLOCK
46 __tcu_select_rtcclk(0);
47 __tcu_select_clk_div1(0);
48 latch = (__cpm_get_rtcclk() + (tps>>1)) / tps;
49#else
50 __tcu_select_extalclk(0); 39 __tcu_select_extalclk(0);
51 __tcu_select_clk_div4(0); 40 __tcu_select_clk_div4(0);
52 41
53 latch = (JZ_EXTAL / 4 + (tps>>1)) / tps; 42 latch = (JZ_EXTAL / 4 + (interval_in_ms>>1)) / interval_in_ms;
54#endif 43
55 REG_TCU_TCNT(0) = 0; 44 REG_TCU_TCNT(0) = 0;
56 REG_TCU_TDFR(0) = latch; 45 REG_TCU_TDFR(0) = latch;
57 REG_TCU_TDHR(0) = latch; 46 REG_TCU_TDHR(0) = latch;
58 //REG_TCU_TDHR(0) = 0;
59 47
60 __tcu_clear_full_match_flag(0); 48 __tcu_clear_full_match_flag(0);
61 __tcu_start_counter(0); 49 __tcu_start_counter(0);
diff --git a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c
index 1401bf8a3f..996731c0cd 100644
--- a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c
@@ -25,9 +25,16 @@
25#include "lcd-target.h" 25#include "lcd-target.h"
26#include "system.h" 26#include "system.h"
27#include "kernel.h" 27#include "kernel.h"
28#include "backlight-target.h"
29
30/*
31 Warning: code behaviour is unpredictable when threads get switched in IRQ mode!
32 So don't update the LCD in an interrupt handler!
33 */
28 34
29static volatile bool lcd_is_on = false; 35static volatile bool lcd_is_on = false;
30static struct mutex lcd_mtx; 36static struct mutex lcd_mtx;
37static struct wakeup lcd_wkup;
31 38
32/* LCD init */ 39/* LCD init */
33void lcd_init_device(void) 40void lcd_init_device(void)
@@ -35,6 +42,8 @@ void lcd_init_device(void)
35 lcd_init_controller(); 42 lcd_init_controller();
36 lcd_is_on = true; 43 lcd_is_on = true;
37 mutex_init(&lcd_mtx); 44 mutex_init(&lcd_mtx);
45 wakeup_init(&lcd_wkup);
46 system_enable_irq(DMA_IRQ(DMA_LCD_CHANNEL));
38} 47}
39 48
40void lcd_enable(bool state) 49void lcd_enable(bool state)
@@ -55,73 +64,75 @@ bool lcd_enabled(void)
55 return lcd_is_on; 64 return lcd_is_on;
56} 65}
57 66
58/* Don't switch threads when in interrupt mode! */
59static inline void lcd_lock(void)
60{
61 if(LIKELY(!in_interrupt_mode()))
62 mutex_lock(&lcd_mtx);
63 else
64 while( !(REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_TT));
65}
66
67static inline void lcd_unlock(void)
68{
69 if(LIKELY(!in_interrupt_mode()))
70 mutex_unlock(&lcd_mtx);
71}
72
73static inline void lcd_wait(void)
74{
75 if(LIKELY(!in_interrupt_mode()))
76 {
77 while( !(REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_TT) )
78 yield();
79 }
80 else
81 while( !(REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_TT));
82}
83
84/* Update a fraction of the display. */ 67/* Update a fraction of the display. */
85void lcd_update_rect(int x, int y, int width, int height) 68void lcd_update_rect(int x, int y, int width, int height)
86{ 69{
87 lcd_lock(); 70#if 1
71 /* This is an ugly HACK until partial LCD drawing works.. */
72 width = LCD_WIDTH;
73 height = LCD_HEIGHT;
74 x = 0;
75 y = 0;
76#endif
77
78 mutex_lock(&lcd_mtx);
88 79
89 lcd_set_target(x, y, width, height); 80 lcd_set_target(x, y, width, height);
90 81
91 REG_DMAC_DCCSR(DMA_LCD_CHANNEL) = 0; 82 dma_enable();
83
84 REG_DMAC_DCCSR(DMA_LCD_CHANNEL) = DMAC_DCCSR_NDES;
92 REG_DMAC_DRSR(DMA_LCD_CHANNEL) = DMAC_DRSR_RS_SLCD; /* source = SLCD */ 85 REG_DMAC_DRSR(DMA_LCD_CHANNEL) = DMAC_DRSR_RS_SLCD; /* source = SLCD */
93 REG_DMAC_DSAR(DMA_LCD_CHANNEL) = ((unsigned int)&lcd_framebuffer[y][x]) & 0x1FFFFFFF; 86 REG_DMAC_DSAR(DMA_LCD_CHANNEL) = PHYSADDR((unsigned long)&lcd_framebuffer[y][x]);
94 REG_DMAC_DTAR(DMA_LCD_CHANNEL) = 0x130500B0; /* SLCD_FIFO */ 87 REG_DMAC_DTAR(DMA_LCD_CHANNEL) = PHYSADDR(SLCD_FIFO);
95 REG_DMAC_DTCR(DMA_LCD_CHANNEL) = width*height; 88 REG_DMAC_DTCR(DMA_LCD_CHANNEL) = width*height;
96 89
97 REG_DMAC_DCMD(DMA_LCD_CHANNEL) = ( DMAC_DCMD_SAI | DMAC_DCMD_RDIL_IGN | DMAC_DCMD_SWDH_32 90 REG_DMAC_DCMD(DMA_LCD_CHANNEL) = ( DMAC_DCMD_SAI | DMAC_DCMD_RDIL_IGN | DMAC_DCMD_SWDH_32
98 | DMAC_DCMD_DWDH_16 | DMAC_DCMD_DS_16BIT ); 91 | DMAC_DCMD_DWDH_16 | DMAC_DCMD_DS_16BIT );
99 REG_DMAC_DCCSR(DMA_LCD_CHANNEL) = DMAC_DCCSR_NDES;
100 92
101 __dcache_writeback_all(); /* Size of framebuffer is way bigger than cache size; 93 __dcache_writeback_all(); /* Size of framebuffer is way bigger than cache size.
102 we need to find a way to make the framebuffer uncached, so this statement can get removed. */ 94 We need to find a way to make the framebuffer uncached, so this statement can get removed. */
103 95
104 while(REG_SLCD_STATE & SLCD_STATE_BUSY); 96 while(REG_SLCD_STATE & SLCD_STATE_BUSY);
97 REG_SLCD_CTRL |= SLCD_CTRL_DMA_EN; /* Enable SLCD DMA support */
105 98
106 REG_SLCD_CTRL |= SLCD_CTRL_DMA_EN; 99 REG_DMAC_DCCSR(DMA_LCD_CHANNEL) |= DMAC_DCCSR_EN; /* Enable DMA channel */
107 REG_DMAC_DCCSR(DMA_LCD_CHANNEL) |= DMAC_DCCSR_EN; 100 REG_DMAC_DCMD(DMA_LCD_CHANNEL) |= DMAC_DCMD_TIE; /* Enable DMA interrupt */
108 101
109 lcd_wait(); 102 wakeup_wait(&lcd_wkup, TIMEOUT_BLOCK);
103
104 REG_DMAC_DCCSR(DMA_LCD_CHANNEL) &= ~DMAC_DCCSR_EN; /* Disable DMA channel */
110 105
111 REG_DMAC_DCCSR(DMA_LCD_CHANNEL) &= ~DMAC_DCCSR_EN; 106 dma_disable();
112 107
113 while(REG_SLCD_STATE & SLCD_STATE_BUSY); 108 while(REG_SLCD_STATE & SLCD_STATE_BUSY);
109 REG_SLCD_CTRL &= ~SLCD_CTRL_DMA_EN; /* Disable SLCD DMA support */
114 110
115 REG_SLCD_CTRL &= ~SLCD_CTRL_DMA_EN; 111 mutex_unlock(&lcd_mtx);
112}
113
114void DMA_CALLBACK(DMA_LCD_CHANNEL)(void)
115{
116 if (REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_HLT)
117 REG_DMAC_DCCSR(DMA_LCD_CHANNEL) &= ~DMAC_DCCSR_HLT;
118
119 if (REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_AR)
120 REG_DMAC_DCCSR(DMA_LCD_CHANNEL) &= ~DMAC_DCCSR_AR;
121
122 if (REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_CT)
123 REG_DMAC_DCCSR(DMA_LCD_CHANNEL) &= ~DMAC_DCCSR_CT;
124
125 if (REG_DMAC_DCCSR(DMA_LCD_CHANNEL) & DMAC_DCCSR_TT)
126 REG_DMAC_DCCSR(DMA_LCD_CHANNEL) &= ~DMAC_DCCSR_TT;
116 127
117 lcd_unlock(); 128 wakeup_signal(&lcd_wkup);
118} 129}
119 130
120/* Update the display. 131/* Update the display.
121 This must be called after all other LCD functions that change the display. */ 132 This must be called after all other LCD functions that change the display. */
122void lcd_update(void) 133void lcd_update(void)
123{ 134{
124 if (!lcd_is_on) 135 if (!lcd_is_on || !backlight_enabled())
125 return; 136 return;
126 137
127 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); 138 lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT);
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c
index 501a90551e..208236ef95 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c
@@ -23,60 +23,119 @@
23#include "jz4740.h" 23#include "jz4740.h"
24#include "backlight-target.h" 24#include "backlight-target.h"
25 25
26#define PWM_CHN 7 /* PWM_CHN7 == GPIO(32*3 + 31) */ 26/* PWM_CHN7 == GPIO(32*3 + 31) */
27#define __gpio_as_PWM_CHN __gpio_as_pwm7 27#define BACKLIGHT_GPIO (32*3+31)
28#define BACKLIGHT_PWM 7
28 29
30#define SW_PWM 1
31
32#if SW_PWM
33
34static bool backlight_on;
35
36static void set_backlight(int val)
37{
38(void)val;
39}
40
41bool _backlight_init(void)
42{
43 __gpio_as_output(BACKLIGHT_GPIO);
44 __gpio_set_pin(BACKLIGHT_GPIO);
45
46 backlight_on = true;
47
48 return true;
49}
50
51bool backlight_enabled(void)
52{
53 return backlight_on;
54}
55
56void _backlight_on(void)
57{
58 __gpio_set_pin(BACKLIGHT_GPIO);
59 backlight_on = true;
60}
61
62void _backlight_off(void)
63{
64 __gpio_clear_pin(BACKLIGHT_GPIO);
65 backlight_on = false;
66}
67
68#else
69
70static int old_val;
29static void set_backlight(int val) 71static void set_backlight(int val)
30{ 72{
73 if(val == old_val)
74 return;
75
31 /* Taken from the OF */ 76 /* Taken from the OF */
32 int tmp; 77 int tmp;
33 tmp = (val/2 + __cpm_get_rtcclk()) / val; 78 tmp = (val/2 + __cpm_get_rtcclk()) / val;
34 if(tmp > 0xFFFF) 79 if(tmp > 0xFFFF)
35 tmp = 0xFFFF; 80 tmp = 0xFFFF;
36 81
37 __tcu_set_half_data(PWM_CHN, (tmp * val * 1374389535) >> 5); 82 __tcu_set_half_data(BACKLIGHT_PWM, (tmp * val * 1374389535) >> 5);
38 __tcu_set_full_data(PWM_CHN, tmp); 83 __tcu_set_full_data(BACKLIGHT_PWM, tmp);
84
85 old_val = val;
39} 86}
40 87
41static void set_backlight_on(void) 88static void set_backlight_on(void)
42{ 89{
43 __tcu_start_timer_clock(PWM_CHN); 90 if(old_val == MAX_BRIGHTNESS_SETTING)
91 return;
92
93 __tcu_start_timer_clock(BACKLIGHT_PWM);
44 94
45 set_backlight(MAX_BRIGHTNESS_SETTING); 95 set_backlight(MAX_BRIGHTNESS_SETTING);
46 96
47 __tcu_set_count(PWM_CHN, 0); 97 __tcu_set_count(BACKLIGHT_PWM, 0);
48 __tcu_start_counter(PWM_CHN); 98 __tcu_start_counter(BACKLIGHT_PWM);
49 99
50 __tcu_enable_pwm_output(PWM_CHN); 100 __tcu_enable_pwm_output(BACKLIGHT_PWM);
51} 101}
52 102
53static void set_backlight_off(void) 103static void set_backlight_off(void)
54{ 104{
55 __tcu_stop_counter(PWM_CHN); 105 __tcu_stop_counter(BACKLIGHT_PWM);
56 __tcu_disable_pwm_output(PWM_CHN); 106 __tcu_disable_pwm_output(BACKLIGHT_PWM);
57 __tcu_stop_timer_clock(PWM_CHN); 107 __tcu_stop_timer_clock(BACKLIGHT_PWM);
108
109 old_val = -1;
58} 110}
59 111
60bool _backlight_init(void) 112bool _backlight_init(void)
61{ 113{
62 __gpio_as_PWM_CHN(); 114 __gpio_as_pwm(BACKLIGHT_PWM);
63 __tcu_start_timer_clock(PWM_CHN); 115 __tcu_start_timer_clock(BACKLIGHT_PWM);
64 116
65 __tcu_stop_counter(PWM_CHN); 117 __tcu_stop_counter(BACKLIGHT_PWM);
66 __tcu_disable_pwm_output(PWM_CHN); 118 __tcu_disable_pwm_output(BACKLIGHT_PWM);
67 119
68 __tcu_init_pwm_output_low(PWM_CHN); 120 __tcu_init_pwm_output_low(BACKLIGHT_PWM);
69 __tcu_select_rtcclk(PWM_CHN); 121 __tcu_select_rtcclk(BACKLIGHT_PWM);
70 __tcu_select_clk_div1(PWM_CHN); 122 __tcu_select_clk_div1(BACKLIGHT_PWM);
71 123
72 __tcu_mask_half_match_irq(PWM_CHN); 124 __tcu_mask_half_match_irq(BACKLIGHT_PWM);
73 __tcu_mask_full_match_irq(PWM_CHN); 125 __tcu_mask_full_match_irq(BACKLIGHT_PWM);
126
127 old_val = -1;
74 128
75 set_backlight_on(); 129 set_backlight_on();
76 130
77 return true; 131 return true;
78} 132}
79 133
134bool backlight_enabled(void)
135{
136 return old_val > -1 ? true : false;
137}
138
80void _backlight_on(void) 139void _backlight_on(void)
81{ 140{
82 set_backlight_on(); 141 set_backlight_on();
@@ -86,6 +145,7 @@ void _backlight_off(void)
86{ 145{
87 set_backlight_off(); 146 set_backlight_off();
88} 147}
148#endif /* !SW_PWM */
89 149
90#ifdef HAVE_BACKLIGHT_BRIGHTNESS 150#ifdef HAVE_BACKLIGHT_BRIGHTNESS
91void _backlight_set_brightness(int brightness) 151void _backlight_set_brightness(int brightness)
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h
index 4170f96cc0..f3f17f024e 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h
@@ -33,5 +33,6 @@ bool _backlight_init(void);
33void _backlight_on(void); 33void _backlight_on(void);
34void _backlight_off(void); 34void _backlight_off(void);
35void _backlight_set_brightness(int brightness); 35void _backlight_set_brightness(int brightness);
36bool backlight_enabled(void);
36 37
37#endif /* BACKLIGHT_TARGET_H */ 38#endif /* BACKLIGHT_TARGET_H */
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
index f7c6a137fc..40d9bb6106 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
@@ -204,7 +204,7 @@ static void _set_lcd_clock(void)
204 __cpm_stop_lcd(); 204 __cpm_stop_lcd();
205 pll_div = ( REG_CPM_CPCCR & CPM_CPCCR_PCS ); /* clock source, 0:pllout/2 1: pllout */ 205 pll_div = ( REG_CPM_CPCCR & CPM_CPCCR_PCS ); /* clock source, 0:pllout/2 1: pllout */
206 pll_div = pll_div ? 1 : 2 ; 206 pll_div = pll_div ? 1 : 2 ;
207 val = ( __cpm_get_pllout()/pll_div ) / 336000000; 207 val = ( __cpm_get_pllout()/pll_div ) / __cpm_get_pclk();
208 val--; 208 val--;
209 if ( val > 0x1ff ) 209 if ( val > 0x1ff )
210 val = 0x1ff; /* CPM_LPCDR is too large, set it to 0x1ff */ 210 val = 0x1ff; /* CPM_LPCDR is too large, set it to 0x1ff */
@@ -235,8 +235,8 @@ void lcd_set_target(short x, short y, short width, short height)
235 SLCD_SEND_COMMAND(REG_RAM_VADDR_START, x); /* x_start */ 235 SLCD_SEND_COMMAND(REG_RAM_VADDR_START, x); /* x_start */
236 SLCD_SEND_COMMAND(REG_RAM_VADDR_END, x+width-1); /* x_end */ 236 SLCD_SEND_COMMAND(REG_RAM_VADDR_END, x+width-1); /* x_end */
237#endif 237#endif
238 SLCD_SEND_COMMAND(REG_RAM_HADDR_SET, x); /* set cursor at x_start */ 238 SLCD_SEND_COMMAND(REG_RAM_HADDR_SET, y); /* set cursor at x_start */
239 SLCD_SEND_COMMAND(REG_RAM_VADDR_SET, y); /* set cursor at y_start */ 239 SLCD_SEND_COMMAND(REG_RAM_VADDR_SET, x); /* set cursor at y_start */
240 SLCD_SET_COMMAND(REG_RW_GRAM); /* write data to GRAM */ 240 SLCD_SET_COMMAND(REG_RW_GRAM); /* write data to GRAM */
241} 241}
242 242
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
index 0271fd1b96..95c2f84a7e 100644
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
@@ -47,7 +47,7 @@
47 BTN_MENU | BTN_VOL_UP) 47 BTN_MENU | BTN_VOL_UP)
48 48
49 49
50#define TS_AD_COUNT 5 50#define TS_AD_COUNT 3
51#define SADC_CFG_SNUM ((TS_AD_COUNT - 1) << SADC_CFG_SNUM_BIT) 51#define SADC_CFG_SNUM ((TS_AD_COUNT - 1) << SADC_CFG_SNUM_BIT)
52 52
53#define SADC_CFG_INIT ( \ 53#define SADC_CFG_INIT ( \
diff --git a/firmware/target/mips/ingenic_jz47xx/pcm-jz4740.c b/firmware/target/mips/ingenic_jz47xx/pcm-jz4740.c
index dce989d81f..c97ef13533 100644
--- a/firmware/target/mips/ingenic_jz47xx/pcm-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/pcm-jz4740.c
@@ -41,17 +41,12 @@ void pcm_postinit(void)
41 __i2s_set_oss_sample_size(16); 41 __i2s_set_oss_sample_size(16);
42} 42}
43 43
44const void * pcm_play_dma_get_peak_buffer(int *count)
45{
46 /* TODO */
47 *count = 0;
48 return NULL;
49}
50
51void pcm_play_dma_init(void) 44void pcm_play_dma_init(void)
52{ 45{
53 /* TODO */ 46 /* TODO */
54 47
48 system_enable_irq(DMA_IRQ(DMA_AIC_TX_CHANNEL));
49
55 /* Initialize default register values. */ 50 /* Initialize default register values. */
56 audiohw_init(); 51 audiohw_init();
57} 52}
@@ -59,11 +54,6 @@ void pcm_play_dma_init(void)
59void pcm_dma_apply_settings(void) 54void pcm_dma_apply_settings(void)
60{ 55{
61 /* TODO */ 56 /* TODO */
62
63 /*
64 __i2s_set_oss_sample_size(pcm_sampr);
65 i2s_codec_set_samplerate(pcm_sampr);
66 */
67} 57}
68 58
69static void play_start_pcm(void) 59static void play_start_pcm(void)
@@ -72,33 +62,47 @@ static void play_start_pcm(void)
72 __i2s_enable_replay(); 62 __i2s_enable_replay();
73 63
74 REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) |= DMAC_DCCSR_EN; 64 REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) |= DMAC_DCCSR_EN;
65 REG_DMAC_DCMD(DMA_AIC_TX_CHANNEL) |= DMAC_DCMD_TIE;
75} 66}
76 67
77static void play_stop_pcm(void) 68static void play_stop_pcm(void)
78{ 69{
79 REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) = (REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) | DMAC_DCCSR_HLT) & ~DMAC_DCCSR_EN; 70 REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) = (REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) | DMAC_DCCSR_HLT) & ~DMAC_DCCSR_EN;
80 71
72 dma_disable();
73
81 __i2s_disable_transmit_dma(); 74 __i2s_disable_transmit_dma();
82 __i2s_disable_replay(); 75 __i2s_disable_replay();
83} 76}
84 77
85void pcm_play_dma_start(const void *addr, size_t size) 78void pcm_play_dma_start(const void *addr, size_t size)
86{ 79{
80 dma_enable();
81
87 REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) = DMAC_DCCSR_NDES; 82 REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) = DMAC_DCCSR_NDES;
88 REG_DMAC_DSAR(DMA_AIC_TX_CHANNEL) = PHYSADDR((unsigned long)addr); 83 REG_DMAC_DSAR(DMA_AIC_TX_CHANNEL) = PHYSADDR((unsigned long)addr);
89 REG_DMAC_DTAR(DMA_AIC_TX_CHANNEL) = PHYSADDR((unsigned long)AIC_DR); 84 REG_DMAC_DTAR(DMA_AIC_TX_CHANNEL) = PHYSADDR((unsigned long)AIC_DR);
90 REG_DMAC_DTCR(DMA_AIC_TX_CHANNEL) = size; 85 REG_DMAC_DTCR(DMA_AIC_TX_CHANNEL) = size;
91 REG_DMAC_DRSR(DMA_AIC_TX_CHANNEL) = DMAC_DRSR_RS_AICOUT; 86 REG_DMAC_DRSR(DMA_AIC_TX_CHANNEL) = DMAC_DRSR_RS_AICOUT;
92 REG_DMAC_DCMD(DMA_AIC_TX_CHANNEL) = ( DMAC_DCMD_SAI| DMAC_DCMD_SWDH_32 | DMAC_DCMD_DS_32BIT | DMAC_DCMD_DWDH_32 87 REG_DMAC_DCMD(DMA_AIC_TX_CHANNEL) = (DMAC_DCMD_SAI| DMAC_DCMD_SWDH_32 | DMAC_DCMD_DS_32BIT | DMAC_DCMD_DWDH_32);
93 | DMAC_DCMD_TIE);
94 88
95 play_start_pcm(); 89 play_start_pcm();
96} 90}
97 91
98void DMA_CALLBACK(DMA_AIC_TX_CHANNEL)(void) 92void DMA_CALLBACK(DMA_AIC_TX_CHANNEL)(void)
99{ 93{
100 if( REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) & DMAC_DCCSR_TT ) 94 if (REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) & DMAC_DCCSR_AR)
95 REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) &= ~DMAC_DCCSR_AR;
96
97 if (REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) & DMAC_DCCSR_CT)
98 REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) &= ~DMAC_DCCSR_CT;
99
100 if (REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) & (DMAC_DCCSR_TT | DMAC_DCCSR_HLT))
101 {
102 REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) &= ~(DMAC_DCCSR_TT | DMAC_DCCSR_HLT);
103 REG_DMAC_DCCSR(DMA_AIC_TX_CHANNEL) &= ~DMAC_DCCSR_EN;
101 __aic_disable_transmit_dma(); 104 __aic_disable_transmit_dma();
105 }
102} 106}
103 107
104size_t pcm_get_bytes_waiting(void) 108size_t pcm_get_bytes_waiting(void)
@@ -106,6 +110,13 @@ size_t pcm_get_bytes_waiting(void)
106 return REG_DMAC_DTCR(DMA_AIC_TX_CHANNEL); 110 return REG_DMAC_DTCR(DMA_AIC_TX_CHANNEL);
107} 111}
108 112
113const void * pcm_play_dma_get_peak_buffer(int *count)
114{
115 /* TODO */
116 *count = REG_DMAC_DTCR(DMA_AIC_TX_CHANNEL)>>2;
117 return NULL;
118}
119
109void pcm_play_dma_stop(void) 120void pcm_play_dma_stop(void)
110{ 121{
111 play_stop_pcm(); 122 play_stop_pcm();
diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
index f733582d70..22d35d93de 100644
--- a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
@@ -24,8 +24,8 @@
24#include "mips.h" 24#include "mips.h"
25#include "mipsregs.h" 25#include "mipsregs.h"
26#include "panic.h" 26#include "panic.h"
27#include "system-target.h" 27#include "system.h"
28#include <string.h> 28#include "string.h"
29#include "kernel.h" 29#include "kernel.h"
30 30
31#define NUM_DMA 6 31#define NUM_DMA 6
@@ -322,53 +322,45 @@ static int get_irq_number(void)
322 return irq; 322 return irq;
323} 323}
324 324
325static bool intr_mode = false;
326
327bool in_interrupt_mode(void)
328{
329 return intr_mode;
330}
331
332void intr_handler(void) 325void intr_handler(void)
333{ 326{
334 int irq = get_irq_number(); 327 int irq = get_irq_number();
335 if(irq < 0) 328 if(UNLIKELY(irq < 0))
336 return; 329 return;
337 330
338 ack_irq(irq); 331 ack_irq(irq);
339 if(irq > 0) 332 if(LIKELY(irq > 0))
340 {
341 intr_mode = true;
342 irqvector[irq-1](); 333 irqvector[irq-1]();
343 intr_mode = false;
344 }
345} 334}
346 335
347#define EXC(x,y) if(_cause == (x)) return (y); 336#define EXC(x,y) case (x): return (y);
348static char* parse_exception(unsigned int cause) 337static char* parse_exception(unsigned int cause)
349{ 338{
350 unsigned int _cause = cause & M_CauseExcCode; 339 switch(cause & M_CauseExcCode)
351 EXC(EXC_INT, "Interrupt"); 340 {
352 EXC(EXC_MOD, "TLB Modified"); 341 EXC(EXC_INT, "Interrupt");
353 EXC(EXC_TLBL, "TLB Exception (Load or Ifetch)"); 342 EXC(EXC_MOD, "TLB Modified");
354 EXC(EXC_ADEL, "Address Error (Load or Ifetch)"); 343 EXC(EXC_TLBL, "TLB Exception (Load or Ifetch)");
355 EXC(EXC_ADES, "Address Error (Store)"); 344 EXC(EXC_ADEL, "Address Error (Load or Ifetch)");
356 EXC(EXC_TLBS, "TLB Exception (Store)"); 345 EXC(EXC_ADES, "Address Error (Store)");
357 EXC(EXC_IBE, "Instruction Bus Error"); 346 EXC(EXC_TLBS, "TLB Exception (Store)");
358 EXC(EXC_DBE, "Data Bus Error"); 347 EXC(EXC_IBE, "Instruction Bus Error");
359 EXC(EXC_SYS, "Syscall"); 348 EXC(EXC_DBE, "Data Bus Error");
360 EXC(EXC_BP, "Breakpoint"); 349 EXC(EXC_SYS, "Syscall");
361 EXC(EXC_RI, "Reserved Instruction"); 350 EXC(EXC_BP, "Breakpoint");
362 EXC(EXC_CPU, "Coprocessor Unusable"); 351 EXC(EXC_RI, "Reserved Instruction");
363 EXC(EXC_OV, "Overflow"); 352 EXC(EXC_CPU, "Coprocessor Unusable");
364 EXC(EXC_TR, "Trap Instruction"); 353 EXC(EXC_OV, "Overflow");
365 EXC(EXC_FPE, "Floating Point Exception"); 354 EXC(EXC_TR, "Trap Instruction");
366 EXC(EXC_C2E, "COP2 Exception"); 355 EXC(EXC_FPE, "Floating Point Exception");
367 EXC(EXC_MDMX, "MDMX Exception"); 356 EXC(EXC_C2E, "COP2 Exception");
368 EXC(EXC_WATCH, "Watch Exception"); 357 EXC(EXC_MDMX, "MDMX Exception");
369 EXC(EXC_MCHECK, "Machine Check Exception"); 358 EXC(EXC_WATCH, "Watch Exception");
370 EXC(EXC_CacheErr, "Cache error caused re-entry to Debug Mode"); 359 EXC(EXC_MCHECK, "Machine Check Exception");
371 return NULL; 360 EXC(EXC_CacheErr, "Cache error caused re-entry to Debug Mode");
361 default:
362 return NULL;
363 }
372} 364}
373 365
374void exception_handler(void* stack_ptr, unsigned int cause, unsigned int epc) 366void exception_handler(void* stack_ptr, unsigned int cause, unsigned int epc)
@@ -644,18 +636,31 @@ static void tlb_call_refill(void)
644 ); 636 );
645} 637}
646 638
647static void dma_init(void) 639static int dma_count = 0;
640void dma_enable(void)
648{ 641{
649 __cpm_start_dmac(); 642 if(++dma_count == 1)
650 643 {
651 REG_DMAC_DCCSR(0) = 0; 644 __cpm_start_dmac();
652 REG_DMAC_DCCSR(1) = 0; 645
653 REG_DMAC_DCCSR(2) = 0; 646 REG_DMAC_DCCSR(0) = 0;
654 REG_DMAC_DCCSR(3) = 0; 647 REG_DMAC_DCCSR(1) = 0;
655 REG_DMAC_DCCSR(4) = 0; 648 REG_DMAC_DCCSR(2) = 0;
656 REG_DMAC_DCCSR(5) = 0; 649 REG_DMAC_DCCSR(3) = 0;
657 650 REG_DMAC_DCCSR(4) = 0;
658 REG_DMAC_DMACR = (DMAC_DMACR_PR_012345 | DMAC_DMACR_DMAE); 651 REG_DMAC_DCCSR(5) = 0;
652
653 REG_DMAC_DMACR = (DMAC_DMACR_PR_012345 | DMAC_DMACR_DMAE);
654 }
655}
656
657void dma_disable(void)
658{
659 if(--dma_count == 0)
660 {
661 REG_DMAC_DMACR &= ~DMAC_DMACR_DMAE;
662 __cpm_stop_dmac();
663 }
659} 664}
660 665
661extern int main(void); 666extern int main(void);
@@ -686,7 +691,6 @@ void system_main(void)
686 dis_irq(i); 691 dis_irq(i);
687 692
688 tlb_init(); 693 tlb_init();
689 dma_init();
690 694
691 detect_clock(); 695 detect_clock();
692 696
diff --git a/firmware/target/mips/ingenic_jz47xx/system-target.h b/firmware/target/mips/ingenic_jz47xx/system-target.h
index a8133140fa..39782a3222 100644
--- a/firmware/target/mips/ingenic_jz47xx/system-target.h
+++ b/firmware/target/mips/ingenic_jz47xx/system-target.h
@@ -101,7 +101,8 @@ void udelay(unsigned int usec);
101void mdelay(unsigned int msec); 101void mdelay(unsigned int msec);
102void power_off(void); 102void power_off(void);
103void system_reboot(void); 103void system_reboot(void);
104bool in_interrupt_mode(void); 104void dma_enable(void);
105void dma_disable(void);
105 106
106#define DMA_LCD_CHANNEL 0 107#define DMA_LCD_CHANNEL 0
107#define DMA_NAND_CHANNEL 1 108#define DMA_NAND_CHANNEL 1
@@ -111,4 +112,6 @@ bool in_interrupt_mode(void);
111#define XDMA_CALLBACK(n) DMA ## n 112#define XDMA_CALLBACK(n) DMA ## n
112#define DMA_CALLBACK(n) XDMA_CALLBACK(n) 113#define DMA_CALLBACK(n) XDMA_CALLBACK(n)
113 114
115#define DMA_IRQ(n) (IRQ_DMA_0 + n)
116
114#endif /* __SYSTEM_TARGET_H_ */ 117#endif /* __SYSTEM_TARGET_H_ */
diff --git a/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c b/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c
index 16965159f6..f06e796e05 100644
--- a/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/usb-jz4740.c
@@ -20,6 +20,8 @@
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include "config.h" 22#include "config.h"
23#define LOGF_ENABLE
24#include "logf.h"
23#include "system.h" 25#include "system.h"
24#include "usb_ch9.h" 26#include "usb_ch9.h"
25#include "usb_drv.h" 27#include "usb_drv.h"
@@ -28,12 +30,6 @@
28#include "jz4740.h" 30#include "jz4740.h"
29#include "thread.h" 31#include "thread.h"
30 32
31#if 1
32#define DEBUGF printf
33#else
34#define DEBUGF(...)
35#endif
36
37#define USB_EP0_IDLE 0 33#define USB_EP0_IDLE 0
38#define USB_EP0_RX 1 34#define USB_EP0_RX 1
39#define USB_EP0_TX 2 35#define USB_EP0_TX 2
@@ -85,7 +81,7 @@ static inline void select_endpoint(int ep)
85 81
86static void readFIFO(struct usb_endpoint *ep, unsigned int size) 82static void readFIFO(struct usb_endpoint *ep, unsigned int size)
87{ 83{
88 DEBUGF("readFIFO(EP%d, %d)", EP_NUMBER(ep), size); 84 logf("readFIFO(EP%d, %d)", EP_NUMBER(ep), size);
89 85
90 register unsigned char *ptr = (unsigned char*)EP_PTR(ep); 86 register unsigned char *ptr = (unsigned char*)EP_PTR(ep);
91 register unsigned int *ptr32 = (unsigned int*)ptr; 87 register unsigned int *ptr32 = (unsigned int*)ptr;
@@ -121,7 +117,7 @@ static void readFIFO(struct usb_endpoint *ep, unsigned int size)
121 117
122static void writeFIFO(struct usb_endpoint *ep, unsigned int size) 118static void writeFIFO(struct usb_endpoint *ep, unsigned int size)
123{ 119{
124 DEBUGF("writeFIFO(EP%d, %d)", EP_NUMBER(ep), size); 120 logf("writeFIFO(EP%d, %d)", EP_NUMBER(ep), size);
125 121
126 register unsigned int *d = (unsigned int *)EP_PTR(ep); 122 register unsigned int *d = (unsigned int *)EP_PTR(ep);
127 register unsigned char *c; 123 register unsigned char *c;
@@ -140,6 +136,8 @@ static void writeFIFO(struct usb_endpoint *ep, unsigned int size)
140 REG8(ep->fifo_addr) = *c++; 136 REG8(ep->fifo_addr) = *c++;
141 } 137 }
142 } 138 }
139 else
140 REG32(ep->fifo_addr) = 0;
143} 141}
144 142
145static void EP0_send(void) 143static void EP0_send(void)
@@ -152,6 +150,8 @@ static void EP0_send(void)
152 else 150 else
153 length = (EP_BUF_LEFT(ep) <= ep->fifo_size ? EP_BUF_LEFT(ep) : ep->fifo_size); 151 length = (EP_BUF_LEFT(ep) <= ep->fifo_size ? EP_BUF_LEFT(ep) : ep->fifo_size);
154 152
153 select_endpoint(0);
154
155 writeFIFO(ep, length); 155 writeFIFO(ep, length);
156 ep->sent += length; 156 ep->sent += length;
157 157
@@ -243,7 +243,7 @@ static void setup_endpoint(struct usb_endpoint *ep)
243 243
244static void udc_reset(void) 244static void udc_reset(void)
245{ 245{
246 DEBUGF("udc_reset"); 246 logf("udc_reset");
247 247
248 register unsigned int i; 248 register unsigned int i;
249 249
@@ -303,19 +303,19 @@ void UDC(void)
303 if(intrUSB & USB_INTR_RESUME); 303 if(intrUSB & USB_INTR_RESUME);
304 if(intrDMA & USB_INTR_DMA_BULKIN) 304 if(intrDMA & USB_INTR_DMA_BULKIN)
305 { 305 {
306 DEBUGF("DMA_BULKIN %d", ((REG_USB_REG_CNTL1 >> 4) & 0xF)); 306 logf("DMA_BULKIN %d", ((REG_USB_REG_CNTL1 >> 4) & 0xF));
307 usb_core_transfer_complete(((REG_USB_REG_CNTL1 >> 4) & 0xF) | USB_DIR_IN, USB_DIR_IN, 0, 0); 307 usb_core_transfer_complete(((REG_USB_REG_CNTL1 >> 4) & 0xF) | USB_DIR_IN, USB_DIR_IN, 0, 0);
308 } 308 }
309 if(intrDMA & USB_INTR_DMA_BULKOUT) 309 if(intrDMA & USB_INTR_DMA_BULKOUT)
310 { 310 {
311 DEBUGF("DMA_BULKOUT %d", ((REG_USB_REG_CNTL2 >> 4) & 0xF)); 311 logf("DMA_BULKOUT %d", ((REG_USB_REG_CNTL2 >> 4) & 0xF));
312 usb_core_transfer_complete(((REG_USB_REG_CNTL2 >> 4) & 0xF) | USB_DIR_OUT, USB_DIR_OUT, 0, 0); 312 usb_core_transfer_complete(((REG_USB_REG_CNTL2 >> 4) & 0xF) | USB_DIR_OUT, USB_DIR_OUT, 0, 0);
313 } 313 }
314} 314}
315 315
316bool usb_drv_stalled(int endpoint, bool in) 316bool usb_drv_stalled(int endpoint, bool in)
317{ 317{
318 DEBUGF("usb_drv_stalled(%d, %s)", endpoint, in?"IN":"OUT"); 318 logf("usb_drv_stalled(%d, %s)", endpoint, in?"IN":"OUT");
319 319
320 select_endpoint(endpoint); 320 select_endpoint(endpoint);
321 321
@@ -332,7 +332,7 @@ bool usb_drv_stalled(int endpoint, bool in)
332 332
333void usb_drv_stall(int endpoint, bool stall, bool in) 333void usb_drv_stall(int endpoint, bool stall, bool in)
334{ 334{
335 DEBUGF("usb_drv_stall(%d,%s,%s)", endpoint, stall?"y":"n", in?"IN":"OUT"); 335 logf("usb_drv_stall(%d,%s,%s)", endpoint, stall?"y":"n", in?"IN":"OUT");
336 336
337 select_endpoint(endpoint); 337 select_endpoint(endpoint);
338 338
@@ -424,14 +424,14 @@ void usb_drv_exit(void)
424 424
425void usb_drv_set_address(int address) 425void usb_drv_set_address(int address)
426{ 426{
427 DEBUGF("set adr: 0x%x", address); 427 logf("set adr: %d", address);
428 428
429 REG_USB_REG_FADDR = address; 429 REG_USB_REG_FADDR = address;
430} 430}
431 431
432int usb_drv_send(int endpoint, void* ptr, int length) 432int usb_drv_send(int endpoint, void* ptr, int length)
433{ 433{
434 DEBUGF("usb_drv_send(%d, 0x%x, %d)", endpoint, (int)ptr, length); 434 logf("usb_drv_send(%d, 0x%x, %d)", endpoint, (int)ptr, length);
435 435
436 if(endpoint == EP_CONTROL && ptr == NULL && length == 0) /* ACK request */ 436 if(endpoint == EP_CONTROL && ptr == NULL && length == 0) /* ACK request */
437 return 0; 437 return 0;
@@ -451,7 +451,7 @@ int usb_drv_send(int endpoint, void* ptr, int length)
451 451
452int usb_drv_recv(int endpoint, void* ptr, int length) 452int usb_drv_recv(int endpoint, void* ptr, int length)
453{ 453{
454 DEBUGF("usb_drv_recv(%d, 0x%x, %d)", endpoint, (int)ptr, length); 454 logf("usb_drv_recv(%d, 0x%x, %d)", endpoint, (int)ptr, length);
455 455
456 if(endpoint == EP_CONTROL && ptr == NULL && length == 0) /* ACK request */ 456 if(endpoint == EP_CONTROL && ptr == NULL && length == 0) /* ACK request */
457 return 0; 457 return 0;
@@ -461,7 +461,7 @@ int usb_drv_recv(int endpoint, void* ptr, int length)
461 461
462void usb_drv_set_test_mode(int mode) 462void usb_drv_set_test_mode(int mode)
463{ 463{
464 DEBUGF("usb_drv_set_test_mode(%d)", mode); 464 logf("usb_drv_set_test_mode(%d)", mode);
465 465
466 switch(mode) 466 switch(mode)
467 { 467 {
@@ -490,7 +490,7 @@ int usb_drv_port_speed(void)
490 490
491void usb_drv_cancel_all_transfers(void) 491void usb_drv_cancel_all_transfers(void)
492{ 492{
493 DEBUGF("usb_drv_cancel_all_transfers()"); 493 logf("usb_drv_cancel_all_transfers()");
494 494
495 unsigned int i; 495 unsigned int i;
496 for(i=0; i<TOTAL_EP(); i++) 496 for(i=0; i<TOTAL_EP(); i++)
@@ -505,14 +505,14 @@ void usb_drv_cancel_all_transfers(void)
505 505
506void usb_drv_release_endpoint(int ep) 506void usb_drv_release_endpoint(int ep)
507{ 507{
508 //DEBUGF("usb_drv_release_endpoint(%d)", ep); 508 //logf("usb_drv_release_endpoint(%d)", ep);
509 509
510 (void)ep; 510 (void)ep;
511} 511}
512 512
513int usb_drv_request_endpoint(int dir) 513int usb_drv_request_endpoint(int dir)
514{ 514{
515 DEBUGF("usb_drv_request_endpoint(%d)", dir); 515 logf("usb_drv_request_endpoint(%d)", dir);
516 516
517 (void)dir; 517 (void)dir;
518 return -1; 518 return -1;