blob: d37e1ccf1e7fdfae016fb92e9c55be046a2655d0 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Poonam Aggrwal0e870982009-07-31 12:08:14 +05302/*
York Sun709389b2012-08-17 08:20:26 +00003 * Copyright 2008-2012 Freescale Semiconductor, Inc.
Poonam Aggrwal0e870982009-07-31 12:08:14 +05304 * Kumar Gala <kumar.gala@freescale.com>
Poonam Aggrwal0e870982009-07-31 12:08:14 +05305 */
6
Wolfgang Denk25ddd1f2010-10-26 14:34:52 +02007#include <asm-offsets.h>
Kumar Galaec2b74f2008-01-17 16:48:33 -06008#include <config.h>
9#include <mpc85xx.h>
Kumar Galaec2b74f2008-01-17 16:48:33 -060010
Kumar Galaec2b74f2008-01-17 16:48:33 -060011#include <ppc_asm.tmpl>
12#include <ppc_defs.h>
13
14#include <asm/cache.h>
15#include <asm/mmu.h>
16
17/* To boot secondary cpus, we need a place for them to start up.
18 * Normally, they start at 0xfffffffc, but that's usually the
19 * firmware, and we don't want to have to run the firmware again.
20 * Instead, the primary cpu will set the BPTR to point here to
21 * this page. We then set up the core, and head to
22 * start_secondary. Note that this means that the code below
23 * must never exceed 1023 instructions (the branch at the end
24 * would then be the 1024th).
25 */
26 .globl __secondary_start_page
27 .align 12
28__secondary_start_page:
Takuma Ueba6a265ab2018-04-23 13:27:33 +090029#ifdef CONFIG_SYS_FSL_ERRATUM_A005125
30 msync
31 isync
32 mfspr r3, SPRN_HDBCR0
33 oris r3, r3, 0x0080
34 mtspr SPRN_HDBCR0, r3
35#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -060036/* First do some preliminary setup */
37 lis r3, HID0_EMCP@h /* enable machine check */
Kumar Gala0f060c32008-10-23 01:47:38 -050038#ifndef CONFIG_E500MC
Kumar Galaec2b74f2008-01-17 16:48:33 -060039 ori r3,r3,HID0_TBEN@l /* enable Timebase */
Kumar Gala0f060c32008-10-23 01:47:38 -050040#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -060041#ifdef CONFIG_PHYS_64BIT
42 ori r3,r3,HID0_ENMAS7@l /* enable MAS7 updates */
43#endif
44 mtspr SPRN_HID0,r3
45
Kumar Gala0f060c32008-10-23 01:47:38 -050046#ifndef CONFIG_E500MC
Kumar Galaec2b74f2008-01-17 16:48:33 -060047 li r3,(HID1_ASTME|HID1_ABE)@l /* Addr streaming & broadcast */
Sandeep Gopalpetff8473e2010-03-12 10:45:02 +053048 mfspr r0,PVR
49 andi. r0,r0,0xff
50 cmpwi r0,0x50@l /* if we are rev 5.0 or greater set MBDD */
51 blt 1f
52 /* Set MBDD bit also */
53 ori r3, r3, HID1_MBDD@l
541:
Kumar Galaec2b74f2008-01-17 16:48:33 -060055 mtspr SPRN_HID1,r3
Kumar Gala0f060c32008-10-23 01:47:38 -050056#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -060057
Kumar Gala43f082b2011-11-22 06:51:15 -060058#ifdef CONFIG_SYS_FSL_ERRATUM_CPU_A003999
Andy Flemingcd7ad622013-03-25 07:33:10 +000059 mfspr r3,SPRN_HDBCR1
Kumar Gala43f082b2011-11-22 06:51:15 -060060 oris r3,r3,0x0100
Andy Flemingcd7ad622013-03-25 07:33:10 +000061 mtspr SPRN_HDBCR1,r3
Kumar Gala43f082b2011-11-22 06:51:15 -060062#endif
63
Scott Wood33eee332012-08-14 10:14:53 +000064#ifdef CONFIG_SYS_FSL_ERRATUM_A004510
65 mfspr r3,SPRN_SVR
66 rlwinm r3,r3,0,0xff
67 li r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV
68 cmpw r3,r4
69 beq 1f
70
71#ifdef CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2
72 li r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2
73 cmpw r3,r4
74 beq 1f
75#endif
76
77 /* Not a supported revision affected by erratum */
78 b 2f
79
801: /* Erratum says set bits 55:60 to 001001 */
81 msync
82 isync
Andy Flemingcd7ad622013-03-25 07:33:10 +000083 mfspr r3,SPRN_HDBCR0
Scott Wood33eee332012-08-14 10:14:53 +000084 li r4,0x48
85 rlwimi r3,r4,0,0x1f8
Andy Flemingcd7ad622013-03-25 07:33:10 +000086 mtspr SPRN_HDBCR0,r3
Scott Wood33eee332012-08-14 10:14:53 +000087 isync
882:
89#endif
90
Kumar Galaec2b74f2008-01-17 16:48:33 -060091 /* Enable branch prediction */
Kumar Gala69bcf5b2010-03-29 13:50:31 -050092 lis r3,BUCSR_ENABLE@h
93 ori r3,r3,BUCSR_ENABLE@l
Kumar Galaec2b74f2008-01-17 16:48:33 -060094 mtspr SPRN_BUCSR,r3
95
Kumar Galae0ff3d32008-09-08 08:51:29 -050096 /* Ensure TB is 0 */
97 li r3,0
98 mttbl r3
99 mttbu r3
100
Kumar Galaec2b74f2008-01-17 16:48:33 -0600101 /* Enable/invalidate the I-Cache */
Kumar Gala33f57bd2010-03-26 15:14:43 -0500102 lis r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@h
103 ori r2,r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@l
104 mtspr SPRN_L1CSR1,r2
1051:
106 mfspr r3,SPRN_L1CSR1
107 and. r1,r3,r2
108 bne 1b
109
110 lis r3,(L1CSR1_CPE|L1CSR1_ICE)@h
111 ori r3,r3,(L1CSR1_CPE|L1CSR1_ICE)@l
112 mtspr SPRN_L1CSR1,r3
Kumar Galaec2b74f2008-01-17 16:48:33 -0600113 isync
Kumar Gala33f57bd2010-03-26 15:14:43 -05001142:
115 mfspr r3,SPRN_L1CSR1
116 andi. r1,r3,L1CSR1_ICE@l
117 beq 2b
Kumar Galaec2b74f2008-01-17 16:48:33 -0600118
119 /* Enable/invalidate the D-Cache */
Kumar Gala33f57bd2010-03-26 15:14:43 -0500120 lis r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@h
121 ori r2,r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@l
122 mtspr SPRN_L1CSR0,r2
1231:
124 mfspr r3,SPRN_L1CSR0
125 and. r1,r3,r2
126 bne 1b
127
128 lis r3,(L1CSR0_CPE|L1CSR0_DCE)@h
129 ori r3,r3,(L1CSR0_CPE|L1CSR0_DCE)@l
130 mtspr SPRN_L1CSR0,r3
Kumar Galaec2b74f2008-01-17 16:48:33 -0600131 isync
Kumar Gala33f57bd2010-03-26 15:14:43 -05001322:
133 mfspr r3,SPRN_L1CSR0
134 andi. r1,r3,L1CSR0_DCE@l
135 beq 2b
Kumar Galaec2b74f2008-01-17 16:48:33 -0600136
137#define toreset(x) (x - __secondary_start_page + 0xfffff000)
138
139 /* get our PIR to figure out our table entry */
York Sunffd06e02012-10-08 07:44:30 +0000140 lis r3,toreset(__spin_table_addr)@h
141 ori r3,r3,toreset(__spin_table_addr)@l
142 lwz r3,0(r3)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600143
Kumar Galaec2b74f2008-01-17 16:48:33 -0600144 mfspr r0,SPRN_PIR
York Sun615f0cb2013-03-25 07:33:27 +0000145#ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
York Sun709389b2012-08-17 08:20:26 +0000146/*
York Sun615f0cb2013-03-25 07:33:27 +0000147 * PIR definition for Chassis 2
York Sun709389b2012-08-17 08:20:26 +0000148 * 0-17 Reserved (logic 0s)
York Sunf6981432013-03-25 07:40:07 +0000149 * 18-19 CHIP_ID, 2'b00 - SoC 1
York Sun709389b2012-08-17 08:20:26 +0000150 * all others - reserved
Timur Tabi0c7e65f2012-10-05 09:48:50 +0000151 * 20-24 CLUSTER_ID 5'b00000 - CCM 1
York Sun709389b2012-08-17 08:20:26 +0000152 * all others - reserved
Timur Tabi0c7e65f2012-10-05 09:48:50 +0000153 * 25-26 CORE_CLUSTER_ID 2'b00 - cluster 1
154 * 2'b01 - cluster 2
155 * 2'b10 - cluster 3
156 * 2'b11 - cluster 4
157 * 27-28 CORE_ID 2'b00 - core 0
158 * 2'b01 - core 1
159 * 2'b10 - core 2
160 * 2'b11 - core 3
161 * 29-31 THREAD_ID 3'b000 - thread 0
162 * 3'b001 - thread 1
York Sunf6981432013-03-25 07:40:07 +0000163 *
164 * Power-on PIR increments threads by 0x01, cores within a cluster by 0x08
165 * and clusters by 0x20.
166 *
167 * We renumber PIR so that all threads in the system are consecutive.
York Sun709389b2012-08-17 08:20:26 +0000168 */
York Sunf6981432013-03-25 07:40:07 +0000169
170 rlwinm r8,r0,29,0x03 /* r8 = core within cluster */
171 srwi r10,r0,5 /* r10 = cluster */
172
173 mulli r5,r10,CONFIG_SYS_FSL_CORES_PER_CLUSTER
174 add r5,r5,r8 /* for spin table index */
175 mulli r4,r5,CONFIG_SYS_FSL_THREADS_PER_CORE /* for PIR */
York Sun709389b2012-08-17 08:20:26 +0000176#elif defined(CONFIG_E500MC)
Kumar Gala0f060c32008-10-23 01:47:38 -0500177 rlwinm r4,r0,27,27,31
York Sunf6981432013-03-25 07:40:07 +0000178 mr r5,r4
Kumar Gala0f060c32008-10-23 01:47:38 -0500179#else
Kumar Galaec2b74f2008-01-17 16:48:33 -0600180 mr r4,r0
York Sunf6981432013-03-25 07:40:07 +0000181 mr r5,r4
Kumar Gala0f060c32008-10-23 01:47:38 -0500182#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -0600183
York Sun709389b2012-08-17 08:20:26 +0000184 /*
York Sunf6981432013-03-25 07:40:07 +0000185 * r10 has the base address for the entry.
186 * we cannot access it yet before setting up a new TLB
York Sun709389b2012-08-17 08:20:26 +0000187 */
York Sunf6981432013-03-25 07:40:07 +0000188 slwi r8,r5,6 /* spin table is padded to 64 byte */
189 add r10,r3,r8
York Sun709389b2012-08-17 08:20:26 +0000190
191 mtspr SPRN_PIR,r4 /* write to PIR register */
192
York Sun1e0d51a2017-10-17 08:00:21 -0700193#ifdef CONFIG_SYS_FSL_ERRATUM_A007907
194 mfspr r8, L1CSR2
195 clrrwi r8, r8, 10 /* clear bit [54-63] DCSTASHID */
196 mtspr L1CSR2, r8
197#else
York Sun6d2b9da2012-10-08 07:44:08 +0000198#ifdef CONFIG_SYS_CACHE_STASHING
199 /* set stash id to (coreID) * 2 + 32 + L1 CT (0) */
200 slwi r8,r4,1
201 addi r8,r8,32
202 mtspr L1CSR2,r8
203#endif
York Sun1e0d51a2017-10-17 08:00:21 -0700204#endif /* CONFIG_SYS_FSL_ERRATUM_A007907 */
York Sun6d2b9da2012-10-08 07:44:08 +0000205
York Sun5e23ab02012-05-07 07:26:47 +0000206#if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) || \
207 defined(CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011)
208 /*
209 * CPU22 applies to P4080 rev 1.0, 2.0, fixed in 3.0
210 * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0
211 * also appleis to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1
212 */
York Sun1e9ea852012-05-07 07:26:45 +0000213 mfspr r3,SPRN_SVR
York Sun5e23ab02012-05-07 07:26:47 +0000214 rlwinm r6,r3,24,~0x800 /* clear E bit */
York Sun1e9ea852012-05-07 07:26:45 +0000215
York Sun5e23ab02012-05-07 07:26:47 +0000216 lis r5,SVR_P4080@h
217 ori r5,r5,SVR_P4080@l
218 cmpw r6,r5
219 bne 1f
220
221 rlwinm r3,r3,0,0xf0
222 li r5,0x30
223 cmpw r3,r5
224 bge 2f
2251:
York Sun57125f22012-08-08 18:04:53 +0000226#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011
227 lis r3,toreset(enable_cpu_a011_workaround)@ha
228 lwz r3,toreset(enable_cpu_a011_workaround)@l(r3)
229 cmpwi r3,0
230 beq 2f
231#endif
York Sun5e23ab02012-05-07 07:26:47 +0000232 mfspr r3,L1CSR2
233 oris r3,r3,(L1CSR2_DCWS)@h
234 mtspr L1CSR2,r3
York Sun1e9ea852012-05-07 07:26:45 +00002352:
Kumar Galafd3c9be2010-05-05 22:35:27 -0500236#endif
237
York Sund217a9a2013-06-25 11:37:49 -0700238#ifdef CONFIG_SYS_FSL_ERRATUM_A005812
239 /*
240 * A-005812 workaround sets bit 32 of SPR 976 for SoCs running in
241 * write shadow mode. This code should run after other code setting
242 * DCWS.
243 */
244 mfspr r3,L1CSR2
245 andis. r3,r3,(L1CSR2_DCWS)@h
246 beq 1f
247 mfspr r3, SPRN_HDBCR0
248 oris r3, r3, 0x8000
249 mtspr SPRN_HDBCR0, r3
2501:
251#endif
252
Kumar Gala1b3e4042009-03-19 09:16:10 -0500253#ifdef CONFIG_BACKSIDE_L2_CACHE
Kumar Galaacf3f8d2011-07-21 00:20:21 -0500254 /* skip L2 setup on P2040/P2040E as they have no L2 */
York Sunfeae3422012-05-07 07:39:53 +0000255 mfspr r3,SPRN_SVR
256 rlwinm r6,r3,24,~0x800 /* clear E bit of SVR */
257
Kumar Galaacf3f8d2011-07-21 00:20:21 -0500258 lis r3,SVR_P2040@h
259 ori r3,r3,SVR_P2040@l
York Sunfeae3422012-05-07 07:39:53 +0000260 cmpw r6,r3
Kumar Galaacf3f8d2011-07-21 00:20:21 -0500261 beq 3f
262
Kumar Gala1b3e4042009-03-19 09:16:10 -0500263 /* Enable/invalidate the L2 cache */
264 msync
Dave Liuff8822952009-10-31 07:59:55 +0800265 lis r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@h
266 ori r2,r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@l
267 mtspr SPRN_L2CSR0,r2
Kumar Gala1b3e4042009-03-19 09:16:10 -05002681:
269 mfspr r3,SPRN_L2CSR0
Dave Liuff8822952009-10-31 07:59:55 +0800270 and. r1,r3,r2
Kumar Gala1b3e4042009-03-19 09:16:10 -0500271 bne 1b
272
Kumar Gala82fd1f82009-03-19 02:53:01 -0500273#ifdef CONFIG_SYS_CACHE_STASHING
274 /* set stash id to (coreID) * 2 + 32 + L2 (1) */
275 addi r3,r8,1
276 mtspr SPRN_L2CSR1,r3
277#endif
278
Kumar Gala1b3e4042009-03-19 09:16:10 -0500279 lis r3,CONFIG_SYS_INIT_L2CSR0@h
280 ori r3,r3,CONFIG_SYS_INIT_L2CSR0@l
281 mtspr SPRN_L2CSR0,r3
282 isync
Dave Liuff8822952009-10-31 07:59:55 +08002832:
284 mfspr r3,SPRN_L2CSR0
285 andis. r1,r3,L2CSR0_L2E@h
286 beq 2b
Kumar Gala1b3e4042009-03-19 09:16:10 -0500287#endif
Kumar Galaacf3f8d2011-07-21 00:20:21 -05002883:
York Sunffd06e02012-10-08 07:44:30 +0000289 /* setup mapping for the spin table, WIMGE=0b00100 */
290 lis r13,toreset(__spin_table_addr)@h
291 ori r13,r13,toreset(__spin_table_addr)@l
292 lwz r13,0(r13)
293 /* mask by 4K */
294 rlwinm r13,r13,0,0,19
Kumar Gala1b3e4042009-03-19 09:16:10 -0500295
York Sunffd06e02012-10-08 07:44:30 +0000296 lis r11,(MAS0_TLBSEL(1)|MAS0_ESEL(1))@h
297 mtspr SPRN_MAS0,r11
298 lis r11,(MAS1_VALID|MAS1_IPROT)@h
299 ori r11,r11,(MAS1_TS|MAS1_TSIZE(BOOKE_PAGESZ_4K))@l
300 mtspr SPRN_MAS1,r11
301 oris r11,r13,(MAS2_M|MAS2_G)@h
302 ori r11,r13,(MAS2_M|MAS2_G)@l
303 mtspr SPRN_MAS2,r11
304 oris r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@h
305 ori r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@l
306 mtspr SPRN_MAS3,r11
307 li r11,0
308 mtspr SPRN_MAS7,r11
309 tlbwe
310
311 /*
312 * __bootpg_addr has the address of __second_half_boot_page
313 * jump there in AS=1 space with cache enabled
314 */
315 lis r13,toreset(__bootpg_addr)@h
316 ori r13,r13,toreset(__bootpg_addr)@l
317 lwz r11,0(r13)
318 mtspr SPRN_SRR0,r11
319 mfmsr r13
320 ori r12,r13,MSR_IS|MSR_DS@l
321 mtspr SPRN_SRR1,r12
322 rfi
323
324 /*
325 * Allocate some space for the SDRAM address of the bootpg.
326 * This variable has to be in the boot page so that it can
327 * be accessed by secondary cores when they come out of reset.
328 */
329 .align L1_CACHE_SHIFT
330 .globl __bootpg_addr
331__bootpg_addr:
332 .long 0
333
334 .global __spin_table_addr
335__spin_table_addr:
336 .long 0
337
338 /*
339 * This variable is set by cpu_init_r() after parsing hwconfig
340 * to enable workaround for erratum NMG_CPU_A011.
341 */
342 .align L1_CACHE_SHIFT
343 .global enable_cpu_a011_workaround
344enable_cpu_a011_workaround:
345 .long 1
346
347 /* Fill in the empty space. The actual reset vector is
348 * the last word of the page */
349__secondary_start_code_end:
350 .space 4092 - (__secondary_start_code_end - __secondary_start_page)
351__secondary_reset_vector:
352 b __secondary_start_page
353
354
355/* this is a separated page for the spin table and cacheable boot code */
356 .align L1_CACHE_SHIFT
357 .global __second_half_boot_page
358__second_half_boot_page:
York Sun2a5fcb82012-10-28 08:12:54 +0000359#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE
360 lis r3,(spin_table_compat - __second_half_boot_page)@h
361 ori r3,r3,(spin_table_compat - __second_half_boot_page)@l
362 add r3,r3,r11 /* r11 has the address of __second_half_boot_page */
363 lwz r14,0(r3)
364#endif
365
Kumar Gala79679d82008-03-26 08:34:25 -0500366#define ENTRY_ADDR_UPPER 0
367#define ENTRY_ADDR_LOWER 4
368#define ENTRY_R3_UPPER 8
369#define ENTRY_R3_LOWER 12
370#define ENTRY_RESV 16
371#define ENTRY_PIR 20
York Sunffd06e02012-10-08 07:44:30 +0000372#define ENTRY_SIZE 64
373 /*
374 * setup the entry
375 * r10 has the base address of the spin table.
376 * spin table is defined as
377 * struct {
378 * uint64_t entry_addr;
379 * uint64_t r3;
380 * uint32_t rsvd1;
381 * uint32_t pir;
382 * };
383 * we pad this struct to 64 bytes so each entry is in its own cacheline
384 */
Kumar Gala79679d82008-03-26 08:34:25 -0500385 li r3,0
Kumar Galaec2b74f2008-01-17 16:48:33 -0600386 li r8,1
York Sunffd06e02012-10-08 07:44:30 +0000387 mfspr r4,SPRN_PIR
Kumar Gala79679d82008-03-26 08:34:25 -0500388 stw r3,ENTRY_ADDR_UPPER(r10)
Kumar Gala79679d82008-03-26 08:34:25 -0500389 stw r3,ENTRY_R3_UPPER(r10)
390 stw r4,ENTRY_R3_LOWER(r10)
York Sunffd06e02012-10-08 07:44:30 +0000391 stw r3,ENTRY_RESV(r10)
392 stw r4,ENTRY_PIR(r10)
393 msync
394 stw r8,ENTRY_ADDR_LOWER(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600395
396 /* spin waiting for addr */
York Sun2a5fcb82012-10-28 08:12:54 +00003973:
398/*
399 * To comply with ePAPR 1.1, the spin table has been moved to cache-enabled
400 * memory. Old OS may not work with this change. A patch is waiting to be
401 * accepted for Linux kernel. Other OS needs similar fix to spin table.
402 * For OSes with old spin table code, we can enable this temporary fix by
403 * setting environmental variable "spin_table_compat". For new OSes, set
404 * "spin_table_compat=no". After Linux is fixed, we can remove this macro
405 * and related code. For now, it is enabled by default.
406 */
407#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE
408 cmpwi r14,0
409 beq 4f
410 dcbf 0, r10
411 sync
4124:
413#endif
414 lwz r4,ENTRY_ADDR_LOWER(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600415 andi. r11,r4,1
York Sunffd06e02012-10-08 07:44:30 +0000416 bne 3b
Kumar Galacf6cc012008-04-28 02:24:04 -0500417 isync
Kumar Gala79679d82008-03-26 08:34:25 -0500418
419 /* get the upper bits of the addr */
420 lwz r11,ENTRY_ADDR_UPPER(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600421
422 /* setup branch addr */
Kumar Gala79679d82008-03-26 08:34:25 -0500423 mtspr SPRN_SRR0,r4
Kumar Galaec2b74f2008-01-17 16:48:33 -0600424
425 /* mark the entry as released */
426 li r8,3
Kumar Gala79679d82008-03-26 08:34:25 -0500427 stw r8,ENTRY_ADDR_LOWER(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600428
429 /* mask by ~64M to setup our tlb we will jump to */
Kumar Gala79679d82008-03-26 08:34:25 -0500430 rlwinm r12,r4,0,0,5
Kumar Galaec2b74f2008-01-17 16:48:33 -0600431
York Sunffd06e02012-10-08 07:44:30 +0000432 /*
433 * setup r3, r4, r5, r6, r7, r8, r9
434 * r3 contains the value to put in the r3 register at secondary cpu
435 * entry. The high 32-bits are ignored on 32-bit chip implementations.
436 * 64-bit chip implementations however shall load all 64-bits
437 */
438#ifdef CONFIG_SYS_PPC64
439 ld r3,ENTRY_R3_UPPER(r10)
440#else
Kumar Gala79679d82008-03-26 08:34:25 -0500441 lwz r3,ENTRY_R3_LOWER(r10)
York Sunffd06e02012-10-08 07:44:30 +0000442#endif
Kumar Gala79679d82008-03-26 08:34:25 -0500443 li r4,0
Kumar Galaec2b74f2008-01-17 16:48:33 -0600444 li r5,0
York Sun3f0997b2012-10-08 07:44:29 +0000445 li r6,0
Kumar Gala79679d82008-03-26 08:34:25 -0500446 lis r7,(64*1024*1024)@h
447 li r8,0
448 li r9,0
Kumar Galaec2b74f2008-01-17 16:48:33 -0600449
450 /* load up the pir */
Kumar Gala79679d82008-03-26 08:34:25 -0500451 lwz r0,ENTRY_PIR(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600452 mtspr SPRN_PIR,r0
453 mfspr r0,SPRN_PIR
Kumar Gala79679d82008-03-26 08:34:25 -0500454 stw r0,ENTRY_PIR(r10)
Kumar Galaec2b74f2008-01-17 16:48:33 -0600455
Haiying Wang181a3652008-12-03 10:08:19 -0500456 mtspr IVPR,r12
Kumar Galaec2b74f2008-01-17 16:48:33 -0600457/*
458 * Coming here, we know the cpu has one TLB mapping in TLB1[0]
459 * which maps 0xfffff000-0xffffffff one-to-one. We set up a
460 * second mapping that maps addr 1:1 for 64M, and then we jump to
461 * addr
462 */
Kumar Gala79679d82008-03-26 08:34:25 -0500463 lis r10,(MAS0_TLBSEL(1)|MAS0_ESEL(0))@h
464 mtspr SPRN_MAS0,r10
465 lis r10,(MAS1_VALID|MAS1_IPROT)@h
466 ori r10,r10,(MAS1_TSIZE(BOOKE_PAGESZ_64M))@l
467 mtspr SPRN_MAS1,r10
Kumar Galaec2b74f2008-01-17 16:48:33 -0600468 /* WIMGE = 0b00000 for now */
Kumar Gala79679d82008-03-26 08:34:25 -0500469 mtspr SPRN_MAS2,r12
470 ori r12,r12,(MAS3_SX|MAS3_SW|MAS3_SR)
471 mtspr SPRN_MAS3,r12
472#ifdef CONFIG_ENABLE_36BIT_PHYS
473 mtspr SPRN_MAS7,r11
474#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -0600475 tlbwe
476
477/* Now we have another mapping for this page, so we jump to that
478 * mapping
479 */
Kumar Gala79679d82008-03-26 08:34:25 -0500480 mtspr SPRN_SRR1,r13
481 rfi
Kumar Galaec2b74f2008-01-17 16:48:33 -0600482
Peter Tyser5ccd29c2009-10-23 15:55:47 -0500483
York Sunffd06e02012-10-08 07:44:30 +0000484 .align 6
Kumar Galaec2b74f2008-01-17 16:48:33 -0600485 .globl __spin_table
486__spin_table:
Poonam Aggrwal0e870982009-07-31 12:08:14 +0530487 .space CONFIG_MAX_CPUS*ENTRY_SIZE
York Sun2a5fcb82012-10-28 08:12:54 +0000488
489#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE
490 .align L1_CACHE_SHIFT
491 .global spin_table_compat
492spin_table_compat:
493 .long 1
494
495#endif
496
York Sunffd06e02012-10-08 07:44:30 +0000497__spin_table_end:
498 .space 4096 - (__spin_table_end - __spin_table)