162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Contains the definition of registers common to all PowerPC variants. 462306a36Sopenharmony_ci * If a register definition has been changed in a different PowerPC 562306a36Sopenharmony_ci * variant, we will case it in #ifndef XXX ... #endif, and have the 662306a36Sopenharmony_ci * number used in the Programming Environments Manual For 32-Bit 762306a36Sopenharmony_ci * Implementations of the PowerPC Architecture (a.k.a. Green Book) here. 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef _ASM_POWERPC_REG_H 1162306a36Sopenharmony_ci#define _ASM_POWERPC_REG_H 1262306a36Sopenharmony_ci#ifdef __KERNEL__ 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci#include <linux/stringify.h> 1562306a36Sopenharmony_ci#include <linux/const.h> 1662306a36Sopenharmony_ci#include <asm/cputable.h> 1762306a36Sopenharmony_ci#include <asm/asm-const.h> 1862306a36Sopenharmony_ci#include <asm/feature-fixups.h> 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci/* Pickup Book E specific registers. */ 2162306a36Sopenharmony_ci#ifdef CONFIG_BOOKE_OR_40x 2262306a36Sopenharmony_ci#include <asm/reg_booke.h> 2362306a36Sopenharmony_ci#endif 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ci#ifdef CONFIG_FSL_EMB_PERFMON 2662306a36Sopenharmony_ci#include <asm/reg_fsl_emb.h> 2762306a36Sopenharmony_ci#endif 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ci#include <asm/reg_8xx.h> 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#define MSR_SF_LG 63 /* Enable 64 bit mode */ 3262306a36Sopenharmony_ci#define MSR_HV_LG 60 /* Hypervisor state */ 3362306a36Sopenharmony_ci#define MSR_TS_T_LG 34 /* Trans Mem state: Transactional */ 3462306a36Sopenharmony_ci#define MSR_TS_S_LG 33 /* Trans Mem state: Suspended */ 3562306a36Sopenharmony_ci#define MSR_TS_LG 33 /* Trans Mem state (2 bits) */ 3662306a36Sopenharmony_ci#define MSR_TM_LG 32 /* Trans Mem Available */ 3762306a36Sopenharmony_ci#define MSR_VEC_LG 25 /* Enable AltiVec */ 3862306a36Sopenharmony_ci#define MSR_VSX_LG 23 /* Enable VSX */ 3962306a36Sopenharmony_ci#define MSR_S_LG 22 /* Secure state */ 4062306a36Sopenharmony_ci#define MSR_POW_LG 18 /* Enable Power Management */ 4162306a36Sopenharmony_ci#define MSR_WE_LG 18 /* Wait State Enable */ 4262306a36Sopenharmony_ci#define MSR_TGPR_LG 17 /* TLB Update registers in use */ 4362306a36Sopenharmony_ci#define MSR_CE_LG 17 /* Critical Interrupt Enable */ 4462306a36Sopenharmony_ci#define MSR_ILE_LG 16 /* Interrupt Little Endian */ 4562306a36Sopenharmony_ci#define MSR_EE_LG 15 /* External Interrupt Enable */ 4662306a36Sopenharmony_ci#define MSR_PR_LG 14 /* Problem State / Privilege Level */ 4762306a36Sopenharmony_ci#define MSR_FP_LG 13 /* Floating Point enable */ 4862306a36Sopenharmony_ci#define MSR_ME_LG 12 /* Machine Check Enable */ 4962306a36Sopenharmony_ci#define MSR_FE0_LG 11 /* Floating Exception mode 0 */ 5062306a36Sopenharmony_ci#define MSR_SE_LG 10 /* Single Step */ 5162306a36Sopenharmony_ci#define MSR_BE_LG 9 /* Branch Trace */ 5262306a36Sopenharmony_ci#define MSR_DE_LG 9 /* Debug Exception Enable */ 5362306a36Sopenharmony_ci#define MSR_FE1_LG 8 /* Floating Exception mode 1 */ 5462306a36Sopenharmony_ci#define MSR_IP_LG 6 /* Exception prefix 0x000/0xFFF */ 5562306a36Sopenharmony_ci#define MSR_IR_LG 5 /* Instruction Relocate */ 5662306a36Sopenharmony_ci#define MSR_DR_LG 4 /* Data Relocate */ 5762306a36Sopenharmony_ci#define MSR_PE_LG 3 /* Protection Enable */ 5862306a36Sopenharmony_ci#define MSR_PX_LG 2 /* Protection Exclusive Mode */ 5962306a36Sopenharmony_ci#define MSR_PMM_LG 2 /* Performance monitor */ 6062306a36Sopenharmony_ci#define MSR_RI_LG 1 /* Recoverable Exception */ 6162306a36Sopenharmony_ci#define MSR_LE_LG 0 /* Little Endian */ 6262306a36Sopenharmony_ci 6362306a36Sopenharmony_ci#ifdef __ASSEMBLY__ 6462306a36Sopenharmony_ci#define __MASK(X) (1<<(X)) 6562306a36Sopenharmony_ci#else 6662306a36Sopenharmony_ci#define __MASK(X) (1UL<<(X)) 6762306a36Sopenharmony_ci#endif 6862306a36Sopenharmony_ci 6962306a36Sopenharmony_ci#ifdef CONFIG_PPC64 7062306a36Sopenharmony_ci#define MSR_SF __MASK(MSR_SF_LG) /* Enable 64 bit mode */ 7162306a36Sopenharmony_ci#define MSR_HV __MASK(MSR_HV_LG) /* Hypervisor state */ 7262306a36Sopenharmony_ci#define MSR_S __MASK(MSR_S_LG) /* Secure state */ 7362306a36Sopenharmony_ci#else 7462306a36Sopenharmony_ci/* so tests for these bits fail on 32-bit */ 7562306a36Sopenharmony_ci#define MSR_SF 0 7662306a36Sopenharmony_ci#define MSR_HV 0 7762306a36Sopenharmony_ci#define MSR_S 0 7862306a36Sopenharmony_ci#endif 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_ci/* 8162306a36Sopenharmony_ci * To be used in shared book E/book S, this avoids needing to worry about 8262306a36Sopenharmony_ci * book S/book E in shared code 8362306a36Sopenharmony_ci */ 8462306a36Sopenharmony_ci#ifndef MSR_SPE 8562306a36Sopenharmony_ci#define MSR_SPE 0 8662306a36Sopenharmony_ci#endif 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci#define MSR_VEC __MASK(MSR_VEC_LG) /* Enable AltiVec */ 8962306a36Sopenharmony_ci#define MSR_VSX __MASK(MSR_VSX_LG) /* Enable VSX */ 9062306a36Sopenharmony_ci#define MSR_POW __MASK(MSR_POW_LG) /* Enable Power Management */ 9162306a36Sopenharmony_ci#define MSR_WE __MASK(MSR_WE_LG) /* Wait State Enable */ 9262306a36Sopenharmony_ci#define MSR_TGPR __MASK(MSR_TGPR_LG) /* TLB Update registers in use */ 9362306a36Sopenharmony_ci#define MSR_CE __MASK(MSR_CE_LG) /* Critical Interrupt Enable */ 9462306a36Sopenharmony_ci#define MSR_ILE __MASK(MSR_ILE_LG) /* Interrupt Little Endian */ 9562306a36Sopenharmony_ci#define MSR_EE __MASK(MSR_EE_LG) /* External Interrupt Enable */ 9662306a36Sopenharmony_ci#define MSR_PR __MASK(MSR_PR_LG) /* Problem State / Privilege Level */ 9762306a36Sopenharmony_ci#define MSR_FP __MASK(MSR_FP_LG) /* Floating Point enable */ 9862306a36Sopenharmony_ci#define MSR_ME __MASK(MSR_ME_LG) /* Machine Check Enable */ 9962306a36Sopenharmony_ci#define MSR_FE0 __MASK(MSR_FE0_LG) /* Floating Exception mode 0 */ 10062306a36Sopenharmony_ci#define MSR_SE __MASK(MSR_SE_LG) /* Single Step */ 10162306a36Sopenharmony_ci#define MSR_BE __MASK(MSR_BE_LG) /* Branch Trace */ 10262306a36Sopenharmony_ci#define MSR_DE __MASK(MSR_DE_LG) /* Debug Exception Enable */ 10362306a36Sopenharmony_ci#define MSR_FE1 __MASK(MSR_FE1_LG) /* Floating Exception mode 1 */ 10462306a36Sopenharmony_ci#define MSR_IP __MASK(MSR_IP_LG) /* Exception prefix 0x000/0xFFF */ 10562306a36Sopenharmony_ci#define MSR_IR __MASK(MSR_IR_LG) /* Instruction Relocate */ 10662306a36Sopenharmony_ci#define MSR_DR __MASK(MSR_DR_LG) /* Data Relocate */ 10762306a36Sopenharmony_ci#define MSR_PE __MASK(MSR_PE_LG) /* Protection Enable */ 10862306a36Sopenharmony_ci#define MSR_PX __MASK(MSR_PX_LG) /* Protection Exclusive Mode */ 10962306a36Sopenharmony_ci#ifndef MSR_PMM 11062306a36Sopenharmony_ci#define MSR_PMM __MASK(MSR_PMM_LG) /* Performance monitor */ 11162306a36Sopenharmony_ci#endif 11262306a36Sopenharmony_ci#define MSR_RI __MASK(MSR_RI_LG) /* Recoverable Exception */ 11362306a36Sopenharmony_ci#define MSR_LE __MASK(MSR_LE_LG) /* Little Endian */ 11462306a36Sopenharmony_ci 11562306a36Sopenharmony_ci#define MSR_TM __MASK(MSR_TM_LG) /* Transactional Mem Available */ 11662306a36Sopenharmony_ci#define MSR_TS_N 0 /* Non-transactional */ 11762306a36Sopenharmony_ci#define MSR_TS_S __MASK(MSR_TS_S_LG) /* Transaction Suspended */ 11862306a36Sopenharmony_ci#define MSR_TS_T __MASK(MSR_TS_T_LG) /* Transaction Transactional */ 11962306a36Sopenharmony_ci#define MSR_TS_MASK (MSR_TS_T | MSR_TS_S) /* Transaction State bits */ 12062306a36Sopenharmony_ci#define MSR_TM_RESV(x) (((x) & MSR_TS_MASK) == MSR_TS_MASK) /* Reserved */ 12162306a36Sopenharmony_ci#define MSR_TM_TRANSACTIONAL(x) (((x) & MSR_TS_MASK) == MSR_TS_T) 12262306a36Sopenharmony_ci#define MSR_TM_SUSPENDED(x) (((x) & MSR_TS_MASK) == MSR_TS_S) 12362306a36Sopenharmony_ci 12462306a36Sopenharmony_ci#ifdef CONFIG_PPC_TRANSACTIONAL_MEM 12562306a36Sopenharmony_ci#define MSR_TM_ACTIVE(x) (((x) & MSR_TS_MASK) != 0) /* Transaction active? */ 12662306a36Sopenharmony_ci#else 12762306a36Sopenharmony_ci#define MSR_TM_ACTIVE(x) ((void)(x), 0) 12862306a36Sopenharmony_ci#endif 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci#if defined(CONFIG_PPC_BOOK3S_64) 13162306a36Sopenharmony_ci#define MSR_64BIT MSR_SF 13262306a36Sopenharmony_ci 13362306a36Sopenharmony_ci/* Server variant */ 13462306a36Sopenharmony_ci#define __MSR (MSR_ME | MSR_RI | MSR_IR | MSR_DR | MSR_HV) 13562306a36Sopenharmony_ci#ifdef __BIG_ENDIAN__ 13662306a36Sopenharmony_ci#define MSR_ __MSR 13762306a36Sopenharmony_ci#define MSR_IDLE (MSR_ME | MSR_SF | MSR_HV) 13862306a36Sopenharmony_ci#else 13962306a36Sopenharmony_ci#define MSR_ (__MSR | MSR_LE) 14062306a36Sopenharmony_ci#define MSR_IDLE (MSR_ME | MSR_SF | MSR_HV | MSR_LE) 14162306a36Sopenharmony_ci#endif 14262306a36Sopenharmony_ci#define MSR_KERNEL (MSR_ | MSR_64BIT) 14362306a36Sopenharmony_ci#define MSR_USER32 (MSR_ | MSR_PR | MSR_EE) 14462306a36Sopenharmony_ci#define MSR_USER64 (MSR_USER32 | MSR_64BIT) 14562306a36Sopenharmony_ci#elif defined(CONFIG_PPC_BOOK3S_32) || defined(CONFIG_PPC_8xx) 14662306a36Sopenharmony_ci/* Default MSR for kernel mode. */ 14762306a36Sopenharmony_ci#define MSR_KERNEL (MSR_ME|MSR_RI|MSR_IR|MSR_DR) 14862306a36Sopenharmony_ci#define MSR_USER (MSR_KERNEL|MSR_PR|MSR_EE) 14962306a36Sopenharmony_ci#endif 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_ci#ifndef MSR_64BIT 15262306a36Sopenharmony_ci#define MSR_64BIT 0 15362306a36Sopenharmony_ci#endif 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ci/* Condition Register related */ 15662306a36Sopenharmony_ci#define CR0_SHIFT 28 15762306a36Sopenharmony_ci#define CR0_MASK 0xF 15862306a36Sopenharmony_ci#define CR0_TBEGIN_FAILURE (0x2 << 28) /* 0b0010 */ 15962306a36Sopenharmony_ci 16062306a36Sopenharmony_ci 16162306a36Sopenharmony_ci/* Power Management - Processor Stop Status and Control Register Fields */ 16262306a36Sopenharmony_ci#define PSSCR_RL_MASK 0x0000000F /* Requested Level */ 16362306a36Sopenharmony_ci#define PSSCR_MTL_MASK 0x000000F0 /* Maximum Transition Level */ 16462306a36Sopenharmony_ci#define PSSCR_TR_MASK 0x00000300 /* Transition State */ 16562306a36Sopenharmony_ci#define PSSCR_PSLL_MASK 0x000F0000 /* Power-Saving Level Limit */ 16662306a36Sopenharmony_ci#define PSSCR_EC 0x00100000 /* Exit Criterion */ 16762306a36Sopenharmony_ci#define PSSCR_ESL 0x00200000 /* Enable State Loss */ 16862306a36Sopenharmony_ci#define PSSCR_SD 0x00400000 /* Status Disable */ 16962306a36Sopenharmony_ci#define PSSCR_PLS 0xf000000000000000 /* Power-saving Level Status */ 17062306a36Sopenharmony_ci#define PSSCR_PLS_SHIFT 60 17162306a36Sopenharmony_ci#define PSSCR_GUEST_VIS 0xf0000000000003ffUL /* Guest-visible PSSCR fields */ 17262306a36Sopenharmony_ci#define PSSCR_FAKE_SUSPEND 0x00000400 /* Fake-suspend bit (P9 DD2.2) */ 17362306a36Sopenharmony_ci#define PSSCR_FAKE_SUSPEND_LG 10 /* Fake-suspend bit position */ 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci/* Floating Point Status and Control Register (FPSCR) Fields */ 17662306a36Sopenharmony_ci#define FPSCR_FX 0x80000000 /* FPU exception summary */ 17762306a36Sopenharmony_ci#define FPSCR_FEX 0x40000000 /* FPU enabled exception summary */ 17862306a36Sopenharmony_ci#define FPSCR_VX 0x20000000 /* Invalid operation summary */ 17962306a36Sopenharmony_ci#define FPSCR_OX 0x10000000 /* Overflow exception summary */ 18062306a36Sopenharmony_ci#define FPSCR_UX 0x08000000 /* Underflow exception summary */ 18162306a36Sopenharmony_ci#define FPSCR_ZX 0x04000000 /* Zero-divide exception summary */ 18262306a36Sopenharmony_ci#define FPSCR_XX 0x02000000 /* Inexact exception summary */ 18362306a36Sopenharmony_ci#define FPSCR_VXSNAN 0x01000000 /* Invalid op for SNaN */ 18462306a36Sopenharmony_ci#define FPSCR_VXISI 0x00800000 /* Invalid op for Inv - Inv */ 18562306a36Sopenharmony_ci#define FPSCR_VXIDI 0x00400000 /* Invalid op for Inv / Inv */ 18662306a36Sopenharmony_ci#define FPSCR_VXZDZ 0x00200000 /* Invalid op for Zero / Zero */ 18762306a36Sopenharmony_ci#define FPSCR_VXIMZ 0x00100000 /* Invalid op for Inv * Zero */ 18862306a36Sopenharmony_ci#define FPSCR_VXVC 0x00080000 /* Invalid op for Compare */ 18962306a36Sopenharmony_ci#define FPSCR_FR 0x00040000 /* Fraction rounded */ 19062306a36Sopenharmony_ci#define FPSCR_FI 0x00020000 /* Fraction inexact */ 19162306a36Sopenharmony_ci#define FPSCR_FPRF 0x0001f000 /* FPU Result Flags */ 19262306a36Sopenharmony_ci#define FPSCR_FPCC 0x0000f000 /* FPU Condition Codes */ 19362306a36Sopenharmony_ci#define FPSCR_VXSOFT 0x00000400 /* Invalid op for software request */ 19462306a36Sopenharmony_ci#define FPSCR_VXSQRT 0x00000200 /* Invalid op for square root */ 19562306a36Sopenharmony_ci#define FPSCR_VXCVI 0x00000100 /* Invalid op for integer convert */ 19662306a36Sopenharmony_ci#define FPSCR_VE 0x00000080 /* Invalid op exception enable */ 19762306a36Sopenharmony_ci#define FPSCR_OE 0x00000040 /* IEEE overflow exception enable */ 19862306a36Sopenharmony_ci#define FPSCR_UE 0x00000020 /* IEEE underflow exception enable */ 19962306a36Sopenharmony_ci#define FPSCR_ZE 0x00000010 /* IEEE zero divide exception enable */ 20062306a36Sopenharmony_ci#define FPSCR_XE 0x00000008 /* FP inexact exception enable */ 20162306a36Sopenharmony_ci#define FPSCR_NI 0x00000004 /* FPU non IEEE-Mode */ 20262306a36Sopenharmony_ci#define FPSCR_RN 0x00000003 /* FPU rounding control */ 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci/* Bit definitions for SPEFSCR. */ 20562306a36Sopenharmony_ci#define SPEFSCR_SOVH 0x80000000 /* Summary integer overflow high */ 20662306a36Sopenharmony_ci#define SPEFSCR_OVH 0x40000000 /* Integer overflow high */ 20762306a36Sopenharmony_ci#define SPEFSCR_FGH 0x20000000 /* Embedded FP guard bit high */ 20862306a36Sopenharmony_ci#define SPEFSCR_FXH 0x10000000 /* Embedded FP sticky bit high */ 20962306a36Sopenharmony_ci#define SPEFSCR_FINVH 0x08000000 /* Embedded FP invalid operation high */ 21062306a36Sopenharmony_ci#define SPEFSCR_FDBZH 0x04000000 /* Embedded FP div by zero high */ 21162306a36Sopenharmony_ci#define SPEFSCR_FUNFH 0x02000000 /* Embedded FP underflow high */ 21262306a36Sopenharmony_ci#define SPEFSCR_FOVFH 0x01000000 /* Embedded FP overflow high */ 21362306a36Sopenharmony_ci#define SPEFSCR_FINXS 0x00200000 /* Embedded FP inexact sticky */ 21462306a36Sopenharmony_ci#define SPEFSCR_FINVS 0x00100000 /* Embedded FP invalid op. sticky */ 21562306a36Sopenharmony_ci#define SPEFSCR_FDBZS 0x00080000 /* Embedded FP div by zero sticky */ 21662306a36Sopenharmony_ci#define SPEFSCR_FUNFS 0x00040000 /* Embedded FP underflow sticky */ 21762306a36Sopenharmony_ci#define SPEFSCR_FOVFS 0x00020000 /* Embedded FP overflow sticky */ 21862306a36Sopenharmony_ci#define SPEFSCR_MODE 0x00010000 /* Embedded FP mode */ 21962306a36Sopenharmony_ci#define SPEFSCR_SOV 0x00008000 /* Integer summary overflow */ 22062306a36Sopenharmony_ci#define SPEFSCR_OV 0x00004000 /* Integer overflow */ 22162306a36Sopenharmony_ci#define SPEFSCR_FG 0x00002000 /* Embedded FP guard bit */ 22262306a36Sopenharmony_ci#define SPEFSCR_FX 0x00001000 /* Embedded FP sticky bit */ 22362306a36Sopenharmony_ci#define SPEFSCR_FINV 0x00000800 /* Embedded FP invalid operation */ 22462306a36Sopenharmony_ci#define SPEFSCR_FDBZ 0x00000400 /* Embedded FP div by zero */ 22562306a36Sopenharmony_ci#define SPEFSCR_FUNF 0x00000200 /* Embedded FP underflow */ 22662306a36Sopenharmony_ci#define SPEFSCR_FOVF 0x00000100 /* Embedded FP overflow */ 22762306a36Sopenharmony_ci#define SPEFSCR_FINXE 0x00000040 /* Embedded FP inexact enable */ 22862306a36Sopenharmony_ci#define SPEFSCR_FINVE 0x00000020 /* Embedded FP invalid op. enable */ 22962306a36Sopenharmony_ci#define SPEFSCR_FDBZE 0x00000010 /* Embedded FP div by zero enable */ 23062306a36Sopenharmony_ci#define SPEFSCR_FUNFE 0x00000008 /* Embedded FP underflow enable */ 23162306a36Sopenharmony_ci#define SPEFSCR_FOVFE 0x00000004 /* Embedded FP overflow enable */ 23262306a36Sopenharmony_ci#define SPEFSCR_FRMC 0x00000003 /* Embedded FP rounding mode control */ 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci/* Special Purpose Registers (SPRNs)*/ 23562306a36Sopenharmony_ci 23662306a36Sopenharmony_ci#ifdef CONFIG_40x 23762306a36Sopenharmony_ci#define SPRN_PID 0x3B1 /* Process ID */ 23862306a36Sopenharmony_ci#else 23962306a36Sopenharmony_ci#define SPRN_PID 0x030 /* Process ID */ 24062306a36Sopenharmony_ci#ifdef CONFIG_BOOKE 24162306a36Sopenharmony_ci#define SPRN_PID0 SPRN_PID/* Process ID Register 0 */ 24262306a36Sopenharmony_ci#endif 24362306a36Sopenharmony_ci#endif 24462306a36Sopenharmony_ci 24562306a36Sopenharmony_ci#define SPRN_CTR 0x009 /* Count Register */ 24662306a36Sopenharmony_ci#define SPRN_DSCR 0x11 24762306a36Sopenharmony_ci#define SPRN_CFAR 0x1c /* Come From Address Register */ 24862306a36Sopenharmony_ci#define SPRN_AMR 0x1d /* Authority Mask Register */ 24962306a36Sopenharmony_ci#define SPRN_UAMOR 0x9d /* User Authority Mask Override Register */ 25062306a36Sopenharmony_ci#define SPRN_AMOR 0x15d /* Authority Mask Override Register */ 25162306a36Sopenharmony_ci#define SPRN_ACOP 0x1F /* Available Coprocessor Register */ 25262306a36Sopenharmony_ci#define SPRN_TFIAR 0x81 /* Transaction Failure Inst Addr */ 25362306a36Sopenharmony_ci#define SPRN_TEXASR 0x82 /* Transaction EXception & Summary */ 25462306a36Sopenharmony_ci#define SPRN_TEXASRU 0x83 /* '' '' '' Upper 32 */ 25562306a36Sopenharmony_ci 25662306a36Sopenharmony_ci#define TEXASR_FC_LG (63 - 7) /* Failure Code */ 25762306a36Sopenharmony_ci#define TEXASR_AB_LG (63 - 31) /* Abort */ 25862306a36Sopenharmony_ci#define TEXASR_SU_LG (63 - 32) /* Suspend */ 25962306a36Sopenharmony_ci#define TEXASR_HV_LG (63 - 34) /* Hypervisor state*/ 26062306a36Sopenharmony_ci#define TEXASR_PR_LG (63 - 35) /* Privilege level */ 26162306a36Sopenharmony_ci#define TEXASR_FS_LG (63 - 36) /* failure summary */ 26262306a36Sopenharmony_ci#define TEXASR_EX_LG (63 - 37) /* TFIAR exact bit */ 26362306a36Sopenharmony_ci#define TEXASR_ROT_LG (63 - 38) /* ROT bit */ 26462306a36Sopenharmony_ci 26562306a36Sopenharmony_ci#define TEXASR_ABORT __MASK(TEXASR_AB_LG) /* terminated by tabort or treclaim */ 26662306a36Sopenharmony_ci#define TEXASR_SUSP __MASK(TEXASR_SU_LG) /* tx failed in suspended state */ 26762306a36Sopenharmony_ci#define TEXASR_HV __MASK(TEXASR_HV_LG) /* MSR[HV] when failure occurred */ 26862306a36Sopenharmony_ci#define TEXASR_PR __MASK(TEXASR_PR_LG) /* MSR[PR] when failure occurred */ 26962306a36Sopenharmony_ci#define TEXASR_FS __MASK(TEXASR_FS_LG) /* TEXASR Failure Summary */ 27062306a36Sopenharmony_ci#define TEXASR_EXACT __MASK(TEXASR_EX_LG) /* TFIAR value is exact */ 27162306a36Sopenharmony_ci#define TEXASR_ROT __MASK(TEXASR_ROT_LG) 27262306a36Sopenharmony_ci#define TEXASR_FC (ASM_CONST(0xFF) << TEXASR_FC_LG) 27362306a36Sopenharmony_ci 27462306a36Sopenharmony_ci#define SPRN_TFHAR 0x80 /* Transaction Failure Handler Addr */ 27562306a36Sopenharmony_ci 27662306a36Sopenharmony_ci#define SPRN_TIDR 144 /* Thread ID register */ 27762306a36Sopenharmony_ci#define SPRN_CTRLF 0x088 27862306a36Sopenharmony_ci#define SPRN_CTRLT 0x098 27962306a36Sopenharmony_ci#define CTRL_CT 0xc0000000 /* current thread */ 28062306a36Sopenharmony_ci#define CTRL_CT0 0x80000000 /* thread 0 */ 28162306a36Sopenharmony_ci#define CTRL_CT1 0x40000000 /* thread 1 */ 28262306a36Sopenharmony_ci#define CTRL_TE 0x00c00000 /* thread enable */ 28362306a36Sopenharmony_ci#define CTRL_RUNLATCH 0x1 28462306a36Sopenharmony_ci#define SPRN_DAWR0 0xB4 28562306a36Sopenharmony_ci#define SPRN_DAWR1 0xB5 28662306a36Sopenharmony_ci#define SPRN_RPR 0xBA /* Relative Priority Register */ 28762306a36Sopenharmony_ci#define SPRN_CIABR 0xBB 28862306a36Sopenharmony_ci#define CIABR_PRIV 0x3 28962306a36Sopenharmony_ci#define CIABR_PRIV_USER 1 29062306a36Sopenharmony_ci#define CIABR_PRIV_SUPER 2 29162306a36Sopenharmony_ci#define CIABR_PRIV_HYPER 3 29262306a36Sopenharmony_ci#define SPRN_DAWRX0 0xBC 29362306a36Sopenharmony_ci#define SPRN_DAWRX1 0xBD 29462306a36Sopenharmony_ci#define DAWRX_USER __MASK(0) 29562306a36Sopenharmony_ci#define DAWRX_KERNEL __MASK(1) 29662306a36Sopenharmony_ci#define DAWRX_HYP __MASK(2) 29762306a36Sopenharmony_ci#define DAWRX_WTI __MASK(3) 29862306a36Sopenharmony_ci#define DAWRX_WT __MASK(4) 29962306a36Sopenharmony_ci#define DAWRX_DR __MASK(5) 30062306a36Sopenharmony_ci#define DAWRX_DW __MASK(6) 30162306a36Sopenharmony_ci#define SPRN_DABR 0x3F5 /* Data Address Breakpoint Register */ 30262306a36Sopenharmony_ci#define SPRN_DABR2 0x13D /* e300 */ 30362306a36Sopenharmony_ci#define SPRN_DABRX 0x3F7 /* Data Address Breakpoint Register Extension */ 30462306a36Sopenharmony_ci#define DABRX_USER __MASK(0) 30562306a36Sopenharmony_ci#define DABRX_KERNEL __MASK(1) 30662306a36Sopenharmony_ci#define DABRX_HYP __MASK(2) 30762306a36Sopenharmony_ci#define DABRX_BTI __MASK(3) 30862306a36Sopenharmony_ci#define DABRX_ALL (DABRX_BTI | DABRX_HYP | DABRX_KERNEL | DABRX_USER) 30962306a36Sopenharmony_ci#define SPRN_DAR 0x013 /* Data Address Register */ 31062306a36Sopenharmony_ci#define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */ 31162306a36Sopenharmony_ci#define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */ 31262306a36Sopenharmony_ci#define DSISR_BAD_DIRECT_ST 0x80000000 /* Obsolete: Direct store error */ 31362306a36Sopenharmony_ci#define DSISR_NOHPTE 0x40000000 /* no translation found */ 31462306a36Sopenharmony_ci#define DSISR_ATTR_CONFLICT 0x20000000 /* P9: Process vs. Partition attr */ 31562306a36Sopenharmony_ci#define DSISR_NOEXEC_OR_G 0x10000000 /* Alias of SRR1 bit, see below */ 31662306a36Sopenharmony_ci#define DSISR_PROTFAULT 0x08000000 /* protection fault */ 31762306a36Sopenharmony_ci#define DSISR_BADACCESS 0x04000000 /* bad access to CI or G */ 31862306a36Sopenharmony_ci#define DSISR_ISSTORE 0x02000000 /* access was a store */ 31962306a36Sopenharmony_ci#define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */ 32062306a36Sopenharmony_ci#define DSISR_NOSEGMENT 0x00200000 /* STAB miss (unsupported) */ 32162306a36Sopenharmony_ci#define DSISR_KEYFAULT 0x00200000 /* Storage Key fault */ 32262306a36Sopenharmony_ci#define DSISR_BAD_EXT_CTRL 0x00100000 /* Obsolete: External ctrl error */ 32362306a36Sopenharmony_ci#define DSISR_UNSUPP_MMU 0x00080000 /* P9: Unsupported MMU config */ 32462306a36Sopenharmony_ci#define DSISR_SET_RC 0x00040000 /* P9: Failed setting of R/C bits */ 32562306a36Sopenharmony_ci#define DSISR_PRTABLE_FAULT 0x00020000 /* P9: Fault on process table */ 32662306a36Sopenharmony_ci#define DSISR_ICSWX_NO_CT 0x00004000 /* P7: icswx unavailable cp type */ 32762306a36Sopenharmony_ci#define DSISR_BAD_COPYPASTE 0x00000008 /* P9: Copy/Paste on wrong memtype */ 32862306a36Sopenharmony_ci#define DSISR_BAD_AMO 0x00000004 /* P9: Incorrect AMO opcode */ 32962306a36Sopenharmony_ci#define DSISR_BAD_CI_LDST 0x00000002 /* P8: Bad HV CI load/store */ 33062306a36Sopenharmony_ci 33162306a36Sopenharmony_ci/* 33262306a36Sopenharmony_ci * DSISR_NOEXEC_OR_G doesn't actually exist. This bit is always 33362306a36Sopenharmony_ci * 0 on DSIs. However, on ISIs, the corresponding bit in SRR1 33462306a36Sopenharmony_ci * indicates an attempt at executing from a no-execute PTE 33562306a36Sopenharmony_ci * or segment or from a guarded page. 33662306a36Sopenharmony_ci * 33762306a36Sopenharmony_ci * We add a definition here for completeness as we alias 33862306a36Sopenharmony_ci * DSISR and SRR1 in do_page_fault. 33962306a36Sopenharmony_ci */ 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci/* 34262306a36Sopenharmony_ci * DSISR bits that are treated as a fault. Any bit set 34362306a36Sopenharmony_ci * here will skip hash_page, and cause do_page_fault to 34462306a36Sopenharmony_ci * trigger a SIGBUS or SIGSEGV: 34562306a36Sopenharmony_ci */ 34662306a36Sopenharmony_ci#define DSISR_BAD_FAULT_32S (DSISR_BAD_DIRECT_ST | \ 34762306a36Sopenharmony_ci DSISR_BADACCESS | \ 34862306a36Sopenharmony_ci DSISR_BAD_EXT_CTRL) 34962306a36Sopenharmony_ci#define DSISR_BAD_FAULT_64S (DSISR_BAD_FAULT_32S | \ 35062306a36Sopenharmony_ci DSISR_ATTR_CONFLICT | \ 35162306a36Sopenharmony_ci DSISR_UNSUPP_MMU | \ 35262306a36Sopenharmony_ci DSISR_PRTABLE_FAULT | \ 35362306a36Sopenharmony_ci DSISR_ICSWX_NO_CT | \ 35462306a36Sopenharmony_ci DSISR_BAD_COPYPASTE | \ 35562306a36Sopenharmony_ci DSISR_BAD_AMO | \ 35662306a36Sopenharmony_ci DSISR_BAD_CI_LDST) 35762306a36Sopenharmony_ci/* 35862306a36Sopenharmony_ci * These bits are equivalent in SRR1 and DSISR for 0x400 35962306a36Sopenharmony_ci * instruction access interrupts on Book3S 36062306a36Sopenharmony_ci */ 36162306a36Sopenharmony_ci#define DSISR_SRR1_MATCH_32S (DSISR_NOHPTE | \ 36262306a36Sopenharmony_ci DSISR_NOEXEC_OR_G | \ 36362306a36Sopenharmony_ci DSISR_PROTFAULT) 36462306a36Sopenharmony_ci#define DSISR_SRR1_MATCH_64S (DSISR_SRR1_MATCH_32S | \ 36562306a36Sopenharmony_ci DSISR_KEYFAULT | \ 36662306a36Sopenharmony_ci DSISR_UNSUPP_MMU | \ 36762306a36Sopenharmony_ci DSISR_SET_RC | \ 36862306a36Sopenharmony_ci DSISR_PRTABLE_FAULT) 36962306a36Sopenharmony_ci 37062306a36Sopenharmony_ci#define SPRN_TBRL 0x10C /* Time Base Read Lower Register (user, R/O) */ 37162306a36Sopenharmony_ci#define SPRN_TBRU 0x10D /* Time Base Read Upper Register (user, R/O) */ 37262306a36Sopenharmony_ci#define SPRN_CIR 0x11B /* Chip Information Register (hyper, R/0) */ 37362306a36Sopenharmony_ci#define SPRN_TBWL 0x11C /* Time Base Lower Register (super, R/W) */ 37462306a36Sopenharmony_ci#define SPRN_TBWU 0x11D /* Time Base Upper Register (super, R/W) */ 37562306a36Sopenharmony_ci#define SPRN_TBU40 0x11E /* Timebase upper 40 bits (hyper, R/W) */ 37662306a36Sopenharmony_ci#define SPRN_SPURR 0x134 /* Scaled PURR */ 37762306a36Sopenharmony_ci#define SPRN_HSPRG0 0x130 /* Hypervisor Scratch 0 */ 37862306a36Sopenharmony_ci#define SPRN_HSPRG1 0x131 /* Hypervisor Scratch 1 */ 37962306a36Sopenharmony_ci#define SPRN_HDSISR 0x132 38062306a36Sopenharmony_ci#define SPRN_HDAR 0x133 38162306a36Sopenharmony_ci#define SPRN_HDEC 0x136 /* Hypervisor Decrementer */ 38262306a36Sopenharmony_ci#define SPRN_HIOR 0x137 /* 970 Hypervisor interrupt offset */ 38362306a36Sopenharmony_ci#define SPRN_RMOR 0x138 /* Real mode offset register */ 38462306a36Sopenharmony_ci#define SPRN_HRMOR 0x139 /* Real mode offset register */ 38562306a36Sopenharmony_ci#define SPRN_HDEXCR_RO 0x1C7 /* Hypervisor DEXCR (non-privileged, readonly) */ 38662306a36Sopenharmony_ci#define SPRN_HASHKEYR 0x1D4 /* Non-privileged hashst/hashchk key register */ 38762306a36Sopenharmony_ci#define SPRN_HDEXCR 0x1D7 /* Hypervisor dynamic execution control register */ 38862306a36Sopenharmony_ci#define SPRN_DEXCR_RO 0x32C /* DEXCR (non-privileged, readonly) */ 38962306a36Sopenharmony_ci#define SPRN_ASDR 0x330 /* Access segment descriptor register */ 39062306a36Sopenharmony_ci#define SPRN_DEXCR 0x33C /* Dynamic execution control register */ 39162306a36Sopenharmony_ci#define DEXCR_PR_SBHE 0x80000000UL /* 0: Speculative Branch Hint Enable */ 39262306a36Sopenharmony_ci#define DEXCR_PR_IBRTPD 0x10000000UL /* 3: Indirect Branch Recurrent Target Prediction Disable */ 39362306a36Sopenharmony_ci#define DEXCR_PR_SRAPD 0x08000000UL /* 4: Subroutine Return Address Prediction Disable */ 39462306a36Sopenharmony_ci#define DEXCR_PR_NPHIE 0x04000000UL /* 5: Non-Privileged Hash Instruction Enable */ 39562306a36Sopenharmony_ci#define DEXCR_INIT DEXCR_PR_NPHIE /* Fixed DEXCR value to initialise all CPUs with */ 39662306a36Sopenharmony_ci#define SPRN_IC 0x350 /* Virtual Instruction Count */ 39762306a36Sopenharmony_ci#define SPRN_VTB 0x351 /* Virtual Time Base */ 39862306a36Sopenharmony_ci#define SPRN_LDBAR 0x352 /* LD Base Address Register */ 39962306a36Sopenharmony_ci#define SPRN_PMICR 0x354 /* Power Management Idle Control Reg */ 40062306a36Sopenharmony_ci#define SPRN_PMSR 0x355 /* Power Management Status Reg */ 40162306a36Sopenharmony_ci#define SPRN_PMMAR 0x356 /* Power Management Memory Activity Register */ 40262306a36Sopenharmony_ci#define SPRN_PSSCR 0x357 /* Processor Stop Status and Control Register (ISA 3.0) */ 40362306a36Sopenharmony_ci#define SPRN_PSSCR_PR 0x337 /* PSSCR ISA 3.0, privileged mode access */ 40462306a36Sopenharmony_ci#define SPRN_TRIG2 0x372 40562306a36Sopenharmony_ci#define SPRN_PMCR 0x374 /* Power Management Control Register */ 40662306a36Sopenharmony_ci#define SPRN_RWMR 0x375 /* Region-Weighting Mode Register */ 40762306a36Sopenharmony_ci 40862306a36Sopenharmony_ci/* HFSCR and FSCR bit numbers are the same */ 40962306a36Sopenharmony_ci#define FSCR_PREFIX_LG 13 /* Enable Prefix Instructions */ 41062306a36Sopenharmony_ci#define FSCR_SCV_LG 12 /* Enable System Call Vectored */ 41162306a36Sopenharmony_ci#define FSCR_MSGP_LG 10 /* Enable MSGP */ 41262306a36Sopenharmony_ci#define FSCR_TAR_LG 8 /* Enable Target Address Register */ 41362306a36Sopenharmony_ci#define FSCR_EBB_LG 7 /* Enable Event Based Branching */ 41462306a36Sopenharmony_ci#define FSCR_TM_LG 5 /* Enable Transactional Memory */ 41562306a36Sopenharmony_ci#define FSCR_BHRB_LG 4 /* Enable Branch History Rolling Buffer*/ 41662306a36Sopenharmony_ci#define FSCR_PM_LG 3 /* Enable prob/priv access to PMU SPRs */ 41762306a36Sopenharmony_ci#define FSCR_DSCR_LG 2 /* Enable Data Stream Control Register */ 41862306a36Sopenharmony_ci#define FSCR_VECVSX_LG 1 /* Enable VMX/VSX */ 41962306a36Sopenharmony_ci#define FSCR_FP_LG 0 /* Enable Floating Point */ 42062306a36Sopenharmony_ci#define SPRN_FSCR 0x099 /* Facility Status & Control Register */ 42162306a36Sopenharmony_ci#define FSCR_PREFIX __MASK(FSCR_PREFIX_LG) 42262306a36Sopenharmony_ci#define FSCR_SCV __MASK(FSCR_SCV_LG) 42362306a36Sopenharmony_ci#define FSCR_TAR __MASK(FSCR_TAR_LG) 42462306a36Sopenharmony_ci#define FSCR_EBB __MASK(FSCR_EBB_LG) 42562306a36Sopenharmony_ci#define FSCR_DSCR __MASK(FSCR_DSCR_LG) 42662306a36Sopenharmony_ci#define FSCR_INTR_CAUSE (ASM_CONST(0xFF) << 56) /* interrupt cause */ 42762306a36Sopenharmony_ci#define SPRN_HFSCR 0xbe /* HV=1 Facility Status & Control Register */ 42862306a36Sopenharmony_ci#define HFSCR_PREFIX __MASK(FSCR_PREFIX_LG) 42962306a36Sopenharmony_ci#define HFSCR_MSGP __MASK(FSCR_MSGP_LG) 43062306a36Sopenharmony_ci#define HFSCR_TAR __MASK(FSCR_TAR_LG) 43162306a36Sopenharmony_ci#define HFSCR_EBB __MASK(FSCR_EBB_LG) 43262306a36Sopenharmony_ci#define HFSCR_TM __MASK(FSCR_TM_LG) 43362306a36Sopenharmony_ci#define HFSCR_PM __MASK(FSCR_PM_LG) 43462306a36Sopenharmony_ci#define HFSCR_BHRB __MASK(FSCR_BHRB_LG) 43562306a36Sopenharmony_ci#define HFSCR_DSCR __MASK(FSCR_DSCR_LG) 43662306a36Sopenharmony_ci#define HFSCR_VECVSX __MASK(FSCR_VECVSX_LG) 43762306a36Sopenharmony_ci#define HFSCR_FP __MASK(FSCR_FP_LG) 43862306a36Sopenharmony_ci#define HFSCR_INTR_CAUSE FSCR_INTR_CAUSE 43962306a36Sopenharmony_ci#define SPRN_TAR 0x32f /* Target Address Register */ 44062306a36Sopenharmony_ci#define SPRN_LPCR 0x13E /* LPAR Control Register */ 44162306a36Sopenharmony_ci#define LPCR_VPM0 ASM_CONST(0x8000000000000000) 44262306a36Sopenharmony_ci#define LPCR_VPM1 ASM_CONST(0x4000000000000000) 44362306a36Sopenharmony_ci#define LPCR_ISL ASM_CONST(0x2000000000000000) 44462306a36Sopenharmony_ci#define LPCR_VC_SH 61 44562306a36Sopenharmony_ci#define LPCR_DPFD_SH 52 44662306a36Sopenharmony_ci#define LPCR_DPFD (ASM_CONST(7) << LPCR_DPFD_SH) 44762306a36Sopenharmony_ci#define LPCR_VRMASD_SH 47 44862306a36Sopenharmony_ci#define LPCR_VRMASD (ASM_CONST(0x1f) << LPCR_VRMASD_SH) 44962306a36Sopenharmony_ci#define LPCR_VRMA_L ASM_CONST(0x0008000000000000) 45062306a36Sopenharmony_ci#define LPCR_VRMA_LP0 ASM_CONST(0x0001000000000000) 45162306a36Sopenharmony_ci#define LPCR_VRMA_LP1 ASM_CONST(0x0000800000000000) 45262306a36Sopenharmony_ci#define LPCR_RMLS 0x1C000000 /* Implementation dependent RMO limit sel */ 45362306a36Sopenharmony_ci#define LPCR_RMLS_SH 26 45462306a36Sopenharmony_ci#define LPCR_HAIL ASM_CONST(0x0000000004000000) /* HV AIL (ISAv3.1) */ 45562306a36Sopenharmony_ci#define LPCR_ILE ASM_CONST(0x0000000002000000) /* !HV irqs set MSR:LE */ 45662306a36Sopenharmony_ci#define LPCR_AIL ASM_CONST(0x0000000001800000) /* Alternate interrupt location */ 45762306a36Sopenharmony_ci#define LPCR_AIL_0 ASM_CONST(0x0000000000000000) /* MMU off exception offset 0x0 */ 45862306a36Sopenharmony_ci#define LPCR_AIL_3 ASM_CONST(0x0000000001800000) /* MMU on exception offset 0xc00...4xxx */ 45962306a36Sopenharmony_ci#define LPCR_ONL ASM_CONST(0x0000000000040000) /* online - PURR/SPURR count */ 46062306a36Sopenharmony_ci#define LPCR_LD ASM_CONST(0x0000000000020000) /* large decremeter */ 46162306a36Sopenharmony_ci#define LPCR_PECE ASM_CONST(0x000000000001f000) /* powersave exit cause enable */ 46262306a36Sopenharmony_ci#define LPCR_PECEDP ASM_CONST(0x0000000000010000) /* directed priv dbells cause exit */ 46362306a36Sopenharmony_ci#define LPCR_PECEDH ASM_CONST(0x0000000000008000) /* directed hyp dbells cause exit */ 46462306a36Sopenharmony_ci#define LPCR_PECE0 ASM_CONST(0x0000000000004000) /* ext. exceptions can cause exit */ 46562306a36Sopenharmony_ci#define LPCR_PECE1 ASM_CONST(0x0000000000002000) /* decrementer can cause exit */ 46662306a36Sopenharmony_ci#define LPCR_PECE2 ASM_CONST(0x0000000000001000) /* machine check etc can cause exit */ 46762306a36Sopenharmony_ci#define LPCR_PECE_HVEE ASM_CONST(0x0000400000000000) /* P9 Wakeup on HV interrupts */ 46862306a36Sopenharmony_ci#define LPCR_MER ASM_CONST(0x0000000000000800) /* Mediated External Exception */ 46962306a36Sopenharmony_ci#define LPCR_MER_SH 11 47062306a36Sopenharmony_ci#define LPCR_GTSE ASM_CONST(0x0000000000000400) /* Guest Translation Shootdown Enable */ 47162306a36Sopenharmony_ci#define LPCR_TC ASM_CONST(0x0000000000000200) /* Translation control */ 47262306a36Sopenharmony_ci#define LPCR_HEIC ASM_CONST(0x0000000000000010) /* Hypervisor External Interrupt Control */ 47362306a36Sopenharmony_ci#define LPCR_LPES 0x0000000c 47462306a36Sopenharmony_ci#define LPCR_LPES0 ASM_CONST(0x0000000000000008) /* LPAR Env selector 0 */ 47562306a36Sopenharmony_ci#define LPCR_LPES1 ASM_CONST(0x0000000000000004) /* LPAR Env selector 1 */ 47662306a36Sopenharmony_ci#define LPCR_LPES_SH 2 47762306a36Sopenharmony_ci#define LPCR_RMI ASM_CONST(0x0000000000000002) /* real mode is cache inhibit */ 47862306a36Sopenharmony_ci#define LPCR_HVICE ASM_CONST(0x0000000000000002) /* P9: HV interrupt enable */ 47962306a36Sopenharmony_ci#define LPCR_HDICE ASM_CONST(0x0000000000000001) /* Hyp Decr enable (HV,PR,EE) */ 48062306a36Sopenharmony_ci#define LPCR_UPRT ASM_CONST(0x0000000000400000) /* Use Process Table (ISA 3) */ 48162306a36Sopenharmony_ci#define LPCR_HR ASM_CONST(0x0000000000100000) 48262306a36Sopenharmony_ci#ifndef SPRN_LPID 48362306a36Sopenharmony_ci#define SPRN_LPID 0x13F /* Logical Partition Identifier */ 48462306a36Sopenharmony_ci#endif 48562306a36Sopenharmony_ci#define SPRN_HMER 0x150 /* Hypervisor maintenance exception reg */ 48662306a36Sopenharmony_ci#define HMER_DEBUG_TRIG (1ul << (63 - 17)) /* Debug trigger */ 48762306a36Sopenharmony_ci#define SPRN_HMEER 0x151 /* Hyp maintenance exception enable reg */ 48862306a36Sopenharmony_ci#define SPRN_PCR 0x152 /* Processor compatibility register */ 48962306a36Sopenharmony_ci#define PCR_VEC_DIS (__MASK(63-0)) /* Vec. disable (bit NA since POWER8) */ 49062306a36Sopenharmony_ci#define PCR_VSX_DIS (__MASK(63-1)) /* VSX disable (bit NA since POWER8) */ 49162306a36Sopenharmony_ci#define PCR_TM_DIS (__MASK(63-2)) /* Trans. memory disable (POWER8) */ 49262306a36Sopenharmony_ci#define PCR_MMA_DIS (__MASK(63-3)) /* Matrix-Multiply Accelerator */ 49362306a36Sopenharmony_ci#define PCR_HIGH_BITS (PCR_MMA_DIS | PCR_VEC_DIS | PCR_VSX_DIS | PCR_TM_DIS) 49462306a36Sopenharmony_ci/* 49562306a36Sopenharmony_ci * These bits are used in the function kvmppc_set_arch_compat() to specify and 49662306a36Sopenharmony_ci * determine both the compatibility level which we want to emulate and the 49762306a36Sopenharmony_ci * compatibility level which the host is capable of emulating. 49862306a36Sopenharmony_ci */ 49962306a36Sopenharmony_ci#define PCR_ARCH_300 0x10 /* Architecture 3.00 */ 50062306a36Sopenharmony_ci#define PCR_ARCH_207 0x8 /* Architecture 2.07 */ 50162306a36Sopenharmony_ci#define PCR_ARCH_206 0x4 /* Architecture 2.06 */ 50262306a36Sopenharmony_ci#define PCR_ARCH_205 0x2 /* Architecture 2.05 */ 50362306a36Sopenharmony_ci#define PCR_LOW_BITS (PCR_ARCH_207 | PCR_ARCH_206 | PCR_ARCH_205 | PCR_ARCH_300) 50462306a36Sopenharmony_ci#define PCR_MASK ~(PCR_HIGH_BITS | PCR_LOW_BITS) /* PCR Reserved Bits */ 50562306a36Sopenharmony_ci#define SPRN_HEIR 0x153 /* Hypervisor Emulated Instruction Register */ 50662306a36Sopenharmony_ci#define SPRN_TLBINDEXR 0x154 /* P7 TLB control register */ 50762306a36Sopenharmony_ci#define SPRN_TLBVPNR 0x155 /* P7 TLB control register */ 50862306a36Sopenharmony_ci#define SPRN_TLBRPNR 0x156 /* P7 TLB control register */ 50962306a36Sopenharmony_ci#define SPRN_TLBLPIDR 0x157 /* P7 TLB control register */ 51062306a36Sopenharmony_ci#define SPRN_DBAT0L 0x219 /* Data BAT 0 Lower Register */ 51162306a36Sopenharmony_ci#define SPRN_DBAT0U 0x218 /* Data BAT 0 Upper Register */ 51262306a36Sopenharmony_ci#define SPRN_DBAT1L 0x21B /* Data BAT 1 Lower Register */ 51362306a36Sopenharmony_ci#define SPRN_DBAT1U 0x21A /* Data BAT 1 Upper Register */ 51462306a36Sopenharmony_ci#define SPRN_DBAT2L 0x21D /* Data BAT 2 Lower Register */ 51562306a36Sopenharmony_ci#define SPRN_DBAT2U 0x21C /* Data BAT 2 Upper Register */ 51662306a36Sopenharmony_ci#define SPRN_DBAT3L 0x21F /* Data BAT 3 Lower Register */ 51762306a36Sopenharmony_ci#define SPRN_DBAT3U 0x21E /* Data BAT 3 Upper Register */ 51862306a36Sopenharmony_ci#define SPRN_DBAT4L 0x239 /* Data BAT 4 Lower Register */ 51962306a36Sopenharmony_ci#define SPRN_DBAT4U 0x238 /* Data BAT 4 Upper Register */ 52062306a36Sopenharmony_ci#define SPRN_DBAT5L 0x23B /* Data BAT 5 Lower Register */ 52162306a36Sopenharmony_ci#define SPRN_DBAT5U 0x23A /* Data BAT 5 Upper Register */ 52262306a36Sopenharmony_ci#define SPRN_DBAT6L 0x23D /* Data BAT 6 Lower Register */ 52362306a36Sopenharmony_ci#define SPRN_DBAT6U 0x23C /* Data BAT 6 Upper Register */ 52462306a36Sopenharmony_ci#define SPRN_DBAT7L 0x23F /* Data BAT 7 Lower Register */ 52562306a36Sopenharmony_ci#define SPRN_DBAT7U 0x23E /* Data BAT 7 Upper Register */ 52662306a36Sopenharmony_ci#define SPRN_PPR 0x380 /* SMT Thread status Register */ 52762306a36Sopenharmony_ci#define SPRN_TSCR 0x399 /* Thread Switch Control Register */ 52862306a36Sopenharmony_ci 52962306a36Sopenharmony_ci#define SPRN_DEC 0x016 /* Decrement Register */ 53062306a36Sopenharmony_ci#define SPRN_PIT 0x3DB /* Programmable Interval Timer (40x/BOOKE) */ 53162306a36Sopenharmony_ci 53262306a36Sopenharmony_ci#define SPRN_DER 0x095 /* Debug Enable Register */ 53362306a36Sopenharmony_ci#define DER_RSTE 0x40000000 /* Reset Interrupt */ 53462306a36Sopenharmony_ci#define DER_CHSTPE 0x20000000 /* Check Stop */ 53562306a36Sopenharmony_ci#define DER_MCIE 0x10000000 /* Machine Check Interrupt */ 53662306a36Sopenharmony_ci#define DER_EXTIE 0x02000000 /* External Interrupt */ 53762306a36Sopenharmony_ci#define DER_ALIE 0x01000000 /* Alignment Interrupt */ 53862306a36Sopenharmony_ci#define DER_PRIE 0x00800000 /* Program Interrupt */ 53962306a36Sopenharmony_ci#define DER_FPUVIE 0x00400000 /* FP Unavailable Interrupt */ 54062306a36Sopenharmony_ci#define DER_DECIE 0x00200000 /* Decrementer Interrupt */ 54162306a36Sopenharmony_ci#define DER_SYSIE 0x00040000 /* System Call Interrupt */ 54262306a36Sopenharmony_ci#define DER_TRE 0x00020000 /* Trace Interrupt */ 54362306a36Sopenharmony_ci#define DER_SEIE 0x00004000 /* FP SW Emulation Interrupt */ 54462306a36Sopenharmony_ci#define DER_ITLBMSE 0x00002000 /* Imp. Spec. Instruction TLB Miss */ 54562306a36Sopenharmony_ci#define DER_ITLBERE 0x00001000 /* Imp. Spec. Instruction TLB Error */ 54662306a36Sopenharmony_ci#define DER_DTLBMSE 0x00000800 /* Imp. Spec. Data TLB Miss */ 54762306a36Sopenharmony_ci#define DER_DTLBERE 0x00000400 /* Imp. Spec. Data TLB Error */ 54862306a36Sopenharmony_ci#define DER_LBRKE 0x00000008 /* Load/Store Breakpoint Interrupt */ 54962306a36Sopenharmony_ci#define DER_IBRKE 0x00000004 /* Instruction Breakpoint Interrupt */ 55062306a36Sopenharmony_ci#define DER_EBRKE 0x00000002 /* External Breakpoint Interrupt */ 55162306a36Sopenharmony_ci#define DER_DPIE 0x00000001 /* Dev. Port Nonmaskable Request */ 55262306a36Sopenharmony_ci#define SPRN_DMISS 0x3D0 /* Data TLB Miss Register */ 55362306a36Sopenharmony_ci#define SPRN_DHDES 0x0B1 /* Directed Hyp. Doorbell Exc. State */ 55462306a36Sopenharmony_ci#define SPRN_DPDES 0x0B0 /* Directed Priv. Doorbell Exc. State */ 55562306a36Sopenharmony_ci#define SPRN_EAR 0x11A /* External Address Register */ 55662306a36Sopenharmony_ci#define SPRN_HASH1 0x3D2 /* Primary Hash Address Register */ 55762306a36Sopenharmony_ci#define SPRN_HASH2 0x3D3 /* Secondary Hash Address Register */ 55862306a36Sopenharmony_ci#define SPRN_HID0 0x3F0 /* Hardware Implementation Register 0 */ 55962306a36Sopenharmony_ci#define HID0_HDICE_SH (63 - 23) /* 970 HDEC interrupt enable */ 56062306a36Sopenharmony_ci#define HID0_EMCP (1<<31) /* Enable Machine Check pin */ 56162306a36Sopenharmony_ci#define HID0_EBA (1<<29) /* Enable Bus Address Parity */ 56262306a36Sopenharmony_ci#define HID0_EBD (1<<28) /* Enable Bus Data Parity */ 56362306a36Sopenharmony_ci#define HID0_SBCLK (1<<27) 56462306a36Sopenharmony_ci#define HID0_EICE (1<<26) 56562306a36Sopenharmony_ci#define HID0_TBEN (1<<26) /* Timebase enable - 745x */ 56662306a36Sopenharmony_ci#define HID0_ECLK (1<<25) 56762306a36Sopenharmony_ci#define HID0_PAR (1<<24) 56862306a36Sopenharmony_ci#define HID0_STEN (1<<24) /* Software table search enable - 745x */ 56962306a36Sopenharmony_ci#define HID0_HIGH_BAT (1<<23) /* Enable high BATs - 7455 */ 57062306a36Sopenharmony_ci#define HID0_DOZE (1<<23) 57162306a36Sopenharmony_ci#define HID0_NAP (1<<22) 57262306a36Sopenharmony_ci#define HID0_SLEEP (1<<21) 57362306a36Sopenharmony_ci#define HID0_DPM (1<<20) 57462306a36Sopenharmony_ci#define HID0_BHTCLR (1<<18) /* Clear branch history table - 7450 */ 57562306a36Sopenharmony_ci#define HID0_XAEN (1<<17) /* Extended addressing enable - 7450 */ 57662306a36Sopenharmony_ci#define HID0_NHR (1<<16) /* Not hard reset (software bit-7450)*/ 57762306a36Sopenharmony_ci#define HID0_ICE (1<<15) /* Instruction Cache Enable */ 57862306a36Sopenharmony_ci#define HID0_DCE (1<<14) /* Data Cache Enable */ 57962306a36Sopenharmony_ci#define HID0_ILOCK (1<<13) /* Instruction Cache Lock */ 58062306a36Sopenharmony_ci#define HID0_DLOCK (1<<12) /* Data Cache Lock */ 58162306a36Sopenharmony_ci#define HID0_ICFI (1<<11) /* Instr. Cache Flash Invalidate */ 58262306a36Sopenharmony_ci#define HID0_DCI (1<<10) /* Data Cache Invalidate */ 58362306a36Sopenharmony_ci#define HID0_SPD (1<<9) /* Speculative disable */ 58462306a36Sopenharmony_ci#define HID0_DAPUEN (1<<8) /* Debug APU enable */ 58562306a36Sopenharmony_ci#define HID0_SGE (1<<7) /* Store Gathering Enable */ 58662306a36Sopenharmony_ci#define HID0_SIED (1<<7) /* Serial Instr. Execution [Disable] */ 58762306a36Sopenharmony_ci#define HID0_DCFA (1<<6) /* Data Cache Flush Assist */ 58862306a36Sopenharmony_ci#define HID0_LRSTK (1<<4) /* Link register stack - 745x */ 58962306a36Sopenharmony_ci#define HID0_BTIC (1<<5) /* Branch Target Instr Cache Enable */ 59062306a36Sopenharmony_ci#define HID0_ABE (1<<3) /* Address Broadcast Enable */ 59162306a36Sopenharmony_ci#define HID0_FOLD (1<<3) /* Branch Folding enable - 745x */ 59262306a36Sopenharmony_ci#define HID0_BHTE (1<<2) /* Branch History Table Enable */ 59362306a36Sopenharmony_ci#define HID0_BTCD (1<<1) /* Branch target cache disable */ 59462306a36Sopenharmony_ci#define HID0_NOPDST (1<<1) /* No-op dst, dstt, etc. instr. */ 59562306a36Sopenharmony_ci#define HID0_NOPTI (1<<0) /* No-op dcbt and dcbst instr. */ 59662306a36Sopenharmony_ci/* POWER8 HID0 bits */ 59762306a36Sopenharmony_ci#define HID0_POWER8_4LPARMODE __MASK(61) 59862306a36Sopenharmony_ci#define HID0_POWER8_2LPARMODE __MASK(57) 59962306a36Sopenharmony_ci#define HID0_POWER8_1TO2LPAR __MASK(52) 60062306a36Sopenharmony_ci#define HID0_POWER8_1TO4LPAR __MASK(51) 60162306a36Sopenharmony_ci#define HID0_POWER8_DYNLPARDIS __MASK(48) 60262306a36Sopenharmony_ci 60362306a36Sopenharmony_ci/* POWER9 HID0 bits */ 60462306a36Sopenharmony_ci#define HID0_POWER9_RADIX __MASK(63 - 8) 60562306a36Sopenharmony_ci 60662306a36Sopenharmony_ci#define SPRN_HID1 0x3F1 /* Hardware Implementation Register 1 */ 60762306a36Sopenharmony_ci#ifdef CONFIG_PPC_BOOK3S_32 60862306a36Sopenharmony_ci#define HID1_EMCP (1<<31) /* 7450 Machine Check Pin Enable */ 60962306a36Sopenharmony_ci#define HID1_DFS (1<<22) /* 7447A Dynamic Frequency Scaling */ 61062306a36Sopenharmony_ci#define HID1_PC0 (1<<16) /* 7450 PLL_CFG[0] */ 61162306a36Sopenharmony_ci#define HID1_PC1 (1<<15) /* 7450 PLL_CFG[1] */ 61262306a36Sopenharmony_ci#define HID1_PC2 (1<<14) /* 7450 PLL_CFG[2] */ 61362306a36Sopenharmony_ci#define HID1_PC3 (1<<13) /* 7450 PLL_CFG[3] */ 61462306a36Sopenharmony_ci#define HID1_SYNCBE (1<<11) /* 7450 ABE for sync, eieio */ 61562306a36Sopenharmony_ci#define HID1_ABE (1<<10) /* 7450 Address Broadcast Enable */ 61662306a36Sopenharmony_ci#define HID1_PS (1<<16) /* 750FX PLL selection */ 61762306a36Sopenharmony_ci#endif 61862306a36Sopenharmony_ci#define SPRN_HID2 0x3F8 /* Hardware Implementation Register 2 */ 61962306a36Sopenharmony_ci#define SPRN_HID2_GEKKO 0x398 /* Gekko HID2 Register */ 62062306a36Sopenharmony_ci#define SPRN_HID2_G2_LE 0x3F3 /* G2_LE HID2 Register */ 62162306a36Sopenharmony_ci#define HID2_G2_LE_HBE (1<<18) /* High BAT Enable (G2_LE) */ 62262306a36Sopenharmony_ci#define SPRN_IABR 0x3F2 /* Instruction Address Breakpoint Register */ 62362306a36Sopenharmony_ci#define SPRN_IABR2 0x3FA /* 83xx */ 62462306a36Sopenharmony_ci#define SPRN_IBCR 0x135 /* 83xx Insn Breakpoint Control Reg */ 62562306a36Sopenharmony_ci#define SPRN_IAMR 0x03D /* Instr. Authority Mask Reg */ 62662306a36Sopenharmony_ci#define SPRN_HID4 0x3F4 /* 970 HID4 */ 62762306a36Sopenharmony_ci#define HID4_LPES0 (1ul << (63-0)) /* LPAR env. sel. bit 0 */ 62862306a36Sopenharmony_ci#define HID4_RMLS2_SH (63 - 2) /* Real mode limit bottom 2 bits */ 62962306a36Sopenharmony_ci#define HID4_LPID5_SH (63 - 6) /* partition ID bottom 4 bits */ 63062306a36Sopenharmony_ci#define HID4_RMOR_SH (63 - 22) /* real mode offset (16 bits) */ 63162306a36Sopenharmony_ci#define HID4_RMOR (0xFFFFul << HID4_RMOR_SH) 63262306a36Sopenharmony_ci#define HID4_LPES1 (1 << (63-57)) /* LPAR env. sel. bit 1 */ 63362306a36Sopenharmony_ci#define HID4_RMLS0_SH (63 - 58) /* Real mode limit top bit */ 63462306a36Sopenharmony_ci#define HID4_LPID1_SH 0 /* partition ID top 2 bits */ 63562306a36Sopenharmony_ci#define SPRN_HID4_GEKKO 0x3F3 /* Gekko HID4 */ 63662306a36Sopenharmony_ci#define SPRN_HID5 0x3F6 /* 970 HID5 */ 63762306a36Sopenharmony_ci#define SPRN_HID6 0x3F9 /* BE HID 6 */ 63862306a36Sopenharmony_ci#define HID6_LB (0x0F<<12) /* Concurrent Large Page Modes */ 63962306a36Sopenharmony_ci#define HID6_DLP (1<<20) /* Disable all large page modes (4K only) */ 64062306a36Sopenharmony_ci#define SPRN_TSC_CELL 0x399 /* Thread switch control on Cell */ 64162306a36Sopenharmony_ci#define TSC_CELL_DEC_ENABLE_0 0x400000 /* Decrementer Interrupt */ 64262306a36Sopenharmony_ci#define TSC_CELL_DEC_ENABLE_1 0x200000 /* Decrementer Interrupt */ 64362306a36Sopenharmony_ci#define TSC_CELL_EE_ENABLE 0x100000 /* External Interrupt */ 64462306a36Sopenharmony_ci#define TSC_CELL_EE_BOOST 0x080000 /* External Interrupt Boost */ 64562306a36Sopenharmony_ci#define SPRN_TSC 0x3FD /* Thread switch control on others */ 64662306a36Sopenharmony_ci#define SPRN_TST 0x3FC /* Thread switch timeout on others */ 64762306a36Sopenharmony_ci#if !defined(SPRN_IAC1) && !defined(SPRN_IAC2) 64862306a36Sopenharmony_ci#define SPRN_IAC1 0x3F4 /* Instruction Address Compare 1 */ 64962306a36Sopenharmony_ci#define SPRN_IAC2 0x3F5 /* Instruction Address Compare 2 */ 65062306a36Sopenharmony_ci#endif 65162306a36Sopenharmony_ci#define SPRN_IBAT0L 0x211 /* Instruction BAT 0 Lower Register */ 65262306a36Sopenharmony_ci#define SPRN_IBAT0U 0x210 /* Instruction BAT 0 Upper Register */ 65362306a36Sopenharmony_ci#define SPRN_IBAT1L 0x213 /* Instruction BAT 1 Lower Register */ 65462306a36Sopenharmony_ci#define SPRN_IBAT1U 0x212 /* Instruction BAT 1 Upper Register */ 65562306a36Sopenharmony_ci#define SPRN_IBAT2L 0x215 /* Instruction BAT 2 Lower Register */ 65662306a36Sopenharmony_ci#define SPRN_IBAT2U 0x214 /* Instruction BAT 2 Upper Register */ 65762306a36Sopenharmony_ci#define SPRN_IBAT3L 0x217 /* Instruction BAT 3 Lower Register */ 65862306a36Sopenharmony_ci#define SPRN_IBAT3U 0x216 /* Instruction BAT 3 Upper Register */ 65962306a36Sopenharmony_ci#define SPRN_IBAT4L 0x231 /* Instruction BAT 4 Lower Register */ 66062306a36Sopenharmony_ci#define SPRN_IBAT4U 0x230 /* Instruction BAT 4 Upper Register */ 66162306a36Sopenharmony_ci#define SPRN_IBAT5L 0x233 /* Instruction BAT 5 Lower Register */ 66262306a36Sopenharmony_ci#define SPRN_IBAT5U 0x232 /* Instruction BAT 5 Upper Register */ 66362306a36Sopenharmony_ci#define SPRN_IBAT6L 0x235 /* Instruction BAT 6 Lower Register */ 66462306a36Sopenharmony_ci#define SPRN_IBAT6U 0x234 /* Instruction BAT 6 Upper Register */ 66562306a36Sopenharmony_ci#define SPRN_IBAT7L 0x237 /* Instruction BAT 7 Lower Register */ 66662306a36Sopenharmony_ci#define SPRN_IBAT7U 0x236 /* Instruction BAT 7 Upper Register */ 66762306a36Sopenharmony_ci#define SPRN_ICMP 0x3D5 /* Instruction TLB Compare Register */ 66862306a36Sopenharmony_ci#define SPRN_ICTC 0x3FB /* Instruction Cache Throttling Control Reg */ 66962306a36Sopenharmony_ci#ifndef SPRN_ICTRL 67062306a36Sopenharmony_ci#define SPRN_ICTRL 0x3F3 /* 1011 7450 icache and interrupt ctrl */ 67162306a36Sopenharmony_ci#endif 67262306a36Sopenharmony_ci#define ICTRL_EICE 0x08000000 /* enable icache parity errs */ 67362306a36Sopenharmony_ci#define ICTRL_EDC 0x04000000 /* enable dcache parity errs */ 67462306a36Sopenharmony_ci#define ICTRL_EICP 0x00000100 /* enable icache par. check */ 67562306a36Sopenharmony_ci#define SPRN_IMISS 0x3D4 /* Instruction TLB Miss Register */ 67662306a36Sopenharmony_ci#define SPRN_IMMR 0x27E /* Internal Memory Map Register */ 67762306a36Sopenharmony_ci#define SPRN_L2CR 0x3F9 /* Level 2 Cache Control Register */ 67862306a36Sopenharmony_ci#define SPRN_L2CR2 0x3f8 67962306a36Sopenharmony_ci#define L2CR_L2E 0x80000000 /* L2 enable */ 68062306a36Sopenharmony_ci#define L2CR_L2PE 0x40000000 /* L2 parity enable */ 68162306a36Sopenharmony_ci#define L2CR_L2SIZ_MASK 0x30000000 /* L2 size mask */ 68262306a36Sopenharmony_ci#define L2CR_L2SIZ_256KB 0x10000000 /* L2 size 256KB */ 68362306a36Sopenharmony_ci#define L2CR_L2SIZ_512KB 0x20000000 /* L2 size 512KB */ 68462306a36Sopenharmony_ci#define L2CR_L2SIZ_1MB 0x30000000 /* L2 size 1MB */ 68562306a36Sopenharmony_ci#define L2CR_L2CLK_MASK 0x0e000000 /* L2 clock mask */ 68662306a36Sopenharmony_ci#define L2CR_L2CLK_DISABLED 0x00000000 /* L2 clock disabled */ 68762306a36Sopenharmony_ci#define L2CR_L2CLK_DIV1 0x02000000 /* L2 clock / 1 */ 68862306a36Sopenharmony_ci#define L2CR_L2CLK_DIV1_5 0x04000000 /* L2 clock / 1.5 */ 68962306a36Sopenharmony_ci#define L2CR_L2CLK_DIV2 0x08000000 /* L2 clock / 2 */ 69062306a36Sopenharmony_ci#define L2CR_L2CLK_DIV2_5 0x0a000000 /* L2 clock / 2.5 */ 69162306a36Sopenharmony_ci#define L2CR_L2CLK_DIV3 0x0c000000 /* L2 clock / 3 */ 69262306a36Sopenharmony_ci#define L2CR_L2RAM_MASK 0x01800000 /* L2 RAM type mask */ 69362306a36Sopenharmony_ci#define L2CR_L2RAM_FLOW 0x00000000 /* L2 RAM flow through */ 69462306a36Sopenharmony_ci#define L2CR_L2RAM_PIPE 0x01000000 /* L2 RAM pipelined */ 69562306a36Sopenharmony_ci#define L2CR_L2RAM_PIPE_LW 0x01800000 /* L2 RAM pipelined latewr */ 69662306a36Sopenharmony_ci#define L2CR_L2DO 0x00400000 /* L2 data only */ 69762306a36Sopenharmony_ci#define L2CR_L2I 0x00200000 /* L2 global invalidate */ 69862306a36Sopenharmony_ci#define L2CR_L2CTL 0x00100000 /* L2 RAM control */ 69962306a36Sopenharmony_ci#define L2CR_L2WT 0x00080000 /* L2 write-through */ 70062306a36Sopenharmony_ci#define L2CR_L2TS 0x00040000 /* L2 test support */ 70162306a36Sopenharmony_ci#define L2CR_L2OH_MASK 0x00030000 /* L2 output hold mask */ 70262306a36Sopenharmony_ci#define L2CR_L2OH_0_5 0x00000000 /* L2 output hold 0.5 ns */ 70362306a36Sopenharmony_ci#define L2CR_L2OH_1_0 0x00010000 /* L2 output hold 1.0 ns */ 70462306a36Sopenharmony_ci#define L2CR_L2SL 0x00008000 /* L2 DLL slow */ 70562306a36Sopenharmony_ci#define L2CR_L2DF 0x00004000 /* L2 differential clock */ 70662306a36Sopenharmony_ci#define L2CR_L2BYP 0x00002000 /* L2 DLL bypass */ 70762306a36Sopenharmony_ci#define L2CR_L2IP 0x00000001 /* L2 GI in progress */ 70862306a36Sopenharmony_ci#define L2CR_L2IO_745x 0x00100000 /* L2 instr. only (745x) */ 70962306a36Sopenharmony_ci#define L2CR_L2DO_745x 0x00010000 /* L2 data only (745x) */ 71062306a36Sopenharmony_ci#define L2CR_L2REP_745x 0x00001000 /* L2 repl. algorithm (745x) */ 71162306a36Sopenharmony_ci#define L2CR_L2HWF_745x 0x00000800 /* L2 hardware flush (745x) */ 71262306a36Sopenharmony_ci#define SPRN_L3CR 0x3FA /* Level 3 Cache Control Register */ 71362306a36Sopenharmony_ci#define L3CR_L3E 0x80000000 /* L3 enable */ 71462306a36Sopenharmony_ci#define L3CR_L3PE 0x40000000 /* L3 data parity enable */ 71562306a36Sopenharmony_ci#define L3CR_L3APE 0x20000000 /* L3 addr parity enable */ 71662306a36Sopenharmony_ci#define L3CR_L3SIZ 0x10000000 /* L3 size */ 71762306a36Sopenharmony_ci#define L3CR_L3CLKEN 0x08000000 /* L3 clock enable */ 71862306a36Sopenharmony_ci#define L3CR_L3RES 0x04000000 /* L3 special reserved bit */ 71962306a36Sopenharmony_ci#define L3CR_L3CLKDIV 0x03800000 /* L3 clock divisor */ 72062306a36Sopenharmony_ci#define L3CR_L3IO 0x00400000 /* L3 instruction only */ 72162306a36Sopenharmony_ci#define L3CR_L3SPO 0x00040000 /* L3 sample point override */ 72262306a36Sopenharmony_ci#define L3CR_L3CKSP 0x00030000 /* L3 clock sample point */ 72362306a36Sopenharmony_ci#define L3CR_L3PSP 0x0000e000 /* L3 P-clock sample point */ 72462306a36Sopenharmony_ci#define L3CR_L3REP 0x00001000 /* L3 replacement algorithm */ 72562306a36Sopenharmony_ci#define L3CR_L3HWF 0x00000800 /* L3 hardware flush */ 72662306a36Sopenharmony_ci#define L3CR_L3I 0x00000400 /* L3 global invalidate */ 72762306a36Sopenharmony_ci#define L3CR_L3RT 0x00000300 /* L3 SRAM type */ 72862306a36Sopenharmony_ci#define L3CR_L3NIRCA 0x00000080 /* L3 non-integer ratio clock adj. */ 72962306a36Sopenharmony_ci#define L3CR_L3DO 0x00000040 /* L3 data only mode */ 73062306a36Sopenharmony_ci#define L3CR_PMEN 0x00000004 /* L3 private memory enable */ 73162306a36Sopenharmony_ci#define L3CR_PMSIZ 0x00000001 /* L3 private memory size */ 73262306a36Sopenharmony_ci 73362306a36Sopenharmony_ci#define SPRN_MSSCR0 0x3f6 /* Memory Subsystem Control Register 0 */ 73462306a36Sopenharmony_ci#define SPRN_MSSSR0 0x3f7 /* Memory Subsystem Status Register 1 */ 73562306a36Sopenharmony_ci#define SPRN_LDSTCR 0x3f8 /* Load/Store control register */ 73662306a36Sopenharmony_ci#define SPRN_LDSTDB 0x3f4 /* */ 73762306a36Sopenharmony_ci#define SPRN_LR 0x008 /* Link Register */ 73862306a36Sopenharmony_ci#ifndef SPRN_PIR 73962306a36Sopenharmony_ci#define SPRN_PIR 0x3FF /* Processor Identification Register */ 74062306a36Sopenharmony_ci#endif 74162306a36Sopenharmony_ci#define SPRN_TIR 0x1BE /* Thread Identification Register */ 74262306a36Sopenharmony_ci#define SPRN_PTCR 0x1D0 /* Partition table control Register */ 74362306a36Sopenharmony_ci#define SPRN_PSPB 0x09F /* Problem State Priority Boost reg */ 74462306a36Sopenharmony_ci#define SPRN_PTEHI 0x3D5 /* 981 7450 PTE HI word (S/W TLB load) */ 74562306a36Sopenharmony_ci#define SPRN_PTELO 0x3D6 /* 982 7450 PTE LO word (S/W TLB load) */ 74662306a36Sopenharmony_ci#define SPRN_PURR 0x135 /* Processor Utilization of Resources Reg */ 74762306a36Sopenharmony_ci#define SPRN_PVR 0x11F /* Processor Version Register */ 74862306a36Sopenharmony_ci#define SPRN_RPA 0x3D6 /* Required Physical Address Register */ 74962306a36Sopenharmony_ci#define SPRN_SDA 0x3BF /* Sampled Data Address Register */ 75062306a36Sopenharmony_ci#define SPRN_SDR1 0x019 /* MMU Hash Base Register */ 75162306a36Sopenharmony_ci#define SPRN_ASR 0x118 /* Address Space Register */ 75262306a36Sopenharmony_ci#define SPRN_SIA 0x3BB /* Sampled Instruction Address Register */ 75362306a36Sopenharmony_ci#define SPRN_SPRG0 0x110 /* Special Purpose Register General 0 */ 75462306a36Sopenharmony_ci#define SPRN_SPRG1 0x111 /* Special Purpose Register General 1 */ 75562306a36Sopenharmony_ci#define SPRN_SPRG2 0x112 /* Special Purpose Register General 2 */ 75662306a36Sopenharmony_ci#define SPRN_SPRG3 0x113 /* Special Purpose Register General 3 */ 75762306a36Sopenharmony_ci#define SPRN_USPRG3 0x103 /* SPRG3 userspace read */ 75862306a36Sopenharmony_ci#define SPRN_SPRG4 0x114 /* Special Purpose Register General 4 */ 75962306a36Sopenharmony_ci#define SPRN_USPRG4 0x104 /* SPRG4 userspace read */ 76062306a36Sopenharmony_ci#define SPRN_SPRG5 0x115 /* Special Purpose Register General 5 */ 76162306a36Sopenharmony_ci#define SPRN_USPRG5 0x105 /* SPRG5 userspace read */ 76262306a36Sopenharmony_ci#define SPRN_SPRG6 0x116 /* Special Purpose Register General 6 */ 76362306a36Sopenharmony_ci#define SPRN_USPRG6 0x106 /* SPRG6 userspace read */ 76462306a36Sopenharmony_ci#define SPRN_SPRG7 0x117 /* Special Purpose Register General 7 */ 76562306a36Sopenharmony_ci#define SPRN_USPRG7 0x107 /* SPRG7 userspace read */ 76662306a36Sopenharmony_ci#define SPRN_SRR0 0x01A /* Save/Restore Register 0 */ 76762306a36Sopenharmony_ci#define SPRN_SRR1 0x01B /* Save/Restore Register 1 */ 76862306a36Sopenharmony_ci 76962306a36Sopenharmony_ci#ifdef CONFIG_PPC_BOOK3S 77062306a36Sopenharmony_ci/* 77162306a36Sopenharmony_ci * Bits loaded from MSR upon interrupt. 77262306a36Sopenharmony_ci * PPC (64-bit) bits 33-36,42-47 are interrupt dependent, the others are 77362306a36Sopenharmony_ci * loaded from MSR. The exception is that SRESET and MCE do not always load 77462306a36Sopenharmony_ci * bit 62 (RI) from MSR. Don't use PPC_BITMASK for this because 32-bit uses 77562306a36Sopenharmony_ci * it. 77662306a36Sopenharmony_ci */ 77762306a36Sopenharmony_ci#define SRR1_MSR_BITS (~0x783f0000UL) 77862306a36Sopenharmony_ci#endif 77962306a36Sopenharmony_ci 78062306a36Sopenharmony_ci#define SRR1_ISI_NOPT 0x40000000 /* ISI: Not found in hash */ 78162306a36Sopenharmony_ci#define SRR1_ISI_N_G_OR_CIP 0x10000000 /* ISI: Access is no-exec or G or CI for a prefixed instruction */ 78262306a36Sopenharmony_ci#define SRR1_ISI_PROT 0x08000000 /* ISI: Other protection fault */ 78362306a36Sopenharmony_ci#define SRR1_WAKEMASK 0x00380000 /* reason for wakeup */ 78462306a36Sopenharmony_ci#define SRR1_WAKEMASK_P8 0x003c0000 /* reason for wakeup on POWER8 and 9 */ 78562306a36Sopenharmony_ci#define SRR1_WAKEMCE_RESVD 0x003c0000 /* Unused/reserved value used by MCE wakeup to indicate cause to idle wakeup handler */ 78662306a36Sopenharmony_ci#define SRR1_WAKESYSERR 0x00300000 /* System error */ 78762306a36Sopenharmony_ci#define SRR1_WAKEEE 0x00200000 /* External interrupt */ 78862306a36Sopenharmony_ci#define SRR1_WAKEHVI 0x00240000 /* Hypervisor Virtualization Interrupt (P9) */ 78962306a36Sopenharmony_ci#define SRR1_WAKEMT 0x00280000 /* mtctrl */ 79062306a36Sopenharmony_ci#define SRR1_WAKEHMI 0x00280000 /* Hypervisor maintenance */ 79162306a36Sopenharmony_ci#define SRR1_WAKEDEC 0x00180000 /* Decrementer interrupt */ 79262306a36Sopenharmony_ci#define SRR1_WAKEDBELL 0x00140000 /* Privileged doorbell on P8 */ 79362306a36Sopenharmony_ci#define SRR1_WAKETHERM 0x00100000 /* Thermal management interrupt */ 79462306a36Sopenharmony_ci#define SRR1_WAKERESET 0x00100000 /* System reset */ 79562306a36Sopenharmony_ci#define SRR1_WAKEHDBELL 0x000c0000 /* Hypervisor doorbell on P8 */ 79662306a36Sopenharmony_ci#define SRR1_WAKESTATE 0x00030000 /* Powersave exit mask [46:47] */ 79762306a36Sopenharmony_ci#define SRR1_WS_HVLOSS 0x00030000 /* HV resources not maintained */ 79862306a36Sopenharmony_ci#define SRR1_WS_GPRLOSS 0x00020000 /* GPRs not maintained */ 79962306a36Sopenharmony_ci#define SRR1_WS_NOLOSS 0x00010000 /* All resources maintained */ 80062306a36Sopenharmony_ci#define SRR1_PROGTM 0x00200000 /* TM Bad Thing */ 80162306a36Sopenharmony_ci#define SRR1_PROGFPE 0x00100000 /* Floating Point Enabled */ 80262306a36Sopenharmony_ci#define SRR1_PROGILL 0x00080000 /* Illegal instruction */ 80362306a36Sopenharmony_ci#define SRR1_PROGPRIV 0x00040000 /* Privileged instruction */ 80462306a36Sopenharmony_ci#define SRR1_PROGTRAP 0x00020000 /* Trap */ 80562306a36Sopenharmony_ci#define SRR1_PROGADDR 0x00010000 /* SRR0 contains subsequent addr */ 80662306a36Sopenharmony_ci 80762306a36Sopenharmony_ci#define SRR1_MCE_MCP 0x00080000 /* Machine check signal caused interrupt */ 80862306a36Sopenharmony_ci#define SRR1_BOUNDARY 0x10000000 /* Prefixed instruction crosses 64-byte boundary */ 80962306a36Sopenharmony_ci#define SRR1_PREFIXED 0x20000000 /* Exception caused by prefixed instruction */ 81062306a36Sopenharmony_ci 81162306a36Sopenharmony_ci#define SPRN_HSRR0 0x13A /* Save/Restore Register 0 */ 81262306a36Sopenharmony_ci#define SPRN_HSRR1 0x13B /* Save/Restore Register 1 */ 81362306a36Sopenharmony_ci#define HSRR1_DENORM 0x00100000 /* Denorm exception */ 81462306a36Sopenharmony_ci#define HSRR1_HISI_WRITE 0x00010000 /* HISI bcs couldn't update mem */ 81562306a36Sopenharmony_ci 81662306a36Sopenharmony_ci#define SPRN_TBCTL 0x35f /* PA6T Timebase control register */ 81762306a36Sopenharmony_ci#define TBCTL_FREEZE 0x0000000000000000ull /* Freeze all tbs */ 81862306a36Sopenharmony_ci#define TBCTL_RESTART 0x0000000100000000ull /* Restart all tbs */ 81962306a36Sopenharmony_ci#define TBCTL_UPDATE_UPPER 0x0000000200000000ull /* Set upper 32 bits */ 82062306a36Sopenharmony_ci#define TBCTL_UPDATE_LOWER 0x0000000300000000ull /* Set lower 32 bits */ 82162306a36Sopenharmony_ci 82262306a36Sopenharmony_ci#ifndef SPRN_SVR 82362306a36Sopenharmony_ci#define SPRN_SVR 0x11E /* System Version Register */ 82462306a36Sopenharmony_ci#endif 82562306a36Sopenharmony_ci#define SPRN_THRM1 0x3FC /* Thermal Management Register 1 */ 82662306a36Sopenharmony_ci/* these bits were defined in inverted endian sense originally, ugh, confusing */ 82762306a36Sopenharmony_ci#define THRM1_TIN (1 << 31) 82862306a36Sopenharmony_ci#define THRM1_TIV (1 << 30) 82962306a36Sopenharmony_ci#define THRM1_THRES(x) ((x&0x7f)<<23) 83062306a36Sopenharmony_ci#define THRM3_SITV(x) ((x & 0x1fff) << 1) 83162306a36Sopenharmony_ci#define THRM1_TID (1<<2) 83262306a36Sopenharmony_ci#define THRM1_TIE (1<<1) 83362306a36Sopenharmony_ci#define THRM1_V (1<<0) 83462306a36Sopenharmony_ci#define SPRN_THRM2 0x3FD /* Thermal Management Register 2 */ 83562306a36Sopenharmony_ci#define SPRN_THRM3 0x3FE /* Thermal Management Register 3 */ 83662306a36Sopenharmony_ci#define THRM3_E (1<<0) 83762306a36Sopenharmony_ci#define SPRN_TLBMISS 0x3D4 /* 980 7450 TLB Miss Register */ 83862306a36Sopenharmony_ci#define SPRN_UMMCR0 0x3A8 /* User Monitor Mode Control Register 0 */ 83962306a36Sopenharmony_ci#define SPRN_UMMCR1 0x3AC /* User Monitor Mode Control Register 0 */ 84062306a36Sopenharmony_ci#define SPRN_UPMC1 0x3A9 /* User Performance Counter Register 1 */ 84162306a36Sopenharmony_ci#define SPRN_UPMC2 0x3AA /* User Performance Counter Register 2 */ 84262306a36Sopenharmony_ci#define SPRN_UPMC3 0x3AD /* User Performance Counter Register 3 */ 84362306a36Sopenharmony_ci#define SPRN_UPMC4 0x3AE /* User Performance Counter Register 4 */ 84462306a36Sopenharmony_ci#define SPRN_USIA 0x3AB /* User Sampled Instruction Address Register */ 84562306a36Sopenharmony_ci#define SPRN_VRSAVE 0x100 /* Vector Register Save Register */ 84662306a36Sopenharmony_ci#define SPRN_XER 0x001 /* Fixed Point Exception Register */ 84762306a36Sopenharmony_ci 84862306a36Sopenharmony_ci#define SPRN_MMCR0_GEKKO 0x3B8 /* Gekko Monitor Mode Control Register 0 */ 84962306a36Sopenharmony_ci#define SPRN_MMCR1_GEKKO 0x3BC /* Gekko Monitor Mode Control Register 1 */ 85062306a36Sopenharmony_ci#define SPRN_PMC1_GEKKO 0x3B9 /* Gekko Performance Monitor Control 1 */ 85162306a36Sopenharmony_ci#define SPRN_PMC2_GEKKO 0x3BA /* Gekko Performance Monitor Control 2 */ 85262306a36Sopenharmony_ci#define SPRN_PMC3_GEKKO 0x3BD /* Gekko Performance Monitor Control 3 */ 85362306a36Sopenharmony_ci#define SPRN_PMC4_GEKKO 0x3BE /* Gekko Performance Monitor Control 4 */ 85462306a36Sopenharmony_ci#define SPRN_WPAR_GEKKO 0x399 /* Gekko Write Pipe Address Register */ 85562306a36Sopenharmony_ci 85662306a36Sopenharmony_ci#define SPRN_SCOMC 0x114 /* SCOM Access Control */ 85762306a36Sopenharmony_ci#define SPRN_SCOMD 0x115 /* SCOM Access DATA */ 85862306a36Sopenharmony_ci 85962306a36Sopenharmony_ci/* Performance monitor SPRs */ 86062306a36Sopenharmony_ci#ifdef CONFIG_PPC64 86162306a36Sopenharmony_ci#define SPRN_MMCR0 795 86262306a36Sopenharmony_ci#define MMCR0_FC 0x80000000UL /* freeze counters */ 86362306a36Sopenharmony_ci#define MMCR0_FCS 0x40000000UL /* freeze in supervisor state */ 86462306a36Sopenharmony_ci#define MMCR0_KERNEL_DISABLE MMCR0_FCS 86562306a36Sopenharmony_ci#define MMCR0_FCP 0x20000000UL /* freeze in problem state */ 86662306a36Sopenharmony_ci#define MMCR0_PROBLEM_DISABLE MMCR0_FCP 86762306a36Sopenharmony_ci#define MMCR0_FCM1 0x10000000UL /* freeze counters while MSR mark = 1 */ 86862306a36Sopenharmony_ci#define MMCR0_FCM0 0x08000000UL /* freeze counters while MSR mark = 0 */ 86962306a36Sopenharmony_ci#define MMCR0_PMXE ASM_CONST(0x04000000) /* perf mon exception enable */ 87062306a36Sopenharmony_ci#define MMCR0_FCECE ASM_CONST(0x02000000) /* freeze ctrs on enabled cond or event */ 87162306a36Sopenharmony_ci#define MMCR0_TBEE 0x00400000UL /* time base exception enable */ 87262306a36Sopenharmony_ci#define MMCR0_BHRBA 0x00200000UL /* BHRB Access allowed in userspace */ 87362306a36Sopenharmony_ci#define MMCR0_EBE 0x00100000UL /* Event based branch enable */ 87462306a36Sopenharmony_ci#define MMCR0_PMCC 0x000c0000UL /* PMC control */ 87562306a36Sopenharmony_ci#define MMCR0_PMCCEXT ASM_CONST(0x00000200) /* PMCCEXT control */ 87662306a36Sopenharmony_ci#define MMCR0_PMCC_U6 0x00080000UL /* PMC1-6 are R/W by user (PR) */ 87762306a36Sopenharmony_ci#define MMCR0_PMC1CE 0x00008000UL /* PMC1 count enable*/ 87862306a36Sopenharmony_ci#define MMCR0_PMCjCE ASM_CONST(0x00004000) /* PMCj count enable*/ 87962306a36Sopenharmony_ci#define MMCR0_TRIGGER 0x00002000UL /* TRIGGER enable */ 88062306a36Sopenharmony_ci#define MMCR0_PMAO_SYNC ASM_CONST(0x00000800) /* PMU intr is synchronous */ 88162306a36Sopenharmony_ci#define MMCR0_C56RUN ASM_CONST(0x00000100) /* PMC5/6 count when RUN=0 */ 88262306a36Sopenharmony_ci/* performance monitor alert has occurred, set to 0 after handling exception */ 88362306a36Sopenharmony_ci#define MMCR0_PMAO ASM_CONST(0x00000080) 88462306a36Sopenharmony_ci#define MMCR0_SHRFC 0x00000040UL /* SHRre freeze conditions between threads */ 88562306a36Sopenharmony_ci#define MMCR0_FC56 0x00000010UL /* freeze counters 5 and 6 */ 88662306a36Sopenharmony_ci#define MMCR0_FCTI 0x00000008UL /* freeze counters in tags inactive mode */ 88762306a36Sopenharmony_ci#define MMCR0_FCTA 0x00000004UL /* freeze counters in tags active mode */ 88862306a36Sopenharmony_ci#define MMCR0_FCWAIT 0x00000002UL /* freeze counter in WAIT state */ 88962306a36Sopenharmony_ci#define MMCR0_FCHV 0x00000001UL /* freeze conditions in hypervisor mode */ 89062306a36Sopenharmony_ci#define SPRN_MMCR1 798 89162306a36Sopenharmony_ci#define SPRN_MMCR2 785 89262306a36Sopenharmony_ci#define SPRN_MMCR3 754 89362306a36Sopenharmony_ci#define SPRN_UMMCR2 769 89462306a36Sopenharmony_ci#define SPRN_UMMCR3 738 89562306a36Sopenharmony_ci#define SPRN_MMCRA 0x312 89662306a36Sopenharmony_ci#define MMCRA_SDSYNC 0x80000000UL /* SDAR synced with SIAR */ 89762306a36Sopenharmony_ci#define MMCRA_SDAR_DCACHE_MISS 0x40000000UL 89862306a36Sopenharmony_ci#define MMCRA_SDAR_ERAT_MISS 0x20000000UL 89962306a36Sopenharmony_ci#define MMCRA_SIHV 0x10000000UL /* state of MSR HV when SIAR set */ 90062306a36Sopenharmony_ci#define MMCRA_SIPR 0x08000000UL /* state of MSR PR when SIAR set */ 90162306a36Sopenharmony_ci#define MMCRA_SLOT 0x07000000UL /* SLOT bits (37-39) */ 90262306a36Sopenharmony_ci#define MMCRA_SLOT_SHIFT 24 90362306a36Sopenharmony_ci#define MMCRA_SAMPLE_ENABLE 0x00000001UL /* enable sampling */ 90462306a36Sopenharmony_ci#define MMCRA_BHRB_DISABLE _UL(0x2000000000) // BHRB disable bit for ISA v3.1 90562306a36Sopenharmony_ci#define POWER6_MMCRA_SDSYNC 0x0000080000000000ULL /* SDAR/SIAR synced */ 90662306a36Sopenharmony_ci#define POWER6_MMCRA_SIHV 0x0000040000000000ULL 90762306a36Sopenharmony_ci#define POWER6_MMCRA_SIPR 0x0000020000000000ULL 90862306a36Sopenharmony_ci#define POWER6_MMCRA_THRM 0x00000020UL 90962306a36Sopenharmony_ci#define POWER6_MMCRA_OTHER 0x0000000EUL 91062306a36Sopenharmony_ci 91162306a36Sopenharmony_ci#define POWER7P_MMCRA_SIAR_VALID 0x10000000 /* P7+ SIAR contents valid */ 91262306a36Sopenharmony_ci#define POWER7P_MMCRA_SDAR_VALID 0x08000000 /* P7+ SDAR contents valid */ 91362306a36Sopenharmony_ci 91462306a36Sopenharmony_ci#define SPRN_MMCRH 316 /* Hypervisor monitor mode control register */ 91562306a36Sopenharmony_ci#define SPRN_MMCRS 894 /* Supervisor monitor mode control register */ 91662306a36Sopenharmony_ci#define SPRN_MMCRC 851 /* Core monitor mode control register */ 91762306a36Sopenharmony_ci#define SPRN_EBBHR 804 /* Event based branch handler register */ 91862306a36Sopenharmony_ci#define SPRN_EBBRR 805 /* Event based branch return register */ 91962306a36Sopenharmony_ci#define SPRN_BESCR 806 /* Branch event status and control register */ 92062306a36Sopenharmony_ci#define BESCR_GE 0x8000000000000000ULL /* Global Enable */ 92162306a36Sopenharmony_ci#define SPRN_WORT 895 /* Workload optimization register - thread */ 92262306a36Sopenharmony_ci#define SPRN_WORC 863 /* Workload optimization register - core */ 92362306a36Sopenharmony_ci 92462306a36Sopenharmony_ci#define SPRN_PMC1 787 92562306a36Sopenharmony_ci#define SPRN_PMC2 788 92662306a36Sopenharmony_ci#define SPRN_PMC3 789 92762306a36Sopenharmony_ci#define SPRN_PMC4 790 92862306a36Sopenharmony_ci#define SPRN_PMC5 791 92962306a36Sopenharmony_ci#define SPRN_PMC6 792 93062306a36Sopenharmony_ci#define SPRN_PMC7 793 93162306a36Sopenharmony_ci#define SPRN_PMC8 794 93262306a36Sopenharmony_ci#define SPRN_SIER 784 93362306a36Sopenharmony_ci#define SIER_SIPR 0x2000000 /* Sampled MSR_PR */ 93462306a36Sopenharmony_ci#define SIER_SIHV 0x1000000 /* Sampled MSR_HV */ 93562306a36Sopenharmony_ci#define SIER_SIAR_VALID 0x0400000 /* SIAR contents valid */ 93662306a36Sopenharmony_ci#define SIER_SDAR_VALID 0x0200000 /* SDAR contents valid */ 93762306a36Sopenharmony_ci#define SPRN_SIER2 752 93862306a36Sopenharmony_ci#define SPRN_SIER3 753 93962306a36Sopenharmony_ci#define SPRN_USIER2 736 94062306a36Sopenharmony_ci#define SPRN_USIER3 737 94162306a36Sopenharmony_ci#define SPRN_SIAR 796 94262306a36Sopenharmony_ci#define SPRN_SDAR 797 94362306a36Sopenharmony_ci#define SPRN_TACR 888 94462306a36Sopenharmony_ci#define SPRN_TCSCR 889 94562306a36Sopenharmony_ci#define SPRN_CSIGR 890 94662306a36Sopenharmony_ci#define SPRN_SPMC1 892 94762306a36Sopenharmony_ci#define SPRN_SPMC2 893 94862306a36Sopenharmony_ci 94962306a36Sopenharmony_ci/* When EBB is enabled, some of MMCR0/MMCR2/SIER are user accessible */ 95062306a36Sopenharmony_ci#define MMCR0_USER_MASK (MMCR0_FC | MMCR0_PMXE | MMCR0_PMAO) 95162306a36Sopenharmony_ci#define MMCR2_USER_MASK 0x4020100804020000UL /* (FC1P|FC2P|FC3P|FC4P|FC5P|FC6P) */ 95262306a36Sopenharmony_ci#define SIER_USER_MASK 0x7fffffUL 95362306a36Sopenharmony_ci 95462306a36Sopenharmony_ci#define SPRN_PA6T_MMCR0 795 95562306a36Sopenharmony_ci#define PA6T_MMCR0_EN0 0x0000000000000001UL 95662306a36Sopenharmony_ci#define PA6T_MMCR0_EN1 0x0000000000000002UL 95762306a36Sopenharmony_ci#define PA6T_MMCR0_EN2 0x0000000000000004UL 95862306a36Sopenharmony_ci#define PA6T_MMCR0_EN3 0x0000000000000008UL 95962306a36Sopenharmony_ci#define PA6T_MMCR0_EN4 0x0000000000000010UL 96062306a36Sopenharmony_ci#define PA6T_MMCR0_EN5 0x0000000000000020UL 96162306a36Sopenharmony_ci#define PA6T_MMCR0_SUPEN 0x0000000000000040UL 96262306a36Sopenharmony_ci#define PA6T_MMCR0_PREN 0x0000000000000080UL 96362306a36Sopenharmony_ci#define PA6T_MMCR0_HYPEN 0x0000000000000100UL 96462306a36Sopenharmony_ci#define PA6T_MMCR0_FCM0 0x0000000000000200UL 96562306a36Sopenharmony_ci#define PA6T_MMCR0_FCM1 0x0000000000000400UL 96662306a36Sopenharmony_ci#define PA6T_MMCR0_INTGEN 0x0000000000000800UL 96762306a36Sopenharmony_ci#define PA6T_MMCR0_INTEN0 0x0000000000001000UL 96862306a36Sopenharmony_ci#define PA6T_MMCR0_INTEN1 0x0000000000002000UL 96962306a36Sopenharmony_ci#define PA6T_MMCR0_INTEN2 0x0000000000004000UL 97062306a36Sopenharmony_ci#define PA6T_MMCR0_INTEN3 0x0000000000008000UL 97162306a36Sopenharmony_ci#define PA6T_MMCR0_INTEN4 0x0000000000010000UL 97262306a36Sopenharmony_ci#define PA6T_MMCR0_INTEN5 0x0000000000020000UL 97362306a36Sopenharmony_ci#define PA6T_MMCR0_DISCNT 0x0000000000040000UL 97462306a36Sopenharmony_ci#define PA6T_MMCR0_UOP 0x0000000000080000UL 97562306a36Sopenharmony_ci#define PA6T_MMCR0_TRG 0x0000000000100000UL 97662306a36Sopenharmony_ci#define PA6T_MMCR0_TRGEN 0x0000000000200000UL 97762306a36Sopenharmony_ci#define PA6T_MMCR0_TRGREG 0x0000000001600000UL 97862306a36Sopenharmony_ci#define PA6T_MMCR0_SIARLOG 0x0000000002000000UL 97962306a36Sopenharmony_ci#define PA6T_MMCR0_SDARLOG 0x0000000004000000UL 98062306a36Sopenharmony_ci#define PA6T_MMCR0_PROEN 0x0000000008000000UL 98162306a36Sopenharmony_ci#define PA6T_MMCR0_PROLOG 0x0000000010000000UL 98262306a36Sopenharmony_ci#define PA6T_MMCR0_DAMEN2 0x0000000020000000UL 98362306a36Sopenharmony_ci#define PA6T_MMCR0_DAMEN3 0x0000000040000000UL 98462306a36Sopenharmony_ci#define PA6T_MMCR0_DAMEN4 0x0000000080000000UL 98562306a36Sopenharmony_ci#define PA6T_MMCR0_DAMEN5 0x0000000100000000UL 98662306a36Sopenharmony_ci#define PA6T_MMCR0_DAMSEL2 0x0000000200000000UL 98762306a36Sopenharmony_ci#define PA6T_MMCR0_DAMSEL3 0x0000000400000000UL 98862306a36Sopenharmony_ci#define PA6T_MMCR0_DAMSEL4 0x0000000800000000UL 98962306a36Sopenharmony_ci#define PA6T_MMCR0_DAMSEL5 0x0000001000000000UL 99062306a36Sopenharmony_ci#define PA6T_MMCR0_HANDDIS 0x0000002000000000UL 99162306a36Sopenharmony_ci#define PA6T_MMCR0_PCTEN 0x0000004000000000UL 99262306a36Sopenharmony_ci#define PA6T_MMCR0_SOCEN 0x0000008000000000UL 99362306a36Sopenharmony_ci#define PA6T_MMCR0_SOCMOD 0x0000010000000000UL 99462306a36Sopenharmony_ci 99562306a36Sopenharmony_ci#define SPRN_PA6T_MMCR1 798 99662306a36Sopenharmony_ci#define PA6T_MMCR1_ES2 0x00000000000000ffUL 99762306a36Sopenharmony_ci#define PA6T_MMCR1_ES3 0x000000000000ff00UL 99862306a36Sopenharmony_ci#define PA6T_MMCR1_ES4 0x0000000000ff0000UL 99962306a36Sopenharmony_ci#define PA6T_MMCR1_ES5 0x00000000ff000000UL 100062306a36Sopenharmony_ci 100162306a36Sopenharmony_ci#define SPRN_PA6T_UPMC0 771 /* User PerfMon Counter 0 */ 100262306a36Sopenharmony_ci#define SPRN_PA6T_UPMC1 772 /* ... */ 100362306a36Sopenharmony_ci#define SPRN_PA6T_UPMC2 773 100462306a36Sopenharmony_ci#define SPRN_PA6T_UPMC3 774 100562306a36Sopenharmony_ci#define SPRN_PA6T_UPMC4 775 100662306a36Sopenharmony_ci#define SPRN_PA6T_UPMC5 776 100762306a36Sopenharmony_ci#define SPRN_PA6T_UMMCR0 779 /* User Monitor Mode Control Register 0 */ 100862306a36Sopenharmony_ci#define SPRN_PA6T_SIAR 780 /* Sampled Instruction Address */ 100962306a36Sopenharmony_ci#define SPRN_PA6T_UMMCR1 782 /* User Monitor Mode Control Register 1 */ 101062306a36Sopenharmony_ci#define SPRN_PA6T_SIER 785 /* Sampled Instruction Event Register */ 101162306a36Sopenharmony_ci#define SPRN_PA6T_PMC0 787 101262306a36Sopenharmony_ci#define SPRN_PA6T_PMC1 788 101362306a36Sopenharmony_ci#define SPRN_PA6T_PMC2 789 101462306a36Sopenharmony_ci#define SPRN_PA6T_PMC3 790 101562306a36Sopenharmony_ci#define SPRN_PA6T_PMC4 791 101662306a36Sopenharmony_ci#define SPRN_PA6T_PMC5 792 101762306a36Sopenharmony_ci#define SPRN_PA6T_TSR0 793 /* Timestamp Register 0 */ 101862306a36Sopenharmony_ci#define SPRN_PA6T_TSR1 794 /* Timestamp Register 1 */ 101962306a36Sopenharmony_ci#define SPRN_PA6T_TSR2 799 /* Timestamp Register 2 */ 102062306a36Sopenharmony_ci#define SPRN_PA6T_TSR3 784 /* Timestamp Register 3 */ 102162306a36Sopenharmony_ci 102262306a36Sopenharmony_ci#define SPRN_PA6T_IER 981 /* Icache Error Register */ 102362306a36Sopenharmony_ci#define SPRN_PA6T_DER 982 /* Dcache Error Register */ 102462306a36Sopenharmony_ci#define SPRN_PA6T_BER 862 /* BIU Error Address Register */ 102562306a36Sopenharmony_ci#define SPRN_PA6T_MER 849 /* MMU Error Register */ 102662306a36Sopenharmony_ci 102762306a36Sopenharmony_ci#define SPRN_PA6T_IMA0 880 /* Instruction Match Array 0 */ 102862306a36Sopenharmony_ci#define SPRN_PA6T_IMA1 881 /* ... */ 102962306a36Sopenharmony_ci#define SPRN_PA6T_IMA2 882 103062306a36Sopenharmony_ci#define SPRN_PA6T_IMA3 883 103162306a36Sopenharmony_ci#define SPRN_PA6T_IMA4 884 103262306a36Sopenharmony_ci#define SPRN_PA6T_IMA5 885 103362306a36Sopenharmony_ci#define SPRN_PA6T_IMA6 886 103462306a36Sopenharmony_ci#define SPRN_PA6T_IMA7 887 103562306a36Sopenharmony_ci#define SPRN_PA6T_IMA8 888 103662306a36Sopenharmony_ci#define SPRN_PA6T_IMA9 889 103762306a36Sopenharmony_ci#define SPRN_PA6T_BTCR 978 /* Breakpoint and Tagging Control Register */ 103862306a36Sopenharmony_ci#define SPRN_PA6T_IMAAT 979 /* Instruction Match Array Action Table */ 103962306a36Sopenharmony_ci#define SPRN_PA6T_PCCR 1019 /* Power Counter Control Register */ 104062306a36Sopenharmony_ci#define SPRN_BKMK 1020 /* Cell Bookmark Register */ 104162306a36Sopenharmony_ci#define SPRN_PA6T_RPCCR 1021 /* Retire PC Trace Control Register */ 104262306a36Sopenharmony_ci 104362306a36Sopenharmony_ci 104462306a36Sopenharmony_ci#else /* 32-bit */ 104562306a36Sopenharmony_ci#define SPRN_MMCR0 952 /* Monitor Mode Control Register 0 */ 104662306a36Sopenharmony_ci#define MMCR0_FC 0x80000000UL /* freeze counters */ 104762306a36Sopenharmony_ci#define MMCR0_FCS 0x40000000UL /* freeze in supervisor state */ 104862306a36Sopenharmony_ci#define MMCR0_FCP 0x20000000UL /* freeze in problem state */ 104962306a36Sopenharmony_ci#define MMCR0_FCM1 0x10000000UL /* freeze counters while MSR mark = 1 */ 105062306a36Sopenharmony_ci#define MMCR0_FCM0 0x08000000UL /* freeze counters while MSR mark = 0 */ 105162306a36Sopenharmony_ci#define MMCR0_PMXE 0x04000000UL /* performance monitor exception enable */ 105262306a36Sopenharmony_ci#define MMCR0_FCECE 0x02000000UL /* freeze ctrs on enabled cond or event */ 105362306a36Sopenharmony_ci#define MMCR0_TBEE 0x00400000UL /* time base exception enable */ 105462306a36Sopenharmony_ci#define MMCR0_PMC1CE 0x00008000UL /* PMC1 count enable*/ 105562306a36Sopenharmony_ci#define MMCR0_PMCnCE 0x00004000UL /* count enable for all but PMC 1*/ 105662306a36Sopenharmony_ci#define MMCR0_TRIGGER 0x00002000UL /* TRIGGER enable */ 105762306a36Sopenharmony_ci#define MMCR0_PMC1SEL 0x00001fc0UL /* PMC 1 Event */ 105862306a36Sopenharmony_ci#define MMCR0_PMC2SEL 0x0000003fUL /* PMC 2 Event */ 105962306a36Sopenharmony_ci 106062306a36Sopenharmony_ci#define SPRN_MMCR1 956 106162306a36Sopenharmony_ci#define MMCR1_PMC3SEL 0xf8000000UL /* PMC 3 Event */ 106262306a36Sopenharmony_ci#define MMCR1_PMC4SEL 0x07c00000UL /* PMC 4 Event */ 106362306a36Sopenharmony_ci#define MMCR1_PMC5SEL 0x003e0000UL /* PMC 5 Event */ 106462306a36Sopenharmony_ci#define MMCR1_PMC6SEL 0x0001f800UL /* PMC 6 Event */ 106562306a36Sopenharmony_ci#define SPRN_MMCR2 944 106662306a36Sopenharmony_ci#define SPRN_PMC1 953 /* Performance Counter Register 1 */ 106762306a36Sopenharmony_ci#define SPRN_PMC2 954 /* Performance Counter Register 2 */ 106862306a36Sopenharmony_ci#define SPRN_PMC3 957 /* Performance Counter Register 3 */ 106962306a36Sopenharmony_ci#define SPRN_PMC4 958 /* Performance Counter Register 4 */ 107062306a36Sopenharmony_ci#define SPRN_PMC5 945 /* Performance Counter Register 5 */ 107162306a36Sopenharmony_ci#define SPRN_PMC6 946 /* Performance Counter Register 6 */ 107262306a36Sopenharmony_ci 107362306a36Sopenharmony_ci#define SPRN_SIAR 955 /* Sampled Instruction Address Register */ 107462306a36Sopenharmony_ci 107562306a36Sopenharmony_ci/* Bit definitions for MMCR0 and PMC1 / PMC2. */ 107662306a36Sopenharmony_ci#define MMCR0_PMC1_CYCLES (1 << 7) 107762306a36Sopenharmony_ci#define MMCR0_PMC1_ICACHEMISS (5 << 7) 107862306a36Sopenharmony_ci#define MMCR0_PMC1_DTLB (6 << 7) 107962306a36Sopenharmony_ci#define MMCR0_PMC2_DCACHEMISS 0x6 108062306a36Sopenharmony_ci#define MMCR0_PMC2_CYCLES 0x1 108162306a36Sopenharmony_ci#define MMCR0_PMC2_ITLB 0x7 108262306a36Sopenharmony_ci#define MMCR0_PMC2_LOADMISSTIME 0x5 108362306a36Sopenharmony_ci#endif 108462306a36Sopenharmony_ci 108562306a36Sopenharmony_ci/* 108662306a36Sopenharmony_ci * SPRG usage: 108762306a36Sopenharmony_ci * 108862306a36Sopenharmony_ci * All 64-bit: 108962306a36Sopenharmony_ci * - SPRG1 stores PACA pointer except 64-bit server in 109062306a36Sopenharmony_ci * HV mode in which case it is HSPRG0 109162306a36Sopenharmony_ci * 109262306a36Sopenharmony_ci * 64-bit server: 109362306a36Sopenharmony_ci * - SPRG0 scratch for TM recheckpoint/reclaim (reserved for HV on Power4) 109462306a36Sopenharmony_ci * - SPRG2 scratch for exception vectors 109562306a36Sopenharmony_ci * - SPRG3 CPU and NUMA node for VDSO getcpu (user visible) 109662306a36Sopenharmony_ci * - HSPRG0 stores PACA in HV mode 109762306a36Sopenharmony_ci * - HSPRG1 scratch for "HV" exceptions 109862306a36Sopenharmony_ci * 109962306a36Sopenharmony_ci * 64-bit embedded 110062306a36Sopenharmony_ci * - SPRG0 generic exception scratch 110162306a36Sopenharmony_ci * - SPRG2 TLB exception stack 110262306a36Sopenharmony_ci * - SPRG3 critical exception scratch (user visible, sorry!) 110362306a36Sopenharmony_ci * - SPRG4 unused (user visible) 110462306a36Sopenharmony_ci * - SPRG6 TLB miss scratch (user visible, sorry !) 110562306a36Sopenharmony_ci * - SPRG7 CPU and NUMA node for VDSO getcpu (user visible) 110662306a36Sopenharmony_ci * - SPRG8 machine check exception scratch 110762306a36Sopenharmony_ci * - SPRG9 debug exception scratch 110862306a36Sopenharmony_ci * 110962306a36Sopenharmony_ci * All 32-bit: 111062306a36Sopenharmony_ci * - SPRG3 current thread_struct physical addr pointer 111162306a36Sopenharmony_ci * (virtual on BookE, physical on others) 111262306a36Sopenharmony_ci * 111362306a36Sopenharmony_ci * 32-bit classic: 111462306a36Sopenharmony_ci * - SPRG0 scratch for exception vectors 111562306a36Sopenharmony_ci * - SPRG1 scratch for exception vectors 111662306a36Sopenharmony_ci * - SPRG2 indicator that we are in RTAS 111762306a36Sopenharmony_ci * - SPRG4 (603 only) pseudo TLB LRU data 111862306a36Sopenharmony_ci * 111962306a36Sopenharmony_ci * 32-bit 40x: 112062306a36Sopenharmony_ci * - SPRG0 scratch for exception vectors 112162306a36Sopenharmony_ci * - SPRG1 scratch for exception vectors 112262306a36Sopenharmony_ci * - SPRG2 scratch for exception vectors 112362306a36Sopenharmony_ci * - SPRG4 scratch for exception vectors (not 403) 112462306a36Sopenharmony_ci * - SPRG5 scratch for exception vectors (not 403) 112562306a36Sopenharmony_ci * - SPRG6 scratch for exception vectors (not 403) 112662306a36Sopenharmony_ci * - SPRG7 scratch for exception vectors (not 403) 112762306a36Sopenharmony_ci * 112862306a36Sopenharmony_ci * 32-bit 440 and FSL BookE: 112962306a36Sopenharmony_ci * - SPRG0 scratch for exception vectors 113062306a36Sopenharmony_ci * - SPRG1 scratch for exception vectors (*) 113162306a36Sopenharmony_ci * - SPRG2 scratch for crit interrupts handler 113262306a36Sopenharmony_ci * - SPRG4 scratch for exception vectors 113362306a36Sopenharmony_ci * - SPRG5 scratch for exception vectors 113462306a36Sopenharmony_ci * - SPRG6 scratch for machine check handler 113562306a36Sopenharmony_ci * - SPRG7 scratch for exception vectors 113662306a36Sopenharmony_ci * - SPRG9 scratch for debug vectors (e500 only) 113762306a36Sopenharmony_ci * 113862306a36Sopenharmony_ci * Additionally, BookE separates "read" and "write" 113962306a36Sopenharmony_ci * of those registers. That allows to use the userspace 114062306a36Sopenharmony_ci * readable variant for reads, which can avoid a fault 114162306a36Sopenharmony_ci * with KVM type virtualization. 114262306a36Sopenharmony_ci * 114362306a36Sopenharmony_ci * 32-bit 8xx: 114462306a36Sopenharmony_ci * - SPRG0 scratch for exception vectors 114562306a36Sopenharmony_ci * - SPRG1 scratch for exception vectors 114662306a36Sopenharmony_ci * - SPRG2 scratch for exception vectors 114762306a36Sopenharmony_ci * 114862306a36Sopenharmony_ci */ 114962306a36Sopenharmony_ci#ifdef CONFIG_PPC64 115062306a36Sopenharmony_ci#define SPRN_SPRG_PACA SPRN_SPRG1 115162306a36Sopenharmony_ci#else 115262306a36Sopenharmony_ci#define SPRN_SPRG_THREAD SPRN_SPRG3 115362306a36Sopenharmony_ci#endif 115462306a36Sopenharmony_ci 115562306a36Sopenharmony_ci#ifdef CONFIG_PPC_BOOK3S_64 115662306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH0 SPRN_SPRG2 115762306a36Sopenharmony_ci#define SPRN_SPRG_HPACA SPRN_HSPRG0 115862306a36Sopenharmony_ci#define SPRN_SPRG_HSCRATCH0 SPRN_HSPRG1 115962306a36Sopenharmony_ci#define SPRN_SPRG_VDSO_READ SPRN_USPRG3 116062306a36Sopenharmony_ci#define SPRN_SPRG_VDSO_WRITE SPRN_SPRG3 116162306a36Sopenharmony_ci 116262306a36Sopenharmony_ci#define GET_PACA(rX) \ 116362306a36Sopenharmony_ci BEGIN_FTR_SECTION_NESTED(66); \ 116462306a36Sopenharmony_ci mfspr rX,SPRN_SPRG_PACA; \ 116562306a36Sopenharmony_ci FTR_SECTION_ELSE_NESTED(66); \ 116662306a36Sopenharmony_ci mfspr rX,SPRN_SPRG_HPACA; \ 116762306a36Sopenharmony_ci ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE, 66) 116862306a36Sopenharmony_ci 116962306a36Sopenharmony_ci#define SET_PACA(rX) \ 117062306a36Sopenharmony_ci BEGIN_FTR_SECTION_NESTED(66); \ 117162306a36Sopenharmony_ci mtspr SPRN_SPRG_PACA,rX; \ 117262306a36Sopenharmony_ci FTR_SECTION_ELSE_NESTED(66); \ 117362306a36Sopenharmony_ci mtspr SPRN_SPRG_HPACA,rX; \ 117462306a36Sopenharmony_ci ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE, 66) 117562306a36Sopenharmony_ci 117662306a36Sopenharmony_ci#define GET_SCRATCH0(rX) \ 117762306a36Sopenharmony_ci BEGIN_FTR_SECTION_NESTED(66); \ 117862306a36Sopenharmony_ci mfspr rX,SPRN_SPRG_SCRATCH0; \ 117962306a36Sopenharmony_ci FTR_SECTION_ELSE_NESTED(66); \ 118062306a36Sopenharmony_ci mfspr rX,SPRN_SPRG_HSCRATCH0; \ 118162306a36Sopenharmony_ci ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE, 66) 118262306a36Sopenharmony_ci 118362306a36Sopenharmony_ci#define SET_SCRATCH0(rX) \ 118462306a36Sopenharmony_ci BEGIN_FTR_SECTION_NESTED(66); \ 118562306a36Sopenharmony_ci mtspr SPRN_SPRG_SCRATCH0,rX; \ 118662306a36Sopenharmony_ci FTR_SECTION_ELSE_NESTED(66); \ 118762306a36Sopenharmony_ci mtspr SPRN_SPRG_HSCRATCH0,rX; \ 118862306a36Sopenharmony_ci ALT_FTR_SECTION_END_NESTED_IFCLR(CPU_FTR_HVMODE, 66) 118962306a36Sopenharmony_ci 119062306a36Sopenharmony_ci#else /* CONFIG_PPC_BOOK3S_64 */ 119162306a36Sopenharmony_ci#define GET_SCRATCH0(rX) mfspr rX,SPRN_SPRG_SCRATCH0 119262306a36Sopenharmony_ci#define SET_SCRATCH0(rX) mtspr SPRN_SPRG_SCRATCH0,rX 119362306a36Sopenharmony_ci 119462306a36Sopenharmony_ci#endif 119562306a36Sopenharmony_ci 119662306a36Sopenharmony_ci#ifdef CONFIG_PPC_BOOK3E_64 119762306a36Sopenharmony_ci#define SPRN_SPRG_MC_SCRATCH SPRN_SPRG8 119862306a36Sopenharmony_ci#define SPRN_SPRG_CRIT_SCRATCH SPRN_SPRG3 119962306a36Sopenharmony_ci#define SPRN_SPRG_DBG_SCRATCH SPRN_SPRG9 120062306a36Sopenharmony_ci#define SPRN_SPRG_TLB_EXFRAME SPRN_SPRG2 120162306a36Sopenharmony_ci#define SPRN_SPRG_TLB_SCRATCH SPRN_SPRG6 120262306a36Sopenharmony_ci#define SPRN_SPRG_GEN_SCRATCH SPRN_SPRG0 120362306a36Sopenharmony_ci#define SPRN_SPRG_GDBELL_SCRATCH SPRN_SPRG_GEN_SCRATCH 120462306a36Sopenharmony_ci#define SPRN_SPRG_VDSO_READ SPRN_USPRG7 120562306a36Sopenharmony_ci#define SPRN_SPRG_VDSO_WRITE SPRN_SPRG7 120662306a36Sopenharmony_ci 120762306a36Sopenharmony_ci#define SET_PACA(rX) mtspr SPRN_SPRG_PACA,rX 120862306a36Sopenharmony_ci#define GET_PACA(rX) mfspr rX,SPRN_SPRG_PACA 120962306a36Sopenharmony_ci 121062306a36Sopenharmony_ci#endif 121162306a36Sopenharmony_ci 121262306a36Sopenharmony_ci#ifdef CONFIG_PPC_BOOK3S_32 121362306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0 121462306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1 121562306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH2 SPRN_SPRG2 121662306a36Sopenharmony_ci#define SPRN_SPRG_603_LRU SPRN_SPRG4 121762306a36Sopenharmony_ci#endif 121862306a36Sopenharmony_ci 121962306a36Sopenharmony_ci#ifdef CONFIG_40x 122062306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0 122162306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1 122262306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH2 SPRN_SPRG2 122362306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH3 SPRN_SPRG4 122462306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH4 SPRN_SPRG5 122562306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH5 SPRN_SPRG6 122662306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH6 SPRN_SPRG7 122762306a36Sopenharmony_ci#endif 122862306a36Sopenharmony_ci 122962306a36Sopenharmony_ci#ifdef CONFIG_BOOKE 123062306a36Sopenharmony_ci#define SPRN_SPRG_RSCRATCH0 SPRN_SPRG0 123162306a36Sopenharmony_ci#define SPRN_SPRG_WSCRATCH0 SPRN_SPRG0 123262306a36Sopenharmony_ci#define SPRN_SPRG_RSCRATCH1 SPRN_SPRG1 123362306a36Sopenharmony_ci#define SPRN_SPRG_WSCRATCH1 SPRN_SPRG1 123462306a36Sopenharmony_ci#define SPRN_SPRG_RSCRATCH_CRIT SPRN_SPRG2 123562306a36Sopenharmony_ci#define SPRN_SPRG_WSCRATCH_CRIT SPRN_SPRG2 123662306a36Sopenharmony_ci#define SPRN_SPRG_RSCRATCH2 SPRN_SPRG4R 123762306a36Sopenharmony_ci#define SPRN_SPRG_WSCRATCH2 SPRN_SPRG4W 123862306a36Sopenharmony_ci#define SPRN_SPRG_RSCRATCH3 SPRN_SPRG5R 123962306a36Sopenharmony_ci#define SPRN_SPRG_WSCRATCH3 SPRN_SPRG5W 124062306a36Sopenharmony_ci#define SPRN_SPRG_RSCRATCH_MC SPRN_SPRG1 124162306a36Sopenharmony_ci#define SPRN_SPRG_WSCRATCH_MC SPRN_SPRG1 124262306a36Sopenharmony_ci#define SPRN_SPRG_RSCRATCH4 SPRN_SPRG7R 124362306a36Sopenharmony_ci#define SPRN_SPRG_WSCRATCH4 SPRN_SPRG7W 124462306a36Sopenharmony_ci#define SPRN_SPRG_RSCRATCH_DBG SPRN_SPRG9 124562306a36Sopenharmony_ci#define SPRN_SPRG_WSCRATCH_DBG SPRN_SPRG9 124662306a36Sopenharmony_ci#endif 124762306a36Sopenharmony_ci 124862306a36Sopenharmony_ci#ifdef CONFIG_PPC_8xx 124962306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH0 SPRN_SPRG0 125062306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH1 SPRN_SPRG1 125162306a36Sopenharmony_ci#define SPRN_SPRG_SCRATCH2 SPRN_SPRG2 125262306a36Sopenharmony_ci#endif 125362306a36Sopenharmony_ci 125462306a36Sopenharmony_ci 125562306a36Sopenharmony_ci 125662306a36Sopenharmony_ci/* 125762306a36Sopenharmony_ci * An mtfsf instruction with the L bit set. On CPUs that support this a 125862306a36Sopenharmony_ci * full 64bits of FPSCR is restored and on other CPUs the L bit is ignored. 125962306a36Sopenharmony_ci * 126062306a36Sopenharmony_ci * Until binutils gets the new form of mtfsf, hardwire the instruction. 126162306a36Sopenharmony_ci */ 126262306a36Sopenharmony_ci#ifdef CONFIG_PPC64 126362306a36Sopenharmony_ci#define MTFSF_L(REG) \ 126462306a36Sopenharmony_ci .long (0xfc00058e | ((0xff) << 17) | ((REG) << 11) | (1 << 25)) 126562306a36Sopenharmony_ci#else 126662306a36Sopenharmony_ci#define MTFSF_L(REG) mtfsf 0xff, (REG) 126762306a36Sopenharmony_ci#endif 126862306a36Sopenharmony_ci 126962306a36Sopenharmony_ci/* Processor Version Register (PVR) field extraction */ 127062306a36Sopenharmony_ci 127162306a36Sopenharmony_ci#define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */ 127262306a36Sopenharmony_ci#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */ 127362306a36Sopenharmony_ci 127462306a36Sopenharmony_ci#define pvr_version_is(pvr) (PVR_VER(mfspr(SPRN_PVR)) == (pvr)) 127562306a36Sopenharmony_ci 127662306a36Sopenharmony_ci/* 127762306a36Sopenharmony_ci * IBM has further subdivided the standard PowerPC 16-bit version and 127862306a36Sopenharmony_ci * revision subfields of the PVR for the PowerPC 403s into the following: 127962306a36Sopenharmony_ci */ 128062306a36Sopenharmony_ci 128162306a36Sopenharmony_ci#define PVR_FAM(pvr) (((pvr) >> 20) & 0xFFF) /* Family field */ 128262306a36Sopenharmony_ci#define PVR_MEM(pvr) (((pvr) >> 16) & 0xF) /* Member field */ 128362306a36Sopenharmony_ci#define PVR_CORE(pvr) (((pvr) >> 12) & 0xF) /* Core field */ 128462306a36Sopenharmony_ci#define PVR_CFG(pvr) (((pvr) >> 8) & 0xF) /* Configuration field */ 128562306a36Sopenharmony_ci#define PVR_MAJ(pvr) (((pvr) >> 4) & 0xF) /* Major revision field */ 128662306a36Sopenharmony_ci#define PVR_MIN(pvr) (((pvr) >> 0) & 0xF) /* Minor revision field */ 128762306a36Sopenharmony_ci 128862306a36Sopenharmony_ci/* Processor Version Numbers */ 128962306a36Sopenharmony_ci 129062306a36Sopenharmony_ci#define PVR_403GA 0x00200000 129162306a36Sopenharmony_ci#define PVR_403GB 0x00200100 129262306a36Sopenharmony_ci#define PVR_403GC 0x00200200 129362306a36Sopenharmony_ci#define PVR_403GCX 0x00201400 129462306a36Sopenharmony_ci#define PVR_405GP 0x40110000 129562306a36Sopenharmony_ci#define PVR_476 0x11a52000 129662306a36Sopenharmony_ci#define PVR_476FPE 0x7ff50000 129762306a36Sopenharmony_ci#define PVR_STB03XXX 0x40310000 129862306a36Sopenharmony_ci#define PVR_NP405H 0x41410000 129962306a36Sopenharmony_ci#define PVR_NP405L 0x41610000 130062306a36Sopenharmony_ci#define PVR_601 0x00010000 130162306a36Sopenharmony_ci#define PVR_602 0x00050000 130262306a36Sopenharmony_ci#define PVR_603 0x00030000 130362306a36Sopenharmony_ci#define PVR_603e 0x00060000 130462306a36Sopenharmony_ci#define PVR_603ev 0x00070000 130562306a36Sopenharmony_ci#define PVR_603r 0x00071000 130662306a36Sopenharmony_ci#define PVR_604 0x00040000 130762306a36Sopenharmony_ci#define PVR_604e 0x00090000 130862306a36Sopenharmony_ci#define PVR_604r 0x000A0000 130962306a36Sopenharmony_ci#define PVR_620 0x00140000 131062306a36Sopenharmony_ci#define PVR_740 0x00080000 131162306a36Sopenharmony_ci#define PVR_750 PVR_740 131262306a36Sopenharmony_ci#define PVR_740P 0x10080000 131362306a36Sopenharmony_ci#define PVR_750P PVR_740P 131462306a36Sopenharmony_ci#define PVR_7400 0x000C0000 131562306a36Sopenharmony_ci#define PVR_7410 0x800C0000 131662306a36Sopenharmony_ci#define PVR_7450 0x80000000 131762306a36Sopenharmony_ci#define PVR_8540 0x80200000 131862306a36Sopenharmony_ci#define PVR_8560 0x80200000 131962306a36Sopenharmony_ci#define PVR_VER_E500V1 0x8020 132062306a36Sopenharmony_ci#define PVR_VER_E500V2 0x8021 132162306a36Sopenharmony_ci#define PVR_VER_E500MC 0x8023 132262306a36Sopenharmony_ci#define PVR_VER_E5500 0x8024 132362306a36Sopenharmony_ci#define PVR_VER_E6500 0x8040 132462306a36Sopenharmony_ci#define PVR_VER_7450 0x8000 132562306a36Sopenharmony_ci#define PVR_VER_7455 0x8001 132662306a36Sopenharmony_ci#define PVR_VER_7447 0x8002 132762306a36Sopenharmony_ci#define PVR_VER_7447A 0x8003 132862306a36Sopenharmony_ci#define PVR_VER_7448 0x8004 132962306a36Sopenharmony_ci 133062306a36Sopenharmony_ci/* 133162306a36Sopenharmony_ci * For the 8xx processors, all of them report the same PVR family for 133262306a36Sopenharmony_ci * the PowerPC core. The various versions of these processors must be 133362306a36Sopenharmony_ci * differentiated by the version number in the Communication Processor 133462306a36Sopenharmony_ci * Module (CPM). 133562306a36Sopenharmony_ci */ 133662306a36Sopenharmony_ci#define PVR_8xx 0x00500000 133762306a36Sopenharmony_ci 133862306a36Sopenharmony_ci#define PVR_8240 0x00810100 133962306a36Sopenharmony_ci#define PVR_8245 0x80811014 134062306a36Sopenharmony_ci#define PVR_8260 PVR_8240 134162306a36Sopenharmony_ci 134262306a36Sopenharmony_ci/* 476 Simulator seems to currently have the PVR of the 602... */ 134362306a36Sopenharmony_ci#define PVR_476_ISS 0x00052000 134462306a36Sopenharmony_ci 134562306a36Sopenharmony_ci/* 64-bit processors */ 134662306a36Sopenharmony_ci#define PVR_NORTHSTAR 0x0033 134762306a36Sopenharmony_ci#define PVR_PULSAR 0x0034 134862306a36Sopenharmony_ci#define PVR_POWER4 0x0035 134962306a36Sopenharmony_ci#define PVR_ICESTAR 0x0036 135062306a36Sopenharmony_ci#define PVR_SSTAR 0x0037 135162306a36Sopenharmony_ci#define PVR_POWER4p 0x0038 135262306a36Sopenharmony_ci#define PVR_970 0x0039 135362306a36Sopenharmony_ci#define PVR_POWER5 0x003A 135462306a36Sopenharmony_ci#define PVR_POWER5p 0x003B 135562306a36Sopenharmony_ci#define PVR_970FX 0x003C 135662306a36Sopenharmony_ci#define PVR_POWER6 0x003E 135762306a36Sopenharmony_ci#define PVR_POWER7 0x003F 135862306a36Sopenharmony_ci#define PVR_630 0x0040 135962306a36Sopenharmony_ci#define PVR_630p 0x0041 136062306a36Sopenharmony_ci#define PVR_970MP 0x0044 136162306a36Sopenharmony_ci#define PVR_970GX 0x0045 136262306a36Sopenharmony_ci#define PVR_POWER7p 0x004A 136362306a36Sopenharmony_ci#define PVR_POWER8E 0x004B 136462306a36Sopenharmony_ci#define PVR_POWER8NVL 0x004C 136562306a36Sopenharmony_ci#define PVR_POWER8 0x004D 136662306a36Sopenharmony_ci#define PVR_POWER9 0x004E 136762306a36Sopenharmony_ci#define PVR_POWER10 0x0080 136862306a36Sopenharmony_ci#define PVR_BE 0x0070 136962306a36Sopenharmony_ci#define PVR_PA6T 0x0090 137062306a36Sopenharmony_ci 137162306a36Sopenharmony_ci/* "Logical" PVR values defined in PAPR, representing architecture levels */ 137262306a36Sopenharmony_ci#define PVR_ARCH_204 0x0f000001 137362306a36Sopenharmony_ci#define PVR_ARCH_205 0x0f000002 137462306a36Sopenharmony_ci#define PVR_ARCH_206 0x0f000003 137562306a36Sopenharmony_ci#define PVR_ARCH_206p 0x0f100003 137662306a36Sopenharmony_ci#define PVR_ARCH_207 0x0f000004 137762306a36Sopenharmony_ci#define PVR_ARCH_300 0x0f000005 137862306a36Sopenharmony_ci#define PVR_ARCH_31 0x0f000006 137962306a36Sopenharmony_ci 138062306a36Sopenharmony_ci/* Macros for setting and retrieving special purpose registers */ 138162306a36Sopenharmony_ci#ifndef __ASSEMBLY__ 138262306a36Sopenharmony_ci 138362306a36Sopenharmony_ci#if defined(CONFIG_PPC64) || defined(__CHECKER__) 138462306a36Sopenharmony_citypedef struct { 138562306a36Sopenharmony_ci u32 val; 138662306a36Sopenharmony_ci#ifdef CONFIG_PPC64 138762306a36Sopenharmony_ci u32 suffix; 138862306a36Sopenharmony_ci#endif 138962306a36Sopenharmony_ci} __packed ppc_inst_t; 139062306a36Sopenharmony_ci#else 139162306a36Sopenharmony_citypedef u32 ppc_inst_t; 139262306a36Sopenharmony_ci#endif 139362306a36Sopenharmony_ci 139462306a36Sopenharmony_ci#define mfmsr() ({unsigned long rval; \ 139562306a36Sopenharmony_ci asm volatile("mfmsr %0" : "=r" (rval) : \ 139662306a36Sopenharmony_ci : "memory"); rval;}) 139762306a36Sopenharmony_ci#ifdef CONFIG_PPC_BOOK3S_64 139862306a36Sopenharmony_ci#define __mtmsrd(v, l) asm volatile("mtmsrd %0," __stringify(l) \ 139962306a36Sopenharmony_ci : : "r" (v) : "memory") 140062306a36Sopenharmony_ci#define mtmsr(v) __mtmsrd((v), 0) 140162306a36Sopenharmony_ci#define __MTMSR "mtmsrd" 140262306a36Sopenharmony_ci#else 140362306a36Sopenharmony_ci#define mtmsr(v) asm volatile("mtmsr %0" : \ 140462306a36Sopenharmony_ci : "r" ((unsigned long)(v)) \ 140562306a36Sopenharmony_ci : "memory") 140662306a36Sopenharmony_ci#define __mtmsrd(v, l) BUILD_BUG() 140762306a36Sopenharmony_ci#define __MTMSR "mtmsr" 140862306a36Sopenharmony_ci#endif 140962306a36Sopenharmony_ci 141062306a36Sopenharmony_cistatic inline void mtmsr_isync(unsigned long val) 141162306a36Sopenharmony_ci{ 141262306a36Sopenharmony_ci asm volatile(__MTMSR " %0; " ASM_FTR_IFCLR("isync", "nop", %1) : : 141362306a36Sopenharmony_ci "r" (val), "i" (CPU_FTR_ARCH_206) : "memory"); 141462306a36Sopenharmony_ci} 141562306a36Sopenharmony_ci 141662306a36Sopenharmony_ci#define mfspr(rn) ({unsigned long rval; \ 141762306a36Sopenharmony_ci asm volatile("mfspr %0," __stringify(rn) \ 141862306a36Sopenharmony_ci : "=r" (rval)); rval;}) 141962306a36Sopenharmony_ci#define mtspr(rn, v) asm volatile("mtspr " __stringify(rn) ",%0" : \ 142062306a36Sopenharmony_ci : "r" ((unsigned long)(v)) \ 142162306a36Sopenharmony_ci : "memory") 142262306a36Sopenharmony_ci#define wrtspr(rn) asm volatile("mtspr " __stringify(rn) ",2" : : : "memory") 142362306a36Sopenharmony_ci 142462306a36Sopenharmony_cistatic inline void wrtee(unsigned long val) 142562306a36Sopenharmony_ci{ 142662306a36Sopenharmony_ci if (__builtin_constant_p(val)) 142762306a36Sopenharmony_ci asm volatile("wrteei %0" : : "i" ((val & MSR_EE) ? 1 : 0) : "memory"); 142862306a36Sopenharmony_ci else 142962306a36Sopenharmony_ci asm volatile("wrtee %0" : : "r" (val) : "memory"); 143062306a36Sopenharmony_ci} 143162306a36Sopenharmony_ci 143262306a36Sopenharmony_ciextern unsigned long msr_check_and_set(unsigned long bits); 143362306a36Sopenharmony_ciextern bool strict_msr_control; 143462306a36Sopenharmony_ciextern void __msr_check_and_clear(unsigned long bits); 143562306a36Sopenharmony_cistatic inline void msr_check_and_clear(unsigned long bits) 143662306a36Sopenharmony_ci{ 143762306a36Sopenharmony_ci if (strict_msr_control) 143862306a36Sopenharmony_ci __msr_check_and_clear(bits); 143962306a36Sopenharmony_ci} 144062306a36Sopenharmony_ci 144162306a36Sopenharmony_ci#ifdef CONFIG_PPC32 144262306a36Sopenharmony_cistatic inline u32 mfsr(u32 idx) 144362306a36Sopenharmony_ci{ 144462306a36Sopenharmony_ci u32 val; 144562306a36Sopenharmony_ci 144662306a36Sopenharmony_ci if (__builtin_constant_p(idx)) 144762306a36Sopenharmony_ci asm volatile("mfsr %0, %1" : "=r" (val): "i" (idx >> 28)); 144862306a36Sopenharmony_ci else 144962306a36Sopenharmony_ci asm volatile("mfsrin %0, %1" : "=r" (val): "r" (idx)); 145062306a36Sopenharmony_ci 145162306a36Sopenharmony_ci return val; 145262306a36Sopenharmony_ci} 145362306a36Sopenharmony_ci 145462306a36Sopenharmony_cistatic inline void mtsr(u32 val, u32 idx) 145562306a36Sopenharmony_ci{ 145662306a36Sopenharmony_ci if (__builtin_constant_p(idx)) 145762306a36Sopenharmony_ci asm volatile("mtsr %1, %0" : : "r" (val), "i" (idx >> 28)); 145862306a36Sopenharmony_ci else 145962306a36Sopenharmony_ci asm volatile("mtsrin %0, %1" : : "r" (val), "r" (idx)); 146062306a36Sopenharmony_ci} 146162306a36Sopenharmony_ci#endif 146262306a36Sopenharmony_ci 146362306a36Sopenharmony_ciextern unsigned long current_stack_frame(void); 146462306a36Sopenharmony_ci 146562306a36Sopenharmony_ciregister unsigned long current_stack_pointer asm("r1"); 146662306a36Sopenharmony_ci 146762306a36Sopenharmony_ciextern unsigned long scom970_read(unsigned int address); 146862306a36Sopenharmony_ciextern void scom970_write(unsigned int address, unsigned long value); 146962306a36Sopenharmony_ci 147062306a36Sopenharmony_cistruct pt_regs; 147162306a36Sopenharmony_ci 147262306a36Sopenharmony_ciextern void ppc_save_regs(struct pt_regs *regs); 147362306a36Sopenharmony_ci#endif /* __ASSEMBLY__ */ 147462306a36Sopenharmony_ci#endif /* __KERNEL__ */ 147562306a36Sopenharmony_ci#endif /* _ASM_POWERPC_REG_H */ 1476