blob: aca7793c5798bf3d678c8ae288ccdd96d7721f7f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
wdenk7eaacc52003-08-29 22:00:43 +00002/*
3 * armboot - Startup Code for ARM926EJS CPU-core
4 *
5 * Copyright (c) 2003 Texas Instruments
6 *
wdenke3a06802004-06-06 23:13:55 +00007 * ----- Adapted for OMAP1610 OMAP730 from ARM925t code ------
wdenk7eaacc52003-08-29 22:00:43 +00008 *
Albert ARIBAUD60fbc8d2011-08-04 18:45:45 +02009 * Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
10 * Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
Detlev Zundelf1b3f2b2009-05-13 10:54:10 +020011 * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de>
wdenk7eaacc52003-08-29 22:00:43 +000012 * Copyright (c) 2003 Richard Woodruff <r-woodruff2@ti.com>
13 * Copyright (c) 2003 Kshitij <kshitij@ti.com>
Albert ARIBAUD340983d2011-04-22 19:41:02 +020014 * Copyright (c) 2010 Albert Aribaud <albert.u.boot@aribaud.net>
wdenk7eaacc52003-08-29 22:00:43 +000015 */
16
Wolfgang Denk0191e472010-10-26 14:34:52 +020017#include <asm-offsets.h>
wdenk7eaacc52003-08-29 22:00:43 +000018#include <config.h>
Wolfgang Denk66e8d442009-07-24 00:17:48 +020019#include <common.h>
Icenowy Zheng362132f2022-01-29 10:23:00 -050020#include <linux/linkage.h>
wdenk7eaacc52003-08-29 22:00:43 +000021
wdenk7eaacc52003-08-29 22:00:43 +000022/*
23 *************************************************************************
24 *
wdenk7eaacc52003-08-29 22:00:43 +000025 * 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 ARIBAUD9852cc62014-04-15 16:13:51 +020035 .globl reset
Icenowy Zheng362132f2022-01-29 10:23:00 -050036 .globl save_boot_params_ret
37 .type save_boot_params_ret,%function
Heiko Schocher0e2412a2010-09-17 13:10:42 +020038
39reset:
Icenowy Zheng362132f2022-01-29 10:23:00 -050040 /* Allow the board to save important registers */
41 b save_boot_params
42save_boot_params_ret:
Heiko Schocher0e2412a2010-09-17 13:10:42 +020043 /*
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 Rinie1e85442021-08-27 21:18:30 -040055#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
Heiko Schocher0e2412a2010-09-17 13:10:42 +020056 bl cpu_init_crit
Christian Riesch11bf5762012-02-02 00:44:37 +000057#endif
Heiko Schocher0e2412a2010-09-17 13:10:42 +020058
Albert ARIBAUDfacdae52013-01-08 10:18:02 +000059 bl _main
Heiko Schocher0e2412a2010-09-17 13:10:42 +020060
61/*------------------------------------------------------------------------------*/
62
Albert ARIBAUDfacdae52013-01-08 10:18:02 +000063 .globl c_runtime_cpu_setup
64c_runtime_cpu_setup:
65
66 bx lr
67
wdenk7eaacc52003-08-29 22:00:43 +000068/*
69 *************************************************************************
70 *
71 * CPU_init_critical registers
72 *
73 * setup important registers
74 * setup memory timing
75 *
76 *************************************************************************
77 */
Tom Rinie1e85442021-08-27 21:18:30 -040078#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
wdenk7eaacc52003-08-29 22:00:43 +000079cpu_init_crit:
80 /*
Sughosh Ganu4cb71862012-02-02 00:44:38 +000081 * flush D cache before disabling it
wdenk7eaacc52003-08-29 22:00:43 +000082 */
83 mov r0, #0
Sughosh Ganu4cb71862012-02-02 00:44:38 +000084flush_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 */
wdenk7eaacc52003-08-29 22:00:43 +000090
91 /*
Christian Riescha927d262012-02-02 00:44:40 +000092 * disable MMU and D cache
Trevor Woerner43ec7e02019-05-03 09:41:00 -040093 * enable I cache if SYS_ICACHE_OFF is not defined
wdenk7eaacc52003-08-29 22:00:43 +000094 */
95 mrc p15, 0, r0, c1, c0, 0
Christian Riesch48c2d6d2012-02-02 00:44:39 +000096 bic r0, r0, #0x00000300 /* clear bits 9:8 (---- --RS) */
wdenk7eaacc52003-08-29 22:00:43 +000097 bic r0, r0, #0x00000087 /* clear bits 7, 2:0 (B--- -CAM) */
Christian Riesch48c2d6d2012-02-02 00:44:39 +000098#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 Goto8d4b7e92016-02-25 10:23:34 +0900103 orr r0, r0, #0x00000002 /* set bit 1 (A) Align */
Trevor Woerner43ec7e02019-05-03 09:41:00 -0400104#if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
wdenk7eaacc52003-08-29 22:00:43 +0000105 orr r0, r0, #0x00001000 /* set bit 12 (I) I-Cache */
Christian Riescha927d262012-02-02 00:44:40 +0000106#endif
wdenk7eaacc52003-08-29 22:00:43 +0000107 mcr p15, 0, r0, c1, c0, 0
108
Tom Rinie1e85442021-08-27 21:18:30 -0400109#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT_ONLY)
wdenk7eaacc52003-08-29 22:00:43 +0000110 /*
111 * Go setup Memory and board specific bits prior to relocation.
112 */
Mans Rullgard96db04f2018-04-21 16:11:07 +0100113 mov r4, lr /* perserve link reg across call */
Wolfgang Denk7f88a5e2005-10-06 17:08:18 +0200114 bl lowlevel_init /* go setup pll,mux,memory */
Mans Rullgard96db04f2018-04-21 16:11:07 +0100115 mov lr, r4 /* restore link */
Simon Glass90844072016-05-05 07:28:06 -0600116#endif
Heiko Schocherc8a6d752011-11-09 20:06:23 +0000117 mov pc, lr /* back to my caller */
Tom Rinie1e85442021-08-27 21:18:30 -0400118#endif /* CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) */
Icenowy Zheng362132f2022-01-29 10:23:00 -0500119
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 *************************************************************************/
129WEAK(save_boot_params)
130 b save_boot_params_ret /* back to my caller */
131ENDPROC(save_boot_params)