blob: 0e0daf5a44ef5b6b324fc2dfe94634df63f02222 [file] [log] [blame]
Poonam Aggrwal0e870982009-07-31 12:08:14 +05301/*
York Sun709389b2012-08-17 08:20:26 +00002 * Copyright 2008-2012 Freescale Semiconductor, Inc.
Poonam Aggrwal0e870982009-07-31 12:08:14 +05303 * Kumar Gala <kumar.gala@freescale.com>
4 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02005 * SPDX-License-Identifier: GPL-2.0+
Poonam Aggrwal0e870982009-07-31 12:08:14 +05306 */
7
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +02008#include <asm-offsets.h>
Kumar Galaec2b74f2008-01-17 16:48:33 -06009#include <config.h>
10#include <mpc85xx.h>
Kumar Galaec2b74f2008-01-17 16:48:33 -060011
Kumar Galaec2b74f2008-01-17 16:48:33 -060012#include <ppc_asm.tmpl>
13#include <ppc_defs.h>
14
15#include <asm/cache.h>
16#include <asm/mmu.h>
17
18/* To boot secondary cpus, we need a place for them to start up.
19 * Normally, they start at 0xfffffffc, but that's usually the
20 * firmware, and we don't want to have to run the firmware again.
21 * Instead, the primary cpu will set the BPTR to point here to
22 * this page. We then set up the core, and head to
23 * start_secondary. Note that this means that the code below
24 * must never exceed 1023 instructions (the branch at the end
25 * would then be the 1024th).
26 */
27 .globl __secondary_start_page
28 .align 12
29__secondary_start_page:
30/* First do some preliminary setup */
31 lis r3, HID0_EMCP@h /* enable machine check */
Kumar Gala0f060c32008-10-23 01:47:38 -050032#ifndef CONFIG_E500MC
Kumar Galaec2b74f2008-01-17 16:48:33 -060033 ori r3,r3,HID0_TBEN@l /* enable Timebase */
Kumar Gala0f060c32008-10-23 01:47:38 -050034#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -060035#ifdef CONFIG_PHYS_64BIT
36 ori r3,r3,HID0_ENMAS7@l /* enable MAS7 updates */
37#endif
38 mtspr SPRN_HID0,r3
39
Kumar Gala0f060c32008-10-23 01:47:38 -050040#ifndef CONFIG_E500MC
Kumar Galaec2b74f2008-01-17 16:48:33 -060041 li r3,(HID1_ASTME|HID1_ABE)@l /* Addr streaming & broadcast */
Sandeep Gopalpetff8473e2010-03-12 10:45:02 +053042 mfspr r0,PVR
43 andi. r0,r0,0xff
44 cmpwi r0,0x50@l /* if we are rev 5.0 or greater set MBDD */
45 blt 1f
46 /* Set MBDD bit also */
47 ori r3, r3, HID1_MBDD@l
481:
Kumar Galaec2b74f2008-01-17 16:48:33 -060049 mtspr SPRN_HID1,r3
Kumar Gala0f060c32008-10-23 01:47:38 -050050#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -060051
Kumar Gala43f082b2011-11-22 06:51:15 -060052#ifdef CONFIG_SYS_FSL_ERRATUM_CPU_A003999
Andy Flemingcd7ad622013-03-25 07:33:10 +000053 mfspr r3,SPRN_HDBCR1
Kumar Gala43f082b2011-11-22 06:51:15 -060054 oris r3,r3,0x0100
Andy Flemingcd7ad622013-03-25 07:33:10 +000055 mtspr SPRN_HDBCR1,r3
Kumar Gala43f082b2011-11-22 06:51:15 -060056#endif
57
Scott Wood33eee332012-08-14 10:14:53 +000058#ifdef CONFIG_SYS_FSL_ERRATUM_A004510
59 mfspr r3,SPRN_SVR
60 rlwinm r3,r3,0,0xff
61 li r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV
62 cmpw r3,r4
63 beq 1f
64
65#ifdef CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2
66 li r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2
67 cmpw r3,r4
68 beq 1f
69#endif
70
71 /* Not a supported revision affected by erratum */
72 b 2f
73
741: /* Erratum says set bits 55:60 to 001001 */
75 msync
76 isync
Andy Flemingcd7ad622013-03-25 07:33:10 +000077 mfspr r3,SPRN_HDBCR0
Scott Wood33eee332012-08-14 10:14:53 +000078 li r4,0x48
79 rlwimi r3,r4,0,0x1f8
Andy Flemingcd7ad622013-03-25 07:33:10 +000080 mtspr SPRN_HDBCR0,r3
Scott Wood33eee332012-08-14 10:14:53 +000081 isync
822:
83#endif
84
Kumar Galaec2b74f2008-01-17 16:48:33 -060085 /* Enable branch prediction */
Kumar Gala69bcf5b2010-03-29 13:50:31 -050086 lis r3,BUCSR_ENABLE@h
87 ori r3,r3,BUCSR_ENABLE@l
Kumar Galaec2b74f2008-01-17 16:48:33 -060088 mtspr SPRN_BUCSR,r3
89
Kumar Galae0ff3d32008-09-08 08:51:29 -050090 /* Ensure TB is 0 */
91 li r3,0
92 mttbl r3
93 mttbu r3
94
Kumar Galaec2b74f2008-01-17 16:48:33 -060095 /* Enable/invalidate the I-Cache */
Kumar Gala33f57bd2010-03-26 15:14:43 -050096 lis r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@h
97 ori r2,r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@l
98 mtspr SPRN_L1CSR1,r2
991:
100 mfspr r3,SPRN_L1CSR1
101 and. r1,r3,r2
102 bne 1b
103
104 lis r3,(L1CSR1_CPE|L1CSR1_ICE)@h
105 ori r3,r3,(L1CSR1_CPE|L1CSR1_ICE)@l
106 mtspr SPRN_L1CSR1,r3
Kumar Galaec2b74f2008-01-17 16:48:33 -0600107 isync
Kumar Gala33f57bd2010-03-26 15:14:43 -05001082:
109 mfspr r3,SPRN_L1CSR1
110 andi. r1,r3,L1CSR1_ICE@l
111 beq 2b
Kumar Galaec2b74f2008-01-17 16:48:33 -0600112
113 /* Enable/invalidate the D-Cache */
Kumar Gala33f57bd2010-03-26 15:14:43 -0500114 lis r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@h
115 ori r2,r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@l
116 mtspr SPRN_L1CSR0,r2
1171:
118 mfspr r3,SPRN_L1CSR0
119 and. r1,r3,r2
120 bne 1b
121
122 lis r3,(L1CSR0_CPE|L1CSR0_DCE)@h
123 ori r3,r3,(L1CSR0_CPE|L1CSR0_DCE)@l
124 mtspr SPRN_L1CSR0,r3
Kumar Galaec2b74f2008-01-17 16:48:33 -0600125 isync
Kumar Gala33f57bd2010-03-26 15:14:43 -05001262:
127 mfspr r3,SPRN_L1CSR0
128 andi. r1,r3,L1CSR0_DCE@l
129 beq 2b
Kumar Galaec2b74f2008-01-17 16:48:33 -0600130
131#define toreset(x) (x - __secondary_start_page + 0xfffff000)
132
133 /* get our PIR to figure out our table entry */
York Sunffd06e02012-10-08 07:44:30 +0000134 lis r3,toreset(__spin_table_addr)@h
135 ori r3,r3,toreset(__spin_table_addr)@l
136 lwz r3,0(r3)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600137
Kumar Galaec2b74f2008-01-17 16:48:33 -0600138 mfspr r0,SPRN_PIR
York Sun615f0cb2013-03-25 07:33:27 +0000139#ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
York Sun709389b2012-08-17 08:20:26 +0000140/*
York Sun615f0cb2013-03-25 07:33:27 +0000141 * PIR definition for Chassis 2
York Sun709389b2012-08-17 08:20:26 +0000142 * 0-17 Reserved (logic 0s)
York Sunf6981432013-03-25 07:40:07 +0000143 * 18-19 CHIP_ID, 2'b00 - SoC 1
York Sun709389b2012-08-17 08:20:26 +0000144 * all others - reserved
Timur Tabi0c7e65f2012-10-05 09:48:50 +0000145 * 20-24 CLUSTER_ID 5'b00000 - CCM 1
York Sun709389b2012-08-17 08:20:26 +0000146 * all others - reserved
Timur Tabi0c7e65f2012-10-05 09:48:50 +0000147 * 25-26 CORE_CLUSTER_ID 2'b00 - cluster 1
148 * 2'b01 - cluster 2
149 * 2'b10 - cluster 3
150 * 2'b11 - cluster 4
151 * 27-28 CORE_ID 2'b00 - core 0
152 * 2'b01 - core 1
153 * 2'b10 - core 2
154 * 2'b11 - core 3
155 * 29-31 THREAD_ID 3'b000 - thread 0
156 * 3'b001 - thread 1
York Sunf6981432013-03-25 07:40:07 +0000157 *
158 * Power-on PIR increments threads by 0x01, cores within a cluster by 0x08
159 * and clusters by 0x20.
160 *
161 * We renumber PIR so that all threads in the system are consecutive.
York Sun709389b2012-08-17 08:20:26 +0000162 */
York Sunf6981432013-03-25 07:40:07 +0000163
164 rlwinm r8,r0,29,0x03 /* r8 = core within cluster */
165 srwi r10,r0,5 /* r10 = cluster */
166
167 mulli r5,r10,CONFIG_SYS_FSL_CORES_PER_CLUSTER
168 add r5,r5,r8 /* for spin table index */
169 mulli r4,r5,CONFIG_SYS_FSL_THREADS_PER_CORE /* for PIR */
York Sun709389b2012-08-17 08:20:26 +0000170#elif defined(CONFIG_E500MC)
Kumar Gala0f060c32008-10-23 01:47:38 -0500171 rlwinm r4,r0,27,27,31
York Sunf6981432013-03-25 07:40:07 +0000172 mr r5,r4
Kumar Gala0f060c32008-10-23 01:47:38 -0500173#else
Kumar Galaec2b74f2008-01-17 16:48:33 -0600174 mr r4,r0
York Sunf6981432013-03-25 07:40:07 +0000175 mr r5,r4
Kumar Gala0f060c32008-10-23 01:47:38 -0500176#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -0600177
York Sun709389b2012-08-17 08:20:26 +0000178 /*
York Sunf6981432013-03-25 07:40:07 +0000179 * r10 has the base address for the entry.
180 * we cannot access it yet before setting up a new TLB
York Sun709389b2012-08-17 08:20:26 +0000181 */
York Sunf6981432013-03-25 07:40:07 +0000182 slwi r8,r5,6 /* spin table is padded to 64 byte */
183 add r10,r3,r8
York Sun709389b2012-08-17 08:20:26 +0000184
185 mtspr SPRN_PIR,r4 /* write to PIR register */
186
York Sun6d2b9da2012-10-08 07:44:08 +0000187#ifdef CONFIG_SYS_CACHE_STASHING
188 /* set stash id to (coreID) * 2 + 32 + L1 CT (0) */
189 slwi r8,r4,1
190 addi r8,r8,32
191 mtspr L1CSR2,r8
192#endif
193
York Sun5e23ab02012-05-07 07:26:47 +0000194#if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) || \
195 defined(CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011)
196 /*
197 * CPU22 applies to P4080 rev 1.0, 2.0, fixed in 3.0
198 * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0
199 * also appleis to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1
200 */
York Sun1e9ea852012-05-07 07:26:45 +0000201 mfspr r3,SPRN_SVR
York Sun5e23ab02012-05-07 07:26:47 +0000202 rlwinm r6,r3,24,~0x800 /* clear E bit */
York Sun1e9ea852012-05-07 07:26:45 +0000203
York Sun5e23ab02012-05-07 07:26:47 +0000204 lis r5,SVR_P4080@h
205 ori r5,r5,SVR_P4080@l
206 cmpw r6,r5
207 bne 1f
208
209 rlwinm r3,r3,0,0xf0
210 li r5,0x30
211 cmpw r3,r5
212 bge 2f
2131:
York Sun57125f22012-08-08 18:04:53 +0000214#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011
215 lis r3,toreset(enable_cpu_a011_workaround)@ha
216 lwz r3,toreset(enable_cpu_a011_workaround)@l(r3)
217 cmpwi r3,0
218 beq 2f
219#endif
York Sun5e23ab02012-05-07 07:26:47 +0000220 mfspr r3,L1CSR2
221 oris r3,r3,(L1CSR2_DCWS)@h
222 mtspr L1CSR2,r3
York Sun1e9ea852012-05-07 07:26:45 +00002232:
Kumar Galafd3c9be2010-05-05 22:35:27 -0500224#endif
225
York Sund217a9a2013-06-25 11:37:49 -0700226#ifdef CONFIG_SYS_FSL_ERRATUM_A005812
227 /*
228 * A-005812 workaround sets bit 32 of SPR 976 for SoCs running in
229 * write shadow mode. This code should run after other code setting
230 * DCWS.
231 */
232 mfspr r3,L1CSR2
233 andis. r3,r3,(L1CSR2_DCWS)@h
234 beq 1f
235 mfspr r3, SPRN_HDBCR0
236 oris r3, r3, 0x8000
237 mtspr SPRN_HDBCR0, r3
2381:
239#endif
240
Kumar Gala1b3e4042009-03-19 09:16:10 -0500241#ifdef CONFIG_BACKSIDE_L2_CACHE
Kumar Galaacf3f8d2011-07-21 00:20:21 -0500242 /* skip L2 setup on P2040/P2040E as they have no L2 */
York Sunfeae3422012-05-07 07:39:53 +0000243 mfspr r3,SPRN_SVR
244 rlwinm r6,r3,24,~0x800 /* clear E bit of SVR */
245
Kumar Galaacf3f8d2011-07-21 00:20:21 -0500246 lis r3,SVR_P2040@h
247 ori r3,r3,SVR_P2040@l
York Sunfeae3422012-05-07 07:39:53 +0000248 cmpw r6,r3
Kumar Galaacf3f8d2011-07-21 00:20:21 -0500249 beq 3f
250
Kumar Gala1b3e4042009-03-19 09:16:10 -0500251 /* Enable/invalidate the L2 cache */
252 msync
Dave Liuff8822952009-10-31 07:59:55 +0800253 lis r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@h
254 ori r2,r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@l
255 mtspr SPRN_L2CSR0,r2
Kumar Gala1b3e4042009-03-19 09:16:10 -05002561:
257 mfspr r3,SPRN_L2CSR0
Dave Liuff8822952009-10-31 07:59:55 +0800258 and. r1,r3,r2
Kumar Gala1b3e4042009-03-19 09:16:10 -0500259 bne 1b
260
Kumar Gala82fd1f82009-03-19 02:53:01 -0500261#ifdef CONFIG_SYS_CACHE_STASHING
262 /* set stash id to (coreID) * 2 + 32 + L2 (1) */
263 addi r3,r8,1
264 mtspr SPRN_L2CSR1,r3
265#endif
266
Kumar Gala1b3e4042009-03-19 09:16:10 -0500267 lis r3,CONFIG_SYS_INIT_L2CSR0@h
268 ori r3,r3,CONFIG_SYS_INIT_L2CSR0@l
269 mtspr SPRN_L2CSR0,r3
270 isync
Dave Liuff8822952009-10-31 07:59:55 +08002712:
272 mfspr r3,SPRN_L2CSR0
273 andis. r1,r3,L2CSR0_L2E@h
274 beq 2b
Kumar Gala1b3e4042009-03-19 09:16:10 -0500275#endif
Kumar Galaacf3f8d2011-07-21 00:20:21 -05002763:
York Sunffd06e02012-10-08 07:44:30 +0000277 /* setup mapping for the spin table, WIMGE=0b00100 */
278 lis r13,toreset(__spin_table_addr)@h
279 ori r13,r13,toreset(__spin_table_addr)@l
280 lwz r13,0(r13)
281 /* mask by 4K */
282 rlwinm r13,r13,0,0,19
Kumar Gala1b3e4042009-03-19 09:16:10 -0500283
York Sunffd06e02012-10-08 07:44:30 +0000284 lis r11,(MAS0_TLBSEL(1)|MAS0_ESEL(1))@h
285 mtspr SPRN_MAS0,r11
286 lis r11,(MAS1_VALID|MAS1_IPROT)@h
287 ori r11,r11,(MAS1_TS|MAS1_TSIZE(BOOKE_PAGESZ_4K))@l
288 mtspr SPRN_MAS1,r11
289 oris r11,r13,(MAS2_M|MAS2_G)@h
290 ori r11,r13,(MAS2_M|MAS2_G)@l
291 mtspr SPRN_MAS2,r11
292 oris r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@h
293 ori r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@l
294 mtspr SPRN_MAS3,r11
295 li r11,0
296 mtspr SPRN_MAS7,r11
297 tlbwe
298
299 /*
300 * __bootpg_addr has the address of __second_half_boot_page
301 * jump there in AS=1 space with cache enabled
302 */
303 lis r13,toreset(__bootpg_addr)@h
304 ori r13,r13,toreset(__bootpg_addr)@l
305 lwz r11,0(r13)
306 mtspr SPRN_SRR0,r11
307 mfmsr r13
308 ori r12,r13,MSR_IS|MSR_DS@l
309 mtspr SPRN_SRR1,r12
310 rfi
311
312 /*
313 * Allocate some space for the SDRAM address of the bootpg.
314 * This variable has to be in the boot page so that it can
315 * be accessed by secondary cores when they come out of reset.
316 */
317 .align L1_CACHE_SHIFT
318 .globl __bootpg_addr
319__bootpg_addr:
320 .long 0
321
322 .global __spin_table_addr
323__spin_table_addr:
324 .long 0
325
326 /*
327 * This variable is set by cpu_init_r() after parsing hwconfig
328 * to enable workaround for erratum NMG_CPU_A011.
329 */
330 .align L1_CACHE_SHIFT
331 .global enable_cpu_a011_workaround
332enable_cpu_a011_workaround:
333 .long 1
334
335 /* Fill in the empty space. The actual reset vector is
336 * the last word of the page */
337__secondary_start_code_end:
338 .space 4092 - (__secondary_start_code_end - __secondary_start_page)
339__secondary_reset_vector:
340 b __secondary_start_page
341
342
343/* this is a separated page for the spin table and cacheable boot code */
344 .align L1_CACHE_SHIFT
345 .global __second_half_boot_page
346__second_half_boot_page:
York Sun2a5fcb82012-10-28 08:12:54 +0000347#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE
348 lis r3,(spin_table_compat - __second_half_boot_page)@h
349 ori r3,r3,(spin_table_compat - __second_half_boot_page)@l
350 add r3,r3,r11 /* r11 has the address of __second_half_boot_page */
351 lwz r14,0(r3)
352#endif
353
Kumar Gala79679d82008-03-26 08:34:25 -0500354#define ENTRY_ADDR_UPPER 0
355#define ENTRY_ADDR_LOWER 4
356#define ENTRY_R3_UPPER 8
357#define ENTRY_R3_LOWER 12
358#define ENTRY_RESV 16
359#define ENTRY_PIR 20
York Sunffd06e02012-10-08 07:44:30 +0000360#define ENTRY_SIZE 64
361 /*
362 * setup the entry
363 * r10 has the base address of the spin table.
364 * spin table is defined as
365 * struct {
366 * uint64_t entry_addr;
367 * uint64_t r3;
368 * uint32_t rsvd1;
369 * uint32_t pir;
370 * };
371 * we pad this struct to 64 bytes so each entry is in its own cacheline
372 */
Kumar Gala79679d82008-03-26 08:34:25 -0500373 li r3,0
Kumar Galaec2b74f2008-01-17 16:48:33 -0600374 li r8,1
York Sunffd06e02012-10-08 07:44:30 +0000375 mfspr r4,SPRN_PIR
Kumar Gala79679d82008-03-26 08:34:25 -0500376 stw r3,ENTRY_ADDR_UPPER(r10)
Kumar Gala79679d82008-03-26 08:34:25 -0500377 stw r3,ENTRY_R3_UPPER(r10)
378 stw r4,ENTRY_R3_LOWER(r10)
York Sunffd06e02012-10-08 07:44:30 +0000379 stw r3,ENTRY_RESV(r10)
380 stw r4,ENTRY_PIR(r10)
381 msync
382 stw r8,ENTRY_ADDR_LOWER(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600383
384 /* spin waiting for addr */
York Sun2a5fcb82012-10-28 08:12:54 +00003853:
386/*
387 * To comply with ePAPR 1.1, the spin table has been moved to cache-enabled
388 * memory. Old OS may not work with this change. A patch is waiting to be
389 * accepted for Linux kernel. Other OS needs similar fix to spin table.
390 * For OSes with old spin table code, we can enable this temporary fix by
391 * setting environmental variable "spin_table_compat". For new OSes, set
392 * "spin_table_compat=no". After Linux is fixed, we can remove this macro
393 * and related code. For now, it is enabled by default.
394 */
395#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE
396 cmpwi r14,0
397 beq 4f
398 dcbf 0, r10
399 sync
4004:
401#endif
402 lwz r4,ENTRY_ADDR_LOWER(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600403 andi. r11,r4,1
York Sunffd06e02012-10-08 07:44:30 +0000404 bne 3b
Kumar Galacf6cc012008-04-28 02:24:04 -0500405 isync
Kumar Gala79679d82008-03-26 08:34:25 -0500406
407 /* get the upper bits of the addr */
408 lwz r11,ENTRY_ADDR_UPPER(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600409
410 /* setup branch addr */
Kumar Gala79679d82008-03-26 08:34:25 -0500411 mtspr SPRN_SRR0,r4
Kumar Galaec2b74f2008-01-17 16:48:33 -0600412
413 /* mark the entry as released */
414 li r8,3
Kumar Gala79679d82008-03-26 08:34:25 -0500415 stw r8,ENTRY_ADDR_LOWER(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600416
417 /* mask by ~64M to setup our tlb we will jump to */
Kumar Gala79679d82008-03-26 08:34:25 -0500418 rlwinm r12,r4,0,0,5
Kumar Galaec2b74f2008-01-17 16:48:33 -0600419
York Sunffd06e02012-10-08 07:44:30 +0000420 /*
421 * setup r3, r4, r5, r6, r7, r8, r9
422 * r3 contains the value to put in the r3 register at secondary cpu
423 * entry. The high 32-bits are ignored on 32-bit chip implementations.
424 * 64-bit chip implementations however shall load all 64-bits
425 */
426#ifdef CONFIG_SYS_PPC64
427 ld r3,ENTRY_R3_UPPER(r10)
428#else
Kumar Gala79679d82008-03-26 08:34:25 -0500429 lwz r3,ENTRY_R3_LOWER(r10)
York Sunffd06e02012-10-08 07:44:30 +0000430#endif
Kumar Gala79679d82008-03-26 08:34:25 -0500431 li r4,0
Kumar Galaec2b74f2008-01-17 16:48:33 -0600432 li r5,0
York Sun3f0997b2012-10-08 07:44:29 +0000433 li r6,0
Kumar Gala79679d82008-03-26 08:34:25 -0500434 lis r7,(64*1024*1024)@h
435 li r8,0
436 li r9,0
Kumar Galaec2b74f2008-01-17 16:48:33 -0600437
438 /* load up the pir */
Kumar Gala79679d82008-03-26 08:34:25 -0500439 lwz r0,ENTRY_PIR(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600440 mtspr SPRN_PIR,r0
441 mfspr r0,SPRN_PIR
Kumar Gala79679d82008-03-26 08:34:25 -0500442 stw r0,ENTRY_PIR(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600443
Haiying Wang181a3652008-12-03 10:08:19 -0500444 mtspr IVPR,r12
Kumar Galaec2b74f2008-01-17 16:48:33 -0600445/*
446 * Coming here, we know the cpu has one TLB mapping in TLB1[0]
447 * which maps 0xfffff000-0xffffffff one-to-one. We set up a
448 * second mapping that maps addr 1:1 for 64M, and then we jump to
449 * addr
450 */
Kumar Gala79679d82008-03-26 08:34:25 -0500451 lis r10,(MAS0_TLBSEL(1)|MAS0_ESEL(0))@h
452 mtspr SPRN_MAS0,r10
453 lis r10,(MAS1_VALID|MAS1_IPROT)@h
454 ori r10,r10,(MAS1_TSIZE(BOOKE_PAGESZ_64M))@l
455 mtspr SPRN_MAS1,r10
Kumar Galaec2b74f2008-01-17 16:48:33 -0600456 /* WIMGE = 0b00000 for now */
Kumar Gala79679d82008-03-26 08:34:25 -0500457 mtspr SPRN_MAS2,r12
458 ori r12,r12,(MAS3_SX|MAS3_SW|MAS3_SR)
459 mtspr SPRN_MAS3,r12
460#ifdef CONFIG_ENABLE_36BIT_PHYS
461 mtspr SPRN_MAS7,r11
462#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -0600463 tlbwe
464
465/* Now we have another mapping for this page, so we jump to that
466 * mapping
467 */
Kumar Gala79679d82008-03-26 08:34:25 -0500468 mtspr SPRN_SRR1,r13
469 rfi
Kumar Galaec2b74f2008-01-17 16:48:33 -0600470
Peter Tyser5ccd29c2009-10-23 15:55:47 -0500471
York Sunffd06e02012-10-08 07:44:30 +0000472 .align 6
Kumar Galaec2b74f2008-01-17 16:48:33 -0600473 .globl __spin_table
474__spin_table:
Poonam Aggrwal0e870982009-07-31 12:08:14 +0530475 .space CONFIG_MAX_CPUS*ENTRY_SIZE
York Sun2a5fcb82012-10-28 08:12:54 +0000476
477#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE
478 .align L1_CACHE_SHIFT
479 .global spin_table_compat
480spin_table_compat:
481 .long 1
482
483#endif
484
York Sunffd06e02012-10-08 07:44:30 +0000485__spin_table_end:
486 .space 4096 - (__spin_table_end - __spin_table)