]>
Commit | Line | Data |
---|---|---|
8ae158cd TL |
1 | /* |
2 | * Copyright (C) 2003 Josef Baumgartner <josef.baumgartner@telex.de> | |
3 | * Based on code from Bernhard Kuhn <bkuhn@metrowerks.com> | |
4 | * | |
45370e18 AW |
5 | * Copyright 2010-2012 Freescale Semiconductor, Inc. |
6 | * TsiChung Liew (Tsi-Chung.Liew@freescale.com) | |
7 | * | |
3765b3e7 | 8 | * SPDX-License-Identifier: GPL-2.0+ |
8ae158cd TL |
9 | */ |
10 | ||
45370e18 | 11 | #include <common.h> |
25ddd1fb | 12 | #include <asm-offsets.h> |
8ae158cd | 13 | #include <config.h> |
45370e18 | 14 | #include <timestamp.h> |
8ae158cd | 15 | #include "version.h" |
dd9f054e | 16 | #include <asm/cache.h> |
8ae158cd | 17 | |
8ae158cd TL |
18 | #define _START _start |
19 | #define _FAULT _fault | |
20 | ||
21 | #define SAVE_ALL \ | |
22 | move.w #0x2700,%sr; /* disable intrs */ \ | |
23 | subl #60,%sp; /* space for 15 regs */ \ | |
24 | moveml %d0-%d7/%a0-%a6,%sp@; | |
25 | ||
26 | #define RESTORE_ALL \ | |
27 | moveml %sp@,%d0-%d7/%a0-%a6; \ | |
28 | addl #60,%sp; /* space for 15 regs */ \ | |
29 | rte; | |
30 | ||
45370e18 | 31 | #if defined(CONFIG_SERIAL_BOOT) |
5c928d02 AD |
32 | #define ASM_DRAMINIT (asm_dram_init - CONFIG_SYS_TEXT_BASE + \ |
33 | CONFIG_SYS_INIT_RAM_ADDR) | |
61a4392a | 34 | #define ASM_DRAMINIT_N (asm_dram_init - CONFIG_SYS_TEXT_BASE) |
5c928d02 AD |
35 | #define ASM_SBF_IMG_HDR (asm_sbf_img_hdr - CONFIG_SYS_TEXT_BASE + \ |
36 | CONFIG_SYS_INIT_RAM_ADDR) | |
9f751551 TL |
37 | #endif |
38 | ||
8ae158cd | 39 | .text |
9f751551 | 40 | |
8ae158cd | 41 | /* |
5c928d02 AD |
42 | * Vector table. This is used for initial platform startup. |
43 | * These vectors are to catch any un-intended traps. | |
8ae158cd TL |
44 | */ |
45 | _vectors: | |
45370e18 | 46 | #if defined(CONFIG_SERIAL_BOOT) |
9f751551 | 47 | |
5c928d02 | 48 | INITSP: .long 0 /* Initial SP */ |
45370e18 | 49 | #ifdef CONFIG_CF_SBF |
5c928d02 | 50 | INITPC: .long ASM_DRAMINIT /* Initial PC */ |
45370e18 AW |
51 | #endif |
52 | #ifdef CONFIG_SYS_NAND_BOOT | |
5c928d02 | 53 | INITPC: .long ASM_DRAMINIT_N /* Initial PC */ |
45370e18 | 54 | #endif |
9f751551 TL |
55 | |
56 | #else | |
57 | ||
5c928d02 AD |
58 | INITSP: .long 0 /* Initial SP */ |
59 | INITPC: .long _START /* Initial PC */ | |
9f751551 TL |
60 | |
61 | #endif | |
8ae158cd | 62 | |
5c928d02 AD |
63 | vector02_0F: |
64 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
65 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
8ae158cd TL |
66 | |
67 | /* Reserved */ | |
68 | vector10_17: | |
69 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
70 | ||
5c928d02 AD |
71 | vector18_1F: |
72 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
8ae158cd | 73 | |
45370e18 | 74 | #if !defined(CONFIG_SERIAL_BOOT) |
9f751551 | 75 | |
8ae158cd TL |
76 | /* TRAP #0 - #15 */ |
77 | vector20_2F: | |
78 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
79 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
80 | ||
81 | /* Reserved */ | |
82 | vector30_3F: | |
83 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
84 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
85 | ||
86 | vector64_127: | |
87 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
88 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
89 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
90 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
91 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
92 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
93 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
94 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
95 | ||
96 | vector128_191: | |
97 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
98 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
99 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
100 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
101 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
102 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
103 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
104 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
105 | ||
106 | vector192_255: | |
107 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
108 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
109 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
110 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
111 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
112 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
113 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
114 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
9f751551 | 115 | #endif |
8ae158cd | 116 | |
45370e18 | 117 | #if defined(CONFIG_SERIAL_BOOT) |
9f751551 TL |
118 | /* Image header: chksum 4 bytes, len 4 bytes, img dest 4 bytes */ |
119 | asm_sbf_img_hdr: | |
5c928d02 AD |
120 | .long 0x00000000 /* checksum, not yet implemented */ |
121 | .long 0x00040000 /* image length */ | |
14d0a02a | 122 | .long CONFIG_SYS_TEXT_BASE /* image to be relocated at */ |
9f751551 TL |
123 | |
124 | asm_dram_init: | |
5c928d02 | 125 | move.w #0x2700,%sr /* Mask off Interrupt */ |
709b384b | 126 | |
45370e18 AW |
127 | #ifdef CONFIG_SYS_NAND_BOOT |
128 | /* for assembly stack */ | |
129 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0 | |
130 | movec %d0, %RAMBAR1 | |
131 | ||
132 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET), %sp | |
5c928d02 | 133 | clr.l %sp@- |
45370e18 AW |
134 | #endif |
135 | ||
136 | #ifdef CONFIG_CF_SBF | |
709b384b TL |
137 | move.l #CONFIG_SYS_INIT_RAM_ADDR, %d0 |
138 | movec %d0, %VBR | |
139 | ||
6d0f6bcf | 140 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0 |
709b384b TL |
141 | movec %d0, %RAMBAR1 |
142 | ||
143 | /* initialize general use internal ram */ | |
5c928d02 AD |
144 | move.l #0, %d0 |
145 | move.l #(ICACHE_STATUS), %a1 /* icache */ | |
146 | move.l #(DCACHE_STATUS), %a2 /* dcache */ | |
147 | move.l %d0, (%a1) | |
148 | move.l %d0, (%a2) | |
709b384b TL |
149 | |
150 | /* invalidate and disable cache */ | |
dd9f054e | 151 | move.l #(CONFIG_SYS_ICACHE_INV + CONFIG_SYS_DCACHE_INV), %d0 |
709b384b TL |
152 | movec %d0, %CACR /* Invalidate cache */ |
153 | move.l #0, %d0 | |
154 | movec %d0, %ACR0 | |
155 | movec %d0, %ACR1 | |
156 | movec %d0, %ACR2 | |
157 | movec %d0, %ACR3 | |
158 | ||
6d0f6bcf | 159 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET), %sp |
5c928d02 | 160 | clr.l %sp@- |
9f751551 TL |
161 | |
162 | /* Must disable global address */ | |
163 | move.l #0xFC008000, %a1 | |
6d0f6bcf | 164 | move.l #(CONFIG_SYS_CS0_BASE), (%a1) |
9f751551 | 165 | move.l #0xFC008008, %a1 |
6d0f6bcf | 166 | move.l #(CONFIG_SYS_CS0_CTRL), (%a1) |
9f751551 | 167 | move.l #0xFC008004, %a1 |
6d0f6bcf | 168 | move.l #(CONFIG_SYS_CS0_MASK), (%a1) |
5c928d02 | 169 | #endif /* CONFIG_CF_SBF */ |
45370e18 AW |
170 | |
171 | #ifdef CONFIG_MCF5441x | |
172 | /* TC: enable all peripherals, | |
173 | in the future only enable certain peripherals */ | |
174 | move.l #0xFC04002D, %a1 | |
9f751551 | 175 | |
45370e18 | 176 | #if defined(CONFIG_CF_SBF) |
5c928d02 | 177 | move.b #23, (%a1) /* dspi */ |
45370e18 | 178 | #endif |
c74dda8b | 179 | #endif /* CONFIG_MCF5441x */ |
45370e18 | 180 | |
c74dda8b AD |
181 | /* mandatory board level ddr-sdram init, |
182 | * for both 5441x and 5445x | |
183 | */ | |
184 | bsr sbf_dram_init | |
709b384b | 185 | |
45370e18 | 186 | #ifdef CONFIG_CF_SBF |
9f751551 TL |
187 | /* |
188 | * DSPI Initialization | |
189 | * a0 - general, sram - 0x80008000 - 32, see M54455EVB.h | |
190 | * a1 - dspi status | |
191 | * a2 - dtfr | |
192 | * a3 - drfr | |
193 | * a4 - Dst addr | |
194 | */ | |
195 | /* Enable pins for DSPI mode - chip-selects are enabled later */ | |
709b384b | 196 | asm_dspi_init: |
45370e18 AW |
197 | #ifdef CONFIG_MCF5441x |
198 | move.l #0xEC09404E, %a1 | |
199 | move.l #0xEC09404F, %a2 | |
200 | move.b #0xFF, (%a1) | |
201 | move.b #0x80, (%a2) | |
202 | #endif | |
203 | ||
204 | #ifdef CONFIG_MCF5445x | |
9f751551 TL |
205 | move.l #0xFC0A4063, %a0 |
206 | move.b #0x7F, (%a0) | |
45370e18 | 207 | #endif |
9f751551 TL |
208 | /* Configure DSPI module */ |
209 | move.l #0xFC05C000, %a0 | |
210 | move.l #0x80FF0C00, (%a0) /* Master, clear TX/RX FIFO */ | |
211 | ||
212 | move.l #0xFC05C00C, %a0 | |
45370e18 AW |
213 | #ifdef CONFIG_MCF5441x |
214 | move.l #0x3E000016, (%a0) | |
215 | #endif | |
216 | #ifdef CONFIG_MCF5445x | |
9f751551 | 217 | move.l #0x3E000011, (%a0) |
45370e18 | 218 | #endif |
9f751551 TL |
219 | |
220 | move.l #0xFC05C034, %a2 /* dtfr */ | |
221 | move.l #0xFC05C03B, %a3 /* drfr */ | |
222 | ||
223 | move.l #(ASM_SBF_IMG_HDR + 4), %a1 | |
224 | move.l (%a1)+, %d5 | |
225 | move.l (%a1), %a4 | |
226 | ||
6d0f6bcf JCPV |
227 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_SBFHDR_DATA_OFFSET), %a0 |
228 | move.l #(CONFIG_SYS_SBFHDR_SIZE), %d4 | |
9f751551 TL |
229 | |
230 | move.l #0xFC05C02C, %a1 /* dspi status */ | |
231 | ||
232 | /* Issue commands and address */ | |
233 | move.l #0x8002000B, %d2 /* Fast Read Cmd */ | |
234 | jsr asm_dspi_wr_status | |
235 | jsr asm_dspi_rd_status | |
236 | ||
237 | move.l #0x80020000, %d2 /* Address byte 2 */ | |
238 | jsr asm_dspi_wr_status | |
239 | jsr asm_dspi_rd_status | |
240 | ||
241 | move.l #0x80020000, %d2 /* Address byte 1 */ | |
242 | jsr asm_dspi_wr_status | |
243 | jsr asm_dspi_rd_status | |
244 | ||
245 | move.l #0x80020000, %d2 /* Address byte 0 */ | |
246 | jsr asm_dspi_wr_status | |
247 | jsr asm_dspi_rd_status | |
248 | ||
249 | move.l #0x80020000, %d2 /* Dummy Wr and Rd */ | |
250 | jsr asm_dspi_wr_status | |
251 | jsr asm_dspi_rd_status | |
252 | ||
253 | /* Transfer serial boot header to sram */ | |
254 | asm_dspi_rd_loop1: | |
255 | move.l #0x80020000, %d2 | |
256 | jsr asm_dspi_wr_status | |
257 | jsr asm_dspi_rd_status | |
258 | ||
259 | move.b %d1, (%a0) /* read, copy to dst */ | |
260 | ||
261 | add.l #1, %a0 /* inc dst by 1 */ | |
262 | sub.l #1, %d4 /* dec cnt by 1 */ | |
263 | bne asm_dspi_rd_loop1 | |
264 | ||
265 | /* Transfer u-boot from serial flash to memory */ | |
266 | asm_dspi_rd_loop2: | |
267 | move.l #0x80020000, %d2 | |
268 | jsr asm_dspi_wr_status | |
269 | jsr asm_dspi_rd_status | |
270 | ||
271 | move.b %d1, (%a4) /* read, copy to dst */ | |
272 | ||
273 | add.l #1, %a4 /* inc dst by 1 */ | |
274 | sub.l #1, %d5 /* dec cnt by 1 */ | |
275 | bne asm_dspi_rd_loop2 | |
276 | ||
277 | move.l #0x00020000, %d2 /* Terminate */ | |
278 | jsr asm_dspi_wr_status | |
279 | jsr asm_dspi_rd_status | |
280 | ||
281 | /* jump to memory and execute */ | |
14d0a02a | 282 | move.l #(CONFIG_SYS_TEXT_BASE + 0x400), %a0 |
9f751551 TL |
283 | jmp (%a0) |
284 | ||
285 | asm_dspi_wr_status: | |
286 | move.l (%a1), %d0 /* status */ | |
287 | and.l #0x0000F000, %d0 | |
288 | cmp.l #0x00003000, %d0 | |
289 | bgt asm_dspi_wr_status | |
290 | ||
291 | move.l %d2, (%a2) | |
292 | rts | |
293 | ||
294 | asm_dspi_rd_status: | |
295 | move.l (%a1), %d0 /* status */ | |
296 | and.l #0x000000F0, %d0 | |
297 | lsr.l #4, %d0 | |
298 | cmp.l #0, %d0 | |
299 | beq asm_dspi_rd_status | |
300 | ||
301 | move.b (%a3), %d1 | |
302 | rts | |
5c928d02 | 303 | #endif /* CONFIG_CF_SBF */ |
45370e18 AW |
304 | |
305 | #ifdef CONFIG_SYS_NAND_BOOT | |
306 | /* copy 4 boot pages to dram as soon as possible */ | |
307 | /* each page is 996 bytes (1056 total with 60 ECC bytes */ | |
308 | move.l #0x00000000, %a1 /* src */ | |
61a4392a | 309 | move.l #CONFIG_SYS_TEXT_BASE, %a2 /* dst */ |
45370e18 AW |
310 | move.l #0x3E0, %d0 /* sz in long */ |
311 | ||
312 | asm_boot_nand_copy: | |
313 | move.l (%a1)+, (%a2)+ | |
314 | subq.l #1, %d0 | |
315 | bne asm_boot_nand_copy | |
316 | ||
317 | /* jump to memory and execute */ | |
318 | move.l #(asm_nand_init), %a0 | |
319 | jmp (%a0) | |
320 | ||
321 | asm_nand_init: | |
322 | /* exit nand boot-mode */ | |
323 | move.l #0xFC0FFF30, %a1 | |
324 | or.l #0x00000040, %d1 | |
325 | move.l %d1, (%a1) | |
326 | ||
327 | /* initialize general use internal ram */ | |
5c928d02 AD |
328 | move.l #0, %d0 |
329 | move.l #(CACR_STATUS), %a1 /* CACR */ | |
330 | move.l #(ICACHE_STATUS), %a2 /* icache */ | |
331 | move.l #(DCACHE_STATUS), %a3 /* dcache */ | |
332 | move.l %d0, (%a1) | |
333 | move.l %d0, (%a2) | |
334 | move.l %d0, (%a3) | |
45370e18 AW |
335 | |
336 | /* invalidate and disable cache */ | |
337 | move.l #0x01004100, %d0 /* Invalidate cache cmd */ | |
338 | movec %d0, %CACR /* Invalidate cache */ | |
339 | move.l #0, %d0 | |
340 | movec %d0, %ACR0 | |
341 | movec %d0, %ACR1 | |
342 | movec %d0, %ACR2 | |
343 | movec %d0, %ACR3 | |
344 | ||
345 | /* Must disable global address */ | |
346 | move.l #0xFC008000, %a1 | |
347 | move.l #(CONFIG_SYS_CS0_BASE), (%a1) | |
348 | move.l #0xFC008008, %a1 | |
349 | move.l #(CONFIG_SYS_CS0_CTRL), (%a1) | |
350 | move.l #0xFC008004, %a1 | |
351 | move.l #(CONFIG_SYS_CS0_MASK), (%a1) | |
352 | ||
353 | /* NAND port configuration */ | |
354 | move.l #0xEC094048, %a1 | |
355 | move.b #0xFD, (%a1)+ | |
356 | move.b #0x5F, (%a1)+ | |
357 | move.b #0x04, (%a1)+ | |
358 | ||
359 | /* reset nand */ | |
360 | move.l #0xFC0FFF38, %a1 /* isr */ | |
361 | move.l #0x000e0000, (%a1) | |
362 | move.l #0xFC0FFF08, %a2 | |
363 | move.l #0x00000000, (%a2)+ /* car */ | |
364 | move.l #0x11000000, (%a2)+ /* rar */ | |
365 | move.l #0x00000000, (%a2)+ /* rpt */ | |
366 | move.l #0x00000000, (%a2)+ /* rai */ | |
367 | move.l #0xFC0FFF2c, %a2 /* cfg */ | |
368 | move.l #0x00000000, (%a2)+ /* secsz */ | |
369 | move.l #0x000e0681, (%a2)+ | |
370 | move.l #0xFC0FFF04, %a2 /* cmd2 */ | |
371 | move.l #0xFF404001, (%a2) | |
372 | move.l #0x000e0000, (%a1) | |
373 | ||
374 | move.l #0x2000, %d1 | |
c74dda8b | 375 | bsr asm_delay |
45370e18 AW |
376 | |
377 | /* setup nand */ | |
378 | move.l #0xFC0FFF00, %a1 | |
379 | move.l #0x30700000, (%a1)+ /* cmd1 */ | |
380 | move.l #0x007EF000, (%a1)+ /* cmd2 */ | |
381 | ||
382 | move.l #0xFC0FFF2C, %a1 | |
383 | move.l #0x00000841, (%a1)+ /* secsz */ | |
384 | move.l #0x000e0681, (%a1)+ /* cfg */ | |
385 | ||
386 | move.l #100, %d4 /* 100 pages ~200KB */ | |
387 | move.l #4, %d2 /* start at 4 */ | |
388 | move.l #0xFC0FFF04, %a0 /* cmd2 */ | |
389 | move.l #0xFC0FFF0C, %a1 /* rar */ | |
5c928d02 | 390 | move.l #(CONFIG_SYS_TEXT_BASE + 0xF80), %a2 |
45370e18 AW |
391 | |
392 | asm_nand_read: | |
393 | move.l #0x11000000, %d0 /* rar */ | |
394 | or.l %d2, %d0 | |
395 | move.l %d0, (%a1) | |
396 | add.l #1, %d2 | |
397 | ||
398 | move.l (%a0), %d0 /* cmd2 */ | |
399 | or.l #1, %d0 | |
400 | move.l %d0, (%a0) | |
401 | ||
402 | move.l #0x200, %d1 | |
c74dda8b | 403 | bsr asm_delay |
45370e18 AW |
404 | |
405 | asm_nand_chk_status: | |
406 | move.l #0xFC0FFF38, %a4 /* isr */ | |
407 | move.l (%a4), %d0 | |
408 | and.l #0x40000000, %d0 | |
409 | tst.l %d0 | |
410 | beq asm_nand_chk_status | |
411 | ||
412 | move.l #0xFC0FFF38, %a4 /* isr */ | |
413 | move.l (%a4), %d0 | |
414 | or.l #0x000E0000, %d0 | |
415 | move.l %d0, (%a4) | |
416 | ||
417 | move.l #0x200, %d3 | |
418 | move.l #0xFC0FC000, %a3 /* buf 1 */ | |
419 | asm_nand_copy: | |
420 | move.l (%a3)+, (%a2)+ | |
421 | subq.l #1, %d3 | |
422 | bgt asm_nand_copy | |
423 | ||
424 | subq.l #1, %d4 | |
425 | bgt asm_nand_read | |
426 | ||
427 | /* jump to memory and execute */ | |
61a4392a | 428 | move.l #(CONFIG_SYS_TEXT_BASE + 0x400), %a0 |
45370e18 AW |
429 | jmp (%a0) |
430 | ||
431 | #endif /* CONFIG_SYS_NAND_BOOT */ | |
709b384b | 432 | |
c74dda8b | 433 | .globl asm_delay |
709b384b TL |
434 | asm_delay: |
435 | nop | |
436 | subq.l #1, %d1 | |
437 | bne asm_delay | |
438 | rts | |
45370e18 | 439 | #endif /* CONFIG_CF_SBF || CONFIG_NAND_U_BOOT */ |
9f751551 | 440 | |
5c928d02 | 441 | .text |
9f751551 | 442 | . = 0x400 |
5c928d02 | 443 | .globl _start |
8ae158cd | 444 | _start: |
45370e18 | 445 | #if !defined(CONFIG_SERIAL_BOOT) |
8ae158cd TL |
446 | nop |
447 | nop | |
5c928d02 | 448 | move.w #0x2700,%sr /* Mask off Interrupt */ |
8ae158cd TL |
449 | |
450 | /* Set vector base register at the beginning of the Flash */ | |
6d0f6bcf | 451 | move.l #CONFIG_SYS_FLASH_BASE, %d0 |
8ae158cd TL |
452 | movec %d0, %VBR |
453 | ||
6d0f6bcf | 454 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0 |
225a24b5 | 455 | movec %d0, %RAMBAR1 |
8ae158cd TL |
456 | |
457 | /* initialize general use internal ram */ | |
5c928d02 AD |
458 | move.l #0, %d0 |
459 | move.l #(ICACHE_STATUS), %a1 /* icache */ | |
460 | move.l #(DCACHE_STATUS), %a2 /* dcache */ | |
461 | move.l %d0, (%a1) | |
462 | move.l %d0, (%a2) | |
8ae158cd TL |
463 | |
464 | /* invalidate and disable cache */ | |
dd9f054e | 465 | move.l #(CONFIG_SYS_ICACHE_INV + CONFIG_SYS_DCACHE_INV), %d0 |
8ae158cd TL |
466 | movec %d0, %CACR /* Invalidate cache */ |
467 | move.l #0, %d0 | |
468 | movec %d0, %ACR0 | |
469 | movec %d0, %ACR1 | |
470 | movec %d0, %ACR2 | |
471 | movec %d0, %ACR3 | |
45370e18 AW |
472 | #else |
473 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0 | |
474 | movec %d0, %RAMBAR1 | |
475 | #endif | |
8ae158cd | 476 | |
5044c9cc | 477 | /* put relocation table address to a5 */ |
5c928d02 | 478 | move.l #__got_start, %a5 |
5044c9cc | 479 | |
480 | /* setup stack initially on top of internal static ram */ | |
5c928d02 | 481 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE), %sp |
5044c9cc | 482 | |
483 | /* | |
484 | * if configured, malloc_f arena will be reserved first, | |
485 | * then (and always) gd struct space will be reserved | |
486 | */ | |
487 | move.l %sp, -(%sp) | |
488 | move.l #board_init_f_alloc_reserve, %a1 | |
489 | jsr (%a1) | |
490 | ||
491 | /* update stack and frame-pointers */ | |
5c928d02 AD |
492 | move.l %d0, %sp |
493 | move.l %sp, %fp | |
8ae158cd | 494 | |
5044c9cc | 495 | /* initialize reserved area */ |
5c928d02 | 496 | move.l %d0, -(%sp) |
5044c9cc | 497 | move.l #board_init_f_init_reserve, %a1 |
498 | jsr (%a1) | |
8ae158cd | 499 | |
55ac54c4 | 500 | /* run low-level CPU init code (from flash) */ |
5c928d02 AD |
501 | move.l #cpu_init_f, %a1 |
502 | jsr (%a1) | |
503 | ||
55ac54c4 | 504 | /* run low-level board init code (from flash) */ |
5044c9cc | 505 | clr.l %sp@- |
5c928d02 AD |
506 | move.l #board_init_f, %a1 |
507 | jsr (%a1) | |
8ae158cd TL |
508 | |
509 | /* board_init_f() does not return */ | |
510 | ||
5c928d02 | 511 | /******************************************************************************/ |
8ae158cd TL |
512 | |
513 | /* | |
514 | * void relocate_code (addr_sp, gd, addr_moni) | |
515 | * | |
516 | * This "function" does not return, instead it continues in RAM | |
517 | * after relocating the monitor code. | |
518 | * | |
519 | * r3 = dest | |
520 | * r4 = src | |
521 | * r5 = length in bytes | |
522 | * r6 = cachelinesize | |
523 | */ | |
5c928d02 | 524 | .globl relocate_code |
8ae158cd | 525 | relocate_code: |
5c928d02 AD |
526 | link.w %a6,#0 |
527 | move.l 8(%a6), %sp /* set new stack pointer */ | |
8ae158cd | 528 | |
5c928d02 AD |
529 | move.l 12(%a6), %d0 /* Save copy of Global Data pointer */ |
530 | move.l 16(%a6), %a0 /* Save copy of Destination Address */ | |
8ae158cd | 531 | |
5c928d02 AD |
532 | move.l #CONFIG_SYS_MONITOR_BASE, %a1 |
533 | move.l #__init_end, %a2 | |
534 | move.l %a0, %a3 | |
8ae158cd TL |
535 | |
536 | /* copy the code to RAM */ | |
537 | 1: | |
5c928d02 AD |
538 | move.l (%a1)+, (%a3)+ |
539 | cmp.l %a1,%a2 | |
540 | bgt.s 1b | |
8ae158cd TL |
541 | |
542 | /* | |
543 | * We are done. Do not return, instead branch to second part of board | |
544 | * initialization, now running from RAM. | |
545 | */ | |
546 | move.l %a0, %a1 | |
6d0f6bcf | 547 | add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1 |
8ae158cd TL |
548 | jmp (%a1) |
549 | ||
550 | in_ram: | |
551 | ||
552 | clear_bss: | |
553 | /* | |
554 | * Now clear BSS segment | |
555 | */ | |
556 | move.l %a0, %a1 | |
6d0f6bcf | 557 | add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1 |
8ae158cd | 558 | move.l %a0, %d1 |
6d0f6bcf | 559 | add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1 |
8ae158cd TL |
560 | 6: |
561 | clr.l (%a1)+ | |
562 | cmp.l %a1,%d1 | |
563 | bgt.s 6b | |
564 | ||
565 | /* | |
566 | * fix got table in RAM | |
567 | */ | |
568 | move.l %a0, %a1 | |
6d0f6bcf | 569 | add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1 |
5c928d02 | 570 | move.l %a1,%a5 /* fix got pointer register a5 */ |
8ae158cd TL |
571 | |
572 | move.l %a0, %a2 | |
6d0f6bcf | 573 | add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2 |
8ae158cd TL |
574 | |
575 | 7: | |
576 | move.l (%a1),%d1 | |
577 | sub.l #_start,%d1 | |
578 | add.l %a0,%d1 | |
579 | move.l %d1,(%a1)+ | |
580 | cmp.l %a2, %a1 | |
581 | bne 7b | |
582 | ||
583 | /* calculate relative jump to board_init_r in ram */ | |
5c928d02 AD |
584 | move.l %a0, %a1 |
585 | add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1 | |
8ae158cd TL |
586 | |
587 | /* set parameters for board_init_r */ | |
5c928d02 AD |
588 | move.l %a0,-(%sp) /* dest_addr */ |
589 | move.l %d0,-(%sp) /* gd */ | |
8ae158cd TL |
590 | jsr (%a1) |
591 | ||
5c928d02 AD |
592 | /******************************************************************************/ |
593 | ||
8ae158cd | 594 | /* exception code */ |
5c928d02 | 595 | .globl _fault |
8ae158cd | 596 | _fault: |
5c928d02 | 597 | bra _fault |
8ae158cd | 598 | |
5c928d02 | 599 | .globl _exc_handler |
8ae158cd TL |
600 | _exc_handler: |
601 | SAVE_ALL | |
602 | movel %sp,%sp@- | |
5c928d02 | 603 | bsr exc_handler |
8ae158cd TL |
604 | addql #4,%sp |
605 | RESTORE_ALL | |
606 | ||
5c928d02 | 607 | .globl _int_handler |
8ae158cd TL |
608 | _int_handler: |
609 | SAVE_ALL | |
610 | movel %sp,%sp@- | |
5c928d02 | 611 | bsr int_handler |
8ae158cd TL |
612 | addql #4,%sp |
613 | RESTORE_ALL | |
614 | ||
5c928d02 | 615 | /******************************************************************************/ |
8ae158cd | 616 | |
5c928d02 | 617 | .globl version_string |
8ae158cd | 618 | version_string: |
5c928d02 AD |
619 | .ascii U_BOOT_VERSION_STRING, "\0" |
620 | .align 4 |