wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 1 | /* |
| 2 | * armboot - Startup Code for SA1100 CPU |
| 3 | * |
| 4 | * Copyright (C) 1998 Dan Malek <dmalek@jlc.net> |
| 5 | * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se> |
| 6 | * Copyright (C) 2000 Wolfgang Denk <wd@denx.de> |
Albert ARIBAUD | 60fbc8d | 2011-08-04 18:45:45 +0200 | [diff] [blame] | 7 | * Copyright (c) 2001 Alex Züpke <azu@sysgo.de> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 8 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
Wolfgang Denk | 0191e47 | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 12 | #include <asm-offsets.h> |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 13 | #include <config.h> |
| 14 | #include <version.h> |
| 15 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 16 | /* |
| 17 | ************************************************************************* |
| 18 | * |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 19 | * Startup Code (reset vector) |
| 20 | * |
| 21 | * do important init only if we don't start from memory! |
| 22 | * relocate armboot to ram |
| 23 | * setup stack |
| 24 | * jump to second stage |
| 25 | * |
| 26 | ************************************************************************* |
| 27 | */ |
| 28 | |
Albert ARIBAUD | 9852cc6 | 2014-04-15 16:13:51 +0200 | [diff] [blame] | 29 | .globl reset |
Heiko Schocher | 344c303 | 2010-09-17 13:10:48 +0200 | [diff] [blame] | 30 | |
| 31 | reset: |
| 32 | /* |
| 33 | * set the cpu to SVC32 mode |
| 34 | */ |
| 35 | mrs r0,cpsr |
| 36 | bic r0,r0,#0x1f |
| 37 | orr r0,r0,#0xd3 |
| 38 | msr cpsr,r0 |
| 39 | |
| 40 | /* |
| 41 | * we do sys-critical inits only at reboot, |
| 42 | * not when booting from ram! |
| 43 | */ |
| 44 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT |
| 45 | bl cpu_init_crit |
| 46 | #endif |
| 47 | |
Albert ARIBAUD | facdae5 | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 48 | bl _main |
Heiko Schocher | 344c303 | 2010-09-17 13:10:48 +0200 | [diff] [blame] | 49 | |
| 50 | /*------------------------------------------------------------------------------*/ |
| 51 | |
Albert ARIBAUD | facdae5 | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 52 | .globl c_runtime_cpu_setup |
| 53 | c_runtime_cpu_setup: |
| 54 | |
| 55 | mov pc, lr |
| 56 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 57 | /* |
| 58 | ************************************************************************* |
| 59 | * |
| 60 | * CPU_init_critical registers |
| 61 | * |
| 62 | * setup important registers |
| 63 | * setup memory timing |
| 64 | * |
| 65 | ************************************************************************* |
| 66 | */ |
| 67 | |
| 68 | |
Mike Williams | bf895ad | 2011-07-22 04:01:30 +0000 | [diff] [blame] | 69 | /* Interrupt-Controller base address */ |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 70 | IC_BASE: .word 0x90050000 |
| 71 | #define ICMR 0x04 |
| 72 | |
| 73 | |
| 74 | /* Reset-Controller */ |
| 75 | RST_BASE: .word 0x90030000 |
| 76 | #define RSRR 0x00 |
| 77 | #define RCSR 0x04 |
| 78 | |
| 79 | |
| 80 | /* PWR */ |
| 81 | PWR_BASE: .word 0x90020000 |
| 82 | #define PSPR 0x08 |
| 83 | #define PPCR 0x14 |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 84 | cpuspeed: .word CONFIG_SYS_CPUSPEED |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 85 | |
| 86 | |
| 87 | cpu_init_crit: |
| 88 | /* |
| 89 | * mask all IRQs |
| 90 | */ |
| 91 | ldr r0, IC_BASE |
| 92 | mov r1, #0x00 |
| 93 | str r1, [r0, #ICMR] |
| 94 | |
| 95 | /* set clock speed */ |
| 96 | ldr r0, PWR_BASE |
| 97 | ldr r1, cpuspeed |
| 98 | str r1, [r0, #PPCR] |
| 99 | |
| 100 | /* |
| 101 | * before relocating, we have to setup RAM timing |
| 102 | * because memory timing is board-dependend, you will |
wdenk | 336b2bc | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 103 | * find a lowlevel_init.S in your board directory. |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 104 | */ |
| 105 | mov ip, lr |
wdenk | 336b2bc | 2005-04-02 23:52:25 +0000 | [diff] [blame] | 106 | bl lowlevel_init |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 107 | mov lr, ip |
| 108 | |
| 109 | /* |
| 110 | * disable MMU stuff and enable I-cache |
| 111 | */ |
| 112 | mrc p15,0,r0,c1,c0 |
| 113 | bic r0, r0, #0x00002000 @ clear bit 13 (X) |
| 114 | bic r0, r0, #0x0000000f @ clear bits 3-0 (WCAM) |
| 115 | orr r0, r0, #0x00001000 @ set bit 12 (I) Icache |
| 116 | orr r0, r0, #0x00000002 @ set bit 2 (A) Align |
| 117 | mcr p15,0,r0,c1,c0 |
| 118 | |
| 119 | /* |
| 120 | * flush v4 I/D caches |
| 121 | */ |
| 122 | mov r0, #0 |
| 123 | mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */ |
| 124 | mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */ |
| 125 | |
| 126 | mov pc, lr |