wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * armboot - Startup Code for ARM920 CPU-core |
| 3 | * |
Albert ARIBAUD | fa82f87 | 2011-08-04 18:45:45 +0200 | [diff] [blame] | 4 | * Copyright (c) 2001 Marius Gröger <mag@sysgo.de> |
| 5 | * Copyright (c) 2002 Alex Züpke <azu@sysgo.de> |
Detlev Zundel | 792a09e | 2009-05-13 10:54:10 +0200 | [diff] [blame] | 6 | * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 7 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 8 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Wolfgang Denk | 25ddd1f | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 11 | #include <asm-offsets.h> |
Wolfgang Denk | 9689ddc | 2009-07-27 10:06:39 +0200 | [diff] [blame] | 12 | #include <common.h> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 13 | #include <config.h> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 14 | |
| 15 | /* |
| 16 | ************************************************************************* |
| 17 | * |
Peter Pearse | 80767a6 | 2007-09-05 16:04:41 +0100 | [diff] [blame] | 18 | * Startup Code (called from the ARM reset exception vector) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 19 | * |
| 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 ARIBAUD | 41623c9 | 2014-04-15 16:13:51 +0200 | [diff] [blame] | 28 | .globl reset |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 29 | |
Albert ARIBAUD | 41623c9 | 2014-04-15 16:13:51 +0200 | [diff] [blame] | 30 | reset: |
Heiko Schocher | cc7cdcb | 2010-09-17 13:10:43 +0200 | [diff] [blame] | 31 | /* |
| 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 Schocher | cc7cdcb | 2010-09-17 13:10:43 +0200 | [diff] [blame] | 39 | #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 |
| 46 | copyex: |
| 47 | subs r2, r2, #1 |
| 48 | ldr r3, [r0], #4 |
| 49 | str r3, [r1], #4 |
| 50 | bne copyex |
| 51 | #endif |
| 52 | |
| 53 | #ifdef CONFIG_S3C24X0 |
| 54 | /* turn off the watchdog */ |
| 55 | |
| 56 | # if defined(CONFIG_S3C2400) |
| 57 | # define pWTCON 0x15300000 |
Mike Williams | 1626308 | 2011-07-22 04:01:30 +0000 | [diff] [blame] | 58 | # define INTMSK 0x14400008 /* Interrupt-Controller base addresses */ |
Heiko Schocher | cc7cdcb | 2010-09-17 13:10:43 +0200 | [diff] [blame] | 59 | # define CLKDIVN 0x14800014 /* clock divisor register */ |
| 60 | #else |
| 61 | # define pWTCON 0x53000000 |
Mike Williams | 1626308 | 2011-07-22 04:01:30 +0000 | [diff] [blame] | 62 | # define INTMSK 0x4A000008 /* Interrupt-Controller base addresses */ |
Heiko Schocher | cc7cdcb | 2010-09-17 13:10:43 +0200 | [diff] [blame] | 63 | # define INTSUBMSK 0x4A00001C |
| 64 | # define CLKDIVN 0x4C000014 /* clock divisor register */ |
| 65 | # endif |
| 66 | |
| 67 | ldr r0, =pWTCON |
| 68 | mov r1, #0x0 |
| 69 | str r1, [r0] |
| 70 | |
| 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] |
| 77 | # if defined(CONFIG_S3C2410) |
| 78 | ldr r1, =0x3ff |
| 79 | ldr r0, =INTSUBMSK |
| 80 | str r1, [r0] |
| 81 | # endif |
| 82 | |
| 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] |
| 88 | #endif /* CONFIG_S3C24X0 */ |
| 89 | |
| 90 | /* |
| 91 | * we do sys-critical inits only at reboot, |
| 92 | * not when booting from ram! |
| 93 | */ |
| 94 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT |
| 95 | bl cpu_init_crit |
| 96 | #endif |
| 97 | |
Albert ARIBAUD | e05e5de | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 98 | bl _main |
Heiko Schocher | cc7cdcb | 2010-09-17 13:10:43 +0200 | [diff] [blame] | 99 | |
| 100 | /*------------------------------------------------------------------------------*/ |
| 101 | |
Albert ARIBAUD | e05e5de | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 102 | .globl c_runtime_cpu_setup |
| 103 | c_runtime_cpu_setup: |
| 104 | |
| 105 | mov pc, lr |
| 106 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 107 | /* |
| 108 | ************************************************************************* |
| 109 | * |
| 110 | * CPU_init_critical registers |
| 111 | * |
| 112 | * setup important registers |
| 113 | * setup memory timing |
| 114 | * |
| 115 | ************************************************************************* |
| 116 | */ |
| 117 | |
| 118 | |
Wolfgang Denk | db28ddb | 2006-04-03 15:46:10 +0200 | [diff] [blame] | 119 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 120 | cpu_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) |
| 134 | orr r0, r0, #0x00000002 @ set bit 2 (A) Align |
| 135 | orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache |
| 136 | mcr p15, 0, r0, c1, c0, 0 |
| 137 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 138 | /* |
| 139 | * before relocating, we have to setup RAM timing |
| 140 | * because memory timing is board-dependend, you will |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 141 | * find a lowlevel_init.S in your board directory. |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 142 | */ |
| 143 | mov ip, lr |
Peter Pearse | d4fc601 | 2007-08-14 10:10:52 +0100 | [diff] [blame] | 144 | |
wdenk | 400558b | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 145 | bl lowlevel_init |
Ulf Samuelsson | cb82a53 | 2009-03-27 23:26:43 +0100 | [diff] [blame] | 146 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 147 | mov lr, ip |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 148 | mov pc, lr |
Wolfgang Denk | db28ddb | 2006-04-03 15:46:10 +0200 | [diff] [blame] | 149 | #endif /* CONFIG_SKIP_LOWLEVEL_INIT */ |