2 * Processor capabilities determination functions.
4 * Copyright (C) xxxx the Anonymous
5 * Copyright (C) 1994 - 2006 Ralf Baechle
6 * Copyright (C) 2003, 2004 Maciej W. Rozycki
7 * Copyright (C) 2001, 2004 MIPS Inc.
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.
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/ptrace.h>
17 #include <linux/smp.h>
18 #include <linux/stddef.h>
19 #include <linux/module.h>
24 #include <asm/mipsregs.h>
25 #include <asm/system.h>
26 #include <asm/watch.h>
27 #include <asm/spram.h>
29 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
30 * the implementation of the "wait" feature differs between CPU families. This
31 * points to the function that implements CPU specific wait.
32 * The wait instruction stops the pipeline and reduces the power consumption of
35 void (*cpu_wait)(void);
36 EXPORT_SYMBOL(cpu_wait);
38 static void r3081_wait(void)
40 unsigned long cfg = read_c0_conf();
41 write_c0_conf(cfg | R30XX_CONF_HALT);
44 static void r39xx_wait(void)
48 write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
52 extern void r4k_wait(void);
55 * This variant is preferable as it allows testing need_resched and going to
56 * sleep depending on the outcome atomically. Unfortunately the "It is
57 * implementation-dependent whether the pipeline restarts when a non-enabled
58 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
59 * using this version a gamble.
61 void r4k_wait_irqoff(void)
65 __asm__(" .set push \n"
70 __asm__(" .globl __pastwait \n"
76 * The RM7000 variant has to handle erratum 38. The workaround is to not
77 * have any pending stores when the WAIT instruction is executed.
79 static void rm7k_wait_irqoff(void)
89 " mtc0 $1, $12 # stalls until W stage \n"
91 " mtc0 $1, $12 # stalls until W stage \n"
97 * The Au1xxx wait is available only if using 32khz counter or
98 * external timer source, but specifically not CP0 Counter.
99 * alchemy/common/time.c may override cpu_wait!
101 static void au1k_wait(void)
103 __asm__(" .set mips3 \n"
104 " cache 0x14, 0(%0) \n"
105 " cache 0x14, 32(%0) \n"
114 : : "r" (au1k_wait));
117 static int __initdata nowait;
119 static int __init wait_disable(char *s)
126 __setup("nowait", wait_disable);
128 static int __cpuinitdata mips_fpu_disabled;
130 static int __init fpu_disable(char *s)
132 cpu_data[0].options &= ~MIPS_CPU_FPU;
133 mips_fpu_disabled = 1;
138 __setup("nofpu", fpu_disable);
140 int __cpuinitdata mips_dsp_disabled;
142 static int __init dsp_disable(char *s)
144 cpu_data[0].ases &= ~MIPS_ASE_DSP;
145 mips_dsp_disabled = 1;
150 __setup("nodsp", dsp_disable);
152 void __init check_wait(void)
154 struct cpuinfo_mips *c = ¤t_cpu_data;
157 printk("Wait instruction disabled.\n");
161 switch (c->cputype) {
164 cpu_wait = r3081_wait;
167 cpu_wait = r39xx_wait;
170 /* case CPU_R4300: */
188 case CPU_CAVIUM_OCTEON:
189 case CPU_CAVIUM_OCTEON_PLUS:
190 case CPU_CAVIUM_OCTEON2:
196 cpu_wait = rm7k_wait_irqoff;
203 if (read_c0_config7() & MIPS_CONF7_WII)
204 cpu_wait = r4k_wait_irqoff;
209 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
210 cpu_wait = r4k_wait_irqoff;
214 cpu_wait = r4k_wait_irqoff;
217 cpu_wait = au1k_wait;
221 * WAIT on Rev1.0 has E1, E2, E3 and E16.
222 * WAIT on Rev2.0 and Rev3.0 has E16.
223 * Rev3.1 WAIT is nop, why bother
225 if ((c->processor_id & 0xff) <= 0x64)
229 * Another rev is incremeting c0_count at a reduced clock
230 * rate while in WAIT mode. So we basically have the choice
231 * between using the cp0 timer as clocksource or avoiding
232 * the WAIT instruction. Until more details are known,
233 * disable the use of WAIT for 20Kc entirely.
238 if ((c->processor_id & 0x00ff) >= 0x40)
246 static inline void check_errata(void)
248 struct cpuinfo_mips *c = ¤t_cpu_data;
250 switch (c->cputype) {
253 * Erratum "RPS May Cause Incorrect Instruction Execution"
254 * This code only handles VPE0, any SMP/SMTC/RTOS code
255 * making use of VPE1 will be responsable for that VPE.
257 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
258 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
265 void __init check_bugs32(void)
271 * Probe whether cpu has config register by trying to play with
272 * alternate cache bit and see whether it matters.
273 * It's used by cpu_probe to distinguish between R3000A and R3081.
275 static inline int cpu_has_confreg(void)
277 #ifdef CONFIG_CPU_R3000
278 extern unsigned long r3k_cache_size(unsigned long);
279 unsigned long size1, size2;
280 unsigned long cfg = read_c0_conf();
282 size1 = r3k_cache_size(ST0_ISC);
283 write_c0_conf(cfg ^ R30XX_CONF_AC);
284 size2 = r3k_cache_size(ST0_ISC);
286 return size1 != size2;
293 * Get the FPU Implementation/Revision.
295 static inline unsigned long cpu_get_fpu_id(void)
297 unsigned long tmp, fpu_id;
299 tmp = read_c0_status();
301 fpu_id = read_32bit_cp1_register(CP1_REVISION);
302 write_c0_status(tmp);
307 * Check the CPU has an FPU the official way.
309 static inline int __cpu_has_fpu(void)
311 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
314 static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
316 #ifdef __NEED_VMBITS_PROBE
317 write_c0_entryhi(0x3fffffffffffe000ULL);
318 back_to_back_c0_hazard();
319 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
323 #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
326 static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
328 switch (c->processor_id & 0xff00) {
330 c->cputype = CPU_R2000;
331 __cpu_name[cpu] = "R2000";
332 c->isa_level = MIPS_CPU_ISA_I;
333 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
336 c->options |= MIPS_CPU_FPU;
340 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
341 if (cpu_has_confreg()) {
342 c->cputype = CPU_R3081E;
343 __cpu_name[cpu] = "R3081";
345 c->cputype = CPU_R3000A;
346 __cpu_name[cpu] = "R3000A";
350 c->cputype = CPU_R3000;
351 __cpu_name[cpu] = "R3000";
353 c->isa_level = MIPS_CPU_ISA_I;
354 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
357 c->options |= MIPS_CPU_FPU;
361 if (read_c0_config() & CONF_SC) {
362 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
363 c->cputype = CPU_R4400PC;
364 __cpu_name[cpu] = "R4400PC";
366 c->cputype = CPU_R4000PC;
367 __cpu_name[cpu] = "R4000PC";
370 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
371 c->cputype = CPU_R4400SC;
372 __cpu_name[cpu] = "R4400SC";
374 c->cputype = CPU_R4000SC;
375 __cpu_name[cpu] = "R4000SC";
379 c->isa_level = MIPS_CPU_ISA_III;
380 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
381 MIPS_CPU_WATCH | MIPS_CPU_VCE |
385 case PRID_IMP_VR41XX:
386 switch (c->processor_id & 0xf0) {
387 case PRID_REV_VR4111:
388 c->cputype = CPU_VR4111;
389 __cpu_name[cpu] = "NEC VR4111";
391 case PRID_REV_VR4121:
392 c->cputype = CPU_VR4121;
393 __cpu_name[cpu] = "NEC VR4121";
395 case PRID_REV_VR4122:
396 if ((c->processor_id & 0xf) < 0x3) {
397 c->cputype = CPU_VR4122;
398 __cpu_name[cpu] = "NEC VR4122";
400 c->cputype = CPU_VR4181A;
401 __cpu_name[cpu] = "NEC VR4181A";
404 case PRID_REV_VR4130:
405 if ((c->processor_id & 0xf) < 0x4) {
406 c->cputype = CPU_VR4131;
407 __cpu_name[cpu] = "NEC VR4131";
409 c->cputype = CPU_VR4133;
410 __cpu_name[cpu] = "NEC VR4133";
414 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
415 c->cputype = CPU_VR41XX;
416 __cpu_name[cpu] = "NEC Vr41xx";
419 c->isa_level = MIPS_CPU_ISA_III;
420 c->options = R4K_OPTS;
424 c->cputype = CPU_R4300;
425 __cpu_name[cpu] = "R4300";
426 c->isa_level = MIPS_CPU_ISA_III;
427 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
432 c->cputype = CPU_R4600;
433 __cpu_name[cpu] = "R4600";
434 c->isa_level = MIPS_CPU_ISA_III;
435 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
442 * This processor doesn't have an MMU, so it's not
443 * "real easy" to run Linux on it. It is left purely
444 * for documentation. Commented out because it shares
445 * it's c0_prid id number with the TX3900.
447 c->cputype = CPU_R4650;
448 __cpu_name[cpu] = "R4650";
449 c->isa_level = MIPS_CPU_ISA_III;
450 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
455 c->isa_level = MIPS_CPU_ISA_I;
456 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
458 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
459 c->cputype = CPU_TX3927;
460 __cpu_name[cpu] = "TX3927";
463 switch (c->processor_id & 0xff) {
464 case PRID_REV_TX3912:
465 c->cputype = CPU_TX3912;
466 __cpu_name[cpu] = "TX3912";
469 case PRID_REV_TX3922:
470 c->cputype = CPU_TX3922;
471 __cpu_name[cpu] = "TX3922";
478 c->cputype = CPU_R4700;
479 __cpu_name[cpu] = "R4700";
480 c->isa_level = MIPS_CPU_ISA_III;
481 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
486 c->cputype = CPU_TX49XX;
487 __cpu_name[cpu] = "R49XX";
488 c->isa_level = MIPS_CPU_ISA_III;
489 c->options = R4K_OPTS | MIPS_CPU_LLSC;
490 if (!(c->processor_id & 0x08))
491 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
495 c->cputype = CPU_R5000;
496 __cpu_name[cpu] = "R5000";
497 c->isa_level = MIPS_CPU_ISA_IV;
498 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
503 c->cputype = CPU_R5432;
504 __cpu_name[cpu] = "R5432";
505 c->isa_level = MIPS_CPU_ISA_IV;
506 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
507 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
511 c->cputype = CPU_R5500;
512 __cpu_name[cpu] = "R5500";
513 c->isa_level = MIPS_CPU_ISA_IV;
514 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
515 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
518 case PRID_IMP_NEVADA:
519 c->cputype = CPU_NEVADA;
520 __cpu_name[cpu] = "Nevada";
521 c->isa_level = MIPS_CPU_ISA_IV;
522 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
523 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
527 c->cputype = CPU_R6000;
528 __cpu_name[cpu] = "R6000";
529 c->isa_level = MIPS_CPU_ISA_II;
530 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
534 case PRID_IMP_R6000A:
535 c->cputype = CPU_R6000A;
536 __cpu_name[cpu] = "R6000A";
537 c->isa_level = MIPS_CPU_ISA_II;
538 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
542 case PRID_IMP_RM7000:
543 c->cputype = CPU_RM7000;
544 __cpu_name[cpu] = "RM7000";
545 c->isa_level = MIPS_CPU_ISA_IV;
546 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
549 * Undocumented RM7000: Bit 29 in the info register of
550 * the RM7000 v2.0 indicates if the TLB has 48 or 64
553 * 29 1 => 64 entry JTLB
556 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
558 case PRID_IMP_RM9000:
559 c->cputype = CPU_RM9000;
560 __cpu_name[cpu] = "RM9000";
561 c->isa_level = MIPS_CPU_ISA_IV;
562 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
565 * Bit 29 in the info register of the RM9000
566 * indicates if the TLB has 48 or 64 entries.
568 * 29 1 => 64 entry JTLB
571 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
574 c->cputype = CPU_R8000;
575 __cpu_name[cpu] = "RM8000";
576 c->isa_level = MIPS_CPU_ISA_IV;
577 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
578 MIPS_CPU_FPU | MIPS_CPU_32FPR |
580 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
582 case PRID_IMP_R10000:
583 c->cputype = CPU_R10000;
584 __cpu_name[cpu] = "R10000";
585 c->isa_level = MIPS_CPU_ISA_IV;
586 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
587 MIPS_CPU_FPU | MIPS_CPU_32FPR |
588 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
592 case PRID_IMP_R12000:
593 c->cputype = CPU_R12000;
594 __cpu_name[cpu] = "R12000";
595 c->isa_level = MIPS_CPU_ISA_IV;
596 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
597 MIPS_CPU_FPU | MIPS_CPU_32FPR |
598 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
602 case PRID_IMP_R14000:
603 c->cputype = CPU_R14000;
604 __cpu_name[cpu] = "R14000";
605 c->isa_level = MIPS_CPU_ISA_IV;
606 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
607 MIPS_CPU_FPU | MIPS_CPU_32FPR |
608 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
612 case PRID_IMP_LOONGSON2:
613 c->cputype = CPU_LOONGSON2;
614 __cpu_name[cpu] = "ICT Loongson-2";
615 c->isa_level = MIPS_CPU_ISA_III;
616 c->options = R4K_OPTS |
617 MIPS_CPU_FPU | MIPS_CPU_LLSC |
624 static char unknown_isa[] __cpuinitdata = KERN_ERR \
625 "Unsupported ISA type, c0.config0: %d.";
627 static inline unsigned int decode_config0(struct cpuinfo_mips *c)
629 unsigned int config0;
632 config0 = read_c0_config();
634 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
635 c->options |= MIPS_CPU_TLB;
636 isa = (config0 & MIPS_CONF_AT) >> 13;
639 switch ((config0 & MIPS_CONF_AR) >> 10) {
641 c->isa_level = MIPS_CPU_ISA_M32R1;
644 c->isa_level = MIPS_CPU_ISA_M32R2;
651 switch ((config0 & MIPS_CONF_AR) >> 10) {
653 c->isa_level = MIPS_CPU_ISA_M64R1;
656 c->isa_level = MIPS_CPU_ISA_M64R2;
666 return config0 & MIPS_CONF_M;
669 panic(unknown_isa, config0);
672 static inline unsigned int decode_config1(struct cpuinfo_mips *c)
674 unsigned int config1;
676 config1 = read_c0_config1();
678 if (config1 & MIPS_CONF1_MD)
679 c->ases |= MIPS_ASE_MDMX;
680 if (config1 & MIPS_CONF1_WR)
681 c->options |= MIPS_CPU_WATCH;
682 if (config1 & MIPS_CONF1_CA)
683 c->ases |= MIPS_ASE_MIPS16;
684 if (config1 & MIPS_CONF1_EP)
685 c->options |= MIPS_CPU_EJTAG;
686 if (config1 & MIPS_CONF1_FP) {
687 c->options |= MIPS_CPU_FPU;
688 c->options |= MIPS_CPU_32FPR;
691 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
693 return config1 & MIPS_CONF_M;
696 static inline unsigned int decode_config2(struct cpuinfo_mips *c)
698 unsigned int config2;
700 config2 = read_c0_config2();
702 if (config2 & MIPS_CONF2_SL)
703 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
705 return config2 & MIPS_CONF_M;
708 static inline unsigned int decode_config3(struct cpuinfo_mips *c)
710 unsigned int config3;
712 config3 = read_c0_config3();
714 if (config3 & MIPS_CONF3_SM)
715 c->ases |= MIPS_ASE_SMARTMIPS;
716 if (config3 & MIPS_CONF3_DSP)
717 c->ases |= MIPS_ASE_DSP;
718 if (config3 & MIPS_CONF3_VINT)
719 c->options |= MIPS_CPU_VINT;
720 if (config3 & MIPS_CONF3_VEIC)
721 c->options |= MIPS_CPU_VEIC;
722 if (config3 & MIPS_CONF3_MT)
723 c->ases |= MIPS_ASE_MIPSMT;
724 if (config3 & MIPS_CONF3_ULRI)
725 c->options |= MIPS_CPU_ULRI;
727 return config3 & MIPS_CONF_M;
730 static inline unsigned int decode_config4(struct cpuinfo_mips *c)
732 unsigned int config4;
734 config4 = read_c0_config4();
736 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
738 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
740 return config4 & MIPS_CONF_M;
743 static void __cpuinit decode_configs(struct cpuinfo_mips *c)
747 /* MIPS32 or MIPS64 compliant CPU. */
748 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
749 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
751 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
753 ok = decode_config0(c); /* Read Config registers. */
754 BUG_ON(!ok); /* Arch spec violation! */
756 ok = decode_config1(c);
758 ok = decode_config2(c);
760 ok = decode_config3(c);
762 ok = decode_config4(c);
764 mips_probe_watch_registers(c);
767 c->core = read_c0_ebase() & 0x3ff;
770 static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
773 switch (c->processor_id & 0xff00) {
775 c->cputype = CPU_4KC;
776 __cpu_name[cpu] = "MIPS 4Kc";
779 case PRID_IMP_4KECR2:
780 c->cputype = CPU_4KEC;
781 __cpu_name[cpu] = "MIPS 4KEc";
785 c->cputype = CPU_4KSC;
786 __cpu_name[cpu] = "MIPS 4KSc";
789 c->cputype = CPU_5KC;
790 __cpu_name[cpu] = "MIPS 5Kc";
793 c->cputype = CPU_20KC;
794 __cpu_name[cpu] = "MIPS 20Kc";
798 c->cputype = CPU_24K;
799 __cpu_name[cpu] = "MIPS 24Kc";
802 c->cputype = CPU_25KF;
803 __cpu_name[cpu] = "MIPS 25Kc";
806 c->cputype = CPU_34K;
807 __cpu_name[cpu] = "MIPS 34Kc";
810 c->cputype = CPU_74K;
811 __cpu_name[cpu] = "MIPS 74Kc";
814 c->cputype = CPU_1004K;
815 __cpu_name[cpu] = "MIPS 1004Kc";
822 static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
825 switch (c->processor_id & 0xff00) {
826 case PRID_IMP_AU1_REV1:
827 case PRID_IMP_AU1_REV2:
828 c->cputype = CPU_ALCHEMY;
829 switch ((c->processor_id >> 24) & 0xff) {
831 __cpu_name[cpu] = "Au1000";
834 __cpu_name[cpu] = "Au1500";
837 __cpu_name[cpu] = "Au1100";
840 __cpu_name[cpu] = "Au1550";
843 __cpu_name[cpu] = "Au1200";
844 if ((c->processor_id & 0xff) == 2)
845 __cpu_name[cpu] = "Au1250";
848 __cpu_name[cpu] = "Au1210";
851 __cpu_name[cpu] = "Au1xxx";
858 static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
862 switch (c->processor_id & 0xff00) {
864 c->cputype = CPU_SB1;
865 __cpu_name[cpu] = "SiByte SB1";
866 /* FPU in pass1 is known to have issues. */
867 if ((c->processor_id & 0xff) < 0x02)
868 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
871 c->cputype = CPU_SB1A;
872 __cpu_name[cpu] = "SiByte SB1A";
877 static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
880 switch (c->processor_id & 0xff00) {
881 case PRID_IMP_SR71000:
882 c->cputype = CPU_SR71000;
883 __cpu_name[cpu] = "Sandcraft SR71000";
890 static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
893 switch (c->processor_id & 0xff00) {
894 case PRID_IMP_PR4450:
895 c->cputype = CPU_PR4450;
896 __cpu_name[cpu] = "Philips PR4450";
897 c->isa_level = MIPS_CPU_ISA_M32R1;
902 static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
905 switch (c->processor_id & 0xff00) {
906 case PRID_IMP_BMIPS32:
907 c->cputype = CPU_BMIPS32;
908 __cpu_name[cpu] = "Broadcom BMIPS32";
910 case PRID_IMP_BMIPS3300:
911 case PRID_IMP_BMIPS3300_ALT:
912 case PRID_IMP_BMIPS3300_BUG:
913 c->cputype = CPU_BMIPS3300;
914 __cpu_name[cpu] = "Broadcom BMIPS3300";
916 case PRID_IMP_BMIPS43XX: {
917 int rev = c->processor_id & 0xff;
919 if (rev >= PRID_REV_BMIPS4380_LO &&
920 rev <= PRID_REV_BMIPS4380_HI) {
921 c->cputype = CPU_BMIPS4380;
922 __cpu_name[cpu] = "Broadcom BMIPS4380";
924 c->cputype = CPU_BMIPS4350;
925 __cpu_name[cpu] = "Broadcom BMIPS4350";
929 case PRID_IMP_BMIPS5000:
930 c->cputype = CPU_BMIPS5000;
931 __cpu_name[cpu] = "Broadcom BMIPS5000";
932 c->options |= MIPS_CPU_ULRI;
934 case PRID_IMP_BMIPS4KC:
935 c->cputype = CPU_4KC;
936 __cpu_name[cpu] = "MIPS 4Kc";
941 static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
944 switch (c->processor_id & 0xff00) {
945 case PRID_IMP_CAVIUM_CN38XX:
946 case PRID_IMP_CAVIUM_CN31XX:
947 case PRID_IMP_CAVIUM_CN30XX:
948 c->cputype = CPU_CAVIUM_OCTEON;
949 __cpu_name[cpu] = "Cavium Octeon";
951 case PRID_IMP_CAVIUM_CN58XX:
952 case PRID_IMP_CAVIUM_CN56XX:
953 case PRID_IMP_CAVIUM_CN50XX:
954 case PRID_IMP_CAVIUM_CN52XX:
955 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
956 __cpu_name[cpu] = "Cavium Octeon+";
959 __elf_platform = "octeon";
961 case PRID_IMP_CAVIUM_CN63XX:
962 c->cputype = CPU_CAVIUM_OCTEON2;
963 __cpu_name[cpu] = "Cavium Octeon II";
965 __elf_platform = "octeon2";
968 printk(KERN_INFO "Unknown Octeon chip!\n");
969 c->cputype = CPU_UNKNOWN;
974 static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
977 /* JZRISC does not implement the CP0 counter. */
978 c->options &= ~MIPS_CPU_COUNTER;
979 switch (c->processor_id & 0xff00) {
980 case PRID_IMP_JZRISC:
981 c->cputype = CPU_JZRISC;
982 __cpu_name[cpu] = "Ingenic JZRISC";
985 panic("Unknown Ingenic Processor ID!");
990 const char *__cpu_name[NR_CPUS];
991 const char *__elf_platform;
993 __cpuinit void cpu_probe(void)
995 struct cpuinfo_mips *c = ¤t_cpu_data;
996 unsigned int cpu = smp_processor_id();
998 c->processor_id = PRID_IMP_UNKNOWN;
999 c->fpu_id = FPIR_IMP_NONE;
1000 c->cputype = CPU_UNKNOWN;
1002 c->processor_id = read_c0_prid();
1003 switch (c->processor_id & 0xff0000) {
1004 case PRID_COMP_LEGACY:
1005 cpu_probe_legacy(c, cpu);
1007 case PRID_COMP_MIPS:
1008 cpu_probe_mips(c, cpu);
1010 case PRID_COMP_ALCHEMY:
1011 cpu_probe_alchemy(c, cpu);
1013 case PRID_COMP_SIBYTE:
1014 cpu_probe_sibyte(c, cpu);
1016 case PRID_COMP_BROADCOM:
1017 cpu_probe_broadcom(c, cpu);
1019 case PRID_COMP_SANDCRAFT:
1020 cpu_probe_sandcraft(c, cpu);
1023 cpu_probe_nxp(c, cpu);
1025 case PRID_COMP_CAVIUM:
1026 cpu_probe_cavium(c, cpu);
1028 case PRID_COMP_INGENIC:
1029 cpu_probe_ingenic(c, cpu);
1033 BUG_ON(!__cpu_name[cpu]);
1034 BUG_ON(c->cputype == CPU_UNKNOWN);
1037 * Platform code can force the cpu type to optimize code
1038 * generation. In that case be sure the cpu type is correctly
1039 * manually setup otherwise it could trigger some nasty bugs.
1041 BUG_ON(current_cpu_type() != c->cputype);
1043 if (mips_fpu_disabled)
1044 c->options &= ~MIPS_CPU_FPU;
1046 if (mips_dsp_disabled)
1047 c->ases &= ~MIPS_ASE_DSP;
1049 if (c->options & MIPS_CPU_FPU) {
1050 c->fpu_id = cpu_get_fpu_id();
1052 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
1053 c->isa_level == MIPS_CPU_ISA_M32R2 ||
1054 c->isa_level == MIPS_CPU_ISA_M64R1 ||
1055 c->isa_level == MIPS_CPU_ISA_M64R2) {
1056 if (c->fpu_id & MIPS_FPIR_3D)
1057 c->ases |= MIPS_ASE_MIPS3D;
1061 if (cpu_has_mips_r2)
1062 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1066 cpu_probe_vmbits(c);
1069 __cpuinit void cpu_report(void)
1071 struct cpuinfo_mips *c = ¤t_cpu_data;
1073 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1074 c->processor_id, cpu_name_string());
1075 if (c->options & MIPS_CPU_FPU)
1076 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);