2011-01-20 07:50:55 +00:00
|
|
|
/*
|
|
|
|
* This file contains low level CPU setup functions.
|
|
|
|
* Copyright (C) 2003 Benjamin Herrenschmidt (benh@kernel.crashing.org)
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version
|
|
|
|
* 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/page.h>
|
|
|
|
#include <asm/cputable.h>
|
|
|
|
#include <asm/ppc_asm.h>
|
|
|
|
#include <asm/asm-offsets.h>
|
|
|
|
#include <asm/cache.h>
|
2016-03-01 07:29:20 +00:00
|
|
|
#include <asm/book3s/64/mmu-hash.h>
|
2011-01-20 07:50:55 +00:00
|
|
|
|
|
|
|
/* Entry: r3 = crap, r4 = ptr to cputable entry
|
|
|
|
*
|
|
|
|
* Note that we can be called twice for pseudo-PVRs
|
|
|
|
*/
|
|
|
|
_GLOBAL(__setup_cpu_power7)
|
|
|
|
mflr r11
|
|
|
|
bl __init_hvmode_206
|
|
|
|
mtlr r11
|
|
|
|
beqlr
|
2011-03-01 04:46:09 +00:00
|
|
|
li r0,0
|
|
|
|
mtspr SPRN_LPID,r0
|
2012-11-05 03:40:18 +00:00
|
|
|
mfspr r3,SPRN_LPCR
|
2011-01-20 07:50:55 +00:00
|
|
|
bl __init_LPCR
|
2013-10-30 14:34:56 +00:00
|
|
|
bl __init_tlb_power7
|
2011-01-20 07:50:55 +00:00
|
|
|
mtlr r11
|
|
|
|
blr
|
|
|
|
|
|
|
|
_GLOBAL(__restore_cpu_power7)
|
|
|
|
mflr r11
|
|
|
|
mfmsr r3
|
|
|
|
rldicl. r0,r3,4,63
|
|
|
|
beqlr
|
2011-03-01 04:46:09 +00:00
|
|
|
li r0,0
|
|
|
|
mtspr SPRN_LPID,r0
|
2012-11-05 03:40:18 +00:00
|
|
|
mfspr r3,SPRN_LPCR
|
2011-01-20 07:50:55 +00:00
|
|
|
bl __init_LPCR
|
2013-10-30 14:34:56 +00:00
|
|
|
bl __init_tlb_power7
|
2012-10-30 19:34:14 +00:00
|
|
|
mtlr r11
|
|
|
|
blr
|
|
|
|
|
|
|
|
_GLOBAL(__setup_cpu_power8)
|
|
|
|
mflr r11
|
2013-03-04 19:45:50 +00:00
|
|
|
bl __init_FSCR
|
2013-04-25 19:28:22 +00:00
|
|
|
bl __init_PMU
|
2012-10-30 19:34:14 +00:00
|
|
|
bl __init_hvmode_206
|
|
|
|
mtlr r11
|
|
|
|
beqlr
|
|
|
|
li r0,0
|
|
|
|
mtspr SPRN_LPID,r0
|
2012-11-05 03:40:18 +00:00
|
|
|
mfspr r3,SPRN_LPCR
|
2014-06-11 05:59:28 +00:00
|
|
|
ori r3, r3, LPCR_PECEDH
|
2012-10-30 19:34:14 +00:00
|
|
|
bl __init_LPCR
|
2013-03-05 17:35:24 +00:00
|
|
|
bl __init_HFSCR
|
2013-10-30 14:34:56 +00:00
|
|
|
bl __init_tlb_power8
|
2013-04-25 19:28:22 +00:00
|
|
|
bl __init_PMU_HV
|
2012-10-30 19:34:14 +00:00
|
|
|
mtlr r11
|
|
|
|
blr
|
|
|
|
|
|
|
|
_GLOBAL(__restore_cpu_power8)
|
|
|
|
mflr r11
|
2013-03-04 19:45:50 +00:00
|
|
|
bl __init_FSCR
|
2013-04-25 19:28:22 +00:00
|
|
|
bl __init_PMU
|
2012-10-30 19:34:14 +00:00
|
|
|
mfmsr r3
|
|
|
|
rldicl. r0,r3,4,63
|
2013-04-24 21:00:37 +00:00
|
|
|
mtlr r11
|
2012-10-30 19:34:14 +00:00
|
|
|
beqlr
|
|
|
|
li r0,0
|
|
|
|
mtspr SPRN_LPID,r0
|
2012-11-05 03:40:18 +00:00
|
|
|
mfspr r3,SPRN_LPCR
|
2014-06-11 05:59:28 +00:00
|
|
|
ori r3, r3, LPCR_PECEDH
|
2012-10-30 19:34:14 +00:00
|
|
|
bl __init_LPCR
|
2013-03-05 17:35:24 +00:00
|
|
|
bl __init_HFSCR
|
2013-10-30 14:34:56 +00:00
|
|
|
bl __init_tlb_power8
|
2013-04-25 19:28:22 +00:00
|
|
|
bl __init_PMU_HV
|
2011-01-20 07:50:55 +00:00
|
|
|
mtlr r11
|
|
|
|
blr
|
|
|
|
|
2016-02-19 00:16:24 +00:00
|
|
|
_GLOBAL(__setup_cpu_power9)
|
|
|
|
mflr r11
|
|
|
|
bl __init_FSCR
|
|
|
|
bl __init_hvmode_206
|
|
|
|
mtlr r11
|
|
|
|
beqlr
|
|
|
|
li r0,0
|
|
|
|
mtspr SPRN_LPID,r0
|
|
|
|
mfspr r3,SPRN_LPCR
|
|
|
|
ori r3, r3, LPCR_PECEDH
|
|
|
|
bl __init_LPCR
|
|
|
|
bl __init_HFSCR
|
|
|
|
bl __init_tlb_power9
|
|
|
|
mtlr r11
|
|
|
|
blr
|
|
|
|
|
|
|
|
_GLOBAL(__restore_cpu_power9)
|
|
|
|
mflr r11
|
|
|
|
bl __init_FSCR
|
|
|
|
mfmsr r3
|
|
|
|
rldicl. r0,r3,4,63
|
|
|
|
mtlr r11
|
|
|
|
beqlr
|
|
|
|
li r0,0
|
|
|
|
mtspr SPRN_LPID,r0
|
|
|
|
mfspr r3,SPRN_LPCR
|
|
|
|
ori r3, r3, LPCR_PECEDH
|
|
|
|
bl __init_LPCR
|
|
|
|
bl __init_HFSCR
|
|
|
|
bl __init_tlb_power9
|
|
|
|
mtlr r11
|
|
|
|
blr
|
|
|
|
|
2011-01-20 07:50:55 +00:00
|
|
|
__init_hvmode_206:
|
powerpc, KVM: Split HVMODE_206 cpu feature bit into separate HV and architecture bits
This replaces the single CPU_FTR_HVMODE_206 bit with two bits, one to
indicate that we have a usable hypervisor mode, and another to indicate
that the processor conforms to PowerISA version 2.06. We also add
another bit to indicate that the processor conforms to ISA version 2.01
and set that for PPC970 and derivatives.
Some PPC970 chips (specifically those in Apple machines) have a
hypervisor mode in that MSR[HV] is always 1, but the hypervisor mode
is not useful in the sense that there is no way to run any code in
supervisor mode (HV=0 PR=0). On these processors, the LPES0 and LPES1
bits in HID4 are always 0, and we use that as a way of detecting that
hypervisor mode is not useful.
Where we have a feature section in assembly code around code that
only applies on POWER7 in hypervisor mode, we use a construct like
END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
The definition of END_FTR_SECTION_IFSET is such that the code will
be enabled (not overwritten with nops) only if all bits in the
provided mask are set.
Note that the CPU feature check in __tlbie() only needs to check the
ARCH_206 bit, not the HVMODE bit, because __tlbie() can only get called
if we are running bare-metal, i.e. in hypervisor mode.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 00:26:11 +00:00
|
|
|
/* Disable CPU_FTR_HVMODE and exit if MSR:HV is not set */
|
2011-01-20 07:50:55 +00:00
|
|
|
mfmsr r3
|
|
|
|
rldicl. r0,r3,4,63
|
|
|
|
bnelr
|
|
|
|
ld r5,CPU_SPEC_FEATURES(r4)
|
powerpc, KVM: Split HVMODE_206 cpu feature bit into separate HV and architecture bits
This replaces the single CPU_FTR_HVMODE_206 bit with two bits, one to
indicate that we have a usable hypervisor mode, and another to indicate
that the processor conforms to PowerISA version 2.06. We also add
another bit to indicate that the processor conforms to ISA version 2.01
and set that for PPC970 and derivatives.
Some PPC970 chips (specifically those in Apple machines) have a
hypervisor mode in that MSR[HV] is always 1, but the hypervisor mode
is not useful in the sense that there is no way to run any code in
supervisor mode (HV=0 PR=0). On these processors, the LPES0 and LPES1
bits in HID4 are always 0, and we use that as a way of detecting that
hypervisor mode is not useful.
Where we have a feature section in assembly code around code that
only applies on POWER7 in hypervisor mode, we use a construct like
END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
The definition of END_FTR_SECTION_IFSET is such that the code will
be enabled (not overwritten with nops) only if all bits in the
provided mask are set.
Note that the CPU feature check in __tlbie() only needs to check the
ARCH_206 bit, not the HVMODE bit, because __tlbie() can only get called
if we are running bare-metal, i.e. in hypervisor mode.
Signed-off-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
2011-06-29 00:26:11 +00:00
|
|
|
LOAD_REG_IMMEDIATE(r6,CPU_FTR_HVMODE)
|
2011-01-20 07:50:55 +00:00
|
|
|
xor r5,r5,r6
|
|
|
|
std r5,CPU_SPEC_FEATURES(r4)
|
|
|
|
blr
|
|
|
|
|
|
|
|
__init_LPCR:
|
|
|
|
/* Setup a sane LPCR:
|
2012-11-05 03:40:18 +00:00
|
|
|
* Called with initial LPCR in R3
|
2011-01-20 07:50:55 +00:00
|
|
|
*
|
2011-04-05 04:20:31 +00:00
|
|
|
* LPES = 0b01 (HSRR0/1 used for 0x500)
|
2011-01-20 07:50:55 +00:00
|
|
|
* PECE = 0b111
|
2011-01-24 02:25:55 +00:00
|
|
|
* DPFD = 4
|
2011-06-29 00:20:24 +00:00
|
|
|
* HDICE = 0
|
|
|
|
* VC = 0b100 (VPM0=1, VPM1=0, ISL=0)
|
|
|
|
* VRMASD = 0b10000 (L=1, LP=00)
|
2011-01-20 07:50:55 +00:00
|
|
|
*
|
|
|
|
* Other bits untouched for now
|
|
|
|
*/
|
2011-06-29 00:20:24 +00:00
|
|
|
li r5,1
|
|
|
|
rldimi r3,r5, LPCR_LPES_SH, 64-LPCR_LPES_SH-2
|
2011-01-20 07:50:55 +00:00
|
|
|
ori r3,r3,(LPCR_PECE0|LPCR_PECE1|LPCR_PECE2)
|
2011-01-24 02:25:55 +00:00
|
|
|
li r5,4
|
2011-06-29 00:20:24 +00:00
|
|
|
rldimi r3,r5, LPCR_DPFD_SH, 64-LPCR_DPFD_SH-3
|
|
|
|
clrrdi r3,r3,1 /* clear HDICE */
|
|
|
|
li r5,4
|
|
|
|
rldimi r3,r5, LPCR_VC_SH, 0
|
|
|
|
li r5,0x10
|
|
|
|
rldimi r3,r5, LPCR_VRMASD_SH, 64-LPCR_VRMASD_SH-5
|
2011-01-20 07:50:55 +00:00
|
|
|
mtspr SPRN_LPCR,r3
|
|
|
|
isync
|
|
|
|
blr
|
2011-03-01 04:46:09 +00:00
|
|
|
|
2013-02-07 15:46:58 +00:00
|
|
|
__init_FSCR:
|
|
|
|
mfspr r3,SPRN_FSCR
|
2013-04-30 20:17:03 +00:00
|
|
|
ori r3,r3,FSCR_TAR|FSCR_DSCR|FSCR_EBB
|
2013-02-07 15:46:58 +00:00
|
|
|
mtspr SPRN_FSCR,r3
|
|
|
|
blr
|
|
|
|
|
2013-03-05 17:35:24 +00:00
|
|
|
__init_HFSCR:
|
|
|
|
mfspr r3,SPRN_HFSCR
|
2013-04-25 20:54:55 +00:00
|
|
|
ori r3,r3,HFSCR_TAR|HFSCR_TM|HFSCR_BHRB|HFSCR_PM|\
|
2013-04-30 20:17:03 +00:00
|
|
|
HFSCR_DSCR|HFSCR_VECVSX|HFSCR_FP|HFSCR_EBB
|
2013-03-05 17:35:24 +00:00
|
|
|
mtspr SPRN_HFSCR,r3
|
|
|
|
blr
|
|
|
|
|
2013-10-30 14:34:56 +00:00
|
|
|
/*
|
|
|
|
* Clear the TLB using the specified IS form of tlbiel instruction
|
|
|
|
* (invalidate by congruence class). P7 has 128 CCs., P8 has 512.
|
|
|
|
*/
|
|
|
|
__init_tlb_power7:
|
2016-02-19 00:16:23 +00:00
|
|
|
li r6,POWER7_TLB_SETS
|
2013-10-30 14:34:56 +00:00
|
|
|
mtctr r6
|
2014-12-19 03:11:05 +00:00
|
|
|
li r7,0xc00 /* IS field = 0b11 */
|
2013-10-30 14:34:56 +00:00
|
|
|
ptesync
|
|
|
|
2: tlbiel r7
|
|
|
|
addi r7,r7,0x1000
|
|
|
|
bdnz 2b
|
|
|
|
ptesync
|
|
|
|
1: blr
|
|
|
|
|
|
|
|
__init_tlb_power8:
|
2016-02-19 00:16:23 +00:00
|
|
|
li r6,POWER8_TLB_SETS
|
2011-03-01 04:46:09 +00:00
|
|
|
mtctr r6
|
2014-12-19 03:11:05 +00:00
|
|
|
li r7,0xc00 /* IS field = 0b11 */
|
2011-03-01 04:46:09 +00:00
|
|
|
ptesync
|
|
|
|
2: tlbiel r7
|
|
|
|
addi r7,r7,0x1000
|
|
|
|
bdnz 2b
|
|
|
|
ptesync
|
|
|
|
1: blr
|
2013-04-25 19:28:22 +00:00
|
|
|
|
2016-02-19 00:16:24 +00:00
|
|
|
__init_tlb_power9:
|
|
|
|
li r6,POWER9_TLB_SETS_HASH
|
|
|
|
mtctr r6
|
|
|
|
li r7,0xc00 /* IS field = 0b11 */
|
|
|
|
ptesync
|
|
|
|
2: tlbiel r7
|
|
|
|
addi r7,r7,0x1000
|
|
|
|
bdnz 2b
|
|
|
|
ptesync
|
|
|
|
1: blr
|
|
|
|
|
2013-04-25 19:28:22 +00:00
|
|
|
__init_PMU_HV:
|
|
|
|
li r5,0
|
|
|
|
mtspr SPRN_MMCRC,r5
|
|
|
|
mtspr SPRN_MMCRH,r5
|
|
|
|
blr
|
|
|
|
|
|
|
|
__init_PMU:
|
|
|
|
li r5,0
|
|
|
|
mtspr SPRN_MMCRS,r5
|
|
|
|
mtspr SPRN_MMCRA,r5
|
|
|
|
mtspr SPRN_MMCR0,r5
|
|
|
|
mtspr SPRN_MMCR1,r5
|
|
|
|
mtspr SPRN_MMCR2,r5
|
|
|
|
blr
|