2 * armboot - Startup Code for OMP2420/ARM1136 CPU-core
4 * Copyright (c) 2004-2006 Texas Instruments
6 * Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
7 * Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
8 * Copyright (c) 2002 Gary Jennejohn <gj@denx.de>
9 * Copyright (c) 2003 Richard Woodruff <r-woodruff2@ti.com>
10 * Copyright (c) 2003 Kshitij <kshitij@ti.com>
11 * Copyright (c) 2004 Jian Zhang <jzhang@ti.com>
13 * See file CREDITS for list of people who contributed to this
16 * This program is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU General Public License as
18 * published by the Free Software Foundation; either version 2 of
19 * the License, or (at your option) any later version.
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; if not, write to the Free Software
28 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
33 #include <asm/arch/cpu.h>
55 .word 0x12345678 /* now 16*4=64 */
60 .balignl 16,0xdeadbeef
62 *************************************************************************
64 * Startup Code (reset vector)
66 * do important init only if we don't start from memory!
67 * setup Memory and board specific bits prior to relocation.
68 * relocate armboot to ram
71 *************************************************************************
82 * These are defined in the board-specific linker script.
93 * the actual reset code
98 * set the cpu to SVC32 mode
105 /* Copy vectors to mask ROM indirect addr */
106 adr r0, _start /* r0 <- current position of code */
107 add r0, r0, #4 /* skip reset vector */
108 mov r2, #64 /* r2 <- size to copy */
109 add r2, r0, r2 /* r2 <- source end address */
110 mov r1, #SRAM_OFFSET0 /* build vect addr */
111 mov r3, #SRAM_OFFSET1
113 mov r3, #SRAM_OFFSET2
116 ldmia r0!, {r3-r10} /* copy from source address [r0] */
117 stmia r1!, {r3-r10} /* copy to target address [r1] */
118 cmp r0, r2 /* until source end address [r2] */
119 bne next /* loop until equal */
121 bl cpy_clk_code /* put dpll adjust code behind vectors */
123 /* the mask ROM code should have PLL and others stable */
126 relocate: /* relocate U-Boot to RAM */
127 adr r0, _start /* r0 <- current position of code */
128 ldr r1, _TEXT_BASE /* test if we run from flash or RAM */
129 cmp r0, r1 /* no need to relocate if XIP */
130 beq stack_setup /* skip txt cpy if XIP(SRAM, SDRAM) */
132 ldr r2, _armboot_start
134 sub r2, r3, r2 /* r2 <- size of armboot */
135 add r2, r0, r2 /* r2 <- source end address */
138 ldmia r0!, {r3-r10} /* copy from source address [r0] */
139 stmia r1!, {r3-r10} /* copy to target address [r1] */
140 cmp r0, r2 /* until source end addreee [r2] */
143 /* Set up the stack */
145 ldr r0, _TEXT_BASE /* upper 128 KiB: relocated uboot */
146 sub sp, r0, #128 /* leave 32 words for abort-stack */
147 and sp, sp, #~7 /* 8 byte alinged for (ldr/str)d */
149 /* Clear BSS (if any). Is below tx (watch load addr - need space) */
151 ldr r0, _bss_start /* find start of bss segment */
152 ldr r1, _bss_end /* stop here */
153 mov r2, #0x00000000 /* clear value */
155 str r2, [r0] /* clear BSS location */
156 cmp r0, r1 /* are we at the end yet */
157 add r0, r0, #4 /* increment clear index pointer */
158 bne clbss_l /* keep clearing till at end */
160 ldr pc, _start_armboot /* jump to C code */
162 _start_armboot: .word start_armboot
166 *************************************************************************
168 * CPU_init_critical registers
170 * setup important registers
171 * setup memory timing
173 *************************************************************************
179 mov r0, #0 /* set up for MCR */
180 mcr p15, 0, r0, c8, c7, 0 /* invalidate TLBs */
181 mcr p15, 0, r0, c7, c5, 1 /* invalidate icache */
183 /* Invalide L2 cache (gp device call point)
184 * - warning, this may have issues on EMU/HS devices
185 * this call can corrupt r0-r5
187 mov r12, #0x1 @ set up to invalide L2
188 smi: .word 0xE1600070 @ Call SMI monitor
191 * disable MMU stuff and caches
193 mrc p15, 0, r0, c1, c0, 0
194 bic r0, r0, #0x00002000 @ clear bits 13 (--V-)
195 bic r0, r0, #0x00000007 @ clear bits 2:0 (-CAM)
196 orr r0, r0, #0x00000002 @ set bit 1 (--A-) Align
197 #ifndef CONFIG_ICACHE_OFF
198 orr r0, r0, #0x00001800 @ set bit 11,12 (---I Z---) BTB,I-Cache
200 mcr p15, 0, r0, c1, c0, 0
203 * Jump to board specific initialization... The Mask ROM will have already initialized
204 * basic memory. Go here to bump up clock rate and handle wake up conditions.
206 adr r0, _start /* r0 <- current position of code */
207 ldr r1, _TEXT_BASE /* test if we run from flash or RAM */
208 cmp r0, r1 /* pass on info about skipping some init portions */
209 moveq r0,#0x1 /* flag to skip prcm and sdrc setup */
212 mov ip, lr /* persevere link reg across call */
213 bl lowlevel_init /* go setup pll,mux,memory */
214 mov lr, ip /* restore link */
215 mov pc, lr /* back to my caller */
222 ldr sp, _TEXT_BASE /* use 32 words abort stack */
223 bl hang /* hang and never return */