summaryrefslogtreecommitdiffstats
path: root/arch/arm/include/asm/system_info.h
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-03-04 09:56:10 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-03-04 12:02:10 +0100
commit82eb0b547aa48f1ed6ed1e2e42e2e0136de66fac (patch)
tree1118225984bc3a3a8a9d19782ca84cf7ad89e15b /arch/arm/include/asm/system_info.h
parent94e71b843f6456abacc2fe76a5c375a461fabdf7 (diff)
downloadbarebox-82eb0b547aa48f1ed6ed1e2e42e2e0136de66fac.tar.gz
barebox-82eb0b547aa48f1ed6ed1e2e42e2e0136de66fac.tar.xz
ARM: make cpu architecture detection available as static inline function
When we have multi cpu support compiled in we need the cpu architecture early so that we can pick the correct cacheflush function. Make it available as static inline function and add a comment above it that this function normally should not be used. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/include/asm/system_info.h')
-rw-r--r--arch/arm/include/asm/system_info.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/arch/arm/include/asm/system_info.h b/arch/arm/include/asm/system_info.h
index 56ebb11a2b..50769ec3bc 100644
--- a/arch/arm/include/asm/system_info.h
+++ b/arch/arm/include/asm/system_info.h
@@ -110,8 +110,51 @@
#ifndef __ASSEMBLY__
#ifdef ARM_MULTIARCH
+/*
+ * Early version to get the ARM cpu architecture. Only needed during
+ * early startup when the C environment is not yet fully initialized.
+ * Normally you should use cpu_architecture() instead.
+ */
+static inline int arm_early_get_cpu_architecture(void)
+{
+ int cpu_arch;
+
+ if ((read_cpuid_id() & 0x0008f000) == 0) {
+ cpu_arch = CPU_ARCH_UNKNOWN;
+ } else if ((read_cpuid_id() & 0x0008f000) == 0x00007000) {
+ cpu_arch = (read_cpuid_id() & (1 << 23)) ? CPU_ARCH_ARMv4T : CPU_ARCH_ARMv3;
+ } else if ((read_cpuid_id() & 0x00080000) == 0x00000000) {
+ cpu_arch = (read_cpuid_id() >> 16) & 7;
+ if (cpu_arch)
+ cpu_arch += CPU_ARCH_ARMv3;
+ } else if ((read_cpuid_id() & 0x000f0000) == 0x000f0000) {
+ unsigned int mmfr0;
+
+ /* Revised CPUID format. Read the Memory Model Feature
+ * Register 0 and check for VMSAv7 or PMSAv7 */
+ asm("mrc p15, 0, %0, c0, c1, 4"
+ : "=r" (mmfr0));
+ if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
+ (mmfr0 & 0x000000f0) >= 0x00000030)
+ cpu_arch = CPU_ARCH_ARMv7;
+ else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
+ (mmfr0 & 0x000000f0) == 0x00000020)
+ cpu_arch = CPU_ARCH_ARMv6;
+ else
+ cpu_arch = CPU_ARCH_UNKNOWN;
+ } else
+ cpu_arch = CPU_ARCH_UNKNOWN;
+
+ return cpu_arch;
+}
+
extern int __pure cpu_architecture(void);
#else
+static inline int __pure arm_early_get_cpu_architecture(void)
+{
+ return ARM_ARCH;
+}
+
static inline int __pure cpu_architecture(void)
{
return ARM_ARCH;