summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-10 21:44:48 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-10 21:44:48 +0000
commit4bf4d2bb55535c9c90afff717bcf046bd19af982 (patch)
tree0c1a8c5a4a636339699059c7300cb45f6cd129e4
parent4396b5b101dba2af84ad92bdefd16c5b6210f910 (diff)
downloadrockbox-4bf4d2bb55535c9c90afff717bcf046bd19af982.tar.gz
rockbox-4bf4d2bb55535c9c90afff717bcf046bd19af982.zip
* Get interrupts working (but crashes after 10-30secs)
* Make current_tick increase * Convert button driver into SADC driver * Make touchscreen handling work better (still needs good calibration routine) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18240 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--bootloader/ondavx747.c9
-rw-r--r--firmware/SOURCES2
-rw-r--r--firmware/target/mips/ingenic_jz47xx/kernel-jz4740.c10
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c131
-rw-r--r--firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c217
-rw-r--r--firmware/target/mips/ingenic_jz47xx/system-jz4740.c31
-rw-r--r--firmware/target/mips/ingenic_jz47xx/system-target.h3
-rw-r--r--firmware/target/mips/ingenic_jz47xx/timer-jz4740.c28
-rw-r--r--firmware/target/mips/ingenic_jz47xx/timer-target.h41
9 files changed, 314 insertions, 158 deletions
diff --git a/bootloader/ondavx747.c b/bootloader/ondavx747.c
index a9230e7ac5..41fb00b28a 100644
--- a/bootloader/ondavx747.c
+++ b/bootloader/ondavx747.c
@@ -43,7 +43,8 @@ static void audiotest(void)
43} 43}
44 44
45int main(void) 45int main(void)
46{ 46{
47 cli();
47 kernel_init(); 48 kernel_init();
48 lcd_init(); 49 lcd_init();
49 font_init(); 50 font_init();
@@ -55,6 +56,8 @@ int main(void)
55 56
56 ata_init(); 57 ata_init();
57 58
59 sti();
60
58 /* To make Windows say "ding-dong".. */ 61 /* To make Windows say "ding-dong".. */
59 REG8(USB_REG_POWER) &= ~USB_POWER_SOFTCONN; 62 REG8(USB_REG_POWER) &= ~USB_POWER_SOFTCONN;
60 63
@@ -136,12 +139,10 @@ int main(void)
136 snprintf(datetime, 30, "%02d/%02d/%04d %02d:%02d:%02d", get_time()->tm_mday, get_time()->tm_mon, get_time()->tm_year, 139 snprintf(datetime, 30, "%02d/%02d/%04d %02d:%02d:%02d", get_time()->tm_mday, get_time()->tm_mon, get_time()->tm_year,
137 get_time()->tm_hour, get_time()->tm_min, get_time()->tm_sec); 140 get_time()->tm_hour, get_time()->tm_min, get_time()->tm_sec);
138 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT, datetime); 141 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT, datetime);
139 snprintf(datetime, 30, "%d", REG_TCU_TCNT0); 142 snprintf(datetime, 30, "%d", current_tick);
140 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*2, datetime); 143 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*2, datetime);
141 snprintf(datetime, 30, "X: %d Y: %d", touch>>16, touch & 0xFFFF); 144 snprintf(datetime, 30, "X: %d Y: %d", touch>>16, touch & 0xFFFF);
142 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*3, datetime); 145 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*3, datetime);
143 snprintf(datetime, 30, "%d", read_c0_count());
144 lcd_putsxy(LCD_WIDTH-SYSFONT_WIDTH*strlen(datetime), LCD_HEIGHT-SYSFONT_HEIGHT*4, datetime);
145 lcd_update(); 146 lcd_update();
146 } 147 }
147 148
diff --git a/firmware/SOURCES b/firmware/SOURCES
index c6cefa014f..17545b99a6 100644
--- a/firmware/SOURCES
+++ b/firmware/SOURCES
@@ -1089,6 +1089,6 @@ drivers/nand_id.c
1089 1089
1090#ifdef ONDA_VX747 1090#ifdef ONDA_VX747
1091target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c 1091target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c
1092target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c
1093target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c 1092target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c
1093target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
1094#endif 1094#endif
diff --git a/firmware/target/mips/ingenic_jz47xx/kernel-jz4740.c b/firmware/target/mips/ingenic_jz47xx/kernel-jz4740.c
index 1d88c750f2..29b581dd6b 100644
--- a/firmware/target/mips/ingenic_jz47xx/kernel-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/kernel-jz4740.c
@@ -22,8 +22,6 @@
22#include "config.h" 22#include "config.h"
23#include "system.h" 23#include "system.h"
24#include "kernel.h" 24#include "kernel.h"
25#include "timer.h"
26#include "thread.h"
27#include "jz4740.h" 25#include "jz4740.h"
28 26
29extern void (*tick_funcs[MAX_NUM_TICK_TASKS])(void); 27extern void (*tick_funcs[MAX_NUM_TICK_TASKS])(void);
@@ -35,7 +33,9 @@ void tick_start(unsigned int interval_in_ms)
35 unsigned int latch; 33 unsigned int latch;
36 __cpm_start_tcu(); 34 __cpm_start_tcu();
37 35
36 __tcu_stop_counter(0);
38 __tcu_disable_pwm_output(0); 37 __tcu_disable_pwm_output(0);
38
39 __tcu_mask_half_match_irq(0); 39 __tcu_mask_half_match_irq(0);
40 __tcu_unmask_full_match_irq(0); 40 __tcu_unmask_full_match_irq(0);
41 41
@@ -49,15 +49,19 @@ void tick_start(unsigned int interval_in_ms)
49 49
50 latch = (JZ_EXTAL / 4 + (tps>>1)) / tps; 50 latch = (JZ_EXTAL / 4 + (tps>>1)) / tps;
51#endif 51#endif
52 REG_TCU_TCNT(0) = 0;
52 REG_TCU_TDFR(0) = latch; 53 REG_TCU_TDFR(0) = latch;
53 REG_TCU_TDHR(0) = latch; 54 REG_TCU_TDHR(0) = latch;
55 //REG_TCU_TDHR(0) = 0;
54 56
55 __tcu_clear_full_match_flag(0); 57 __tcu_clear_full_match_flag(0);
56 __tcu_start_counter(0); 58 __tcu_start_counter(0);
57 59
58 //printf("TCSR = 0x%04x\r\n",*(volatile u16 *)0xb000204C); 60 system_enable_irq(IRQ_TCU0);
61
59} 62}
60 63
64/* Interrupt handler */
61void TCU0(void) 65void TCU0(void)
62{ 66{
63 int i; 67 int i;
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c
deleted file mode 100644
index a6846ba18d..0000000000
--- a/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c
+++ /dev/null
@@ -1,131 +0,0 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "jz4740.h"
24#include "button-target.h"
25
26#define BTN_VOL_DOWN (1 << 27)
27#define BTN_VOL_UP (1 << 0)
28#define BTN_MENU (1 << 1)
29#define BTN_OFF (1 << 29)
30#define BTN_HOLD (1 << 16)
31#define BTN_MASK (BTN_VOL_DOWN | BTN_VOL_UP \
32 | BTN_MENU | BTN_OFF )
33
34#define SADC_CFG_INIT ( \
35 (2 << SADC_CFG_CLKOUT_NUM_BIT) | \
36 SADC_CFG_XYZ1Z2 | \
37 SADC_CFG_SNUM_5 | \
38 (1 << SADC_CFG_CLKDIV_BIT) | \
39 SADC_CFG_PBAT_HIGH | \
40 SADC_CFG_CMD_INT_PEN \
41 )
42
43bool button_hold(void)
44{
45 return (~REG_GPIO_PXPIN(3) & BTN_HOLD ? 1 : 0);
46}
47
48void button_init_device(void)
49{
50 REG_SADC_ENA = 0;
51 REG_SADC_STATE &= (~REG_SADC_STATE);
52 REG_SADC_CTRL = 0x1f;
53
54 __cpm_start_sadc();
55 REG_SADC_CFG = SADC_CFG_INIT;
56
57 REG_SADC_SAMETIME = 1;
58 REG_SADC_WAITTIME = 1000; /* per 100 HZ */
59 REG_SADC_STATE &= (~REG_SADC_STATE);
60 REG_SADC_CTRL &= (~(SADC_CTRL_PENDM | SADC_CTRL_TSRDYM));
61 REG_SADC_ENA = SADC_ENA_TSEN; // | REG_SADC_ENA;//SADC_ENA_TSEN | SADC_ENA_PBATEN | SADC_ENA_SADCINEN;
62}
63
64static int touch_to_pixels(short x, short y)
65{
66 /* X:300 -> 3800 Y:300->3900 */
67 x -= 300;
68 y -= 300;
69
70 /* X & Y are switched */
71 x /= 3200 / LCD_WIDTH;
72 y /= 3600 / LCD_HEIGHT;
73
74 y = LCD_HEIGHT - y;
75
76 return (x << 16) | y;
77}
78
79int button_read_device(int *data)
80{
81 if(button_hold())
82 return 0;
83
84 unsigned int key = ~REG_GPIO_PXPIN(3);
85 int ret = 0;
86 if(key & BTN_MASK)
87 {
88 if(key & BTN_VOL_DOWN)
89 ret |= BUTTON_VOL_DOWN;
90 if(key & BTN_VOL_UP)
91 ret |= BUTTON_VOL_UP;
92 if(key & BTN_MENU)
93 ret |= BUTTON_MENU;
94 if(key & BTN_OFF)
95 ret |= BUTTON_POWER;
96 }
97
98 if(REG_SADC_STATE & (SADC_CTRL_TSRDYM|SADC_STATE_PEND))
99 {
100 if(REG_SADC_STATE & SADC_CTRL_PENDM)
101 {
102 REG_SADC_CTRL &= (~(SADC_CTRL_PENUM | SADC_CTRL_TSRDYM));
103 REG_SADC_CTRL |= (SADC_CTRL_PENDM);
104 unsigned int dat;
105 unsigned short xData,yData;
106 short tszData;
107
108 dat = REG_SADC_TSDAT;
109
110 xData = (dat >> 0) & 0xfff;
111 yData = (dat >> 16) & 0xfff;
112
113 dat = REG_SADC_TSDAT;
114 tszData = (dat >> 0) & 0xfff;
115 tszData = tszData - ((dat >> 16) & 0xfff);
116
117 *data = touch_to_pixels(xData, yData);
118
119 }
120 REG_SADC_STATE = 0;
121 //__intc_unmask_irq(IRQ_SADC);
122 }
123 else
124 *data = 0;
125
126 return ret;
127}
128void button_set_touch_available(void)
129{
130 return;
131}
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
new file mode 100644
index 0000000000..b5c817c367
--- /dev/null
+++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/sadc-onda_vx747.c
@@ -0,0 +1,217 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "system.h"
24#include "jz4740.h"
25#include "button-target.h"
26
27#define BTN_VOL_DOWN (1 << 27)
28#define BTN_VOL_UP (1 << 0)
29#define BTN_MENU (1 << 1)
30#define BTN_OFF (1 << 29)
31#define BTN_HOLD (1 << 16)
32#define BTN_MASK (BTN_VOL_DOWN | BTN_VOL_UP \
33 | BTN_MENU | BTN_OFF )
34
35
36#define TS_AD_COUNT 5
37#define M_SADC_CFG_SNUM ((TS_AD_COUNT - 1) << SADC_CFG_SNUM_BIT)
38
39#define SADC_CFG_INIT ( \
40 (2 << SADC_CFG_CLKOUT_NUM_BIT) | \
41 SADC_CFG_XYZ1Z2 | \
42 M_SADC_CFG_SNUM | \
43 (2 << SADC_CFG_CLKDIV_BIT) | \
44 SADC_CFG_PBAT_HIGH | \
45 SADC_CFG_CMD_INT_PEN \
46 )
47
48static bool pendown_flag = false;
49static short x_pos = -1, y_pos = -1, datacount = 0;
50static short stable_x_pos = -1, stable_y_pos = -1;
51
52bool button_hold(void)
53{
54 return (~REG_GPIO_PXPIN(3) & BTN_HOLD ? 1 : 0);
55}
56
57void button_init_device(void)
58{
59 REG_SADC_ENA = 0;
60 REG_SADC_STATE &= (~REG_SADC_STATE);
61 REG_SADC_CTRL = 0x1f;
62
63 __cpm_start_sadc();
64 REG_SADC_CFG = SADC_CFG_INIT;
65
66 system_enable_irq(IRQ_SADC);
67
68 REG_SADC_SAMETIME = 350;
69 REG_SADC_WAITTIME = 100; /* per 10 HZ */
70 REG_SADC_STATE &= (~REG_SADC_STATE);
71 REG_SADC_CTRL &= (~(SADC_CTRL_PENDM | SADC_CTRL_PENUM | SADC_CTRL_TSRDYM));
72 REG_SADC_ENA = (SADC_ENA_TSEN | REG_SADC_ENA); //| SADC_ENA_PBATEN | SADC_ENA_SADCINEN);
73
74 __gpio_port_as_input(3, 29);
75 __gpio_port_as_input(3, 27);
76 __gpio_port_as_input(3, 16);
77 __gpio_port_as_input(3, 1);
78 __gpio_port_as_input(3, 0);
79}
80
81//static unsigned short touchdivider[2] = {14.5833*1000, 9*1000};
82static int touch_to_pixels(short x, short y)
83{
84 /* X:300 -> 3800 Y:300->3900 */
85 x -= 300;
86 y -= 300;
87
88 x /= 3200 / LCD_WIDTH;
89 y /= 3600 / LCD_HEIGHT;
90 //x /= touchdivider[0];
91 //y /= touchdivider[1];
92
93 y = LCD_HEIGHT - y;
94
95 return (x << 16) | y;
96}
97
98int button_read_device(int *data)
99{
100 if(button_hold())
101 return 0;
102
103 unsigned int key = ~(__gpio_get_port(3));
104 int ret = 0;
105 if(key & BTN_MASK)
106 {
107 if(key & BTN_VOL_DOWN)
108 ret |= BUTTON_VOL_DOWN;
109 if(key & BTN_VOL_UP)
110 ret |= BUTTON_VOL_UP;
111 if(key & BTN_MENU)
112 ret |= BUTTON_MENU;
113 if(key & BTN_OFF)
114 ret |= BUTTON_POWER;
115 }
116
117 if(pendown_flag)
118 {
119 *data = touch_to_pixels(stable_x_pos, stable_y_pos);
120 ret |= BUTTON_TOUCH;
121 }
122 else
123 *data = 0;
124
125 return ret;
126}
127
128void button_set_touch_available(void)
129{
130 return;
131}
132
133/* Interrupt handler */
134void SADC(void)
135{
136 unsigned char state;
137 unsigned char sadcstate;
138
139 sadcstate = REG_SADC_STATE;
140 state = REG_SADC_STATE & (~REG_SADC_CTRL);
141 REG_SADC_STATE &= sadcstate;
142
143 if(state & SADC_CTRL_PENDM)
144 {
145 /* Pen down IRQ */
146 REG_SADC_CTRL &= (~(SADC_CTRL_PENUM | SADC_CTRL_TSRDYM));
147 REG_SADC_CTRL |= (SADC_CTRL_PENDM);// | SADC_CTRL_TSRDYM);
148 pendown_flag = true;
149 }
150 if(state & SADC_CTRL_PENUM)
151 {
152 /* Pen up IRQ */
153 REG_SADC_CTRL &= (~SADC_CTRL_PENDM );
154 REG_SADC_CTRL |= SADC_CTRL_PENUM;
155 pendown_flag = false;
156 x_pos = -1;
157 y_pos = -1;
158 stable_x_pos = -1;
159 stable_y_pos = -1;
160 }
161 if(state & SADC_CTRL_TSRDYM)
162 {
163 unsigned int dat;
164 unsigned short xData, yData;
165 short tsz1Data, tsz2Data;
166
167 dat = REG_SADC_TSDAT;
168
169 xData = (dat >> 0) & 0xfff;
170 yData = (dat >> 16) & 0xfff;
171
172 dat = REG_SADC_TSDAT;
173 tsz1Data = (dat >> 0) & 0xfff;
174 tsz2Data = (dat >> 16) & 0xfff;
175
176 if(!pendown_flag)
177 return ;
178
179 tsz1Data = tsz2Data - tsz1Data;
180
181 if((tsz1Data > 15) || (tsz1Data < -15))
182 {
183 if(x_pos == -1)
184 x_pos = xData;
185 else
186 x_pos = (x_pos + xData) / 2;
187
188 if(y_pos == -1)
189 y_pos = yData;
190 else
191 y_pos = (y_pos + yData) / 2;
192 }
193
194 datacount++;
195
196 if(datacount > TS_AD_COUNT - 1)
197 {
198 if(x_pos != -1)
199 {
200 stable_x_pos = x_pos;
201 stable_y_pos = y_pos;
202 x_pos = -1;
203 y_pos = -1;
204 }
205
206 datacount = 0;
207 }
208 }
209 if(state & SADC_CTRL_PBATRDYM)
210 {
211 /* Battery AD IRQ */
212 }
213 if(state & SADC_CTRL_SRDYM)
214 {
215 /* SADC AD IRQ */
216 }
217}
diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
index 6d1e68e115..e878173abd 100644
--- a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
+++ b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c
@@ -32,9 +32,10 @@
32#define NUM_GPIO 128 32#define NUM_GPIO 128
33#define IRQ_MAX (IRQ_GPIO_0 + NUM_GPIO) 33#define IRQ_MAX (IRQ_GPIO_0 + NUM_GPIO)
34 34
35static int irq;
35static void UIRQ(void) 36static void UIRQ(void)
36{ 37{
37 panicf("Unhandled interrupt occurred\n"); 38 panicf("Unhandled interrupt occurred: %d\n", irq);
38} 39}
39 40
40#define default_interrupt(name) \ 41#define default_interrupt(name) \
@@ -51,7 +52,6 @@ default_interrupt(SSI);
51default_interrupt(CIM); 52default_interrupt(CIM);
52default_interrupt(AIC); 53default_interrupt(AIC);
53default_interrupt(ETH); 54default_interrupt(ETH);
54default_interrupt(TCU3);
55default_interrupt(TCU2); 55default_interrupt(TCU2);
56default_interrupt(TCU1); 56default_interrupt(TCU1);
57default_interrupt(TCU0); 57default_interrupt(TCU0);
@@ -197,11 +197,12 @@ default_interrupt(GPIO127);
197 197
198static void (* const irqvector[])(void) = 198static void (* const irqvector[])(void) =
199{ 199{
200 I2C,EMC,UHC,UART0,SADC,MSC,RTC,SSI, 200 I2C,EMC,UHC,UIRQ,UIRQ,UIRQ,UIRQ,UIRQ,
201 CIM,AIC,ETH,UIRQ,TCU3,TCU2,TCU1,TCU0, 201 UART0,UIRQ,UIRQ,SADC,UIRQ,MSC,RTC,SSI,
202 UDC,UIRQ,UIRQ,UIRQ,UIRQ,IPU,LCD,UIRQ, 202 CIM,AIC,ETH,UIRQ,TCU2,TCU1,TCU0,UDC,
203 DMA0,DMA1,DMA2,DMA3,DMA4,DMA5,UIRQ,UIRQ, 203 UIRQ,UIRQ,UIRQ,UIRQ,IPU,LCD,UIRQ,DMA0,
204 UIRQ,UIRQ,UIRQ,UIRQ,UIRQ,UIRQ,UIRQ,UIRQ, 204 DMA1,DMA2,DMA3,DMA4,DMA5,UIRQ,UIRQ,UIRQ,
205 UIRQ,UIRQ,UIRQ,UIRQ,UIRQ,UIRQ,UIRQ,
205 GPIO0,GPIO1,GPIO2,GPIO3,GPIO4,GPIO5,GPIO6,GPIO7, 206 GPIO0,GPIO1,GPIO2,GPIO3,GPIO4,GPIO5,GPIO6,GPIO7,
206 GPIO8,GPIO9,GPIO10,GPIO11,GPIO12,GPIO13,GPIO14,GPIO15, 207 GPIO8,GPIO9,GPIO10,GPIO11,GPIO12,GPIO13,GPIO14,GPIO15,
207 GPIO16,GPIO17,GPIO18,GPIO19,GPIO20,GPIO21,GPIO22,GPIO23, 208 GPIO16,GPIO17,GPIO18,GPIO19,GPIO20,GPIO21,GPIO22,GPIO23,
@@ -223,7 +224,7 @@ static void (* const irqvector[])(void) =
223static unsigned int dma_irq_mask = 0; 224static unsigned int dma_irq_mask = 0;
224static unsigned int gpio_irq_mask[4] = {0}; 225static unsigned int gpio_irq_mask[4] = {0};
225 226
226static void ena_irq(unsigned int irq) 227void system_enable_irq(unsigned int irq)
227{ 228{
228 register unsigned int t; 229 register unsigned int t;
229 if ((irq >= IRQ_GPIO_0) && (irq <= IRQ_GPIO_0 + NUM_GPIO)) 230 if ((irq >= IRQ_GPIO_0) && (irq <= IRQ_GPIO_0 + NUM_GPIO))
@@ -333,7 +334,7 @@ static int get_irq_number(void)
333 334
334void intr_handler(void) 335void intr_handler(void)
335{ 336{
336 register int irq = get_irq_number(); 337 irq = get_irq_number();
337 if(irq < 0) 338 if(irq < 0)
338 return; 339 return;
339 340
@@ -341,7 +342,6 @@ void intr_handler(void)
341 if(irq > 0) 342 if(irq > 0)
342 irqvector[irq-1](); 343 irqvector[irq-1]();
343 344
344 printf("Interrupt!");
345 return; 345 return;
346} 346}
347 347
@@ -558,18 +558,11 @@ void system_main(void)
558 558
559 __dcache_writeback_all(); 559 __dcache_writeback_all();
560 __icache_invalidate_all(); 560 __icache_invalidate_all();
561
562 //set_c0_status(1 << 22); /* Enable Boot Exception Vectors */
563 561
564 /* Init interrupt handlers */ 562 /* Init interrupt handling */
565 ipl = 0; 563 ipl = 0;
566 for(i=0;i<IRQ_MAX;i++) 564 for(i=0;i<IRQ_MAX;i++)
567 { 565 dis_irq(i);
568 if(irqvector[i] == UIRQ)
569 dis_irq(i);
570 else
571 ena_irq(i);
572 }
573 566
574 sti(); 567 sti();
575 568
diff --git a/firmware/target/mips/ingenic_jz47xx/system-target.h b/firmware/target/mips/ingenic_jz47xx/system-target.h
index d923a48546..7d4c28756a 100644
--- a/firmware/target/mips/ingenic_jz47xx/system-target.h
+++ b/firmware/target/mips/ingenic_jz47xx/system-target.h
@@ -94,8 +94,11 @@ void __dcache_invalidate_all(void);
94void __icache_invalidate_all(void); 94void __icache_invalidate_all(void);
95void __flush_dcache_line(unsigned long addr); 95void __flush_dcache_line(unsigned long addr);
96void dma_cache_wback_inv(unsigned long addr, unsigned long size); 96void dma_cache_wback_inv(unsigned long addr, unsigned long size);
97void system_enable_irq(unsigned int irq);
97void sti(void); 98void sti(void);
98void cli(void); 99void cli(void);
100void udelay(unsigned int usec);
101void mdelay(unsigned int msec);
99 102
100#endif /* __SYSTEM_TARGET_H_ */ 103#endif /* __SYSTEM_TARGET_H_ */
101 104
diff --git a/firmware/target/mips/ingenic_jz47xx/timer-jz4740.c b/firmware/target/mips/ingenic_jz47xx/timer-jz4740.c
new file mode 100644
index 0000000000..00c8abcdbd
--- /dev/null
+++ b/firmware/target/mips/ingenic_jz47xx/timer-jz4740.c
@@ -0,0 +1,28 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "config.h"
23#include "jz4740.h"
24
25
26bool __timer_set(long cycles, bool set);
27bool __timer_register(void);
28void __timer_unregister(void);
diff --git a/firmware/target/mips/ingenic_jz47xx/timer-target.h b/firmware/target/mips/ingenic_jz47xx/timer-target.h
new file mode 100644
index 0000000000..202f941ce1
--- /dev/null
+++ b/firmware/target/mips/ingenic_jz47xx/timer-target.h
@@ -0,0 +1,41 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2008 by Maurus Cuelenaere
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef __TIMER_H_
23#define __TIMER_H_
24
25#define TIMER_FREQ (27000000)
26
27bool __timer_set(long cycles, bool set);
28bool __timer_register(void);
29void __timer_unregister(void);
30
31#define __TIMER_SET(cycles, set) \
32 __timer_set(cycles, set)
33
34#define __TIMER_REGISTER(reg_prio, unregister_callback, cycles, \
35 int_prio, timer_callback) \
36 __timer_register()
37
38#define __TIMER_UNREGISTER(...) \
39 __timer_unregister()
40
41#endif /* __TIMER_H_ */