2 * armboot - Startup Code for XScale CPU-core
4 * Copyright (C) 1998 Dan Malek <dmalek@jlc.net>
5 * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se>
6 * Copyright (C) 2000 Wolfgang Denk <wd@denx.de>
7 * Copyright (C) 2001 Alex Zuepke <azu@sysgo.de>
8 * Copyright (C) 2001 Marius Groger <mag@sysgo.de>
9 * Copyright (C) 2002 Alex Zupke <azu@sysgo.de>
10 * Copyright (C) 2002 Gary Jennejohn <garyj@denx.de>
11 * Copyright (C) 2002 Kyle Harris <kharris@nexus-tech.net>
12 * Copyright (C) 2003 Kai-Uwe Bloem <kai-uwe.bloem@auerswald.de>
13 * Copyright (C) 2003 Kshitij <kshitij@ti.com>
14 * Copyright (C) 2003 Richard Woodruff <r-woodruff2@ti.com>
15 * Copyright (C) 2003 Robert Schwebel <r.schwebel@pengutronix.de>
16 * Copyright (C) 2004 Texas Instruments <r-woodruff2@ti.com>
17 * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com>
19 * SPDX-License-Identifier: GPL-2.0+
22 #include <asm-offsets.h>
27 *************************************************************************
29 * Startup Code (reset vector)
31 * do important init only if we don't start from memory!
32 * setup Memory and board specific bits prior to relocation.
33 * relocate armboot to ram
36 *************************************************************************
43 * set the cpu to SVC32 mode
50 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
54 #ifdef CONFIG_CPU_PXA25X
55 bl lock_cache_for_stack
60 /*------------------------------------------------------------------------------*/
62 .globl c_runtime_cpu_setup
65 #ifdef CONFIG_CPU_PXA25X
67 * Unlock (actually, disable) the cache now that board_init_f
68 * is done. We could do this earlier but we would need to add
69 * a new C runtime hook, whereas c_runtime_cpu_setup already
71 * As this routine is just a call to cpu_init_crit, let us
72 * tail-optimize and do a simple branch here.
80 *************************************************************************
82 * CPU_init_critical registers
84 * setup important registers
87 *************************************************************************
89 #if !defined(CONFIG_SKIP_LOWLEVEL_INIT) || defined(CONFIG_CPU_PXA25X)
95 mcr p15, 0, r0, c7, c7, 0 /* Invalidate I+D+BTB caches */
96 mcr p15, 0, r0, c8, c7, 0 /* Invalidate Unified TLB */
99 * disable MMU stuff and caches
101 mrc p15, 0, r0, c1, c0, 0
102 bic r0, r0, #0x00003300 @ clear bits 13:12, 9:8 (--VI --RS)
103 bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM)
104 orr r0, r0, #0x00000002 @ set bit 2 (A) Align
105 mcr p15, 0, r0, c1, c0, 0
107 mov pc, lr /* back to my caller */
108 #endif /* !CONFIG_SKIP_LOWLEVEL_INIT || CONFIG_CPU_PXA25X */
111 * Enable MMU to use DCache as DRAM.
113 * This is useful on PXA25x and PXA26x in early bootstages, where there is no
114 * other possible memory available to hold stack.
116 #ifdef CONFIG_CPU_PXA25X
118 mrc p15, 0, \reg, c2, c0, 0
122 lock_cache_for_stack:
123 /* Domain access -- enable for all CPs */
125 mcr p15, 0, r0, c3, c0, 0
127 /* Point TTBR to MMU table */
129 mcr p15, 0, r0, c2, c0, 0
131 /* Kick in MMU, ICache, DCache, BTB */
132 mrc p15, 0, r0, c1, c0, 0
137 mcr p15, 0, r0, c1, c0, 0
140 /* Unlock Icache, Dcache */
141 mcr p15, 0, r0, c9, c1, 1
142 mcr p15, 0, r0, c9, c2, 1
144 /* Flush Icache, Dcache, BTB */
145 mcr p15, 0, r0, c7, c7, 0
147 /* Unlock I-TLB, D-TLB */
148 mcr p15, 0, r0, c10, c4, 1
149 mcr p15, 0, r0, c10, c8, 1
152 mcr p15, 0, r0, c8, c7, 0
154 /* Allocate 4096 bytes of Dcache as RAM */
156 /* Drain pending loads and stores */
157 mcr p15, 0, r0, c7, c10, 4
162 mcr p15, 0, r0, c9, c2, 0
165 /* 128 lines reserved (128 x 32bytes = 4096 bytes total) */
170 mcr p15, 0, r1, c7, c2, 5
171 /* Drain pending loads and stores */
172 mcr p15, 0, r0, c7, c10, 4
179 /* Drain pending loads and stores */
180 mcr p15, 0, r0, c7, c10, 4
182 mcr p15, 0, r2, c9, c2, 0
187 .section .mmutable, "a"
190 /* 0x00000000 - 0xffe00000 : 1:1, uncached mapping */
193 .word (__base << 20) | 0xc12
194 .set __base, __base + 1
197 /* 0xfff00000 : 1:1, cached mapping */
198 .word (0xfff << 20) | 0x1c1e
199 #endif /* CONFIG_CPU_PXA25X */