1 // SPDX-License-Identifier: GPL-2.0+
3 * PXA CPU information display
5 * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
11 #include <linux/compiler.h>
13 #ifdef CONFIG_CPU_PXA25X
14 #if ((CONFIG_SYS_INIT_SP_ADDR) != 0xfffff800)
15 #error "Init SP address must be set to 0xfffff800 for PXA250"
19 #define CPU_MASK_PXA_PRODID 0x000003f0
20 #define CPU_MASK_PXA_REVID 0x0000000f
22 #define CPU_MASK_PRODREV (CPU_MASK_PXA_PRODID | CPU_MASK_PXA_REVID)
24 #define CPU_VALUE_PXA25X 0x100
25 #define CPU_VALUE_PXA27X 0x110
27 static uint32_t pxa_get_cpuid(void)
30 asm volatile("mrc p15, 0, %0, c0, c0, 0" : "=r"(cpuid));
34 int cpu_is_pxa25x(void)
36 uint32_t id = pxa_get_cpuid();
37 id &= CPU_MASK_PXA_PRODID;
38 return id == CPU_VALUE_PXA25X;
41 int cpu_is_pxa27x(void)
43 uint32_t id = pxa_get_cpuid();
44 id &= CPU_MASK_PXA_PRODID;
45 return id == CPU_VALUE_PXA27X;
48 int cpu_is_pxa27xm(void)
50 uint32_t id = pxa_get_cpuid();
51 return ((id & CPU_MASK_PXA_PRODID) == CPU_VALUE_PXA27X) &&
52 ((id & CPU_MASK_PXA_REVID) == 8);
55 uint32_t pxa_get_cpu_revision(void)
57 return pxa_get_cpuid() & CPU_MASK_PRODREV;
60 #ifdef CONFIG_DISPLAY_CPUINFO
61 static const char *pxa25x_get_revision(void)
63 static __maybe_unused const char * const revs_25x[] = { "A0" };
64 static __maybe_unused const char * const revs_26x[] = {
67 static const char *unknown = "Unknown";
73 id = pxa_get_cpuid() & CPU_MASK_PXA_REVID;
75 /* PXA26x is a sick special case as it can't be told apart from PXA25x :-( */
76 #ifdef CONFIG_CPU_PXA26X
78 case 3: return revs_26x[0];
79 case 5: return revs_26x[1];
80 case 6: return revs_26x[2];
89 static const char *pxa27x_get_revision(void)
91 static const char *const rev[] = { "A0", "A1", "B0", "B1", "C0", "C5" };
92 static const char *unknown = "Unknown";
98 id = pxa_get_cpuid() & CPU_MASK_PXA_REVID;
100 if ((id == 5) || (id == 6) || (id > 8))
103 /* Cap the special PXA270 C5 case. */
107 /* Cap the special PXA270M A1 case. */
114 static int print_cpuinfo_pxa2xx(void)
116 if (cpu_is_pxa25x()) {
117 puts("Marvell PXA25x rev. ");
118 puts(pxa25x_get_revision());
119 } else if (cpu_is_pxa27x()) {
120 puts("Marvell PXA27x");
121 if (cpu_is_pxa27xm()) puts("M");
123 puts(pxa27x_get_revision());
132 int print_cpuinfo(void)
138 ret = print_cpuinfo_pxa2xx();