Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 2 | /* |
| 3 | * armboot - Startup Code for ARM926EJS CPU-core |
| 4 | * |
| 5 | * Copyright (c) 2003 Texas Instruments |
| 6 | * |
wdenk | e3a0680 | 2004-06-06 23:13:55 +0000 | [diff] [blame] | 7 | * ----- Adapted for OMAP1610 OMAP730 from ARM925t code ------ |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 8 | * |
Albert ARIBAUD | 60fbc8d | 2011-08-04 18:45:45 +0200 | [diff] [blame] | 9 | * Copyright (c) 2001 Marius Gröger <mag@sysgo.de> |
| 10 | * Copyright (c) 2002 Alex Züpke <azu@sysgo.de> |
Detlev Zundel | f1b3f2b | 2009-05-13 10:54:10 +0200 | [diff] [blame] | 11 | * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de> |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 12 | * Copyright (c) 2003 Richard Woodruff <r-woodruff2@ti.com> |
| 13 | * Copyright (c) 2003 Kshitij <kshitij@ti.com> |
Albert ARIBAUD | 340983d | 2011-04-22 19:41:02 +0200 | [diff] [blame] | 14 | * Copyright (c) 2010 Albert Aribaud <albert.u.boot@aribaud.net> |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 15 | */ |
| 16 | |
Wolfgang Denk | 0191e47 | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 17 | #include <asm-offsets.h> |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 18 | #include <config.h> |
Icenowy Zheng | 362132f | 2022-01-29 10:23:00 -0500 | [diff] [blame] | 19 | #include <linux/linkage.h> |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 20 | |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 21 | /* |
| 22 | ************************************************************************* |
| 23 | * |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 24 | * Startup Code (reset vector) |
| 25 | * |
| 26 | * do important init only if we don't start from memory! |
| 27 | * setup Memory and board specific bits prior to relocation. |
| 28 | * relocate armboot to ram |
| 29 | * setup stack |
| 30 | * |
| 31 | ************************************************************************* |
| 32 | */ |
| 33 | |
Albert ARIBAUD | 9852cc6 | 2014-04-15 16:13:51 +0200 | [diff] [blame] | 34 | .globl reset |
Icenowy Zheng | 362132f | 2022-01-29 10:23:00 -0500 | [diff] [blame] | 35 | .globl save_boot_params_ret |
| 36 | .type save_boot_params_ret,%function |
Heiko Schocher | 0e2412a | 2010-09-17 13:10:42 +0200 | [diff] [blame] | 37 | |
| 38 | reset: |
Icenowy Zheng | 362132f | 2022-01-29 10:23:00 -0500 | [diff] [blame] | 39 | /* Allow the board to save important registers */ |
| 40 | b save_boot_params |
| 41 | save_boot_params_ret: |
Heiko Schocher | 0e2412a | 2010-09-17 13:10:42 +0200 | [diff] [blame] | 42 | /* |
| 43 | * set the cpu to SVC32 mode |
| 44 | */ |
| 45 | mrs r0,cpsr |
| 46 | bic r0,r0,#0x1f |
| 47 | orr r0,r0,#0xd3 |
| 48 | msr cpsr,r0 |
| 49 | |
| 50 | /* |
| 51 | * we do sys-critical inits only at reboot, |
| 52 | * not when booting from ram! |
| 53 | */ |
Tom Rini | e1e8544 | 2021-08-27 21:18:30 -0400 | [diff] [blame] | 54 | #if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) |
Heiko Schocher | 0e2412a | 2010-09-17 13:10:42 +0200 | [diff] [blame] | 55 | bl cpu_init_crit |
Christian Riesch | 11bf576 | 2012-02-02 00:44:37 +0000 | [diff] [blame] | 56 | #endif |
Heiko Schocher | 0e2412a | 2010-09-17 13:10:42 +0200 | [diff] [blame] | 57 | |
Albert ARIBAUD | facdae5 | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 58 | bl _main |
Heiko Schocher | 0e2412a | 2010-09-17 13:10:42 +0200 | [diff] [blame] | 59 | |
| 60 | /*------------------------------------------------------------------------------*/ |
| 61 | |
Albert ARIBAUD | facdae5 | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 62 | .globl c_runtime_cpu_setup |
| 63 | c_runtime_cpu_setup: |
| 64 | |
| 65 | bx lr |
| 66 | |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 67 | /* |
| 68 | ************************************************************************* |
| 69 | * |
| 70 | * CPU_init_critical registers |
| 71 | * |
| 72 | * setup important registers |
| 73 | * setup memory timing |
| 74 | * |
| 75 | ************************************************************************* |
| 76 | */ |
Tom Rini | e1e8544 | 2021-08-27 21:18:30 -0400 | [diff] [blame] | 77 | #if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 78 | cpu_init_crit: |
| 79 | /* |
Sughosh Ganu | 4cb7186 | 2012-02-02 00:44:38 +0000 | [diff] [blame] | 80 | * flush D cache before disabling it |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 81 | */ |
| 82 | mov r0, #0 |
Sughosh Ganu | 4cb7186 | 2012-02-02 00:44:38 +0000 | [diff] [blame] | 83 | flush_dcache: |
| 84 | mrc p15, 0, r15, c7, c10, 3 |
| 85 | bne flush_dcache |
| 86 | |
| 87 | mcr p15, 0, r0, c8, c7, 0 /* invalidate TLB */ |
| 88 | mcr p15, 0, r0, c7, c5, 0 /* invalidate I Cache */ |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 89 | |
| 90 | /* |
Christian Riesch | a927d26 | 2012-02-02 00:44:40 +0000 | [diff] [blame] | 91 | * disable MMU and D cache |
Trevor Woerner | 43ec7e0 | 2019-05-03 09:41:00 -0400 | [diff] [blame] | 92 | * enable I cache if SYS_ICACHE_OFF is not defined |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 93 | */ |
| 94 | mrc p15, 0, r0, c1, c0, 0 |
Christian Riesch | 48c2d6d | 2012-02-02 00:44:39 +0000 | [diff] [blame] | 95 | bic r0, r0, #0x00000300 /* clear bits 9:8 (---- --RS) */ |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 96 | bic r0, r0, #0x00000087 /* clear bits 7, 2:0 (B--- -CAM) */ |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 97 | #ifdef CFG_SYS_EXCEPTION_VECTORS_HIGH |
Christian Riesch | 48c2d6d | 2012-02-02 00:44:39 +0000 | [diff] [blame] | 98 | orr r0, r0, #0x00002000 /* set bit 13 (--V- ----) */ |
| 99 | #else |
| 100 | bic r0, r0, #0x00002000 /* clear bit 13 (--V- ----) */ |
| 101 | #endif |
Yuichiro Goto | 8d4b7e9 | 2016-02-25 10:23:34 +0900 | [diff] [blame] | 102 | orr r0, r0, #0x00000002 /* set bit 1 (A) Align */ |
Trevor Woerner | 43ec7e0 | 2019-05-03 09:41:00 -0400 | [diff] [blame] | 103 | #if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF) |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 104 | orr r0, r0, #0x00001000 /* set bit 12 (I) I-Cache */ |
Christian Riesch | a927d26 | 2012-02-02 00:44:40 +0000 | [diff] [blame] | 105 | #endif |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 106 | mcr p15, 0, r0, c1, c0, 0 |
| 107 | |
Tom Rini | e1e8544 | 2021-08-27 21:18:30 -0400 | [diff] [blame] | 108 | #if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT_ONLY) |
wdenk | 7eaacc5 | 2003-08-29 22:00:43 +0000 | [diff] [blame] | 109 | /* |
| 110 | * Go setup Memory and board specific bits prior to relocation. |
| 111 | */ |
Mans Rullgard | 96db04f | 2018-04-21 16:11:07 +0100 | [diff] [blame] | 112 | mov r4, lr /* perserve link reg across call */ |
Wolfgang Denk | 7f88a5e | 2005-10-06 17:08:18 +0200 | [diff] [blame] | 113 | bl lowlevel_init /* go setup pll,mux,memory */ |
Mans Rullgard | 96db04f | 2018-04-21 16:11:07 +0100 | [diff] [blame] | 114 | mov lr, r4 /* restore link */ |
Simon Glass | 9084407 | 2016-05-05 07:28:06 -0600 | [diff] [blame] | 115 | #endif |
Heiko Schocher | c8a6d75 | 2011-11-09 20:06:23 +0000 | [diff] [blame] | 116 | mov pc, lr /* back to my caller */ |
Tom Rini | e1e8544 | 2021-08-27 21:18:30 -0400 | [diff] [blame] | 117 | #endif /* CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) */ |
Icenowy Zheng | 362132f | 2022-01-29 10:23:00 -0500 | [diff] [blame] | 118 | |
| 119 | /************************************************************************* |
| 120 | * |
| 121 | * void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3) |
| 122 | * __attribute__((weak)); |
| 123 | * |
| 124 | * Stack pointer is not yet initialized at this moment |
| 125 | * Don't save anything to stack even if compiled with -O0 |
| 126 | * |
| 127 | *************************************************************************/ |
| 128 | WEAK(save_boot_params) |
| 129 | b save_boot_params_ret /* back to my caller */ |
| 130 | ENDPROC(save_boot_params) |