blob: 69cabebed91edbba882b5b7821f22aaaa3969bcc [file] [log] [blame]
wdenkfe8c2802002-11-03 00:38:21 +00001/*
2 * armboot - Startup Code for ARM920 CPU-core
3 *
Albert ARIBAUD60fbc8d2011-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 Zundelf1b3f2b2009-05-13 10:54:10 +02006 * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de>
wdenkfe8c2802002-11-03 00:38:21 +00007 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
wdenkfe8c2802002-11-03 00:38:21 +00009 */
10
Wolfgang Denk0191e472010-10-26 14:34:52 +020011#include <asm-offsets.h>
Wolfgang Denk140f0442009-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 Pearse782cf162007-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 ARIBAUD9852cc62014-04-15 16:13:51 +020028 .globl reset
wdenkfe8c2802002-11-03 00:38:21 +000029
Albert ARIBAUD9852cc62014-04-15 16:13:51 +020030reset:
wdenkfe8c2802002-11-03 00:38:21 +000031 /*
32 * set the cpu to SVC32 mode
33 */
kevin.morfitt@fearnside-systems.co.ukd1cacc72009-10-10 13:30:22 +090034 mrs r0, cpsr
35 bic r0, r0, #0x1f
36 orr r0, r0, #0xd3
37 msr cpsr, r0
Peter Pearse782cf162007-09-05 16:04:41 +010038
Jean-Christophe PLAGNIOL-VILLARD06f34962008-11-30 19:36:50 +010039#if defined(CONFIG_AT91RM9200DK) || defined(CONFIG_AT91RM9200EK)
Peter Pearsede5b02c2007-08-14 10:10:52 +010040 /*
Peter Pearse782cf162007-09-05 16:04:41 +010041 * relocate exception table
Peter Pearsede5b02c2007-08-14 10:10:52 +010042 */
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
kevin.morfitt@fearnside-systems.co.uke0d81312009-11-17 18:30:34 +090053#ifdef CONFIG_S3C24X0
Peter Pearse782cf162007-09-05 16:04:41 +010054 /* turn off the watchdog */
55
56# if defined(CONFIG_S3C2400)
kevin.morfitt@fearnside-systems.co.ukd1cacc72009-10-10 13:30:22 +090057# define pWTCON 0x15300000
Mike Williamsbf895ad2011-07-22 04:01:30 +000058# define INTMSK 0x14400008 /* Interrupt-Controller base addresses */
Peter Pearse782cf162007-09-05 16:04:41 +010059# define CLKDIVN 0x14800014 /* clock divisor register */
60#else
kevin.morfitt@fearnside-systems.co.ukd1cacc72009-10-10 13:30:22 +090061# define pWTCON 0x53000000
Mike Williamsbf895ad2011-07-22 04:01:30 +000062# define INTMSK 0x4A000008 /* Interrupt-Controller base addresses */
Peter Pearse782cf162007-09-05 16:04:41 +010063# define INTSUBMSK 0x4A00001C
64# define CLKDIVN 0x4C000014 /* clock divisor register */
65# endif
66
kevin.morfitt@fearnside-systems.co.ukd1cacc72009-10-10 13:30:22 +090067 ldr r0, =pWTCON
68 mov r1, #0x0
69 str r1, [r0]
wdenkfe8c2802002-11-03 00:38:21 +000070
71 /*
72 * mask all IRQs by setting all bits in the INTMR - default
73 */
74 mov r1, #0xffffffff
75 ldr r0, =INTMSK
76 str r1, [r0]
wdenk7ac16102004-08-01 22:48:16 +000077# if defined(CONFIG_S3C2410)
wdenkfe8c2802002-11-03 00:38:21 +000078 ldr r1, =0x3ff
79 ldr r0, =INTSUBMSK
80 str r1, [r0]
wdenk7ac16102004-08-01 22:48:16 +000081# endif
wdenkfe8c2802002-11-03 00:38:21 +000082
83 /* FCLK:HCLK:PCLK = 1:2:4 */
84 /* default FCLK is 120 MHz ! */
85 ldr r0, =CLKDIVN
86 mov r1, #3
87 str r1, [r0]
kevin.morfitt@fearnside-systems.co.uke0d81312009-11-17 18:30:34 +090088#endif /* CONFIG_S3C24X0 */
wdenkfe8c2802002-11-03 00:38:21 +000089
90 /*
91 * we do sys-critical inits only at reboot,
92 * not when booting from ram!
93 */
wdenk3d3d99f2005-04-04 12:44:11 +000094#ifndef CONFIG_SKIP_LOWLEVEL_INIT
wdenkfe8c2802002-11-03 00:38:21 +000095 bl cpu_init_crit
96#endif
97
Albert ARIBAUDfacdae52013-01-08 10:18:02 +000098 bl _main
Heiko Schocher271a2402010-09-17 13:10:43 +020099
100/*------------------------------------------------------------------------------*/
101
Albert ARIBAUDfacdae52013-01-08 10:18:02 +0000102 .globl c_runtime_cpu_setup
103c_runtime_cpu_setup:
104
105 mov pc, lr
106
wdenkfe8c2802002-11-03 00:38:21 +0000107/*
108 *************************************************************************
109 *
110 * CPU_init_critical registers
111 *
112 * setup important registers
113 * setup memory timing
114 *
115 *************************************************************************
116 */
117
118
Wolfgang Denkf2e11a72006-04-03 15:46:10 +0200119#ifndef CONFIG_SKIP_LOWLEVEL_INIT
wdenkfe8c2802002-11-03 00:38:21 +0000120cpu_init_crit:
121 /*
122 * flush v4 I/D caches
123 */
124 mov r0, #0
125 mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
126 mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */
127
128 /*
129 * disable MMU stuff and caches
130 */
131 mrc p15, 0, r0, c1, c0, 0
132 bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS)
133 bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
Yuichiro Goto8d4b7e92016-02-25 10:23:34 +0900134 orr r0, r0, #0x00000002 @ set bit 1 (A) Align
wdenkfe8c2802002-11-03 00:38:21 +0000135 orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache
136 mcr p15, 0, r0, c1, c0, 0
137
wdenkfe8c2802002-11-03 00:38:21 +0000138 /*
139 * before relocating, we have to setup RAM timing
140 * because memory timing is board-dependend, you will
wdenk336b2bc2005-04-02 23:52:25 +0000141 * find a lowlevel_init.S in your board directory.
wdenkfe8c2802002-11-03 00:38:21 +0000142 */
143 mov ip, lr
Peter Pearsede5b02c2007-08-14 10:10:52 +0100144
wdenk336b2bc2005-04-02 23:52:25 +0000145 bl lowlevel_init
Ulf Samuelsson07f9b4e2009-03-27 23:26:43 +0100146
wdenkfe8c2802002-11-03 00:38:21 +0000147 mov lr, ip
wdenkfe8c2802002-11-03 00:38:21 +0000148 mov pc, lr
Wolfgang Denkf2e11a72006-04-03 15:46:10 +0200149#endif /* CONFIG_SKIP_LOWLEVEL_INIT */