diff options
author | Marcoen Hirschberg <marcoen@gmail.com> | 2007-04-19 10:14:55 +0000 |
---|---|---|
committer | Marcoen Hirschberg <marcoen@gmail.com> | 2007-04-19 10:14:55 +0000 |
commit | 6ffbe3896b89ce86cccfe3b1f492f60e34d89603 (patch) | |
tree | b6b845fc876b0d98b793aefa906f5d5eab6993f5 /firmware/target/arm/pnx0101 | |
parent | 710a9ca194316d3a269a3c3dd2e603768da5a780 (diff) | |
download | rockbox-6ffbe3896b89ce86cccfe3b1f492f60e34d89603.tar.gz rockbox-6ffbe3896b89ce86cccfe3b1f492f60e34d89603.zip |
move the iriver ifp7xx and other pnx0101 related files together in the target tree
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13207 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/pnx0101')
-rw-r--r-- | firmware/target/arm/pnx0101/backlight-target.h | 26 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/crt0-pnx0101.S | 229 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c | 57 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/iriver-ifp7xx/adc-target.h | 29 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c | 33 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c | 89 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/iriver-ifp7xx/button-target.h | 56 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c | 208 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c | 85 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/iriver-ifp7xx/system-target.h | 34 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c | 50 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/system-pnx0101.c | 351 | ||||
-rw-r--r-- | firmware/target/arm/pnx0101/usb-target.h | 27 |
13 files changed, 1274 insertions, 0 deletions
diff --git a/firmware/target/arm/pnx0101/backlight-target.h b/firmware/target/arm/pnx0101/backlight-target.h new file mode 100644 index 0000000000..04236880ee --- /dev/null +++ b/firmware/target/arm/pnx0101/backlight-target.h | |||
@@ -0,0 +1,26 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: backlight-target.h 13136 2007-04-12 22:12:13Z amiconn $ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef BACKLIGHT_TARGET_H | ||
20 | #define BACKLIGHT_TARGET_H | ||
21 | |||
22 | #define __backlight_init() true | ||
23 | void __backlight_on(void); | ||
24 | void __backlight_off(void); | ||
25 | |||
26 | #endif | ||
diff --git a/firmware/target/arm/pnx0101/crt0-pnx0101.S b/firmware/target/arm/pnx0101/crt0-pnx0101.S new file mode 100644 index 0000000000..d11546edaa --- /dev/null +++ b/firmware/target/arm/pnx0101/crt0-pnx0101.S | |||
@@ -0,0 +1,229 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: crt0.S 11850 2006-12-29 02:49:12Z markun $ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #define ASM /* do not include structure definitions from pnx0101.h */ | ||
20 | |||
21 | #include "config.h" | ||
22 | #include "cpu.h" | ||
23 | |||
24 | .section .init.text,"ax",%progbits | ||
25 | |||
26 | .global start | ||
27 | start: | ||
28 | |||
29 | /* Arm bootloader and startup code based on startup.s from the iPodLinux loader | ||
30 | * | ||
31 | * Copyright (c) 2003, Daniel Palffy (dpalffy (at) rainstorm.org) | ||
32 | * Copyright (c) 2005, Bernard Leach <leachbj@bouncycastle.org> | ||
33 | * | ||
34 | */ | ||
35 | |||
36 | msr cpsr_c, #0xd3 /* enter supervisor mode, disable IRQ */ | ||
37 | |||
38 | #ifndef BOOTLOADER | ||
39 | #ifndef DEBUG | ||
40 | ldr r0, =0x80105000 | ||
41 | mov r1, #1 | ||
42 | str r1, [r0, #4] | ||
43 | mov r1, #0 | ||
44 | str r1, [r0, #4] | ||
45 | 1: ldr r1, [r0] | ||
46 | cmp r1, #0 | ||
47 | bne 1b | ||
48 | mov r1, #0x74 | ||
49 | str r1, [r0, #8] | ||
50 | mov r1, #2 | ||
51 | str r1, [r0, #0x18] | ||
52 | mov r1, #2 | ||
53 | str r1, [r0, #0x20] | ||
54 | mov r1, #82 | ||
55 | str r1, [r0, #0x28] | ||
56 | mov r1, #100 | ||
57 | str r1, [r0, #0x2c] | ||
58 | mov r1, #0x120 | ||
59 | str r1, [r0, #0x30] | ||
60 | mov r1, #6 | ||
61 | str r1, [r0, #4] | ||
62 | ldr r0, =1f | ||
63 | mov r15, r0 | ||
64 | 1: | ||
65 | #endif /* !DEBUG */ | ||
66 | |||
67 | #ifndef DEBUG | ||
68 | /* Copy exception handler code to address 0 */ | ||
69 | ldr r2, =_vectorsstart | ||
70 | ldr r3, =_vectorsend | ||
71 | ldr r4, =_vectorscopy | ||
72 | 1: | ||
73 | cmp r3, r2 | ||
74 | ldrhi r5, [r4], #4 | ||
75 | strhi r5, [r2], #4 | ||
76 | bhi 1b | ||
77 | #else | ||
78 | ldr r1, =vectors | ||
79 | ldr r0, =irq_handler | ||
80 | str r0, [r1, #24] | ||
81 | ldr r0, =fiq_handler | ||
82 | str r0, [r1, #28] | ||
83 | #endif | ||
84 | |||
85 | #ifndef STUB | ||
86 | /* Zero out IBSS */ | ||
87 | ldr r2, =_iedata | ||
88 | ldr r3, =_iend | ||
89 | mov r4, #0 | ||
90 | 1: | ||
91 | cmp r3, r2 | ||
92 | strhi r4, [r2], #4 | ||
93 | bhi 1b | ||
94 | |||
95 | /* Copy the IRAM */ | ||
96 | ldr r2, =_iramcopy | ||
97 | ldr r3, =_iramstart | ||
98 | ldr r4, =_iramend | ||
99 | 1: | ||
100 | cmp r4, r3 | ||
101 | ldrhi r5, [r2], #4 | ||
102 | strhi r5, [r3], #4 | ||
103 | bhi 1b | ||
104 | #endif /* !STUB */ | ||
105 | #endif /* !BOOTLOADER */ | ||
106 | |||
107 | /* Initialise bss section to zero */ | ||
108 | ldr r2, =_edata | ||
109 | ldr r3, =_end | ||
110 | mov r4, #0 | ||
111 | 1: | ||
112 | cmp r3, r2 | ||
113 | strhi r4, [r2], #4 | ||
114 | bhi 1b | ||
115 | |||
116 | /* Set up some stack and munge it with 0xdeadbeef */ | ||
117 | ldr sp, =stackend | ||
118 | mov r3, sp | ||
119 | ldr r2, =stackbegin | ||
120 | ldr r4, =0xdeadbeef | ||
121 | 1: | ||
122 | cmp r3, r2 | ||
123 | strhi r4, [r2], #4 | ||
124 | bhi 1b | ||
125 | |||
126 | /* Set up stack for IRQ mode */ | ||
127 | msr cpsr_c, #0xd2 | ||
128 | ldr sp, =irq_stack | ||
129 | /* Set up stack for FIQ mode */ | ||
130 | msr cpsr_c, #0xd1 | ||
131 | ldr sp, =fiq_stack | ||
132 | |||
133 | /* Let abort and undefined modes use IRQ stack */ | ||
134 | msr cpsr_c, #0xd7 | ||
135 | ldr sp, =irq_stack | ||
136 | msr cpsr_c, #0xdb | ||
137 | ldr sp, =irq_stack | ||
138 | /* Switch to supervisor mode */ | ||
139 | msr cpsr_c, #0xd3 | ||
140 | ldr sp, =stackend | ||
141 | bl main | ||
142 | /* main() should never return */ | ||
143 | |||
144 | /* Exception handlers. Will be copied to address 0 after memory remapping */ | ||
145 | .section .vectors,"aw" | ||
146 | ldr pc, [pc, #24] | ||
147 | ldr pc, [pc, #24] | ||
148 | ldr pc, [pc, #24] | ||
149 | ldr pc, [pc, #24] | ||
150 | ldr pc, [pc, #24] | ||
151 | ldr pc, [pc, #24] | ||
152 | ldr pc, [pc, #24] | ||
153 | ldr pc, [pc, #24] | ||
154 | |||
155 | /* Exception vectors */ | ||
156 | .global vectors | ||
157 | vectors: | ||
158 | .word start | ||
159 | .word undef_instr_handler | ||
160 | .word software_int_handler | ||
161 | .word prefetch_abort_handler | ||
162 | .word data_abort_handler | ||
163 | .word reserved_handler | ||
164 | .word irq_handler | ||
165 | .word fiq_handler | ||
166 | |||
167 | .text | ||
168 | |||
169 | #ifndef STUB | ||
170 | .global irq | ||
171 | .global fiq | ||
172 | .global UIE | ||
173 | #endif | ||
174 | |||
175 | /* All illegal exceptions call into UIE with exception address as first | ||
176 | parameter. This is calculated differently depending on which exception | ||
177 | we're in. Second parameter is exception number, used for a string lookup | ||
178 | in UIE. | ||
179 | */ | ||
180 | undef_instr_handler: | ||
181 | mov r0, lr | ||
182 | mov r1, #0 | ||
183 | b UIE | ||
184 | |||
185 | /* We run supervisor mode most of the time, and should never see a software | ||
186 | exception being thrown. Perhaps make it illegal and call UIE? | ||
187 | */ | ||
188 | software_int_handler: | ||
189 | reserved_handler: | ||
190 | movs pc, lr | ||
191 | |||
192 | prefetch_abort_handler: | ||
193 | sub r0, lr, #4 | ||
194 | mov r1, #1 | ||
195 | b UIE | ||
196 | |||
197 | fiq_handler: | ||
198 | @ Branch straight to FIQ handler in pcm_playback.c. This also handles the | ||
199 | @ the correct return sequence. | ||
200 | stmfd sp!, {r0-r7, r12, lr} | ||
201 | bl fiq | ||
202 | ldmfd sp!, {r0-r7, r12, lr} | ||
203 | subs pc, lr, #4 | ||
204 | |||
205 | data_abort_handler: | ||
206 | sub r0, lr, #8 | ||
207 | mov r1, #2 | ||
208 | b UIE | ||
209 | |||
210 | irq_handler: | ||
211 | #ifndef STUB | ||
212 | stmfd sp!, {r0-r11, r12, lr} | ||
213 | bl irq | ||
214 | ldmfd sp!, {r0-r11, r12, lr} | ||
215 | #endif | ||
216 | subs pc, lr, #4 | ||
217 | |||
218 | #ifdef STUB | ||
219 | UIE: | ||
220 | b UIE | ||
221 | #endif | ||
222 | |||
223 | /* 256 words of IRQ stack */ | ||
224 | .space 256*4 | ||
225 | irq_stack: | ||
226 | |||
227 | /* 256 words of FIQ stack */ | ||
228 | .space 256*4 | ||
229 | fiq_stack: | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c new file mode 100644 index 0000000000..79b1ad0fcb --- /dev/null +++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-ifp7xx.c | |||
@@ -0,0 +1,57 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include "system.h" | ||
22 | #include "kernel.h" | ||
23 | #include "thread.h" | ||
24 | #include "adc.h" | ||
25 | |||
26 | static unsigned short adcdata[NUM_ADC_CHANNELS]; | ||
27 | |||
28 | unsigned short adc_read(int channel) | ||
29 | { | ||
30 | return adcdata[channel]; | ||
31 | } | ||
32 | |||
33 | static void adc_tick(void) | ||
34 | { | ||
35 | if (ADCST & 0x10) { | ||
36 | adcdata[0] = ADCCH0 & 0x3ff; | ||
37 | adcdata[1] = ADCCH1 & 0x3ff; | ||
38 | adcdata[2] = ADCCH2 & 0x3ff; | ||
39 | adcdata[3] = ADCCH3 & 0x3ff; | ||
40 | adcdata[4] = ADCCH4 & 0x3ff; | ||
41 | ADCST = 0xa; | ||
42 | } | ||
43 | } | ||
44 | |||
45 | void adc_init(void) | ||
46 | { | ||
47 | ADCR24 = 0xaaaaa; | ||
48 | ADCR28 = 0; | ||
49 | ADCST = 2; | ||
50 | ADCST = 0xa; | ||
51 | |||
52 | while (!(ADCST & 0x10)); | ||
53 | adc_tick(); | ||
54 | |||
55 | tick_add_task(adc_tick); | ||
56 | } | ||
57 | |||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-target.h b/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-target.h new file mode 100644 index 0000000000..8e5e6edbc5 --- /dev/null +++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/adc-target.h | |||
@@ -0,0 +1,29 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef _ADC_TARGET_H_ | ||
20 | #define _ADC_TARGET_H_ | ||
21 | |||
22 | #define NUM_ADC_CHANNELS 5 | ||
23 | |||
24 | #define ADC_BUTTONS 0 | ||
25 | #define ADC_BATTERY 1 | ||
26 | #define ADC_BUTTON_PLAY 2 | ||
27 | #define ADC_UNREG_POWER ADC_BATTERY /* For compatibility */ | ||
28 | |||
29 | #endif | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c new file mode 100644 index 0000000000..c0dc3974c0 --- /dev/null +++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/backlight-ifp7xx.c | |||
@@ -0,0 +1,33 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include "system.h" | ||
22 | #include "backlight.h" | ||
23 | #include "lcd.h" | ||
24 | |||
25 | void __backlight_on(void) | ||
26 | { | ||
27 | GPIO3_SET = 1; | ||
28 | } | ||
29 | |||
30 | void __backlight_off(void) | ||
31 | { | ||
32 | GPIO3_CLR = 1; | ||
33 | } | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c new file mode 100644 index 0000000000..52e29fdfdf --- /dev/null +++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/button-ifp7xx.c | |||
@@ -0,0 +1,89 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | |||
21 | #include <stdlib.h> | ||
22 | #include "config.h" | ||
23 | #include "cpu.h" | ||
24 | #include "system.h" | ||
25 | #include "button.h" | ||
26 | #include "kernel.h" | ||
27 | #include "backlight.h" | ||
28 | #include "adc.h" | ||
29 | #include "system.h" | ||
30 | |||
31 | |||
32 | void button_init_device(void) | ||
33 | { | ||
34 | |||
35 | } | ||
36 | |||
37 | bool button_hold(void) | ||
38 | { | ||
39 | return (GPIO5_READ & 4) ? false : true; | ||
40 | } | ||
41 | |||
42 | /* | ||
43 | * Get button pressed from hardware | ||
44 | */ | ||
45 | int button_read_device(void) | ||
46 | { | ||
47 | int btn = BUTTON_NONE; | ||
48 | int data; | ||
49 | static bool hold_button = false; | ||
50 | bool hold_button_old; | ||
51 | |||
52 | /* normal buttons */ | ||
53 | hold_button_old = hold_button; | ||
54 | hold_button = button_hold(); | ||
55 | |||
56 | if (hold_button != hold_button_old) | ||
57 | backlight_hold_changed(hold_button); | ||
58 | |||
59 | if (!button_hold()) | ||
60 | { | ||
61 | data = adc_read(ADC_BUTTONS); | ||
62 | if (data < 0x35c) | ||
63 | { | ||
64 | if (data < 0x151) | ||
65 | if (data < 0xc7) | ||
66 | if (data < 0x41) | ||
67 | btn = BUTTON_LEFT; | ||
68 | else | ||
69 | btn = BUTTON_RIGHT; | ||
70 | else | ||
71 | btn = BUTTON_SELECT; | ||
72 | else | ||
73 | if (data < 0x268) | ||
74 | if (data < 0x1d7) | ||
75 | btn = BUTTON_UP; | ||
76 | else | ||
77 | btn = BUTTON_DOWN; | ||
78 | else | ||
79 | if (data < 0x2f9) | ||
80 | btn = BUTTON_EQ; | ||
81 | else | ||
82 | btn = BUTTON_MODE; | ||
83 | } | ||
84 | |||
85 | if (adc_read(ADC_BUTTON_PLAY) < 0x64) | ||
86 | btn |= BUTTON_PLAY; | ||
87 | } | ||
88 | return btn; | ||
89 | } | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/button-target.h b/firmware/target/arm/pnx0101/iriver-ifp7xx/button-target.h new file mode 100644 index 0000000000..954a2dfe9c --- /dev/null +++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/button-target.h | |||
@@ -0,0 +1,56 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | /* Custom written for the ifp7xx */ | ||
21 | |||
22 | #ifndef _BUTTON_TARGET_H_ | ||
23 | #define _BUTTON_TARGET_H_ | ||
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(void); | ||
33 | |||
34 | /* iriver IFP7XX specific button codes */ | ||
35 | |||
36 | #define BUTTON_PLAY 0x00000001 | ||
37 | #define BUTTON_SELECT 0x00000002 | ||
38 | |||
39 | #define BUTTON_LEFT 0x00000004 | ||
40 | #define BUTTON_RIGHT 0x00000008 | ||
41 | #define BUTTON_UP 0x00000010 | ||
42 | #define BUTTON_DOWN 0x00000020 | ||
43 | |||
44 | #define BUTTON_MODE 0x00000040 | ||
45 | #define BUTTON_EQ 0x00000080 | ||
46 | |||
47 | #define BUTTON_MAIN (BUTTON_PLAY|BUTTON_SELECT\ | ||
48 | |BUTTON_LEFT|BUTTON_RIGHT|BUTTON_UP|BUTTON_DOWN\ | ||
49 | |BUTTON_MODE|BUTTON_EQ) | ||
50 | |||
51 | #define BUTTON_REMOTE 0 | ||
52 | |||
53 | #define POWEROFF_BUTTON BUTTON_PLAY | ||
54 | #define POWEROFF_COUNT 40 | ||
55 | |||
56 | #endif /* _BUTTON_TARGET_H_ */ | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c new file mode 100644 index 0000000000..0aacd8af67 --- /dev/null +++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/lcd-ifp7xx.c | |||
@@ -0,0 +1,208 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alan Korr | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | |||
21 | #include "kernel.h" | ||
22 | #include "lcd.h" | ||
23 | #include "system.h" | ||
24 | |||
25 | /*** definitions ***/ | ||
26 | |||
27 | #define LCD_SET_LOWER_COLUMN_ADDRESS ((char)0x00) | ||
28 | #define LCD_SET_HIGHER_COLUMN_ADDRESS ((char)0x10) | ||
29 | #define LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO ((char)0x20) | ||
30 | #define LCD_SET_POWER_CONTROL_REGISTER ((char)0x28) | ||
31 | #define LCD_SET_DISPLAY_START_LINE ((char)0x40) | ||
32 | #define LCD_SET_CONTRAST_CONTROL_REGISTER ((char)0x81) | ||
33 | #define LCD_SET_SEGMENT_REMAP ((char)0xA0) | ||
34 | #define LCD_SET_LCD_BIAS ((char)0xA2) | ||
35 | #define LCD_SET_ENTIRE_DISPLAY_OFF ((char)0xA4) | ||
36 | #define LCD_SET_ENTIRE_DISPLAY_ON ((char)0xA5) | ||
37 | #define LCD_SET_NORMAL_DISPLAY ((char)0xA6) | ||
38 | #define LCD_SET_REVERSE_DISPLAY ((char)0xA7) | ||
39 | #define LCD_SET_MULTIPLEX_RATIO ((char)0xA8) | ||
40 | #define LCD_SET_BIAS_TC_OSC ((char)0xA9) | ||
41 | #define LCD_SET_1OVER4_BIAS_RATIO ((char)0xAA) | ||
42 | #define LCD_SET_INDICATOR_OFF ((char)0xAC) | ||
43 | #define LCD_SET_INDICATOR_ON ((char)0xAD) | ||
44 | #define LCD_SET_DISPLAY_OFF ((char)0xAE) | ||
45 | #define LCD_SET_DISPLAY_ON ((char)0xAF) | ||
46 | #define LCD_SET_PAGE_ADDRESS ((char)0xB0) | ||
47 | #define LCD_SET_COM_OUTPUT_SCAN_DIRECTION ((char)0xC0) | ||
48 | #define LCD_SET_TOTAL_FRAME_PHASES ((char)0xD2) | ||
49 | #define LCD_SET_DISPLAY_OFFSET ((char)0xD3) | ||
50 | #define LCD_SET_READ_MODIFY_WRITE_MODE ((char)0xE0) | ||
51 | #define LCD_SOFTWARE_RESET ((char)0xE2) | ||
52 | #define LCD_NOP ((char)0xE3) | ||
53 | #define LCD_SET_END_OF_READ_MODIFY_WRITE_MODE ((char)0xEE) | ||
54 | |||
55 | /* LCD command codes */ | ||
56 | #define LCD_CNTL_RESET 0xe2 /* Software reset */ | ||
57 | #define LCD_CNTL_POWER 0x2f /* Power control */ | ||
58 | #define LCD_CNTL_CONTRAST 0x81 /* Contrast */ | ||
59 | #define LCD_CNTL_OUTSCAN 0xc8 /* Output scan direction */ | ||
60 | #define LCD_CNTL_SEGREMAP 0xa1 /* Segment remap */ | ||
61 | #define LCD_CNTL_DISPON 0xaf /* Display on */ | ||
62 | |||
63 | #define LCD_CNTL_PAGE 0xb0 /* Page address */ | ||
64 | #define LCD_CNTL_HIGHCOL 0x10 /* Upper column address */ | ||
65 | #define LCD_CNTL_LOWCOL 0x00 /* Lower column address */ | ||
66 | |||
67 | /*** driver routines ***/ | ||
68 | |||
69 | void lcd_write_command(int cmd) | ||
70 | { | ||
71 | while ((LCDSTAT & 3) != 3); | ||
72 | LCDCMD = cmd; | ||
73 | } | ||
74 | |||
75 | void lcd_write_data( const unsigned char* data, int count ) | ||
76 | { | ||
77 | int i; | ||
78 | for (i=0; i < count; i++) { | ||
79 | while ((LCDSTAT & 3) != 3); | ||
80 | LCDDATA = data[i]; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | /*** hardware configuration ***/ | ||
85 | |||
86 | int lcd_default_contrast(void) | ||
87 | { | ||
88 | return 45; | ||
89 | } | ||
90 | |||
91 | void lcd_set_contrast(int val) | ||
92 | { | ||
93 | lcd_write_command(LCD_CNTL_CONTRAST); | ||
94 | lcd_write_command(val); | ||
95 | } | ||
96 | |||
97 | void lcd_set_invert_display(bool yesno) | ||
98 | { | ||
99 | if (yesno) | ||
100 | lcd_write_command(LCD_SET_REVERSE_DISPLAY); | ||
101 | else | ||
102 | lcd_write_command(LCD_SET_NORMAL_DISPLAY); | ||
103 | } | ||
104 | |||
105 | /* turn the display upside down (call lcd_update() afterwards) */ | ||
106 | void lcd_set_flip(bool yesno) | ||
107 | { | ||
108 | if (yesno) | ||
109 | { | ||
110 | lcd_write_command(LCD_SET_SEGMENT_REMAP); | ||
111 | lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION); | ||
112 | } | ||
113 | else | ||
114 | { | ||
115 | lcd_write_command(LCD_SET_SEGMENT_REMAP | 0x01); | ||
116 | lcd_write_command(LCD_SET_COM_OUTPUT_SCAN_DIRECTION | 0x08); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | void lcd_init_device(void) | ||
121 | { | ||
122 | LCDREG10 = 0xf; | ||
123 | LCDREG04 = 0x4084; | ||
124 | |||
125 | /* inits like the original firmware */ | ||
126 | lcd_write_command(LCD_SOFTWARE_RESET); | ||
127 | lcd_write_command(LCD_SET_INTERNAL_REGULATOR_RESISTOR_RATIO + 4); | ||
128 | lcd_write_command(LCD_SET_LCD_BIAS); | ||
129 | lcd_write_command(LCD_SET_POWER_CONTROL_REGISTER + 7); | ||
130 | /* power control register: op-amp=1, regulator=1, booster=1 */ | ||
131 | lcd_write_command(LCD_SET_DISPLAY_ON); | ||
132 | lcd_write_command(LCD_SET_NORMAL_DISPLAY); | ||
133 | lcd_set_flip(false); | ||
134 | lcd_write_command(LCD_SET_DISPLAY_START_LINE + 0); | ||
135 | lcd_set_contrast(lcd_default_contrast()); | ||
136 | lcd_write_command(LCD_SET_PAGE_ADDRESS); | ||
137 | lcd_write_command(LCD_SET_LOWER_COLUMN_ADDRESS + 0); | ||
138 | lcd_write_command(LCD_SET_HIGHER_COLUMN_ADDRESS + 0); | ||
139 | |||
140 | lcd_clear_display(); | ||
141 | lcd_update(); | ||
142 | } | ||
143 | |||
144 | /*** Update functions ***/ | ||
145 | |||
146 | /* Performance function that works with an external buffer | ||
147 | note that by and bheight are in 8-pixel units! */ | ||
148 | void lcd_blit(const unsigned char* data, int x, int by, int width, | ||
149 | int bheight, int stride) | ||
150 | { | ||
151 | /* Copy display bitmap to hardware */ | ||
152 | while (bheight--) | ||
153 | { | ||
154 | lcd_write_command (LCD_CNTL_PAGE | (by++ & 0xf)); | ||
155 | lcd_write_command (LCD_CNTL_HIGHCOL | (((x+4)>>4) & 0xf)); | ||
156 | lcd_write_command (LCD_CNTL_LOWCOL | ((x+4) & 0xf)); | ||
157 | |||
158 | lcd_write_data(data, width); | ||
159 | data += stride; | ||
160 | } | ||
161 | } | ||
162 | |||
163 | |||
164 | /* Update the display. | ||
165 | This must be called after all other LCD functions that change the display. */ | ||
166 | void lcd_update(void) ICODE_ATTR; | ||
167 | void lcd_update(void) | ||
168 | { | ||
169 | int y; | ||
170 | |||
171 | /* Copy display bitmap to hardware */ | ||
172 | for (y = 0; y < LCD_FBHEIGHT; y++) | ||
173 | { | ||
174 | lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); | ||
175 | lcd_write_command (LCD_CNTL_HIGHCOL); | ||
176 | lcd_write_command (LCD_CNTL_LOWCOL | 4); | ||
177 | |||
178 | lcd_write_data (lcd_framebuffer[y], LCD_WIDTH); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | /* Update a fraction of the display. */ | ||
183 | void lcd_update_rect(int, int, int, int) ICODE_ATTR; | ||
184 | void lcd_update_rect(int x, int y, int width, int height) | ||
185 | { | ||
186 | int ymax; | ||
187 | |||
188 | /* The Y coordinates have to work on even 8 pixel rows */ | ||
189 | ymax = (y + height-1) >> 3; | ||
190 | y >>= 3; | ||
191 | |||
192 | if(x + width > LCD_WIDTH) | ||
193 | width = LCD_WIDTH - x; | ||
194 | if (width <= 0) | ||
195 | return; /* nothing left to do, 0 is harmful to lcd_write_data() */ | ||
196 | if(ymax >= LCD_FBHEIGHT) | ||
197 | ymax = LCD_FBHEIGHT-1; | ||
198 | |||
199 | /* Copy specified rectange bitmap to hardware */ | ||
200 | for (; y <= ymax; y++) | ||
201 | { | ||
202 | lcd_write_command (LCD_CNTL_PAGE | (y & 0xf)); | ||
203 | lcd_write_command (LCD_CNTL_HIGHCOL | (((x+4) >> 4) & 0xf)); | ||
204 | lcd_write_command (LCD_CNTL_LOWCOL | ((x+4) & 0xf)); | ||
205 | |||
206 | lcd_write_data (&lcd_framebuffer[y][x], width); | ||
207 | } | ||
208 | } | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c new file mode 100644 index 0000000000..4e4f585298 --- /dev/null +++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/power-ifp7xx.c | |||
@@ -0,0 +1,85 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Linus Nielsen Feltzing | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include <stdbool.h> | ||
22 | #include "adc.h" | ||
23 | #include "kernel.h" | ||
24 | #include "system.h" | ||
25 | #include "power.h" | ||
26 | #include "logf.h" | ||
27 | #include "usb.h" | ||
28 | |||
29 | #if CONFIG_TUNER | ||
30 | |||
31 | static bool powered = false; | ||
32 | |||
33 | bool radio_powered(void) | ||
34 | { | ||
35 | return powered; | ||
36 | } | ||
37 | |||
38 | bool radio_power(bool status) | ||
39 | { | ||
40 | bool old_status = powered; | ||
41 | powered = status; | ||
42 | |||
43 | return old_status; | ||
44 | } | ||
45 | |||
46 | #endif /* #if CONFIG_TUNER */ | ||
47 | |||
48 | #ifndef SIMULATOR | ||
49 | |||
50 | void power_init(void) | ||
51 | { | ||
52 | } | ||
53 | |||
54 | void ide_power_enable(bool on) | ||
55 | { | ||
56 | (void)on; | ||
57 | /* no ide controller */ | ||
58 | } | ||
59 | |||
60 | bool ide_powered(void) | ||
61 | { | ||
62 | return true; /* pretend always powered if not controlable */ | ||
63 | } | ||
64 | |||
65 | void power_off(void) | ||
66 | { | ||
67 | set_irq_level(HIGHEST_IRQ_LEVEL); | ||
68 | GPIO1_CLR = 1 << 16; | ||
69 | GPIO2_SET = 1; | ||
70 | while(1) | ||
71 | yield(); | ||
72 | } | ||
73 | |||
74 | #else | ||
75 | |||
76 | void power_off(void) | ||
77 | { | ||
78 | } | ||
79 | |||
80 | void ide_power_enable(bool on) | ||
81 | { | ||
82 | (void)on; | ||
83 | } | ||
84 | |||
85 | #endif /* SIMULATOR */ | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/system-target.h b/firmware/target/arm/pnx0101/iriver-ifp7xx/system-target.h new file mode 100644 index 0000000000..dc11bb74da --- /dev/null +++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/system-target.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2002 by Alan Korr | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #ifndef SYSTEM_TARGET_H | ||
20 | #define SYSTEM_TARGET_H | ||
21 | |||
22 | #include "system-arm.h" | ||
23 | |||
24 | #define CPUFREQ_DEFAULT 12000000 | ||
25 | #define CPUFREQ_NORMAL 48000000 | ||
26 | #define CPUFREQ_MAX 60000000 | ||
27 | |||
28 | typedef void (*interrupt_handler_t)(void); | ||
29 | |||
30 | void irq_set_int_handler(int n, interrupt_handler_t handler); | ||
31 | void irq_enable_int(int n); | ||
32 | void irq_disable_int(int n); | ||
33 | |||
34 | #endif /* SYSTEM_TARGET_H */ | ||
diff --git a/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c b/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c new file mode 100644 index 0000000000..a22a227b15 --- /dev/null +++ b/firmware/target/arm/pnx0101/iriver-ifp7xx/usb-ifp7xx.c | |||
@@ -0,0 +1,50 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardell | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "config.h" | ||
20 | #include "cpu.h" | ||
21 | #include "kernel.h" | ||
22 | #include "thread.h" | ||
23 | #include "system.h" | ||
24 | #include "debug.h" | ||
25 | #include "ata.h" | ||
26 | #include "fat.h" | ||
27 | #include "disk.h" | ||
28 | #include "panic.h" | ||
29 | #include "lcd.h" | ||
30 | #include "adc.h" | ||
31 | #include "usb.h" | ||
32 | #include "button.h" | ||
33 | #include "sprintf.h" | ||
34 | #include "string.h" | ||
35 | |||
36 | void usb_init_device(void) | ||
37 | { | ||
38 | } | ||
39 | |||
40 | bool usb_detect(void) | ||
41 | { | ||
42 | /* TODO: Implement USB_ISP1582 */ | ||
43 | return false; | ||
44 | } | ||
45 | |||
46 | void usb_enable(bool on) | ||
47 | { | ||
48 | /* TODO: Implement USB_ISP1582 */ | ||
49 | (void)on; | ||
50 | } | ||
diff --git a/firmware/target/arm/pnx0101/system-pnx0101.c b/firmware/target/arm/pnx0101/system-pnx0101.c new file mode 100644 index 0000000000..9d8bb405a8 --- /dev/null +++ b/firmware/target/arm/pnx0101/system-pnx0101.c | |||
@@ -0,0 +1,351 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2007 by Tomasz Malesinski | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | #include <stdlib.h> | ||
21 | #include "pnx0101.h" | ||
22 | #include "system.h" | ||
23 | |||
24 | static struct | ||
25 | { | ||
26 | unsigned char freq; | ||
27 | unsigned char sys_mult; | ||
28 | unsigned char sys_div; | ||
29 | unsigned char mem_conf[9]; | ||
30 | } | ||
31 | perf_modes[3] ICONST_ATTR = | ||
32 | { | ||
33 | {12, 4, 4, {2, 1, 1, 1, 1, 1, 1, 1, 1, 0}}, | ||
34 | {48, 4, 1, {5, 4, 1, 4, 4, 1, 3, 3, 1, 0}}, | ||
35 | {60, 5, 1, {6, 5, 1, 5, 5, 1, 4, 3, 1, 1}} | ||
36 | }; | ||
37 | |||
38 | static int performance_mode, bus_divider; | ||
39 | |||
40 | static void cgu_set_sel_stage_input(int clock, int input) | ||
41 | { | ||
42 | int s = CGU.base_ssr[clock]; | ||
43 | if (s & 1) | ||
44 | CGU.base_fs2[clock] = input; | ||
45 | else | ||
46 | CGU.base_fs1[clock] = input; | ||
47 | CGU.base_scr[clock] = (s & 3) ^ 3; | ||
48 | } | ||
49 | |||
50 | static void cgu_reset_sel_stage_clocks(int first_esr, int n_esr, | ||
51 | int first_div, int n_div) | ||
52 | { | ||
53 | int i; | ||
54 | for (i = 0; i < n_esr; i++) | ||
55 | CGU.clk_esr[first_esr + i] = 0; | ||
56 | for (i = 0; i < n_div; i++) | ||
57 | CGU.base_fdc[first_div + i] = 0; | ||
58 | } | ||
59 | |||
60 | static void cgu_configure_div(int div, int n, int m) | ||
61 | { | ||
62 | int msub, madd, div_size, max_n; | ||
63 | unsigned long cfg; | ||
64 | |||
65 | if (n == m) | ||
66 | { | ||
67 | CGU.base_fdc[div] = CGU.base_fdc[div] & ~1; | ||
68 | return; | ||
69 | } | ||
70 | |||
71 | msub = -n; | ||
72 | madd = m - n; | ||
73 | div_size = (div == PNX0101_HIPREC_FDC) ? 10 : 8; | ||
74 | max_n = 1 << div_size; | ||
75 | while ((madd << 1) < max_n && (msub << 1) >= -max_n) | ||
76 | { | ||
77 | madd <<= 1; | ||
78 | msub <<= 1; | ||
79 | } | ||
80 | cfg = (((msub << div_size) | madd) << 3) | 4; | ||
81 | CGU.base_fdc[div] = CGU.base_fdc[div] & ~1; | ||
82 | CGU.base_fdc[div] = cfg | 2; | ||
83 | CGU.base_fdc[div] = cfg; | ||
84 | CGU.base_fdc[div] = cfg | 1; | ||
85 | } | ||
86 | |||
87 | static void cgu_connect_div_to_clock(int rel_div, int esr) | ||
88 | { | ||
89 | CGU.clk_esr[esr] = (rel_div << 1) | 1; | ||
90 | } | ||
91 | |||
92 | static void cgu_disconnect_div_from_clock(int esr) | ||
93 | { | ||
94 | CGU.clk_esr[esr] = 0; | ||
95 | } | ||
96 | |||
97 | static void cgu_enable_clock(int clock) | ||
98 | { | ||
99 | CGU.clk_pcr[clock] |= 1; | ||
100 | } | ||
101 | |||
102 | static void cgu_start_sel_stage_dividers(int bcr) | ||
103 | { | ||
104 | CGU.base_bcr[bcr] = 1; | ||
105 | } | ||
106 | |||
107 | /* Convert a pointer that points to IRAM (0x4xxxx) to a pointer that | ||
108 | points to the uncached page (0x0xxxx) that is also mapped to IRAM. */ | ||
109 | static inline void *noncached(void *p) { | ||
110 | return (void *)(((unsigned long)p) & 0xffff); | ||
111 | } | ||
112 | |||
113 | /* TODO: if it works, then comment it */ | ||
114 | static void do_set_mem_timings(int mode) ICODE_ATTR; | ||
115 | static void do_set_mem_timings(int mode) | ||
116 | { | ||
117 | unsigned char *mem_conf = noncached(perf_modes[mode].mem_conf); | ||
118 | int old_irq = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
119 | while ((EMC.status & 3) != 0); | ||
120 | EMC.control = 5; | ||
121 | EMCSTATIC0.waitrd = mem_conf[0]; | ||
122 | EMCSTATIC0.waitwr = mem_conf[1]; | ||
123 | EMCSTATIC1.waitrd = mem_conf[3]; | ||
124 | EMCSTATIC1.waitwr = mem_conf[4]; | ||
125 | EMCSTATIC2.waitrd = mem_conf[6]; | ||
126 | EMCSTATIC2.waitwr = mem_conf[7]; | ||
127 | EMCSTATIC0.waitoen = mem_conf[2]; | ||
128 | EMCSTATIC1.waitoen = mem_conf[5]; | ||
129 | EMCSTATIC2.waitoen = mem_conf[8]; | ||
130 | #ifndef DEBUG | ||
131 | EMCSTATIC1.config = mem_conf[9] ? 0x80081 : 0x81; | ||
132 | #endif | ||
133 | EMC.control = 1; | ||
134 | set_irq_level(old_irq); | ||
135 | } | ||
136 | |||
137 | static void emc_set_mem_timings(int mode) { | ||
138 | void (*f)(int) = noncached(do_set_mem_timings); | ||
139 | (*f)(mode); | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | static void do_enable_write_buffers(int on) ICODE_ATTR; | ||
144 | static void do_enable_write_buffers(int on) { | ||
145 | int old_irq = set_irq_level(HIGHEST_IRQ_LEVEL); | ||
146 | while ((EMC.status & 3) != 0); | ||
147 | EMC.control = 5; | ||
148 | EMCSTATIC1.config = on ? 0x80081 : 0x81; | ||
149 | EMC.control = 1; | ||
150 | set_irq_level(old_irq); | ||
151 | } | ||
152 | |||
153 | void emc_enable_write_buffers(int on) { | ||
154 | void (*f)(int) = noncached(do_enable_write_buffers); | ||
155 | (*f)(on); | ||
156 | } | ||
157 | */ | ||
158 | |||
159 | /* can it be replaced? */ | ||
160 | static void cgu_busy_wait(int n) | ||
161 | { | ||
162 | while (n > 0) | ||
163 | { | ||
164 | n--; | ||
165 | } | ||
166 | } | ||
167 | |||
168 | static void cgu_set_sys_mult(int i) | ||
169 | { | ||
170 | cgu_set_sel_stage_input(PNX0101_SEL_STAGE_SYS, PNX0101_MAIN_CLOCK_FAST); | ||
171 | cgu_set_sel_stage_input(PNX0101_SEL_STAGE_APB3, PNX0101_MAIN_CLOCK_FAST); | ||
172 | |||
173 | PLL.lppdn = 1; | ||
174 | PLL.lpfin = 1; | ||
175 | PLL.lpmbyp = 0; | ||
176 | PLL.lpdbyp = 0; | ||
177 | PLL.lppsel = 1; | ||
178 | PLL.lpmsel = i - 1; | ||
179 | PLL.lppdn = 0; | ||
180 | while (!PLL.lplock); | ||
181 | |||
182 | cgu_configure_div(PNX0101_FIRST_DIV_SYS + 1, 1, (i == 5) ? 15 : 12); | ||
183 | cgu_connect_div_to_clock(1, 0x11); | ||
184 | cgu_enable_clock(0x11); | ||
185 | cgu_start_sel_stage_dividers(PNX0101_BCR_SYS); | ||
186 | |||
187 | cgu_set_sel_stage_input(PNX0101_SEL_STAGE_SYS, | ||
188 | PNX0101_MAIN_CLOCK_MAIN_PLL); | ||
189 | cgu_set_sel_stage_input(PNX0101_SEL_STAGE_APB3, | ||
190 | PNX0101_MAIN_CLOCK_MAIN_PLL); | ||
191 | } | ||
192 | |||
193 | static void pnx0101_set_performance_mode(int mode) | ||
194 | { | ||
195 | int old = performance_mode; | ||
196 | if (perf_modes[old].freq < perf_modes[mode].freq) | ||
197 | { | ||
198 | emc_set_mem_timings(mode); | ||
199 | if (perf_modes[old].sys_mult != perf_modes[mode].sys_mult) | ||
200 | cgu_set_sys_mult(perf_modes[mode].sys_mult); | ||
201 | if (perf_modes[old].sys_div != perf_modes[mode].sys_div) | ||
202 | cgu_configure_div(bus_divider, 1, perf_modes[mode].sys_div); | ||
203 | } | ||
204 | else if (perf_modes[old].freq > perf_modes[mode].freq) | ||
205 | { | ||
206 | if (perf_modes[old].sys_mult != perf_modes[mode].sys_mult) | ||
207 | cgu_set_sys_mult(perf_modes[mode].sys_mult); | ||
208 | if (perf_modes[old].sys_div != perf_modes[mode].sys_div) | ||
209 | cgu_configure_div(bus_divider, 1, perf_modes[mode].sys_div); | ||
210 | emc_set_mem_timings(mode); | ||
211 | } | ||
212 | performance_mode = mode; | ||
213 | } | ||
214 | |||
215 | static void pnx0101_init_clocks(void) | ||
216 | { | ||
217 | bus_divider = PNX0101_FIRST_DIV_SYS + (CGU.clk_esr[0] >> 1); | ||
218 | performance_mode = 0; | ||
219 | pnx0101_set_performance_mode(2); | ||
220 | /* | ||
221 | #ifndef DEBUG | ||
222 | emc_enable_write_buffers(1); | ||
223 | #endif | ||
224 | */ | ||
225 | cgu_set_sel_stage_input(PNX0101_SEL_STAGE_APB1, | ||
226 | PNX0101_MAIN_CLOCK_FAST); | ||
227 | cgu_reset_sel_stage_clocks(PNX0101_FIRST_ESR_APB1, PNX0101_N_ESR_APB1, | ||
228 | PNX0101_FIRST_DIV_APB1, PNX0101_N_DIV_APB1); | ||
229 | cgu_configure_div(PNX0101_FIRST_DIV_APB1, 1, 4); | ||
230 | cgu_connect_div_to_clock(0, PNX0101_ESR_APB1); | ||
231 | cgu_connect_div_to_clock(0, PNX0101_ESR_T0); | ||
232 | cgu_connect_div_to_clock(0, PNX0101_ESR_T1); | ||
233 | cgu_connect_div_to_clock(0, PNX0101_ESR_I2C); | ||
234 | cgu_enable_clock(PNX0101_CLOCK_APB1); | ||
235 | cgu_enable_clock(PNX0101_CLOCK_T0); | ||
236 | cgu_enable_clock(PNX0101_CLOCK_T1); | ||
237 | cgu_enable_clock(PNX0101_CLOCK_I2C); | ||
238 | } | ||
239 | |||
240 | #ifdef HAVE_ADJUSTABLE_CPU_FREQ | ||
241 | void set_cpu_frequency(long frequency) | ||
242 | { | ||
243 | switch (frequency) | ||
244 | { | ||
245 | case CPUFREQ_MAX: | ||
246 | pnx0101_set_performance_mode(2); | ||
247 | cpu_frequency = CPUFREQ_MAX; | ||
248 | break; | ||
249 | case CPUFREQ_NORMAL: | ||
250 | pnx0101_set_performance_mode(1); | ||
251 | cpu_frequency = CPUFREQ_NORMAL; | ||
252 | break; | ||
253 | case CPUFREQ_DEFAULT: | ||
254 | default: | ||
255 | pnx0101_set_performance_mode(0); | ||
256 | cpu_frequency = CPUFREQ_DEFAULT; | ||
257 | break; | ||
258 | } | ||
259 | |||
260 | } | ||
261 | #endif | ||
262 | |||
263 | interrupt_handler_t interrupt_vector[0x1d] __attribute__ ((section(".idata"))); | ||
264 | |||
265 | #define IRQ_READ(reg, dest) \ | ||
266 | do { unsigned long v2; \ | ||
267 | do { \ | ||
268 | dest = (reg); \ | ||
269 | v2 = (reg); \ | ||
270 | } while ((dest != v2)); \ | ||
271 | } while (0); | ||
272 | |||
273 | #define IRQ_WRITE_WAIT(reg, val, cond) \ | ||
274 | do { unsigned long v, v2; \ | ||
275 | do { \ | ||
276 | (reg) = (val); \ | ||
277 | v = (reg); \ | ||
278 | v2 = (reg); \ | ||
279 | } while ((v != v2) || !(cond)); \ | ||
280 | } while (0); | ||
281 | |||
282 | static void undefined_int(void) | ||
283 | { | ||
284 | } | ||
285 | |||
286 | void irq(void) | ||
287 | { | ||
288 | int n; | ||
289 | IRQ_READ(INTVECTOR[0], n) | ||
290 | (*(interrupt_vector[n >> 3]))(); | ||
291 | } | ||
292 | |||
293 | void fiq(void) | ||
294 | { | ||
295 | } | ||
296 | |||
297 | void irq_enable_int(int n) | ||
298 | { | ||
299 | IRQ_WRITE_WAIT(INTREQ[n], INTREQ_WEENABLE | INTREQ_ENABLE, v & 0x10000); | ||
300 | } | ||
301 | |||
302 | void irq_disable_int(int n) | ||
303 | { | ||
304 | IRQ_WRITE_WAIT(INTREQ[n], INTREQ_WEENABLE, (v & 0x10000) == 0); | ||
305 | } | ||
306 | |||
307 | void irq_set_int_handler(int n, interrupt_handler_t handler) | ||
308 | { | ||
309 | interrupt_vector[n] = handler; | ||
310 | } | ||
311 | |||
312 | void system_init(void) | ||
313 | { | ||
314 | int i; | ||
315 | |||
316 | /* turn off watchdog */ | ||
317 | (*(volatile unsigned long *)0x80002804) = 0; | ||
318 | |||
319 | /* | ||
320 | IRQ_WRITE_WAIT(INTVECTOR[0], 0, v == 0); | ||
321 | IRQ_WRITE_WAIT(INTVECTOR[1], 0, v == 0); | ||
322 | IRQ_WRITE_WAIT(INTPRIOMASK[0], 0, v == 0); | ||
323 | IRQ_WRITE_WAIT(INTPRIOMASK[1], 0, v == 0); | ||
324 | */ | ||
325 | |||
326 | for (i = 0; i < 0x1c; i++) | ||
327 | { | ||
328 | IRQ_WRITE_WAIT(INTREQ[i], | ||
329 | INTREQ_WEPRIO | INTREQ_WETARGET | | ||
330 | INTREQ_WEENABLE | INTREQ_WEACTVLO | 1, | ||
331 | (v & 0x3010f) == 1); | ||
332 | IRQ_WRITE_WAIT(INTREQ[i], INTREQ_WEENABLE, (v & 0x10000) == 0); | ||
333 | IRQ_WRITE_WAIT(INTREQ[i], INTREQ_WEPRIO | 1, (v & 0xf) == 1); | ||
334 | interrupt_vector[i + 1] = undefined_int; | ||
335 | } | ||
336 | interrupt_vector[0] = undefined_int; | ||
337 | pnx0101_init_clocks(); | ||
338 | } | ||
339 | |||
340 | |||
341 | void system_reboot(void) | ||
342 | { | ||
343 | (*(volatile unsigned long *)0x80002804) = 1; | ||
344 | while (1); | ||
345 | } | ||
346 | |||
347 | int system_memory_guard(int newmode) | ||
348 | { | ||
349 | (void)newmode; | ||
350 | return 0; | ||
351 | } | ||
diff --git a/firmware/target/arm/pnx0101/usb-target.h b/firmware/target/arm/pnx0101/usb-target.h new file mode 100644 index 0000000000..fb263b2419 --- /dev/null +++ b/firmware/target/arm/pnx0101/usb-target.h | |||
@@ -0,0 +1,27 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: usb-target.h 11494 2006-11-10 07:43:36Z tomal $ | ||
9 | * | ||
10 | * Copyright (C) 2006 by Barry Wardelll | ||
11 | * | ||
12 | * All files in this archive are subject to the GNU General Public License. | ||
13 | * See the file COPYING in the source tree root for full license agreement. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | /* Based off x5 version */ | ||
21 | |||
22 | #ifndef USB_TARGET_H | ||
23 | #define USB_TARGET_H | ||
24 | |||
25 | bool usb_init_device(void); | ||
26 | |||
27 | #endif | ||