1
2
3
4
5
6
7
8#include <asm-offsets.h>
9#include <config.h>
10#include <mpc85xx.h>
11
12#include <ppc_asm.tmpl>
13#include <ppc_defs.h>
14
15#include <asm/cache.h>
16#include <asm/mmu.h>
17
18
19
20
21
22
23
24
25
26
27 .globl __secondary_start_page
28 .align 12
29__secondary_start_page:
30
31 lis r3, HID0_EMCP@h
32#ifndef CONFIG_E500MC
33 ori r3,r3,HID0_TBEN@l
34#endif
35#ifdef CONFIG_PHYS_64BIT
36 ori r3,r3,HID0_ENMAS7@l
37#endif
38 mtspr SPRN_HID0,r3
39
40#ifndef CONFIG_E500MC
41 li r3,(HID1_ASTME|HID1_ABE)@l
42 mfspr r0,PVR
43 andi. r0,r0,0xff
44 cmpwi r0,0x50@l
45 blt 1f
46
47 ori r3, r3, HID1_MBDD@l
481:
49 mtspr SPRN_HID1,r3
50#endif
51
52#ifdef CONFIG_SYS_FSL_ERRATUM_CPU_A003999
53 mfspr r3,SPRN_HDBCR1
54 oris r3,r3,0x0100
55 mtspr SPRN_HDBCR1,r3
56#endif
57
58#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
72 b 2f
73
741:
75 msync
76 isync
77 mfspr r3,SPRN_HDBCR0
78 li r4,0x48
79 rlwimi r3,r4,0,0x1f8
80 mtspr SPRN_HDBCR0,r3
81 isync
822:
83#endif
84
85
86 lis r3,BUCSR_ENABLE@h
87 ori r3,r3,BUCSR_ENABLE@l
88 mtspr SPRN_BUCSR,r3
89
90
91 li r3,0
92 mttbl r3
93 mttbu r3
94
95
96 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
107 isync
1082:
109 mfspr r3,SPRN_L1CSR1
110 andi. r1,r3,L1CSR1_ICE@l
111 beq 2b
112
113
114 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
125 isync
1262:
127 mfspr r3,SPRN_L1CSR0
128 andi. r1,r3,L1CSR0_DCE@l
129 beq 2b
130
131#define toreset(x) (x - __secondary_start_page + 0xfffff000)
132
133
134 lis r3,toreset(__spin_table_addr)@h
135 ori r3,r3,toreset(__spin_table_addr)@l
136 lwz r3,0(r3)
137
138 mfspr r0,SPRN_PIR
139#ifdef CONFIG_SYS_FSL_QORIQ_CHASSIS2
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164 rlwinm r8,r0,29,0x03
165 srwi r10,r0,5
166
167 mulli r5,r10,CONFIG_SYS_FSL_CORES_PER_CLUSTER
168 add r5,r5,r8
169 mulli r4,r5,CONFIG_SYS_FSL_THREADS_PER_CORE
170
171 rlwinm r4,r0,27,27,31
172 mr r5,r4
173#else
174 mr r4,r0
175 mr r5,r4
176#endif
177
178
179
180
181
182 slwi r8,r5,6
183 add r10,r3,r8
184
185 mtspr SPRN_PIR,r4
186
187#ifdef CONFIG_SYS_CACHE_STASHING
188
189 slwi r8,r4,1
190 addi r8,r8,32
191 mtspr L1CSR2,r8
192#endif
193
194
195 defined(CONFIG_SYS_FSL_ERRATUM_NMG_CPU_A011)
196
197
198
199
200
201 mfspr r3,SPRN_SVR
202 rlwinm r6,r3,24,~0x800
203
204 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:
214#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
220 mfspr r3,L1CSR2
221 oris r3,r3,(L1CSR2_DCWS)@h
222 mtspr L1CSR2,r3
2232:
224#endif
225
226#ifdef CONFIG_SYS_FSL_ERRATUM_A005812
227
228
229
230
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
241#ifdef CONFIG_BACKSIDE_L2_CACHE
242
243 mfspr r3,SPRN_SVR
244 rlwinm r6,r3,24,~0x800
245
246 lis r3,SVR_P2040@h
247 ori r3,r3,SVR_P2040@l
248 cmpw r6,r3
249 beq 3f
250
251
252 msync
253 lis r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@h
254 ori r2,r2,(L2CSR0_L2FI|L2CSR0_L2LFC)@l
255 mtspr SPRN_L2CSR0,r2
2561:
257 mfspr r3,SPRN_L2CSR0
258 and. r1,r3,r2
259 bne 1b
260
261#ifdef CONFIG_SYS_CACHE_STASHING
262
263 addi r3,r8,1
264 mtspr SPRN_L2CSR1,r3
265#endif
266
267 lis r3,CONFIG_SYS_INIT_L2CSR0@h
268 ori r3,r3,CONFIG_SYS_INIT_L2CSR0@l
269 mtspr SPRN_L2CSR0,r3
270 isync
2712:
272 mfspr r3,SPRN_L2CSR0
273 andis. r1,r3,L2CSR0_L2E@h
274 beq 2b
275#endif
2763:
277
278 lis r13,toreset(__spin_table_addr)@h
279 ori r13,r13,toreset(__spin_table_addr)@l
280 lwz r13,0(r13)
281
282 rlwinm r13,r13,0,0,19
283
284 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
301
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
314
315
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
328
329
330 .align L1_CACHE_SHIFT
331 .global enable_cpu_a011_workaround
332enable_cpu_a011_workaround:
333 .long 1
334
335
336
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
344 .align L1_CACHE_SHIFT
345 .global __second_half_boot_page
346__second_half_boot_page:
347#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
351 lwz r14,0(r3)
352#endif
353
354#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
360#define ENTRY_SIZE 64
361
362
363
364
365
366
367
368
369
370
371
372
373 li r3,0
374 li r8,1
375 mfspr r4,SPRN_PIR
376 stw r3,ENTRY_ADDR_UPPER(r10)
377 stw r3,ENTRY_R3_UPPER(r10)
378 stw r4,ENTRY_R3_LOWER(r10)
379 stw r3,ENTRY_RESV(r10)
380 stw r4,ENTRY_PIR(r10)
381 msync
382 stw r8,ENTRY_ADDR_LOWER(r10)
383
384
3853:
386
387
388
389
390
391
392
393
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)
403 andi. r11,r4,1
404 bne 3b
405 isync
406
407
408 lwz r11,ENTRY_ADDR_UPPER(r10)
409
410
411 mtspr SPRN_SRR0,r4
412
413
414 li r8,3
415 stw r8,ENTRY_ADDR_LOWER(r10)
416
417
418 rlwinm r12,r4,0,0,5
419
420
421
422
423
424
425
426#ifdef CONFIG_SYS_PPC64
427 ld r3,ENTRY_R3_UPPER(r10)
428#else
429 lwz r3,ENTRY_R3_LOWER(r10)
430#endif
431 li r4,0
432 li r5,0
433 li r6,0
434 lis r7,(64*1024*1024)@h
435 li r8,0
436 li r9,0
437
438
439 lwz r0,ENTRY_PIR(r10)
440 mtspr SPRN_PIR,r0
441 mfspr r0,SPRN_PIR
442 stw r0,ENTRY_PIR(r10)
443
444 mtspr IVPR,r12
445
446
447
448
449
450
451 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
456
457 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
463 tlbwe
464
465
466
467
468 mtspr SPRN_SRR1,r13
469 rfi
470
471
472 .align 6
473 .globl __spin_table
474__spin_table:
475 .space CONFIG_MAX_CPUS*ENTRY_SIZE
476
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
485__spin_table_end:
486 .space 4096 - (__spin_table_end - __spin_table)
487