blob: 70c8ad9bc8fc147a6d88d8d9a0ac8e7523eb2399 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Processor capabilities determination functions.
3 *
4 * Copyright (C) xxxx the Anonymous
Ralf Baechle41943182005-05-05 16:45:59 +00005 * Copyright (C) 2003, 2004 Maciej W. Rozycki
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 * Copyright (C) 1994 - 2003 Ralf Baechle
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 */
14#include <linux/config.h>
15#include <linux/init.h>
16#include <linux/kernel.h>
17#include <linux/ptrace.h>
18#include <linux/stddef.h>
19
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>
24
25/*
26 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
27 * the implementation of the "wait" feature differs between CPU families. This
28 * points to the function that implements CPU specific wait.
29 * The wait instruction stops the pipeline and reduces the power consumption of
30 * the CPU very much.
31 */
32void (*cpu_wait)(void) = NULL;
33
34static void r3081_wait(void)
35{
36 unsigned long cfg = read_c0_conf();
37 write_c0_conf(cfg | R30XX_CONF_HALT);
38}
39
40static void r39xx_wait(void)
41{
42 unsigned long cfg = read_c0_conf();
43 write_c0_conf(cfg | TX39_CONF_HALT);
44}
45
46static void r4k_wait(void)
47{
48 __asm__(".set\tmips3\n\t"
49 "wait\n\t"
50 ".set\tmips0");
51}
52
Pete Popov494900a2005-04-07 00:42:10 +000053/* The Au1xxx wait is available only if using 32khz counter or
54 * external timer source, but specifically not CP0 Counter. */
Pete Popovfe359bf2005-04-08 08:34:43 +000055int allow_au1k_wait;
Ralf Baechle10f650d2005-05-25 13:32:49 +000056
Pete Popov494900a2005-04-07 00:42:10 +000057static void au1k_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070058{
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 /* using the wait instruction makes CP0 counter unusable */
Ralf Baechle10f650d2005-05-25 13:32:49 +000060 __asm__(".set mips3\n\t"
61 "cache 0x14, 0(%0)\n\t"
62 "cache 0x14, 32(%0)\n\t"
Pete Popov494900a2005-04-07 00:42:10 +000063 "sync\n\t"
64 "nop\n\t"
Linus Torvalds1da177e2005-04-16 15:20:36 -070065 "wait\n\t"
66 "nop\n\t"
67 "nop\n\t"
68 "nop\n\t"
69 "nop\n\t"
Pete Popov494900a2005-04-07 00:42:10 +000070 ".set mips0\n\t"
Ralf Baechle10f650d2005-05-25 13:32:49 +000071 : : "r" (au1k_wait));
Linus Torvalds1da177e2005-04-16 15:20:36 -070072}
73
Ralf Baechle55d04df2005-07-13 19:22:45 +000074static int __initdata nowait = 0;
75
76int __init wait_disable(char *s)
77{
78 nowait = 1;
79
80 return 1;
81}
82
83__setup("nowait", wait_disable);
84
Linus Torvalds1da177e2005-04-16 15:20:36 -070085static inline void check_wait(void)
86{
87 struct cpuinfo_mips *c = &current_cpu_data;
88
89 printk("Checking for 'wait' instruction... ");
Ralf Baechle55d04df2005-07-13 19:22:45 +000090 if (nowait) {
91 printk (" disabled.\n");
92 return;
93 }
94
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 switch (c->cputype) {
96 case CPU_R3081:
97 case CPU_R3081E:
98 cpu_wait = r3081_wait;
99 printk(" available.\n");
100 break;
101 case CPU_TX3927:
102 cpu_wait = r39xx_wait;
103 printk(" available.\n");
104 break;
105 case CPU_R4200:
106/* case CPU_R4300: */
107 case CPU_R4600:
108 case CPU_R4640:
109 case CPU_R4650:
110 case CPU_R4700:
111 case CPU_R5000:
112 case CPU_NEVADA:
113 case CPU_RM7000:
114 case CPU_RM9000:
115 case CPU_TX49XX:
116 case CPU_4KC:
117 case CPU_4KEC:
118 case CPU_4KSC:
119 case CPU_5KC:
120/* case CPU_20KC:*/
121 case CPU_24K:
122 case CPU_25KF:
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000123 case CPU_34K:
Pete Popovbdf21b12005-07-14 17:47:57 +0000124 case CPU_PR4450:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 cpu_wait = r4k_wait;
126 printk(" available.\n");
127 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 case CPU_AU1000:
129 case CPU_AU1100:
130 case CPU_AU1500:
Pete Popove3ad1c22005-03-01 06:33:16 +0000131 case CPU_AU1550:
132 case CPU_AU1200:
Pete Popovfe359bf2005-04-08 08:34:43 +0000133 if (allow_au1k_wait) {
134 cpu_wait = au1k_wait;
135 printk(" available.\n");
136 } else
137 printk(" unavailable.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 default:
140 printk(" unavailable.\n");
141 break;
142 }
143}
144
145void __init check_bugs32(void)
146{
147 check_wait();
148}
149
150/*
151 * Probe whether cpu has config register by trying to play with
152 * alternate cache bit and see whether it matters.
153 * It's used by cpu_probe to distinguish between R3000A and R3081.
154 */
155static inline int cpu_has_confreg(void)
156{
157#ifdef CONFIG_CPU_R3000
158 extern unsigned long r3k_cache_size(unsigned long);
159 unsigned long size1, size2;
160 unsigned long cfg = read_c0_conf();
161
162 size1 = r3k_cache_size(ST0_ISC);
163 write_c0_conf(cfg ^ R30XX_CONF_AC);
164 size2 = r3k_cache_size(ST0_ISC);
165 write_c0_conf(cfg);
166 return size1 != size2;
167#else
168 return 0;
169#endif
170}
171
172/*
173 * Get the FPU Implementation/Revision.
174 */
175static inline unsigned long cpu_get_fpu_id(void)
176{
177 unsigned long tmp, fpu_id;
178
179 tmp = read_c0_status();
180 __enable_fpu();
181 fpu_id = read_32bit_cp1_register(CP1_REVISION);
182 write_c0_status(tmp);
183 return fpu_id;
184}
185
186/*
187 * Check the CPU has an FPU the official way.
188 */
189static inline int __cpu_has_fpu(void)
190{
191 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
192}
193
194#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4KTLB \
195 | MIPS_CPU_COUNTER)
196
197static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
198{
199 switch (c->processor_id & 0xff00) {
200 case PRID_IMP_R2000:
201 c->cputype = CPU_R2000;
202 c->isa_level = MIPS_CPU_ISA_I;
203 c->options = MIPS_CPU_TLB | MIPS_CPU_NOFPUEX;
204 if (__cpu_has_fpu())
205 c->options |= MIPS_CPU_FPU;
206 c->tlbsize = 64;
207 break;
208 case PRID_IMP_R3000:
209 if ((c->processor_id & 0xff) == PRID_REV_R3000A)
210 if (cpu_has_confreg())
211 c->cputype = CPU_R3081E;
212 else
213 c->cputype = CPU_R3000A;
214 else
215 c->cputype = CPU_R3000;
216 c->isa_level = MIPS_CPU_ISA_I;
217 c->options = MIPS_CPU_TLB | MIPS_CPU_NOFPUEX;
218 if (__cpu_has_fpu())
219 c->options |= MIPS_CPU_FPU;
220 c->tlbsize = 64;
221 break;
222 case PRID_IMP_R4000:
223 if (read_c0_config() & CONF_SC) {
224 if ((c->processor_id & 0xff) >= PRID_REV_R4400)
225 c->cputype = CPU_R4400PC;
226 else
227 c->cputype = CPU_R4000PC;
228 } else {
229 if ((c->processor_id & 0xff) >= PRID_REV_R4400)
230 c->cputype = CPU_R4400SC;
231 else
232 c->cputype = CPU_R4000SC;
233 }
234
235 c->isa_level = MIPS_CPU_ISA_III;
236 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
237 MIPS_CPU_WATCH | MIPS_CPU_VCE |
238 MIPS_CPU_LLSC;
239 c->tlbsize = 48;
240 break;
241 case PRID_IMP_VR41XX:
242 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 case PRID_REV_VR4111:
244 c->cputype = CPU_VR4111;
245 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 case PRID_REV_VR4121:
247 c->cputype = CPU_VR4121;
248 break;
249 case PRID_REV_VR4122:
250 if ((c->processor_id & 0xf) < 0x3)
251 c->cputype = CPU_VR4122;
252 else
253 c->cputype = CPU_VR4181A;
254 break;
255 case PRID_REV_VR4130:
256 if ((c->processor_id & 0xf) < 0x4)
257 c->cputype = CPU_VR4131;
258 else
259 c->cputype = CPU_VR4133;
260 break;
261 default:
262 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
263 c->cputype = CPU_VR41XX;
264 break;
265 }
266 c->isa_level = MIPS_CPU_ISA_III;
267 c->options = R4K_OPTS;
268 c->tlbsize = 32;
269 break;
270 case PRID_IMP_R4300:
271 c->cputype = CPU_R4300;
272 c->isa_level = MIPS_CPU_ISA_III;
273 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
274 MIPS_CPU_LLSC;
275 c->tlbsize = 32;
276 break;
277 case PRID_IMP_R4600:
278 c->cputype = CPU_R4600;
279 c->isa_level = MIPS_CPU_ISA_III;
280 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
281 c->tlbsize = 48;
282 break;
283 #if 0
284 case PRID_IMP_R4650:
285 /*
286 * This processor doesn't have an MMU, so it's not
287 * "real easy" to run Linux on it. It is left purely
288 * for documentation. Commented out because it shares
289 * it's c0_prid id number with the TX3900.
290 */
291 c->cputype = CPU_R4650;
292 c->isa_level = MIPS_CPU_ISA_III;
293 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
294 c->tlbsize = 48;
295 break;
296 #endif
297 case PRID_IMP_TX39:
298 c->isa_level = MIPS_CPU_ISA_I;
299 c->options = MIPS_CPU_TLB;
300
301 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
302 c->cputype = CPU_TX3927;
303 c->tlbsize = 64;
304 } else {
305 switch (c->processor_id & 0xff) {
306 case PRID_REV_TX3912:
307 c->cputype = CPU_TX3912;
308 c->tlbsize = 32;
309 break;
310 case PRID_REV_TX3922:
311 c->cputype = CPU_TX3922;
312 c->tlbsize = 64;
313 break;
314 default:
315 c->cputype = CPU_UNKNOWN;
316 break;
317 }
318 }
319 break;
320 case PRID_IMP_R4700:
321 c->cputype = CPU_R4700;
322 c->isa_level = MIPS_CPU_ISA_III;
323 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
324 MIPS_CPU_LLSC;
325 c->tlbsize = 48;
326 break;
327 case PRID_IMP_TX49:
328 c->cputype = CPU_TX49XX;
329 c->isa_level = MIPS_CPU_ISA_III;
330 c->options = R4K_OPTS | MIPS_CPU_LLSC;
331 if (!(c->processor_id & 0x08))
332 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
333 c->tlbsize = 48;
334 break;
335 case PRID_IMP_R5000:
336 c->cputype = CPU_R5000;
337 c->isa_level = MIPS_CPU_ISA_IV;
338 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
339 MIPS_CPU_LLSC;
340 c->tlbsize = 48;
341 break;
342 case PRID_IMP_R5432:
343 c->cputype = CPU_R5432;
344 c->isa_level = MIPS_CPU_ISA_IV;
345 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
346 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
347 c->tlbsize = 48;
348 break;
349 case PRID_IMP_R5500:
350 c->cputype = CPU_R5500;
351 c->isa_level = MIPS_CPU_ISA_IV;
352 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
353 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
354 c->tlbsize = 48;
355 break;
356 case PRID_IMP_NEVADA:
357 c->cputype = CPU_NEVADA;
358 c->isa_level = MIPS_CPU_ISA_IV;
359 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
360 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
361 c->tlbsize = 48;
362 break;
363 case PRID_IMP_R6000:
364 c->cputype = CPU_R6000;
365 c->isa_level = MIPS_CPU_ISA_II;
366 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
367 MIPS_CPU_LLSC;
368 c->tlbsize = 32;
369 break;
370 case PRID_IMP_R6000A:
371 c->cputype = CPU_R6000A;
372 c->isa_level = MIPS_CPU_ISA_II;
373 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
374 MIPS_CPU_LLSC;
375 c->tlbsize = 32;
376 break;
377 case PRID_IMP_RM7000:
378 c->cputype = CPU_RM7000;
379 c->isa_level = MIPS_CPU_ISA_IV;
380 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
381 MIPS_CPU_LLSC;
382 /*
383 * Undocumented RM7000: Bit 29 in the info register of
384 * the RM7000 v2.0 indicates if the TLB has 48 or 64
385 * entries.
386 *
387 * 29 1 => 64 entry JTLB
388 * 0 => 48 entry JTLB
389 */
390 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
391 break;
392 case PRID_IMP_RM9000:
393 c->cputype = CPU_RM9000;
394 c->isa_level = MIPS_CPU_ISA_IV;
395 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
396 MIPS_CPU_LLSC;
397 /*
398 * Bit 29 in the info register of the RM9000
399 * indicates if the TLB has 48 or 64 entries.
400 *
401 * 29 1 => 64 entry JTLB
402 * 0 => 48 entry JTLB
403 */
404 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
405 break;
406 case PRID_IMP_R8000:
407 c->cputype = CPU_R8000;
408 c->isa_level = MIPS_CPU_ISA_IV;
409 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
410 MIPS_CPU_FPU | MIPS_CPU_32FPR |
411 MIPS_CPU_LLSC;
412 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
413 break;
414 case PRID_IMP_R10000:
415 c->cputype = CPU_R10000;
416 c->isa_level = MIPS_CPU_ISA_IV;
417 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
418 MIPS_CPU_FPU | MIPS_CPU_32FPR |
419 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
420 MIPS_CPU_LLSC;
421 c->tlbsize = 64;
422 break;
423 case PRID_IMP_R12000:
424 c->cputype = CPU_R12000;
425 c->isa_level = MIPS_CPU_ISA_IV;
426 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
427 MIPS_CPU_FPU | MIPS_CPU_32FPR |
428 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
429 MIPS_CPU_LLSC;
430 c->tlbsize = 64;
431 break;
432 }
433}
434
Ralf Baechle41943182005-05-05 16:45:59 +0000435static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436{
Ralf Baechle41943182005-05-05 16:45:59 +0000437 unsigned int config0;
438 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439
Ralf Baechle41943182005-05-05 16:45:59 +0000440 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
Ralf Baechle41943182005-05-05 16:45:59 +0000442 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Maciej W. Rozyckid5b6f1d2005-06-06 16:40:58 +0000443 c->options |= MIPS_CPU_TLB | MIPS_CPU_4KTLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000444 isa = (config0 & MIPS_CONF_AT) >> 13;
445 switch (isa) {
446 case 0:
447 c->isa_level = MIPS_CPU_ISA_M32;
448 break;
449 case 2:
450 c->isa_level = MIPS_CPU_ISA_M64;
451 break;
452 default:
453 panic("Unsupported ISA type, cp0.config0.at: %d.", isa);
454 }
455
456 return config0 & MIPS_CONF_M;
457}
458
459static inline unsigned int decode_config1(struct cpuinfo_mips *c)
460{
461 unsigned int config1;
462
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000464
465 if (config1 & MIPS_CONF1_MD)
466 c->ases |= MIPS_ASE_MDMX;
467 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000469 if (config1 & MIPS_CONF1_CA)
470 c->ases |= MIPS_ASE_MIPS16;
471 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000473 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 c->options |= MIPS_CPU_FPU;
475 c->options |= MIPS_CPU_32FPR;
476 }
Ralf Baechle41943182005-05-05 16:45:59 +0000477 if (cpu_has_tlb)
478 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
479
480 return config1 & MIPS_CONF_M;
481}
482
483static inline unsigned int decode_config2(struct cpuinfo_mips *c)
484{
485 unsigned int config2;
486
487 config2 = read_c0_config2();
488
489 if (config2 & MIPS_CONF2_SL)
490 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
491
492 return config2 & MIPS_CONF_M;
493}
494
495static inline unsigned int decode_config3(struct cpuinfo_mips *c)
496{
497 unsigned int config3;
498
499 config3 = read_c0_config3();
500
501 if (config3 & MIPS_CONF3_SM)
502 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000503 if (config3 & MIPS_CONF3_DSP)
504 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000505 if (config3 & MIPS_CONF3_VINT)
506 c->options |= MIPS_CPU_VINT;
507 if (config3 & MIPS_CONF3_VEIC)
508 c->options |= MIPS_CPU_VEIC;
509 if (config3 & MIPS_CONF3_MT)
510 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechle41943182005-05-05 16:45:59 +0000511
512 return config3 & MIPS_CONF_M;
513}
514
515static inline void decode_configs(struct cpuinfo_mips *c)
516{
517 /* MIPS32 or MIPS64 compliant CPU. */
518 c->options = MIPS_CPU_4KEX | MIPS_CPU_COUNTER | MIPS_CPU_DIVEC |
519 MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
520
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
522
Ralf Baechle41943182005-05-05 16:45:59 +0000523 /* Read Config registers. */
524 if (!decode_config0(c))
525 return; /* actually worth a panic() */
526 if (!decode_config1(c))
527 return;
528 if (!decode_config2(c))
529 return;
530 if (!decode_config3(c))
531 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532}
533
534static inline void cpu_probe_mips(struct cpuinfo_mips *c)
535{
Ralf Baechle41943182005-05-05 16:45:59 +0000536 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 switch (c->processor_id & 0xff00) {
538 case PRID_IMP_4KC:
539 c->cputype = CPU_4KC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 break;
541 case PRID_IMP_4KEC:
542 c->cputype = CPU_4KEC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 break;
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000544 case PRID_IMP_4KECR2:
545 c->cputype = CPU_4KEC;
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000546 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 case PRID_IMP_4KSC:
548 c->cputype = CPU_4KSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 break;
550 case PRID_IMP_5KC:
551 c->cputype = CPU_5KC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 break;
553 case PRID_IMP_20KC:
554 c->cputype = CPU_20KC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 break;
556 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000557 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 c->cputype = CPU_24K;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 break;
560 case PRID_IMP_25KF:
561 c->cputype = CPU_25KF;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 /* Probe for L2 cache */
563 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
564 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000565 case PRID_IMP_34K:
566 c->cputype = CPU_34K;
567 c->isa_level = MIPS_CPU_ISA_M32;
568 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 }
570}
571
572static inline void cpu_probe_alchemy(struct cpuinfo_mips *c)
573{
Ralf Baechle41943182005-05-05 16:45:59 +0000574 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 switch (c->processor_id & 0xff00) {
576 case PRID_IMP_AU1_REV1:
577 case PRID_IMP_AU1_REV2:
578 switch ((c->processor_id >> 24) & 0xff) {
579 case 0:
580 c->cputype = CPU_AU1000;
581 break;
582 case 1:
583 c->cputype = CPU_AU1500;
584 break;
585 case 2:
586 c->cputype = CPU_AU1100;
587 break;
588 case 3:
589 c->cputype = CPU_AU1550;
590 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000591 case 4:
592 c->cputype = CPU_AU1200;
593 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 default:
595 panic("Unknown Au Core!");
596 break;
597 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 break;
599 }
600}
601
602static inline void cpu_probe_sibyte(struct cpuinfo_mips *c)
603{
Ralf Baechle41943182005-05-05 16:45:59 +0000604 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700605 switch (c->processor_id & 0xff00) {
606 case PRID_IMP_SB1:
607 c->cputype = CPU_SB1;
Ralf Baechle41943182005-05-05 16:45:59 +0000608#ifdef CONFIG_SB1_PASS_1_WORKAROUNDS
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 /* FPU in pass1 is known to have issues. */
Ralf Baechle41943182005-05-05 16:45:59 +0000610 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611#endif
612 break;
613 }
614}
615
616static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c)
617{
Ralf Baechle41943182005-05-05 16:45:59 +0000618 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 switch (c->processor_id & 0xff00) {
620 case PRID_IMP_SR71000:
621 c->cputype = CPU_SR71000;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700622 c->scache.ways = 8;
623 c->tlbsize = 64;
624 break;
625 }
626}
627
Pete Popovbdf21b12005-07-14 17:47:57 +0000628static inline void cpu_probe_philips(struct cpuinfo_mips *c)
629{
630 decode_configs(c);
631 switch (c->processor_id & 0xff00) {
632 case PRID_IMP_PR4450:
633 c->cputype = CPU_PR4450;
634 c->isa_level = MIPS_CPU_ISA_M32;
635 break;
636 default:
637 panic("Unknown Philips Core!"); /* REVISIT: die? */
638 break;
639 }
640}
641
642
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643__init void cpu_probe(void)
644{
645 struct cpuinfo_mips *c = &current_cpu_data;
646
647 c->processor_id = PRID_IMP_UNKNOWN;
648 c->fpu_id = FPIR_IMP_NONE;
649 c->cputype = CPU_UNKNOWN;
650
651 c->processor_id = read_c0_prid();
652 switch (c->processor_id & 0xff0000) {
653 case PRID_COMP_LEGACY:
654 cpu_probe_legacy(c);
655 break;
656 case PRID_COMP_MIPS:
657 cpu_probe_mips(c);
658 break;
659 case PRID_COMP_ALCHEMY:
660 cpu_probe_alchemy(c);
661 break;
662 case PRID_COMP_SIBYTE:
663 cpu_probe_sibyte(c);
664 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 case PRID_COMP_SANDCRAFT:
666 cpu_probe_sandcraft(c);
667 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000668 case PRID_COMP_PHILIPS:
669 cpu_probe_philips(c);
670 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671 default:
672 c->cputype = CPU_UNKNOWN;
673 }
Ralf Baechle41943182005-05-05 16:45:59 +0000674 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +0000676
677 if (c->isa_level == MIPS_CPU_ISA_M32 ||
678 c->isa_level == MIPS_CPU_ISA_M64) {
679 if (c->fpu_id & MIPS_FPIR_3D)
680 c->ases |= MIPS_ASE_MIPS3D;
681 }
682 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683}
684
685__init void cpu_report(void)
686{
687 struct cpuinfo_mips *c = &current_cpu_data;
688
689 printk("CPU revision is: %08x\n", c->processor_id);
690 if (c->options & MIPS_CPU_FPU)
691 printk("FPU revision is: %08x\n", c->fpu_id);
692}