1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * This file contains low level CPU setup functions.
4 * Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
7 #include <asm/processor.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/book3s/64/mmu-hash.h>
15 /* Entry: r3 = crap, r4 = ptr to cputable entry
17 * Note that we can be called twice for pseudo-PVRs
19 _GLOBAL(__setup_cpu_power7)
26 LOAD_REG_IMMEDIATE(r0, PCR_MASK)
29 li r4,(LPCR_LPES1 >> LPCR_LPES_SH)
34 _GLOBAL(__restore_cpu_power7)
41 LOAD_REG_IMMEDIATE(r0, PCR_MASK)
44 li r4,(LPCR_LPES1 >> LPCR_LPES_SH)
49 _GLOBAL(__setup_cpu_power8)
59 LOAD_REG_IMMEDIATE(r0, PCR_MASK)
62 ori r3, r3, LPCR_PECEDH
63 li r4,0 /* LPES = 0 */
67 bl __init_PMU_HV_ISA207
71 _GLOBAL(__restore_cpu_power8)
82 LOAD_REG_IMMEDIATE(r0, PCR_MASK)
85 ori r3, r3, LPCR_PECEDH
86 li r4,0 /* LPES = 0 */
90 bl __init_PMU_HV_ISA207
94 _GLOBAL(__setup_cpu_power9)
105 LOAD_REG_IMMEDIATE(r0, PCR_MASK)
108 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE | LPCR_HEIC)
110 LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR)
112 li r4,0 /* LPES = 0 */
113 bl __init_LPCR_ISA300
119 _GLOBAL(__restore_cpu_power9)
131 LOAD_REG_IMMEDIATE(r0, PCR_MASK)
134 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE | LPCR_HEIC)
136 LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR)
138 li r4,0 /* LPES = 0 */
139 bl __init_LPCR_ISA300
146 /* Disable CPU_FTR_HVMODE and exit if MSR:HV is not set */
150 ld r5,CPU_SPEC_FEATURES(r4)
151 LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE | CPU_FTR_P9_TM_HV_ASSIST)
153 std r5,CPU_SPEC_FEATURES(r4)
157 /* Setup a sane LPCR:
158 * Called with initial LPCR in R3 and desired LPES 2-bit value in R4
160 * LPES = 0b01 (HSRR0/1 used for 0x500)
164 * VC = 0b100 (VPM0=1, VPM1=0, ISL=0)
165 * VRMASD = 0b10000 (L=1, LP=00)
167 * Other bits untouched for now
170 rldimi r3,r5, LPCR_VRMASD_SH, 64-LPCR_VRMASD_SH-5
172 /* POWER9 has no VRMASD */
174 rldimi r3,r4, LPCR_LPES_SH, 64-LPCR_LPES_SH-2
175 ori r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2)
177 rldimi r3,r5, LPCR_DPFD_SH, 64-LPCR_DPFD_SH-3
178 clrrdi r3,r3,1 /* clear HDICE */
180 rldimi r3,r5, LPCR_VC_SH, 0
187 ori r3,r3,FSCR_TAR|FSCR_DSCR|FSCR_EBB
193 ori r3,r3,HFSCR_TAR|HFSCR_TM|HFSCR_BHRB|HFSCR_PM|\
194 HFSCR_DSCR|HFSCR_VECVSX|HFSCR_FP|HFSCR_EBB|HFSCR_MSGP
203 __init_PMU_HV_ISA207: