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