blob: 5d212f35b56c97506e37c3e2ee36c88aa173c554 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Poonam Aggrwal4baef822009-07-31 12:08:14 +05302/*
York Sun2adf2ce2012-08-17 08:20:26 +00003 * Copyright 2008-2012 Freescale Semiconductor, Inc.
Poonam Aggrwal4baef822009-07-31 12:08:14 +05304 * Kumar Gala <kumar.gala@freescale.com>
Poonam Aggrwal4baef822009-07-31 12:08:14 +05305 */
6
Wolfgang Denk0191e472010-10-26 14:34:52 +02007#include <asm-offsets.h>
Kumar Gala36d6b3f2008-01-17 16:48:33 -06008#include <config.h>
9#include <mpc85xx.h>
Kumar Gala36d6b3f2008-01-17 16:48:33 -060010
Kumar Gala36d6b3f2008-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:
29/* First do some preliminary setup */
30 lis r3, HID0_EMCP@h /* enable machine check */
Kumar Gala9f4a6892008-10-23 01:47:38 -050031#ifndef CONFIG_E500MC
Kumar Gala36d6b3f2008-01-17 16:48:33 -060032 ori r3,r3,HID0_TBEN@l /* enable Timebase */
Kumar Gala9f4a6892008-10-23 01:47:38 -050033#endif
Kumar Gala36d6b3f2008-01-17 16:48:33 -060034#ifdef CONFIG_PHYS_64BIT
35 ori r3,r3,HID0_ENMAS7@l /* enable MAS7 updates */
36#endif
37 mtspr SPRN_HID0,r3
38
Kumar Gala9f4a6892008-10-23 01:47:38 -050039#ifndef CONFIG_E500MC
Kumar Gala36d6b3f2008-01-17 16:48:33 -060040 li r3,(HID1_ASTME|HID1_ABE)@l /* Addr streaming & broadcast */
Sandeep Gopalpet8709aed2010-03-12 10:45:02 +053041 mfspr r0,PVR
42 andi. r0,r0,0xff
43 cmpwi r0,0x50@l /* if we are rev 5.0 or greater set MBDD */
44 blt 1f
45 /* Set MBDD bit also */
46 ori r3, r3, HID1_MBDD@l
471:
Kumar Gala36d6b3f2008-01-17 16:48:33 -060048 mtspr SPRN_HID1,r3
Kumar Gala9f4a6892008-10-23 01:47:38 -050049#endif
Kumar Gala36d6b3f2008-01-17 16:48:33 -060050
Kumar Gala945e59a2011-11-22 06:51:15 -060051#ifdef CONFIG_SYS_FSL_ERRATUM_CPU_A003999
Andy Flemingeab55c02013-03-25 07:33:10 +000052 mfspr r3,SPRN_HDBCR1
Kumar Gala945e59a2011-11-22 06:51:15 -060053 oris r3,r3,0x0100
Andy Flemingeab55c02013-03-25 07:33:10 +000054 mtspr SPRN_HDBCR1,r3
Kumar Gala945e59a2011-11-22 06:51:15 -060055#endif
56
Scott Wood80806962012-08-14 10:14:53 +000057#ifdef CONFIG_SYS_FSL_ERRATUM_A004510
58 mfspr r3,SPRN_SVR
59 rlwinm r3,r3,0,0xff
60 li r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV
61 cmpw r3,r4
62 beq 1f
63
64#ifdef CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2
65 li r4,CONFIG_SYS_FSL_ERRATUM_A004510_SVR_REV2
66 cmpw r3,r4
67 beq 1f
68#endif
69
70 /* Not a supported revision affected by erratum */
71 b 2f
72
731: /* Erratum says set bits 55:60 to 001001 */
74 msync
75 isync
Andy Flemingeab55c02013-03-25 07:33:10 +000076 mfspr r3,SPRN_HDBCR0
Scott Wood80806962012-08-14 10:14:53 +000077 li r4,0x48
78 rlwimi r3,r4,0,0x1f8
Andy Flemingeab55c02013-03-25 07:33:10 +000079 mtspr SPRN_HDBCR0,r3
Scott Wood80806962012-08-14 10:14:53 +000080 isync
812:
82#endif
83
Kumar Gala36d6b3f2008-01-17 16:48:33 -060084 /* Enable branch prediction */
Kumar Gala5530cb82010-03-29 13:50:31 -050085 lis r3,BUCSR_ENABLE@h
86 ori r3,r3,BUCSR_ENABLE@l
Kumar Gala36d6b3f2008-01-17 16:48:33 -060087 mtspr SPRN_BUCSR,r3
88
Kumar Galab937cc52008-09-08 08:51:29 -050089 /* Ensure TB is 0 */
90 li r3,0
91 mttbl r3
92 mttbu r3
93
Kumar Gala36d6b3f2008-01-17 16:48:33 -060094 /* Enable/invalidate the I-Cache */
Kumar Gala48bd5f02010-03-26 15:14:43 -050095 lis r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@h
96 ori r2,r2,(L1CSR1_ICFI|L1CSR1_ICLFR)@l
97 mtspr SPRN_L1CSR1,r2
981:
99 mfspr r3,SPRN_L1CSR1
100 and. r1,r3,r2
101 bne 1b
102
103 lis r3,(L1CSR1_CPE|L1CSR1_ICE)@h
104 ori r3,r3,(L1CSR1_CPE|L1CSR1_ICE)@l
105 mtspr SPRN_L1CSR1,r3
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600106 isync
Kumar Gala48bd5f02010-03-26 15:14:43 -05001072:
108 mfspr r3,SPRN_L1CSR1
109 andi. r1,r3,L1CSR1_ICE@l
110 beq 2b
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600111
112 /* Enable/invalidate the D-Cache */
Kumar Gala48bd5f02010-03-26 15:14:43 -0500113 lis r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@h
114 ori r2,r2,(L1CSR0_DCFI|L1CSR0_DCLFR)@l
115 mtspr SPRN_L1CSR0,r2
1161:
117 mfspr r3,SPRN_L1CSR0
118 and. r1,r3,r2
119 bne 1b
120
121 lis r3,(L1CSR0_CPE|L1CSR0_DCE)@h
122 ori r3,r3,(L1CSR0_CPE|L1CSR0_DCE)@l
123 mtspr SPRN_L1CSR0,r3
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600124 isync
Kumar Gala48bd5f02010-03-26 15:14:43 -05001252:
126 mfspr r3,SPRN_L1CSR0
127 andi. r1,r3,L1CSR0_DCE@l
128 beq 2b
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600129
130#define toreset(x) (x - __secondary_start_page + 0xfffff000)
131
132 /* get our PIR to figure out our table entry */
York Sun2394a0f2012-10-08 07:44:30 +0000133 lis r3,toreset(__spin_table_addr)@h
134 ori r3,r3,toreset(__spin_table_addr)@l
135 lwz r3,0(r3)
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600136
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600137 mfspr r0,SPRN_PIR
York Sun14c30492013-03-25 07:33:27 +0000138#ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
York Sun2adf2ce2012-08-17 08:20:26 +0000139/*
York Sun14c30492013-03-25 07:33:27 +0000140 * PIR definition for Chassis 2
York Sun2adf2ce2012-08-17 08:20:26 +0000141 * 0-17 Reserved (logic 0s)
York Sunaa150bb2013-03-25 07:40:07 +0000142 * 18-19 CHIP_ID, 2'b00 - SoC 1
York Sun2adf2ce2012-08-17 08:20:26 +0000143 * all others - reserved
Timur Tabie6c28192012-10-05 09:48:50 +0000144 * 20-24 CLUSTER_ID 5'b00000 - CCM 1
York Sun2adf2ce2012-08-17 08:20:26 +0000145 * all others - reserved
Timur Tabie6c28192012-10-05 09:48:50 +0000146 * 25-26 CORE_CLUSTER_ID 2'b00 - cluster 1
147 * 2'b01 - cluster 2
148 * 2'b10 - cluster 3
149 * 2'b11 - cluster 4
150 * 27-28 CORE_ID 2'b00 - core 0
151 * 2'b01 - core 1
152 * 2'b10 - core 2
153 * 2'b11 - core 3
154 * 29-31 THREAD_ID 3'b000 - thread 0
155 * 3'b001 - thread 1
York Sunaa150bb2013-03-25 07:40:07 +0000156 *
157 * Power-on PIR increments threads by 0x01, cores within a cluster by 0x08
158 * and clusters by 0x20.
159 *
160 * We renumber PIR so that all threads in the system are consecutive.
York Sun2adf2ce2012-08-17 08:20:26 +0000161 */
York Sunaa150bb2013-03-25 07:40:07 +0000162
163 rlwinm r8,r0,29,0x03 /* r8 = core within cluster */
164 srwi r10,r0,5 /* r10 = cluster */
165
166 mulli r5,r10,CONFIG_SYS_FSL_CORES_PER_CLUSTER
167 add r5,r5,r8 /* for spin table index */
168 mulli r4,r5,CONFIG_SYS_FSL_THREADS_PER_CORE /* for PIR */
York Sun2adf2ce2012-08-17 08:20:26 +0000169#elif defined(CONFIG_E500MC)
Kumar Gala9f4a6892008-10-23 01:47:38 -0500170 rlwinm r4,r0,27,27,31
York Sunaa150bb2013-03-25 07:40:07 +0000171 mr r5,r4
Kumar Gala9f4a6892008-10-23 01:47:38 -0500172#else
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600173 mr r4,r0
York Sunaa150bb2013-03-25 07:40:07 +0000174 mr r5,r4
Kumar Gala9f4a6892008-10-23 01:47:38 -0500175#endif
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600176
York Sun2adf2ce2012-08-17 08:20:26 +0000177 /*
York Sunaa150bb2013-03-25 07:40:07 +0000178 * r10 has the base address for the entry.
179 * we cannot access it yet before setting up a new TLB
York Sun2adf2ce2012-08-17 08:20:26 +0000180 */
York Sunaa150bb2013-03-25 07:40:07 +0000181 slwi r8,r5,6 /* spin table is padded to 64 byte */
182 add r10,r3,r8
York Sun2adf2ce2012-08-17 08:20:26 +0000183
184 mtspr SPRN_PIR,r4 /* write to PIR register */
185
York Sun548b8ba2017-10-17 08:00:21 -0700186#ifdef CONFIG_SYS_FSL_ERRATUM_A007907
187 mfspr r8, L1CSR2
188 clrrwi r8, r8, 10 /* clear bit [54-63] DCSTASHID */
189 mtspr L1CSR2, r8
190#else
York Sunc3d87b12012-10-08 07:44:08 +0000191#ifdef CONFIG_SYS_CACHE_STASHING
192 /* set stash id to (coreID) * 2 + 32 + L1 CT (0) */
193 slwi r8,r4,1
194 addi r8,r8,32
195 mtspr L1CSR2,r8
196#endif
York Sun548b8ba2017-10-17 08:00:21 -0700197#endif /* CONFIG_SYS_FSL_ERRATUM_A007907 */
York Sunc3d87b12012-10-08 07:44:08 +0000198
York Sun9ed88112012-05-07 07:26:47 +0000199#if defined(CONFIG_SYS_P4080_ERRATUM_CPU22) || \
200 defined(CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011)
201 /*
202 * CPU22 applies to P4080 rev 1.0, 2.0, fixed in 3.0
203 * NMG_CPU_A011 applies to P4080 rev 1.0, 2.0, fixed in 3.0
204 * also appleis to P3041 rev 1.0, 1.1, P2041 rev 1.0, 1.1
205 */
York Sund755c832012-05-07 07:26:45 +0000206 mfspr r3,SPRN_SVR
York Sun9ed88112012-05-07 07:26:47 +0000207 rlwinm r6,r3,24,~0x800 /* clear E bit */
208
209 lis r5,SVR_P4080@h
210 ori r5,r5,SVR_P4080@l
211 cmpw r6,r5
212 bne 1f
213
York Sund755c832012-05-07 07:26:45 +0000214 rlwinm r3,r3,0,0xf0
York Sun9ed88112012-05-07 07:26:47 +0000215 li r5,0x30
216 cmpw r3,r5
York Sund755c832012-05-07 07:26:45 +0000217 bge 2f
York Sun9ed88112012-05-07 07:26:47 +00002181:
York Sun53155532012-08-08 18:04:53 +0000219#ifdef CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011
220 lis r3,toreset(enable_cpu_a011_workaround)@ha
221 lwz r3,toreset(enable_cpu_a011_workaround)@l(r3)
222 cmpwi r3,0
223 beq 2f
224#endif
York Sun9ed88112012-05-07 07:26:47 +0000225 mfspr r3,L1CSR2
226 oris r3,r3,(L1CSR2_DCWS)@h
227 mtspr L1CSR2,r3
York Sund755c832012-05-07 07:26:45 +00002282:
Kumar Gala6b245b92010-05-05 22:35:27 -0500229#endif
230
York Suncca41c52013-06-25 11:37:49 -0700231#ifdef CONFIG_SYS_FSL_ERRATUM_A005812
232 /*
233 * A-005812 workaround sets bit 32 of SPR 976 for SoCs running in
234 * write shadow mode. This code should run after other code setting
235 * DCWS.
236 */
237 mfspr r3,L1CSR2
238 andis. r3,r3,(L1CSR2_DCWS)@h
239 beq 1f
240 mfspr r3, SPRN_HDBCR0
241 oris r3, r3, 0x8000
242 mtspr SPRN_HDBCR0, r3
2431:
244#endif
245
Kumar Galae56f2c52009-03-19 09:16:10 -0500246#ifdef CONFIG_BACKSIDE_L2_CACHE
Kumar Galae08c6d82011-07-21 00:20:21 -0500247 /* skip L2 setup on P2040/P2040E as they have no L2 */
York Sun8d131c42012-05-07 07:39:53 +0000248 mfspr r3,SPRN_SVR
249 rlwinm r6,r3,24,~0x800 /* clear E bit of SVR */
250
Kumar Galae08c6d82011-07-21 00:20:21 -0500251 lis r3,SVR_P2040@h
252 ori r3,r3,SVR_P2040@l
York Sun8d131c42012-05-07 07:39:53 +0000253 cmpw r6,r3
Kumar Galae08c6d82011-07-21 00:20:21 -0500254 beq 3f
255
Kumar Galae56f2c52009-03-19 09:16:10 -0500256 /* Enable/invalidate the L2 cache */
257 msync
Dave Liub8bb4112009-10-31 07:59:55 +0800258 lis r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@h
259 ori r2,r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@l
260 mtspr SPRN_L2CSR0,r2
Kumar Galae56f2c52009-03-19 09:16:10 -05002611:
262 mfspr r3,SPRN_L2CSR0
Dave Liub8bb4112009-10-31 07:59:55 +0800263 and. r1,r3,r2
Kumar Galae56f2c52009-03-19 09:16:10 -0500264 bne 1b
265
Kumar Gala8d2817c2009-03-19 02:53:01 -0500266#ifdef CONFIG_SYS_CACHE_STASHING
267 /* set stash id to (coreID) * 2 + 32 + L2 (1) */
268 addi r3,r8,1
269 mtspr SPRN_L2CSR1,r3
270#endif
271
Kumar Galae56f2c52009-03-19 09:16:10 -0500272 lis r3,CONFIG_SYS_INIT_L2CSR0@h
273 ori r3,r3,CONFIG_SYS_INIT_L2CSR0@l
274 mtspr SPRN_L2CSR0,r3
275 isync
Dave Liub8bb4112009-10-31 07:59:55 +08002762:
277 mfspr r3,SPRN_L2CSR0
278 andis. r1,r3,L2CSR0_L2E@h
279 beq 2b
Kumar Galae56f2c52009-03-19 09:16:10 -0500280#endif
Kumar Galae08c6d82011-07-21 00:20:21 -05002813:
York Sun2394a0f2012-10-08 07:44:30 +0000282 /* setup mapping for the spin table, WIMGE=0b00100 */
283 lis r13,toreset(__spin_table_addr)@h
284 ori r13,r13,toreset(__spin_table_addr)@l
Peter Tyser7feaacb2009-10-23 15:55:47 -0500285 lwz r13,0(r13)
York Sun2394a0f2012-10-08 07:44:30 +0000286 /* mask by 4K */
287 rlwinm r13,r13,0,0,19
Peter Tyser7feaacb2009-10-23 15:55:47 -0500288
Kumar Galadeeac572008-03-26 08:34:25 -0500289 lis r11,(MAS0_TLBSEL(1)|MAS0_ESEL(1))@h
290 mtspr SPRN_MAS0,r11
291 lis r11,(MAS1_VALID|MAS1_IPROT)@h
292 ori r11,r11,(MAS1_TS|MAS1_TSIZE(BOOKE_PAGESZ_4K))@l
293 mtspr SPRN_MAS1,r11
York Sun2394a0f2012-10-08 07:44:30 +0000294 oris r11,r13,(MAS2_M|MAS2_G)@h
295 ori r11,r13,(MAS2_M|MAS2_G)@l
Kumar Galadeeac572008-03-26 08:34:25 -0500296 mtspr SPRN_MAS2,r11
Peter Tyser7feaacb2009-10-23 15:55:47 -0500297 oris r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@h
298 ori r11,r13,(MAS3_SX|MAS3_SW|MAS3_SR)@l
Kumar Galadeeac572008-03-26 08:34:25 -0500299 mtspr SPRN_MAS3,r11
York Sun2394a0f2012-10-08 07:44:30 +0000300 li r11,0
301 mtspr SPRN_MAS7,r11
Kumar Galadeeac572008-03-26 08:34:25 -0500302 tlbwe
303
Peter Tyser7feaacb2009-10-23 15:55:47 -0500304 /*
York Sun2394a0f2012-10-08 07:44:30 +0000305 * __bootpg_addr has the address of __second_half_boot_page
306 * jump there in AS=1 space with cache enabled
Peter Tyser7feaacb2009-10-23 15:55:47 -0500307 */
York Sun2394a0f2012-10-08 07:44:30 +0000308 lis r13,toreset(__bootpg_addr)@h
309 ori r13,r13,toreset(__bootpg_addr)@l
310 lwz r11,0(r13)
311 mtspr SPRN_SRR0,r11
Kumar Galadeeac572008-03-26 08:34:25 -0500312 mfmsr r13
313 ori r12,r13,MSR_IS|MSR_DS@l
Kumar Galadeeac572008-03-26 08:34:25 -0500314 mtspr SPRN_SRR1,r12
315 rfi
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600316
York Sun2394a0f2012-10-08 07:44:30 +0000317 /*
318 * Allocate some space for the SDRAM address of the bootpg.
319 * This variable has to be in the boot page so that it can
320 * be accessed by secondary cores when they come out of reset.
321 */
322 .align L1_CACHE_SHIFT
323 .globl __bootpg_addr
324__bootpg_addr:
325 .long 0
326
327 .global __spin_table_addr
328__spin_table_addr:
329 .long 0
330
331 /*
332 * This variable is set by cpu_init_r() after parsing hwconfig
333 * to enable workaround for erratum NMG_CPU_A011.
334 */
335 .align L1_CACHE_SHIFT
336 .global enable_cpu_a011_workaround
337enable_cpu_a011_workaround:
338 .long 1
339
340 /* Fill in the empty space. The actual reset vector is
341 * the last word of the page */
342__secondary_start_code_end:
343 .space 4092 - (__secondary_start_code_end - __secondary_start_page)
344__secondary_reset_vector:
345 b __secondary_start_page
346
347
348/* this is a separated page for the spin table and cacheable boot code */
349 .align L1_CACHE_SHIFT
350 .global __second_half_boot_page
351__second_half_boot_page:
York Sunf066a042012-10-28 08:12:54 +0000352#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE
353 lis r3,(spin_table_compat - __second_half_boot_page)@h
354 ori r3,r3,(spin_table_compat - __second_half_boot_page)@l
355 add r3,r3,r11 /* r11 has the address of __second_half_boot_page */
356 lwz r14,0(r3)
357#endif
358
York Sun2394a0f2012-10-08 07:44:30 +0000359#define ENTRY_ADDR_UPPER 0
360#define ENTRY_ADDR_LOWER 4
361#define ENTRY_R3_UPPER 8
362#define ENTRY_R3_LOWER 12
363#define ENTRY_RESV 16
364#define ENTRY_PIR 20
365#define ENTRY_SIZE 64
366 /*
367 * setup the entry
368 * r10 has the base address of the spin table.
369 * spin table is defined as
370 * struct {
371 * uint64_t entry_addr;
372 * uint64_t r3;
373 * uint32_t rsvd1;
374 * uint32_t pir;
375 * };
376 * we pad this struct to 64 bytes so each entry is in its own cacheline
377 */
378 li r3,0
379 li r8,1
380 mfspr r4,SPRN_PIR
381 stw r3,ENTRY_ADDR_UPPER(r10)
382 stw r3,ENTRY_R3_UPPER(r10)
383 stw r4,ENTRY_R3_LOWER(r10)
384 stw r3,ENTRY_RESV(r10)
385 stw r4,ENTRY_PIR(r10)
386 msync
387 stw r8,ENTRY_ADDR_LOWER(r10)
388
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600389 /* spin waiting for addr */
York Sunf066a042012-10-28 08:12:54 +00003903:
391/*
392 * To comply with ePAPR 1.1, the spin table has been moved to cache-enabled
393 * memory. Old OS may not work with this change. A patch is waiting to be
394 * accepted for Linux kernel. Other OS needs similar fix to spin table.
395 * For OSes with old spin table code, we can enable this temporary fix by
396 * setting environmental variable "spin_table_compat". For new OSes, set
397 * "spin_table_compat=no". After Linux is fixed, we can remove this macro
398 * and related code. For now, it is enabled by default.
399 */
400#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE
401 cmpwi r14,0
402 beq 4f
403 dcbf 0, r10
404 sync
4054:
406#endif
407 lwz r4,ENTRY_ADDR_LOWER(r10)
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600408 andi. r11,r4,1
York Sun2394a0f2012-10-08 07:44:30 +0000409 bne 3b
Kumar Gala398dcd62008-04-28 02:24:04 -0500410 isync
Kumar Galadeeac572008-03-26 08:34:25 -0500411
412 /* get the upper bits of the addr */
413 lwz r11,ENTRY_ADDR_UPPER(r10)
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600414
415 /* setup branch addr */
Kumar Galadeeac572008-03-26 08:34:25 -0500416 mtspr SPRN_SRR0,r4
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600417
418 /* mark the entry as released */
419 li r8,3
Kumar Galadeeac572008-03-26 08:34:25 -0500420 stw r8,ENTRY_ADDR_LOWER(r10)
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600421
422 /* mask by ~64M to setup our tlb we will jump to */
Kumar Galadeeac572008-03-26 08:34:25 -0500423 rlwinm r12,r4,0,0,5
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600424
York Sun2394a0f2012-10-08 07:44:30 +0000425 /*
426 * setup r3, r4, r5, r6, r7, r8, r9
427 * r3 contains the value to put in the r3 register at secondary cpu
428 * entry. The high 32-bits are ignored on 32-bit chip implementations.
429 * 64-bit chip implementations however shall load all 64-bits
430 */
431#ifdef CONFIG_SYS_PPC64
432 ld r3,ENTRY_R3_UPPER(r10)
433#else
Kumar Galadeeac572008-03-26 08:34:25 -0500434 lwz r3,ENTRY_R3_LOWER(r10)
York Sun2394a0f2012-10-08 07:44:30 +0000435#endif
Kumar Galadeeac572008-03-26 08:34:25 -0500436 li r4,0
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600437 li r5,0
York Sun31a0c8c2012-10-08 07:44:29 +0000438 li r6,0
Kumar Galadeeac572008-03-26 08:34:25 -0500439 lis r7,(64*1024*1024)@h
440 li r8,0
441 li r9,0
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600442
443 /* load up the pir */
Kumar Galadeeac572008-03-26 08:34:25 -0500444 lwz r0,ENTRY_PIR(r10)
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600445 mtspr SPRN_PIR,r0
446 mfspr r0,SPRN_PIR
Kumar Galadeeac572008-03-26 08:34:25 -0500447 stw r0,ENTRY_PIR(r10)
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600448
Haiying Wangf4745512008-12-03 10:08:19 -0500449 mtspr IVPR,r12
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600450/*
451 * Coming here, we know the cpu has one TLB mapping in TLB1[0]
452 * which maps 0xfffff000-0xffffffff one-to-one. We set up a
453 * second mapping that maps addr 1:1 for 64M, and then we jump to
454 * addr
455 */
Kumar Galadeeac572008-03-26 08:34:25 -0500456 lis r10,(MAS0_TLBSEL(1)|MAS0_ESEL(0))@h
457 mtspr SPRN_MAS0,r10
458 lis r10,(MAS1_VALID|MAS1_IPROT)@h
459 ori r10,r10,(MAS1_TSIZE(BOOKE_PAGESZ_64M))@l
460 mtspr SPRN_MAS1,r10
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600461 /* WIMGE = 0b00000 for now */
Kumar Galadeeac572008-03-26 08:34:25 -0500462 mtspr SPRN_MAS2,r12
463 ori r12,r12,(MAS3_SX|MAS3_SW|MAS3_SR)
464 mtspr SPRN_MAS3,r12
465#ifdef CONFIG_ENABLE_36BIT_PHYS
466 mtspr SPRN_MAS7,r11
467#endif
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600468 tlbwe
469
470/* Now we have another mapping for this page, so we jump to that
471 * mapping
472 */
Kumar Galadeeac572008-03-26 08:34:25 -0500473 mtspr SPRN_SRR1,r13
474 rfi
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600475
Peter Tyser7feaacb2009-10-23 15:55:47 -0500476
York Sun2394a0f2012-10-08 07:44:30 +0000477 .align 6
Kumar Gala36d6b3f2008-01-17 16:48:33 -0600478 .globl __spin_table
479__spin_table:
Poonam Aggrwal4baef822009-07-31 12:08:14 +0530480 .space CONFIG_MAX_CPUS*ENTRY_SIZE
York Sunf066a042012-10-28 08:12:54 +0000481
482#ifdef CONFIG_PPC_SPINTABLE_COMPATIBLE
483 .align L1_CACHE_SHIFT
484 .global spin_table_compat
485spin_table_compat:
486 .long 1
487
488#endif
489
York Sun2394a0f2012-10-08 07:44:30 +0000490__spin_table_end:
491 .space 4096 - (__spin_table_end - __spin_table)