From a38be63831aa3c5696581a58c8afb5bfc11e45d5 Mon Sep 17 00:00:00 2001 From: Ahmad Fatoum Date: Thu, 9 Jun 2022 07:59:02 +0200 Subject: ARM64: asm: implement read_cpuid_id() We'll need to use this function in code that will be compiled for both 32-bit and 64-bit ARM, so add the 64-bit implementation. Signed-off-by: Ahmad Fatoum Link: https://lore.barebox.org/20220609055922.667016-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer --- arch/arm/include/asm/cputype.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h index 7dc027c174..c3fc057650 100644 --- a/arch/arm/include/asm/cputype.h +++ b/arch/arm/include/asm/cputype.h @@ -6,6 +6,23 @@ #include #include +#ifdef CONFIG_CPU_64v8 + +#define CPUID_ID midr_el1 +#define CPUID_CACHETYPE ctr_el0 +#define CPUID_MPIDR mpidr_el1 + +#define read_cpuid(reg) \ + ({ \ + unsigned int __val; \ + asm("mrs %0, " __stringify(reg) \ + : "=r" (__val) \ + : \ + : "cc"); \ + __val; \ + }) +#else + #define CPUID_ID 0 #define CPUID_CACHETYPE 1 #define CPUID_TCM 2 @@ -27,8 +44,6 @@ #define CPUID_EXT_ISAR4 "c2, 4" #define CPUID_EXT_ISAR5 "c2, 5" -extern unsigned int processor_id; - #define read_cpuid(reg) \ ({ \ unsigned int __val; \ @@ -47,6 +62,9 @@ extern unsigned int processor_id; : "cc"); \ __val; \ }) +#endif + +extern unsigned int processor_id; /* * The CPU ID never changes at run time, so we might as well tell the -- cgit v1.2.3