Commit | Line | Data |
---|---|---|
df857416 MR |
1 | /* |
2 | * Record and handle CPU attributes. | |
3 | * | |
4 | * Copyright (C) 2014 ARM Ltd. | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License version 2 as | |
7 | * published by the Free Software Foundation. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | * GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License | |
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | #include <asm/arch_timer.h> | |
18 | #include <asm/cachetype.h> | |
19 | #include <asm/cpu.h> | |
20 | #include <asm/cputype.h> | |
21 | ||
22 | #include <linux/init.h> | |
23 | #include <linux/smp.h> | |
24 | ||
25 | /* | |
26 | * In case the boot CPU is hotpluggable, we record its initial state and | |
27 | * current state separately. Certain system registers may contain different | |
28 | * values depending on configuration at or after reset. | |
29 | */ | |
30 | DEFINE_PER_CPU(struct cpuinfo_arm64, cpu_data); | |
31 | static struct cpuinfo_arm64 boot_cpu_data; | |
32 | ||
33 | static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info) | |
34 | { | |
35 | info->reg_cntfrq = arch_timer_get_cntfrq(); | |
36 | info->reg_ctr = read_cpuid_cachetype(); | |
37 | info->reg_dczid = read_cpuid(DCZID_EL0); | |
38 | info->reg_midr = read_cpuid_id(); | |
39 | ||
40 | info->reg_id_aa64isar0 = read_cpuid(ID_AA64ISAR0_EL1); | |
41 | info->reg_id_aa64isar1 = read_cpuid(ID_AA64ISAR1_EL1); | |
42 | info->reg_id_aa64mmfr0 = read_cpuid(ID_AA64MMFR0_EL1); | |
43 | info->reg_id_aa64mmfr1 = read_cpuid(ID_AA64MMFR1_EL1); | |
44 | info->reg_id_aa64pfr0 = read_cpuid(ID_AA64PFR0_EL1); | |
45 | info->reg_id_aa64pfr1 = read_cpuid(ID_AA64PFR1_EL1); | |
46 | ||
47 | info->reg_id_isar0 = read_cpuid(ID_ISAR0_EL1); | |
48 | info->reg_id_isar1 = read_cpuid(ID_ISAR1_EL1); | |
49 | info->reg_id_isar2 = read_cpuid(ID_ISAR2_EL1); | |
50 | info->reg_id_isar3 = read_cpuid(ID_ISAR3_EL1); | |
51 | info->reg_id_isar4 = read_cpuid(ID_ISAR4_EL1); | |
52 | info->reg_id_isar5 = read_cpuid(ID_ISAR5_EL1); | |
53 | info->reg_id_mmfr0 = read_cpuid(ID_MMFR0_EL1); | |
54 | info->reg_id_mmfr1 = read_cpuid(ID_MMFR1_EL1); | |
55 | info->reg_id_mmfr2 = read_cpuid(ID_MMFR2_EL1); | |
56 | info->reg_id_mmfr3 = read_cpuid(ID_MMFR3_EL1); | |
57 | info->reg_id_pfr0 = read_cpuid(ID_PFR0_EL1); | |
58 | info->reg_id_pfr1 = read_cpuid(ID_PFR1_EL1); | |
59 | } | |
60 | ||
61 | void cpuinfo_store_cpu(void) | |
62 | { | |
63 | struct cpuinfo_arm64 *info = this_cpu_ptr(&cpu_data); | |
64 | __cpuinfo_store_cpu(info); | |
65 | } | |
66 | ||
67 | void __init cpuinfo_store_boot_cpu(void) | |
68 | { | |
69 | struct cpuinfo_arm64 *info = &per_cpu(cpu_data, 0); | |
70 | __cpuinfo_store_cpu(info); | |
71 | ||
72 | boot_cpu_data = *info; | |
73 | } |