aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Rutland <mark.rutland@arm.com>2014-07-16 11:32:43 -0400
committerCatalin Marinas <catalin.marinas@arm.com>2014-07-18 10:24:08 -0400
commit89c4a306e7631bcb71cc537c8a029172af6047fe (patch)
tree57fff43760ad3abdfc1a4eca49b6a3b8b932bfa0
parent18ab7db6b749ac27aac08d572afbbd2f4d937934 (diff)
arm64: add MIDR_EL1 field accessors
The MIDR_EL1 register is composed of a number of bitfields, and uses of the fields has so far involved open-coding of the shifts and masks required. This patch adds shifts and masks for each of the MIDR_EL1 subfields, and also provides accessors built atop of these. Existing uses within cputype.h are updated to use these accessors. The read_cpuid_part_number macro is modified to return the extracted bitfield rather than returning the value in-place with all other fields (including revision) masked out, to better match the other accessors. As the value is only used in comparison with the *_CPU_PART_* macros which are similarly updated, and these values are never exposed to userspace, this change should not affect any functionality. Signed-off-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Will Deacon <will.deacon@arm.com> Reviewed-by: Will Deacon <will.deacon@arm.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r--arch/arm64/include/asm/cputype.h33
1 files changed, 26 insertions, 7 deletions
diff --git a/arch/arm64/include/asm/cputype.h b/arch/arm64/include/asm/cputype.h
index ed48a3a7836a..379d0b874328 100644
--- a/arch/arm64/include/asm/cputype.h
+++ b/arch/arm64/include/asm/cputype.h
@@ -38,15 +38,34 @@
38 __val; \ 38 __val; \
39}) 39})
40 40
41#define MIDR_REVISION_MASK 0xf
42#define MIDR_REVISION(midr) ((midr) & MIDR_REVISION_MASK)
43#define MIDR_PARTNUM_SHIFT 4
44#define MIDR_PARTNUM_MASK (0xfff << MIDR_PARTNUM_SHIFT)
45#define MIDR_PARTNUM(midr) \
46 (((midr) & MIDR_PARTNUM_MASK) >> MIDR_PARTNUM_SHIFT)
47#define MIDR_ARCHITECTURE_SHIFT 16
48#define MIDR_ARCHITECTURE_MASK (0xf << MIDR_ARCHITECTURE_SHIFT)
49#define MIDR_ARCHITECTURE(midr) \
50 (((midr) & MIDR_ARCHITECTURE_MASK) >> MIDR_ARCHITECTURE_SHIFT)
51#define MIDR_VARIANT_SHIFT 20
52#define MIDR_VARIANT_MASK (0xf << MIDR_VARIANT_SHIFT)
53#define MIDR_VARIANT(midr) \
54 (((midr) & MIDR_VARIANT_MASK) >> MIDR_VARIANT_SHIFT)
55#define MIDR_IMPLEMENTOR_SHIFT 24
56#define MIDR_IMPLEMENTOR_MASK (0xff << MIDR_IMPLEMENTOR_SHIFT)
57#define MIDR_IMPLEMENTOR(midr) \
58 (((midr) & MIDR_IMPLEMENTOR_MASK) >> MIDR_IMPLEMENTOR_SHIFT)
59
41#define ARM_CPU_IMP_ARM 0x41 60#define ARM_CPU_IMP_ARM 0x41
42#define ARM_CPU_IMP_APM 0x50 61#define ARM_CPU_IMP_APM 0x50
43 62
44#define ARM_CPU_PART_AEM_V8 0xD0F0 63#define ARM_CPU_PART_AEM_V8 0xD0F
45#define ARM_CPU_PART_FOUNDATION 0xD000 64#define ARM_CPU_PART_FOUNDATION 0xD00
46#define ARM_CPU_PART_CORTEX_A53 0xD030 65#define ARM_CPU_PART_CORTEX_A57 0xD07
47#define ARM_CPU_PART_CORTEX_A57 0xD070 66#define ARM_CPU_PART_CORTEX_A53 0xD03
48 67
49#define APM_CPU_PART_POTENZA 0x0000 68#define APM_CPU_PART_POTENZA 0x000
50 69
51#ifndef __ASSEMBLY__ 70#ifndef __ASSEMBLY__
52 71
@@ -67,12 +86,12 @@ static inline u64 __attribute_const__ read_cpuid_mpidr(void)
67 86
68static inline unsigned int __attribute_const__ read_cpuid_implementor(void) 87static inline unsigned int __attribute_const__ read_cpuid_implementor(void)
69{ 88{
70 return (read_cpuid_id() & 0xFF000000) >> 24; 89 return MIDR_IMPLEMENTOR(read_cpuid_id());
71} 90}
72 91
73static inline unsigned int __attribute_const__ read_cpuid_part_number(void) 92static inline unsigned int __attribute_const__ read_cpuid_part_number(void)
74{ 93{
75 return (read_cpuid_id() & 0xFFF0); 94 return MIDR_PARTNUM(read_cpuid_id());
76} 95}
77 96
78static inline u32 __attribute_const__ read_cpuid_cachetype(void) 97static inline u32 __attribute_const__ read_cpuid_cachetype(void)