arm64: drop redundant macros from read_cpuid()
[firefly-linux-kernel-4.4.55.git] / arch / arm64 / include / asm / cputype.h
1 /*
2  * Copyright (C) 2012 ARM Ltd.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16 #ifndef __ASM_CPUTYPE_H
17 #define __ASM_CPUTYPE_H
18
19 #define INVALID_HWID            ULONG_MAX
20
21 #define MPIDR_HWID_BITMASK      0xff00ffffff
22
23 #define read_cpuid(reg) ({                                              \
24         u64 __val;                                                      \
25         asm("mrs        %0, " #reg : "=r" (__val));                     \
26         __val;                                                          \
27 })
28
29 #define ARM_CPU_IMP_ARM         0x41
30
31 #define ARM_CPU_PART_AEM_V8     0xD0F0
32 #define ARM_CPU_PART_FOUNDATION 0xD000
33 #define ARM_CPU_PART_CORTEX_A57 0xD070
34
35 #ifndef __ASSEMBLY__
36
37 /*
38  * The CPU ID never changes at run time, so we might as well tell the
39  * compiler that it's constant.  Use this function to read the CPU ID
40  * rather than directly reading processor_id or read_cpuid() directly.
41  */
42 static inline u32 __attribute_const__ read_cpuid_id(void)
43 {
44         return read_cpuid(MIDR_EL1);
45 }
46
47 static inline u64 __attribute_const__ read_cpuid_mpidr(void)
48 {
49         return read_cpuid(MPIDR_EL1);
50 }
51
52 static inline unsigned int __attribute_const__ read_cpuid_implementor(void)
53 {
54         return (read_cpuid_id() & 0xFF000000) >> 24;
55 }
56
57 static inline unsigned int __attribute_const__ read_cpuid_part_number(void)
58 {
59         return (read_cpuid_id() & 0xFFF0);
60 }
61
62 static inline u32 __attribute_const__ read_cpuid_cachetype(void)
63 {
64         return read_cpuid(CTR_EL0);
65 }
66
67 #endif /* __ASSEMBLY__ */
68
69 #endif