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>
28 #include <asm/uaccess.h>
31 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
32 * the implementation of the "wait" feature differs between CPU families. This
33 * points to the function that implements CPU specific wait.
34 * The wait instruction stops the pipeline and reduces the power consumption of
37 void (*cpu_wait)(void);
38 EXPORT_SYMBOL(cpu_wait);
40 static void r3081_wait(void)
42 unsigned long cfg = read_c0_conf();
43 write_c0_conf(cfg | R30XX_CONF_HALT);
46 static void r39xx_wait(void)
50 write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
54 extern void r4k_wait(void);
57 * This variant is preferable as it allows testing need_resched and going to
58 * sleep depending on the outcome atomically. Unfortunately the "It is
59 * implementation-dependent whether the pipeline restarts when a non-enabled
60 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
61 * using this version a gamble.
63 void r4k_wait_irqoff(void)
67 __asm__(" .set push \n"
72 __asm__(" .globl __pastwait \n"
78 * The RM7000 variant has to handle erratum 38. The workaround is to not
79 * have any pending stores when the WAIT instruction is executed.
81 static void rm7k_wait_irqoff(void)
91 " mtc0 $1, $12 # stalls until W stage \n"
93 " mtc0 $1, $12 # stalls until W stage \n"
99 * The Au1xxx wait is available only if using 32khz counter or
100 * external timer source, but specifically not CP0 Counter.
101 * alchemy/common/time.c may override cpu_wait!
103 static void au1k_wait(void)
105 __asm__(" .set mips3 \n"
106 " cache 0x14, 0(%0) \n"
107 " cache 0x14, 32(%0) \n"
116 : : "r" (au1k_wait));
119 static int __initdata nowait;
121 static int __init wait_disable(char *s)
128 __setup("nowait", wait_disable);
130 static int __cpuinitdata mips_fpu_disabled;
132 static int __init fpu_disable(char *s)
134 cpu_data[0].options &= ~MIPS_CPU_FPU;
135 mips_fpu_disabled = 1;
140 __setup("nofpu", fpu_disable);
142 int __cpuinitdata mips_dsp_disabled;
144 static int __init dsp_disable(char *s)
146 cpu_data[0].ases &= ~MIPS_ASE_DSP;
147 mips_dsp_disabled = 1;
152 __setup("nodsp", dsp_disable);
154 void __init check_wait(void)
156 struct cpuinfo_mips *c = ¤t_cpu_data;
159 printk("Wait instruction disabled.\n");
163 switch (c->cputype) {
166 cpu_wait = r3081_wait;
169 cpu_wait = r39xx_wait;
172 /* case CPU_R4300: */
190 case CPU_CAVIUM_OCTEON:
191 case CPU_CAVIUM_OCTEON_PLUS:
192 case CPU_CAVIUM_OCTEON2:
198 cpu_wait = rm7k_wait_irqoff;
205 if (read_c0_config7() & MIPS_CONF7_WII)
206 cpu_wait = r4k_wait_irqoff;
211 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
212 cpu_wait = r4k_wait_irqoff;
216 cpu_wait = r4k_wait_irqoff;
219 cpu_wait = au1k_wait;
223 * WAIT on Rev1.0 has E1, E2, E3 and E16.
224 * WAIT on Rev2.0 and Rev3.0 has E16.
225 * Rev3.1 WAIT is nop, why bother
227 if ((c->processor_id & 0xff) <= 0x64)
231 * Another rev is incremeting c0_count at a reduced clock
232 * rate while in WAIT mode. So we basically have the choice
233 * between using the cp0 timer as clocksource or avoiding
234 * the WAIT instruction. Until more details are known,
235 * disable the use of WAIT for 20Kc entirely.
240 if ((c->processor_id & 0x00ff) >= 0x40)
248 static inline void check_errata(void)
250 struct cpuinfo_mips *c = ¤t_cpu_data;
252 switch (c->cputype) {
255 * Erratum "RPS May Cause Incorrect Instruction Execution"
256 * This code only handles VPE0, any SMP/SMTC/RTOS code
257 * making use of VPE1 will be responsable for that VPE.
259 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
260 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
267 void __init check_bugs32(void)
273 * Probe whether cpu has config register by trying to play with
274 * alternate cache bit and see whether it matters.
275 * It's used by cpu_probe to distinguish between R3000A and R3081.
277 static inline int cpu_has_confreg(void)
279 #ifdef CONFIG_CPU_R3000
280 extern unsigned long r3k_cache_size(unsigned long);
281 unsigned long size1, size2;
282 unsigned long cfg = read_c0_conf();
284 size1 = r3k_cache_size(ST0_ISC);
285 write_c0_conf(cfg ^ R30XX_CONF_AC);
286 size2 = r3k_cache_size(ST0_ISC);
288 return size1 != size2;
294 static inline void set_elf_platform(int cpu, const char *plat)
297 __elf_platform = plat;
301 * Get the FPU Implementation/Revision.
303 static inline unsigned long cpu_get_fpu_id(void)
305 unsigned long tmp, fpu_id;
307 tmp = read_c0_status();
309 fpu_id = read_32bit_cp1_register(CP1_REVISION);
310 write_c0_status(tmp);
315 * Check the CPU has an FPU the official way.
317 static inline int __cpu_has_fpu(void)
319 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
322 static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
324 #ifdef __NEED_VMBITS_PROBE
325 write_c0_entryhi(0x3fffffffffffe000ULL);
326 back_to_back_c0_hazard();
327 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
331 #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
334 static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
336 switch (c->processor_id & 0xff00) {
338 c->cputype = CPU_R2000;
339 __cpu_name[cpu] = "R2000";
340 c->isa_level = MIPS_CPU_ISA_I;
341 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
344 c->options |= MIPS_CPU_FPU;
348 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
349 if (cpu_has_confreg()) {
350 c->cputype = CPU_R3081E;
351 __cpu_name[cpu] = "R3081";
353 c->cputype = CPU_R3000A;
354 __cpu_name[cpu] = "R3000A";
358 c->cputype = CPU_R3000;
359 __cpu_name[cpu] = "R3000";
361 c->isa_level = MIPS_CPU_ISA_I;
362 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
365 c->options |= MIPS_CPU_FPU;
369 if (read_c0_config() & CONF_SC) {
370 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
371 c->cputype = CPU_R4400PC;
372 __cpu_name[cpu] = "R4400PC";
374 c->cputype = CPU_R4000PC;
375 __cpu_name[cpu] = "R4000PC";
378 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
379 c->cputype = CPU_R4400SC;
380 __cpu_name[cpu] = "R4400SC";
382 c->cputype = CPU_R4000SC;
383 __cpu_name[cpu] = "R4000SC";
387 c->isa_level = MIPS_CPU_ISA_III;
388 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
389 MIPS_CPU_WATCH | MIPS_CPU_VCE |
393 case PRID_IMP_VR41XX:
394 switch (c->processor_id & 0xf0) {
395 case PRID_REV_VR4111:
396 c->cputype = CPU_VR4111;
397 __cpu_name[cpu] = "NEC VR4111";
399 case PRID_REV_VR4121:
400 c->cputype = CPU_VR4121;
401 __cpu_name[cpu] = "NEC VR4121";
403 case PRID_REV_VR4122:
404 if ((c->processor_id & 0xf) < 0x3) {
405 c->cputype = CPU_VR4122;
406 __cpu_name[cpu] = "NEC VR4122";
408 c->cputype = CPU_VR4181A;
409 __cpu_name[cpu] = "NEC VR4181A";
412 case PRID_REV_VR4130:
413 if ((c->processor_id & 0xf) < 0x4) {
414 c->cputype = CPU_VR4131;
415 __cpu_name[cpu] = "NEC VR4131";
417 c->cputype = CPU_VR4133;
418 __cpu_name[cpu] = "NEC VR4133";
422 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
423 c->cputype = CPU_VR41XX;
424 __cpu_name[cpu] = "NEC Vr41xx";
427 c->isa_level = MIPS_CPU_ISA_III;
428 c->options = R4K_OPTS;
432 c->cputype = CPU_R4300;
433 __cpu_name[cpu] = "R4300";
434 c->isa_level = MIPS_CPU_ISA_III;
435 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
440 c->cputype = CPU_R4600;
441 __cpu_name[cpu] = "R4600";
442 c->isa_level = MIPS_CPU_ISA_III;
443 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
450 * This processor doesn't have an MMU, so it's not
451 * "real easy" to run Linux on it. It is left purely
452 * for documentation. Commented out because it shares
453 * it's c0_prid id number with the TX3900.
455 c->cputype = CPU_R4650;
456 __cpu_name[cpu] = "R4650";
457 c->isa_level = MIPS_CPU_ISA_III;
458 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
463 c->isa_level = MIPS_CPU_ISA_I;
464 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
466 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
467 c->cputype = CPU_TX3927;
468 __cpu_name[cpu] = "TX3927";
471 switch (c->processor_id & 0xff) {
472 case PRID_REV_TX3912:
473 c->cputype = CPU_TX3912;
474 __cpu_name[cpu] = "TX3912";
477 case PRID_REV_TX3922:
478 c->cputype = CPU_TX3922;
479 __cpu_name[cpu] = "TX3922";
486 c->cputype = CPU_R4700;
487 __cpu_name[cpu] = "R4700";
488 c->isa_level = MIPS_CPU_ISA_III;
489 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
494 c->cputype = CPU_TX49XX;
495 __cpu_name[cpu] = "R49XX";
496 c->isa_level = MIPS_CPU_ISA_III;
497 c->options = R4K_OPTS | MIPS_CPU_LLSC;
498 if (!(c->processor_id & 0x08))
499 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
503 c->cputype = CPU_R5000;
504 __cpu_name[cpu] = "R5000";
505 c->isa_level = MIPS_CPU_ISA_IV;
506 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
511 c->cputype = CPU_R5432;
512 __cpu_name[cpu] = "R5432";
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;
519 c->cputype = CPU_R5500;
520 __cpu_name[cpu] = "R5500";
521 c->isa_level = MIPS_CPU_ISA_IV;
522 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
523 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
526 case PRID_IMP_NEVADA:
527 c->cputype = CPU_NEVADA;
528 __cpu_name[cpu] = "Nevada";
529 c->isa_level = MIPS_CPU_ISA_IV;
530 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
531 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
535 c->cputype = CPU_R6000;
536 __cpu_name[cpu] = "R6000";
537 c->isa_level = MIPS_CPU_ISA_II;
538 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
542 case PRID_IMP_R6000A:
543 c->cputype = CPU_R6000A;
544 __cpu_name[cpu] = "R6000A";
545 c->isa_level = MIPS_CPU_ISA_II;
546 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
550 case PRID_IMP_RM7000:
551 c->cputype = CPU_RM7000;
552 __cpu_name[cpu] = "RM7000";
553 c->isa_level = MIPS_CPU_ISA_IV;
554 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
557 * Undocumented RM7000: Bit 29 in the info register of
558 * the RM7000 v2.0 indicates if the TLB has 48 or 64
561 * 29 1 => 64 entry JTLB
564 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
566 case PRID_IMP_RM9000:
567 c->cputype = CPU_RM9000;
568 __cpu_name[cpu] = "RM9000";
569 c->isa_level = MIPS_CPU_ISA_IV;
570 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
573 * Bit 29 in the info register of the RM9000
574 * indicates if the TLB has 48 or 64 entries.
576 * 29 1 => 64 entry JTLB
579 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
582 c->cputype = CPU_R8000;
583 __cpu_name[cpu] = "RM8000";
584 c->isa_level = MIPS_CPU_ISA_IV;
585 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
586 MIPS_CPU_FPU | MIPS_CPU_32FPR |
588 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
590 case PRID_IMP_R10000:
591 c->cputype = CPU_R10000;
592 __cpu_name[cpu] = "R10000";
593 c->isa_level = MIPS_CPU_ISA_IV;
594 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
595 MIPS_CPU_FPU | MIPS_CPU_32FPR |
596 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
600 case PRID_IMP_R12000:
601 c->cputype = CPU_R12000;
602 __cpu_name[cpu] = "R12000";
603 c->isa_level = MIPS_CPU_ISA_IV;
604 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
605 MIPS_CPU_FPU | MIPS_CPU_32FPR |
606 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
610 case PRID_IMP_R14000:
611 c->cputype = CPU_R14000;
612 __cpu_name[cpu] = "R14000";
613 c->isa_level = MIPS_CPU_ISA_IV;
614 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
615 MIPS_CPU_FPU | MIPS_CPU_32FPR |
616 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
620 case PRID_IMP_LOONGSON2:
621 c->cputype = CPU_LOONGSON2;
622 __cpu_name[cpu] = "ICT Loongson-2";
623 c->isa_level = MIPS_CPU_ISA_III;
624 c->options = R4K_OPTS |
625 MIPS_CPU_FPU | MIPS_CPU_LLSC |
632 static char unknown_isa[] __cpuinitdata = KERN_ERR \
633 "Unsupported ISA type, c0.config0: %d.";
635 static inline unsigned int decode_config0(struct cpuinfo_mips *c)
637 unsigned int config0;
640 config0 = read_c0_config();
642 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
643 c->options |= MIPS_CPU_TLB;
644 isa = (config0 & MIPS_CONF_AT) >> 13;
647 switch ((config0 & MIPS_CONF_AR) >> 10) {
649 c->isa_level = MIPS_CPU_ISA_M32R1;
652 c->isa_level = MIPS_CPU_ISA_M32R2;
659 switch ((config0 & MIPS_CONF_AR) >> 10) {
661 c->isa_level = MIPS_CPU_ISA_M64R1;
664 c->isa_level = MIPS_CPU_ISA_M64R2;
674 return config0 & MIPS_CONF_M;
677 panic(unknown_isa, config0);
680 static inline unsigned int decode_config1(struct cpuinfo_mips *c)
682 unsigned int config1;
684 config1 = read_c0_config1();
686 if (config1 & MIPS_CONF1_MD)
687 c->ases |= MIPS_ASE_MDMX;
688 if (config1 & MIPS_CONF1_WR)
689 c->options |= MIPS_CPU_WATCH;
690 if (config1 & MIPS_CONF1_CA)
691 c->ases |= MIPS_ASE_MIPS16;
692 if (config1 & MIPS_CONF1_EP)
693 c->options |= MIPS_CPU_EJTAG;
694 if (config1 & MIPS_CONF1_FP) {
695 c->options |= MIPS_CPU_FPU;
696 c->options |= MIPS_CPU_32FPR;
699 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
701 return config1 & MIPS_CONF_M;
704 static inline unsigned int decode_config2(struct cpuinfo_mips *c)
706 unsigned int config2;
708 config2 = read_c0_config2();
710 if (config2 & MIPS_CONF2_SL)
711 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
713 return config2 & MIPS_CONF_M;
716 static inline unsigned int decode_config3(struct cpuinfo_mips *c)
718 unsigned int config3;
720 config3 = read_c0_config3();
722 if (config3 & MIPS_CONF3_SM)
723 c->ases |= MIPS_ASE_SMARTMIPS;
724 if (config3 & MIPS_CONF3_DSP)
725 c->ases |= MIPS_ASE_DSP;
726 if (config3 & MIPS_CONF3_VINT)
727 c->options |= MIPS_CPU_VINT;
728 if (config3 & MIPS_CONF3_VEIC)
729 c->options |= MIPS_CPU_VEIC;
730 if (config3 & MIPS_CONF3_MT)
731 c->ases |= MIPS_ASE_MIPSMT;
732 if (config3 & MIPS_CONF3_ULRI)
733 c->options |= MIPS_CPU_ULRI;
735 return config3 & MIPS_CONF_M;
738 static inline unsigned int decode_config4(struct cpuinfo_mips *c)
740 unsigned int config4;
742 config4 = read_c0_config4();
744 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
746 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
748 c->kscratch_mask = (config4 >> 16) & 0xff;
750 return config4 & MIPS_CONF_M;
753 static void __cpuinit decode_configs(struct cpuinfo_mips *c)
757 /* MIPS32 or MIPS64 compliant CPU. */
758 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
759 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
761 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
763 ok = decode_config0(c); /* Read Config registers. */
764 BUG_ON(!ok); /* Arch spec violation! */
766 ok = decode_config1(c);
768 ok = decode_config2(c);
770 ok = decode_config3(c);
772 ok = decode_config4(c);
774 mips_probe_watch_registers(c);
777 c->core = read_c0_ebase() & 0x3ff;
780 static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
783 switch (c->processor_id & 0xff00) {
785 c->cputype = CPU_4KC;
786 __cpu_name[cpu] = "MIPS 4Kc";
789 case PRID_IMP_4KECR2:
790 c->cputype = CPU_4KEC;
791 __cpu_name[cpu] = "MIPS 4KEc";
795 c->cputype = CPU_4KSC;
796 __cpu_name[cpu] = "MIPS 4KSc";
799 c->cputype = CPU_5KC;
800 __cpu_name[cpu] = "MIPS 5Kc";
803 c->cputype = CPU_20KC;
804 __cpu_name[cpu] = "MIPS 20Kc";
808 c->cputype = CPU_24K;
809 __cpu_name[cpu] = "MIPS 24Kc";
812 c->cputype = CPU_25KF;
813 __cpu_name[cpu] = "MIPS 25Kc";
816 c->cputype = CPU_34K;
817 __cpu_name[cpu] = "MIPS 34Kc";
820 c->cputype = CPU_74K;
821 __cpu_name[cpu] = "MIPS 74Kc";
824 c->cputype = CPU_1004K;
825 __cpu_name[cpu] = "MIPS 1004Kc";
832 static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
835 switch (c->processor_id & 0xff00) {
836 case PRID_IMP_AU1_REV1:
837 case PRID_IMP_AU1_REV2:
838 c->cputype = CPU_ALCHEMY;
839 switch ((c->processor_id >> 24) & 0xff) {
841 __cpu_name[cpu] = "Au1000";
844 __cpu_name[cpu] = "Au1500";
847 __cpu_name[cpu] = "Au1100";
850 __cpu_name[cpu] = "Au1550";
853 __cpu_name[cpu] = "Au1200";
854 if ((c->processor_id & 0xff) == 2)
855 __cpu_name[cpu] = "Au1250";
858 __cpu_name[cpu] = "Au1210";
861 __cpu_name[cpu] = "Au1xxx";
868 static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
872 switch (c->processor_id & 0xff00) {
874 c->cputype = CPU_SB1;
875 __cpu_name[cpu] = "SiByte SB1";
876 /* FPU in pass1 is known to have issues. */
877 if ((c->processor_id & 0xff) < 0x02)
878 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
881 c->cputype = CPU_SB1A;
882 __cpu_name[cpu] = "SiByte SB1A";
887 static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
890 switch (c->processor_id & 0xff00) {
891 case PRID_IMP_SR71000:
892 c->cputype = CPU_SR71000;
893 __cpu_name[cpu] = "Sandcraft SR71000";
900 static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
903 switch (c->processor_id & 0xff00) {
904 case PRID_IMP_PR4450:
905 c->cputype = CPU_PR4450;
906 __cpu_name[cpu] = "Philips PR4450";
907 c->isa_level = MIPS_CPU_ISA_M32R1;
912 static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
915 switch (c->processor_id & 0xff00) {
916 case PRID_IMP_BMIPS32_REV4:
917 case PRID_IMP_BMIPS32_REV8:
918 c->cputype = CPU_BMIPS32;
919 __cpu_name[cpu] = "Broadcom BMIPS32";
920 set_elf_platform(cpu, "bmips32");
922 case PRID_IMP_BMIPS3300:
923 case PRID_IMP_BMIPS3300_ALT:
924 case PRID_IMP_BMIPS3300_BUG:
925 c->cputype = CPU_BMIPS3300;
926 __cpu_name[cpu] = "Broadcom BMIPS3300";
927 set_elf_platform(cpu, "bmips3300");
929 case PRID_IMP_BMIPS43XX: {
930 int rev = c->processor_id & 0xff;
932 if (rev >= PRID_REV_BMIPS4380_LO &&
933 rev <= PRID_REV_BMIPS4380_HI) {
934 c->cputype = CPU_BMIPS4380;
935 __cpu_name[cpu] = "Broadcom BMIPS4380";
936 set_elf_platform(cpu, "bmips4380");
938 c->cputype = CPU_BMIPS4350;
939 __cpu_name[cpu] = "Broadcom BMIPS4350";
940 set_elf_platform(cpu, "bmips4350");
944 case PRID_IMP_BMIPS5000:
945 c->cputype = CPU_BMIPS5000;
946 __cpu_name[cpu] = "Broadcom BMIPS5000";
947 set_elf_platform(cpu, "bmips5000");
948 c->options |= MIPS_CPU_ULRI;
953 static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
956 switch (c->processor_id & 0xff00) {
957 case PRID_IMP_CAVIUM_CN38XX:
958 case PRID_IMP_CAVIUM_CN31XX:
959 case PRID_IMP_CAVIUM_CN30XX:
960 c->cputype = CPU_CAVIUM_OCTEON;
961 __cpu_name[cpu] = "Cavium Octeon";
963 case PRID_IMP_CAVIUM_CN58XX:
964 case PRID_IMP_CAVIUM_CN56XX:
965 case PRID_IMP_CAVIUM_CN50XX:
966 case PRID_IMP_CAVIUM_CN52XX:
967 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
968 __cpu_name[cpu] = "Cavium Octeon+";
970 set_elf_platform(cpu, "octeon");
972 case PRID_IMP_CAVIUM_CN63XX:
973 c->cputype = CPU_CAVIUM_OCTEON2;
974 __cpu_name[cpu] = "Cavium Octeon II";
975 set_elf_platform(cpu, "octeon2");
978 printk(KERN_INFO "Unknown Octeon chip!\n");
979 c->cputype = CPU_UNKNOWN;
984 static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
987 /* JZRISC does not implement the CP0 counter. */
988 c->options &= ~MIPS_CPU_COUNTER;
989 switch (c->processor_id & 0xff00) {
990 case PRID_IMP_JZRISC:
991 c->cputype = CPU_JZRISC;
992 __cpu_name[cpu] = "Ingenic JZRISC";
995 panic("Unknown Ingenic Processor ID!");
1000 static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1004 c->options = (MIPS_CPU_TLB |
1012 switch (c->processor_id & 0xff00) {
1013 case PRID_IMP_NETLOGIC_XLR732:
1014 case PRID_IMP_NETLOGIC_XLR716:
1015 case PRID_IMP_NETLOGIC_XLR532:
1016 case PRID_IMP_NETLOGIC_XLR308:
1017 case PRID_IMP_NETLOGIC_XLR532C:
1018 case PRID_IMP_NETLOGIC_XLR516C:
1019 case PRID_IMP_NETLOGIC_XLR508C:
1020 case PRID_IMP_NETLOGIC_XLR308C:
1021 c->cputype = CPU_XLR;
1022 __cpu_name[cpu] = "Netlogic XLR";
1025 case PRID_IMP_NETLOGIC_XLS608:
1026 case PRID_IMP_NETLOGIC_XLS408:
1027 case PRID_IMP_NETLOGIC_XLS404:
1028 case PRID_IMP_NETLOGIC_XLS208:
1029 case PRID_IMP_NETLOGIC_XLS204:
1030 case PRID_IMP_NETLOGIC_XLS108:
1031 case PRID_IMP_NETLOGIC_XLS104:
1032 case PRID_IMP_NETLOGIC_XLS616B:
1033 case PRID_IMP_NETLOGIC_XLS608B:
1034 case PRID_IMP_NETLOGIC_XLS416B:
1035 case PRID_IMP_NETLOGIC_XLS412B:
1036 case PRID_IMP_NETLOGIC_XLS408B:
1037 case PRID_IMP_NETLOGIC_XLS404B:
1038 c->cputype = CPU_XLR;
1039 __cpu_name[cpu] = "Netlogic XLS";
1043 printk(KERN_INFO "Unknown Netlogic chip id [%02x]!\n",
1045 c->cputype = CPU_XLR;
1049 c->isa_level = MIPS_CPU_ISA_M64R1;
1050 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1054 /* For use by uaccess.h */
1056 EXPORT_SYMBOL(__ua_limit);
1059 const char *__cpu_name[NR_CPUS];
1060 const char *__elf_platform;
1062 __cpuinit void cpu_probe(void)
1064 struct cpuinfo_mips *c = ¤t_cpu_data;
1065 unsigned int cpu = smp_processor_id();
1067 c->processor_id = PRID_IMP_UNKNOWN;
1068 c->fpu_id = FPIR_IMP_NONE;
1069 c->cputype = CPU_UNKNOWN;
1071 c->processor_id = read_c0_prid();
1072 switch (c->processor_id & 0xff0000) {
1073 case PRID_COMP_LEGACY:
1074 cpu_probe_legacy(c, cpu);
1076 case PRID_COMP_MIPS:
1077 cpu_probe_mips(c, cpu);
1079 case PRID_COMP_ALCHEMY:
1080 cpu_probe_alchemy(c, cpu);
1082 case PRID_COMP_SIBYTE:
1083 cpu_probe_sibyte(c, cpu);
1085 case PRID_COMP_BROADCOM:
1086 cpu_probe_broadcom(c, cpu);
1088 case PRID_COMP_SANDCRAFT:
1089 cpu_probe_sandcraft(c, cpu);
1092 cpu_probe_nxp(c, cpu);
1094 case PRID_COMP_CAVIUM:
1095 cpu_probe_cavium(c, cpu);
1097 case PRID_COMP_INGENIC:
1098 cpu_probe_ingenic(c, cpu);
1100 case PRID_COMP_NETLOGIC:
1101 cpu_probe_netlogic(c, cpu);
1105 BUG_ON(!__cpu_name[cpu]);
1106 BUG_ON(c->cputype == CPU_UNKNOWN);
1109 * Platform code can force the cpu type to optimize code
1110 * generation. In that case be sure the cpu type is correctly
1111 * manually setup otherwise it could trigger some nasty bugs.
1113 BUG_ON(current_cpu_type() != c->cputype);
1115 if (mips_fpu_disabled)
1116 c->options &= ~MIPS_CPU_FPU;
1118 if (mips_dsp_disabled)
1119 c->ases &= ~MIPS_ASE_DSP;
1121 if (c->options & MIPS_CPU_FPU) {
1122 c->fpu_id = cpu_get_fpu_id();
1124 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
1125 c->isa_level == MIPS_CPU_ISA_M32R2 ||
1126 c->isa_level == MIPS_CPU_ISA_M64R1 ||
1127 c->isa_level == MIPS_CPU_ISA_M64R2) {
1128 if (c->fpu_id & MIPS_FPIR_3D)
1129 c->ases |= MIPS_ASE_MIPS3D;
1133 if (cpu_has_mips_r2)
1134 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1138 cpu_probe_vmbits(c);
1142 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1146 __cpuinit void cpu_report(void)
1148 struct cpuinfo_mips *c = ¤t_cpu_data;
1150 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1151 c->processor_id, cpu_name_string());
1152 if (c->options & MIPS_CPU_FPU)
1153 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);