diff options
Diffstat (limited to 'firmware/target/arm/tms320dm320/sansa-connect/crt0-board.S')
-rw-r--r-- | firmware/target/arm/tms320dm320/sansa-connect/crt0-board.S | 238 |
1 files changed, 238 insertions, 0 deletions
diff --git a/firmware/target/arm/tms320dm320/sansa-connect/crt0-board.S b/firmware/target/arm/tms320dm320/sansa-connect/crt0-board.S new file mode 100644 index 0000000000..debd2cd2be --- /dev/null +++ b/firmware/target/arm/tms320dm320/sansa-connect/crt0-board.S | |||
@@ -0,0 +1,238 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id: $ | ||
9 | * | ||
10 | * Copyright (C) 2011 by Tomasz Moń | ||
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 | #include "config.h" | ||
22 | #include "cpu.h" | ||
23 | |||
24 | /* Macro for reading a register */ | ||
25 | .macro mrh register | ||
26 | ldr r1, =\register | ||
27 | ldrh r0, [r1] | ||
28 | .endm | ||
29 | |||
30 | /* Macro for writing a register */ | ||
31 | .macro mwh register, value | ||
32 | ldr r0, =\value | ||
33 | ldr r1, =\register | ||
34 | strh r0, [r1] | ||
35 | .endm | ||
36 | |||
37 | /* This version uses a mov to save on the literal pool size. Otherwise it is | ||
38 | * functionally equivalent. | ||
39 | */ | ||
40 | .macro mwhm register, value | ||
41 | mov r0, #\value | ||
42 | ldr r1, =\register | ||
43 | strh r0, [r1] | ||
44 | .endm | ||
45 | |||
46 | /* | ||
47 | * _init_board: | ||
48 | * This function initializes the specific board this SoC is on. | ||
49 | */ | ||
50 | .section .init, "ax" | ||
51 | .code 32 | ||
52 | .align 0x04 | ||
53 | .global _init_board | ||
54 | .type _init_board, %function | ||
55 | |||
56 | _init_board: | ||
57 | |||
58 | /* Setup the EMIF interface timings */ | ||
59 | |||
60 | /* FLASH interface: | ||
61 | * These are based on the OF setup | ||
62 | */ | ||
63 | /* IO_EMIF_CS0CTRL1 and | ||
64 | * IO_EMIF_CS0CTRL2 | ||
65 | */ | ||
66 | mwh 0x30A00, 0x889A | ||
67 | mwh 0x30A02, 0x1110 | ||
68 | |||
69 | mwhm 0x30A04, 0 | ||
70 | mwh 0x30A06, 0x1415 | ||
71 | mwh 0x30A08, 0x1109 | ||
72 | |||
73 | mwh 0x30A0A, 0x1220 | ||
74 | mwh 0x30A0C, 0x1104 | ||
75 | mwh 0x30A0E, 0x0222 | ||
76 | |||
77 | /* IO_EMIF_CS3CTRL1 and | ||
78 | * IO_EMIF_CS3CTRL2 | ||
79 | */ | ||
80 | mwh 0x30A10, 0x8899 | ||
81 | mwh 0x30A12, 0x5110 | ||
82 | |||
83 | /* USB interface */ | ||
84 | /* IO_EMIF_CS4CTRL1 and | ||
85 | * IO_EMIF_CS4CTRL2 | ||
86 | */ | ||
87 | mwh 0x30A14, 0x77DF | ||
88 | mwh 0x30A16, 0x7740 | ||
89 | |||
90 | /* IO_EMIF_BUSCTRL */ | ||
91 | mwhm 0x30A18, 0 | ||
92 | mwhm 0x30A1A, 0 | ||
93 | mwhm 0x30A1C, 0 | ||
94 | mwhm 0x30A1E, 0 | ||
95 | |||
96 | _clock_setup: | ||
97 | /* Clock initialization */ | ||
98 | |||
99 | /* IO_CLK_BYP: Bypass the PLLs for the following changes */ | ||
100 | mwh 0x30894, 0x1111 | ||
101 | |||
102 | /* | ||
103 | * IO_CLK_PLLA | ||
104 | * IO_CLK_PLLB | ||
105 | */ | ||
106 | mwhm 0x30880, 0x00A0 | ||
107 | mwhm 0x30882, 0x1000 | ||
108 | |||
109 | /* IO_CLK_SEL0 */ | ||
110 | mwh 0x30884, 0x0066 | ||
111 | |||
112 | /* IO_CLK_SEL1 */ | ||
113 | mwhm 0x30886, 0x0003 | ||
114 | |||
115 | # IO_CLK_SEL2: ARM, AXL, SDRAM and DSP are from PLLA */ | ||
116 | mwh 0x30888, 0 | ||
117 | |||
118 | /* IO_CLK_DIV0: Set the slow clock speed for the ARM/AHB */ | ||
119 | mwh 0x3088A, 0x0101 | ||
120 | |||
121 | /* IO_CLK_DIV1: Accelerator, SDRAM */ | ||
122 | mwh 0x3088C, 0x0102 | ||
123 | |||
124 | /* IO_CLK_DIV2: DSP, MS Clock */ | ||
125 | mwhm 0x3088E, 0x0200 | ||
126 | |||
127 | # PLLA &= ~0x1000 (BIC #0x1000) | ||
128 | mrh 0x30880 | ||
129 | bic r0, r0, #0x1000 | ||
130 | strh r0, [r1] | ||
131 | |||
132 | /* Wait for PLLs to lock before feeding them to the downstream devices */ | ||
133 | _plla_wait: | ||
134 | mrh 0x30880 | ||
135 | bic r0, r0, #0x7F | ||
136 | tst r0, r0 | ||
137 | beq _plla_wait | ||
138 | |||
139 | /* IO_CLK_BYP: Enable PLL feeds */ | ||
140 | mwhm 0x30894, 0x0 | ||
141 | |||
142 | /* IO_CLK_MOD0 */ | ||
143 | mwh 0x30898, 0x01A7 | ||
144 | |||
145 | /* IO_CLK_MOD1 */ | ||
146 | mwhm 0x3089A, 0x18 | ||
147 | |||
148 | /* IO_CLK_MOD2 */ | ||
149 | mwhm 0x3089C, 0x4A0 | ||
150 | |||
151 | /* Setup the SDRAM range on the AHB bus */ | ||
152 | /* SDRAMSA */ | ||
153 | mov r0, #0x60000 | ||
154 | mov r1, #0x1000000 | ||
155 | str r1, [r0, #0xF00] | ||
156 | |||
157 | /* SDRAMEA: 64MB */ | ||
158 | mov r1, #0x5000000 | ||
159 | str r1, [r0, #0xF04] | ||
160 | |||
161 | /* SDRC_REFCTL */ | ||
162 | mwh 0x309A8, 0 | ||
163 | |||
164 | ldr r0, =0x309A6 | ||
165 | mov r2, #0x1380 | ||
166 | orr r1, r2, #2 | ||
167 | strh r1, [r0] | ||
168 | orr r1, r2, #4 | ||
169 | strh r1, [r0] | ||
170 | strh r1, [r0] | ||
171 | strh r1, [r0] | ||
172 | strh r1, [r0] | ||
173 | strh r1, [r0] | ||
174 | strh r1, [r0] | ||
175 | strh r1, [r0] | ||
176 | strh r1, [r0] | ||
177 | orr r1, r2, #1 | ||
178 | strh r1, [r0] | ||
179 | strh r2, [r0] | ||
180 | strh r2, [r0] | ||
181 | |||
182 | mwhm 0x309A8, 0x0140 | ||
183 | |||
184 | mwhm 0x309BE, 0x4 | ||
185 | mwhm 0x309BC, 0x2 | ||
186 | ldr r0, =0x309C4 | ||
187 | ldr r1, [r0] | ||
188 | orr r1, r1, #1 | ||
189 | strh r1, [r0] | ||
190 | |||
191 | ldr r0, =0x309A6 | ||
192 | mov r1, #0x1380 | ||
193 | strh r1, [r0] | ||
194 | bic r1, r1, #0x80 | ||
195 | strh r1, [r0] | ||
196 | orr r1, r1, #0x40 | ||
197 | strh r1, [r0] | ||
198 | |||
199 | mwhm 0x309A8, 0x0140 | ||
200 | |||
201 | /* Go through the GPIO initialization */ | ||
202 | /* Warning: setting some of the functions wrong will make OF unable | ||
203 | to boot (freeze during startup) */ | ||
204 | /* IO_GIO_FSEL0: Set up the GPIO pin functions 0-16 */ | ||
205 | mwhm 0x305A4, 0xC000 | ||
206 | |||
207 | /* IO_GIO_FSEL1: 17-24 */ | ||
208 | mwh 0x305A6, 0xAAAA | ||
209 | |||
210 | /* IO_GIO_FSEL2: 18-32 */ | ||
211 | mwh 0x305A8, 0xA80A | ||
212 | |||
213 | /* IO_GIO_FSEL3: 33-40 */ | ||
214 | mwh 0x305AA, 0x1007 | ||
215 | |||
216 | /* IO_GIO_DIR0 */ | ||
217 | mwh 0x30580, 0xFF77 | ||
218 | |||
219 | /* IO_GIO_DIR1 */ | ||
220 | mwh 0x30582, 0xEFFE | ||
221 | |||
222 | /* IO_GIO_DIR2 */ | ||
223 | mwh 0x30584, 0x01FD | ||
224 | |||
225 | /* IO_GIO_INV0 */ | ||
226 | mwh 0x30586, 0x0000 | ||
227 | |||
228 | /* IO_GIO_INV1 */ | ||
229 | mwh 0x30588, 0x0000 | ||
230 | |||
231 | /* IO_GIO_INV2 */ | ||
232 | mwh 0x3058A, 0x0000 | ||
233 | |||
234 | bx lr | ||
235 | |||
236 | .ltorg | ||
237 | .size _init_board, .-_init_board | ||
238 | |||