blob: 0704bdde27e07b944510f7ac9b3739c63f5fbb83 [file] [log] [blame]
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +02001/*
Cyril Chemparathy4e3ad932010-06-07 14:13:27 -04002 * armboot - Startup Code for ARM1176 CPU-core
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +02003 *
4 * Copyright (c) 2007 Samsung Electronics
5 *
6 * Copyright (C) 2008
7 * Guennadi Liakhovetki, DENX Software Engineering, <lg@denx.de>
8 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020010 *
11 * 2007-09-21 - Restructured codes by jsgood (jsgood.yang@samsung.com)
12 * 2007-09-21 - Added MoviNAND and OneNAND boot codes by
13 * jsgood (jsgood.yang@samsung.com)
14 * Base codes by scsuh (sc.suh)
15 */
16
Wolfgang Denk0191e472010-10-26 14:34:52 +020017#include <asm-offsets.h>
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020018#include <config.h>
19#include <version.h>
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020020
Benoît Thébaudeau62dd75c2013-04-11 09:36:02 +000021#ifndef CONFIG_SYS_PHY_UBOOT_BASE
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020022#define CONFIG_SYS_PHY_UBOOT_BASE CONFIG_SYS_UBOOT_BASE
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020023#endif
24
25/*
26 *************************************************************************
27 *
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020028 * Startup Code (reset vector)
29 *
30 * do important init only if we don't start from memory!
31 * setup Memory and board specific bits prior to relocation.
32 * relocate armboot to ram
33 * setup stack
34 *
35 *************************************************************************
36 */
37
Albert ARIBAUD9852cc62014-04-15 16:13:51 +020038 .globl reset
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020039
40reset:
41 /*
42 * set the cpu to SVC32 mode
43 */
44 mrs r0, cpsr
45 bic r0, r0, #0x3f
46 orr r0, r0, #0xd3
47 msr cpsr, r0
48
49/*
50 *************************************************************************
51 *
52 * CPU_init_critical registers
53 *
54 * setup important registers
55 * setup memory timing
56 *
57 *************************************************************************
58 */
59 /*
60 * we do sys-critical inits only at reboot,
61 * not when booting from ram!
62 */
63cpu_init_crit:
64 /*
65 * When booting from NAND - it has definitely been a reset, so, no need
66 * to flush caches and disable the MMU
67 */
Benoît Thébaudeau80f2f932013-04-11 09:36:01 +000068#ifndef CONFIG_SPL_BUILD
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020069 /*
70 * flush v4 I/D caches
71 */
72 mov r0, #0
73 mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
74 mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */
75
76 /*
77 * disable MMU stuff and caches
78 */
79 mrc p15, 0, r0, c1, c0, 0
80 bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS)
81 bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
82 orr r0, r0, #0x00000002 @ set bit 2 (A) Align
83 orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache
Cyril Chemparathy4e3ad932010-06-07 14:13:27 -040084
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020085 /* Prepare to disable the MMU */
Cyril Chemparathy4e3ad932010-06-07 14:13:27 -040086 adr r2, mmu_disable_phys
Wolfgang Denk0708bc62010-10-07 21:51:12 +020087 sub r2, r2, #(CONFIG_SYS_PHY_UBOOT_BASE - CONFIG_SYS_TEXT_BASE)
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020088 b mmu_disable
89
90 .align 5
91 /* Run in a single cache-line */
92mmu_disable:
93 mcr p15, 0, r0, c1, c0, 0
94 nop
95 nop
96 mov pc, r2
Cyril Chemparathy4e3ad932010-06-07 14:13:27 -040097mmu_disable_phys:
98
99#ifdef CONFIG_DISABLE_TCM
100 /*
101 * Disable the TCMs
102 */
103 mrc p15, 0, r0, c0, c0, 2 /* Return TCM details */
104 cmp r0, #0
105 beq skip_tcmdisable
106 mov r1, #0
107 mov r2, #1
108 tst r0, r2
109 mcrne p15, 0, r1, c9, c1, 1 /* Disable Instruction TCM if present*/
110 tst r0, r2, LSL #16
111 mcrne p15, 0, r1, c9, c1, 0 /* Disable Data TCM if present*/
112skip_tcmdisable:
113#endif
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +0200114#endif
115
Cyril Chemparathy4e3ad932010-06-07 14:13:27 -0400116#ifdef CONFIG_PERIPORT_REMAP
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +0200117 /* Peri port setup */
Cyril Chemparathy4e3ad932010-06-07 14:13:27 -0400118 ldr r0, =CONFIG_PERIPORT_BASE
119 orr r0, r0, #CONFIG_PERIPORT_SIZE
120 mcr p15,0,r0,c15,c2,4
Joonyoung Shimce0cdc52010-02-08 22:00:52 +0900121#endif
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +0200122
123 /*
124 * Go setup Memory and board specific bits prior to relocation.
125 */
126 bl lowlevel_init /* go setup pll,mux,memory */
127
Albert ARIBAUDfacdae52013-01-08 10:18:02 +0000128 bl _main
Heiko Schocher55f965a2010-09-17 13:10:53 +0200129
130/*------------------------------------------------------------------------------*/
131
Albert ARIBAUDfacdae52013-01-08 10:18:02 +0000132 .globl c_runtime_cpu_setup
133c_runtime_cpu_setup:
134
135 mov pc, lr