1/*
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License.  See the file "COPYING" in the main directory of this archive
4 * for more details.
5 *
6 * Copyright (C) 2003, 2004 Ralf Baechle
7 * Copyright (C) 2004  Maciej W. Rozycki
8 */
9#ifndef __ASM_CPU_TYPE_H
10#define __ASM_CPU_TYPE_H
11
12#include <linux/smp.h>
13#include <linux/compiler.h>
14
15static inline int __pure __get_cpu_type(const int cpu_type)
16{
17	switch (cpu_type) {
18#if defined(CONFIG_SYS_HAS_CPU_LOONGSON2E) || \
19    defined(CONFIG_SYS_HAS_CPU_LOONGSON2F)
20	case CPU_LOONGSON2:
21#endif
22
23#ifdef CONFIG_SYS_HAS_CPU_LOONGSON3
24	case CPU_LOONGSON3:
25#endif
26
27#ifdef CONFIG_SYS_HAS_CPU_LOONGSON1B
28	case CPU_LOONGSON1:
29#endif
30
31#ifdef CONFIG_SYS_HAS_CPU_MIPS32_R1
32	case CPU_4KC:
33	case CPU_ALCHEMY:
34	case CPU_PR4450:
35	case CPU_JZRISC:
36#endif
37
38#if defined(CONFIG_SYS_HAS_CPU_MIPS32_R1) || \
39    defined(CONFIG_SYS_HAS_CPU_MIPS32_R2)
40	case CPU_4KEC:
41#endif
42
43#ifdef CONFIG_SYS_HAS_CPU_MIPS32_R2
44	case CPU_4KSC:
45	case CPU_24K:
46	case CPU_34K:
47	case CPU_1004K:
48	case CPU_74K:
49	case CPU_M14KC:
50	case CPU_M14KEC:
51	case CPU_INTERAPTIV:
52	case CPU_PROAPTIV:
53	case CPU_P5600:
54	case CPU_M5150:
55#endif
56
57#if defined(CONFIG_SYS_HAS_CPU_MIPS32_R2) || \
58    defined(CONFIG_SYS_HAS_CPU_MIPS32_R6) || \
59    defined(CONFIG_SYS_HAS_CPU_MIPS64_R2) || \
60    defined(CONFIG_SYS_HAS_CPU_MIPS64_R6)
61	case CPU_QEMU_GENERIC:
62#endif
63
64#ifdef CONFIG_SYS_HAS_CPU_MIPS64_R1
65	case CPU_5KC:
66	case CPU_5KE:
67	case CPU_20KC:
68	case CPU_25KF:
69	case CPU_SB1:
70	case CPU_SB1A:
71#endif
72
73#ifdef CONFIG_SYS_HAS_CPU_MIPS64_R2
74	/*
75	 * All MIPS64 R2 processors have their own special symbols.  That is,
76	 * there currently is no pure R2 core
77	 */
78#endif
79
80#ifdef CONFIG_SYS_HAS_CPU_R3000
81	case CPU_R2000:
82	case CPU_R3000:
83	case CPU_R3000A:
84	case CPU_R3041:
85	case CPU_R3051:
86	case CPU_R3052:
87	case CPU_R3081:
88	case CPU_R3081E:
89#endif
90
91#ifdef CONFIG_SYS_HAS_CPU_TX39XX
92	case CPU_TX3912:
93	case CPU_TX3922:
94	case CPU_TX3927:
95#endif
96
97#ifdef CONFIG_SYS_HAS_CPU_VR41XX
98	case CPU_VR41XX:
99	case CPU_VR4111:
100	case CPU_VR4121:
101	case CPU_VR4122:
102	case CPU_VR4131:
103	case CPU_VR4133:
104	case CPU_VR4181:
105	case CPU_VR4181A:
106#endif
107
108#ifdef CONFIG_SYS_HAS_CPU_R4300
109	case CPU_R4300:
110	case CPU_R4310:
111#endif
112
113#ifdef CONFIG_SYS_HAS_CPU_R4X00
114	case CPU_R4000PC:
115	case CPU_R4000SC:
116	case CPU_R4000MC:
117	case CPU_R4200:
118	case CPU_R4400PC:
119	case CPU_R4400SC:
120	case CPU_R4400MC:
121	case CPU_R4600:
122	case CPU_R4700:
123	case CPU_R4640:
124	case CPU_R4650:
125#endif
126
127#ifdef CONFIG_SYS_HAS_CPU_TX49XX
128	case CPU_TX49XX:
129#endif
130
131#ifdef CONFIG_SYS_HAS_CPU_R5000
132	case CPU_R5000:
133#endif
134
135#ifdef CONFIG_SYS_HAS_CPU_R5432
136	case CPU_R5432:
137#endif
138
139#ifdef CONFIG_SYS_HAS_CPU_R5500
140	case CPU_R5500:
141#endif
142
143#ifdef CONFIG_SYS_HAS_CPU_R6000
144	case CPU_R6000:
145	case CPU_R6000A:
146#endif
147
148#ifdef CONFIG_SYS_HAS_CPU_NEVADA
149	case CPU_NEVADA:
150#endif
151
152#ifdef CONFIG_SYS_HAS_CPU_R8000
153	case CPU_R8000:
154#endif
155
156#ifdef CONFIG_SYS_HAS_CPU_R10000
157	case CPU_R10000:
158	case CPU_R12000:
159	case CPU_R14000:
160	case CPU_R16000:
161#endif
162#ifdef CONFIG_SYS_HAS_CPU_RM7000
163	case CPU_RM7000:
164	case CPU_SR71000:
165#endif
166#ifdef CONFIG_SYS_HAS_CPU_SB1
167	case CPU_SB1:
168	case CPU_SB1A:
169#endif
170#ifdef CONFIG_SYS_HAS_CPU_CAVIUM_OCTEON
171	case CPU_CAVIUM_OCTEON:
172	case CPU_CAVIUM_OCTEON_PLUS:
173	case CPU_CAVIUM_OCTEON2:
174	case CPU_CAVIUM_OCTEON3:
175#endif
176
177#if defined(CONFIG_SYS_HAS_CPU_BMIPS32_3300) || \
178	defined (CONFIG_SYS_HAS_CPU_MIPS32_R1)
179	case CPU_BMIPS32:
180	case CPU_BMIPS3300:
181#endif
182
183#ifdef CONFIG_SYS_HAS_CPU_BMIPS4350
184	case CPU_BMIPS4350:
185#endif
186
187#ifdef CONFIG_SYS_HAS_CPU_BMIPS4380
188	case CPU_BMIPS4380:
189#endif
190
191#ifdef CONFIG_SYS_HAS_CPU_BMIPS5000
192	case CPU_BMIPS5000:
193#endif
194
195#ifdef CONFIG_SYS_HAS_CPU_XLP
196	case CPU_XLP:
197#endif
198
199#ifdef CONFIG_SYS_HAS_CPU_XLR
200	case CPU_XLR:
201#endif
202		break;
203	default:
204		unreachable();
205	}
206
207	return cpu_type;
208}
209
210static inline int __pure current_cpu_type(void)
211{
212	const int cpu_type = current_cpu_data.cputype;
213
214	return __get_cpu_type(cpu_type);
215}
216
217static inline int __pure boot_cpu_type(void)
218{
219	const int cpu_type = cpu_data[0].cputype;
220
221	return __get_cpu_type(cpu_type);
222}
223
224#endif /* __ASM_CPU_TYPE_H */
225