1
2
3
4
5
6
7 #include <asm/processor.h>
8 #include <asm/page.h>
9 #include <asm/cputable.h>
10 #include <asm/ppc_asm.h>
11 #include <asm/asm-offsets.h>
12 #include <asm/cache.h>
13 #include <asm/mmu.h>
14 #include <asm/feature-fixups.h>
15
16 _GLOBAL(__setup_cpu_603)
17 mflr r5
18 BEGIN_MMU_FTR_SECTION
19 li r10,0
20 mtspr SPRN_SPRG_603_LRU,r10
21 END_MMU_FTR_SECTION_IFSET(MMU_FTR_NEED_DTLB_SW_LRU)
22
23 BEGIN_FTR_SECTION
24 bl __init_fpu_registers
25 END_FTR_SECTION_IFCLR(CPU_FTR_FPU_UNAVAILABLE)
26 bl setup_common_caches
27 mtlr r5
28 blr
29 _GLOBAL(__setup_cpu_604)
30 mflr r5
31 bl setup_common_caches
32 bl setup_604_hid0
33 mtlr r5
34 blr
35 _GLOBAL(__setup_cpu_750)
36 mflr r5
37 bl __init_fpu_registers
38 bl setup_common_caches
39 bl setup_750_7400_hid0
40 mtlr r5
41 blr
42 _GLOBAL(__setup_cpu_750cx)
43 mflr r5
44 bl __init_fpu_registers
45 bl setup_common_caches
46 bl setup_750_7400_hid0
47 bl setup_750cx
48 mtlr r5
49 blr
50 _GLOBAL(__setup_cpu_750fx)
51 mflr r5
52 bl __init_fpu_registers
53 bl setup_common_caches
54 bl setup_750_7400_hid0
55 bl setup_750fx
56 mtlr r5
57 blr
58 _GLOBAL(__setup_cpu_7400)
59 mflr r5
60 bl __init_fpu_registers
61 bl setup_7400_workarounds
62 bl setup_common_caches
63 bl setup_750_7400_hid0
64 mtlr r5
65 blr
66 _GLOBAL(__setup_cpu_7410)
67 mflr r5
68 bl __init_fpu_registers
69 bl setup_7410_workarounds
70 bl setup_common_caches
71 bl setup_750_7400_hid0
72 li r3,0
73 mtspr SPRN_L2CR2,r3
74 mtlr r5
75 blr
76 _GLOBAL(__setup_cpu_745x)
77 mflr r5
78 bl setup_common_caches
79 bl setup_745x_specifics
80 mtlr r5
81 blr
82
83
84 setup_common_caches:
85 mfspr r11,SPRN_HID0
86 andi. r0,r11,HID0_DCE
87 ori r11,r11,HID0_ICE|HID0_DCE
88 ori r8,r11,HID0_ICFI
89 bne 1f
90 ori r8,r8,HID0_DCI
91 1: sync
92 mtspr SPRN_HID0,r8
93 sync
94 mtspr SPRN_HID0,r11
95 sync
96 isync
97 blr
98
99
100
101
102 setup_604_hid0:
103 mfspr r11,SPRN_HID0
104 ori r11,r11,HID0_SIED|HID0_BHTE
105 ori r8,r11,HID0_BTCD
106 sync
107 mtspr SPRN_HID0,r8
108 sync
109 mtspr SPRN_HID0,r11
110 sync
111 isync
112 blr
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128 setup_7400_workarounds:
129 mfpvr r3
130 rlwinm r3,r3,0,20,31
131 cmpwi 0,r3,0x0207
132 ble 1f
133 blr
134 setup_7410_workarounds:
135 mfpvr r3
136 rlwinm r3,r3,0,20,31
137 cmpwi 0,r3,0x0100
138 bnelr
139 1:
140 mfspr r11,SPRN_MSSSR0
141
142 rlwinm r11,r11,0,9,6
143 oris r11,r11,0x0100
144
145 oris r11,r11,0x0002
146
147 rlwinm r11,r11,0,5,2
148 oris r11,r11,0x0800
149 sync
150 mtspr SPRN_MSSSR0,r11
151 sync
152 isync
153 blr
154
155
156
157
158
159
160
161 setup_750_7400_hid0:
162 mfspr r11,SPRN_HID0
163 ori r11,r11,HID0_SGE | HID0_ABE | HID0_BHTE | HID0_BTIC
164 oris r11,r11,HID0_DPM@h
165 BEGIN_FTR_SECTION
166 xori r11,r11,HID0_BTIC
167 END_FTR_SECTION_IFSET(CPU_FTR_NO_BTIC)
168 BEGIN_FTR_SECTION
169 xoris r11,r11,HID0_DPM@h
170 END_FTR_SECTION_IFSET(CPU_FTR_NO_DPM)
171 li r3,HID0_SPD
172 andc r11,r11,r3
173 li r3,0
174 mtspr SPRN_ICTC,r3
175 isync
176 mtspr SPRN_HID0,r11
177 sync
178 isync
179 blr
180
181
182
183
184
185 setup_750cx:
186 mfspr r10, SPRN_HID1
187 rlwinm r10,r10,4,28,31
188 cmpwi cr0,r10,7
189 cmpwi cr1,r10,9
190 cmpwi cr2,r10,11
191 cror 4*cr0+eq,4*cr0+eq,4*cr1+eq
192 cror 4*cr0+eq,4*cr0+eq,4*cr2+eq
193 bnelr
194 lwz r6,CPU_SPEC_FEATURES(r4)
195 li r7,CPU_FTR_CAN_NAP
196 andc r6,r6,r7
197 stw r6,CPU_SPEC_FEATURES(r4)
198 blr
199
200
201
202 setup_750fx:
203 blr
204
205
206
207
208
209
210
211
212
213
214
215 setup_745x_specifics:
216
217
218
219
220 BEGIN_FTR_SECTION
221 mfspr r11,SPRN_L3CR
222 andis. r11,r11,L3CR_L3E@h
223 beq 1f
224 END_FTR_SECTION_IFSET(CPU_FTR_L3CR)
225 lwz r6,CPU_SPEC_FEATURES(r4)
226 andis. r0,r6,CPU_FTR_L3_DISABLE_NAP@h
227 beq 1f
228 li r7,CPU_FTR_CAN_NAP
229 andc r6,r6,r7
230 stw r6,CPU_SPEC_FEATURES(r4)
231 1:
232 mfspr r11,SPRN_HID0
233
234
235
236 ori r11,r11,HID0_SGE | HID0_FOLD | HID0_BHTE
237 ori r11,r11,HID0_LRSTK | HID0_BTIC
238 oris r11,r11,HID0_DPM@h
239 BEGIN_MMU_FTR_SECTION
240 oris r11,r11,HID0_HIGH_BAT@h
241 END_MMU_FTR_SECTION_IFSET(MMU_FTR_USE_HIGH_BATS)
242 BEGIN_FTR_SECTION
243 xori r11,r11,HID0_BTIC
244 END_FTR_SECTION_IFSET(CPU_FTR_NO_BTIC)
245 BEGIN_FTR_SECTION
246 xoris r11,r11,HID0_DPM@h
247 END_FTR_SECTION_IFSET(CPU_FTR_NO_DPM)
248
249
250
251 li r3,HID0_SPD | HID0_NOPDST | HID0_NOPTI
252 andc r11,r11,r3
253 li r3,0
254
255 mtspr SPRN_ICTC,r3
256 isync
257 mtspr SPRN_HID0,r11
258 sync
259 isync
260
261
262
263 mfspr r3,SPRN_L2CR
264 andis. r3,r3,L2CR_L2E@h
265 beqlr
266 mfspr r3,SPRN_MSSCR0
267 ori r3,r3,3
268 sync
269 mtspr SPRN_MSSCR0,r3
270 sync
271 isync
272 blr
273
274
275
276
277
278
279 _GLOBAL(__init_fpu_registers)
280 mfmsr r10
281 ori r11,r10,MSR_FP
282 mtmsr r11
283 isync
284 addis r9,r3,empty_zero_page@ha
285 addi r9,r9,empty_zero_page@l
286 REST_32FPRS(0,r9)
287 sync
288 mtmsr r10
289 isync
290 blr
291
292
293
294 #define CS_HID0 0
295 #define CS_HID1 4
296 #define CS_HID2 8
297 #define CS_MSSCR0 12
298 #define CS_MSSSR0 16
299 #define CS_ICTRL 20
300 #define CS_LDSTCR 24
301 #define CS_LDSTDB 28
302 #define CS_SIZE 32
303
304 .data
305 .balign L1_CACHE_BYTES
306 cpu_state_storage:
307 .space CS_SIZE
308 .balign L1_CACHE_BYTES,0
309 .text
310
311
312
313
314
315
316
317 _GLOBAL(__save_cpu_setup)
318
319 mfcr r7
320
321
322 lis r5,cpu_state_storage@h
323 ori r5,r5,cpu_state_storage@l
324
325
326 mfspr r3,SPRN_HID0
327 stw r3,CS_HID0(r5)
328
329
330 mfspr r3,SPRN_PVR
331 srwi r3,r3,16
332 cmplwi cr0,r3,0x8000
333 cmplwi cr1,r3,0x000c
334 cmplwi cr2,r3,0x800c
335 cmplwi cr3,r3,0x8001
336 cmplwi cr4,r3,0x8002
337 cmplwi cr5,r3,0x8003
338 cmplwi cr6,r3,0x7000
339 cmplwi cr7,r3,0x8004
340
341 cror 4*cr1+eq,4*cr1+eq,4*cr2+eq
342
343 cror 4*cr0+eq,4*cr0+eq,4*cr3+eq
344 cror 4*cr0+eq,4*cr0+eq,4*cr4+eq
345 cror 4*cr0+eq,4*cr0+eq,4*cr1+eq
346 cror 4*cr0+eq,4*cr0+eq,4*cr5+eq
347 cror 4*cr0+eq,4*cr0+eq,4*cr7+eq
348 bne 1f
349
350 mfspr r4,SPRN_MSSCR0
351 stw r4,CS_MSSCR0(r5)
352 mfspr r4,SPRN_MSSSR0
353 stw r4,CS_MSSSR0(r5)
354 beq cr1,1f
355
356 mfspr r4,SPRN_HID1
357 stw r4,CS_HID1(r5)
358 mfspr r4,SPRN_ICTRL
359 stw r4,CS_ICTRL(r5)
360 mfspr r4,SPRN_LDSTCR
361 stw r4,CS_LDSTCR(r5)
362 mfspr r4,SPRN_LDSTDB
363 stw r4,CS_LDSTDB(r5)
364 1:
365 bne cr6,1f
366
367 mfspr r4,SPRN_HID1
368 stw r4,CS_HID1(r5)
369
370 mfspr r3,SPRN_PVR
371 andi. r3,r3,0xff00
372 cmpwi cr0,r3,0x0200
373 bne 1f
374 mfspr r4,SPRN_HID2
375 stw r4,CS_HID2(r5)
376 1:
377 mtcr r7
378 blr
379
380
381
382
383
384 _GLOBAL(__restore_cpu_setup)
385
386 mfcr r7
387
388
389 lis r5,(cpu_state_storage-KERNELBASE)@h
390 ori r5,r5,cpu_state_storage@l
391
392
393 lwz r3,CS_HID0(r5)
394 sync
395 isync
396 mtspr SPRN_HID0,r3
397 sync
398 isync
399
400
401 mfspr r3,SPRN_PVR
402 srwi r3,r3,16
403 cmplwi cr0,r3,0x8000
404 cmplwi cr1,r3,0x000c
405 cmplwi cr2,r3,0x800c
406 cmplwi cr3,r3,0x8001
407 cmplwi cr4,r3,0x8002
408 cmplwi cr5,r3,0x8003
409 cmplwi cr6,r3,0x7000
410 cmplwi cr7,r3,0x8004
411
412 cror 4*cr1+eq,4*cr1+eq,4*cr2+eq
413
414 cror 4*cr0+eq,4*cr0+eq,4*cr3+eq
415 cror 4*cr0+eq,4*cr0+eq,4*cr4+eq
416 cror 4*cr0+eq,4*cr0+eq,4*cr1+eq
417 cror 4*cr0+eq,4*cr0+eq,4*cr5+eq
418 cror 4*cr0+eq,4*cr0+eq,4*cr7+eq
419 bne 2f
420
421 lwz r4,CS_MSSCR0(r5)
422 sync
423 mtspr SPRN_MSSCR0,r4
424 sync
425 isync
426 lwz r4,CS_MSSSR0(r5)
427 sync
428 mtspr SPRN_MSSSR0,r4
429 sync
430 isync
431 bne cr2,1f
432
433 li r4,0
434 mtspr SPRN_L2CR2,r4
435 1: beq cr1,2f
436
437 lwz r4,CS_HID1(r5)
438 sync
439 mtspr SPRN_HID1,r4
440 isync
441 sync
442 lwz r4,CS_ICTRL(r5)
443 sync
444 mtspr SPRN_ICTRL,r4
445 isync
446 sync
447 lwz r4,CS_LDSTCR(r5)
448 sync
449 mtspr SPRN_LDSTCR,r4
450 isync
451 sync
452 lwz r4,CS_LDSTDB(r5)
453 sync
454 mtspr SPRN_LDSTDB,r4
455 isync
456 sync
457 2: bne cr6,1f
458
459
460
461
462
463 mfspr r3,SPRN_PVR
464 andi. r3,r3,0xff00
465 cmpwi cr0,r3,0x0200
466 bne 4f
467 lwz r4,CS_HID2(r5)
468 rlwinm r4,r4,0,19,17
469 mtspr SPRN_HID2,r4
470 sync
471 4:
472 lwz r4,CS_HID1(r5)
473 rlwinm r5,r4,0,16,14
474 mtspr SPRN_HID1,r5
475
476 mftbl r5
477 3: mftbl r6
478 sub r6,r6,r5
479 cmplwi cr0,r6,10000
480 ble 3b
481
482 mtspr SPRN_HID1,r4
483 1:
484 mtcr r7
485 blr
486