blob: 1bdbcad3bb7414d2a394150e02bfcbbb0eb9db27 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Processor capabilities determination functions.
3 *
4 * Copyright (C) xxxx the Anonymous
Ralf Baechle010b8532006-01-29 18:42:08 +00005 * Copyright (C) 1994 - 2006 Ralf Baechle
Ralf Baechle41943182005-05-05 16:45:59 +00006 * Copyright (C) 2003, 2004 Maciej W. Rozycki
Ralf Baechle41943182005-05-05 16:45:59 +00007 * Copyright (C) 2001, 2004 MIPS Inc.
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/ptrace.h>
17#include <linux/stddef.h>
18
Ralf Baechle57599062007-02-18 19:07:31 +000019#include <asm/bugs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020#include <asm/cpu.h>
21#include <asm/fpu.h>
22#include <asm/mipsregs.h>
23#include <asm/system.h>
David Daney654f57b2008-09-23 00:07:16 -070024#include <asm/watch.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26/*
27 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
28 * the implementation of the "wait" feature differs between CPU families. This
29 * points to the function that implements CPU specific wait.
30 * The wait instruction stops the pipeline and reduces the power consumption of
31 * the CPU very much.
32 */
33void (*cpu_wait)(void) = NULL;
34
35static void r3081_wait(void)
36{
37 unsigned long cfg = read_c0_conf();
38 write_c0_conf(cfg | R30XX_CONF_HALT);
39}
40
41static void r39xx_wait(void)
42{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090043 local_irq_disable();
44 if (!need_resched())
45 write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
46 local_irq_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070047}
48
Atsushi Nemotoc65a5482007-11-12 02:05:18 +090049extern void r4k_wait(void);
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090050
51/*
52 * This variant is preferable as it allows testing need_resched and going to
53 * sleep depending on the outcome atomically. Unfortunately the "It is
54 * implementation-dependent whether the pipeline restarts when a non-enabled
55 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
56 * using this version a gamble.
57 */
Kevin D. Kissell8531a352008-09-09 21:48:52 +020058void r4k_wait_irqoff(void)
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090059{
60 local_irq_disable();
61 if (!need_resched())
Kevin D. Kissell8531a352008-09-09 21:48:52 +020062 __asm__(" .set push \n"
63 " .set mips3 \n"
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090064 " wait \n"
Kevin D. Kissell8531a352008-09-09 21:48:52 +020065 " .set pop \n");
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090066 local_irq_enable();
Kevin D. Kissell8531a352008-09-09 21:48:52 +020067 __asm__(" .globl __pastwait \n"
68 "__pastwait: \n");
69 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -070070}
71
Ralf Baechle5a812992007-07-17 18:49:48 +010072/*
73 * The RM7000 variant has to handle erratum 38. The workaround is to not
74 * have any pending stores when the WAIT instruction is executed.
75 */
76static void rm7k_wait_irqoff(void)
77{
78 local_irq_disable();
79 if (!need_resched())
80 __asm__(
81 " .set push \n"
82 " .set mips3 \n"
83 " .set noat \n"
84 " mfc0 $1, $12 \n"
85 " sync \n"
86 " mtc0 $1, $12 # stalls until W stage \n"
87 " wait \n"
88 " mtc0 $1, $12 # stalls until W stage \n"
89 " .set pop \n");
90 local_irq_enable();
91}
92
Pete Popov494900a2005-04-07 00:42:10 +000093/* The Au1xxx wait is available only if using 32khz counter or
94 * external timer source, but specifically not CP0 Counter. */
Pete Popovfe359bf2005-04-08 08:34:43 +000095int allow_au1k_wait;
Ralf Baechle10f650d2005-05-25 13:32:49 +000096
Pete Popov494900a2005-04-07 00:42:10 +000097static void au1k_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070098{
Manuel Lauss0c694de2008-12-21 09:26:23 +010099 if (!allow_au1k_wait)
100 return;
101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 /* using the wait instruction makes CP0 counter unusable */
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900103 __asm__(" .set mips3 \n"
104 " cache 0x14, 0(%0) \n"
105 " cache 0x14, 32(%0) \n"
106 " sync \n"
107 " nop \n"
108 " wait \n"
109 " nop \n"
110 " nop \n"
111 " nop \n"
112 " nop \n"
113 " .set mips0 \n"
Ralf Baechle10f650d2005-05-25 13:32:49 +0000114 : : "r" (au1k_wait));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115}
116
Ralf Baechle55d04df2005-07-13 19:22:45 +0000117static int __initdata nowait = 0;
118
Atsushi Nemotof49a7472007-02-18 01:02:14 +0900119static int __init wait_disable(char *s)
Ralf Baechle55d04df2005-07-13 19:22:45 +0000120{
121 nowait = 1;
122
123 return 1;
124}
125
126__setup("nowait", wait_disable);
127
Atsushi Nemotoc65a5482007-11-12 02:05:18 +0900128void __init check_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129{
130 struct cpuinfo_mips *c = &current_cpu_data;
131
Ralf Baechle55d04df2005-07-13 19:22:45 +0000132 if (nowait) {
Ralf Baechlec2379232006-11-30 01:14:44 +0000133 printk("Wait instruction disabled.\n");
Ralf Baechle55d04df2005-07-13 19:22:45 +0000134 return;
135 }
136
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 switch (c->cputype) {
138 case CPU_R3081:
139 case CPU_R3081E:
140 cpu_wait = r3081_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 break;
142 case CPU_TX3927:
143 cpu_wait = r39xx_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 break;
145 case CPU_R4200:
146/* case CPU_R4300: */
147 case CPU_R4600:
148 case CPU_R4640:
149 case CPU_R4650:
150 case CPU_R4700:
151 case CPU_R5000:
Shinya Kuribayashia644b272009-03-03 18:05:51 +0900152 case CPU_R5500:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 case CPU_NEVADA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 case CPU_4KC:
155 case CPU_4KEC:
156 case CPU_4KSC:
157 case CPU_5KC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700158 case CPU_25KF:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100159 case CPU_PR4450:
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200160 case CPU_BCM3302:
David Daney0dd47812008-12-11 15:33:26 -0800161 case CPU_CAVIUM_OCTEON:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100164
Ralf Baechle5a812992007-07-17 18:49:48 +0100165 case CPU_RM7000:
166 cpu_wait = rm7k_wait_irqoff;
167 break;
168
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100169 case CPU_24K:
170 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100171 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100172 cpu_wait = r4k_wait;
173 if (read_c0_config7() & MIPS_CONF7_WII)
174 cpu_wait = r4k_wait_irqoff;
175 break;
176
177 case CPU_74K:
178 cpu_wait = r4k_wait;
179 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
180 cpu_wait = r4k_wait_irqoff;
181 break;
182
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900183 case CPU_TX49XX:
184 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900185 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 case CPU_AU1000:
187 case CPU_AU1100:
188 case CPU_AU1500:
Pete Popove3ad1c22005-03-01 06:33:16 +0000189 case CPU_AU1550:
190 case CPU_AU1200:
Manuel Lauss237cfee2007-12-06 09:07:55 +0100191 case CPU_AU1210:
192 case CPU_AU1250:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100193 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100195 case CPU_20KC:
196 /*
197 * WAIT on Rev1.0 has E1, E2, E3 and E16.
198 * WAIT on Rev2.0 and Rev3.0 has E16.
199 * Rev3.1 WAIT is nop, why bother
200 */
201 if ((c->processor_id & 0xff) <= 0x64)
202 break;
203
Ralf Baechle50da4692007-09-14 19:08:43 +0100204 /*
205 * Another rev is incremeting c0_count at a reduced clock
206 * rate while in WAIT mode. So we basically have the choice
207 * between using the cp0 timer as clocksource or avoiding
208 * the WAIT instruction. Until more details are known,
209 * disable the use of WAIT for 20Kc entirely.
210 cpu_wait = r4k_wait;
211 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100212 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100213 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000214 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100215 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100216 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 break;
219 }
220}
221
Marc St-Jean9267a302007-06-14 15:55:31 -0600222static inline void check_errata(void)
223{
224 struct cpuinfo_mips *c = &current_cpu_data;
225
226 switch (c->cputype) {
227 case CPU_34K:
228 /*
229 * Erratum "RPS May Cause Incorrect Instruction Execution"
230 * This code only handles VPE0, any SMP/SMTC/RTOS code
231 * making use of VPE1 will be responsable for that VPE.
232 */
233 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
234 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
235 break;
236 default:
237 break;
238 }
239}
240
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241void __init check_bugs32(void)
242{
Marc St-Jean9267a302007-06-14 15:55:31 -0600243 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244}
245
246/*
247 * Probe whether cpu has config register by trying to play with
248 * alternate cache bit and see whether it matters.
249 * It's used by cpu_probe to distinguish between R3000A and R3081.
250 */
251static inline int cpu_has_confreg(void)
252{
253#ifdef CONFIG_CPU_R3000
254 extern unsigned long r3k_cache_size(unsigned long);
255 unsigned long size1, size2;
256 unsigned long cfg = read_c0_conf();
257
258 size1 = r3k_cache_size(ST0_ISC);
259 write_c0_conf(cfg ^ R30XX_CONF_AC);
260 size2 = r3k_cache_size(ST0_ISC);
261 write_c0_conf(cfg);
262 return size1 != size2;
263#else
264 return 0;
265#endif
266}
267
268/*
269 * Get the FPU Implementation/Revision.
270 */
271static inline unsigned long cpu_get_fpu_id(void)
272{
273 unsigned long tmp, fpu_id;
274
275 tmp = read_c0_status();
276 __enable_fpu();
277 fpu_id = read_32bit_cp1_register(CP1_REVISION);
278 write_c0_status(tmp);
279 return fpu_id;
280}
281
282/*
283 * Check the CPU has an FPU the official way.
284 */
285static inline int __cpu_has_fpu(void)
286{
287 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
288}
289
Ralf Baechle02cf2112005-10-01 13:06:32 +0100290#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 | MIPS_CPU_COUNTER)
292
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000293static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294{
295 switch (c->processor_id & 0xff00) {
296 case PRID_IMP_R2000:
297 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000298 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100300 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
301 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302 if (__cpu_has_fpu())
303 c->options |= MIPS_CPU_FPU;
304 c->tlbsize = 64;
305 break;
306 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000307 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
308 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000310 __cpu_name[cpu] = "R3081";
311 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000313 __cpu_name[cpu] = "R3000A";
314 }
315 break;
316 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000318 __cpu_name[cpu] = "R3000";
319 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700320 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100321 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
322 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 if (__cpu_has_fpu())
324 c->options |= MIPS_CPU_FPU;
325 c->tlbsize = 64;
326 break;
327 case PRID_IMP_R4000:
328 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000329 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000331 __cpu_name[cpu] = "R4400PC";
332 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000334 __cpu_name[cpu] = "R4000PC";
335 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000337 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000339 __cpu_name[cpu] = "R4400SC";
340 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000342 __cpu_name[cpu] = "R4000SC";
343 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 }
345
346 c->isa_level = MIPS_CPU_ISA_III;
347 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
348 MIPS_CPU_WATCH | MIPS_CPU_VCE |
349 MIPS_CPU_LLSC;
350 c->tlbsize = 48;
351 break;
352 case PRID_IMP_VR41XX:
353 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 case PRID_REV_VR4111:
355 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000356 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 case PRID_REV_VR4121:
359 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000360 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 break;
362 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000363 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000365 __cpu_name[cpu] = "NEC VR4122";
366 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000368 __cpu_name[cpu] = "NEC VR4181A";
369 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 break;
371 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000372 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000374 __cpu_name[cpu] = "NEC VR4131";
375 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000377 __cpu_name[cpu] = "NEC VR4133";
378 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 break;
380 default:
381 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
382 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000383 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 break;
385 }
386 c->isa_level = MIPS_CPU_ISA_III;
387 c->options = R4K_OPTS;
388 c->tlbsize = 32;
389 break;
390 case PRID_IMP_R4300:
391 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000392 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 c->isa_level = MIPS_CPU_ISA_III;
394 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
395 MIPS_CPU_LLSC;
396 c->tlbsize = 32;
397 break;
398 case PRID_IMP_R4600:
399 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000400 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000402 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
403 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 c->tlbsize = 48;
405 break;
406 #if 0
407 case PRID_IMP_R4650:
408 /*
409 * This processor doesn't have an MMU, so it's not
410 * "real easy" to run Linux on it. It is left purely
411 * for documentation. Commented out because it shares
412 * it's c0_prid id number with the TX3900.
413 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000414 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000415 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 c->isa_level = MIPS_CPU_ISA_III;
417 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
418 c->tlbsize = 48;
419 break;
420 #endif
421 case PRID_IMP_TX39:
422 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100423 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424
425 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
426 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000427 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 c->tlbsize = 64;
429 } else {
430 switch (c->processor_id & 0xff) {
431 case PRID_REV_TX3912:
432 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000433 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 c->tlbsize = 32;
435 break;
436 case PRID_REV_TX3922:
437 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000438 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 c->tlbsize = 64;
440 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441 }
442 }
443 break;
444 case PRID_IMP_R4700:
445 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000446 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 c->isa_level = MIPS_CPU_ISA_III;
448 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
449 MIPS_CPU_LLSC;
450 c->tlbsize = 48;
451 break;
452 case PRID_IMP_TX49:
453 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000454 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 c->isa_level = MIPS_CPU_ISA_III;
456 c->options = R4K_OPTS | MIPS_CPU_LLSC;
457 if (!(c->processor_id & 0x08))
458 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
459 c->tlbsize = 48;
460 break;
461 case PRID_IMP_R5000:
462 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000463 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 c->isa_level = MIPS_CPU_ISA_IV;
465 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
466 MIPS_CPU_LLSC;
467 c->tlbsize = 48;
468 break;
469 case PRID_IMP_R5432:
470 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000471 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 c->isa_level = MIPS_CPU_ISA_IV;
473 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
474 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
475 c->tlbsize = 48;
476 break;
477 case PRID_IMP_R5500:
478 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000479 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 c->isa_level = MIPS_CPU_ISA_IV;
481 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
482 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
483 c->tlbsize = 48;
484 break;
485 case PRID_IMP_NEVADA:
486 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000487 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 c->isa_level = MIPS_CPU_ISA_IV;
489 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
490 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
491 c->tlbsize = 48;
492 break;
493 case PRID_IMP_R6000:
494 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000495 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 c->isa_level = MIPS_CPU_ISA_II;
497 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
498 MIPS_CPU_LLSC;
499 c->tlbsize = 32;
500 break;
501 case PRID_IMP_R6000A:
502 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000503 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 c->isa_level = MIPS_CPU_ISA_II;
505 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
506 MIPS_CPU_LLSC;
507 c->tlbsize = 32;
508 break;
509 case PRID_IMP_RM7000:
510 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000511 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 c->isa_level = MIPS_CPU_ISA_IV;
513 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
514 MIPS_CPU_LLSC;
515 /*
516 * Undocumented RM7000: Bit 29 in the info register of
517 * the RM7000 v2.0 indicates if the TLB has 48 or 64
518 * entries.
519 *
520 * 29 1 => 64 entry JTLB
521 * 0 => 48 entry JTLB
522 */
523 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
524 break;
525 case PRID_IMP_RM9000:
526 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000527 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 c->isa_level = MIPS_CPU_ISA_IV;
529 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
530 MIPS_CPU_LLSC;
531 /*
532 * Bit 29 in the info register of the RM9000
533 * indicates if the TLB has 48 or 64 entries.
534 *
535 * 29 1 => 64 entry JTLB
536 * 0 => 48 entry JTLB
537 */
538 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
539 break;
540 case PRID_IMP_R8000:
541 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000542 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 c->isa_level = MIPS_CPU_ISA_IV;
544 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
545 MIPS_CPU_FPU | MIPS_CPU_32FPR |
546 MIPS_CPU_LLSC;
547 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
548 break;
549 case PRID_IMP_R10000:
550 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000551 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000553 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 MIPS_CPU_FPU | MIPS_CPU_32FPR |
555 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
556 MIPS_CPU_LLSC;
557 c->tlbsize = 64;
558 break;
559 case PRID_IMP_R12000:
560 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000561 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000563 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700564 MIPS_CPU_FPU | MIPS_CPU_32FPR |
565 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
566 MIPS_CPU_LLSC;
567 c->tlbsize = 64;
568 break;
Kumba44d921b2006-05-16 22:23:59 -0400569 case PRID_IMP_R14000:
570 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000571 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400572 c->isa_level = MIPS_CPU_ISA_IV;
573 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
574 MIPS_CPU_FPU | MIPS_CPU_32FPR |
575 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
576 MIPS_CPU_LLSC;
577 c->tlbsize = 64;
578 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800579 case PRID_IMP_LOONGSON2:
580 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000581 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800582 c->isa_level = MIPS_CPU_ISA_III;
583 c->options = R4K_OPTS |
584 MIPS_CPU_FPU | MIPS_CPU_LLSC |
585 MIPS_CPU_32FPR;
586 c->tlbsize = 64;
587 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 }
589}
590
Ralf Baechle234fcd12008-03-08 09:56:28 +0000591static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000592 "Unsupported ISA type, c0.config0: %d.";
593
Ralf Baechle41943182005-05-05 16:45:59 +0000594static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595{
Ralf Baechle41943182005-05-05 16:45:59 +0000596 unsigned int config0;
597 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598
Ralf Baechle41943182005-05-05 16:45:59 +0000599 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600
Ralf Baechle41943182005-05-05 16:45:59 +0000601 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100602 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000603 isa = (config0 & MIPS_CONF_AT) >> 13;
604 switch (isa) {
605 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100606 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000607 case 0:
608 c->isa_level = MIPS_CPU_ISA_M32R1;
609 break;
610 case 1:
611 c->isa_level = MIPS_CPU_ISA_M32R2;
612 break;
613 default:
614 goto unknown;
615 }
Ralf Baechle41943182005-05-05 16:45:59 +0000616 break;
617 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100618 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000619 case 0:
620 c->isa_level = MIPS_CPU_ISA_M64R1;
621 break;
622 case 1:
623 c->isa_level = MIPS_CPU_ISA_M64R2;
624 break;
625 default:
626 goto unknown;
627 }
Ralf Baechle41943182005-05-05 16:45:59 +0000628 break;
629 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000630 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000631 }
632
633 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000634
635unknown:
636 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000637}
638
639static inline unsigned int decode_config1(struct cpuinfo_mips *c)
640{
641 unsigned int config1;
642
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000644
645 if (config1 & MIPS_CONF1_MD)
646 c->ases |= MIPS_ASE_MDMX;
647 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000649 if (config1 & MIPS_CONF1_CA)
650 c->ases |= MIPS_ASE_MIPS16;
651 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000653 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 c->options |= MIPS_CPU_FPU;
655 c->options |= MIPS_CPU_32FPR;
656 }
Ralf Baechle41943182005-05-05 16:45:59 +0000657 if (cpu_has_tlb)
658 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
659
660 return config1 & MIPS_CONF_M;
661}
662
663static inline unsigned int decode_config2(struct cpuinfo_mips *c)
664{
665 unsigned int config2;
666
667 config2 = read_c0_config2();
668
669 if (config2 & MIPS_CONF2_SL)
670 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
671
672 return config2 & MIPS_CONF_M;
673}
674
675static inline unsigned int decode_config3(struct cpuinfo_mips *c)
676{
677 unsigned int config3;
678
679 config3 = read_c0_config3();
680
681 if (config3 & MIPS_CONF3_SM)
682 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a8f2005-05-31 11:49:19 +0000683 if (config3 & MIPS_CONF3_DSP)
684 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000685 if (config3 & MIPS_CONF3_VINT)
686 c->options |= MIPS_CPU_VINT;
687 if (config3 & MIPS_CONF3_VEIC)
688 c->options |= MIPS_CPU_VEIC;
689 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000690 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100691 if (config3 & MIPS_CONF3_ULRI)
692 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000693
694 return config3 & MIPS_CONF_M;
695}
696
Ralf Baechle234fcd12008-03-08 09:56:28 +0000697static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000698{
Ralf Baechle558ce122008-10-29 12:33:34 +0000699 int ok;
700
Ralf Baechle41943182005-05-05 16:45:59 +0000701 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100702 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
703 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000704
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
706
Ralf Baechle558ce122008-10-29 12:33:34 +0000707 ok = decode_config0(c); /* Read Config registers. */
708 BUG_ON(!ok); /* Arch spec violation! */
709 if (ok)
710 ok = decode_config1(c);
711 if (ok)
712 ok = decode_config2(c);
713 if (ok)
714 ok = decode_config3(c);
715
716 mips_probe_watch_registers(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717}
718
Chris Dearman0b6d4972007-09-13 12:32:02 +0100719#ifdef CONFIG_CPU_MIPSR2
720extern void spram_config(void);
721#else
722static inline void spram_config(void) {}
723#endif
724
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000725static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726{
Ralf Baechle41943182005-05-05 16:45:59 +0000727 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 switch (c->processor_id & 0xff00) {
729 case PRID_IMP_4KC:
730 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000731 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 break;
733 case PRID_IMP_4KEC:
734 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000735 __cpu_name[cpu] = "MIPS 4KEc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 break;
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000737 case PRID_IMP_4KECR2:
738 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000739 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000740 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100742 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700743 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000744 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 break;
746 case PRID_IMP_5KC:
747 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000748 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 break;
750 case PRID_IMP_20KC:
751 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000752 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 break;
754 case PRID_IMP_24K:
Ralf Baechlee50c0a8f2005-05-31 11:49:19 +0000755 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000757 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 break;
759 case PRID_IMP_25KF:
760 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000761 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000763 case PRID_IMP_34K:
764 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000765 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000766 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100767 case PRID_IMP_74K:
768 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000769 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100770 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100771 case PRID_IMP_1004K:
772 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000773 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100774 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100776
777 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778}
779
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000780static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781{
Ralf Baechle41943182005-05-05 16:45:59 +0000782 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 switch (c->processor_id & 0xff00) {
784 case PRID_IMP_AU1_REV1:
785 case PRID_IMP_AU1_REV2:
786 switch ((c->processor_id >> 24) & 0xff) {
787 case 0:
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000788 c->cputype = CPU_AU1000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000789 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 break;
791 case 1:
792 c->cputype = CPU_AU1500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000793 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 break;
795 case 2:
796 c->cputype = CPU_AU1100;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000797 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 break;
799 case 3:
800 c->cputype = CPU_AU1550;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000801 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000803 case 4:
804 c->cputype = CPU_AU1200;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000805 __cpu_name[cpu] = "Au1200";
806 if ((c->processor_id & 0xff) == 2) {
Manuel Lauss237cfee2007-12-06 09:07:55 +0100807 c->cputype = CPU_AU1250;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000808 __cpu_name[cpu] = "Au1250";
809 }
Manuel Lauss237cfee2007-12-06 09:07:55 +0100810 break;
811 case 5:
812 c->cputype = CPU_AU1210;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000813 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000814 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 default:
816 panic("Unknown Au Core!");
817 break;
818 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 break;
820 }
821}
822
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000823static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824{
Ralf Baechle41943182005-05-05 16:45:59 +0000825 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100826
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 switch (c->processor_id & 0xff00) {
828 case PRID_IMP_SB1:
829 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000830 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100832 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000833 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700835 case PRID_IMP_SB1A:
836 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000837 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700838 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 }
840}
841
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000842static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843{
Ralf Baechle41943182005-05-05 16:45:59 +0000844 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 switch (c->processor_id & 0xff00) {
846 case PRID_IMP_SR71000:
847 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000848 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 c->scache.ways = 8;
850 c->tlbsize = 64;
851 break;
852 }
853}
854
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000855static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000856{
857 decode_configs(c);
858 switch (c->processor_id & 0xff00) {
859 case PRID_IMP_PR4450:
860 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000861 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000862 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000863 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000864 }
865}
866
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000867static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200868{
869 decode_configs(c);
870 switch (c->processor_id & 0xff00) {
871 case PRID_IMP_BCM3302:
872 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000873 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200874 break;
875 case PRID_IMP_BCM4710:
876 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000877 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200878 break;
879 }
880}
881
David Daney0dd47812008-12-11 15:33:26 -0800882static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
883{
884 decode_configs(c);
885 switch (c->processor_id & 0xff00) {
886 case PRID_IMP_CAVIUM_CN38XX:
887 case PRID_IMP_CAVIUM_CN31XX:
888 case PRID_IMP_CAVIUM_CN30XX:
889 case PRID_IMP_CAVIUM_CN58XX:
890 case PRID_IMP_CAVIUM_CN56XX:
891 case PRID_IMP_CAVIUM_CN50XX:
892 case PRID_IMP_CAVIUM_CN52XX:
893 c->cputype = CPU_CAVIUM_OCTEON;
894 __cpu_name[cpu] = "Cavium Octeon";
895 break;
896 default:
897 printk(KERN_INFO "Unknown Octeon chip!\n");
898 c->cputype = CPU_UNKNOWN;
899 break;
900 }
901}
902
Ralf Baechle9966db252007-10-11 23:46:17 +0100903const char *__cpu_name[NR_CPUS];
904
Ralf Baechle234fcd12008-03-08 09:56:28 +0000905__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906{
907 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100908 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909
910 c->processor_id = PRID_IMP_UNKNOWN;
911 c->fpu_id = FPIR_IMP_NONE;
912 c->cputype = CPU_UNKNOWN;
913
914 c->processor_id = read_c0_prid();
915 switch (c->processor_id & 0xff0000) {
916 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000917 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918 break;
919 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000920 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921 break;
922 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000923 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924 break;
925 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000926 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200928 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000929 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200930 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000932 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933 break;
Daniel Lairda92b0582008-03-06 09:07:18 +0000934 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000935 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000936 break;
David Daney0dd47812008-12-11 15:33:26 -0800937 case PRID_COMP_CAVIUM:
938 cpu_probe_cavium(c, cpu);
939 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200941
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000942 BUG_ON(!__cpu_name[cpu]);
943 BUG_ON(c->cputype == CPU_UNKNOWN);
944
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200945 /*
946 * Platform code can force the cpu type to optimize code
947 * generation. In that case be sure the cpu type is correctly
948 * manually setup otherwise it could trigger some nasty bugs.
949 */
950 BUG_ON(current_cpu_type() != c->cputype);
951
Ralf Baechle41943182005-05-05 16:45:59 +0000952 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +0000954
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000955 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +0000956 c->isa_level == MIPS_CPU_ISA_M32R2 ||
957 c->isa_level == MIPS_CPU_ISA_M64R1 ||
958 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +0000959 if (c->fpu_id & MIPS_FPIR_3D)
960 c->ases |= MIPS_ASE_MIPS3D;
961 }
962 }
Ralf Baechle9966db252007-10-11 23:46:17 +0100963
Ralf Baechlef6771db2007-11-08 18:02:29 +0000964 if (cpu_has_mips_r2)
965 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
966 else
967 c->srsets = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968}
969
Ralf Baechle234fcd12008-03-08 09:56:28 +0000970__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971{
972 struct cpuinfo_mips *c = &current_cpu_data;
973
Ralf Baechle9966db252007-10-11 23:46:17 +0100974 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
975 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700976 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +0100977 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978}