blob: 17d8be5b5b1c1025902012d87015764ed080764d [file] [log] [blame]
Marek Vasute8de0fa2011-11-26 08:11:32 +01001/*
2 * PXA CPU information display
3 *
4 * Copyright (C) 2011 Marek Vasut <marek.vasut@gmail.com>
5 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02006 * SPDX-License-Identifier: GPL-2.0+
Marek Vasute8de0fa2011-11-26 08:11:32 +01007 */
8
9#include <common.h>
10#include <asm/io.h>
11#include <errno.h>
12#include <linux/compiler.h>
13
Albert ARIBAUD23ff29b2014-04-15 16:13:49 +020014#ifdef CONFIG_CPU_PXA25X
15#if ((CONFIG_SYS_INIT_SP_ADDR) != 0xfffff800)
16#error "Init SP address must be set to 0xfffff800 for PXA250"
17#endif
18#endif
19
Lukasz Dalek539e9ff2012-10-03 00:51:06 +020020#define CPU_MASK_PXA_PRODID 0x000003f0
21#define CPU_MASK_PXA_REVID 0x0000000f
Marek Vasute8de0fa2011-11-26 08:11:32 +010022
Lukasz Dalek539e9ff2012-10-03 00:51:06 +020023#define CPU_MASK_PRODREV (CPU_MASK_PXA_PRODID | CPU_MASK_PXA_REVID)
24
Marek Vasute8de0fa2011-11-26 08:11:32 +010025#define CPU_VALUE_PXA25X 0x100
26#define CPU_VALUE_PXA27X 0x110
27
28static uint32_t pxa_get_cpuid(void)
29{
30 uint32_t cpuid;
31 asm volatile("mrc p15, 0, %0, c0, c0, 0" : "=r"(cpuid));
32 return cpuid;
33}
34
35int cpu_is_pxa25x(void)
36{
37 uint32_t id = pxa_get_cpuid();
38 id &= CPU_MASK_PXA_PRODID;
39 return id == CPU_VALUE_PXA25X;
40}
41
42int cpu_is_pxa27x(void)
43{
44 uint32_t id = pxa_get_cpuid();
45 id &= CPU_MASK_PXA_PRODID;
46 return id == CPU_VALUE_PXA27X;
47}
48
Lukasz Dalek539e9ff2012-10-03 00:51:06 +020049uint32_t pxa_get_cpu_revision(void)
50{
51 return pxa_get_cpuid() & CPU_MASK_PRODREV;
52}
53
Marek Vasute8de0fa2011-11-26 08:11:32 +010054#ifdef CONFIG_DISPLAY_CPUINFO
55static const char *pxa25x_get_revision(void)
56{
57 static __maybe_unused const char * const revs_25x[] = { "A0" };
58 static __maybe_unused const char * const revs_26x[] = {
59 "A0", "B0", "B1"
60 };
61 static const char *unknown = "Unknown";
62 uint32_t id;
63
64 if (!cpu_is_pxa25x())
65 return unknown;
66
67 id = pxa_get_cpuid() & CPU_MASK_PXA_REVID;
68
69/* PXA26x is a sick special case as it can't be told apart from PXA25x :-( */
70#ifdef CONFIG_CPU_PXA26X
71 switch (id) {
72 case 3: return revs_26x[0];
73 case 5: return revs_26x[1];
74 case 6: return revs_26x[2];
75 }
76#else
77 if (id == 6)
78 return revs_25x[0];
79#endif
80 return unknown;
81}
82
83static const char *pxa27x_get_revision(void)
84{
85 static const char *const rev[] = { "A0", "A1", "B0", "B1", "C0", "C5" };
86 static const char *unknown = "Unknown";
87 uint32_t id;
88
89 if (!cpu_is_pxa27x())
90 return unknown;
91
92 id = pxa_get_cpuid() & CPU_MASK_PXA_REVID;
93
94 if ((id == 5) || (id == 6) || (id > 7))
95 return unknown;
96
97 /* Cap the special PXA270 C5 case. */
98 if (id == 7)
99 id = 5;
100
101 return rev[id];
102}
103
104static int print_cpuinfo_pxa2xx(void)
105{
106 if (cpu_is_pxa25x()) {
107 puts("Marvell PXA25x rev. ");
108 puts(pxa25x_get_revision());
109 } else if (cpu_is_pxa27x()) {
110 puts("Marvell PXA27x rev. ");
111 puts(pxa27x_get_revision());
112 } else
113 return -EINVAL;
114
115 puts("\n");
116
117 return 0;
118}
119
120int print_cpuinfo(void)
121{
122 int ret;
123
124 puts("CPU: ");
125
126 ret = print_cpuinfo_pxa2xx();
127 if (!ret)
128 return ret;
129
130 return ret;
131}
132#endif