blob: 5d6c9f0861e1409f055b1bca2f133d0960b77e45 [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>
Icenowy Zheng362132f2022-01-29 10:23:00 -050019#include <linux/linkage.h>
wdenk7eaacc52003-08-29 22:00:43 +000020
wdenk7eaacc52003-08-29 22:00:43 +000021/*
22 *************************************************************************
23 *
wdenk7eaacc52003-08-29 22:00:43 +000024 * 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 ARIBAUD9852cc62014-04-15 16:13:51 +020034 .globl reset
Icenowy Zheng362132f2022-01-29 10:23:00 -050035 .globl save_boot_params_ret
36 .type save_boot_params_ret,%function
Heiko Schocher0e2412a2010-09-17 13:10:42 +020037
38reset:
Icenowy Zheng362132f2022-01-29 10:23:00 -050039 /* Allow the board to save important registers */
40 b save_boot_params
41save_boot_params_ret:
Heiko Schocher0e2412a2010-09-17 13:10:42 +020042 /*
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 Rinie1e85442021-08-27 21:18:30 -040054#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
Heiko Schocher0e2412a2010-09-17 13:10:42 +020055 bl cpu_init_crit
Christian Riesch11bf5762012-02-02 00:44:37 +000056#endif
Heiko Schocher0e2412a2010-09-17 13:10:42 +020057
Albert ARIBAUDfacdae52013-01-08 10:18:02 +000058 bl _main
Heiko Schocher0e2412a2010-09-17 13:10:42 +020059
60/*------------------------------------------------------------------------------*/
61
Albert ARIBAUDfacdae52013-01-08 10:18:02 +000062 .globl c_runtime_cpu_setup
63c_runtime_cpu_setup:
64
65 bx lr
66
wdenk7eaacc52003-08-29 22:00:43 +000067/*
68 *************************************************************************
69 *
70 * CPU_init_critical registers
71 *
72 * setup important registers
73 * setup memory timing
74 *
75 *************************************************************************
76 */
Tom Rinie1e85442021-08-27 21:18:30 -040077#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
wdenk7eaacc52003-08-29 22:00:43 +000078cpu_init_crit:
79 /*
Sughosh Ganu4cb71862012-02-02 00:44:38 +000080 * flush D cache before disabling it
wdenk7eaacc52003-08-29 22:00:43 +000081 */
82 mov r0, #0
Sughosh Ganu4cb71862012-02-02 00:44:38 +000083flush_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 */
wdenk7eaacc52003-08-29 22:00:43 +000089
90 /*
Christian Riescha927d262012-02-02 00:44:40 +000091 * disable MMU and D cache
Trevor Woerner43ec7e02019-05-03 09:41:00 -040092 * enable I cache if SYS_ICACHE_OFF is not defined
wdenk7eaacc52003-08-29 22:00:43 +000093 */
94 mrc p15, 0, r0, c1, c0, 0
Christian Riesch48c2d6d2012-02-02 00:44:39 +000095 bic r0, r0, #0x00000300 /* clear bits 9:8 (---- --RS) */
wdenk7eaacc52003-08-29 22:00:43 +000096 bic r0, r0, #0x00000087 /* clear bits 7, 2:0 (B--- -CAM) */
Tom Rini6a5dccc2022-11-16 13:10:41 -050097#ifdef CFG_SYS_EXCEPTION_VECTORS_HIGH
Christian Riesch48c2d6d2012-02-02 00:44:39 +000098 orr r0, r0, #0x00002000 /* set bit 13 (--V- ----) */
99#else
100 bic r0, r0, #0x00002000 /* clear bit 13 (--V- ----) */
101#endif
Yuichiro Goto8d4b7e92016-02-25 10:23:34 +0900102 orr r0, r0, #0x00000002 /* set bit 1 (A) Align */
Trevor Woerner43ec7e02019-05-03 09:41:00 -0400103#if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
wdenk7eaacc52003-08-29 22:00:43 +0000104 orr r0, r0, #0x00001000 /* set bit 12 (I) I-Cache */
Christian Riescha927d262012-02-02 00:44:40 +0000105#endif
wdenk7eaacc52003-08-29 22:00:43 +0000106 mcr p15, 0, r0, c1, c0, 0
107
Tom Rinie1e85442021-08-27 21:18:30 -0400108#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT_ONLY)
wdenk7eaacc52003-08-29 22:00:43 +0000109 /*
110 * Go setup Memory and board specific bits prior to relocation.
111 */
Mans Rullgard96db04f2018-04-21 16:11:07 +0100112 mov r4, lr /* perserve link reg across call */
Wolfgang Denk7f88a5e2005-10-06 17:08:18 +0200113 bl lowlevel_init /* go setup pll,mux,memory */
Mans Rullgard96db04f2018-04-21 16:11:07 +0100114 mov lr, r4 /* restore link */
Simon Glass90844072016-05-05 07:28:06 -0600115#endif
Heiko Schocherc8a6d752011-11-09 20:06:23 +0000116 mov pc, lr /* back to my caller */
Tom Rinie1e85442021-08-27 21:18:30 -0400117#endif /* CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) */
Icenowy Zheng362132f2022-01-29 10:23:00 -0500118
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 *************************************************************************/
128WEAK(save_boot_params)
129 b save_boot_params_ret /* back to my caller */
130ENDPROC(save_boot_params)