diff options
Diffstat (limited to 'firmware/target/mips/ingenic_jz47xx')
14 files changed, 1261 insertions, 0 deletions
diff --git a/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c b/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c new file mode 100755 index 0000000000..b907bb86df --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/ata-jz4740.c | |||
@@ -0,0 +1,40 @@ | |||
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 "ata.h" | ||
25 | |||
26 | int ata_read_sectors(IF_MV2(int drive,) unsigned long start, int count, void* buf) | ||
27 | { | ||
28 | (void)start; | ||
29 | (void)count; | ||
30 | (void)buf; | ||
31 | return 0; | ||
32 | } | ||
33 | |||
34 | int ata_write_sectors(IF_MV2(int drive,) unsigned long start, int count, const void* buf) | ||
35 | { | ||
36 | (void)start; | ||
37 | (void)count; | ||
38 | (void)buf; | ||
39 | return 0; | ||
40 | } | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/boot.lds b/firmware/target/mips/ingenic_jz47xx/boot.lds new file mode 100755 index 0000000000..9bc635afad --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/boot.lds | |||
@@ -0,0 +1,107 @@ | |||
1 | #include "config.h" | ||
2 | #undef mips | ||
3 | |||
4 | OUTPUT_FORMAT("elf32-tradlittlemips") | ||
5 | OUTPUT_ARCH(MIPS) | ||
6 | ENTRY(_start) | ||
7 | STARTUP(target/mips/ingenic_jz47xx/crt0.o) | ||
8 | |||
9 | #define DRAMSIZE (MEMORYSIZE * 0x100000) | ||
10 | |||
11 | #define DRAMORIG 0x80E00000 /* HACK */ | ||
12 | #define IRAMORIG 0x80000000 | ||
13 | #define IRAMSIZE 16K | ||
14 | |||
15 | MEMORY | ||
16 | { | ||
17 | DRAM : ORIGIN = DRAMORIG, LENGTH = DRAMSIZE | ||
18 | IRAM : ORIGIN = IRAMORIG, LENGTH = IRAMSIZE | ||
19 | } | ||
20 | |||
21 | SECTIONS | ||
22 | { | ||
23 | . = DRAMORIG; | ||
24 | |||
25 | .text : { | ||
26 | loadaddress = .; | ||
27 | _loadaddress = .; | ||
28 | *(.init.text); | ||
29 | *(.text*); | ||
30 | *(.glue_7); | ||
31 | *(.glue_7t); | ||
32 | . = ALIGN(0x4); | ||
33 | } > DRAM | ||
34 | |||
35 | . = ALIGN(4); | ||
36 | |||
37 | .rodata : | ||
38 | { | ||
39 | *(.rodata); /* problems without this, dunno why */ | ||
40 | *(.rodata*); | ||
41 | *(.rodata.str1.1); | ||
42 | *(.rodata.str1.4); | ||
43 | . = ALIGN(0x4); | ||
44 | |||
45 | /* Pseudo-allocate the copies of the data sections */ | ||
46 | _datacopy = .; | ||
47 | } > DRAM | ||
48 | |||
49 | . = ALIGN(4); | ||
50 | |||
51 | .data : { | ||
52 | *(.icode); | ||
53 | *(.irodata); | ||
54 | *(.idata); | ||
55 | *(.data*); | ||
56 | *(.scommon*); | ||
57 | *(.sdata*); | ||
58 | . = ALIGN(0x4); | ||
59 | _dataend = . ; | ||
60 | } > DRAM | ||
61 | |||
62 | . = ALIGN(4); | ||
63 | |||
64 | _gp = ALIGN(16); | ||
65 | .got : { | ||
66 | *(.got*) | ||
67 | }> DRAM | ||
68 | |||
69 | . = ALIGN(4); | ||
70 | |||
71 | .stack : | ||
72 | { | ||
73 | *(.stack) | ||
74 | _stackbegin = .; | ||
75 | stackbegin = .; | ||
76 | . += 0x2000; | ||
77 | _stackend = .; | ||
78 | stackend = .; | ||
79 | } > DRAM | ||
80 | |||
81 | . = ALIGN(4); | ||
82 | |||
83 | .bss : | ||
84 | { | ||
85 | _edata = .; | ||
86 | *(.sbss*); | ||
87 | *(.bss*); | ||
88 | *(.ibss); | ||
89 | *(COMMON) | ||
90 | _end = .; | ||
91 | } > DRAM | ||
92 | |||
93 | . = ALIGN(4); | ||
94 | |||
95 | .vectors IRAMORIG : | ||
96 | { | ||
97 | _vectorsstart = .; | ||
98 | KEEP(*(.resetvectors)); | ||
99 | *(.resetvectors); | ||
100 | KEEP(*(.vectors)); | ||
101 | *(.vectors); | ||
102 | _vectorsend = .; | ||
103 | } AT > DRAM | ||
104 | _vectorscopy = LOADADDR(.vectors); | ||
105 | |||
106 | . = ALIGN(4); | ||
107 | } | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/crt0.S b/firmware/target/mips/ingenic_jz47xx/crt0.S new file mode 100755 index 0000000000..6ac9ad71ab --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/crt0.S | |||
@@ -0,0 +1,246 @@ | |||
1 | /* | ||
2 | * init.S | ||
3 | * | ||
4 | * Initialization code for JzRISC. | ||
5 | * | ||
6 | * Author: Seeger Chin | ||
7 | * e-mail: seeger.chin@gmail.com | ||
8 | * | ||
9 | * Copyright (C) 2006 Ingenic Semiconductor Inc. | ||
10 | * | ||
11 | * This program is free software; you can redistribute it and/or modify | ||
12 | * it under the terms of the GNU General Public License version 2 as | ||
13 | * published by the Free Software Foundation. | ||
14 | * | ||
15 | */ | ||
16 | |||
17 | #include "config.h" | ||
18 | #include "mips.h" | ||
19 | |||
20 | .text | ||
21 | |||
22 | .set mips3 | ||
23 | |||
24 | .extern main | ||
25 | |||
26 | .global _start | ||
27 | #ifdef BOOTLOADER | ||
28 | .section .init.text,"ax",%progbits | ||
29 | #else | ||
30 | .section .resetvectors,"ax",%progbits | ||
31 | #endif | ||
32 | .set noreorder | ||
33 | .set noat | ||
34 | |||
35 | #ifdef BOOTLOADER | ||
36 | .word 0 /* HACK */ | ||
37 | .word 0 /* HACK */ | ||
38 | #endif | ||
39 | _start: | ||
40 | la ra, _start | ||
41 | //---------------------------------------------------- | ||
42 | // init cp0 registers. | ||
43 | //---------------------------------------------------- | ||
44 | mtc0 zero, C0_WATCHLO | ||
45 | mtc0 zero, C0_WATCHHI | ||
46 | |||
47 | li t0, (M_StatusBEV | M_StatusIM7 | M_StatusIM6 \ | ||
48 | | M_StatusIM5 | M_StatusIM4 | M_StatusIM3 \ | ||
49 | | M_StatusIM2 | M_StatusERL) | ||
50 | // BEV = Enable Boot Exception Vectors | ||
51 | // IMx = Interrupt mask | ||
52 | // ERL = Denotes error level | ||
53 | mtc0 t0, C0_STATUS | ||
54 | |||
55 | li t1, M_CauseIV | ||
56 | mtc0 t1, C0_CAUSE | ||
57 | |||
58 | //---------------------------------------------------- | ||
59 | // init caches, assumes a 4way*128set*32byte i/d cache | ||
60 | //---------------------------------------------------- | ||
61 | li t0, 3 // enable cache for kseg0 accesses | ||
62 | mtc0 t0, C0_CONFIG // CONFIG reg | ||
63 | la t0, 0x80000000 // an idx op should use a unmappable address | ||
64 | ori t1, t0, 0x4000 // 16kB cache | ||
65 | mtc0 zero, C0_TAGLO // TAGLO reg | ||
66 | mtc0 zero, C0_TAGHI // TAGHI reg | ||
67 | |||
68 | _init_cache_loop: | ||
69 | cache 0x8, 0(t0) // index store icache tag | ||
70 | cache 0x9, 0(t0) // index store dcache tag | ||
71 | bne t0, t1, _init_cache_loop | ||
72 | addiu t0, t0, 0x20 // 32 bytes per cache line | ||
73 | nop | ||
74 | |||
75 | //---------------------------------------------------- | ||
76 | // Invalidate BTB | ||
77 | //---------------------------------------------------- | ||
78 | mfc0 t0, C0_CONFIG | ||
79 | nop | ||
80 | ori t0, 2 | ||
81 | mtc0 t0, C0_CONFIG | ||
82 | nop | ||
83 | |||
84 | //---------------------------------------------------- | ||
85 | // setup stack, jump to C code | ||
86 | //---------------------------------------------------- | ||
87 | la sp, stackend | ||
88 | la t0, stackbegin | ||
89 | li t1, 0xDEADBEEF | ||
90 | |||
91 | _init_stack_loop: | ||
92 | sw t1, 0(t0) | ||
93 | bne t0, sp, _init_stack_loop | ||
94 | addiu t0, t0, 4 | ||
95 | |||
96 | la t0, main | ||
97 | jr t0 | ||
98 | nop | ||
99 | |||
100 | |||
101 | #ifndef BOOTLOADER | ||
102 | .section .vectors,"ax",%progbits | ||
103 | #endif | ||
104 | .extern exception_handler | ||
105 | .global except_common_entry | ||
106 | .type except_common_entry,@function | ||
107 | except_common_entry: | ||
108 | la k0, exception_handler | ||
109 | jr k0 | ||
110 | nop | ||
111 | nop | ||
112 | nop | ||
113 | |||
114 | .extern _int | ||
115 | .extern _exception | ||
116 | .global exception_handler | ||
117 | .type exception_handler,@function | ||
118 | .set noreorder | ||
119 | exception_handler: | ||
120 | |||
121 | |||
122 | addiu sp, -0x80 # Add Immediate Unsigned | ||
123 | sw ra, 0(sp) # Store Word | ||
124 | sw fp, 4(sp) # Store Word | ||
125 | sw gp, 8(sp) # Store Word | ||
126 | sw t9, 0xC(sp) # Store Word | ||
127 | sw t8, 0x10(sp) # Store Word | ||
128 | sw s7, 0x14(sp) # Store Word | ||
129 | sw s6, 0x18(sp) # Store Word | ||
130 | sw s5, 0x1C(sp) # Store Word | ||
131 | sw s4, 0x20(sp) # Store Word | ||
132 | sw s3, 0x24(sp) # Store Word | ||
133 | sw s2, 0x28(sp) # Store Word | ||
134 | sw s1, 0x2C(sp) # Store Word | ||
135 | sw s0, 0x30(sp) # Store Word | ||
136 | sw t7, 0x34(sp) # Store Word | ||
137 | sw t6, 0x38(sp) # Store Word | ||
138 | sw t5, 0x3C(sp) # Store Word | ||
139 | sw t4, 0x40(sp) # Store Word | ||
140 | sw t3, 0x44(sp) # Store Word | ||
141 | sw t2, 0x48(sp) # Store Word | ||
142 | sw t1, 0x4C(sp) # Store Word | ||
143 | sw t0, 0x50(sp) # Store Word | ||
144 | sw a3, 0x54(sp) # Store Word | ||
145 | sw a2, 0x58(sp) # Store Word | ||
146 | sw a1, 0x5C(sp) # Store Word | ||
147 | sw a0, 0x60(sp) # Store Word | ||
148 | sw v1, 0x64(sp) # Store Word | ||
149 | sw v0, 0x68(sp) # Store Word | ||
150 | sw $1, 0x6C(sp) # Store Word | ||
151 | mflo t0 # Move F LO | ||
152 | nop | ||
153 | sw t0, 0x70(sp) # Store Word | ||
154 | mfhi t0 # Move F HI | ||
155 | nop | ||
156 | sw t0, 0x74(sp) # Store Word | ||
157 | mfc0 t0, C0_STATUS # Status register | ||
158 | sll zero, 1 # Shift Left Logical | ||
159 | sll zero, 1 # Shift Left Logical | ||
160 | sll zero, 1 # Shift Left Logical | ||
161 | sll zero, 1 # Shift Left Logical | ||
162 | sw t0, 0x78(sp) # Store Word | ||
163 | mfc0 t0, C0_EPC # Exception Program Counter | ||
164 | sll zero, 1 # Shift Left Logical | ||
165 | sll zero, 1 # Shift Left Logical | ||
166 | sll zero, 1 # Shift Left Logical | ||
167 | sll zero, 1 # Shift Left Logical | ||
168 | sw t0, 0x7C(sp) # Store Word | ||
169 | li k1, 0x7C # Load Immediate | ||
170 | mfc0 k0, C0_CAUSE # C0_CAUSE of last exception | ||
171 | and k0, k1 # AND | ||
172 | beq zero, k0, _int # Branch on Equal | ||
173 | nop | ||
174 | la k0, _exception | ||
175 | jr k0 | ||
176 | nop | ||
177 | |||
178 | .global _int | ||
179 | .type _int,@function | ||
180 | _int: | ||
181 | jal intr_handler # Jump And Link | ||
182 | nop | ||
183 | lw ra, 0(sp) # Load Word | ||
184 | lw fp, 4(sp) # Load Word | ||
185 | sw gp, 8(sp) # Store Word | ||
186 | lw t9, 0xC(sp) # Load Word | ||
187 | lw t8, 0x10(sp) # Load Word | ||
188 | lw s7, 0x14(sp) # Load Word | ||
189 | lw s6, 0x18(sp) # Load Word | ||
190 | lw s5, 0x1C(sp) # Load Word | ||
191 | lw s4, 0x20(sp) # Load Word | ||
192 | lw s3, 0x24(sp) # Load Word | ||
193 | lw s2, 0x28(sp) # Load Word | ||
194 | lw s1, 0x2C(sp) # Load Word | ||
195 | lw s0, 0x30(sp) # Load Word | ||
196 | lw t7, 0x34(sp) # Load Word | ||
197 | lw t6, 0x38(sp) # Load Word | ||
198 | lw t5, 0x3C(sp) # Load Word | ||
199 | lw t4, 0x40(sp) # Load Word | ||
200 | lw t3, 0x44(sp) # Load Word | ||
201 | lw t2, 0x48(sp) # Load Word | ||
202 | lw t1, 0x4C(sp) # Load Word | ||
203 | lw t0, 0x50(sp) # Load Word | ||
204 | lw a3, 0x54(sp) # Load Word | ||
205 | lw a2, 0x58(sp) # Load Word | ||
206 | lw a1, 0x5C(sp) # Load Word | ||
207 | lw a0, 0x60(sp) # Load Word | ||
208 | lw v1, 0x64(sp) # Load Word | ||
209 | lw v0, 0x68(sp) # Load Word | ||
210 | lw v1, 0x6C(sp) # Load Word | ||
211 | lw k0, 0x70(sp) # Load Word | ||
212 | mtlo k0 # Move To LO | ||
213 | nop | ||
214 | lw k0, 0x74(sp) # Load Word | ||
215 | mthi k0 # Move To HI | ||
216 | nop | ||
217 | lw k0, 0x78(sp) # Load Word | ||
218 | nop | ||
219 | mtc0 k0, C0_STATUS # Status register | ||
220 | sll zero, 1 # Shift Left Logical | ||
221 | sll zero, 1 # Shift Left Logical | ||
222 | sll zero, 1 # Shift Left Logical | ||
223 | sll zero, 1 # Shift Left Logical | ||
224 | lw k0, 0x7C(sp) # Load Word | ||
225 | nop | ||
226 | mtc0 k0, C0_EPC # Exception Program Counter | ||
227 | sll zero, 1 # Shift Left Logical | ||
228 | sll zero, 1 # Shift Left Logical | ||
229 | sll zero, 1 # Shift Left Logical | ||
230 | sll zero, 1 # Shift Left Logical | ||
231 | addiu sp, 0x80 # Add Immediate Unsigned | ||
232 | eret # Exception Return | ||
233 | nop | ||
234 | |||
235 | .extern _except_handler | ||
236 | .global _exception | ||
237 | .type _exception,@function | ||
238 | _exception: | ||
239 | move a0, sp | ||
240 | mfc0 a1, C0_CAUSE # C0_CAUSE of last exception | ||
241 | mfc0 a2, C0_EPC # Exception Program Counter | ||
242 | la k0, except_handler # Load Address | ||
243 | jr k0 # Jump Register | ||
244 | nop | ||
245 | |||
246 | .set reorder | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c new file mode 100755 index 0000000000..429178aeee --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/lcd-jz4740.c | |||
@@ -0,0 +1,94 @@ | |||
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 "lcd.h" | ||
25 | #include "lcd-target.h" | ||
26 | |||
27 | static volatile bool _lcd_on = false; | ||
28 | static volatile bool lcd_poweroff = false; | ||
29 | |||
30 | /* LCD init */ | ||
31 | void lcd_init_device(void) | ||
32 | { | ||
33 | lcd_init_controller(); | ||
34 | _lcd_on = true; | ||
35 | } | ||
36 | |||
37 | void lcd_enable(bool state) | ||
38 | { | ||
39 | if(state) | ||
40 | lcd_on(); | ||
41 | else | ||
42 | lcd_off(); | ||
43 | |||
44 | _lcd_on = state; | ||
45 | } | ||
46 | |||
47 | bool lcd_enabled(void) | ||
48 | { | ||
49 | return _lcd_on; | ||
50 | } | ||
51 | |||
52 | #define LCDADDR(x, y) ((unsigned int)&lcd_framebuffer[(y)][(x)]) | ||
53 | #define LCD_UNCACHED(addr) ((unsigned int)(addr) | 0xA0000000) | ||
54 | |||
55 | /* Update a fraction of the display. */ | ||
56 | void lcd_update_rect(int x, int y, int width, int height) | ||
57 | { | ||
58 | /* HACKY... */ | ||
59 | x=0; y=0; width=400; height=240; | ||
60 | lcd_set_target(x, y, width-1, height-1); | ||
61 | |||
62 | REG_DMAC_DCCSR(0) = 0; | ||
63 | REG_DMAC_DRSR(0) = DMAC_DRSR_RS_SLCD; /* source = SLCD */ | ||
64 | REG_DMAC_DSAR(0) = LCDADDR(x,y) & 0x1FFFFFFF; | ||
65 | #if 0 | ||
66 | REG_DMAC_DTAR(0) = LCD_UNCACHED(SLCD_FIFO); | ||
67 | #else | ||
68 | REG_DMAC_DTAR(0) = 0x130500B0; /* SLCD_FIFO */ | ||
69 | #endif | ||
70 | REG_DMAC_DTCR(0) = (width*height); | ||
71 | |||
72 | REG_DMAC_DCMD(0) = (DMAC_DCMD_SAI | DMAC_DCMD_RDIL_IGN | DMAC_DCMD_SWDH_32 /* (1 << 23) | (0 << 16) | (0 << 14) */ | ||
73 | | DMAC_DCMD_DWDH_16 | DMAC_DCMD_DS_16BIT); /* | (2 << 12) | (3 << 8) */ | ||
74 | REG_DMAC_DCCSR(0) = (DMAC_DCCSR_NDES | DMAC_DCCSR_EN); /* (1 << 31) | (1 << 0) */ | ||
75 | |||
76 | jz_flush_icache(); | ||
77 | |||
78 | REG_DMAC_DMACR = DMAC_DMACR_DMAE; | ||
79 | |||
80 | while( !(REG_DMAC_DCCSR(0) & DMAC_DCCSR_TT) ) | ||
81 | asm("nop"); | ||
82 | |||
83 | //REG_DMAC_DCCSR(0) &= ~DMAC_DCCSR_TT; | ||
84 | } | ||
85 | |||
86 | /* Update the display. | ||
87 | This must be called after all other LCD functions that change the display. */ | ||
88 | void lcd_update(void) | ||
89 | { | ||
90 | if (!_lcd_on) | ||
91 | return; | ||
92 | |||
93 | lcd_update_rect(0, 0, LCD_WIDTH, LCD_HEIGHT); | ||
94 | } | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/adc-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/adc-target.h new file mode 100755 index 0000000000..e74f008a3e --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/adc-target.h | |||
@@ -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 | #ifndef _ADC_TARGET_H_ | ||
22 | #define _ADC_TARGET_H_ | ||
23 | |||
24 | #define NUM_ADC_CHANNELS 4 | ||
25 | |||
26 | #define ADC_BUTTONS 0 | ||
27 | |||
28 | #endif /* _ADC_TARGET_H_ */ | ||
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 new file mode 100755 index 0000000000..9deab7712a --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-onda_vx747.c | |||
@@ -0,0 +1,80 @@ | |||
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 "backlight-target.h" | ||
25 | |||
26 | #define GPIO_PWM 123 | ||
27 | #define PWM_CHN 7 | ||
28 | #define PWM_FULL 101 | ||
29 | |||
30 | static void set_backlight(int unk, int val) | ||
31 | { | ||
32 | if(val == 0) | ||
33 | __gpio_as_pwm7(); | ||
34 | else | ||
35 | { | ||
36 | REG_TCU_TCSR(7) |= 2; | ||
37 | REG_TCU_TCSR(7) &= ~0x100; | ||
38 | int tmp; | ||
39 | tmp = (unk/2 + __cpm_get_rtcclk()) / unk; | ||
40 | if(tmp > 0xFFFF) | ||
41 | tmp = 0xFFFF; | ||
42 | |||
43 | __tcu_set_half_data(7, (tmp * unk * 1374389535) >> 5); | ||
44 | __tcu_set_full_data(7, tmp); | ||
45 | |||
46 | REG_TCU_TSCR = (1 << 7); | ||
47 | REG_TCU_TESR = (1 << 7); | ||
48 | |||
49 | __tcu_enable_pwm_output(7); | ||
50 | } | ||
51 | __tcu_set_count(7, 0); | ||
52 | } | ||
53 | |||
54 | bool _backlight_init(void) | ||
55 | { | ||
56 | __gpio_as_pwm7(); | ||
57 | |||
58 | __tcu_stop_counter(7); | ||
59 | __tcu_disable_pwm_output(7); | ||
60 | |||
61 | set_backlight(300, 7); | ||
62 | |||
63 | return true; | ||
64 | } | ||
65 | void _backlight_on(void) | ||
66 | { | ||
67 | set_backlight(300, 7); | ||
68 | } | ||
69 | void _backlight_off(void) | ||
70 | { | ||
71 | set_backlight(300, 0); | ||
72 | } | ||
73 | |||
74 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
75 | void _backlight_set_brightness(int brightness) | ||
76 | { | ||
77 | (void)brightness; | ||
78 | return; | ||
79 | } | ||
80 | #endif | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h new file mode 100755 index 0000000000..4170f96cc0 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/backlight-target.h | |||
@@ -0,0 +1,37 @@ | |||
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 | #ifndef BACKLIGHT_TARGET_H | ||
22 | #define BACKLIGHT_TARGET_H | ||
23 | |||
24 | #ifdef BOOTLOADER | ||
25 | #define BACKLIGHT_DRIVER_CLOSE | ||
26 | /* Force the whole driver to be built */ | ||
27 | #define BACKLIGHT_FULL_INIT | ||
28 | #endif | ||
29 | |||
30 | #include <stdbool.h> | ||
31 | |||
32 | bool _backlight_init(void); | ||
33 | void _backlight_on(void); | ||
34 | void _backlight_off(void); | ||
35 | void _backlight_set_brightness(int brightness); | ||
36 | |||
37 | #endif /* BACKLIGHT_TARGET_H */ | ||
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 new file mode 100755 index 0000000000..e42325bcb3 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-onda_vx747.c | |||
@@ -0,0 +1,123 @@ | |||
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 | bool button_hold(void) | ||
43 | { | ||
44 | return (REG_GPIO_PXPIN(3) ^ BTN_HOLD ? 1 : 0); | ||
45 | } | ||
46 | |||
47 | void button_init_device(void) | ||
48 | { | ||
49 | REG_SADC_ENA = 0; | ||
50 | REG_SADC_STATE &= (~REG_SADC_STATE); | ||
51 | REG_SADC_CTRL = 0x1f; | ||
52 | |||
53 | __cpm_start_sadc(); | ||
54 | REG_SADC_CFG = SADC_CFG_INIT; | ||
55 | |||
56 | REG_SADC_SAMETIME = 1; | ||
57 | REG_SADC_WAITTIME = 1000; //per 100 HZ | ||
58 | REG_SADC_STATE &= (~REG_SADC_STATE); | ||
59 | REG_SADC_CTRL &= (~(SADC_CTRL_PENDM | SADC_CTRL_TSRDYM)); | ||
60 | REG_SADC_ENA = SADC_ENA_TSEN; // | REG_SADC_ENA;//SADC_ENA_TSEN | SADC_ENA_PBATEN | SADC_ENA_SADCINEN; | ||
61 | } | ||
62 | |||
63 | static int touch_to_pixels(short x, short y) | ||
64 | { | ||
65 | /* X:300 -> 3800 Y:300->3900 */ | ||
66 | x -= 300; | ||
67 | y -= 300; | ||
68 | |||
69 | x /= 3200 / LCD_WIDTH; | ||
70 | y /= 3600 / LCD_HEIGHT; | ||
71 | |||
72 | return (x << 16) | y; | ||
73 | } | ||
74 | |||
75 | int button_read_device(int *data) | ||
76 | { | ||
77 | unsigned int key = ~REG_GPIO_PXPIN(3); | ||
78 | int ret = 0; | ||
79 | if(key & BTN_MASK) | ||
80 | { | ||
81 | if(key & BTN_VOL_DOWN) | ||
82 | ret |= BUTTON_VOL_DOWN; | ||
83 | if(key & BTN_VOL_UP) | ||
84 | ret |= BUTTON_VOL_UP; | ||
85 | if(key & BTN_MENU) | ||
86 | ret |= BUTTON_MENU; | ||
87 | if(key & BTN_OFF) | ||
88 | ret |= BUTTON_POWER; | ||
89 | } | ||
90 | |||
91 | if(REG_SADC_STATE & (SADC_CTRL_TSRDYM|SADC_STATE_PEND)) | ||
92 | { | ||
93 | if(REG_SADC_STATE & SADC_CTRL_PENDM) | ||
94 | { | ||
95 | REG_SADC_CTRL &= (~(SADC_CTRL_PENUM | SADC_CTRL_TSRDYM)); | ||
96 | REG_SADC_CTRL |= (SADC_CTRL_PENDM); | ||
97 | unsigned int dat; | ||
98 | unsigned short xData,yData; | ||
99 | short tsz1Data,tsz2Data; | ||
100 | |||
101 | dat = REG_SADC_TSDAT; | ||
102 | |||
103 | xData = (dat >> 0) & 0xfff; | ||
104 | yData = (dat >> 16) & 0xfff; | ||
105 | |||
106 | dat = REG_SADC_TSDAT; | ||
107 | tsz1Data = (dat >> 0) & 0xfff; | ||
108 | tsz2Data = (dat >> 16) & 0xfff; | ||
109 | |||
110 | *data = touch_to_pixels(xData, yData); | ||
111 | |||
112 | tsz1Data = tsz2Data - tsz1Data; | ||
113 | } | ||
114 | REG_SADC_STATE = 0; | ||
115 | //__intc_unmask_irq(IRQ_SADC); | ||
116 | } | ||
117 | |||
118 | return ret; | ||
119 | } | ||
120 | void button_set_touch_available(void) | ||
121 | { | ||
122 | return; | ||
123 | } | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-target.h new file mode 100755 index 0000000000..23ce386cb1 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/button-target.h | |||
@@ -0,0 +1,69 @@ | |||
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 | #ifndef BUTTON_TARGET_H | ||
22 | #define BUTTON_TARGET_H | ||
23 | |||
24 | |||
25 | #include <stdbool.h> | ||
26 | #include "config.h" | ||
27 | |||
28 | #define HAS_BUTTON_HOLD | ||
29 | |||
30 | bool button_hold(void); | ||
31 | void button_init_device(void); | ||
32 | int button_read_device(int *data); | ||
33 | void button_set_touch_available(void); | ||
34 | |||
35 | /* Main unit's buttons */ | ||
36 | #define BUTTON_POWER 0x00000001 | ||
37 | #define BUTTON_VOL_UP 0x00000002 | ||
38 | #define BUTTON_VOL_DOWN 0x00000004 | ||
39 | #define BUTTON_MENU 0x00000008 | ||
40 | |||
41 | /* Compatibility hacks for flipping. Needs a somewhat better fix. */ | ||
42 | #define BUTTON_LEFT BUTTON_MIDLEFT | ||
43 | #define BUTTON_RIGHT BUTTON_MIDRIGHT | ||
44 | #define BUTTON_UP BUTTON_TOPMIDDLE | ||
45 | #define BUTTON_DOWN BUTTON_BOTTOMMIDDLE | ||
46 | |||
47 | /* Touchpad Screen Area Buttons */ | ||
48 | #define BUTTON_TOPLEFT 0x00000010 | ||
49 | #define BUTTON_TOPMIDDLE 0x00000020 | ||
50 | #define BUTTON_TOPRIGHT 0x00000040 | ||
51 | #define BUTTON_MIDLEFT 0x00000080 | ||
52 | #define BUTTON_CENTER 0x00000100 | ||
53 | #define BUTTON_MIDRIGHT 0x00000200 | ||
54 | #define BUTTON_BOTTOMLEFT 0x00000400 | ||
55 | #define BUTTON_BOTTOMMIDDLE 0x00000800 | ||
56 | #define BUTTON_BOTTOMRIGHT 0x00001000 | ||
57 | |||
58 | #define BUTTON_TOUCH 0x00002000 | ||
59 | |||
60 | #define BUTTON_MAIN 0x3FFF | ||
61 | |||
62 | /* No remote */ | ||
63 | #define BUTTON_REMOTE 0 | ||
64 | |||
65 | /* Software power-off */ | ||
66 | #define POWEROFF_BUTTON BUTTON_POWER | ||
67 | #define POWEROFF_COUNT 10 | ||
68 | |||
69 | #endif /* BUTTON_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 new file mode 100755 index 0000000000..d46cee6884 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-onda_vx747.c | |||
@@ -0,0 +1,201 @@ | |||
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 "lcd-target.h" | ||
25 | |||
26 | #define PIN_CS_N (32*1+17) /* Chip select */ | ||
27 | #define PIN_RESET_N (32*1+18) /* Reset */ | ||
28 | |||
29 | #define my__gpio_as_lcd_16bit() \ | ||
30 | do { \ | ||
31 | REG_GPIO_PXFUNS(2) = 0x001cffff; \ | ||
32 | REG_GPIO_PXSELC(2) = 0x001cffff; \ | ||
33 | REG_GPIO_PXPES(2) = 0x001cffff; \ | ||
34 | } while (0) | ||
35 | |||
36 | |||
37 | #define SLEEP(x) for(i=0; i<x; i++) asm("nop"); asm("nop"); | ||
38 | #define DELAY SLEEP(700000); | ||
39 | static void _display_pin_init(void) | ||
40 | { | ||
41 | int i; | ||
42 | my__gpio_as_lcd_16bit(); | ||
43 | __gpio_as_output(PIN_CS_N); | ||
44 | __gpio_as_output(PIN_RESET_N); | ||
45 | __gpio_clear_pin(PIN_CS_N); | ||
46 | |||
47 | __gpio_set_pin(PIN_RESET_N); | ||
48 | DELAY; | ||
49 | __gpio_clear_pin(PIN_RESET_N); | ||
50 | DELAY; | ||
51 | __gpio_set_pin(PIN_RESET_N); | ||
52 | DELAY; | ||
53 | } | ||
54 | |||
55 | #define WAIT_ON_SLCD while(REG_SLCD_STATE & SLCD_STATE_BUSY); | ||
56 | #define SLCD_SET_DATA(x) WAIT_ON_SLCD; REG_SLCD_DATA = (x) | SLCD_DATA_RS_DATA; | ||
57 | #define SLCD_SET_COMMAND(x) WAIT_ON_SLCD; REG_SLCD_DATA = (x) | SLCD_DATA_RS_COMMAND; | ||
58 | #define SLCD_SEND_COMMAND(cmd,val) SLCD_SET_COMMAND(cmd); SLCD_SET_DATA(val); | ||
59 | static void _display_on(void) | ||
60 | { | ||
61 | int i; | ||
62 | |||
63 | SLCD_SEND_COMMAND(0x600, 1); | ||
64 | SLEEP(700000); | ||
65 | SLCD_SEND_COMMAND(0x600, 0); | ||
66 | SLEEP(700000); | ||
67 | SLCD_SEND_COMMAND(0x606, 0); | ||
68 | |||
69 | SLCD_SEND_COMMAND(1, 0x100); | ||
70 | SLCD_SEND_COMMAND(2, 0x100); | ||
71 | SLCD_SEND_COMMAND(3, 0x1028); | ||
72 | SLCD_SEND_COMMAND(8, 0x503); | ||
73 | SLCD_SEND_COMMAND(9, 1); | ||
74 | SLCD_SEND_COMMAND(0xB, 0x10); | ||
75 | SLCD_SEND_COMMAND(0xC, 0); | ||
76 | SLCD_SEND_COMMAND(0xF, 0); | ||
77 | SLCD_SEND_COMMAND(7, 1); | ||
78 | SLCD_SEND_COMMAND(0x10, 0x12); | ||
79 | SLCD_SEND_COMMAND(0x11, 0x202); | ||
80 | SLCD_SEND_COMMAND(0x12, 0x300); | ||
81 | SLCD_SEND_COMMAND(0x20, 0x21e); | ||
82 | SLCD_SEND_COMMAND(0x21, 0x202); | ||
83 | SLCD_SEND_COMMAND(0x22, 0x100); | ||
84 | SLCD_SEND_COMMAND(0x90, 0x8000); | ||
85 | SLCD_SEND_COMMAND(0x100, 0x16b0); | ||
86 | SLCD_SEND_COMMAND(0x101, 0x147); | ||
87 | SLCD_SEND_COMMAND(0x102, 0x1bd); | ||
88 | SLCD_SEND_COMMAND(0x103, 0x2f00); | ||
89 | SLCD_SEND_COMMAND(0x107, 0); | ||
90 | SLCD_SEND_COMMAND(0x110, 1); | ||
91 | SLCD_SEND_COMMAND(0x200, 0); /* set cursor at x_start */ | ||
92 | SLCD_SEND_COMMAND(0x201, 0); /* set cursor at y_start */ | ||
93 | SLCD_SEND_COMMAND(0x210, 0); /* y_start*/ | ||
94 | SLCD_SEND_COMMAND(0x211, 239); /* y_end */ | ||
95 | SLCD_SEND_COMMAND(0x212, 0); /* x_start */ | ||
96 | SLCD_SEND_COMMAND(0x213, 399); /* x_end */ | ||
97 | SLCD_SEND_COMMAND(0x280, 0); | ||
98 | SLCD_SEND_COMMAND(0x281, 6); | ||
99 | SLCD_SEND_COMMAND(0x282, 0); | ||
100 | SLCD_SEND_COMMAND(0x300, 0x101); | ||
101 | SLCD_SEND_COMMAND(0x301, 0xb27); | ||
102 | SLCD_SEND_COMMAND(0x302, 0x132a); | ||
103 | SLCD_SEND_COMMAND(0x303, 0x2a13); | ||
104 | SLCD_SEND_COMMAND(0x304, 0x270b); | ||
105 | SLCD_SEND_COMMAND(0x305, 0x101); | ||
106 | SLCD_SEND_COMMAND(0x306, 0x1205); | ||
107 | SLCD_SEND_COMMAND(0x307, 0x512); | ||
108 | SLCD_SEND_COMMAND(0x308, 5); | ||
109 | SLCD_SEND_COMMAND(0x309, 3); | ||
110 | SLCD_SEND_COMMAND(0x30a, 0xf04); | ||
111 | SLCD_SEND_COMMAND(0x30b, 0xf00); | ||
112 | SLCD_SEND_COMMAND(0x30c, 0xf); | ||
113 | SLCD_SEND_COMMAND(0x30d, 0x40f); | ||
114 | SLCD_SEND_COMMAND(0x30e, 0x300); | ||
115 | SLCD_SEND_COMMAND(0x30f, 0x500); | ||
116 | SLCD_SEND_COMMAND(0x400, 0x3100); | ||
117 | SLCD_SEND_COMMAND(0x401, 1); | ||
118 | SLCD_SEND_COMMAND(0x404, 0); | ||
119 | SLCD_SEND_COMMAND(0x500, 0); | ||
120 | SLCD_SEND_COMMAND(0x501, 0); | ||
121 | SLCD_SEND_COMMAND(0x502, 0); | ||
122 | SLCD_SEND_COMMAND(0x503, 0); | ||
123 | SLCD_SEND_COMMAND(0x504, 0); | ||
124 | SLCD_SEND_COMMAND(0x505, 0); | ||
125 | SLCD_SEND_COMMAND(0x606, 0); | ||
126 | SLCD_SEND_COMMAND(0x6f0, 0); | ||
127 | SLCD_SEND_COMMAND(0x7f0, 0x5420); | ||
128 | SLCD_SEND_COMMAND(0x7f3, 0x288a); | ||
129 | SLCD_SEND_COMMAND(0x7f4, 0x22); | ||
130 | SLCD_SEND_COMMAND(0x7f5, 1); | ||
131 | SLCD_SEND_COMMAND(0x7f0, 0); | ||
132 | |||
133 | SLCD_SEND_COMMAND(7, 0x173); | ||
134 | SLEEP(3500000); | ||
135 | SLCD_SEND_COMMAND(7, 0x171); | ||
136 | SLEEP(3500000); | ||
137 | SLCD_SEND_COMMAND(7, 0x173); | ||
138 | SLEEP(3500000); | ||
139 | } | ||
140 | |||
141 | static void _set_lcd_bus(void) | ||
142 | { | ||
143 | REG_LCD_CFG &= ~LCD_CFG_LCDPIN_MASK; | ||
144 | REG_LCD_CFG |= LCD_CFG_LCDPIN_SLCD; | ||
145 | |||
146 | REG_SLCD_CFG = (SLCD_CFG_BURST_8_WORD | SLCD_CFG_DWIDTH_16 | SLCD_CFG_CWIDTH_16BIT | ||
147 | | SLCD_CFG_CS_ACTIVE_LOW | SLCD_CFG_RS_CMD_LOW | SLCD_CFG_CLK_ACTIVE_FALLING | ||
148 | | SLCD_CFG_TYPE_PARALLEL); | ||
149 | |||
150 | REG_SLCD_CTRL = SLCD_CTRL_DMA_EN; | ||
151 | } | ||
152 | |||
153 | static void _set_lcd_clock(void) | ||
154 | { | ||
155 | unsigned int val; | ||
156 | int pll_div; | ||
157 | |||
158 | __cpm_stop_lcd(); | ||
159 | pll_div = ( REG_CPM_CPCCR & CPM_CPCCR_PCS ); /* clock source,0:pllout/2 1: pllout */ | ||
160 | pll_div = pll_div ? 1 : 2 ; | ||
161 | val = ( __cpm_get_pllout()/pll_div ) / 336000000; | ||
162 | val--; | ||
163 | if ( val > 0x1ff ) | ||
164 | { | ||
165 | //printf("CPM_LPCDR too large, set it to 0x1ff\n"); | ||
166 | val = 0x1ff; | ||
167 | } | ||
168 | __cpm_set_pixdiv(val); | ||
169 | __cpm_start_lcd(); | ||
170 | } | ||
171 | |||
172 | void lcd_init_controller(void) | ||
173 | { | ||
174 | int i; | ||
175 | _display_pin_init(); | ||
176 | _set_lcd_bus(); | ||
177 | _set_lcd_clock(); | ||
178 | SLEEP(1000); | ||
179 | _display_on(); | ||
180 | } | ||
181 | |||
182 | void lcd_set_target(short x, short y, short width, short height) | ||
183 | { | ||
184 | SLCD_SEND_COMMAND(0x210, y); /* y_start */ | ||
185 | SLCD_SEND_COMMAND(0x211, y+height); /* y_end */ | ||
186 | SLCD_SEND_COMMAND(0x212, x); /* x_start */ | ||
187 | SLCD_SEND_COMMAND(0x213, x+width); /* x_end */ | ||
188 | SLCD_SEND_COMMAND(0x200, x); /* set cursor at x_start */ | ||
189 | SLCD_SEND_COMMAND(0x201, y); /* set cursor at y_start */ | ||
190 | SLCD_SET_COMMAND(0x202); /* write data? */ | ||
191 | } | ||
192 | |||
193 | void lcd_on(void) | ||
194 | { | ||
195 | _display_on(); | ||
196 | } | ||
197 | |||
198 | void lcd_off(void) | ||
199 | { | ||
200 | return; | ||
201 | } | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-target.h new file mode 100755 index 0000000000..e643608d56 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/lcd-target.h | |||
@@ -0,0 +1,36 @@ | |||
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 | #ifndef LCD_TARGET_H | ||
22 | #define LCD_TARGET_H | ||
23 | |||
24 | #include <stdbool.h> | ||
25 | |||
26 | void lcd_enable(bool state); | ||
27 | bool lcd_enabled(void); | ||
28 | void lcd_init_device(void); | ||
29 | |||
30 | |||
31 | void lcd_init_controller(void); | ||
32 | void lcd_set_target(short x, short y, short width, short height); | ||
33 | void lcd_on(void); | ||
34 | void lcd_off(void); | ||
35 | |||
36 | #endif /* LCD_TARGET_H */ | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h b/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h new file mode 100755 index 0000000000..30893aaaa3 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/onda_vx747/usb-target.h | |||
@@ -0,0 +1,26 @@ | |||
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 | #ifndef USB_TARGET_H | ||
22 | #define USB_TARGET_H | ||
23 | |||
24 | void usb_init_device(void); | ||
25 | |||
26 | #endif | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/system-jz4740.c b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c new file mode 100755 index 0000000000..4963cac517 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/system-jz4740.c | |||
@@ -0,0 +1,71 @@ | |||
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 "mipsregs.h" | ||
25 | |||
26 | void intr_handler(void) | ||
27 | { | ||
28 | return; | ||
29 | } | ||
30 | |||
31 | void except_handler(void* stack_ptr, unsigned int cause, unsigned int epc) | ||
32 | { | ||
33 | (void)stack_ptr; | ||
34 | (void)cause; | ||
35 | (void)epc; | ||
36 | REG8(USB_REG_POWER) &= ~USB_POWER_SOFTCONN; | ||
37 | while(1); | ||
38 | } | ||
39 | |||
40 | void system_reboot(void) | ||
41 | { | ||
42 | while(1); | ||
43 | } | ||
44 | |||
45 | void cli(void) | ||
46 | { | ||
47 | register unsigned int t; | ||
48 | t = read_c0_status(); | ||
49 | t &= ~1; | ||
50 | write_c0_status(t); | ||
51 | } | ||
52 | |||
53 | unsigned int mips_get_sr(void) | ||
54 | { | ||
55 | unsigned int t = read_c0_status(); | ||
56 | return t; | ||
57 | } | ||
58 | |||
59 | void sti(void) | ||
60 | { | ||
61 | register unsigned int t; | ||
62 | t = read_c0_status(); | ||
63 | t |= 1; | ||
64 | t &= ~2; | ||
65 | write_c0_status(t); | ||
66 | } | ||
67 | |||
68 | void tick_start(unsigned int interval_in_ms) | ||
69 | { | ||
70 | (void)interval_in_ms; | ||
71 | } | ||
diff --git a/firmware/target/mips/ingenic_jz47xx/system-target.h b/firmware/target/mips/ingenic_jz47xx/system-target.h new file mode 100755 index 0000000000..2fff6423b9 --- /dev/null +++ b/firmware/target/mips/ingenic_jz47xx/system-target.h | |||
@@ -0,0 +1,103 @@ | |||
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 "mipsregs.h" | ||
25 | |||
26 | /* Core-level interrupt masking */ | ||
27 | |||
28 | /* This one returns the old status */ | ||
29 | #define HIGHEST_IRQ_LEVEL 0 | ||
30 | |||
31 | #define set_irq_level(status) \ | ||
32 | set_interrupt_status((status), ST0_IE) | ||
33 | #define set_fiq_status(status) \ | ||
34 | set_interrupt_status((status), ST0_IE) | ||
35 | |||
36 | static inline int set_interrupt_status(int status, int mask) | ||
37 | { | ||
38 | unsigned int res, oldstatus; | ||
39 | |||
40 | res = oldstatus = read_c0_status(); | ||
41 | res &= ~mask; | ||
42 | res |= (status & mask); | ||
43 | write_c0_status(res); | ||
44 | |||
45 | return oldstatus; | ||
46 | } | ||
47 | |||
48 | static inline void enable_interrupt(void) | ||
49 | { | ||
50 | /* Set IE bit */ | ||
51 | set_c0_status(ST0_IE); | ||
52 | } | ||
53 | |||
54 | static inline void disable_interrupt(void) | ||
55 | { | ||
56 | /* Clear IE bit */ | ||
57 | clear_c0_status(ST0_IE); | ||
58 | } | ||
59 | |||
60 | #define disable_irq() \ | ||
61 | disable_interrupt() | ||
62 | |||
63 | #define enable_irq() \ | ||
64 | enable_interrupt() | ||
65 | |||
66 | #define disable_fiq() \ | ||
67 | disable_interrupt() | ||
68 | |||
69 | #define enable_fiq() \ | ||
70 | enable_interrupt() | ||
71 | |||
72 | static inline int disable_interrupt_save(int mask) | ||
73 | { | ||
74 | unsigned int oldstatus; | ||
75 | |||
76 | oldstatus = read_c0_status(); | ||
77 | write_c0_status(oldstatus | mask); | ||
78 | |||
79 | return oldstatus; | ||
80 | } | ||
81 | |||
82 | #define disable_irq_save() \ | ||
83 | disable_interrupt_save(ST0_IE) | ||
84 | |||
85 | #define disable_fiq_save() \ | ||
86 | disable_interrupt_save(ST0_IE) | ||
87 | |||
88 | static inline void restore_interrupt(int status) | ||
89 | { | ||
90 | write_c0_status(status); | ||
91 | } | ||
92 | |||
93 | #define restore_irq(cpsr) \ | ||
94 | restore_interrupt(cpsr) | ||
95 | |||
96 | #define restore_fiq(cpsr) \ | ||
97 | restore_interrupt(cpsr) | ||
98 | |||
99 | #define swap16(x) (((x) & 0xff) << 8 | ((x) >> 8) & 0xff) | ||
100 | #define swap32(x) (((x) & 0xff) << 24 | ((x) & 0xff00) << 8 | ((x) & 0xff0000) >> 8 | ((x) >> 24) & 0xff) | ||
101 | |||
102 | void sti(void); | ||
103 | void cli(void); | ||