blob: 3880a402d8ad04a5ab567a327980ddc8ef3129ed [file] [log] [blame]
wdenkfe8c2802002-11-03 00:38:21 +00001/*
2 * armboot - Startup Code for ARM920 CPU-core
3 *
Albert ARIBAUDfa82f872011-08-04 18:45:45 +02004 * Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
5 * Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
Detlev Zundel792a09e2009-05-13 10:54:10 +02006 * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de>
wdenkfe8c2802002-11-03 00:38:21 +00007 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
wdenkfe8c2802002-11-03 00:38:21 +00009 */
10
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +020011#include <asm-offsets.h>
Wolfgang Denk9689ddc2009-07-27 10:06:39 +020012#include <common.h>
wdenkfe8c2802002-11-03 00:38:21 +000013#include <config.h>
wdenkfe8c2802002-11-03 00:38:21 +000014
15/*
16 *************************************************************************
17 *
Peter Pearse80767a62007-09-05 16:04:41 +010018 * Startup Code (called from the ARM reset exception vector)
wdenkfe8c2802002-11-03 00:38:21 +000019 *
20 * do important init only if we don't start from memory!
21 * relocate armboot to ram
22 * setup stack
23 * jump to second stage
24 *
25 *************************************************************************
26 */
27
Albert ARIBAUD41623c92014-04-15 16:13:51 +020028 .globl reset
wdenkfe8c2802002-11-03 00:38:21 +000029
Albert ARIBAUD41623c92014-04-15 16:13:51 +020030reset:
Heiko Schochercc7cdcb2010-09-17 13:10:43 +020031 /*
32 * set the cpu to SVC32 mode
33 */
34 mrs r0, cpsr
35 bic r0, r0, #0x1f
36 orr r0, r0, #0xd3
37 msr cpsr, r0
38
Heiko Schochercc7cdcb2010-09-17 13:10:43 +020039#if defined(CONFIG_AT91RM9200DK) || defined(CONFIG_AT91RM9200EK)
40 /*
41 * relocate exception table
42 */
43 ldr r0, =_start
44 ldr r1, =0x0
45 mov r2, #16
46copyex:
47 subs r2, r2, #1
48 ldr r3, [r0], #4
49 str r3, [r1], #4
50 bne copyex
51#endif
52
Heiko Schochercc7cdcb2010-09-17 13:10:43 +020053 /*
54 * we do sys-critical inits only at reboot,
55 * not when booting from ram!
56 */
57#ifndef CONFIG_SKIP_LOWLEVEL_INIT
58 bl cpu_init_crit
59#endif
60
Albert ARIBAUDe05e5de2013-01-08 10:18:02 +000061 bl _main
Heiko Schochercc7cdcb2010-09-17 13:10:43 +020062
63/*------------------------------------------------------------------------------*/
64
Albert ARIBAUDe05e5de2013-01-08 10:18:02 +000065 .globl c_runtime_cpu_setup
66c_runtime_cpu_setup:
67
68 mov pc, lr
69
wdenkfe8c2802002-11-03 00:38:21 +000070/*
71 *************************************************************************
72 *
73 * CPU_init_critical registers
74 *
75 * setup important registers
76 * setup memory timing
77 *
78 *************************************************************************
79 */
80
81
Wolfgang Denkdb28ddb2006-04-03 15:46:10 +020082#ifndef CONFIG_SKIP_LOWLEVEL_INIT
wdenkfe8c2802002-11-03 00:38:21 +000083cpu_init_crit:
84 /*
85 * flush v4 I/D caches
86 */
87 mov r0, #0
88 mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
89 mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */
90
91 /*
92 * disable MMU stuff and caches
93 */
94 mrc p15, 0, r0, c1, c0, 0
95 bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS)
96 bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
Yuichiro Gotoba10b852016-02-25 10:23:34 +090097 orr r0, r0, #0x00000002 @ set bit 1 (A) Align
wdenkfe8c2802002-11-03 00:38:21 +000098 orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache
99 mcr p15, 0, r0, c1, c0, 0
100
Simon Glassb5bd0982016-05-05 07:28:06 -0600101#ifndef CONFIG_SKIP_LOWLEVEL_INIT_ONLY
wdenkfe8c2802002-11-03 00:38:21 +0000102 /*
103 * before relocating, we have to setup RAM timing
104 * because memory timing is board-dependend, you will
wdenk400558b2005-04-02 23:52:25 +0000105 * find a lowlevel_init.S in your board directory.
wdenkfe8c2802002-11-03 00:38:21 +0000106 */
107 mov ip, lr
Peter Pearsed4fc6012007-08-14 10:10:52 +0100108
wdenk400558b2005-04-02 23:52:25 +0000109 bl lowlevel_init
wdenkfe8c2802002-11-03 00:38:21 +0000110 mov lr, ip
Simon Glassb5bd0982016-05-05 07:28:06 -0600111#endif
wdenkfe8c2802002-11-03 00:38:21 +0000112 mov pc, lr
Wolfgang Denkdb28ddb2006-04-03 15:46:10 +0200113#endif /* CONFIG_SKIP_LOWLEVEL_INIT */