1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2008 Rafaël Carré
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
24 /* AS3525 hardware registers */
25 .set GPIOA, 0xC80B0000
26 .set GPIOB, 0xC80C0000
27 .set GPIOC, 0xC80D0000
28 .set GPIOD, 0xC80E0000
29 .set CGU_PERI, 0xC80F0014
34 ldr pc, =start /* reset vector */
35 /* next vectors are unused */
44 /* These values are filled in by mkamsboot - don't move them from offset 0x20 */
46 uclunpack_end: .word 0 /* End of the ucl_unpack function */
47 uclunpack_size: .word 0 /* Size in bytes of the ucl_unpack function */
49 ucl_of_end: .word 0 /* End of the ucl-compressed OF image */
50 ucl_of_size: .word 0 /* Size in bytes of the compressed OF image */
52 ucl_rb_end: .word 0 /* End of the ucl-compressed RB image */
53 ucl_rb_size: .word 0 /* Size in bytes of the compressed RB image */
55 ucl_dest: .word 0 /* End of our destination buffer (end of memory) */
58 /* First copy the UCL unpack function to the end of RAM */
59 ldr r0, uclunpack_end /* Source */
60 ldr r1, uclunpack_size /* Source length */
61 sub r2, r0, r1 /* Source start - 1*/
63 ldr r3, ucl_dest /* Destination end */
71 /* store the new destination buffer */
74 /* enable gpio clock */
82 #if defined(SANSA_C200V2)
83 #define USB_PIN 1 /* FIXME: not correct on some c200v2s */
84 #elif defined(SANSA_CLIP) || defined(SANSA_CLIPV2)
86 #elif defined(SANSA_FUZE) || defined(SANSA_E200V2) || defined(SANSA_FUZEV2)
90 #ifdef USB_PIN /* TODO : remove this check when we'll have an USB driver */
94 ldr r1, [r0, #(4*(1<<USB_PIN))]
99 /* Here are model specific tests, for dual boot without a computer */
100 /* All models use left button */
101 /* /!\ Right button for c200v2 (left button is unkwown) */
104 .set row, (1<<5) /* enable output on C5 */
105 .set col, (1<<0) /* read keyscan column B0 */
110 str r1, [r0, #(4*row)]
115 ldr r1, [r0, #(4*col)]
119 #elif defined(SANSA_CLIPV2)
120 .set row, (1<<4) /* enable output on D4 */
121 .set col, (1<<0) /* read keyscan column D0 */
124 mov r1, #((1<<5)|(1<<4)|(1<<3)) /* all rows as output */
129 str r1, [r0, #(4*(1<<3))]
131 str r1, [r0, #(4*(1<<4))]
133 str r1, [r0, #(4*(1<<5))]
135 mov r1, #0 /* button row low */
136 str r1, [r0, #(4*row)]
138 mov r1, #5 /* small delay */
142 ldr r1, [r0, #(4*col)]
146 #elif defined(SANSA_E200V2) || defined(SANSA_FUZE) || defined(SANSA_FUZEV2)
150 ldr r1, [r0, #0x20] /* read pin C3 */
152 cmp r1, #0 /* C3 = #0 means button pressed */
154 /* the logic is reversed on the fuzev2 */
158 #endif /* SANSA_FUZEV2 */
160 #elif defined(SANSA_CLIPPLUS)
163 ldr r1, [r0, #4*(1<<3)] @ read pin C3 "|<<"
166 ldr r2, [r0, #4*(1<<1)] @ read pin A1 "Home"
168 orr r2, r2, r1 @ c3 || A1
170 cmp r2, #0 @ test input from pins
171 bne boot_of @ branch directly to OF if either pin high
172 #elif defined(SANSA_C200V2)
173 /* check for RIGHT on C6, should changed to LEFT as soon as it
174 * known in which pin that is in order for consistency */
177 str r1, [r0, #0x400] /* set pin to output */
179 ldr r1, [r0, #256] /* 1<<(6+2) */
180 cmp r1, #0 /* C6 low means button pressed */
182 #elif defined(SANSA_M200V4)
183 .set row, (1<<5) /* enable output on A5 */
184 .set col, (1<<0) /* read keyscan column A0 */
189 str r1, [r0, #(4*row)]
191 ldr r2, [r0, #(4*col)]
193 /* check value read (1 means button pressed) */
197 #error No target-specific key check defined!
201 /* The dualboot button was not held, so we boot rockbox */
202 ldr r0, ucl_rb_end /* Address of compressed image */
203 ldr r1, ucl_rb_size /* Compressed size */
207 ldr r0, ucl_of_end /* Address of compressed image */
208 ldr r1, ucl_of_size /* Compressed size */
213 /* r0 = source_end for UCL image to copy */
214 /* r1 = size of UCL image to copy */
217 add r5, r3, #2 /* r5 is entry point of copy of uclunpack */
218 /* function, plus one (for thumb mode */
220 sub r4, r3, r1 /* r4 := destination_start - 1 */
225 cmp r3, r4 /* Stop when we reached dest_start-1 */
228 /* Call the ucl decompress function, which will branch to 0x0 */
230 add r0, r3, #1 /* r0 := Start of compressed image */
231 /* r1 already contains compressed size */
232 mov r2, #0 /* r2 := Destination for unpacking */
233 bx r5 /* Branch to uclunpack, switching to thumb */
235 /* never reached : uclunpack will branch to the reset vector (0x0) */