]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - arch/arm64/include/asm/cputype.h
Linux 3.16-rc4
[mirror_ubuntu-artful-kernel.git] / arch / arm64 / include / asm / cputype.h
CommitLineData
9cce7a43
CM
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
3e98fdac
JM
19#define INVALID_HWID ULONG_MAX
20
4c7aa002
JM
21#define MPIDR_HWID_BITMASK 0xff00ffffff
22
b058450f
LP
23#define MPIDR_LEVEL_BITS_SHIFT 3
24#define MPIDR_LEVEL_BITS (1 << MPIDR_LEVEL_BITS_SHIFT)
25#define MPIDR_LEVEL_MASK ((1 << MPIDR_LEVEL_BITS) - 1)
26
27#define MPIDR_LEVEL_SHIFT(level) \
28 (((1 << level) >> 1) << MPIDR_LEVEL_BITS_SHIFT)
29
30#define MPIDR_AFFINITY_LEVEL(mpidr, level) \
31 ((mpidr >> MPIDR_LEVEL_SHIFT(level)) & MPIDR_LEVEL_MASK)
32
9cce7a43
CM
33#define read_cpuid(reg) ({ \
34 u64 __val; \
148eb0a1 35 asm("mrs %0, " #reg : "=r" (__val)); \
9cce7a43
CM
36 __val; \
37})
38
d9c1951f 39#define ARM_CPU_IMP_ARM 0x41
4ad637a4 40#define ARM_CPU_IMP_APM 0x50
d9c1951f
MZ
41
42#define ARM_CPU_PART_AEM_V8 0xD0F0
43#define ARM_CPU_PART_FOUNDATION 0xD000
1252b331 44#define ARM_CPU_PART_CORTEX_A53 0xD030
d9c1951f
MZ
45#define ARM_CPU_PART_CORTEX_A57 0xD070
46
4ad637a4
VK
47#define APM_CPU_PART_POTENZA 0x0000
48
0359b0e2
JM
49#ifndef __ASSEMBLY__
50
9cce7a43
CM
51/*
52 * The CPU ID never changes at run time, so we might as well tell the
53 * compiler that it's constant. Use this function to read the CPU ID
54 * rather than directly reading processor_id or read_cpuid() directly.
55 */
56static inline u32 __attribute_const__ read_cpuid_id(void)
57{
148eb0a1 58 return read_cpuid(MIDR_EL1);
9cce7a43
CM
59}
60
d9c1951f
MZ
61static inline u64 __attribute_const__ read_cpuid_mpidr(void)
62{
148eb0a1 63 return read_cpuid(MPIDR_EL1);
d9c1951f
MZ
64}
65
66static inline unsigned int __attribute_const__ read_cpuid_implementor(void)
67{
68 return (read_cpuid_id() & 0xFF000000) >> 24;
69}
70
71static inline unsigned int __attribute_const__ read_cpuid_part_number(void)
72{
73 return (read_cpuid_id() & 0xFFF0);
74}
75
9cce7a43
CM
76static inline u32 __attribute_const__ read_cpuid_cachetype(void)
77{
148eb0a1 78 return read_cpuid(CTR_EL0);
9cce7a43
CM
79}
80
0359b0e2
JM
81#endif /* __ASSEMBLY__ */
82
9cce7a43 83#endif