blob: f05113da9df21ff5a28ebc644fc83bf5399f8606 [file] [log] [blame]
wdenk6f213472003-08-29 22:00:43 +00001/*
2 * armboot - Startup Code for ARM926EJS CPU-core
3 *
4 * Copyright (c) 2003 Texas Instruments
5 *
wdenka56bd922004-06-06 23:13:55 +00006 * ----- Adapted for OMAP1610 OMAP730 from ARM925t code ------
wdenk6f213472003-08-29 22:00:43 +00007 *
Albert ARIBAUDfa82f872011-08-04 18:45:45 +02008 * Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
9 * Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
Detlev Zundel792a09e2009-05-13 10:54:10 +020010 * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de>
wdenk6f213472003-08-29 22:00:43 +000011 * Copyright (c) 2003 Richard Woodruff <r-woodruff2@ti.com>
12 * Copyright (c) 2003 Kshitij <kshitij@ti.com>
Albert ARIBAUD57b4bce2011-04-22 19:41:02 +020013 * Copyright (c) 2010 Albert Aribaud <albert.u.boot@aribaud.net>
wdenk6f213472003-08-29 22:00:43 +000014 *
Wolfgang Denk1a459662013-07-08 09:37:19 +020015 * SPDX-License-Identifier: GPL-2.0+
wdenk6f213472003-08-29 22:00:43 +000016 */
17
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +020018#include <asm-offsets.h>
wdenk6f213472003-08-29 22:00:43 +000019#include <config.h>
Wolfgang Denkfcd3c872009-07-24 00:17:48 +020020#include <common.h>
wdenk6f213472003-08-29 22:00:43 +000021
wdenk6f213472003-08-29 22:00:43 +000022/*
23 *************************************************************************
24 *
wdenk6f213472003-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 ARIBAUD41623c92014-04-15 16:13:51 +020035 .globl reset
Heiko Schocherab86f722010-09-17 13:10:42 +020036
37reset:
38 /*
39 * set the cpu to SVC32 mode
40 */
41 mrs r0,cpsr
42 bic r0,r0,#0x1f
43 orr r0,r0,#0xd3
44 msr cpsr,r0
45
46 /*
47 * we do sys-critical inits only at reboot,
48 * not when booting from ram!
49 */
Christian Riesch27b66622012-02-02 00:44:37 +000050#ifndef CONFIG_SKIP_LOWLEVEL_INIT
Heiko Schocherab86f722010-09-17 13:10:42 +020051 bl cpu_init_crit
Christian Riesch27b66622012-02-02 00:44:37 +000052#endif
Heiko Schocherab86f722010-09-17 13:10:42 +020053
Albert ARIBAUDe05e5de2013-01-08 10:18:02 +000054 bl _main
Heiko Schocherab86f722010-09-17 13:10:42 +020055
56/*------------------------------------------------------------------------------*/
57
Albert ARIBAUDe05e5de2013-01-08 10:18:02 +000058 .globl c_runtime_cpu_setup
59c_runtime_cpu_setup:
60
61 bx lr
62
wdenk6f213472003-08-29 22:00:43 +000063/*
64 *************************************************************************
65 *
66 * CPU_init_critical registers
67 *
68 * setup important registers
69 * setup memory timing
70 *
71 *************************************************************************
72 */
Christian Riesch27b66622012-02-02 00:44:37 +000073#ifndef CONFIG_SKIP_LOWLEVEL_INIT
wdenk6f213472003-08-29 22:00:43 +000074cpu_init_crit:
75 /*
Sughosh Ganuda104e02012-02-02 00:44:38 +000076 * flush D cache before disabling it
wdenk6f213472003-08-29 22:00:43 +000077 */
78 mov r0, #0
Sughosh Ganuda104e02012-02-02 00:44:38 +000079flush_dcache:
80 mrc p15, 0, r15, c7, c10, 3
81 bne flush_dcache
82
83 mcr p15, 0, r0, c8, c7, 0 /* invalidate TLB */
84 mcr p15, 0, r0, c7, c5, 0 /* invalidate I Cache */
wdenk6f213472003-08-29 22:00:43 +000085
86 /*
Christian Rieschd735a992012-02-02 00:44:40 +000087 * disable MMU and D cache
88 * enable I cache if CONFIG_SYS_ICACHE_OFF is not defined
wdenk6f213472003-08-29 22:00:43 +000089 */
90 mrc p15, 0, r0, c1, c0, 0
Christian Rieschb67d8812012-02-02 00:44:39 +000091 bic r0, r0, #0x00000300 /* clear bits 9:8 (---- --RS) */
wdenk6f213472003-08-29 22:00:43 +000092 bic r0, r0, #0x00000087 /* clear bits 7, 2:0 (B--- -CAM) */
Christian Rieschb67d8812012-02-02 00:44:39 +000093#ifdef CONFIG_SYS_EXCEPTION_VECTORS_HIGH
94 orr r0, r0, #0x00002000 /* set bit 13 (--V- ----) */
95#else
96 bic r0, r0, #0x00002000 /* clear bit 13 (--V- ----) */
97#endif
Yuichiro Gotoba10b852016-02-25 10:23:34 +090098 orr r0, r0, #0x00000002 /* set bit 1 (A) Align */
Christian Rieschd735a992012-02-02 00:44:40 +000099#ifndef CONFIG_SYS_ICACHE_OFF
wdenk6f213472003-08-29 22:00:43 +0000100 orr r0, r0, #0x00001000 /* set bit 12 (I) I-Cache */
Christian Rieschd735a992012-02-02 00:44:40 +0000101#endif
wdenk6f213472003-08-29 22:00:43 +0000102 mcr p15, 0, r0, c1, c0, 0
103
104 /*
105 * Go setup Memory and board specific bits prior to relocation.
106 */
107 mov ip, lr /* perserve link reg across call */
Wolfgang Denk87cb6862005-10-06 17:08:18 +0200108 bl lowlevel_init /* go setup pll,mux,memory */
wdenk6f213472003-08-29 22:00:43 +0000109 mov lr, ip /* restore link */
Heiko Schocherca4b5582011-11-09 20:06:23 +0000110 mov pc, lr /* back to my caller */
Christian Riesch27b66622012-02-02 00:44:37 +0000111#endif /* CONFIG_SKIP_LOWLEVEL_INIT */