Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 2 | /* |
| 3 | * armboot - Startup Code for ARM920 CPU-core |
| 4 | * |
Albert ARIBAUD | fa82f87 | 2011-08-04 18:45:45 +0200 | [diff] [blame] | 5 | * Copyright (c) 2001 Marius Gröger <mag@sysgo.de> |
| 6 | * Copyright (c) 2002 Alex Züpke <azu@sysgo.de> |
Detlev Zundel | 792a09e | 2009-05-13 10:54:10 +0200 | [diff] [blame] | 7 | * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 8 | */ |
| 9 | |
Wolfgang Denk | 25ddd1f | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 10 | #include <asm-offsets.h> |
Wolfgang Denk | 9689ddc | 2009-07-27 10:06:39 +0200 | [diff] [blame] | 11 | #include <common.h> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 12 | #include <config.h> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 13 | |
| 14 | /* |
| 15 | ************************************************************************* |
| 16 | * |
Peter Pearse | 80767a6 | 2007-09-05 16:04:41 +0100 | [diff] [blame] | 17 | * Startup Code (called from the ARM reset exception vector) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 18 | * |
| 19 | * do important init only if we don't start from memory! |
| 20 | * relocate armboot to ram |
| 21 | * setup stack |
| 22 | * jump to second stage |
| 23 | * |
| 24 | ************************************************************************* |
| 25 | */ |
| 26 | |
Albert ARIBAUD | 41623c9 | 2014-04-15 16:13:51 +0200 | [diff] [blame] | 27 | .globl reset |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 28 | |
Albert ARIBAUD | 41623c9 | 2014-04-15 16:13:51 +0200 | [diff] [blame] | 29 | reset: |
Heiko Schocher | cc7cdcb | 2010-09-17 13:10:43 +0200 | [diff] [blame] | 30 | /* |
| 31 | * set the cpu to SVC32 mode |
| 32 | */ |
| 33 | mrs r0, cpsr |
| 34 | bic r0, r0, #0x1f |
| 35 | orr r0, r0, #0xd3 |
| 36 | msr cpsr, r0 |
| 37 | |
Heiko Schocher | cc7cdcb | 2010-09-17 13:10:43 +0200 | [diff] [blame] | 38 | #if defined(CONFIG_AT91RM9200DK) || defined(CONFIG_AT91RM9200EK) |
| 39 | /* |
| 40 | * relocate exception table |
| 41 | */ |
| 42 | ldr r0, =_start |
| 43 | ldr r1, =0x0 |
| 44 | mov r2, #16 |
| 45 | copyex: |
| 46 | subs r2, r2, #1 |
| 47 | ldr r3, [r0], #4 |
| 48 | str r3, [r1], #4 |
| 49 | bne copyex |
| 50 | #endif |
| 51 | |
Heiko Schocher | cc7cdcb | 2010-09-17 13:10:43 +0200 | [diff] [blame] | 52 | /* |
| 53 | * we do sys-critical inits only at reboot, |
| 54 | * not when booting from ram! |
| 55 | */ |
| 56 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT |
| 57 | bl cpu_init_crit |
| 58 | #endif |
| 59 | |
Albert ARIBAUD | e05e5de | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 60 | bl _main |
Heiko Schocher | cc7cdcb | 2010-09-17 13:10:43 +0200 | [diff] [blame] | 61 | |
| 62 | /*------------------------------------------------------------------------------*/ |
| 63 | |
Albert ARIBAUD | e05e5de | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 64 | .globl c_runtime_cpu_setup |
| 65 | c_runtime_cpu_setup: |
| 66 | |
| 67 | mov pc, lr |
| 68 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 69 | /* |
| 70 | ************************************************************************* |
| 71 | * |
| 72 | * CPU_init_critical registers |
| 73 | * |
| 74 | * setup important registers |
| 75 | * setup memory timing |
| 76 | * |
| 77 | ************************************************************************* |
| 78 | */ |
| 79 | |
| 80 | |
Wolfgang Denk | db28ddb | 2006-04-03 15:46:10 +0200 | [diff] [blame] | 81 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 82 | cpu_init_crit: |
| 83 | /* |
| 84 | * flush v4 I/D caches |
| 85 | */ |
| 86 | mov r0, #0 |
| 87 | mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */ |
| 88 | mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */ |
| 89 | |
| 90 | /* |
| 91 | * disable MMU stuff and caches |
| 92 | */ |
| 93 | mrc p15, 0, r0, c1, c0, 0 |
| 94 | bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS) |
| 95 | bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM) |
Yuichiro Goto | ba10b85 | 2016-02-25 10:23:34 +0900 | [diff] [blame] | 96 | orr r0, r0, #0x00000002 @ set bit 1 (A) Align |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 97 | orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache |
| 98 | mcr p15, 0, r0, c1, c0, 0 |
| 99 | |
Simon Glass | b5bd098 | 2016-05-05 07:28:06 -0600 | [diff] [blame] | 100 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT_ONLY |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 101 | /* |
| 102 | * before relocating, we have to setup RAM timing |
| 103 | * because memory timing is board-dependend, you will |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 104 | * find a lowlevel_init.S in your board directory. |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 105 | */ |
| 106 | mov ip, lr |
Peter Pearse | d4fc601 | 2007-08-14 10:10:52 +0100 | [diff] [blame] | 107 | |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 108 | bl lowlevel_init |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 109 | mov lr, ip |
Simon Glass | b5bd098 | 2016-05-05 07:28:06 -0600 | [diff] [blame] | 110 | #endif |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 111 | mov pc, lr |
Wolfgang Denk | db28ddb | 2006-04-03 15:46:10 +0200 | [diff] [blame] | 112 | #endif /* CONFIG_SKIP_LOWLEVEL_INIT */ |