blob: 4579d5c12da9cc5ec2d26ee8f0daf2d5a357a519 [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>
Ralf Baechle631330f2009-06-19 14:05:26 +010017#include <linux/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/stddef.h>
19
Ralf Baechle57599062007-02-18 19:07:31 +000020#include <asm/bugs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/cpu.h>
22#include <asm/fpu.h>
23#include <asm/mipsregs.h>
24#include <asm/system.h>
David Daney654f57b2008-09-23 00:07:16 -070025#include <asm/watch.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27/*
28 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
29 * the implementation of the "wait" feature differs between CPU families. This
30 * points to the function that implements CPU specific wait.
31 * The wait instruction stops the pipeline and reduces the power consumption of
32 * the CPU very much.
33 */
Ralf Baechle982f6ff2009-09-17 02:25:07 +020034void (*cpu_wait)(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36static void r3081_wait(void)
37{
38 unsigned long cfg = read_c0_conf();
39 write_c0_conf(cfg | R30XX_CONF_HALT);
40}
41
42static void r39xx_wait(void)
43{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090044 local_irq_disable();
45 if (!need_resched())
46 write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
47 local_irq_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070048}
49
Atsushi Nemotoc65a5482007-11-12 02:05:18 +090050extern void r4k_wait(void);
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090051
52/*
53 * This variant is preferable as it allows testing need_resched and going to
54 * sleep depending on the outcome atomically. Unfortunately the "It is
55 * implementation-dependent whether the pipeline restarts when a non-enabled
56 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
57 * using this version a gamble.
58 */
Kevin D. Kissell8531a352008-09-09 21:48:52 +020059void r4k_wait_irqoff(void)
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090060{
61 local_irq_disable();
62 if (!need_resched())
Kevin D. Kissell8531a352008-09-09 21:48:52 +020063 __asm__(" .set push \n"
64 " .set mips3 \n"
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090065 " wait \n"
Kevin D. Kissell8531a352008-09-09 21:48:52 +020066 " .set pop \n");
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090067 local_irq_enable();
Kevin D. Kissell8531a352008-09-09 21:48:52 +020068 __asm__(" .globl __pastwait \n"
69 "__pastwait: \n");
70 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071}
72
Ralf Baechle5a812992007-07-17 18:49:48 +010073/*
74 * The RM7000 variant has to handle erratum 38. The workaround is to not
75 * have any pending stores when the WAIT instruction is executed.
76 */
77static void rm7k_wait_irqoff(void)
78{
79 local_irq_disable();
80 if (!need_resched())
81 __asm__(
82 " .set push \n"
83 " .set mips3 \n"
84 " .set noat \n"
85 " mfc0 $1, $12 \n"
86 " sync \n"
87 " mtc0 $1, $12 # stalls until W stage \n"
88 " wait \n"
89 " mtc0 $1, $12 # stalls until W stage \n"
90 " .set pop \n");
91 local_irq_enable();
92}
93
Manuel Lauss2882b0c2009-08-22 18:09:27 +020094/*
95 * The Au1xxx wait is available only if using 32khz counter or
96 * external timer source, but specifically not CP0 Counter.
97 * alchemy/common/time.c may override cpu_wait!
98 */
Pete Popov494900a2005-04-07 00:42:10 +000099static void au1k_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900101 __asm__(" .set mips3 \n"
102 " cache 0x14, 0(%0) \n"
103 " cache 0x14, 32(%0) \n"
104 " sync \n"
105 " nop \n"
106 " wait \n"
107 " nop \n"
108 " nop \n"
109 " nop \n"
110 " nop \n"
111 " .set mips0 \n"
Ralf Baechle10f650d2005-05-25 13:32:49 +0000112 : : "r" (au1k_wait));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113}
114
Ralf Baechle982f6ff2009-09-17 02:25:07 +0200115static int __initdata nowait;
Ralf Baechle55d04df2005-07-13 19:22:45 +0000116
Atsushi Nemotof49a7472007-02-18 01:02:14 +0900117static int __init wait_disable(char *s)
Ralf Baechle55d04df2005-07-13 19:22:45 +0000118{
119 nowait = 1;
120
121 return 1;
122}
123
124__setup("nowait", wait_disable);
125
Atsushi Nemotoc65a5482007-11-12 02:05:18 +0900126void __init check_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127{
128 struct cpuinfo_mips *c = &current_cpu_data;
129
Ralf Baechle55d04df2005-07-13 19:22:45 +0000130 if (nowait) {
Ralf Baechlec2379232006-11-30 01:14:44 +0000131 printk("Wait instruction disabled.\n");
Ralf Baechle55d04df2005-07-13 19:22:45 +0000132 return;
133 }
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 switch (c->cputype) {
136 case CPU_R3081:
137 case CPU_R3081E:
138 cpu_wait = r3081_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 break;
140 case CPU_TX3927:
141 cpu_wait = r39xx_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 break;
143 case CPU_R4200:
144/* case CPU_R4300: */
145 case CPU_R4600:
146 case CPU_R4640:
147 case CPU_R4650:
148 case CPU_R4700:
149 case CPU_R5000:
Shinya Kuribayashia644b272009-03-03 18:05:51 +0900150 case CPU_R5500:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 case CPU_NEVADA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 case CPU_4KC:
153 case CPU_4KEC:
154 case CPU_4KSC:
155 case CPU_5KC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 case CPU_25KF:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100157 case CPU_PR4450:
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200158 case CPU_BCM3302:
David Daney0dd47812008-12-11 15:33:26 -0800159 case CPU_CAVIUM_OCTEON:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100162
Ralf Baechle5a812992007-07-17 18:49:48 +0100163 case CPU_RM7000:
164 cpu_wait = rm7k_wait_irqoff;
165 break;
166
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100167 case CPU_24K:
168 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100169 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100170 cpu_wait = r4k_wait;
171 if (read_c0_config7() & MIPS_CONF7_WII)
172 cpu_wait = r4k_wait_irqoff;
173 break;
174
175 case CPU_74K:
176 cpu_wait = r4k_wait;
177 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
178 cpu_wait = r4k_wait_irqoff;
179 break;
180
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900181 case CPU_TX49XX:
182 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900183 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100184 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100185 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100187 case CPU_20KC:
188 /*
189 * WAIT on Rev1.0 has E1, E2, E3 and E16.
190 * WAIT on Rev2.0 and Rev3.0 has E16.
191 * Rev3.1 WAIT is nop, why bother
192 */
193 if ((c->processor_id & 0xff) <= 0x64)
194 break;
195
Ralf Baechle50da4692007-09-14 19:08:43 +0100196 /*
197 * Another rev is incremeting c0_count at a reduced clock
198 * rate while in WAIT mode. So we basically have the choice
199 * between using the cp0 timer as clocksource or avoiding
200 * the WAIT instruction. Until more details are known,
201 * disable the use of WAIT for 20Kc entirely.
202 cpu_wait = r4k_wait;
203 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100204 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100205 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000206 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100207 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100208 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 break;
211 }
212}
213
Marc St-Jean9267a302007-06-14 15:55:31 -0600214static inline void check_errata(void)
215{
216 struct cpuinfo_mips *c = &current_cpu_data;
217
218 switch (c->cputype) {
219 case CPU_34K:
220 /*
221 * Erratum "RPS May Cause Incorrect Instruction Execution"
222 * This code only handles VPE0, any SMP/SMTC/RTOS code
223 * making use of VPE1 will be responsable for that VPE.
224 */
225 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
226 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
227 break;
228 default:
229 break;
230 }
231}
232
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233void __init check_bugs32(void)
234{
Marc St-Jean9267a302007-06-14 15:55:31 -0600235 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236}
237
238/*
239 * Probe whether cpu has config register by trying to play with
240 * alternate cache bit and see whether it matters.
241 * It's used by cpu_probe to distinguish between R3000A and R3081.
242 */
243static inline int cpu_has_confreg(void)
244{
245#ifdef CONFIG_CPU_R3000
246 extern unsigned long r3k_cache_size(unsigned long);
247 unsigned long size1, size2;
248 unsigned long cfg = read_c0_conf();
249
250 size1 = r3k_cache_size(ST0_ISC);
251 write_c0_conf(cfg ^ R30XX_CONF_AC);
252 size2 = r3k_cache_size(ST0_ISC);
253 write_c0_conf(cfg);
254 return size1 != size2;
255#else
256 return 0;
257#endif
258}
259
260/*
261 * Get the FPU Implementation/Revision.
262 */
263static inline unsigned long cpu_get_fpu_id(void)
264{
265 unsigned long tmp, fpu_id;
266
267 tmp = read_c0_status();
268 __enable_fpu();
269 fpu_id = read_32bit_cp1_register(CP1_REVISION);
270 write_c0_status(tmp);
271 return fpu_id;
272}
273
274/*
275 * Check the CPU has an FPU the official way.
276 */
277static inline int __cpu_has_fpu(void)
278{
279 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
280}
281
Ralf Baechle02cf2112005-10-01 13:06:32 +0100282#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 | MIPS_CPU_COUNTER)
284
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000285static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286{
287 switch (c->processor_id & 0xff00) {
288 case PRID_IMP_R2000:
289 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000290 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100292 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
293 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 if (__cpu_has_fpu())
295 c->options |= MIPS_CPU_FPU;
296 c->tlbsize = 64;
297 break;
298 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000299 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
300 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000302 __cpu_name[cpu] = "R3081";
303 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000305 __cpu_name[cpu] = "R3000A";
306 }
307 break;
308 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700309 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000310 __cpu_name[cpu] = "R3000";
311 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100313 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
314 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 if (__cpu_has_fpu())
316 c->options |= MIPS_CPU_FPU;
317 c->tlbsize = 64;
318 break;
319 case PRID_IMP_R4000:
320 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000321 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000323 __cpu_name[cpu] = "R4400PC";
324 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000326 __cpu_name[cpu] = "R4000PC";
327 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 } else {
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_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000331 __cpu_name[cpu] = "R4400SC";
332 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000334 __cpu_name[cpu] = "R4000SC";
335 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 }
337
338 c->isa_level = MIPS_CPU_ISA_III;
339 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
340 MIPS_CPU_WATCH | MIPS_CPU_VCE |
341 MIPS_CPU_LLSC;
342 c->tlbsize = 48;
343 break;
344 case PRID_IMP_VR41XX:
345 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700346 case PRID_REV_VR4111:
347 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000348 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 case PRID_REV_VR4121:
351 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000352 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 break;
354 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000355 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000357 __cpu_name[cpu] = "NEC VR4122";
358 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000360 __cpu_name[cpu] = "NEC VR4181A";
361 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 break;
363 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000364 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000366 __cpu_name[cpu] = "NEC VR4131";
367 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000369 __cpu_name[cpu] = "NEC VR4133";
370 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 break;
372 default:
373 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
374 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000375 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 break;
377 }
378 c->isa_level = MIPS_CPU_ISA_III;
379 c->options = R4K_OPTS;
380 c->tlbsize = 32;
381 break;
382 case PRID_IMP_R4300:
383 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000384 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 c->isa_level = MIPS_CPU_ISA_III;
386 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
387 MIPS_CPU_LLSC;
388 c->tlbsize = 32;
389 break;
390 case PRID_IMP_R4600:
391 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000392 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000394 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
395 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 c->tlbsize = 48;
397 break;
398 #if 0
399 case PRID_IMP_R4650:
400 /*
401 * This processor doesn't have an MMU, so it's not
402 * "real easy" to run Linux on it. It is left purely
403 * for documentation. Commented out because it shares
404 * it's c0_prid id number with the TX3900.
405 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000406 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000407 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 c->isa_level = MIPS_CPU_ISA_III;
409 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
410 c->tlbsize = 48;
411 break;
412 #endif
413 case PRID_IMP_TX39:
414 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100415 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416
417 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
418 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000419 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 c->tlbsize = 64;
421 } else {
422 switch (c->processor_id & 0xff) {
423 case PRID_REV_TX3912:
424 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000425 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 c->tlbsize = 32;
427 break;
428 case PRID_REV_TX3922:
429 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000430 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 c->tlbsize = 64;
432 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 }
434 }
435 break;
436 case PRID_IMP_R4700:
437 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000438 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 c->isa_level = MIPS_CPU_ISA_III;
440 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
441 MIPS_CPU_LLSC;
442 c->tlbsize = 48;
443 break;
444 case PRID_IMP_TX49:
445 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000446 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 c->isa_level = MIPS_CPU_ISA_III;
448 c->options = R4K_OPTS | MIPS_CPU_LLSC;
449 if (!(c->processor_id & 0x08))
450 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
451 c->tlbsize = 48;
452 break;
453 case PRID_IMP_R5000:
454 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000455 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 c->isa_level = MIPS_CPU_ISA_IV;
457 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
458 MIPS_CPU_LLSC;
459 c->tlbsize = 48;
460 break;
461 case PRID_IMP_R5432:
462 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000463 __cpu_name[cpu] = "R5432";
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_WATCH | MIPS_CPU_LLSC;
467 c->tlbsize = 48;
468 break;
469 case PRID_IMP_R5500:
470 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000471 __cpu_name[cpu] = "R5500";
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_NEVADA:
478 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000479 __cpu_name[cpu] = "Nevada";
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_DIVEC | MIPS_CPU_LLSC;
483 c->tlbsize = 48;
484 break;
485 case PRID_IMP_R6000:
486 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000487 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 c->isa_level = MIPS_CPU_ISA_II;
489 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
490 MIPS_CPU_LLSC;
491 c->tlbsize = 32;
492 break;
493 case PRID_IMP_R6000A:
494 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000495 __cpu_name[cpu] = "R6000A";
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_RM7000:
502 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000503 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 c->isa_level = MIPS_CPU_ISA_IV;
505 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
506 MIPS_CPU_LLSC;
507 /*
508 * Undocumented RM7000: Bit 29 in the info register of
509 * the RM7000 v2.0 indicates if the TLB has 48 or 64
510 * entries.
511 *
512 * 29 1 => 64 entry JTLB
513 * 0 => 48 entry JTLB
514 */
515 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
516 break;
517 case PRID_IMP_RM9000:
518 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000519 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 c->isa_level = MIPS_CPU_ISA_IV;
521 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
522 MIPS_CPU_LLSC;
523 /*
524 * Bit 29 in the info register of the RM9000
525 * indicates if the TLB has 48 or 64 entries.
526 *
527 * 29 1 => 64 entry JTLB
528 * 0 => 48 entry JTLB
529 */
530 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
531 break;
532 case PRID_IMP_R8000:
533 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000534 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 c->isa_level = MIPS_CPU_ISA_IV;
536 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
537 MIPS_CPU_FPU | MIPS_CPU_32FPR |
538 MIPS_CPU_LLSC;
539 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
540 break;
541 case PRID_IMP_R10000:
542 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000543 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000545 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 MIPS_CPU_FPU | MIPS_CPU_32FPR |
547 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
548 MIPS_CPU_LLSC;
549 c->tlbsize = 64;
550 break;
551 case PRID_IMP_R12000:
552 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000553 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700554 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000555 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 MIPS_CPU_FPU | MIPS_CPU_32FPR |
557 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
558 MIPS_CPU_LLSC;
559 c->tlbsize = 64;
560 break;
Kumba44d921b2006-05-16 22:23:59 -0400561 case PRID_IMP_R14000:
562 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000563 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400564 c->isa_level = MIPS_CPU_ISA_IV;
565 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
566 MIPS_CPU_FPU | MIPS_CPU_32FPR |
567 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
568 MIPS_CPU_LLSC;
569 c->tlbsize = 64;
570 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800571 case PRID_IMP_LOONGSON2:
572 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000573 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800574 c->isa_level = MIPS_CPU_ISA_III;
575 c->options = R4K_OPTS |
576 MIPS_CPU_FPU | MIPS_CPU_LLSC |
577 MIPS_CPU_32FPR;
578 c->tlbsize = 64;
579 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 }
581}
582
Ralf Baechle234fcd12008-03-08 09:56:28 +0000583static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000584 "Unsupported ISA type, c0.config0: %d.";
585
Ralf Baechle41943182005-05-05 16:45:59 +0000586static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587{
Ralf Baechle41943182005-05-05 16:45:59 +0000588 unsigned int config0;
589 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590
Ralf Baechle41943182005-05-05 16:45:59 +0000591 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592
Ralf Baechle41943182005-05-05 16:45:59 +0000593 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100594 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000595 isa = (config0 & MIPS_CONF_AT) >> 13;
596 switch (isa) {
597 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100598 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000599 case 0:
600 c->isa_level = MIPS_CPU_ISA_M32R1;
601 break;
602 case 1:
603 c->isa_level = MIPS_CPU_ISA_M32R2;
604 break;
605 default:
606 goto unknown;
607 }
Ralf Baechle41943182005-05-05 16:45:59 +0000608 break;
609 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100610 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000611 case 0:
612 c->isa_level = MIPS_CPU_ISA_M64R1;
613 break;
614 case 1:
615 c->isa_level = MIPS_CPU_ISA_M64R2;
616 break;
617 default:
618 goto unknown;
619 }
Ralf Baechle41943182005-05-05 16:45:59 +0000620 break;
621 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000622 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000623 }
624
625 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000626
627unknown:
628 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000629}
630
631static inline unsigned int decode_config1(struct cpuinfo_mips *c)
632{
633 unsigned int config1;
634
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000636
637 if (config1 & MIPS_CONF1_MD)
638 c->ases |= MIPS_ASE_MDMX;
639 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700640 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000641 if (config1 & MIPS_CONF1_CA)
642 c->ases |= MIPS_ASE_MIPS16;
643 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000645 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 c->options |= MIPS_CPU_FPU;
647 c->options |= MIPS_CPU_32FPR;
648 }
Ralf Baechle41943182005-05-05 16:45:59 +0000649 if (cpu_has_tlb)
650 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
651
652 return config1 & MIPS_CONF_M;
653}
654
655static inline unsigned int decode_config2(struct cpuinfo_mips *c)
656{
657 unsigned int config2;
658
659 config2 = read_c0_config2();
660
661 if (config2 & MIPS_CONF2_SL)
662 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
663
664 return config2 & MIPS_CONF_M;
665}
666
667static inline unsigned int decode_config3(struct cpuinfo_mips *c)
668{
669 unsigned int config3;
670
671 config3 = read_c0_config3();
672
673 if (config3 & MIPS_CONF3_SM)
674 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a8f2005-05-31 11:49:19 +0000675 if (config3 & MIPS_CONF3_DSP)
676 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000677 if (config3 & MIPS_CONF3_VINT)
678 c->options |= MIPS_CPU_VINT;
679 if (config3 & MIPS_CONF3_VEIC)
680 c->options |= MIPS_CPU_VEIC;
681 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000682 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100683 if (config3 & MIPS_CONF3_ULRI)
684 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000685
686 return config3 & MIPS_CONF_M;
687}
688
Ralf Baechle234fcd12008-03-08 09:56:28 +0000689static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000690{
Ralf Baechle558ce122008-10-29 12:33:34 +0000691 int ok;
692
Ralf Baechle41943182005-05-05 16:45:59 +0000693 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100694 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
695 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000696
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
698
Ralf Baechle558ce122008-10-29 12:33:34 +0000699 ok = decode_config0(c); /* Read Config registers. */
700 BUG_ON(!ok); /* Arch spec violation! */
701 if (ok)
702 ok = decode_config1(c);
703 if (ok)
704 ok = decode_config2(c);
705 if (ok)
706 ok = decode_config3(c);
707
708 mips_probe_watch_registers(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709}
710
Chris Dearman0b6d4972007-09-13 12:32:02 +0100711#ifdef CONFIG_CPU_MIPSR2
712extern void spram_config(void);
713#else
714static inline void spram_config(void) {}
715#endif
716
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000717static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718{
Ralf Baechle41943182005-05-05 16:45:59 +0000719 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 switch (c->processor_id & 0xff00) {
721 case PRID_IMP_4KC:
722 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000723 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 break;
725 case PRID_IMP_4KEC:
726 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000727 __cpu_name[cpu] = "MIPS 4KEc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 break;
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000729 case PRID_IMP_4KECR2:
730 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000731 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000732 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100734 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000736 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700737 break;
738 case PRID_IMP_5KC:
739 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000740 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 break;
742 case PRID_IMP_20KC:
743 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000744 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 break;
746 case PRID_IMP_24K:
Ralf Baechlee50c0a8f2005-05-31 11:49:19 +0000747 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000749 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 break;
751 case PRID_IMP_25KF:
752 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000753 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000755 case PRID_IMP_34K:
756 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000757 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000758 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100759 case PRID_IMP_74K:
760 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000761 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100762 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100763 case PRID_IMP_1004K:
764 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000765 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100766 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100768
769 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770}
771
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000772static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773{
Ralf Baechle41943182005-05-05 16:45:59 +0000774 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 switch (c->processor_id & 0xff00) {
776 case PRID_IMP_AU1_REV1:
777 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100778 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 switch ((c->processor_id >> 24) & 0xff) {
780 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000781 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 break;
783 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000784 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 break;
786 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000787 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 break;
789 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000790 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000792 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000793 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100794 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000795 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100796 break;
797 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000798 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000799 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100801 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 break;
803 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 break;
805 }
806}
807
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000808static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809{
Ralf Baechle41943182005-05-05 16:45:59 +0000810 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100811
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 switch (c->processor_id & 0xff00) {
813 case PRID_IMP_SB1:
814 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000815 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100817 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000818 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700820 case PRID_IMP_SB1A:
821 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000822 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700823 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 }
825}
826
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000827static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828{
Ralf Baechle41943182005-05-05 16:45:59 +0000829 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 switch (c->processor_id & 0xff00) {
831 case PRID_IMP_SR71000:
832 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000833 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 c->scache.ways = 8;
835 c->tlbsize = 64;
836 break;
837 }
838}
839
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000840static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000841{
842 decode_configs(c);
843 switch (c->processor_id & 0xff00) {
844 case PRID_IMP_PR4450:
845 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000846 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000847 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000848 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000849 }
850}
851
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000852static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200853{
854 decode_configs(c);
855 switch (c->processor_id & 0xff00) {
856 case PRID_IMP_BCM3302:
857 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000858 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200859 break;
860 case PRID_IMP_BCM4710:
861 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000862 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200863 break;
864 }
865}
866
David Daney0dd47812008-12-11 15:33:26 -0800867static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
868{
869 decode_configs(c);
870 switch (c->processor_id & 0xff00) {
871 case PRID_IMP_CAVIUM_CN38XX:
872 case PRID_IMP_CAVIUM_CN31XX:
873 case PRID_IMP_CAVIUM_CN30XX:
874 case PRID_IMP_CAVIUM_CN58XX:
875 case PRID_IMP_CAVIUM_CN56XX:
876 case PRID_IMP_CAVIUM_CN50XX:
877 case PRID_IMP_CAVIUM_CN52XX:
878 c->cputype = CPU_CAVIUM_OCTEON;
879 __cpu_name[cpu] = "Cavium Octeon";
880 break;
881 default:
882 printk(KERN_INFO "Unknown Octeon chip!\n");
883 c->cputype = CPU_UNKNOWN;
884 break;
885 }
886}
887
Ralf Baechle9966db252007-10-11 23:46:17 +0100888const char *__cpu_name[NR_CPUS];
889
Ralf Baechle234fcd12008-03-08 09:56:28 +0000890__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891{
892 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100893 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894
895 c->processor_id = PRID_IMP_UNKNOWN;
896 c->fpu_id = FPIR_IMP_NONE;
897 c->cputype = CPU_UNKNOWN;
898
899 c->processor_id = read_c0_prid();
900 switch (c->processor_id & 0xff0000) {
901 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000902 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 break;
904 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000905 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 break;
907 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000908 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 break;
910 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000911 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200913 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000914 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200915 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000917 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918 break;
Daniel Lairda92b0582008-03-06 09:07:18 +0000919 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000920 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000921 break;
David Daney0dd47812008-12-11 15:33:26 -0800922 case PRID_COMP_CAVIUM:
923 cpu_probe_cavium(c, cpu);
924 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200926
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000927 BUG_ON(!__cpu_name[cpu]);
928 BUG_ON(c->cputype == CPU_UNKNOWN);
929
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200930 /*
931 * Platform code can force the cpu type to optimize code
932 * generation. In that case be sure the cpu type is correctly
933 * manually setup otherwise it could trigger some nasty bugs.
934 */
935 BUG_ON(current_cpu_type() != c->cputype);
936
Ralf Baechle41943182005-05-05 16:45:59 +0000937 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +0000939
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000940 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +0000941 c->isa_level == MIPS_CPU_ISA_M32R2 ||
942 c->isa_level == MIPS_CPU_ISA_M64R1 ||
943 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +0000944 if (c->fpu_id & MIPS_FPIR_3D)
945 c->ases |= MIPS_ASE_MIPS3D;
946 }
947 }
Ralf Baechle9966db252007-10-11 23:46:17 +0100948
Ralf Baechlef6771db2007-11-08 18:02:29 +0000949 if (cpu_has_mips_r2)
950 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
951 else
952 c->srsets = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953}
954
Ralf Baechle234fcd12008-03-08 09:56:28 +0000955__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956{
957 struct cpuinfo_mips *c = &current_cpu_data;
958
Ralf Baechle9966db252007-10-11 23:46:17 +0100959 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
960 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +0100962 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963}