2 * This file contains low level CPU setup functions.
3 * Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
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.
12 #include <asm/processor.h>
14 #include <asm/cputable.h>
15 #include <asm/ppc_asm.h>
16 #include <asm/asm-offsets.h>
17 #include <asm/cache.h>
18 #include <asm/book3s/64/mmu-hash.h>
20 /* Entry: r3 = crap, r4 = ptr to cputable entry
22 * Note that we can be called twice for pseudo-PVRs
24 _GLOBAL(__setup_cpu_power7)
32 li r4,(LPCR_LPES1 >> LPCR_LPES_SH)
38 _GLOBAL(__restore_cpu_power7)
46 li r4,(LPCR_LPES1 >> LPCR_LPES_SH)
52 _GLOBAL(__setup_cpu_power8)
63 ori r3, r3, LPCR_PECEDH
64 li r4,0 /* LPES = 0 */
69 bl __init_PMU_HV_ISA207
73 _GLOBAL(__restore_cpu_power8)
85 ori r3, r3, LPCR_PECEDH
86 li r4,0 /* LPES = 0 */
91 bl __init_PMU_HV_ISA207
95 _GLOBAL(__setup_cpu_power9)
106 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE | LPCR_HEIC)
108 LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR)
110 li r4,0 /* LPES = 0 */
111 bl __init_LPCR_ISA300
118 _GLOBAL(__restore_cpu_power9)
130 LOAD_REG_IMMEDIATE(r4, LPCR_PECEDH | LPCR_PECE_HVEE | LPCR_HVICE | LPCR_HEIC)
132 LOAD_REG_IMMEDIATE(r4, LPCR_UPRT | LPCR_HR)
134 li r4,0 /* LPES = 0 */
135 bl __init_LPCR_ISA300
143 /* Disable CPU_FTR_HVMODE and exit if MSR:HV is not set */
147 ld r5,CPU_SPEC_FEATURES(r4)
148 LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE)
150 std r5,CPU_SPEC_FEATURES(r4)
154 /* Setup a sane LPCR:
155 * Called with initial LPCR in R3 and desired LPES 2-bit value in R4
157 * LPES = 0b01 (HSRR0/1 used for 0x500)
161 * VC = 0b100 (VPM0=1, VPM1=0, ISL=0)
162 * VRMASD = 0b10000 (L=1, LP=00)
164 * Other bits untouched for now
167 rldimi r3,r5, LPCR_VRMASD_SH, 64-LPCR_VRMASD_SH-5
169 /* POWER9 has no VRMASD */
171 rldimi r3,r4, LPCR_LPES_SH, 64-LPCR_LPES_SH-2
172 ori r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2)
174 rldimi r3,r5, LPCR_DPFD_SH, 64-LPCR_DPFD_SH-3
175 clrrdi r3,r3,1 /* clear HDICE */
177 rldimi r3,r5, LPCR_VC_SH, 0
184 ori r3,r3,FSCR_TAR|FSCR_DSCR|FSCR_EBB
190 ori r3,r3,HFSCR_TAR|HFSCR_TM|HFSCR_BHRB|HFSCR_PM|\
191 HFSCR_DSCR|HFSCR_VECVSX|HFSCR_FP|HFSCR_EBB|HFSCR_MSGP
196 * Clear the TLB using the specified IS form of tlbiel instruction
197 * (invalidate by congruence class). P7 has 128 CCs., P8 has 512.
200 li r6,POWER7_TLB_SETS
202 li r7,0xc00 /* IS field = 0b11 */
211 li r6,POWER8_TLB_SETS
213 li r7,0xc00 /* IS field = 0b11 */
222 * Flush the TLB in hash mode. Hash must flush with RIC=2 once for process
223 * and one for partition scope to clear process and partition table entries.
226 li r6,POWER9_TLB_SETS_HASH - 1
228 li r7,0xc00 /* IS field = 0b11 */
231 PPC_TLBIEL(7, 8, 2, 1, 0)
232 PPC_TLBIEL(7, 8, 2, 0, 0)
234 PPC_TLBIEL(7, 8, 0, 0, 0)
244 __init_PMU_HV_ISA207: