blob: 9e76a4a9e0e17eddafd9f94635c113afd1a14cc3 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +02002/*
Cyril Chemparathy4e3ad932010-06-07 14:13:27 -04003 * armboot - Startup Code for ARM1176 CPU-core
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +02004 *
5 * Copyright (c) 2007 Samsung Electronics
6 *
7 * Copyright (C) 2008
8 * Guennadi Liakhovetki, DENX Software Engineering, <lg@denx.de>
9 *
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020010 * 2007-09-21 - Restructured codes by jsgood (jsgood.yang@samsung.com)
11 * 2007-09-21 - Added MoviNAND and OneNAND boot codes by
12 * jsgood (jsgood.yang@samsung.com)
13 * Base codes by scsuh (sc.suh)
14 */
15
Wolfgang Denk0191e472010-10-26 14:34:52 +020016#include <asm-offsets.h>
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020017#include <config.h>
Cédric Schieli4bcddad2016-11-11 11:59:06 +010018#include <linux/linkage.h>
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020019
Benoît Thébaudeau62dd75c2013-04-11 09:36:02 +000020#ifndef CONFIG_SYS_PHY_UBOOT_BASE
Tom Rini6a5dccc2022-11-16 13:10:41 -050021#define CONFIG_SYS_PHY_UBOOT_BASE CFG_SYS_UBOOT_BASE
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020022#endif
23
24/*
25 *************************************************************************
26 *
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020027 * Startup Code (reset vector)
28 *
29 * do important init only if we don't start from memory!
30 * setup Memory and board specific bits prior to relocation.
31 * relocate armboot to ram
32 * setup stack
33 *
34 *************************************************************************
35 */
36
Albert ARIBAUD9852cc62014-04-15 16:13:51 +020037 .globl reset
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020038
39reset:
Cédric Schieli4bcddad2016-11-11 11:59:06 +010040 /* Allow the board to save important registers */
41 b save_boot_params
42.globl save_boot_params_ret
43save_boot_params_ret:
44
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020045 /*
46 * set the cpu to SVC32 mode
47 */
48 mrs r0, cpsr
49 bic r0, r0, #0x3f
50 orr r0, r0, #0xd3
51 msr cpsr, r0
52
53/*
54 *************************************************************************
55 *
56 * CPU_init_critical registers
57 *
58 * setup important registers
59 * setup memory timing
60 *
61 *************************************************************************
62 */
63 /*
64 * we do sys-critical inits only at reboot,
65 * not when booting from ram!
66 */
67cpu_init_crit:
68 /*
69 * When booting from NAND - it has definitely been a reset, so, no need
70 * to flush caches and disable the MMU
71 */
Benoît Thébaudeau80f2f932013-04-11 09:36:01 +000072#ifndef CONFIG_SPL_BUILD
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020073 /*
74 * flush v4 I/D caches
75 */
76 mov r0, #0
77 mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */
78 mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */
79
80 /*
81 * disable MMU stuff and caches
82 */
83 mrc p15, 0, r0, c1, c0, 0
84 bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS)
85 bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
Yuichiro Goto8d4b7e92016-02-25 10:23:34 +090086 orr r0, r0, #0x00000002 @ set bit 1 (A) Align
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020087 orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache
Cyril Chemparathy4e3ad932010-06-07 14:13:27 -040088
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020089 /* Prepare to disable the MMU */
Cyril Chemparathy4e3ad932010-06-07 14:13:27 -040090 adr r2, mmu_disable_phys
Simon Glass72cc5382022-10-20 18:22:39 -060091 sub r2, r2, #(CONFIG_SYS_PHY_UBOOT_BASE - CONFIG_TEXT_BASE)
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +020092 b mmu_disable
93
94 .align 5
95 /* Run in a single cache-line */
96mmu_disable:
97 mcr p15, 0, r0, c1, c0, 0
98 nop
99 nop
100 mov pc, r2
Cyril Chemparathy4e3ad932010-06-07 14:13:27 -0400101mmu_disable_phys:
102
Joonyoung Shimce0cdc52010-02-08 22:00:52 +0900103#endif
Guennadi Liakhovetski8c170c52008-08-31 00:39:46 +0200104
105 /*
106 * Go setup Memory and board specific bits prior to relocation.
107 */
108 bl lowlevel_init /* go setup pll,mux,memory */
109
Albert ARIBAUDfacdae52013-01-08 10:18:02 +0000110 bl _main
Heiko Schocher55f965a2010-09-17 13:10:53 +0200111
112/*------------------------------------------------------------------------------*/
113
Albert ARIBAUDfacdae52013-01-08 10:18:02 +0000114 .globl c_runtime_cpu_setup
115c_runtime_cpu_setup:
116
117 mov pc, lr
Cédric Schieli4bcddad2016-11-11 11:59:06 +0100118
119WEAK(save_boot_params)
120 b save_boot_params_ret /* back to my caller */
121ENDPROC(save_boot_params)