xref: /rk3399_rockchip-uboot/arch/powerpc/cpu/mpc85xx/release.S (revision 6d2b9da19cbfe0b7da7e9ae0bf2a1a000f2e2804)
1a47a12beSStefan Roese/*
2709389b6SYork Sun * Copyright 2008-2012 Freescale Semiconductor, Inc.
3a47a12beSStefan Roese * Kumar Gala <kumar.gala@freescale.com>
4a47a12beSStefan Roese *
5a47a12beSStefan Roese * See file CREDITS for list of people who contributed to this
6a47a12beSStefan Roese * project.
7a47a12beSStefan Roese *
8a47a12beSStefan Roese * This program is free software; you can redistribute it and/or
9a47a12beSStefan Roese * modify it under the terms of the GNU General Public License as
10a47a12beSStefan Roese * published by the Free Software Foundation; either version 2 of
11a47a12beSStefan Roese * the License, or (at your option) any later version.
12a47a12beSStefan Roese *
13a47a12beSStefan Roese * This program is distributed in the hope that it will be useful,
14a47a12beSStefan Roese * but WITHOUT ANY WARRANTY; without even the implied warranty of
15a47a12beSStefan Roese * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16a47a12beSStefan Roese * GNU General Public License for more details.
17a47a12beSStefan Roese *
18a47a12beSStefan Roese * You should have received a copy of the GNU General Public License
19a47a12beSStefan Roese * along with this program; if not, write to the Free Software
20a47a12beSStefan Roese * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21a47a12beSStefan Roese * MA 02111-1307 USA
22a47a12beSStefan Roese */
23a47a12beSStefan Roese
2425ddd1fbSWolfgang Denk#include <asm-offsets.h>
25a47a12beSStefan Roese#include <config.h>
26a47a12beSStefan Roese#include <mpc85xx.h>
27a47a12beSStefan Roese#include <version.h>
28a47a12beSStefan Roese
29a47a12beSStefan Roese#define _LINUX_CONFIG_H 1	/* avoid reading Linux autoconf.h file	*/
30a47a12beSStefan Roese
31a47a12beSStefan Roese#include <ppc_asm.tmpl>
32a47a12beSStefan Roese#include <ppc_defs.h>
33a47a12beSStefan Roese
34a47a12beSStefan Roese#include <asm/cache.h>
35a47a12beSStefan Roese#include <asm/mmu.h>
36a47a12beSStefan Roese
37a47a12beSStefan Roese/* To boot secondary cpus, we need a place for them to start up.
38a47a12beSStefan Roese * Normally, they start at 0xfffffffc, but that's usually the
39a47a12beSStefan Roese * firmware, and we don't want to have to run the firmware again.
40a47a12beSStefan Roese * Instead, the primary cpu will set the BPTR to point here to
41a47a12beSStefan Roese * this page.  We then set up the core, and head to
42a47a12beSStefan Roese * start_secondary.  Note that this means that the code below
43a47a12beSStefan Roese * must never exceed 1023 instructions (the branch at the end
44a47a12beSStefan Roese * would then be the 1024th).
45a47a12beSStefan Roese */
46a47a12beSStefan Roese	.globl	__secondary_start_page
47a47a12beSStefan Roese	.align	12
48a47a12beSStefan Roese__secondary_start_page:
49a47a12beSStefan Roese/* First do some preliminary setup */
50a47a12beSStefan Roese	lis	r3, HID0_EMCP@h		/* enable machine check */
51a47a12beSStefan Roese#ifndef CONFIG_E500MC
52a47a12beSStefan Roese	ori	r3,r3,HID0_TBEN@l	/* enable Timebase */
53a47a12beSStefan Roese#endif
54a47a12beSStefan Roese#ifdef CONFIG_PHYS_64BIT
55a47a12beSStefan Roese	ori	r3,r3,HID0_ENMAS7@l	/* enable MAS7 updates */
56a47a12beSStefan Roese#endif
57a47a12beSStefan Roese	mtspr	SPRN_HID0,r3
58a47a12beSStefan Roese
59a47a12beSStefan Roese#ifndef CONFIG_E500MC
60a47a12beSStefan Roese	li	r3,(HID1_ASTME|HID1_ABE)@l	/* Addr streaming & broadcast */
61a47a12beSStefan Roese	mfspr   r0,PVR
62a47a12beSStefan Roese	andi.	r0,r0,0xff
63a47a12beSStefan Roese	cmpwi	r0,0x50@l	/* if we are rev 5.0 or greater set MBDD */
64a47a12beSStefan Roese	blt 1f
65a47a12beSStefan Roese	/* Set MBDD bit also */
66a47a12beSStefan Roese	ori r3, r3, HID1_MBDD@l
67a47a12beSStefan Roese1:
68a47a12beSStefan Roese	mtspr	SPRN_HID1,r3
69a47a12beSStefan Roese#endif
70a47a12beSStefan Roese
7143f082bbSKumar Gala#ifdef CONFIG_SYS_FSL_ERRATUM_CPU_A003999
7243f082bbSKumar Gala	mfspr	r3,977
7343f082bbSKumar Gala	oris	r3,r3,0x0100
7443f082bbSKumar Gala	mtspr	977,r3
7543f082bbSKumar Gala#endif
7643f082bbSKumar Gala
7733eee330SScott Wood#ifdef CONFIG_SYS_FSL_ERRATUM_A004510
7833eee330SScott Wood	mfspr	r3,SPRN_SVR
7933eee330SScott Wood	rlwinm	r3,r3,0,0xff
8033eee330SScott Wood	li	r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV
8133eee330SScott Wood	cmpw	r3,r4
8233eee330SScott Wood	beq	1f
8333eee330SScott Wood
8433eee330SScott Wood#ifdef CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2
8533eee330SScott Wood	li	r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2
8633eee330SScott Wood	cmpw	r3,r4
8733eee330SScott Wood	beq	1f
8833eee330SScott Wood#endif
8933eee330SScott Wood
9033eee330SScott Wood	/* Not a supported revision affected by erratum */
9133eee330SScott Wood	b	2f
9233eee330SScott Wood
9333eee330SScott Wood1:	/* Erratum says set bits 55:60 to 001001 */
9433eee330SScott Wood	msync
9533eee330SScott Wood	isync
9633eee330SScott Wood	mfspr	r3,976
9733eee330SScott Wood	li	r4,0x48
9833eee330SScott Wood	rlwimi	r3,r4,0,0x1f8
9933eee330SScott Wood	mtspr	976,r3
10033eee330SScott Wood	isync
10133eee330SScott Wood2:
10233eee330SScott Wood#endif
10333eee330SScott Wood
104a47a12beSStefan Roese	/* Enable branch prediction */
105a47a12beSStefan Roese	lis	r3,BUCSR_ENABLE@h
106a47a12beSStefan Roese	ori	r3,r3,BUCSR_ENABLE@l
107a47a12beSStefan Roese	mtspr	SPRN_BUCSR,r3
108a47a12beSStefan Roese
109a47a12beSStefan Roese	/* Ensure TB is 0 */
110a47a12beSStefan Roese	li	r3,0
111a47a12beSStefan Roese	mttbl	r3
112a47a12beSStefan Roese	mttbu	r3
113a47a12beSStefan Roese
114a47a12beSStefan Roese	/* Enable/invalidate the I-Cache */
115a47a12beSStefan Roese	lis	r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@h
116a47a12beSStefan Roese	ori	r2,r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@l
117a47a12beSStefan Roese	mtspr	SPRN_L1CSR1,r2
118a47a12beSStefan Roese1:
119a47a12beSStefan Roese	mfspr	r3,SPRN_L1CSR1
120a47a12beSStefan Roese	and.	r1,r3,r2
121a47a12beSStefan Roese	bne	1b
122a47a12beSStefan Roese
123a47a12beSStefan Roese	lis	r3,(L1CSR1_CPE|L1CSR1_ICE)@h
124a47a12beSStefan Roese	ori	r3,r3,(L1CSR1_CPE|L1CSR1_ICE)@l
125a47a12beSStefan Roese	mtspr	SPRN_L1CSR1,r3
126a47a12beSStefan Roese	isync
127a47a12beSStefan Roese2:
128a47a12beSStefan Roese	mfspr	r3,SPRN_L1CSR1
129a47a12beSStefan Roese	andi.	r1,r3,L1CSR1_ICE@l
130a47a12beSStefan Roese	beq	2b
131a47a12beSStefan Roese
132a47a12beSStefan Roese	/* Enable/invalidate the D-Cache */
133a47a12beSStefan Roese	lis	r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@h
134a47a12beSStefan Roese	ori	r2,r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@l
135a47a12beSStefan Roese	mtspr	SPRN_L1CSR0,r2
136a47a12beSStefan Roese1:
137a47a12beSStefan Roese	mfspr	r3,SPRN_L1CSR0
138a47a12beSStefan Roese	and.	r1,r3,r2
139a47a12beSStefan Roese	bne	1b
140a47a12beSStefan Roese
141a47a12beSStefan Roese	lis	r3,(L1CSR0_CPE|L1CSR0_DCE)@h
142a47a12beSStefan Roese	ori	r3,r3,(L1CSR0_CPE|L1CSR0_DCE)@l
143a47a12beSStefan Roese	mtspr	SPRN_L1CSR0,r3
144a47a12beSStefan Roese	isync
145a47a12beSStefan Roese2:
146a47a12beSStefan Roese	mfspr	r3,SPRN_L1CSR0
147a47a12beSStefan Roese	andi.	r1,r3,L1CSR0_DCE@l
148a47a12beSStefan Roese	beq	2b
149a47a12beSStefan Roese
150a47a12beSStefan Roese#define toreset(x) (x - __secondary_start_page + 0xfffff000)
151a47a12beSStefan Roese
152a47a12beSStefan Roese	/* get our PIR to figure out our table entry */
153a47a12beSStefan Roese	lis	r3,toreset(__spin_table)@h
154a47a12beSStefan Roese	ori	r3,r3,toreset(__spin_table)@l
155a47a12beSStefan Roese
156a47a12beSStefan Roese	/* r10 has the base address for the entry */
157a47a12beSStefan Roese	mfspr	r0,SPRN_PIR
158709389b6SYork Sun#if	defined(CONFIG_E6500)
159709389b6SYork Sun/*
160709389b6SYork Sun * PIR definition for E6500
161709389b6SYork Sun * 0-17 Reserved (logic 0s)
1620c7e65f3STimur Tabi * 8-19 CHIP_ID,    2'b00      - SoC 1
163709389b6SYork Sun *                  all others - reserved
1640c7e65f3STimur Tabi * 20-24 CLUSTER_ID 5'b00000   - CCM 1
165709389b6SYork Sun *                  all others - reserved
1660c7e65f3STimur Tabi * 25-26 CORE_CLUSTER_ID 2'b00 - cluster 1
1670c7e65f3STimur Tabi *                       2'b01 - cluster 2
1680c7e65f3STimur Tabi *                       2'b10 - cluster 3
1690c7e65f3STimur Tabi *                       2'b11 - cluster 4
1700c7e65f3STimur Tabi * 27-28 CORE_ID         2'b00 - core 0
1710c7e65f3STimur Tabi *                       2'b01 - core 1
1720c7e65f3STimur Tabi *                       2'b10 - core 2
1730c7e65f3STimur Tabi *                       2'b11 - core 3
1740c7e65f3STimur Tabi * 29-31 THREAD_ID       3'b000 - thread 0
1750c7e65f3STimur Tabi *                       3'b001 - thread 1
176709389b6SYork Sun */
177709389b6SYork Sun	rlwinm  r4,r0,29,25,31
178709389b6SYork Sun#elif	defined(CONFIG_E500MC)
179a47a12beSStefan Roese	rlwinm	r4,r0,27,27,31
180a47a12beSStefan Roese#else
181a47a12beSStefan Roese	mr	r4,r0
182a47a12beSStefan Roese#endif
183a47a12beSStefan Roese	slwi	r8,r4,5
184a47a12beSStefan Roese	add	r10,r3,r8
185a47a12beSStefan Roese
186709389b6SYork Sun#ifdef CONFIG_E6500
187709389b6SYork Sun	mfspr	r0,SPRN_PIR
188709389b6SYork Sun	/*
189709389b6SYork Sun	 * core 0 thread 0: pir reset value 0x00, new pir 0
190709389b6SYork Sun	 * core 0 thread 1: pir reset value 0x01, new pir 1
191709389b6SYork Sun	 * core 1 thread 0: pir reset value 0x08, new pir 2
192709389b6SYork Sun	 * core 1 thread 1: pir reset value 0x09, new pir 3
193709389b6SYork Sun	 * core 2 thread 0: pir reset value 0x10, new pir 4
194709389b6SYork Sun	 * core 2 thread 1: pir reset value 0x11, new pir 5
195709389b6SYork Sun	 * etc.
196709389b6SYork Sun	 *
197709389b6SYork Sun	 * Only thread 0 of each core will be running, updating PIR doesn't
198709389b6SYork Sun	 * need to deal with the thread bits.
199709389b6SYork Sun	 */
200709389b6SYork Sun	rlwinm	r4,r0,30,24,30
201709389b6SYork Sun#endif
202709389b6SYork Sun
203709389b6SYork Sun	mtspr	SPRN_PIR,r4	/* write to PIR register */
204709389b6SYork Sun
205*6d2b9da1SYork Sun#ifdef CONFIG_SYS_CACHE_STASHING
206*6d2b9da1SYork Sun	/* set stash id to (coreID) * 2 + 32 + L1 CT (0) */
207*6d2b9da1SYork Sun	slwi	r8,r4,1
208*6d2b9da1SYork Sun	addi	r8,r8,32
209*6d2b9da1SYork Sun	mtspr	L1CSR2,r8
210*6d2b9da1SYork Sun#endif
211*6d2b9da1SYork Sun
2125e23ab0aSYork Sun#if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) || \
2135e23ab0aSYork Sun	defined(CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011)
2145e23ab0aSYork Sun	/*
2155e23ab0aSYork Sun	 * CPU22 applies to P4080 rev 1.0, 2.0, fixed in 3.0
2165e23ab0aSYork Sun	 * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0
2175e23ab0aSYork Sun	 * also appleis to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1
2185e23ab0aSYork Sun	 */
2191e9ea85fSYork Sun	mfspr   r3,SPRN_SVR
2205e23ab0aSYork Sun	rlwinm	r6,r3,24,~0x800		/* clear E bit */
2211e9ea85fSYork Sun
2225e23ab0aSYork Sun	lis	r5,SVR_P4080@h
2235e23ab0aSYork Sun	ori	r5,r5,SVR_P4080@l
2245e23ab0aSYork Sun	cmpw	r6,r5
2255e23ab0aSYork Sun	bne	1f
2265e23ab0aSYork Sun
2275e23ab0aSYork Sun	rlwinm  r3,r3,0,0xf0
2285e23ab0aSYork Sun	li      r5,0x30
2295e23ab0aSYork Sun	cmpw    r3,r5
2305e23ab0aSYork Sun	bge     2f
2315e23ab0aSYork Sun1:
23257125f22SYork Sun#ifdef	CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011
23357125f22SYork Sun	lis	r3,toreset(enable_cpu_a011_workaround)@ha
23457125f22SYork Sun	lwz	r3,toreset(enable_cpu_a011_workaround)@l(r3)
23557125f22SYork Sun	cmpwi	r3,0
23657125f22SYork Sun	beq	2f
23757125f22SYork Sun#endif
2385e23ab0aSYork Sun	mfspr	r3,L1CSR2
2395e23ab0aSYork Sun	oris	r3,r3,(L1CSR2_DCWS)@h
2405e23ab0aSYork Sun	mtspr	L1CSR2,r3
2411e9ea85fSYork Sun2:
242fd3c9befSKumar Gala#endif
243fd3c9befSKumar Gala
244a47a12beSStefan Roese#ifdef CONFIG_BACKSIDE_L2_CACHE
245acf3f8daSKumar Gala	/* skip L2 setup on P2040/P2040E as they have no L2 */
246feae3424SYork Sun	mfspr	r3,SPRN_SVR
247feae3424SYork Sun	rlwinm	r6,r3,24,~0x800		/* clear E bit of SVR */
248feae3424SYork Sun
249acf3f8daSKumar Gala	lis	r3,SVR_P2040@h
250acf3f8daSKumar Gala	ori	r3,r3,SVR_P2040@l
251feae3424SYork Sun	cmpw	r6,r3
252acf3f8daSKumar Gala	beq 3f
253acf3f8daSKumar Gala
254a47a12beSStefan Roese	/* Enable/invalidate the L2 cache */
255a47a12beSStefan Roese	msync
256a47a12beSStefan Roese	lis	r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@h
257a47a12beSStefan Roese	ori	r2,r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@l
258a47a12beSStefan Roese	mtspr	SPRN_L2CSR0,r2
259a47a12beSStefan Roese1:
260a47a12beSStefan Roese	mfspr	r3,SPRN_L2CSR0
261a47a12beSStefan Roese	and.	r1,r3,r2
262a47a12beSStefan Roese	bne	1b
263a47a12beSStefan Roese
264a47a12beSStefan Roese#ifdef CONFIG_SYS_CACHE_STASHING
265a47a12beSStefan Roese	/* set stash id to (coreID) * 2 + 32 + L2 (1) */
266a47a12beSStefan Roese	addi	r3,r8,1
267a47a12beSStefan Roese	mtspr	SPRN_L2CSR1,r3
268a47a12beSStefan Roese#endif
269a47a12beSStefan Roese
270a47a12beSStefan Roese	lis	r3,CONFIG_SYS_INIT_L2CSR0@h
271a47a12beSStefan Roese	ori	r3,r3,CONFIG_SYS_INIT_L2CSR0@l
272a47a12beSStefan Roese	mtspr	SPRN_L2CSR0,r3
273a47a12beSStefan Roese	isync
274a47a12beSStefan Roese2:
275a47a12beSStefan Roese	mfspr	r3,SPRN_L2CSR0
276a47a12beSStefan Roese	andis.	r1,r3,L2CSR0_L2E@h
277a47a12beSStefan Roese	beq	2b
278a47a12beSStefan Roese#endif
279acf3f8daSKumar Gala3:
280a47a12beSStefan Roese
281a47a12beSStefan Roese#define EPAPR_MAGIC		(0x45504150)
282a47a12beSStefan Roese#define ENTRY_ADDR_UPPER	0
283a47a12beSStefan Roese#define ENTRY_ADDR_LOWER	4
284a47a12beSStefan Roese#define ENTRY_R3_UPPER		8
285a47a12beSStefan Roese#define ENTRY_R3_LOWER		12
286a47a12beSStefan Roese#define ENTRY_RESV		16
287a47a12beSStefan Roese#define ENTRY_PIR		20
288a47a12beSStefan Roese#define ENTRY_R6_UPPER		24
289a47a12beSStefan Roese#define ENTRY_R6_LOWER		28
290a47a12beSStefan Roese#define ENTRY_SIZE		32
291a47a12beSStefan Roese
292a47a12beSStefan Roese	/* setup the entry */
293a47a12beSStefan Roese	li	r3,0
294a47a12beSStefan Roese	li	r8,1
295709389b6SYork Sun	stw	r4,ENTRY_PIR(r10)
296a47a12beSStefan Roese	stw	r3,ENTRY_ADDR_UPPER(r10)
297a47a12beSStefan Roese	stw	r8,ENTRY_ADDR_LOWER(r10)
298a47a12beSStefan Roese	stw	r3,ENTRY_R3_UPPER(r10)
299a47a12beSStefan Roese	stw	r4,ENTRY_R3_LOWER(r10)
300a47a12beSStefan Roese	stw	r3,ENTRY_R6_UPPER(r10)
301a47a12beSStefan Roese	stw	r3,ENTRY_R6_LOWER(r10)
302a47a12beSStefan Roese
303a47a12beSStefan Roese	/* load r13 with the address of the 'bootpg' in SDRAM */
304a47a12beSStefan Roese	lis	r13,toreset(__bootpg_addr)@h
305a47a12beSStefan Roese	ori	r13,r13,toreset(__bootpg_addr)@l
306a47a12beSStefan Roese	lwz	r13,0(r13)
307a47a12beSStefan Roese
308a47a12beSStefan Roese	/* setup mapping for AS = 1, and jump there */
309a47a12beSStefan Roese	lis	r11,(MAS0_TLBSEL(1)|MAS0_ESEL(1))@h
310a47a12beSStefan Roese	mtspr	SPRN_MAS0,r11
311a47a12beSStefan Roese	lis	r11,(MAS1_VALID|MAS1_IPROT)@h
312a47a12beSStefan Roese	ori	r11,r11,(MAS1_TS|MAS1_TSIZE(BOOKE_PAGESZ_4K))@l
313a47a12beSStefan Roese	mtspr	SPRN_MAS1,r11
314a47a12beSStefan Roese	oris	r11,r13,(MAS2_I|MAS2_G)@h
315a47a12beSStefan Roese	ori	r11,r13,(MAS2_I|MAS2_G)@l
316a47a12beSStefan Roese	mtspr	SPRN_MAS2,r11
317a47a12beSStefan Roese	oris	r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@h
318a47a12beSStefan Roese	ori	r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@l
319a47a12beSStefan Roese	mtspr	SPRN_MAS3,r11
320a47a12beSStefan Roese	tlbwe
321a47a12beSStefan Roese
322a47a12beSStefan Roese	bl	1f
323a47a12beSStefan Roese1:	mflr	r11
324a47a12beSStefan Roese	/*
325a47a12beSStefan Roese	 * OR in 0xfff to create a mask of the bootpg SDRAM address.  We use
326a47a12beSStefan Roese	 * this mask to fixup the cpu spin table and the address that we want
327a47a12beSStefan Roese	 * to jump to, eg change them from 0xfffffxxx to 0x7ffffxxx if the
328a47a12beSStefan Roese	 * bootpg is at 0x7ffff000 in SDRAM.
329a47a12beSStefan Roese	 */
330a47a12beSStefan Roese	ori	r13,r13,0xfff
331a47a12beSStefan Roese	and	r11, r11, r13
332a47a12beSStefan Roese	and	r10, r10, r13
333a47a12beSStefan Roese
334a47a12beSStefan Roese	addi	r11,r11,(2f-1b)
335a47a12beSStefan Roese	mfmsr	r13
336a47a12beSStefan Roese	ori	r12,r13,MSR_IS|MSR_DS@l
337a47a12beSStefan Roese
338a47a12beSStefan Roese	mtspr	SPRN_SRR0,r11
339a47a12beSStefan Roese	mtspr	SPRN_SRR1,r12
340a47a12beSStefan Roese	rfi
341a47a12beSStefan Roese
342a47a12beSStefan Roese	/* spin waiting for addr */
343a47a12beSStefan Roese2:
344a47a12beSStefan Roese	lwz	r4,ENTRY_ADDR_LOWER(r10)
345a47a12beSStefan Roese	andi.	r11,r4,1
346a47a12beSStefan Roese	bne	2b
347a47a12beSStefan Roese	isync
348a47a12beSStefan Roese
349a47a12beSStefan Roese	/* setup IVORs to match fixed offsets */
350a47a12beSStefan Roese#include "fixed_ivor.S"
351a47a12beSStefan Roese
352a47a12beSStefan Roese	/* get the upper bits of the addr */
353a47a12beSStefan Roese	lwz	r11,ENTRY_ADDR_UPPER(r10)
354a47a12beSStefan Roese
355a47a12beSStefan Roese	/* setup branch addr */
356a47a12beSStefan Roese	mtspr	SPRN_SRR0,r4
357a47a12beSStefan Roese
358a47a12beSStefan Roese	/* mark the entry as released */
359a47a12beSStefan Roese	li	r8,3
360a47a12beSStefan Roese	stw	r8,ENTRY_ADDR_LOWER(r10)
361a47a12beSStefan Roese
362a47a12beSStefan Roese	/* mask by ~64M to setup our tlb we will jump to */
363a47a12beSStefan Roese	rlwinm	r12,r4,0,0,5
364a47a12beSStefan Roese
365a47a12beSStefan Roese	/* setup r3, r4, r5, r6, r7, r8, r9 */
366a47a12beSStefan Roese	lwz	r3,ENTRY_R3_LOWER(r10)
367a47a12beSStefan Roese	li	r4,0
368a47a12beSStefan Roese	li	r5,0
369a47a12beSStefan Roese	lwz	r6,ENTRY_R6_LOWER(r10)
370a47a12beSStefan Roese	lis	r7,(64*1024*1024)@h
371a47a12beSStefan Roese	li	r8,0
372a47a12beSStefan Roese	li	r9,0
373a47a12beSStefan Roese
374a47a12beSStefan Roese	/* load up the pir */
375a47a12beSStefan Roese	lwz	r0,ENTRY_PIR(r10)
376a47a12beSStefan Roese	mtspr	SPRN_PIR,r0
377a47a12beSStefan Roese	mfspr	r0,SPRN_PIR
378a47a12beSStefan Roese	stw	r0,ENTRY_PIR(r10)
379a47a12beSStefan Roese
380a47a12beSStefan Roese	mtspr	IVPR,r12
381a47a12beSStefan Roese/*
382a47a12beSStefan Roese * Coming here, we know the cpu has one TLB mapping in TLB1[0]
383a47a12beSStefan Roese * which maps 0xfffff000-0xffffffff one-to-one.  We set up a
384a47a12beSStefan Roese * second mapping that maps addr 1:1 for 64M, and then we jump to
385a47a12beSStefan Roese * addr
386a47a12beSStefan Roese */
387a47a12beSStefan Roese	lis	r10,(MAS0_TLBSEL(1)|MAS0_ESEL(0))@h
388a47a12beSStefan Roese	mtspr	SPRN_MAS0,r10
389a47a12beSStefan Roese	lis	r10,(MAS1_VALID|MAS1_IPROT)@h
390a47a12beSStefan Roese	ori	r10,r10,(MAS1_TSIZE(BOOKE_PAGESZ_64M))@l
391a47a12beSStefan Roese	mtspr	SPRN_MAS1,r10
392a47a12beSStefan Roese	/* WIMGE = 0b00000 for now */
393a47a12beSStefan Roese	mtspr	SPRN_MAS2,r12
394a47a12beSStefan Roese	ori	r12,r12,(MAS3_SX|MAS3_SW|MAS3_SR)
395a47a12beSStefan Roese	mtspr	SPRN_MAS3,r12
396a47a12beSStefan Roese#ifdef CONFIG_ENABLE_36BIT_PHYS
397a47a12beSStefan Roese	mtspr	SPRN_MAS7,r11
398a47a12beSStefan Roese#endif
399a47a12beSStefan Roese	tlbwe
400a47a12beSStefan Roese
401a47a12beSStefan Roese/* Now we have another mapping for this page, so we jump to that
402a47a12beSStefan Roese * mapping
403a47a12beSStefan Roese */
404a47a12beSStefan Roese	mtspr	SPRN_SRR1,r13
405a47a12beSStefan Roese	rfi
406a47a12beSStefan Roese
407a47a12beSStefan Roese	/*
408a47a12beSStefan Roese	 * Allocate some space for the SDRAM address of the bootpg.
409a47a12beSStefan Roese	 * This variable has to be in the boot page so that it can
410a47a12beSStefan Roese	 * be accessed by secondary cores when they come out of reset.
411a47a12beSStefan Roese	 */
412a47a12beSStefan Roese	.globl __bootpg_addr
413a47a12beSStefan Roese__bootpg_addr:
414a47a12beSStefan Roese	.long	0
415a47a12beSStefan Roese
416a47a12beSStefan Roese	.align L1_CACHE_SHIFT
417a47a12beSStefan Roese	.globl __spin_table
418a47a12beSStefan Roese__spin_table:
419a47a12beSStefan Roese	.space CONFIG_MAX_CPUS*ENTRY_SIZE
420a47a12beSStefan Roese
42157125f22SYork Sun	/*
42257125f22SYork Sun	 * This variable is set by cpu_init_r() after parsing hwconfig
42357125f22SYork Sun	 * to enable workaround for erratum NMG_CPU_A011.
42457125f22SYork Sun	 */
42557125f22SYork Sun	.align L1_CACHE_SHIFT
42657125f22SYork Sun	.global enable_cpu_a011_workaround
42757125f22SYork Sunenable_cpu_a011_workaround:
42857125f22SYork Sun	.long	1
42957125f22SYork Sun
430a47a12beSStefan Roese	/* Fill in the empty space.  The actual reset vector is
431a47a12beSStefan Roese	 * the last word of the page */
432a47a12beSStefan Roese__secondary_start_code_end:
433a47a12beSStefan Roese	.space 4092 - (__secondary_start_code_end - __secondary_start_page)
434a47a12beSStefan Roese__secondary_reset_vector:
435a47a12beSStefan Roese	b	__secondary_start_page
436