blob: 78183fc19bc40874a341e000277868164d5447f2 [file] [log] [blame]
wdenk074cff02004-02-24 00:16:43 +00001/*
2 * Startup Code for S3C44B0 CPU-core
3 *
4 * (C) Copyright 2004
5 * DAVE Srl
6 *
7 * http://www.dave-tech.it
8 * http://www.wawnet.biz
9 * mailto:info@wawnet.biz
10 *
11 * See file CREDITS for list of people who contributed to this
12 * project.
13 *
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.
18 *
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.
23 *
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,
27 * MA 02111-1307 USA
28 */
29
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +020030#include <asm-offsets.h>
wdenk074cff02004-02-24 00:16:43 +000031#include <config.h>
32#include <version.h>
33
wdenk074cff02004-02-24 00:16:43 +000034/*
35 * Jump vector table
36 */
37
38
39.globl _start
40_start: b reset
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
48
49 .balignl 16,0xdeadbeef
50
51
52/*
53 *************************************************************************
54 *
55 * Startup Code (reset vector)
56 *
57 * do important init only if we don't start from memory!
58 * relocate u-boot to ram
59 * setup stack
60 * jump to second stage
61 *
62 *************************************************************************
63 */
64
Heiko Schocher01109552010-09-17 13:10:49 +020065.globl _TEXT_BASE
wdenk074cff02004-02-24 00:16:43 +000066_TEXT_BASE:
Benoît Thébaudeau508611b2013-04-11 09:35:42 +000067#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
68 .word CONFIG_SPL_TEXT_BASE
69#else
Wolfgang Denk14d0a022010-10-07 21:51:12 +020070 .word CONFIG_SYS_TEXT_BASE
Benoît Thébaudeau508611b2013-04-11 09:35:42 +000071#endif
wdenk074cff02004-02-24 00:16:43 +000072
wdenk074cff02004-02-24 00:16:43 +000073/*
wdenk42dfe7a2004-03-14 22:25:36 +000074 * These are defined in the board-specific linker script.
Albert Aribaud3336ca62010-11-25 22:45:02 +010075 * Subtracting _start from them lets the linker put their
76 * relative position in the executable instead of leaving
77 * them null.
wdenk074cff02004-02-24 00:16:43 +000078 */
Albert Aribaud3336ca62010-11-25 22:45:02 +010079.globl _bss_start_ofs
80_bss_start_ofs:
81 .word __bss_start - _start
wdenk42dfe7a2004-03-14 22:25:36 +000082
Albert Aribaud3336ca62010-11-25 22:45:02 +010083.globl _bss_end_ofs
84_bss_end_ofs:
Simon Glass3929fb02013-03-14 06:54:53 +000085 .word __bss_end - _start
wdenk074cff02004-02-24 00:16:43 +000086
Po-Yu Chuangf326cbb2011-03-01 23:02:04 +000087.globl _end_ofs
88_end_ofs:
89 .word _end - _start
90
wdenk074cff02004-02-24 00:16:43 +000091#ifdef CONFIG_USE_IRQ
92/* IRQ stack memory (calculated at run-time) */
93.globl IRQ_STACK_START
94IRQ_STACK_START:
95 .word 0x0badc0de
96
97/* IRQ stack memory (calculated at run-time) */
98.globl FIQ_STACK_START
99FIQ_STACK_START:
100 .word 0x0badc0de
101#endif
102
Heiko Schocher01109552010-09-17 13:10:49 +0200103/* IRQ stack memory (calculated at run-time) + 8 bytes */
104.globl IRQ_STACK_START_IN
105IRQ_STACK_START_IN:
106 .word 0x0badc0de
wdenk074cff02004-02-24 00:16:43 +0000107
Heiko Schocher01109552010-09-17 13:10:49 +0200108/*
109 * the actual reset code
110 */
111
112reset:
113 /*
114 * set the cpu to SVC32 mode
115 */
116 mrs r0,cpsr
117 bic r0,r0,#0x1f
118 orr r0,r0,#0xd3
119 msr cpsr,r0
120
121 /*
122 * we do sys-critical inits only at reboot,
123 * not when booting from ram!
124 */
125#ifndef CONFIG_SKIP_LOWLEVEL_INIT
126 bl cpu_init_crit
127 /*
128 * before relocating, we have to setup RAM timing
129 * because memory timing is board-dependend, you will
130 * find a lowlevel_init.S in your board directory.
131 */
132 bl lowlevel_init
133#endif
134
Albert ARIBAUDe05e5de2013-01-08 10:18:02 +0000135 bl _main
Heiko Schocher01109552010-09-17 13:10:49 +0200136
137/*------------------------------------------------------------------------------*/
138
Albert ARIBAUDe05e5de2013-01-08 10:18:02 +0000139 .globl c_runtime_cpu_setup
140c_runtime_cpu_setup:
141
142 bx lr
143
wdenk074cff02004-02-24 00:16:43 +0000144/*
145 *************************************************************************
146 *
147 * CPU_init_critical registers
148 *
149 * setup important registers
150 * setup memory timing
151 *
152 *************************************************************************
153 */
154
155#define INTCON (0x01c00000+0x200000)
156#define INTMSK (0x01c00000+0x20000c)
157#define LOCKTIME (0x01c00000+0x18000c)
158#define PLLCON (0x01c00000+0x180000)
159#define CLKCON (0x01c00000+0x180004)
160#define WTCON (0x01c00000+0x130000)
161cpu_init_crit:
162 /* disable watch dog */
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200163 ldr r0, =WTCON
wdenk074cff02004-02-24 00:16:43 +0000164 ldr r1, =0x0
165 str r1, [r0]
166
167 /*
168 * mask all IRQs by clearing all bits in the INTMRs
169 */
170 ldr r1,=INTMSK
171 ldr r0, =0x03fffeff
172 str r0, [r1]
173
174 ldr r1, =INTCON
175 ldr r0, =0x05
176 str r0, [r1]
177
178 /* Set Clock Control Register */
179 ldr r1, =LOCKTIME
180 ldrb r0, =800
181 strb r0, [r1]
182
183 ldr r1, =PLLCON
184
185#if CONFIG_S3C44B0_CLOCK_SPEED==66
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200186 ldr r0, =0x34031 /* 66MHz (Quartz=11MHz) */
wdenk074cff02004-02-24 00:16:43 +0000187#elif CONFIG_S3C44B0_CLOCK_SPEED==75
188 ldr r0, =0x610c1 /*B2: Xtal=20mhz Fclk=75MHz */
189#else
190# error CONFIG_S3C44B0_CLOCK_SPEED undefined
191#endif
192
193 str r0, [r1]
194
195 ldr r1,=CLKCON
196 ldr r0, =0x7ff8
197 str r0, [r1]
198
199 mov pc, lr
200
201
202/*************************************************/
203/* interrupt vectors */
204/*************************************************/
205real_vectors:
206 b reset
207 b undefined_instruction
208 b software_interrupt
209 b prefetch_abort
210 b data_abort
211 b not_used
212 b irq
213 b fiq
214
215/*************************************************/
216
217undefined_instruction:
218 mov r6, #3
219 b reset
220
221software_interrupt:
222 mov r6, #4
223 b reset
224
225prefetch_abort:
226 mov r6, #5
227 b reset
228
229data_abort:
230 mov r6, #6
231 b reset
232
233not_used:
234 /* we *should* never reach this */
235 mov r6, #7
236 b reset
237
238irq:
239 mov r6, #8
240 b reset
241
242fiq:
243 mov r6, #9
244 b reset