Merge tag 'dmaengine-4.21-rc1' of git://git.infradead.org/users/vkoul/slave-dma
[linux-2.6-block.git] / arch / powerpc / kernel / cpu_setup_power.S
CommitLineData
24cc67de
BH
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>
f64e8084 18#include <asm/book3s/64/mmu-hash.h>
24cc67de
BH
19
20/* Entry: r3 = crap, r4 = ptr to cputable entry
21 *
22 * Note that we can be called twice for pseudo-PVRs
23 */
24_GLOBAL(__setup_cpu_power7)
25 mflr r11
26 bl __init_hvmode_206
27 mtlr r11
28 beqlr
b144871c
BH
29 li r0,0
30 mtspr SPRN_LPID,r0
faf37c44 31 mtspr SPRN_PCR,r0
f7c32c24 32 mfspr r3,SPRN_LPCR
08a1e650 33 li r4,(LPCR_LPES1 >> LPCR_LPES_SH)
700b7ead 34 bl __init_LPCR_ISA206
24cc67de
BH
35 mtlr r11
36 blr
37
38_GLOBAL(__restore_cpu_power7)
39 mflr r11
40 mfmsr r3
41 rldicl. r0,r3,4,63
42 beqlr
b144871c
BH
43 li r0,0
44 mtspr SPRN_LPID,r0
faf37c44 45 mtspr SPRN_PCR,r0
f7c32c24 46 mfspr r3,SPRN_LPCR
08a1e650 47 li r4,(LPCR_LPES1 >> LPCR_LPES_SH)
700b7ead 48 bl __init_LPCR_ISA206
aec937b1
MN
49 mtlr r11
50 blr
51
52_GLOBAL(__setup_cpu_power8)
53 mflr r11
57d23167 54 bl __init_FSCR
240686c1 55 bl __init_PMU
393eb79a 56 bl __init_PMU_ISA207
aec937b1
MN
57 bl __init_hvmode_206
58 mtlr r11
59 beqlr
60 li r0,0
61 mtspr SPRN_LPID,r0
faf37c44 62 mtspr SPRN_PCR,r0
f7c32c24 63 mfspr r3,SPRN_LPCR
d4e58e59 64 ori r3, r3, LPCR_PECEDH
08a1e650 65 li r4,0 /* LPES = 0 */
700b7ead 66 bl __init_LPCR_ISA206
2a3563b0 67 bl __init_HFSCR
240686c1 68 bl __init_PMU_HV
393eb79a 69 bl __init_PMU_HV_ISA207
aec937b1
MN
70 mtlr r11
71 blr
72
73_GLOBAL(__restore_cpu_power8)
74 mflr r11
57d23167 75 bl __init_FSCR
240686c1 76 bl __init_PMU
393eb79a 77 bl __init_PMU_ISA207
aec937b1
MN
78 mfmsr r3
79 rldicl. r0,r3,4,63
8c2a3817 80 mtlr r11
aec937b1
MN
81 beqlr
82 li r0,0
83 mtspr SPRN_LPID,r0
faf37c44 84 mtspr SPRN_PCR,r0
f7c32c24 85 mfspr r3,SPRN_LPCR
d4e58e59 86 ori r3, r3, LPCR_PECEDH
08a1e650 87 li r4,0 /* LPES = 0 */
700b7ead 88 bl __init_LPCR_ISA206
2a3563b0 89 bl __init_HFSCR
240686c1 90 bl __init_PMU_HV
393eb79a 91 bl __init_PMU_HV_ISA207
24cc67de
BH
92 mtlr r11
93 blr
94
c3ab300e
MN
95_GLOBAL(__setup_cpu_power9)
96 mflr r11
97 bl __init_FSCR
393eb79a 98 bl __init_PMU
c3ab300e
MN
99 bl __init_hvmode_206
100 mtlr r11
101 beqlr
102 li r0,0
378f96d3 103 mtspr SPRN_PSSCR,r0
c3ab300e 104 mtspr SPRN_LPID,r0
371b8044 105 mtspr SPRN_PID,r0
faf37c44 106 mtspr SPRN_PCR,r0
c3ab300e 107 mfspr r3,SPRN_LPCR
08a1e650 108 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE | LPCR_HEIC)
7a43906f 109 or r3, r3, r4
fda2d27d
AK
110 LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR)
111 andc r3, r3, r4
8d1b48ef 112 li r4,0 /* LPES = 0 */
700b7ead 113 bl __init_LPCR_ISA300
c3ab300e 114 bl __init_HFSCR
393eb79a 115 bl __init_PMU_HV
c3ab300e
MN
116 mtlr r11
117 blr
118
119_GLOBAL(__restore_cpu_power9)
120 mflr r11
121 bl __init_FSCR
393eb79a 122 bl __init_PMU
c3ab300e
MN
123 mfmsr r3
124 rldicl. r0,r3,4,63
125 mtlr r11
126 beqlr
127 li r0,0
378f96d3 128 mtspr SPRN_PSSCR,r0
c3ab300e 129 mtspr SPRN_LPID,r0
371b8044 130 mtspr SPRN_PID,r0
faf37c44 131 mtspr SPRN_PCR,r0
c3ab300e 132 mfspr r3,SPRN_LPCR
08a1e650 133 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE | LPCR_HEIC)
7a43906f 134 or r3, r3, r4
fda2d27d
AK
135 LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR)
136 andc r3, r3, r4
8d1b48ef 137 li r4,0 /* LPES = 0 */
700b7ead 138 bl __init_LPCR_ISA300
c3ab300e 139 bl __init_HFSCR
393eb79a 140 bl __init_PMU_HV
c3ab300e
MN
141 mtlr r11
142 blr
143
24cc67de 144__init_hvmode_206:
969391c5 145 /* Disable CPU_FTR_HVMODE and exit if MSR:HV is not set */
24cc67de
BH
146 mfmsr r3
147 rldicl. r0,r3,4,63
148 bnelr
149 ld r5,CPU_SPEC_FEATURES(r4)
e7b17d50
PM
150 LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE | CPU_FTR_P9_TM_HV_ASSIST)
151 andc r5,r5,r6
24cc67de
BH
152 std r5,CPU_SPEC_FEATURES(r4)
153 blr
154
700b7ead 155__init_LPCR_ISA206:
24cc67de 156 /* Setup a sane LPCR:
08a1e650 157 * Called with initial LPCR in R3 and desired LPES 2-bit value in R4
24cc67de 158 *
a5d4f3ad 159 * LPES = 0b01 (HSRR0/1 used for 0x500)
24cc67de 160 * PECE = 0b111
895796a8 161 * DPFD = 4
923c53ca
PM
162 * HDICE = 0
163 * VC = 0b100 (VPM0=1, VPM1=0, ISL=0)
164 * VRMASD = 0b10000 (L=1, LP=00)
24cc67de
BH
165 *
166 * Other bits untouched for now
167 */
700b7ead
NP
168 li r5,0x10
169 rldimi r3,r5, LPCR_VRMASD_SH, 64-LPCR_VRMASD_SH-5
170
171 /* POWER9 has no VRMASD */
172__init_LPCR_ISA300:
08a1e650 173 rldimi r3,r4, LPCR_LPES_SH, 64-LPCR_LPES_SH-2
24cc67de 174 ori r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2)
895796a8 175 li r5,4
923c53ca
PM
176 rldimi r3,r5, LPCR_DPFD_SH, 64-LPCR_DPFD_SH-3
177 clrrdi r3,r3,1 /* clear HDICE */
178 li r5,4
179 rldimi r3,r5, LPCR_VC_SH, 0
24cc67de
BH
180 mtspr SPRN_LPCR,r3
181 isync
182 blr
b144871c 183
2468dcf6
IM
184__init_FSCR:
185 mfspr r3,SPRN_FSCR
1ddf499e 186 ori r3,r3,FSCR_TAR|FSCR_DSCR|FSCR_EBB
2468dcf6
IM
187 mtspr SPRN_FSCR,r3
188 blr
189
2a3563b0
MN
190__init_HFSCR:
191 mfspr r3,SPRN_HFSCR
53b56ca0 192 ori r3,r3,HFSCR_TAR|HFSCR_TM|HFSCR_BHRB|HFSCR_PM|\
02ed21ae 193 HFSCR_DSCR|HFSCR_VECVSX|HFSCR_FP|HFSCR_EBB|HFSCR_MSGP
2a3563b0
MN
194 mtspr SPRN_HFSCR,r3
195 blr
196
240686c1
ME
197__init_PMU_HV:
198 li r5,0
199 mtspr SPRN_MMCRC,r5
393eb79a
MS
200 blr
201
202__init_PMU_HV_ISA207:
203 li r5,0
240686c1
ME
204 mtspr SPRN_MMCRH,r5
205 blr
206
207__init_PMU:
208 li r5,0
240686c1
ME
209 mtspr SPRN_MMCRA,r5
210 mtspr SPRN_MMCR0,r5
211 mtspr SPRN_MMCR1,r5
212 mtspr SPRN_MMCR2,r5
213 blr
393eb79a
MS
214
215__init_PMU_ISA207:
216 li r5,0
217 mtspr SPRN_MMCRS,r5
218 blr