]> rtime.felk.cvut.cz Git - linux-imx.git/blob - arch/powerpc/kernel/cpu_setup_power.S
powerpc/power8: Fix secondary CPUs hanging on boot for HV=0
[linux-imx.git] / arch / powerpc / kernel / cpu_setup_power.S
1 /*
2  * This file contains low level CPU setup functions.
3  *    Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version
8  * 2 of the License, or (at your option) any later version.
9  *
10  */
11
12 #include <asm/processor.h>
13 #include <asm/page.h>
14 #include <asm/cputable.h>
15 #include <asm/ppc_asm.h>
16 #include <asm/asm-offsets.h>
17 #include <asm/cache.h>
18
19 /* Entry: r3 = crap, r4 = ptr to cputable entry
20  *
21  * Note that we can be called twice for pseudo-PVRs
22  */
23 _GLOBAL(__setup_cpu_power7)
24         mflr    r11
25         bl      __init_hvmode_206
26         mtlr    r11
27         beqlr
28         li      r0,0
29         mtspr   SPRN_LPID,r0
30         mfspr   r3,SPRN_LPCR
31         bl      __init_LPCR
32         bl      __init_TLB
33         mtlr    r11
34         blr
35
36 _GLOBAL(__restore_cpu_power7)
37         mflr    r11
38         mfmsr   r3
39         rldicl. r0,r3,4,63
40         beqlr
41         li      r0,0
42         mtspr   SPRN_LPID,r0
43         mfspr   r3,SPRN_LPCR
44         bl      __init_LPCR
45         bl      __init_TLB
46         mtlr    r11
47         blr
48
49 _GLOBAL(__setup_cpu_power8)
50         mflr    r11
51         bl      __init_FSCR
52         bl      __init_hvmode_206
53         mtlr    r11
54         beqlr
55         li      r0,0
56         mtspr   SPRN_LPID,r0
57         mfspr   r3,SPRN_LPCR
58         oris    r3, r3, LPCR_AIL_3@h
59         bl      __init_LPCR
60         bl      __init_HFSCR
61         bl      __init_TLB
62         mtlr    r11
63         blr
64
65 _GLOBAL(__restore_cpu_power8)
66         mflr    r11
67         bl      __init_FSCR
68         mfmsr   r3
69         rldicl. r0,r3,4,63
70         mtlr    r11
71         beqlr
72         li      r0,0
73         mtspr   SPRN_LPID,r0
74         mfspr   r3,SPRN_LPCR
75         oris    r3, r3, LPCR_AIL_3@h
76         bl      __init_LPCR
77         bl      __init_HFSCR
78         bl      __init_TLB
79         mtlr    r11
80         blr
81
82 __init_hvmode_206:
83         /* Disable CPU_FTR_HVMODE and exit if MSR:HV is not set */
84         mfmsr   r3
85         rldicl. r0,r3,4,63
86         bnelr
87         ld      r5,CPU_SPEC_FEATURES(r4)
88         LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE)
89         xor     r5,r5,r6
90         std     r5,CPU_SPEC_FEATURES(r4)
91         blr
92
93 __init_LPCR:
94         /* Setup a sane LPCR:
95          *   Called with initial LPCR in R3
96          *
97          *   LPES = 0b01 (HSRR0/1 used for 0x500)
98          *   PECE = 0b111
99          *   DPFD = 4
100          *   HDICE = 0
101          *   VC = 0b100 (VPM0=1, VPM1=0, ISL=0)
102          *   VRMASD = 0b10000 (L=1, LP=00)
103          *
104          * Other bits untouched for now
105          */
106         li      r5,1
107         rldimi  r3,r5, LPCR_LPES_SH, 64-LPCR_LPES_SH-2
108         ori     r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2)
109         li      r5,4
110         rldimi  r3,r5, LPCR_DPFD_SH, 64-LPCR_DPFD_SH-3
111         clrrdi  r3,r3,1         /* clear HDICE */
112         li      r5,4
113         rldimi  r3,r5, LPCR_VC_SH, 0
114         li      r5,0x10
115         rldimi  r3,r5, LPCR_VRMASD_SH, 64-LPCR_VRMASD_SH-5
116         mtspr   SPRN_LPCR,r3
117         isync
118         blr
119
120 __init_FSCR:
121         mfspr   r3,SPRN_FSCR
122         ori     r3,r3,FSCR_TAR|FSCR_DSCR
123         mtspr   SPRN_FSCR,r3
124         blr
125
126 __init_HFSCR:
127         mfspr   r3,SPRN_HFSCR
128         ori     r3,r3,HFSCR_TAR|HFSCR_TM|HFSCR_DSCR|HFSCR_VECVSX|HFSCR_FP
129         mtspr   SPRN_HFSCR,r3
130         blr
131
132 __init_TLB:
133         /* Clear the TLB */
134         li      r6,128
135         mtctr   r6
136         li      r7,0xc00        /* IS field = 0b11 */
137         ptesync
138 2:      tlbiel  r7
139         addi    r7,r7,0x1000
140         bdnz    2b
141         ptesync
142 1:      blr