blob: 1abe9905c9c1895ef220bc51f7f4ddf366b5cfad [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 */
34void (*cpu_wait)(void) = NULL;
35
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
Pete Popov494900a2005-04-07 00:42:10 +000094/* The Au1xxx wait is available only if using 32khz counter or
95 * external timer source, but specifically not CP0 Counter. */
Pete Popovfe359bf2005-04-08 08:34:43 +000096int allow_au1k_wait;
Ralf Baechle10f650d2005-05-25 13:32:49 +000097
Pete Popov494900a2005-04-07 00:42:10 +000098static void au1k_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070099{
Manuel Lauss0c694de2008-12-21 09:26:23 +0100100 if (!allow_au1k_wait)
101 return;
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 /* using the wait instruction makes CP0 counter unusable */
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900104 __asm__(" .set mips3 \n"
105 " cache 0x14, 0(%0) \n"
106 " cache 0x14, 32(%0) \n"
107 " sync \n"
108 " nop \n"
109 " wait \n"
110 " nop \n"
111 " nop \n"
112 " nop \n"
113 " nop \n"
114 " .set mips0 \n"
Ralf Baechle10f650d2005-05-25 13:32:49 +0000115 : : "r" (au1k_wait));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116}
117
Ralf Baechle55d04df2005-07-13 19:22:45 +0000118static int __initdata nowait = 0;
119
Atsushi Nemotof49a7472007-02-18 01:02:14 +0900120static int __init wait_disable(char *s)
Ralf Baechle55d04df2005-07-13 19:22:45 +0000121{
122 nowait = 1;
123
124 return 1;
125}
126
127__setup("nowait", wait_disable);
128
Atsushi Nemotoc65a5482007-11-12 02:05:18 +0900129void __init check_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130{
131 struct cpuinfo_mips *c = &current_cpu_data;
132
Ralf Baechle55d04df2005-07-13 19:22:45 +0000133 if (nowait) {
Ralf Baechlec2379232006-11-30 01:14:44 +0000134 printk("Wait instruction disabled.\n");
Ralf Baechle55d04df2005-07-13 19:22:45 +0000135 return;
136 }
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 switch (c->cputype) {
139 case CPU_R3081:
140 case CPU_R3081E:
141 cpu_wait = r3081_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 break;
143 case CPU_TX3927:
144 cpu_wait = r39xx_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 break;
146 case CPU_R4200:
147/* case CPU_R4300: */
148 case CPU_R4600:
149 case CPU_R4640:
150 case CPU_R4650:
151 case CPU_R4700:
152 case CPU_R5000:
Shinya Kuribayashia644b272009-03-03 18:05:51 +0900153 case CPU_R5500:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154 case CPU_NEVADA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 case CPU_4KC:
156 case CPU_4KEC:
157 case CPU_4KSC:
158 case CPU_5KC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159 case CPU_25KF:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100160 case CPU_PR4450:
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200161 case CPU_BCM3302:
David Daney0dd47812008-12-11 15:33:26 -0800162 case CPU_CAVIUM_OCTEON:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100165
Ralf Baechle5a812992007-07-17 18:49:48 +0100166 case CPU_RM7000:
167 cpu_wait = rm7k_wait_irqoff;
168 break;
169
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100170 case CPU_24K:
171 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100172 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100173 cpu_wait = r4k_wait;
174 if (read_c0_config7() & MIPS_CONF7_WII)
175 cpu_wait = r4k_wait_irqoff;
176 break;
177
178 case CPU_74K:
179 cpu_wait = r4k_wait;
180 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
181 cpu_wait = r4k_wait_irqoff;
182 break;
183
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900184 case CPU_TX49XX:
185 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900186 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100187 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100188 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100190 case CPU_20KC:
191 /*
192 * WAIT on Rev1.0 has E1, E2, E3 and E16.
193 * WAIT on Rev2.0 and Rev3.0 has E16.
194 * Rev3.1 WAIT is nop, why bother
195 */
196 if ((c->processor_id & 0xff) <= 0x64)
197 break;
198
Ralf Baechle50da4692007-09-14 19:08:43 +0100199 /*
200 * Another rev is incremeting c0_count at a reduced clock
201 * rate while in WAIT mode. So we basically have the choice
202 * between using the cp0 timer as clocksource or avoiding
203 * the WAIT instruction. Until more details are known,
204 * disable the use of WAIT for 20Kc entirely.
205 cpu_wait = r4k_wait;
206 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100207 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100208 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000209 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100210 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100211 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 break;
214 }
215}
216
Marc St-Jean9267a302007-06-14 15:55:31 -0600217static inline void check_errata(void)
218{
219 struct cpuinfo_mips *c = &current_cpu_data;
220
221 switch (c->cputype) {
222 case CPU_34K:
223 /*
224 * Erratum "RPS May Cause Incorrect Instruction Execution"
225 * This code only handles VPE0, any SMP/SMTC/RTOS code
226 * making use of VPE1 will be responsable for that VPE.
227 */
228 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
229 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
230 break;
231 default:
232 break;
233 }
234}
235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236void __init check_bugs32(void)
237{
Marc St-Jean9267a302007-06-14 15:55:31 -0600238 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239}
240
241/*
242 * Probe whether cpu has config register by trying to play with
243 * alternate cache bit and see whether it matters.
244 * It's used by cpu_probe to distinguish between R3000A and R3081.
245 */
246static inline int cpu_has_confreg(void)
247{
248#ifdef CONFIG_CPU_R3000
249 extern unsigned long r3k_cache_size(unsigned long);
250 unsigned long size1, size2;
251 unsigned long cfg = read_c0_conf();
252
253 size1 = r3k_cache_size(ST0_ISC);
254 write_c0_conf(cfg ^ R30XX_CONF_AC);
255 size2 = r3k_cache_size(ST0_ISC);
256 write_c0_conf(cfg);
257 return size1 != size2;
258#else
259 return 0;
260#endif
261}
262
263/*
264 * Get the FPU Implementation/Revision.
265 */
266static inline unsigned long cpu_get_fpu_id(void)
267{
268 unsigned long tmp, fpu_id;
269
270 tmp = read_c0_status();
271 __enable_fpu();
272 fpu_id = read_32bit_cp1_register(CP1_REVISION);
273 write_c0_status(tmp);
274 return fpu_id;
275}
276
277/*
278 * Check the CPU has an FPU the official way.
279 */
280static inline int __cpu_has_fpu(void)
281{
282 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
283}
284
Ralf Baechle02cf2112005-10-01 13:06:32 +0100285#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 | MIPS_CPU_COUNTER)
287
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000288static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289{
290 switch (c->processor_id & 0xff00) {
291 case PRID_IMP_R2000:
292 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000293 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100295 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
296 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 if (__cpu_has_fpu())
298 c->options |= MIPS_CPU_FPU;
299 c->tlbsize = 64;
300 break;
301 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000302 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
303 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000305 __cpu_name[cpu] = "R3081";
306 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000308 __cpu_name[cpu] = "R3000A";
309 }
310 break;
311 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000313 __cpu_name[cpu] = "R3000";
314 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100316 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
317 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 if (__cpu_has_fpu())
319 c->options |= MIPS_CPU_FPU;
320 c->tlbsize = 64;
321 break;
322 case PRID_IMP_R4000:
323 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000324 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000326 __cpu_name[cpu] = "R4400PC";
327 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000329 __cpu_name[cpu] = "R4000PC";
330 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000332 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000334 __cpu_name[cpu] = "R4400SC";
335 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000337 __cpu_name[cpu] = "R4000SC";
338 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 }
340
341 c->isa_level = MIPS_CPU_ISA_III;
342 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
343 MIPS_CPU_WATCH | MIPS_CPU_VCE |
344 MIPS_CPU_LLSC;
345 c->tlbsize = 48;
346 break;
347 case PRID_IMP_VR41XX:
348 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 case PRID_REV_VR4111:
350 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000351 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 case PRID_REV_VR4121:
354 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000355 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 break;
357 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000358 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000360 __cpu_name[cpu] = "NEC VR4122";
361 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000363 __cpu_name[cpu] = "NEC VR4181A";
364 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 break;
366 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000367 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000369 __cpu_name[cpu] = "NEC VR4131";
370 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000372 __cpu_name[cpu] = "NEC VR4133";
373 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 break;
375 default:
376 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
377 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000378 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 break;
380 }
381 c->isa_level = MIPS_CPU_ISA_III;
382 c->options = R4K_OPTS;
383 c->tlbsize = 32;
384 break;
385 case PRID_IMP_R4300:
386 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000387 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 c->isa_level = MIPS_CPU_ISA_III;
389 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
390 MIPS_CPU_LLSC;
391 c->tlbsize = 32;
392 break;
393 case PRID_IMP_R4600:
394 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000395 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000397 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
398 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 c->tlbsize = 48;
400 break;
401 #if 0
402 case PRID_IMP_R4650:
403 /*
404 * This processor doesn't have an MMU, so it's not
405 * "real easy" to run Linux on it. It is left purely
406 * for documentation. Commented out because it shares
407 * it's c0_prid id number with the TX3900.
408 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000409 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000410 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 c->isa_level = MIPS_CPU_ISA_III;
412 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
413 c->tlbsize = 48;
414 break;
415 #endif
416 case PRID_IMP_TX39:
417 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100418 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419
420 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
421 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000422 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 c->tlbsize = 64;
424 } else {
425 switch (c->processor_id & 0xff) {
426 case PRID_REV_TX3912:
427 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000428 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 c->tlbsize = 32;
430 break;
431 case PRID_REV_TX3922:
432 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000433 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 c->tlbsize = 64;
435 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 }
437 }
438 break;
439 case PRID_IMP_R4700:
440 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000441 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 c->isa_level = MIPS_CPU_ISA_III;
443 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
444 MIPS_CPU_LLSC;
445 c->tlbsize = 48;
446 break;
447 case PRID_IMP_TX49:
448 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000449 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 c->isa_level = MIPS_CPU_ISA_III;
451 c->options = R4K_OPTS | MIPS_CPU_LLSC;
452 if (!(c->processor_id & 0x08))
453 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
454 c->tlbsize = 48;
455 break;
456 case PRID_IMP_R5000:
457 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000458 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 c->isa_level = MIPS_CPU_ISA_IV;
460 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
461 MIPS_CPU_LLSC;
462 c->tlbsize = 48;
463 break;
464 case PRID_IMP_R5432:
465 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000466 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 c->isa_level = MIPS_CPU_ISA_IV;
468 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
469 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
470 c->tlbsize = 48;
471 break;
472 case PRID_IMP_R5500:
473 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000474 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 c->isa_level = MIPS_CPU_ISA_IV;
476 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
477 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
478 c->tlbsize = 48;
479 break;
480 case PRID_IMP_NEVADA:
481 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000482 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 c->isa_level = MIPS_CPU_ISA_IV;
484 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
485 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
486 c->tlbsize = 48;
487 break;
488 case PRID_IMP_R6000:
489 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000490 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 c->isa_level = MIPS_CPU_ISA_II;
492 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
493 MIPS_CPU_LLSC;
494 c->tlbsize = 32;
495 break;
496 case PRID_IMP_R6000A:
497 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000498 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 c->isa_level = MIPS_CPU_ISA_II;
500 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
501 MIPS_CPU_LLSC;
502 c->tlbsize = 32;
503 break;
504 case PRID_IMP_RM7000:
505 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000506 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 c->isa_level = MIPS_CPU_ISA_IV;
508 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
509 MIPS_CPU_LLSC;
510 /*
511 * Undocumented RM7000: Bit 29 in the info register of
512 * the RM7000 v2.0 indicates if the TLB has 48 or 64
513 * entries.
514 *
515 * 29 1 => 64 entry JTLB
516 * 0 => 48 entry JTLB
517 */
518 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
519 break;
520 case PRID_IMP_RM9000:
521 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000522 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 c->isa_level = MIPS_CPU_ISA_IV;
524 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
525 MIPS_CPU_LLSC;
526 /*
527 * Bit 29 in the info register of the RM9000
528 * indicates if the TLB has 48 or 64 entries.
529 *
530 * 29 1 => 64 entry JTLB
531 * 0 => 48 entry JTLB
532 */
533 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
534 break;
535 case PRID_IMP_R8000:
536 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000537 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 c->isa_level = MIPS_CPU_ISA_IV;
539 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
540 MIPS_CPU_FPU | MIPS_CPU_32FPR |
541 MIPS_CPU_LLSC;
542 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
543 break;
544 case PRID_IMP_R10000:
545 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000546 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000548 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 MIPS_CPU_FPU | MIPS_CPU_32FPR |
550 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
551 MIPS_CPU_LLSC;
552 c->tlbsize = 64;
553 break;
554 case PRID_IMP_R12000:
555 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000556 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000558 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 MIPS_CPU_FPU | MIPS_CPU_32FPR |
560 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
561 MIPS_CPU_LLSC;
562 c->tlbsize = 64;
563 break;
Kumba44d921b2006-05-16 22:23:59 -0400564 case PRID_IMP_R14000:
565 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000566 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400567 c->isa_level = MIPS_CPU_ISA_IV;
568 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
569 MIPS_CPU_FPU | MIPS_CPU_32FPR |
570 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
571 MIPS_CPU_LLSC;
572 c->tlbsize = 64;
573 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800574 case PRID_IMP_LOONGSON2:
575 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000576 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800577 c->isa_level = MIPS_CPU_ISA_III;
578 c->options = R4K_OPTS |
579 MIPS_CPU_FPU | MIPS_CPU_LLSC |
580 MIPS_CPU_32FPR;
581 c->tlbsize = 64;
582 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 }
584}
585
Ralf Baechle234fcd12008-03-08 09:56:28 +0000586static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000587 "Unsupported ISA type, c0.config0: %d.";
588
Ralf Baechle41943182005-05-05 16:45:59 +0000589static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590{
Ralf Baechle41943182005-05-05 16:45:59 +0000591 unsigned int config0;
592 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593
Ralf Baechle41943182005-05-05 16:45:59 +0000594 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595
Ralf Baechle41943182005-05-05 16:45:59 +0000596 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100597 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000598 isa = (config0 & MIPS_CONF_AT) >> 13;
599 switch (isa) {
600 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100601 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000602 case 0:
603 c->isa_level = MIPS_CPU_ISA_M32R1;
604 break;
605 case 1:
606 c->isa_level = MIPS_CPU_ISA_M32R2;
607 break;
608 default:
609 goto unknown;
610 }
Ralf Baechle41943182005-05-05 16:45:59 +0000611 break;
612 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100613 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000614 case 0:
615 c->isa_level = MIPS_CPU_ISA_M64R1;
616 break;
617 case 1:
618 c->isa_level = MIPS_CPU_ISA_M64R2;
619 break;
620 default:
621 goto unknown;
622 }
Ralf Baechle41943182005-05-05 16:45:59 +0000623 break;
624 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000625 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000626 }
627
628 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000629
630unknown:
631 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000632}
633
634static inline unsigned int decode_config1(struct cpuinfo_mips *c)
635{
636 unsigned int config1;
637
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000639
640 if (config1 & MIPS_CONF1_MD)
641 c->ases |= MIPS_ASE_MDMX;
642 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000644 if (config1 & MIPS_CONF1_CA)
645 c->ases |= MIPS_ASE_MIPS16;
646 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000648 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 c->options |= MIPS_CPU_FPU;
650 c->options |= MIPS_CPU_32FPR;
651 }
Ralf Baechle41943182005-05-05 16:45:59 +0000652 if (cpu_has_tlb)
653 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
654
655 return config1 & MIPS_CONF_M;
656}
657
658static inline unsigned int decode_config2(struct cpuinfo_mips *c)
659{
660 unsigned int config2;
661
662 config2 = read_c0_config2();
663
664 if (config2 & MIPS_CONF2_SL)
665 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
666
667 return config2 & MIPS_CONF_M;
668}
669
670static inline unsigned int decode_config3(struct cpuinfo_mips *c)
671{
672 unsigned int config3;
673
674 config3 = read_c0_config3();
675
676 if (config3 & MIPS_CONF3_SM)
677 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000678 if (config3 & MIPS_CONF3_DSP)
679 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000680 if (config3 & MIPS_CONF3_VINT)
681 c->options |= MIPS_CPU_VINT;
682 if (config3 & MIPS_CONF3_VEIC)
683 c->options |= MIPS_CPU_VEIC;
684 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000685 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100686 if (config3 & MIPS_CONF3_ULRI)
687 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000688
689 return config3 & MIPS_CONF_M;
690}
691
Ralf Baechle234fcd12008-03-08 09:56:28 +0000692static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000693{
Ralf Baechle558ce122008-10-29 12:33:34 +0000694 int ok;
695
Ralf Baechle41943182005-05-05 16:45:59 +0000696 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100697 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
698 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000699
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
701
Ralf Baechle558ce122008-10-29 12:33:34 +0000702 ok = decode_config0(c); /* Read Config registers. */
703 BUG_ON(!ok); /* Arch spec violation! */
704 if (ok)
705 ok = decode_config1(c);
706 if (ok)
707 ok = decode_config2(c);
708 if (ok)
709 ok = decode_config3(c);
710
711 mips_probe_watch_registers(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712}
713
Chris Dearman0b6d4972007-09-13 12:32:02 +0100714#ifdef CONFIG_CPU_MIPSR2
715extern void spram_config(void);
716#else
717static inline void spram_config(void) {}
718#endif
719
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000720static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721{
Ralf Baechle41943182005-05-05 16:45:59 +0000722 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 switch (c->processor_id & 0xff00) {
724 case PRID_IMP_4KC:
725 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000726 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 break;
728 case PRID_IMP_4KEC:
729 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000730 __cpu_name[cpu] = "MIPS 4KEc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 break;
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000732 case PRID_IMP_4KECR2:
733 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000734 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000735 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100737 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000739 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 break;
741 case PRID_IMP_5KC:
742 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000743 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 break;
745 case PRID_IMP_20KC:
746 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000747 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 break;
749 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000750 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000752 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 break;
754 case PRID_IMP_25KF:
755 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000756 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000758 case PRID_IMP_34K:
759 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000760 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000761 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100762 case PRID_IMP_74K:
763 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000764 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100765 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100766 case PRID_IMP_1004K:
767 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000768 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100769 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100771
772 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773}
774
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000775static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776{
Ralf Baechle41943182005-05-05 16:45:59 +0000777 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 switch (c->processor_id & 0xff00) {
779 case PRID_IMP_AU1_REV1:
780 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100781 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 switch ((c->processor_id >> 24) & 0xff) {
783 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000784 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 break;
786 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000787 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 break;
789 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000790 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 break;
792 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000793 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000795 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000796 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100797 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000798 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100799 break;
800 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000801 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000802 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100804 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 break;
806 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 break;
808 }
809}
810
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000811static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812{
Ralf Baechle41943182005-05-05 16:45:59 +0000813 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100814
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 switch (c->processor_id & 0xff00) {
816 case PRID_IMP_SB1:
817 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000818 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100820 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000821 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700823 case PRID_IMP_SB1A:
824 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000825 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700826 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 }
828}
829
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000830static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831{
Ralf Baechle41943182005-05-05 16:45:59 +0000832 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 switch (c->processor_id & 0xff00) {
834 case PRID_IMP_SR71000:
835 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000836 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 c->scache.ways = 8;
838 c->tlbsize = 64;
839 break;
840 }
841}
842
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000843static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000844{
845 decode_configs(c);
846 switch (c->processor_id & 0xff00) {
847 case PRID_IMP_PR4450:
848 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000849 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000850 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000851 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000852 }
853}
854
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000855static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200856{
857 decode_configs(c);
858 switch (c->processor_id & 0xff00) {
859 case PRID_IMP_BCM3302:
860 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000861 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200862 break;
863 case PRID_IMP_BCM4710:
864 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000865 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200866 break;
867 }
868}
869
David Daney0dd47812008-12-11 15:33:26 -0800870static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
871{
872 decode_configs(c);
873 switch (c->processor_id & 0xff00) {
874 case PRID_IMP_CAVIUM_CN38XX:
875 case PRID_IMP_CAVIUM_CN31XX:
876 case PRID_IMP_CAVIUM_CN30XX:
877 case PRID_IMP_CAVIUM_CN58XX:
878 case PRID_IMP_CAVIUM_CN56XX:
879 case PRID_IMP_CAVIUM_CN50XX:
880 case PRID_IMP_CAVIUM_CN52XX:
881 c->cputype = CPU_CAVIUM_OCTEON;
882 __cpu_name[cpu] = "Cavium Octeon";
883 break;
884 default:
885 printk(KERN_INFO "Unknown Octeon chip!\n");
886 c->cputype = CPU_UNKNOWN;
887 break;
888 }
889}
890
Ralf Baechle9966db252007-10-11 23:46:17 +0100891const char *__cpu_name[NR_CPUS];
892
Ralf Baechle234fcd12008-03-08 09:56:28 +0000893__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894{
895 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100896 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897
898 c->processor_id = PRID_IMP_UNKNOWN;
899 c->fpu_id = FPIR_IMP_NONE;
900 c->cputype = CPU_UNKNOWN;
901
902 c->processor_id = read_c0_prid();
903 switch (c->processor_id & 0xff0000) {
904 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000905 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 break;
907 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000908 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 break;
910 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000911 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912 break;
913 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000914 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200916 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000917 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200918 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000920 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921 break;
Daniel Lairda92b0582008-03-06 09:07:18 +0000922 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000923 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000924 break;
David Daney0dd47812008-12-11 15:33:26 -0800925 case PRID_COMP_CAVIUM:
926 cpu_probe_cavium(c, cpu);
927 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200929
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000930 BUG_ON(!__cpu_name[cpu]);
931 BUG_ON(c->cputype == CPU_UNKNOWN);
932
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200933 /*
934 * Platform code can force the cpu type to optimize code
935 * generation. In that case be sure the cpu type is correctly
936 * manually setup otherwise it could trigger some nasty bugs.
937 */
938 BUG_ON(current_cpu_type() != c->cputype);
939
Ralf Baechle41943182005-05-05 16:45:59 +0000940 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +0000942
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000943 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +0000944 c->isa_level == MIPS_CPU_ISA_M32R2 ||
945 c->isa_level == MIPS_CPU_ISA_M64R1 ||
946 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +0000947 if (c->fpu_id & MIPS_FPIR_3D)
948 c->ases |= MIPS_ASE_MIPS3D;
949 }
950 }
Ralf Baechle9966db252007-10-11 23:46:17 +0100951
Ralf Baechlef6771db2007-11-08 18:02:29 +0000952 if (cpu_has_mips_r2)
953 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
954 else
955 c->srsets = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700956}
957
Ralf Baechle234fcd12008-03-08 09:56:28 +0000958__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959{
960 struct cpuinfo_mips *c = &current_cpu_data;
961
Ralf Baechle9966db252007-10-11 23:46:17 +0100962 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
963 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +0100965 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966}