blob: bef3e2dc7c52674c120433257bfeb04b93e0ac42 [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 */
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:
Chris Dearmanc6209532006-05-02 14:08:46 +0100124 case CPU_74K:
Pete Popovbdf21b12005-07-14 17:47:57 +0000125 case CPU_PR4450:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700126 cpu_wait = r4k_wait;
127 printk(" available.\n");
128 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129 case CPU_AU1000:
130 case CPU_AU1100:
131 case CPU_AU1500:
Pete Popove3ad1c22005-03-01 06:33:16 +0000132 case CPU_AU1550:
133 case CPU_AU1200:
Pete Popovfe359bf2005-04-08 08:34:43 +0000134 if (allow_au1k_wait) {
135 cpu_wait = au1k_wait;
136 printk(" available.\n");
137 } else
138 printk(" unavailable.\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 default:
141 printk(" unavailable.\n");
142 break;
143 }
144}
145
146void __init check_bugs32(void)
147{
148 check_wait();
149}
150
151/*
152 * Probe whether cpu has config register by trying to play with
153 * alternate cache bit and see whether it matters.
154 * It's used by cpu_probe to distinguish between R3000A and R3081.
155 */
156static inline int cpu_has_confreg(void)
157{
158#ifdef CONFIG_CPU_R3000
159 extern unsigned long r3k_cache_size(unsigned long);
160 unsigned long size1, size2;
161 unsigned long cfg = read_c0_conf();
162
163 size1 = r3k_cache_size(ST0_ISC);
164 write_c0_conf(cfg ^ R30XX_CONF_AC);
165 size2 = r3k_cache_size(ST0_ISC);
166 write_c0_conf(cfg);
167 return size1 != size2;
168#else
169 return 0;
170#endif
171}
172
173/*
174 * Get the FPU Implementation/Revision.
175 */
176static inline unsigned long cpu_get_fpu_id(void)
177{
178 unsigned long tmp, fpu_id;
179
180 tmp = read_c0_status();
181 __enable_fpu();
182 fpu_id = read_32bit_cp1_register(CP1_REVISION);
183 write_c0_status(tmp);
184 return fpu_id;
185}
186
187/*
188 * Check the CPU has an FPU the official way.
189 */
190static inline int __cpu_has_fpu(void)
191{
192 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
193}
194
Ralf Baechle02cf2112005-10-01 13:06:32 +0100195#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 | MIPS_CPU_COUNTER)
197
198static inline void cpu_probe_legacy(struct cpuinfo_mips *c)
199{
200 switch (c->processor_id & 0xff00) {
201 case PRID_IMP_R2000:
202 c->cputype = CPU_R2000;
203 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100204 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
205 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700206 if (__cpu_has_fpu())
207 c->options |= MIPS_CPU_FPU;
208 c->tlbsize = 64;
209 break;
210 case PRID_IMP_R3000:
211 if ((c->processor_id & 0xff) == PRID_REV_R3000A)
212 if (cpu_has_confreg())
213 c->cputype = CPU_R3081E;
214 else
215 c->cputype = CPU_R3000A;
216 else
217 c->cputype = CPU_R3000;
218 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100219 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
220 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 if (__cpu_has_fpu())
222 c->options |= MIPS_CPU_FPU;
223 c->tlbsize = 64;
224 break;
225 case PRID_IMP_R4000:
226 if (read_c0_config() & CONF_SC) {
227 if ((c->processor_id & 0xff) >= PRID_REV_R4400)
228 c->cputype = CPU_R4400PC;
229 else
230 c->cputype = CPU_R4000PC;
231 } else {
232 if ((c->processor_id & 0xff) >= PRID_REV_R4400)
233 c->cputype = CPU_R4400SC;
234 else
235 c->cputype = CPU_R4000SC;
236 }
237
238 c->isa_level = MIPS_CPU_ISA_III;
239 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
240 MIPS_CPU_WATCH | MIPS_CPU_VCE |
241 MIPS_CPU_LLSC;
242 c->tlbsize = 48;
243 break;
244 case PRID_IMP_VR41XX:
245 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 case PRID_REV_VR4111:
247 c->cputype = CPU_VR4111;
248 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 case PRID_REV_VR4121:
250 c->cputype = CPU_VR4121;
251 break;
252 case PRID_REV_VR4122:
253 if ((c->processor_id & 0xf) < 0x3)
254 c->cputype = CPU_VR4122;
255 else
256 c->cputype = CPU_VR4181A;
257 break;
258 case PRID_REV_VR4130:
259 if ((c->processor_id & 0xf) < 0x4)
260 c->cputype = CPU_VR4131;
261 else
262 c->cputype = CPU_VR4133;
263 break;
264 default:
265 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
266 c->cputype = CPU_VR41XX;
267 break;
268 }
269 c->isa_level = MIPS_CPU_ISA_III;
270 c->options = R4K_OPTS;
271 c->tlbsize = 32;
272 break;
273 case PRID_IMP_R4300:
274 c->cputype = CPU_R4300;
275 c->isa_level = MIPS_CPU_ISA_III;
276 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
277 MIPS_CPU_LLSC;
278 c->tlbsize = 32;
279 break;
280 case PRID_IMP_R4600:
281 c->cputype = CPU_R4600;
282 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000283 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
284 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700285 c->tlbsize = 48;
286 break;
287 #if 0
288 case PRID_IMP_R4650:
289 /*
290 * This processor doesn't have an MMU, so it's not
291 * "real easy" to run Linux on it. It is left purely
292 * for documentation. Commented out because it shares
293 * it's c0_prid id number with the TX3900.
294 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000295 c->cputype = CPU_R4650;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 c->isa_level = MIPS_CPU_ISA_III;
297 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
298 c->tlbsize = 48;
299 break;
300 #endif
301 case PRID_IMP_TX39:
302 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100303 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304
305 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
306 c->cputype = CPU_TX3927;
307 c->tlbsize = 64;
308 } else {
309 switch (c->processor_id & 0xff) {
310 case PRID_REV_TX3912:
311 c->cputype = CPU_TX3912;
312 c->tlbsize = 32;
313 break;
314 case PRID_REV_TX3922:
315 c->cputype = CPU_TX3922;
316 c->tlbsize = 64;
317 break;
318 default:
319 c->cputype = CPU_UNKNOWN;
320 break;
321 }
322 }
323 break;
324 case PRID_IMP_R4700:
325 c->cputype = CPU_R4700;
326 c->isa_level = MIPS_CPU_ISA_III;
327 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
328 MIPS_CPU_LLSC;
329 c->tlbsize = 48;
330 break;
331 case PRID_IMP_TX49:
332 c->cputype = CPU_TX49XX;
333 c->isa_level = MIPS_CPU_ISA_III;
334 c->options = R4K_OPTS | MIPS_CPU_LLSC;
335 if (!(c->processor_id & 0x08))
336 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
337 c->tlbsize = 48;
338 break;
339 case PRID_IMP_R5000:
340 c->cputype = CPU_R5000;
341 c->isa_level = MIPS_CPU_ISA_IV;
342 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
343 MIPS_CPU_LLSC;
344 c->tlbsize = 48;
345 break;
346 case PRID_IMP_R5432:
347 c->cputype = CPU_R5432;
348 c->isa_level = MIPS_CPU_ISA_IV;
349 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
350 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
351 c->tlbsize = 48;
352 break;
353 case PRID_IMP_R5500:
354 c->cputype = CPU_R5500;
355 c->isa_level = MIPS_CPU_ISA_IV;
356 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
357 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
358 c->tlbsize = 48;
359 break;
360 case PRID_IMP_NEVADA:
361 c->cputype = CPU_NEVADA;
362 c->isa_level = MIPS_CPU_ISA_IV;
363 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
364 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
365 c->tlbsize = 48;
366 break;
367 case PRID_IMP_R6000:
368 c->cputype = CPU_R6000;
369 c->isa_level = MIPS_CPU_ISA_II;
370 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
371 MIPS_CPU_LLSC;
372 c->tlbsize = 32;
373 break;
374 case PRID_IMP_R6000A:
375 c->cputype = CPU_R6000A;
376 c->isa_level = MIPS_CPU_ISA_II;
377 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
378 MIPS_CPU_LLSC;
379 c->tlbsize = 32;
380 break;
381 case PRID_IMP_RM7000:
382 c->cputype = CPU_RM7000;
383 c->isa_level = MIPS_CPU_ISA_IV;
384 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
385 MIPS_CPU_LLSC;
386 /*
387 * Undocumented RM7000: Bit 29 in the info register of
388 * the RM7000 v2.0 indicates if the TLB has 48 or 64
389 * entries.
390 *
391 * 29 1 => 64 entry JTLB
392 * 0 => 48 entry JTLB
393 */
394 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
395 break;
396 case PRID_IMP_RM9000:
397 c->cputype = CPU_RM9000;
398 c->isa_level = MIPS_CPU_ISA_IV;
399 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
400 MIPS_CPU_LLSC;
401 /*
402 * Bit 29 in the info register of the RM9000
403 * indicates if the TLB has 48 or 64 entries.
404 *
405 * 29 1 => 64 entry JTLB
406 * 0 => 48 entry JTLB
407 */
408 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
409 break;
410 case PRID_IMP_R8000:
411 c->cputype = CPU_R8000;
412 c->isa_level = MIPS_CPU_ISA_IV;
413 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
414 MIPS_CPU_FPU | MIPS_CPU_32FPR |
415 MIPS_CPU_LLSC;
416 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
417 break;
418 case PRID_IMP_R10000:
419 c->cputype = CPU_R10000;
420 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000421 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422 MIPS_CPU_FPU | MIPS_CPU_32FPR |
423 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
424 MIPS_CPU_LLSC;
425 c->tlbsize = 64;
426 break;
427 case PRID_IMP_R12000:
428 c->cputype = CPU_R12000;
429 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000430 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700431 MIPS_CPU_FPU | MIPS_CPU_32FPR |
432 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
433 MIPS_CPU_LLSC;
434 c->tlbsize = 64;
435 break;
Kumba44d921b2006-05-16 22:23:59 -0400436 case PRID_IMP_R14000:
437 c->cputype = CPU_R14000;
438 c->isa_level = MIPS_CPU_ISA_IV;
439 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
440 MIPS_CPU_FPU | MIPS_CPU_32FPR |
441 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
442 MIPS_CPU_LLSC;
443 c->tlbsize = 64;
444 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 }
446}
447
Ralf Baechleb4672d32005-12-08 14:04:24 +0000448static char unknown_isa[] __initdata = KERN_ERR \
449 "Unsupported ISA type, c0.config0: %d.";
450
Ralf Baechle41943182005-05-05 16:45:59 +0000451static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452{
Ralf Baechle41943182005-05-05 16:45:59 +0000453 unsigned int config0;
454 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
Ralf Baechle41943182005-05-05 16:45:59 +0000456 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457
Ralf Baechle41943182005-05-05 16:45:59 +0000458 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100459 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000460 isa = (config0 & MIPS_CONF_AT) >> 13;
461 switch (isa) {
462 case 0:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000463 switch ((config0 >> 10) & 7) {
464 case 0:
465 c->isa_level = MIPS_CPU_ISA_M32R1;
466 break;
467 case 1:
468 c->isa_level = MIPS_CPU_ISA_M32R2;
469 break;
470 default:
471 goto unknown;
472 }
Ralf Baechle41943182005-05-05 16:45:59 +0000473 break;
474 case 2:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000475 switch ((config0 >> 10) & 7) {
476 case 0:
477 c->isa_level = MIPS_CPU_ISA_M64R1;
478 break;
479 case 1:
480 c->isa_level = MIPS_CPU_ISA_M64R2;
481 break;
482 default:
483 goto unknown;
484 }
Ralf Baechle41943182005-05-05 16:45:59 +0000485 break;
486 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000487 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000488 }
489
490 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000491
492unknown:
493 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000494}
495
496static inline unsigned int decode_config1(struct cpuinfo_mips *c)
497{
498 unsigned int config1;
499
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000501
502 if (config1 & MIPS_CONF1_MD)
503 c->ases |= MIPS_ASE_MDMX;
504 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000506 if (config1 & MIPS_CONF1_CA)
507 c->ases |= MIPS_ASE_MIPS16;
508 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000510 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 c->options |= MIPS_CPU_FPU;
512 c->options |= MIPS_CPU_32FPR;
513 }
Ralf Baechle41943182005-05-05 16:45:59 +0000514 if (cpu_has_tlb)
515 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
516
517 return config1 & MIPS_CONF_M;
518}
519
520static inline unsigned int decode_config2(struct cpuinfo_mips *c)
521{
522 unsigned int config2;
523
524 config2 = read_c0_config2();
525
526 if (config2 & MIPS_CONF2_SL)
527 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
528
529 return config2 & MIPS_CONF_M;
530}
531
532static inline unsigned int decode_config3(struct cpuinfo_mips *c)
533{
534 unsigned int config3;
535
536 config3 = read_c0_config3();
537
538 if (config3 & MIPS_CONF3_SM)
539 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a8f2005-05-31 11:49:19 +0000540 if (config3 & MIPS_CONF3_DSP)
541 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000542 if (config3 & MIPS_CONF3_VINT)
543 c->options |= MIPS_CPU_VINT;
544 if (config3 & MIPS_CONF3_VEIC)
545 c->options |= MIPS_CPU_VEIC;
546 if (config3 & MIPS_CONF3_MT)
547 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechle41943182005-05-05 16:45:59 +0000548
549 return config3 & MIPS_CONF_M;
550}
551
552static inline void decode_configs(struct cpuinfo_mips *c)
553{
554 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100555 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
556 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000557
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
559
Ralf Baechle41943182005-05-05 16:45:59 +0000560 /* Read Config registers. */
561 if (!decode_config0(c))
562 return; /* actually worth a panic() */
563 if (!decode_config1(c))
564 return;
565 if (!decode_config2(c))
566 return;
567 if (!decode_config3(c))
568 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569}
570
571static inline void cpu_probe_mips(struct cpuinfo_mips *c)
572{
Ralf Baechle41943182005-05-05 16:45:59 +0000573 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 switch (c->processor_id & 0xff00) {
575 case PRID_IMP_4KC:
576 c->cputype = CPU_4KC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 break;
578 case PRID_IMP_4KEC:
579 c->cputype = CPU_4KEC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 break;
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000581 case PRID_IMP_4KECR2:
582 c->cputype = CPU_4KEC;
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000583 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100585 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 c->cputype = CPU_4KSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 break;
588 case PRID_IMP_5KC:
589 c->cputype = CPU_5KC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 break;
591 case PRID_IMP_20KC:
592 c->cputype = CPU_20KC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 break;
594 case PRID_IMP_24K:
Ralf Baechlee50c0a8f2005-05-31 11:49:19 +0000595 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 c->cputype = CPU_24K;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 break;
598 case PRID_IMP_25KF:
599 c->cputype = CPU_25KF;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 /* Probe for L2 cache */
601 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
602 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000603 case PRID_IMP_34K:
604 c->cputype = CPU_34K;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000605 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100606 case PRID_IMP_74K:
607 c->cputype = CPU_74K;
608 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 }
610}
611
612static inline void cpu_probe_alchemy(struct cpuinfo_mips *c)
613{
Ralf Baechle41943182005-05-05 16:45:59 +0000614 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 switch (c->processor_id & 0xff00) {
616 case PRID_IMP_AU1_REV1:
617 case PRID_IMP_AU1_REV2:
618 switch ((c->processor_id >> 24) & 0xff) {
619 case 0:
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000620 c->cputype = CPU_AU1000;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 break;
622 case 1:
623 c->cputype = CPU_AU1500;
624 break;
625 case 2:
626 c->cputype = CPU_AU1100;
627 break;
628 case 3:
629 c->cputype = CPU_AU1550;
630 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000631 case 4:
632 c->cputype = CPU_AU1200;
633 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 default:
635 panic("Unknown Au Core!");
636 break;
637 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 break;
639 }
640}
641
642static inline void cpu_probe_sibyte(struct cpuinfo_mips *c)
643{
Ralf Baechle41943182005-05-05 16:45:59 +0000644 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100645
646 /*
647 * For historical reasons the SB1 comes with it's own variant of
648 * cache code which eventually will be folded into c-r4k.c. Until
649 * then we pretend it's got it's own cache architecture.
650 */
Andrew Isaacsond121ced2005-10-19 23:54:43 -0700651 c->options &= ~MIPS_CPU_4K_CACHE;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100652 c->options |= MIPS_CPU_SB1_CACHE;
653
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 switch (c->processor_id & 0xff00) {
655 case PRID_IMP_SB1:
656 c->cputype = CPU_SB1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 /* FPU in pass1 is known to have issues. */
Ralf Baechle010b8532006-01-29 18:42:08 +0000658 if ((c->processor_id & 0xff) < 0x20)
659 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700661 case PRID_IMP_SB1A:
662 c->cputype = CPU_SB1A;
663 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 }
665}
666
667static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c)
668{
Ralf Baechle41943182005-05-05 16:45:59 +0000669 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 switch (c->processor_id & 0xff00) {
671 case PRID_IMP_SR71000:
672 c->cputype = CPU_SR71000;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 c->scache.ways = 8;
674 c->tlbsize = 64;
675 break;
676 }
677}
678
Pete Popovbdf21b12005-07-14 17:47:57 +0000679static inline void cpu_probe_philips(struct cpuinfo_mips *c)
680{
681 decode_configs(c);
682 switch (c->processor_id & 0xff00) {
683 case PRID_IMP_PR4450:
684 c->cputype = CPU_PR4450;
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000685 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000686 break;
687 default:
688 panic("Unknown Philips Core!"); /* REVISIT: die? */
689 break;
690 }
691}
692
693
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694__init void cpu_probe(void)
695{
696 struct cpuinfo_mips *c = &current_cpu_data;
697
698 c->processor_id = PRID_IMP_UNKNOWN;
699 c->fpu_id = FPIR_IMP_NONE;
700 c->cputype = CPU_UNKNOWN;
701
702 c->processor_id = read_c0_prid();
703 switch (c->processor_id & 0xff0000) {
704 case PRID_COMP_LEGACY:
705 cpu_probe_legacy(c);
706 break;
707 case PRID_COMP_MIPS:
708 cpu_probe_mips(c);
709 break;
710 case PRID_COMP_ALCHEMY:
711 cpu_probe_alchemy(c);
712 break;
713 case PRID_COMP_SIBYTE:
714 cpu_probe_sibyte(c);
715 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 case PRID_COMP_SANDCRAFT:
717 cpu_probe_sandcraft(c);
718 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000719 case PRID_COMP_PHILIPS:
720 cpu_probe_philips(c);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000721 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 default:
723 c->cputype = CPU_UNKNOWN;
724 }
Ralf Baechle41943182005-05-05 16:45:59 +0000725 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700726 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +0000727
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000728 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +0000729 c->isa_level == MIPS_CPU_ISA_M32R2 ||
730 c->isa_level == MIPS_CPU_ISA_M64R1 ||
731 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +0000732 if (c->fpu_id & MIPS_FPIR_3D)
733 c->ases |= MIPS_ASE_MIPS3D;
734 }
735 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736}
737
738__init void cpu_report(void)
739{
740 struct cpuinfo_mips *c = &current_cpu_data;
741
742 printk("CPU revision is: %08x\n", c->processor_id);
743 if (c->options & MIPS_CPU_FPU)
744 printk("FPU revision is: %08x\n", c->fpu_id);
745}