blob: 8eb249475e473bbbca5888fd61d9cb1aa9dbb7ae [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#include <version.h>
22
wdenk6f213472003-08-29 22:00:43 +000023/*
24 *************************************************************************
25 *
wdenk6f213472003-08-29 22:00:43 +000026 * Startup Code (reset vector)
27 *
28 * do important init only if we don't start from memory!
29 * setup Memory and board specific bits prior to relocation.
30 * relocate armboot to ram
31 * setup stack
32 *
33 *************************************************************************
34 */
35
Albert ARIBAUD41623c92014-04-15 16:13:51 +020036 .globl reset
Heiko Schocherab86f722010-09-17 13:10:42 +020037
38reset:
39 /*
40 * set the cpu to SVC32 mode
41 */
42 mrs r0,cpsr
43 bic r0,r0,#0x1f
44 orr r0,r0,#0xd3
45 msr cpsr,r0
46
47 /*
48 * we do sys-critical inits only at reboot,
49 * not when booting from ram!
50 */
Christian Riesch27b66622012-02-02 00:44:37 +000051#ifndef CONFIG_SKIP_LOWLEVEL_INIT
Heiko Schocherab86f722010-09-17 13:10:42 +020052 bl cpu_init_crit
Christian Riesch27b66622012-02-02 00:44:37 +000053#endif
Heiko Schocherab86f722010-09-17 13:10:42 +020054
Albert ARIBAUDe05e5de2013-01-08 10:18:02 +000055 bl _main
Heiko Schocherab86f722010-09-17 13:10:42 +020056
57/*------------------------------------------------------------------------------*/
58
Albert ARIBAUDe05e5de2013-01-08 10:18:02 +000059 .globl c_runtime_cpu_setup
60c_runtime_cpu_setup:
61
62 bx lr
63
wdenk6f213472003-08-29 22:00:43 +000064/*
65 *************************************************************************
66 *
67 * CPU_init_critical registers
68 *
69 * setup important registers
70 * setup memory timing
71 *
72 *************************************************************************
73 */
Christian Riesch27b66622012-02-02 00:44:37 +000074#ifndef CONFIG_SKIP_LOWLEVEL_INIT
wdenk6f213472003-08-29 22:00:43 +000075cpu_init_crit:
76 /*
Sughosh Ganuda104e02012-02-02 00:44:38 +000077 * flush D cache before disabling it
wdenk6f213472003-08-29 22:00:43 +000078 */
79 mov r0, #0
Sughosh Ganuda104e02012-02-02 00:44:38 +000080flush_dcache:
81 mrc p15, 0, r15, c7, c10, 3
82 bne flush_dcache
83
84 mcr p15, 0, r0, c8, c7, 0 /* invalidate TLB */
85 mcr p15, 0, r0, c7, c5, 0 /* invalidate I Cache */
wdenk6f213472003-08-29 22:00:43 +000086
87 /*
Christian Rieschd735a992012-02-02 00:44:40 +000088 * disable MMU and D cache
89 * enable I cache if CONFIG_SYS_ICACHE_OFF is not defined
wdenk6f213472003-08-29 22:00:43 +000090 */
91 mrc p15, 0, r0, c1, c0, 0
Christian Rieschb67d8812012-02-02 00:44:39 +000092 bic r0, r0, #0x00000300 /* clear bits 9:8 (---- --RS) */
wdenk6f213472003-08-29 22:00:43 +000093 bic r0, r0, #0x00000087 /* clear bits 7, 2:0 (B--- -CAM) */
Christian Rieschb67d8812012-02-02 00:44:39 +000094#ifdef CONFIG_SYS_EXCEPTION_VECTORS_HIGH
95 orr r0, r0, #0x00002000 /* set bit 13 (--V- ----) */
96#else
97 bic r0, r0, #0x00002000 /* clear bit 13 (--V- ----) */
98#endif
wdenk6f213472003-08-29 22:00:43 +000099 orr r0, r0, #0x00000002 /* set bit 2 (A) Align */
Christian Rieschd735a992012-02-02 00:44:40 +0000100#ifndef CONFIG_SYS_ICACHE_OFF
wdenk6f213472003-08-29 22:00:43 +0000101 orr r0, r0, #0x00001000 /* set bit 12 (I) I-Cache */
Christian Rieschd735a992012-02-02 00:44:40 +0000102#endif
wdenk6f213472003-08-29 22:00:43 +0000103 mcr p15, 0, r0, c1, c0, 0
104
105 /*
106 * Go setup Memory and board specific bits prior to relocation.
107 */
108 mov ip, lr /* perserve link reg across call */
Wolfgang Denk87cb6862005-10-06 17:08:18 +0200109 bl lowlevel_init /* go setup pll,mux,memory */
wdenk6f213472003-08-29 22:00:43 +0000110 mov lr, ip /* restore link */
Heiko Schocherca4b5582011-11-09 20:06:23 +0000111 mov pc, lr /* back to my caller */
Christian Riesch27b66622012-02-02 00:44:37 +0000112#endif /* CONFIG_SKIP_LOWLEVEL_INIT */