Commit f9d21782 authored by Catalin Marinas's avatar Catalin Marinas

ARMv7: Correctly identify the CPU architecture version

The cpu_architecture() function in arch/arm/kernel/setup.c only works
with cores produced by ARM Ltd. The more generic approach is to read
the ID_MMFR0 register and check for the VMSA or PMSA version
supported.
Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent d89eeedf
...@@ -301,10 +301,23 @@ int cpu_architecture(void) ...@@ -301,10 +301,23 @@ int cpu_architecture(void)
cpu_arch = (processor_id >> 16) & 7; cpu_arch = (processor_id >> 16) & 7;
if (cpu_arch) if (cpu_arch)
cpu_arch += CPU_ARCH_ARMv3; cpu_arch += CPU_ARCH_ARMv3;
} else { } else if ((processor_id & 0x000f0000) == 0x000f0000) {
/* the revised CPUID */ unsigned int mmfr0;
cpu_arch = ((processor_id >> 12) & 0xf) - 0xb + CPU_ARCH_ARMv6;
} /* 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; return cpu_arch;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment