blob: 0afcc47aad7d4d522d6f50c14a166bb3a950e511 [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>
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
Heiko Schocher0e2412a2010-09-17 13:10:42 +020035
36reset:
37 /*
38 * set the cpu to SVC32 mode
39 */
40 mrs r0,cpsr
41 bic r0,r0,#0x1f
42 orr r0,r0,#0xd3
43 msr cpsr,r0
44
45 /*
46 * we do sys-critical inits only at reboot,
47 * not when booting from ram!
48 */
Tom Rinie1e85442021-08-27 21:18:30 -040049#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
Heiko Schocher0e2412a2010-09-17 13:10:42 +020050 bl cpu_init_crit
Christian Riesch11bf5762012-02-02 00:44:37 +000051#endif
Heiko Schocher0e2412a2010-09-17 13:10:42 +020052
Albert ARIBAUDfacdae52013-01-08 10:18:02 +000053 bl _main
Heiko Schocher0e2412a2010-09-17 13:10:42 +020054
55/*------------------------------------------------------------------------------*/
56
Albert ARIBAUDfacdae52013-01-08 10:18:02 +000057 .globl c_runtime_cpu_setup
58c_runtime_cpu_setup:
59
60 bx lr
61
wdenk7eaacc52003-08-29 22:00:43 +000062/*
63 *************************************************************************
64 *
65 * CPU_init_critical registers
66 *
67 * setup important registers
68 * setup memory timing
69 *
70 *************************************************************************
71 */
Tom Rinie1e85442021-08-27 21:18:30 -040072#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)
wdenk7eaacc52003-08-29 22:00:43 +000073cpu_init_crit:
74 /*
Sughosh Ganu4cb71862012-02-02 00:44:38 +000075 * flush D cache before disabling it
wdenk7eaacc52003-08-29 22:00:43 +000076 */
77 mov r0, #0
Sughosh Ganu4cb71862012-02-02 00:44:38 +000078flush_dcache:
79 mrc p15, 0, r15, c7, c10, 3
80 bne flush_dcache
81
82 mcr p15, 0, r0, c8, c7, 0 /* invalidate TLB */
83 mcr p15, 0, r0, c7, c5, 0 /* invalidate I Cache */
wdenk7eaacc52003-08-29 22:00:43 +000084
85 /*
Christian Riescha927d262012-02-02 00:44:40 +000086 * disable MMU and D cache
Trevor Woerner43ec7e02019-05-03 09:41:00 -040087 * enable I cache if SYS_ICACHE_OFF is not defined
wdenk7eaacc52003-08-29 22:00:43 +000088 */
89 mrc p15, 0, r0, c1, c0, 0
Christian Riesch48c2d6d2012-02-02 00:44:39 +000090 bic r0, r0, #0x00000300 /* clear bits 9:8 (---- --RS) */
wdenk7eaacc52003-08-29 22:00:43 +000091 bic r0, r0, #0x00000087 /* clear bits 7, 2:0 (B--- -CAM) */
Christian Riesch48c2d6d2012-02-02 00:44:39 +000092#ifdef CONFIG_SYS_EXCEPTION_VECTORS_HIGH
93 orr r0, r0, #0x00002000 /* set bit 13 (--V- ----) */
94#else
95 bic r0, r0, #0x00002000 /* clear bit 13 (--V- ----) */
96#endif
Yuichiro Goto8d4b7e92016-02-25 10:23:34 +090097 orr r0, r0, #0x00000002 /* set bit 1 (A) Align */
Trevor Woerner43ec7e02019-05-03 09:41:00 -040098#if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
wdenk7eaacc52003-08-29 22:00:43 +000099 orr r0, r0, #0x00001000 /* set bit 12 (I) I-Cache */
Christian Riescha927d262012-02-02 00:44:40 +0000100#endif
wdenk7eaacc52003-08-29 22:00:43 +0000101 mcr p15, 0, r0, c1, c0, 0
102
Tom Rinie1e85442021-08-27 21:18:30 -0400103#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT_ONLY)
wdenk7eaacc52003-08-29 22:00:43 +0000104 /*
105 * Go setup Memory and board specific bits prior to relocation.
106 */
Mans Rullgard96db04f2018-04-21 16:11:07 +0100107 mov r4, lr /* perserve link reg across call */
Wolfgang Denk7f88a5e2005-10-06 17:08:18 +0200108 bl lowlevel_init /* go setup pll,mux,memory */
Mans Rullgard96db04f2018-04-21 16:11:07 +0100109 mov lr, r4 /* restore link */
Simon Glass90844072016-05-05 07:28:06 -0600110#endif
Heiko Schocherc8a6d752011-11-09 20:06:23 +0000111 mov pc, lr /* back to my caller */
Tom Rinie1e85442021-08-27 21:18:30 -0400112#endif /* CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) */