]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Processor capabilities determination functions. | |
3 | * | |
4 | * Copyright (C) xxxx the Anonymous | |
4194318c | 5 | * Copyright (C) 2003, 2004 Maciej W. Rozycki |
1da177e4 | 6 | * Copyright (C) 1994 - 2003 Ralf Baechle |
4194318c | 7 | * Copyright (C) 2001, 2004 MIPS Inc. |
1da177e4 LT |
8 | * |
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 | ||
1da177e4 LT |
20 | #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 | */ | |
32 | void (*cpu_wait)(void) = NULL; | |
33 | ||
34 | static void r3081_wait(void) | |
35 | { | |
36 | unsigned long cfg = read_c0_conf(); | |
37 | write_c0_conf(cfg | R30XX_CONF_HALT); | |
38 | } | |
39 | ||
40 | static void r39xx_wait(void) | |
41 | { | |
42 | unsigned long cfg = read_c0_conf(); | |
43 | write_c0_conf(cfg | TX39_CONF_HALT); | |
44 | } | |
45 | ||
46 | static void r4k_wait(void) | |
47 | { | |
48 | __asm__(".set\tmips3\n\t" | |
49 | "wait\n\t" | |
50 | ".set\tmips0"); | |
51 | } | |
52 | ||
494900af PP |
53 | /* The Au1xxx wait is available only if using 32khz counter or |
54 | * external timer source, but specifically not CP0 Counter. */ | |
fe359bf5 | 55 | int allow_au1k_wait; |
10f650db | 56 | |
494900af | 57 | static void au1k_wait(void) |
1da177e4 | 58 | { |
1da177e4 | 59 | /* using the wait instruction makes CP0 counter unusable */ |
10f650db RB |
60 | __asm__(".set mips3\n\t" |
61 | "cache 0x14, 0(%0)\n\t" | |
62 | "cache 0x14, 32(%0)\n\t" | |
494900af PP |
63 | "sync\n\t" |
64 | "nop\n\t" | |
1da177e4 LT |
65 | "wait\n\t" |
66 | "nop\n\t" | |
67 | "nop\n\t" | |
68 | "nop\n\t" | |
69 | "nop\n\t" | |
494900af | 70 | ".set mips0\n\t" |
10f650db | 71 | : : "r" (au1k_wait)); |
1da177e4 LT |
72 | } |
73 | ||
55d04dff RB |
74 | static int __initdata nowait = 0; |
75 | ||
76 | int __init wait_disable(char *s) | |
77 | { | |
78 | nowait = 1; | |
79 | ||
80 | return 1; | |
81 | } | |
82 | ||
83 | __setup("nowait", wait_disable); | |
84 | ||
1da177e4 LT |
85 | static inline void check_wait(void) |
86 | { | |
87 | struct cpuinfo_mips *c = ¤t_cpu_data; | |
88 | ||
89 | printk("Checking for 'wait' instruction... "); | |
55d04dff RB |
90 | if (nowait) { |
91 | printk (" disabled.\n"); | |
92 | return; | |
93 | } | |
94 | ||
1da177e4 LT |
95 | 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: | |
bbc7f22f | 123 | case CPU_34K: |
bdf21b18 | 124 | case CPU_PR4450: |
1da177e4 LT |
125 | cpu_wait = r4k_wait; |
126 | printk(" available.\n"); | |
127 | break; | |
1da177e4 LT |
128 | case CPU_AU1000: |
129 | case CPU_AU1100: | |
130 | case CPU_AU1500: | |
e3ad1c23 PP |
131 | case CPU_AU1550: |
132 | case CPU_AU1200: | |
fe359bf5 PP |
133 | if (allow_au1k_wait) { |
134 | cpu_wait = au1k_wait; | |
135 | printk(" available.\n"); | |
136 | } else | |
137 | printk(" unavailable.\n"); | |
1da177e4 | 138 | break; |
1da177e4 LT |
139 | default: |
140 | printk(" unavailable.\n"); | |
141 | break; | |
142 | } | |
143 | } | |
144 | ||
145 | void __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 | */ | |
155 | static 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 | */ | |
175 | static 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 | */ | |
189 | static 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 | ||
197 | static 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) { | |
1da177e4 LT |
243 | case PRID_REV_VR4111: |
244 | c->cputype = CPU_VR4111; | |
245 | break; | |
1da177e4 LT |
246 | 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 | ||
4194318c | 435 | static inline unsigned int decode_config0(struct cpuinfo_mips *c) |
1da177e4 | 436 | { |
4194318c RB |
437 | unsigned int config0; |
438 | int isa; | |
1da177e4 | 439 | |
4194318c RB |
440 | config0 = read_c0_config(); |
441 | ||
442 | if (((config0 & MIPS_CONF_MT) >> 7) == 1) | |
d5b6f1db | 443 | c->options |= MIPS_CPU_TLB | MIPS_CPU_4KTLB; |
4194318c RB |
444 | 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 | ||
459 | static inline unsigned int decode_config1(struct cpuinfo_mips *c) | |
460 | { | |
461 | unsigned int config1; | |
1da177e4 | 462 | |
1da177e4 | 463 | config1 = read_c0_config1(); |
4194318c RB |
464 | |
465 | if (config1 & MIPS_CONF1_MD) | |
466 | c->ases |= MIPS_ASE_MDMX; | |
467 | if (config1 & MIPS_CONF1_WR) | |
1da177e4 | 468 | c->options |= MIPS_CPU_WATCH; |
4194318c RB |
469 | if (config1 & MIPS_CONF1_CA) |
470 | c->ases |= MIPS_ASE_MIPS16; | |
471 | if (config1 & MIPS_CONF1_EP) | |
1da177e4 | 472 | c->options |= MIPS_CPU_EJTAG; |
4194318c | 473 | if (config1 & MIPS_CONF1_FP) { |
1da177e4 LT |
474 | c->options |= MIPS_CPU_FPU; |
475 | c->options |= MIPS_CPU_32FPR; | |
476 | } | |
4194318c RB |
477 | if (cpu_has_tlb) |
478 | c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1; | |
479 | ||
480 | return config1 & MIPS_CONF_M; | |
481 | } | |
482 | ||
483 | static 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 | ||
495 | static 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; | |
e50c0a8f RB |
503 | if (config3 & MIPS_CONF3_DSP) |
504 | c->ases |= MIPS_ASE_DSP; | |
8f40611d RB |
505 | 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; | |
4194318c RB |
511 | |
512 | return config3 & MIPS_CONF_M; | |
513 | } | |
514 | ||
515 | static 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 | ||
1da177e4 LT |
521 | c->scache.flags = MIPS_CACHE_NOT_PRESENT; |
522 | ||
4194318c RB |
523 | /* 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; | |
1da177e4 LT |
532 | } |
533 | ||
534 | static inline void cpu_probe_mips(struct cpuinfo_mips *c) | |
535 | { | |
4194318c | 536 | decode_configs(c); |
1da177e4 LT |
537 | switch (c->processor_id & 0xff00) { |
538 | case PRID_IMP_4KC: | |
539 | c->cputype = CPU_4KC; | |
1da177e4 LT |
540 | break; |
541 | case PRID_IMP_4KEC: | |
542 | c->cputype = CPU_4KEC; | |
1da177e4 | 543 | break; |
2b07bd02 RB |
544 | case PRID_IMP_4KECR2: |
545 | c->cputype = CPU_4KEC; | |
2b07bd02 | 546 | break; |
1da177e4 LT |
547 | case PRID_IMP_4KSC: |
548 | c->cputype = CPU_4KSC; | |
1da177e4 LT |
549 | break; |
550 | case PRID_IMP_5KC: | |
551 | c->cputype = CPU_5KC; | |
1da177e4 LT |
552 | break; |
553 | case PRID_IMP_20KC: | |
554 | c->cputype = CPU_20KC; | |
1da177e4 LT |
555 | break; |
556 | case PRID_IMP_24K: | |
e50c0a8f | 557 | case PRID_IMP_24KE: |
1da177e4 | 558 | c->cputype = CPU_24K; |
1da177e4 LT |
559 | break; |
560 | case PRID_IMP_25KF: | |
561 | c->cputype = CPU_25KF; | |
1da177e4 LT |
562 | /* Probe for L2 cache */ |
563 | c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT; | |
564 | break; | |
bbc7f22f RB |
565 | case PRID_IMP_34K: |
566 | c->cputype = CPU_34K; | |
567 | c->isa_level = MIPS_CPU_ISA_M32; | |
568 | break; | |
1da177e4 LT |
569 | } |
570 | } | |
571 | ||
572 | static inline void cpu_probe_alchemy(struct cpuinfo_mips *c) | |
573 | { | |
4194318c | 574 | decode_configs(c); |
1da177e4 LT |
575 | 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; | |
e3ad1c23 PP |
591 | case 4: |
592 | c->cputype = CPU_AU1200; | |
593 | break; | |
1da177e4 LT |
594 | default: |
595 | panic("Unknown Au Core!"); | |
596 | break; | |
597 | } | |
1da177e4 LT |
598 | break; |
599 | } | |
600 | } | |
601 | ||
602 | static inline void cpu_probe_sibyte(struct cpuinfo_mips *c) | |
603 | { | |
4194318c | 604 | decode_configs(c); |
1da177e4 LT |
605 | switch (c->processor_id & 0xff00) { |
606 | case PRID_IMP_SB1: | |
607 | c->cputype = CPU_SB1; | |
4194318c | 608 | #ifdef CONFIG_SB1_PASS_1_WORKAROUNDS |
1da177e4 | 609 | /* FPU in pass1 is known to have issues. */ |
4194318c | 610 | c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR); |
1da177e4 LT |
611 | #endif |
612 | break; | |
613 | } | |
614 | } | |
615 | ||
616 | static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c) | |
617 | { | |
4194318c | 618 | decode_configs(c); |
1da177e4 LT |
619 | switch (c->processor_id & 0xff00) { |
620 | case PRID_IMP_SR71000: | |
621 | c->cputype = CPU_SR71000; | |
1da177e4 LT |
622 | c->scache.ways = 8; |
623 | c->tlbsize = 64; | |
624 | break; | |
625 | } | |
626 | } | |
627 | ||
bdf21b18 PP |
628 | static 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 | ||
1da177e4 LT |
643 | __init void cpu_probe(void) |
644 | { | |
645 | struct cpuinfo_mips *c = ¤t_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; | |
1da177e4 LT |
665 | case PRID_COMP_SANDCRAFT: |
666 | cpu_probe_sandcraft(c); | |
667 | break; | |
bdf21b18 PP |
668 | case PRID_COMP_PHILIPS: |
669 | cpu_probe_philips(c); | |
670 | break; | |
1da177e4 LT |
671 | default: |
672 | c->cputype = CPU_UNKNOWN; | |
673 | } | |
4194318c | 674 | if (c->options & MIPS_CPU_FPU) { |
1da177e4 | 675 | c->fpu_id = cpu_get_fpu_id(); |
4194318c RB |
676 | |
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 | } | |
1da177e4 LT |
683 | } |
684 | ||
685 | __init void cpu_report(void) | |
686 | { | |
687 | struct cpuinfo_mips *c = ¤t_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 | } |