2 * Copyright (C) 2003 Josef Baumgartner <josef.baumgartner@telex.de>
3 * Based on code from Bernhard Kuhn <bkuhn@metrowerks.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #ifndef CONFIG_IDENT_STRING
28 #define CONFIG_IDENT_STRING ""
37 move.w #0x2700,%sr; /* disable intrs */ \
38 subl #60,%sp; /* space for 15 regs */ \
39 moveml %d0-%d7/%a0-%a6,%sp@; \
42 moveml %sp@,%d0-%d7/%a0-%a6; \
43 addl #60,%sp; /* space for 15 regs */ \
46 /* If we come from a pre-loader we don't need an initial exception
49 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
53 * Vector table. This is used for initial platform startup.
54 * These vectors are to catch any un-intended traps.
58 .long 0x00000000, _START
59 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
60 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
61 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
62 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
63 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
64 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
65 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
66 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
68 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
69 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
70 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
71 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
72 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
73 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
74 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
75 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
77 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
78 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
79 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
80 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
81 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
82 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
83 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
84 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
86 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
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
105 /* if we come from a pre-loader we have no exception table and
106 * therefore no VBR to set
108 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
109 move.l #CFG_FLASH_BASE, %d0
113 #if defined(CONFIG_M5272) || defined(CONFIG_M5249)
114 move.l #(CFG_MBAR + 1), %d0 /* set MBAR address + valid flag */
117 /*** The 5249 has MBAR2 as well ***/
119 move.l #(CFG_MBAR2 + 1), %d0 /* Get MBAR2 address */
120 movec %d0, #0xc0e /* Set MBAR2 */
123 move.l #(CFG_INIT_RAM_ADDR + 1), %d0
125 #endif /* #if defined(CONFIG_M5272) || defined(CONFIG_M5249) */
128 /* Initialize IPSBAR */
129 move.l #(CFG_MBAR + 1), %d0 /* set IPSBAR address + valid flag */
130 move.l %d0, 0x40000000
132 /* Initialize FLASHBAR: locate internal Flash and validate it */
133 move.l #(CFG_INT_FLASH_BASE + 0x21), %d0
136 /* Initialize RAMBAR1: locate SRAM and validate it */
137 move.l #(CFG_INIT_RAM_ADDR + 0x21), %d0
141 /* invalidate and disable cache */
142 move.l #0x01000000, %d0 /* Invalidate cache cmd */
143 movec %d0, %CACR /* Invalidate cache */
148 /* set stackpointer to end of internal ram to get some stackspace for the first c-code */
149 move.l #(CFG_INIT_RAM_ADDR + CFG_INIT_SP_OFFSET), %sp
152 move.l #__got_start, %a5 /* put relocation table address to a5 */
154 bsr cpu_init_f /* run low-level CPU init code (from flash) */
155 bsr board_init_f /* run low-level board init code (from flash) */
157 /* board_init_f() does not return
159 /*------------------------------------------------------------------------------*/
162 * void relocate_code (addr_sp, gd, addr_moni)
164 * This "function" does not return, instead it continues in RAM
165 * after relocating the monitor code.
169 * r5 = length in bytes
175 move.l 8(%a6), %sp /* set new stack pointer */
177 move.l 12(%a6), %d0 /* Save copy of Global Data pointer */
178 move.l 16(%a6), %a0 /* Save copy of Destination Address */
180 move.l #CFG_MONITOR_BASE, %a1
181 move.l #__init_end, %a2
184 /* copy the code to RAM */
186 move.l (%a1)+, (%a3)+
191 * We are done. Do not return, instead branch to second part of board
192 * initialization, now running from RAM.
195 add.l #(in_ram - CFG_MONITOR_BASE), %a1
202 * Now clear BSS segment
205 add.l #(_sbss - CFG_MONITOR_BASE),%a1
207 add.l #(_ebss - CFG_MONITOR_BASE),%d1
214 * fix got table in RAM
217 add.l #(__got_start - CFG_MONITOR_BASE),%a1
218 move.l %a1,%a5 /* * fix got pointer register a5 */
221 add.l #(__got_end - CFG_MONITOR_BASE),%a2
231 /* calculate relative jump to board_init_r in ram */
233 add.l #(board_init_r - CFG_MONITOR_BASE), %a1
235 /* set parameters for board_init_r */
236 move.l %a0,-(%sp) /* dest_addr */
237 move.l %d0,-(%sp) /* gd */
240 /*------------------------------------------------------------------------------*/
262 /*------------------------------------------------------------------------------*/
263 /* cache functions */
267 move.l #0x01000000, %d0 /* Invalidate cache cmd */
268 movec %d0, %CACR /* Invalidate cache */
269 move.l #0x0000c000, %d0 /* Setup cache mask */
270 movec %d0, %ACR0 /* Enable cache */
271 move.l #0xff00c000, %d0 /* Setup cache mask */
272 movec %d0, %ACR1 /* Enable cache */
273 move.l #0x80000100, %d0 /* Setup cache mask */
274 movec %d0, %CACR /* Enable cache */
276 move.l %d0, icache_state
283 move.l #0x01000000, %d0 /* Invalidate cache cmd */
284 movec %d0, %CACR /* Invalidate cache */
285 move.l #0x0000c000, %d0 /* Setup cache mask */
286 movec %d0, %ACR0 /* Enable cache */
287 move.l #0xff00c000, %d0 /* Setup cache mask */
288 movec %d0, %ACR1 /* Enable cache */
289 move.l #0x80400100, %d0 /* Setup cache mask, data cache disabel*/
290 movec %d0, %CACR /* Enable cache */
292 move.l %d0, icache_state
300 * Note: The 5249 Documentation doesn't give a bit position for CINV!
301 * From the 5272 and the 5307 documentation, I have deduced that it is
302 * probably CACR[24]. Should someone say something to Motorola?
305 move.l #0x01000000, %d0 /* Invalidate whole cache */
307 move.l #0xff00c000, %d0 /* Set FLASH cachable: always match (SM=0b10) */
309 move.l #0x0000c000, %d0 /* Set SDRAM cachable: always match (SM=0b10) */
311 move.l #0x90000200, %d0 /* Set cache enable cmd */
314 move.l %d0, icache_state
318 .globl icache_disable
320 move.l #0x00000100, %d0 /* Setup cache mask */
321 movec %d0, %CACR /* Enable cache */
322 clr.l %d0 /* Setup cache mask */
323 movec %d0, %ACR0 /* Enable cache */
324 movec %d0, %ACR1 /* Enable cache */
326 move.l %d0, icache_state
331 move.l icache_state, %d0
339 /*------------------------------------------------------------------------------*/
341 .globl version_string
343 .ascii U_BOOT_VERSION
344 .ascii " (", __DATE__, " - ", __TIME__, ")"
345 .ascii CONFIG_IDENT_STRING, "\0"