Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
cputype.h
Go to the documentation of this file.
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 ID_MIDR_EL1 "midr_el1"
20 #define ID_CTR_EL0 "ctr_el0"
21 
22 #define ID_AA64PFR0_EL1 "id_aa64pfr0_el1"
23 #define ID_AA64DFR0_EL1 "id_aa64dfr0_el1"
24 #define ID_AA64AFR0_EL1 "id_aa64afr0_el1"
25 #define ID_AA64ISAR0_EL1 "id_aa64isar0_el1"
26 #define ID_AA64MMFR0_EL1 "id_aa64mmfr0_el1"
27 
28 #define read_cpuid(reg) ({ \
29  u64 __val; \
30  asm("mrs %0, " reg : "=r" (__val)); \
31  __val; \
32 })
33 
34 /*
35  * The CPU ID never changes at run time, so we might as well tell the
36  * compiler that it's constant. Use this function to read the CPU ID
37  * rather than directly reading processor_id or read_cpuid() directly.
38  */
39 static inline u32 __attribute_const__ read_cpuid_id(void)
40 {
41  return read_cpuid(ID_MIDR_EL1);
42 }
43 
44 static inline u32 __attribute_const__ read_cpuid_cachetype(void)
45 {
46  return read_cpuid(ID_CTR_EL0);
47 }
48 
49 #endif