2 * Startup Code for S3C44B0 CPU-core
7 * http://www.dave-tech.it
8 * http://www.wawnet.biz
9 * mailto:info@wawnet.biz
11 * See file CREDITS for list of people who contributed to this
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License as
16 * published by the Free Software Foundation; either version 2 of
17 * the License, or (at your option) any later version.
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 #include <asm-offsets.h>
41 add pc, pc, #0x0c000000
42 add pc, pc, #0x0c000000
43 add pc, pc, #0x0c000000
44 add pc, pc, #0x0c000000
45 add pc, pc, #0x0c000000
46 add pc, pc, #0x0c000000
47 add pc, pc, #0x0c000000
49 .balignl 16,0xdeadbeef
53 *************************************************************************
55 * Startup Code (reset vector)
57 * do important init only if we don't start from memory!
58 * relocate u-boot to ram
60 * jump to second stage
62 *************************************************************************
67 .word CONFIG_SYS_TEXT_BASE
70 * These are defined in the board-specific linker script.
71 * Subtracting _start from them lets the linker put their
72 * relative position in the executable instead of leaving
77 .word __bss_start - _start
84 /* IRQ stack memory (calculated at run-time) */
85 .globl IRQ_STACK_START
89 /* IRQ stack memory (calculated at run-time) */
90 .globl FIQ_STACK_START
95 /* IRQ stack memory (calculated at run-time) + 8 bytes */
96 .globl IRQ_STACK_START_IN
101 * the actual reset code
106 * set the cpu to SVC32 mode
114 * we do sys-critical inits only at reboot,
115 * not when booting from ram!
117 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
120 * before relocating, we have to setup RAM timing
121 * because memory timing is board-dependend, you will
122 * find a lowlevel_init.S in your board directory.
127 /* Set stackpointer in internal RAM to call board_init_f */
129 ldr sp, =(CONFIG_SYS_INIT_SP_ADDR)
130 bic sp, sp, #7 /* 8-byte alignment for ABI compliance */
134 /*------------------------------------------------------------------------------*/
137 * void relocate_code (addr_sp, gd, addr_moni)
139 * This "function" does not return, instead it continues in RAM
140 * after relocating the monitor code.
145 mov r4, r0 /* save addr_sp */
146 mov r5, r1 /* save addr of gd */
147 mov r6, r2 /* save addr of destination */
149 /* Set up the stack */
155 beq clear_bss /* skip relocation */
156 mov r1, r6 /* r1 <- scratch for copy_loop */
158 ldr r3, _bss_start_ofs
159 add r2, r0, r3 /* r2 <- source end address */
162 ldmia r0!, {r9-r10} /* copy from source address [r0] */
163 stmia r1!, {r9-r10} /* copy to target address [r1] */
164 cmp r0, r2 /* until source end address [r2] */
167 #ifndef CONFIG_PRELOADER
169 * fix .rel.dyn relocations
171 ldr r0, _TEXT_BASE /* r0 <- Text base */
172 sub r9, r6, r0 /* r9 <- relocation offset */
173 ldr r10, _dynsym_start_ofs /* r10 <- sym table ofs */
174 add r10, r10, r0 /* r10 <- sym table in FLASH */
175 ldr r2, _rel_dyn_start_ofs /* r2 <- rel dyn start ofs */
176 add r2, r2, r0 /* r2 <- rel dyn start in FLASH */
177 ldr r3, _rel_dyn_end_ofs /* r3 <- rel dyn end ofs */
178 add r3, r3, r0 /* r3 <- rel dyn end in FLASH */
180 ldr r0, [r2] /* r0 <- location to fix up, IN FLASH! */
181 add r0, r0, r9 /* r0 <- location to fix up in RAM */
184 cmp r7, #23 /* relative fixup? */
186 cmp r7, #2 /* absolute fixup? */
188 /* ignore unknown type of fixup */
191 /* absolute fix: set location to (offset) symbol value */
192 mov r1, r1, LSR #4 /* r1 <- symbol index in .dynsym */
193 add r1, r10, r1 /* r1 <- address of symbol in table */
194 ldr r1, [r1, #4] /* r1 <- symbol value */
195 add r1, r1, r9 /* r1 <- relocated sym addr */
198 /* relative fix: increase location by offset */
203 add r2, r2, #8 /* each rel.dyn entry is 8 bytes */
209 #ifndef CONFIG_PRELOADER
210 ldr r0, _bss_start_ofs
212 ldr r3, _TEXT_BASE /* Text base */
213 mov r4, r6 /* reloc addr */
216 mov r2, #0x00000000 /* clear */
218 clbss_l:str r2, [r0] /* clear loop... */
228 * We are done. Do not return, instead branch to second part of board
229 * initialization, now running from RAM.
231 ldr r0, _board_init_r_ofs
235 /* setup parameters for board_init_r */
236 mov r0, r5 /* gd_t */
237 mov r1, r6 /* dest_addr */
242 .word board_init_r - _start
245 .word __rel_dyn_start - _start
247 .word __rel_dyn_end - _start
249 .word __dynsym_start - _start
252 *************************************************************************
254 * CPU_init_critical registers
256 * setup important registers
257 * setup memory timing
259 *************************************************************************
262 #define INTCON (0x01c00000+0x200000)
263 #define INTMSK (0x01c00000+0x20000c)
264 #define LOCKTIME (0x01c00000+0x18000c)
265 #define PLLCON (0x01c00000+0x180000)
266 #define CLKCON (0x01c00000+0x180004)
267 #define WTCON (0x01c00000+0x130000)
269 /* disable watch dog */
275 * mask all IRQs by clearing all bits in the INTMRs
285 /* Set Clock Control Register */
292 #if CONFIG_S3C44B0_CLOCK_SPEED==66
293 ldr r0, =0x34031 /* 66MHz (Quartz=11MHz) */
294 #elif CONFIG_S3C44B0_CLOCK_SPEED==75
295 ldr r0, =0x610c1 /*B2: Xtal=20mhz Fclk=75MHz */
297 # error CONFIG_S3C44B0_CLOCK_SPEED undefined
309 /*************************************************/
310 /* interrupt vectors */
311 /*************************************************/
314 b undefined_instruction
322 /*************************************************/
324 undefined_instruction:
341 /* we *should* never reach this */