2 * armboot - Startup Code for ARM1176 CPU-core
4 * Copyright (c) 2007 Samsung Electronics
7 * Guennadi Liakhovetki, DENX Software Engineering, <lg@denx.de>
9 * See file CREDITS for list of people who contributed to this
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 * 2007-09-21 - Restructured codes by jsgood (jsgood.yang@samsung.com)
28 * 2007-09-21 - Added MoviNAND and OneNAND boot codes by
29 * jsgood (jsgood.yang@samsung.com)
30 * Base codes by scsuh (sc.suh)
33 #include <asm-offsets.h>
37 #ifndef CONFIG_SYS_PHY_UBOOT_BASE
38 #define CONFIG_SYS_PHY_UBOOT_BASE CONFIG_SYS_UBOOT_BASE
42 *************************************************************************
44 * Jump vector table as in table 3.1 in [1]
46 *************************************************************************
51 #ifndef CONFIG_SPL_BUILD
52 ldr pc, _undefined_instruction
53 ldr pc, _software_interrupt
54 ldr pc, _prefetch_abort
60 _undefined_instruction:
61 .word undefined_instruction
63 .word software_interrupt
75 .word 0x12345678 /* now 16*4=64 */
82 .balignl 16,0xdeadbeef
84 *************************************************************************
86 * Startup Code (reset vector)
88 * do important init only if we don't start from memory!
89 * setup Memory and board specific bits prior to relocation.
90 * relocate armboot to ram
93 *************************************************************************
98 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
99 .word CONFIG_SPL_TEXT_BASE
101 .word CONFIG_SYS_TEXT_BASE
105 * These are defined in the board-specific linker script.
106 * Subtracting _start from them lets the linker put their
107 * relative position in the executable instead of leaving
111 .globl _bss_start_ofs
113 .word __bss_start - _start
117 .word __bss_end - _start
123 /* IRQ stack memory (calculated at run-time) + 8 bytes */
124 .globl IRQ_STACK_START_IN
129 * the actual reset code
134 * set the cpu to SVC32 mode
142 *************************************************************************
144 * CPU_init_critical registers
146 * setup important registers
147 * setup memory timing
149 *************************************************************************
152 * we do sys-critical inits only at reboot,
153 * not when booting from ram!
157 * When booting from NAND - it has definitely been a reset, so, no need
158 * to flush caches and disable the MMU
160 #ifndef CONFIG_SPL_BUILD
162 * flush v4 I/D caches
165 mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
166 mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */
169 * disable MMU stuff and caches
171 mrc p15, 0, r0, c1, c0, 0
172 bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS)
173 bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
174 orr r0, r0, #0x00000002 @ set bit 2 (A) Align
175 orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache
177 /* Prepare to disable the MMU */
178 adr r2, mmu_disable_phys
179 sub r2, r2, #(CONFIG_SYS_PHY_UBOOT_BASE - CONFIG_SYS_TEXT_BASE)
183 /* Run in a single cache-line */
185 mcr p15, 0, r0, c1, c0, 0
191 #ifdef CONFIG_DISABLE_TCM
195 mrc p15, 0, r0, c0, c0, 2 /* Return TCM details */
201 mcrne p15, 0, r1, c9, c1, 1 /* Disable Instruction TCM if present*/
203 mcrne p15, 0, r1, c9, c1, 0 /* Disable Data TCM if present*/
208 #ifdef CONFIG_PERIPORT_REMAP
209 /* Peri port setup */
210 ldr r0, =CONFIG_PERIPORT_BASE
211 orr r0, r0, #CONFIG_PERIPORT_SIZE
212 mcr p15,0,r0,c15,c2,4
216 * Go setup Memory and board specific bits prior to relocation.
218 bl lowlevel_init /* go setup pll,mux,memory */
222 /*------------------------------------------------------------------------------*/
224 .globl c_runtime_cpu_setup
229 #ifndef CONFIG_SPL_BUILD
231 *************************************************************************
235 *************************************************************************
240 #define S_FRAME_SIZE 72
262 #define MODE_SVC 0x13
266 * use bad_save_user_regs for abort/prefetch/undef/swi ...
269 .macro bad_save_user_regs
270 /* carve out a frame on current user stack */
271 sub sp, sp, #S_FRAME_SIZE
272 /* Save user registers (now in svc mode) r0-r12 */
275 ldr r2, IRQ_STACK_START_IN
276 /* get values for "aborted" pc and cpsr (into parm regs) */
278 /* grab pointer to old stack */
279 add r0, sp, #S_FRAME_SIZE
283 /* save sp_SVC, lr_SVC, pc, cpsr */
285 /* save current stack into r0 (param register) */
290 ldr r13, IRQ_STACK_START_IN @ setup our mode stack
292 /* save caller lr in position 0 of saved stack */
296 /* save spsr in position 1 of saved stack */
299 /* prepare SVC-Mode */
302 /* switch modes, make sure moves will execute */
304 /* capture return pc */
306 /* jump to next instruction & switch modes. */
310 .macro get_bad_stack_swi
311 /* space on current stack for scratch reg. */
313 /* save R0's value. */
315 ldr r13, IRQ_STACK_START_IN @ setup our mode stack
316 /* save caller lr in position 0 of saved stack */
320 /* save spsr in position 1 of saved stack */
326 /* pop stack entry */
334 undefined_instruction:
337 bl do_undefined_instruction
343 bl do_software_interrupt
374 #endif /* CONFIG_SPL_BUILD */