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, 2011, 2012 MIPS Technologies, 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/export.h>
23 #include <asm/cpu-type.h>
25 #include <asm/mipsregs.h>
26 #include <asm/mipsmtregs.h>
28 #include <asm/watch.h>
30 #include <asm/pgtable-bits.h>
31 #include <asm/spram.h>
32 #include <asm/uaccess.h>
34 static int mips_fpu_disabled;
36 static int __init fpu_disable(char *s)
38 cpu_data[0].options &= ~MIPS_CPU_FPU;
39 mips_fpu_disabled = 1;
44 __setup("nofpu", fpu_disable);
46 int mips_dsp_disabled;
48 static int __init dsp_disable(char *s)
50 cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
51 mips_dsp_disabled = 1;
56 __setup("nodsp", dsp_disable);
58 static int mips_htw_disabled;
60 static int __init htw_disable(char *s)
62 mips_htw_disabled = 1;
63 cpu_data[0].options &= ~MIPS_CPU_HTW;
64 write_c0_pwctl(read_c0_pwctl() &
65 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
70 __setup("nohtw", htw_disable);
72 static int mips_ftlb_disabled;
73 static int mips_has_ftlb_configured;
75 static void set_ftlb_enable(struct cpuinfo_mips *c, int enable);
77 static int __init ftlb_disable(char *s)
79 unsigned int config4, mmuextdef;
82 * If the core hasn't done any FTLB configuration, there is nothing
85 if (!mips_has_ftlb_configured)
88 /* Disable it in the boot cpu */
89 set_ftlb_enable(&cpu_data[0], 0);
91 back_to_back_c0_hazard();
93 config4 = read_c0_config4();
95 /* Check that FTLB has been disabled */
96 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
97 /* MMUSIZEEXT == VTLB ON, FTLB OFF */
98 if (mmuextdef == MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT) {
99 /* This should never happen */
100 pr_warn("FTLB could not be disabled!\n");
104 mips_ftlb_disabled = 1;
105 mips_has_ftlb_configured = 0;
108 * noftlb is mainly used for debug purposes so print
109 * an informative message instead of using pr_debug()
111 pr_info("FTLB has been disabled\n");
114 * Some of these bits are duplicated in the decode_config4.
115 * MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT is the only possible case
116 * once FTLB has been disabled so undo what decode_config4 did.
118 cpu_data[0].tlbsize -= cpu_data[0].tlbsizeftlbways *
119 cpu_data[0].tlbsizeftlbsets;
120 cpu_data[0].tlbsizeftlbsets = 0;
121 cpu_data[0].tlbsizeftlbways = 0;
126 __setup("noftlb", ftlb_disable);
129 static inline void check_errata(void)
131 struct cpuinfo_mips *c = ¤t_cpu_data;
133 switch (current_cpu_type()) {
136 * Erratum "RPS May Cause Incorrect Instruction Execution"
137 * This code only handles VPE0, any SMP/RTOS code
138 * making use of VPE1 will be responsable for that VPE.
140 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
141 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
148 void __init check_bugs32(void)
154 * Probe whether cpu has config register by trying to play with
155 * alternate cache bit and see whether it matters.
156 * It's used by cpu_probe to distinguish between R3000A and R3081.
158 static inline int cpu_has_confreg(void)
160 #ifdef CONFIG_CPU_R3000
161 extern unsigned long r3k_cache_size(unsigned long);
162 unsigned long size1, size2;
163 unsigned long cfg = read_c0_conf();
165 size1 = r3k_cache_size(ST0_ISC);
166 write_c0_conf(cfg ^ R30XX_CONF_AC);
167 size2 = r3k_cache_size(ST0_ISC);
169 return size1 != size2;
175 static inline void set_elf_platform(int cpu, const char *plat)
178 __elf_platform = plat;
182 * Get the FPU Implementation/Revision.
184 static inline unsigned long cpu_get_fpu_id(void)
186 unsigned long tmp, fpu_id;
188 tmp = read_c0_status();
189 __enable_fpu(FPU_AS_IS);
190 fpu_id = read_32bit_cp1_register(CP1_REVISION);
191 write_c0_status(tmp);
196 * Check the CPU has an FPU the official way.
198 static inline int __cpu_has_fpu(void)
200 return (cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE;
203 static inline unsigned long cpu_get_msa_id(void)
205 unsigned long status, msa_id;
207 status = read_c0_status();
208 __enable_fpu(FPU_64BIT);
210 msa_id = read_msa_ir();
212 write_c0_status(status);
216 static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
218 #ifdef __NEED_VMBITS_PROBE
219 write_c0_entryhi(0x3fffffffffffe000ULL);
220 back_to_back_c0_hazard();
221 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
225 static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
228 case MIPS_CPU_ISA_M64R2:
229 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
230 case MIPS_CPU_ISA_M64R1:
231 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
233 c->isa_level |= MIPS_CPU_ISA_V;
234 case MIPS_CPU_ISA_IV:
235 c->isa_level |= MIPS_CPU_ISA_IV;
236 case MIPS_CPU_ISA_III:
237 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
240 /* R6 incompatible with everything else */
241 case MIPS_CPU_ISA_M64R6:
242 c->isa_level |= MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6;
243 case MIPS_CPU_ISA_M32R6:
244 c->isa_level |= MIPS_CPU_ISA_M32R6;
245 /* Break here so we don't add incompatible ISAs */
247 case MIPS_CPU_ISA_M32R2:
248 c->isa_level |= MIPS_CPU_ISA_M32R2;
249 case MIPS_CPU_ISA_M32R1:
250 c->isa_level |= MIPS_CPU_ISA_M32R1;
251 case MIPS_CPU_ISA_II:
252 c->isa_level |= MIPS_CPU_ISA_II;
257 static char unknown_isa[] = KERN_ERR \
258 "Unsupported ISA type, c0.config0: %d.";
260 static unsigned int calculate_ftlb_probability(struct cpuinfo_mips *c)
263 unsigned int probability = c->tlbsize / c->tlbsizevtlb;
266 * 0 = All TLBWR instructions go to FTLB
267 * 1 = 15:1: For every 16 TBLWR instructions, 15 go to the
268 * FTLB and 1 goes to the VTLB.
269 * 2 = 7:1: As above with 7:1 ratio.
270 * 3 = 3:1: As above with 3:1 ratio.
272 * Use the linear midpoint as the probability threshold.
274 if (probability >= 12)
276 else if (probability >= 6)
280 * So FTLB is less than 4 times bigger than VTLB.
281 * A 3:1 ratio can still be useful though.
286 static void set_ftlb_enable(struct cpuinfo_mips *c, int enable)
288 unsigned int config6;
290 /* It's implementation dependent how the FTLB can be enabled */
291 switch (c->cputype) {
294 /* proAptiv & related cores use Config6 to enable the FTLB */
295 config6 = read_c0_config6();
296 /* Clear the old probability value */
297 config6 &= ~(3 << MIPS_CONF6_FTLBP_SHIFT);
300 write_c0_config6(config6 |
301 (calculate_ftlb_probability(c)
302 << MIPS_CONF6_FTLBP_SHIFT)
303 | MIPS_CONF6_FTLBEN);
306 write_c0_config6(config6 & ~MIPS_CONF6_FTLBEN);
307 back_to_back_c0_hazard();
312 static inline unsigned int decode_config0(struct cpuinfo_mips *c)
314 unsigned int config0;
317 config0 = read_c0_config();
320 * Look for Standard TLB or Dual VTLB and FTLB
322 if ((((config0 & MIPS_CONF_MT) >> 7) == 1) ||
323 (((config0 & MIPS_CONF_MT) >> 7) == 4))
324 c->options |= MIPS_CPU_TLB;
326 isa = (config0 & MIPS_CONF_AT) >> 13;
329 switch ((config0 & MIPS_CONF_AR) >> 10) {
331 set_isa(c, MIPS_CPU_ISA_M32R1);
334 set_isa(c, MIPS_CPU_ISA_M32R2);
337 set_isa(c, MIPS_CPU_ISA_M32R6);
344 switch ((config0 & MIPS_CONF_AR) >> 10) {
346 set_isa(c, MIPS_CPU_ISA_M64R1);
349 set_isa(c, MIPS_CPU_ISA_M64R2);
352 set_isa(c, MIPS_CPU_ISA_M64R6);
362 return config0 & MIPS_CONF_M;
365 panic(unknown_isa, config0);
368 static inline unsigned int decode_config1(struct cpuinfo_mips *c)
370 unsigned int config1;
372 config1 = read_c0_config1();
374 if (config1 & MIPS_CONF1_MD)
375 c->ases |= MIPS_ASE_MDMX;
376 if (config1 & MIPS_CONF1_WR)
377 c->options |= MIPS_CPU_WATCH;
378 if (config1 & MIPS_CONF1_CA)
379 c->ases |= MIPS_ASE_MIPS16;
380 if (config1 & MIPS_CONF1_EP)
381 c->options |= MIPS_CPU_EJTAG;
382 if (config1 & MIPS_CONF1_FP) {
383 c->options |= MIPS_CPU_FPU;
384 c->options |= MIPS_CPU_32FPR;
387 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
388 c->tlbsizevtlb = c->tlbsize;
389 c->tlbsizeftlbsets = 0;
392 return config1 & MIPS_CONF_M;
395 static inline unsigned int decode_config2(struct cpuinfo_mips *c)
397 unsigned int config2;
399 config2 = read_c0_config2();
401 if (config2 & MIPS_CONF2_SL)
402 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
404 return config2 & MIPS_CONF_M;
407 static inline unsigned int decode_config3(struct cpuinfo_mips *c)
409 unsigned int config3;
411 config3 = read_c0_config3();
413 if (config3 & MIPS_CONF3_SM) {
414 c->ases |= MIPS_ASE_SMARTMIPS;
415 c->options |= MIPS_CPU_RIXI;
417 if (config3 & MIPS_CONF3_RXI)
418 c->options |= MIPS_CPU_RIXI;
419 if (config3 & MIPS_CONF3_DSP)
420 c->ases |= MIPS_ASE_DSP;
421 if (config3 & MIPS_CONF3_DSP2P)
422 c->ases |= MIPS_ASE_DSP2P;
423 if (config3 & MIPS_CONF3_VINT)
424 c->options |= MIPS_CPU_VINT;
425 if (config3 & MIPS_CONF3_VEIC)
426 c->options |= MIPS_CPU_VEIC;
427 if (config3 & MIPS_CONF3_MT)
428 c->ases |= MIPS_ASE_MIPSMT;
429 if (config3 & MIPS_CONF3_ULRI)
430 c->options |= MIPS_CPU_ULRI;
431 if (config3 & MIPS_CONF3_ISA)
432 c->options |= MIPS_CPU_MICROMIPS;
433 if (config3 & MIPS_CONF3_VZ)
434 c->ases |= MIPS_ASE_VZ;
435 if (config3 & MIPS_CONF3_SC)
436 c->options |= MIPS_CPU_SEGMENTS;
437 if (config3 & MIPS_CONF3_MSA)
438 c->ases |= MIPS_ASE_MSA;
439 /* Only tested on 32-bit cores */
440 if ((config3 & MIPS_CONF3_PW) && config_enabled(CONFIG_32BIT)) {
442 c->options |= MIPS_CPU_HTW;
445 return config3 & MIPS_CONF_M;
448 static inline unsigned int decode_config4(struct cpuinfo_mips *c)
450 unsigned int config4;
452 unsigned int mmuextdef;
453 unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE;
455 config4 = read_c0_config4();
458 if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
459 c->options |= MIPS_CPU_TLBINV;
460 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
462 case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:
463 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
464 c->tlbsizevtlb = c->tlbsize;
466 case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT:
468 ((config4 & MIPS_CONF4_VTLBSIZEEXT) >>
469 MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40;
470 c->tlbsize = c->tlbsizevtlb;
471 ftlb_page = MIPS_CONF4_VFTLBPAGESIZE;
473 case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT:
474 if (mips_ftlb_disabled)
476 newcf4 = (config4 & ~ftlb_page) |
477 (page_size_ftlb(mmuextdef) <<
478 MIPS_CONF4_FTLBPAGESIZE_SHIFT);
479 write_c0_config4(newcf4);
480 back_to_back_c0_hazard();
481 config4 = read_c0_config4();
482 if (config4 != newcf4) {
483 pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
485 /* Switch FTLB off */
486 set_ftlb_enable(c, 0);
489 c->tlbsizeftlbsets = 1 <<
490 ((config4 & MIPS_CONF4_FTLBSETS) >>
491 MIPS_CONF4_FTLBSETS_SHIFT);
492 c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >>
493 MIPS_CONF4_FTLBWAYS_SHIFT) + 2;
494 c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets;
495 mips_has_ftlb_configured = 1;
500 c->kscratch_mask = (config4 >> 16) & 0xff;
502 return config4 & MIPS_CONF_M;
505 static inline unsigned int decode_config5(struct cpuinfo_mips *c)
507 unsigned int config5;
509 config5 = read_c0_config5();
510 config5 &= ~(MIPS_CONF5_UFR | MIPS_CONF5_UFE);
511 write_c0_config5(config5);
513 if (config5 & MIPS_CONF5_EVA)
514 c->options |= MIPS_CPU_EVA;
515 if (config5 & MIPS_CONF5_MRP)
516 c->options |= MIPS_CPU_MAAR;
517 if (config5 & MIPS_CONF5_LLB)
518 c->options |= MIPS_CPU_RW_LLB;
520 if (config5 & MIPS_CONF5_MVH)
521 c->options |= MIPS_CPU_XPA;
524 return config5 & MIPS_CONF_M;
527 static void decode_configs(struct cpuinfo_mips *c)
531 /* MIPS32 or MIPS64 compliant CPU. */
532 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
533 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
535 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
537 /* Enable FTLB if present and not disabled */
538 set_ftlb_enable(c, !mips_ftlb_disabled);
540 ok = decode_config0(c); /* Read Config registers. */
541 BUG_ON(!ok); /* Arch spec violation! */
543 ok = decode_config1(c);
545 ok = decode_config2(c);
547 ok = decode_config3(c);
549 ok = decode_config4(c);
551 ok = decode_config5(c);
553 mips_probe_watch_registers(c);
556 /* Enable the RIXI exceptions */
557 set_c0_pagegrain(PG_IEC);
558 back_to_back_c0_hazard();
559 /* Verify the IEC bit is set */
560 if (read_c0_pagegrain() & PG_IEC)
561 c->options |= MIPS_CPU_RIXIEX;
564 #ifndef CONFIG_MIPS_CPS
565 if (cpu_has_mips_r2_r6) {
566 c->core = get_ebase_cpunum();
568 c->core >>= fls(core_nvpes()) - 1;
573 #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
576 static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
578 switch (c->processor_id & PRID_IMP_MASK) {
580 c->cputype = CPU_R2000;
581 __cpu_name[cpu] = "R2000";
582 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
585 c->options |= MIPS_CPU_FPU;
589 if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
590 if (cpu_has_confreg()) {
591 c->cputype = CPU_R3081E;
592 __cpu_name[cpu] = "R3081";
594 c->cputype = CPU_R3000A;
595 __cpu_name[cpu] = "R3000A";
598 c->cputype = CPU_R3000;
599 __cpu_name[cpu] = "R3000";
601 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
604 c->options |= MIPS_CPU_FPU;
608 if (read_c0_config() & CONF_SC) {
609 if ((c->processor_id & PRID_REV_MASK) >=
611 c->cputype = CPU_R4400PC;
612 __cpu_name[cpu] = "R4400PC";
614 c->cputype = CPU_R4000PC;
615 __cpu_name[cpu] = "R4000PC";
618 int cca = read_c0_config() & CONF_CM_CMASK;
622 * SC and MC versions can't be reliably told apart,
623 * but only the latter support coherent caching
624 * modes so assume the firmware has set the KSEG0
625 * coherency attribute reasonably (if uncached, we
629 case CONF_CM_CACHABLE_CE:
630 case CONF_CM_CACHABLE_COW:
631 case CONF_CM_CACHABLE_CUW:
638 if ((c->processor_id & PRID_REV_MASK) >=
640 c->cputype = mc ? CPU_R4400MC : CPU_R4400SC;
641 __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC";
643 c->cputype = mc ? CPU_R4000MC : CPU_R4000SC;
644 __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC";
648 set_isa(c, MIPS_CPU_ISA_III);
649 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
650 MIPS_CPU_WATCH | MIPS_CPU_VCE |
654 case PRID_IMP_VR41XX:
655 set_isa(c, MIPS_CPU_ISA_III);
656 c->options = R4K_OPTS;
658 switch (c->processor_id & 0xf0) {
659 case PRID_REV_VR4111:
660 c->cputype = CPU_VR4111;
661 __cpu_name[cpu] = "NEC VR4111";
663 case PRID_REV_VR4121:
664 c->cputype = CPU_VR4121;
665 __cpu_name[cpu] = "NEC VR4121";
667 case PRID_REV_VR4122:
668 if ((c->processor_id & 0xf) < 0x3) {
669 c->cputype = CPU_VR4122;
670 __cpu_name[cpu] = "NEC VR4122";
672 c->cputype = CPU_VR4181A;
673 __cpu_name[cpu] = "NEC VR4181A";
676 case PRID_REV_VR4130:
677 if ((c->processor_id & 0xf) < 0x4) {
678 c->cputype = CPU_VR4131;
679 __cpu_name[cpu] = "NEC VR4131";
681 c->cputype = CPU_VR4133;
682 c->options |= MIPS_CPU_LLSC;
683 __cpu_name[cpu] = "NEC VR4133";
687 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
688 c->cputype = CPU_VR41XX;
689 __cpu_name[cpu] = "NEC Vr41xx";
694 c->cputype = CPU_R4300;
695 __cpu_name[cpu] = "R4300";
696 set_isa(c, MIPS_CPU_ISA_III);
697 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
702 c->cputype = CPU_R4600;
703 __cpu_name[cpu] = "R4600";
704 set_isa(c, MIPS_CPU_ISA_III);
705 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
712 * This processor doesn't have an MMU, so it's not
713 * "real easy" to run Linux on it. It is left purely
714 * for documentation. Commented out because it shares
715 * it's c0_prid id number with the TX3900.
717 c->cputype = CPU_R4650;
718 __cpu_name[cpu] = "R4650";
719 set_isa(c, MIPS_CPU_ISA_III);
720 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
725 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
727 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
728 c->cputype = CPU_TX3927;
729 __cpu_name[cpu] = "TX3927";
732 switch (c->processor_id & PRID_REV_MASK) {
733 case PRID_REV_TX3912:
734 c->cputype = CPU_TX3912;
735 __cpu_name[cpu] = "TX3912";
738 case PRID_REV_TX3922:
739 c->cputype = CPU_TX3922;
740 __cpu_name[cpu] = "TX3922";
747 c->cputype = CPU_R4700;
748 __cpu_name[cpu] = "R4700";
749 set_isa(c, MIPS_CPU_ISA_III);
750 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
755 c->cputype = CPU_TX49XX;
756 __cpu_name[cpu] = "R49XX";
757 set_isa(c, MIPS_CPU_ISA_III);
758 c->options = R4K_OPTS | MIPS_CPU_LLSC;
759 if (!(c->processor_id & 0x08))
760 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
764 c->cputype = CPU_R5000;
765 __cpu_name[cpu] = "R5000";
766 set_isa(c, MIPS_CPU_ISA_IV);
767 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
772 c->cputype = CPU_R5432;
773 __cpu_name[cpu] = "R5432";
774 set_isa(c, MIPS_CPU_ISA_IV);
775 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
776 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
780 c->cputype = CPU_R5500;
781 __cpu_name[cpu] = "R5500";
782 set_isa(c, MIPS_CPU_ISA_IV);
783 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
784 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
787 case PRID_IMP_NEVADA:
788 c->cputype = CPU_NEVADA;
789 __cpu_name[cpu] = "Nevada";
790 set_isa(c, MIPS_CPU_ISA_IV);
791 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
792 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
796 c->cputype = CPU_R6000;
797 __cpu_name[cpu] = "R6000";
798 set_isa(c, MIPS_CPU_ISA_II);
799 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
803 case PRID_IMP_R6000A:
804 c->cputype = CPU_R6000A;
805 __cpu_name[cpu] = "R6000A";
806 set_isa(c, MIPS_CPU_ISA_II);
807 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
811 case PRID_IMP_RM7000:
812 c->cputype = CPU_RM7000;
813 __cpu_name[cpu] = "RM7000";
814 set_isa(c, MIPS_CPU_ISA_IV);
815 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
818 * Undocumented RM7000: Bit 29 in the info register of
819 * the RM7000 v2.0 indicates if the TLB has 48 or 64
822 * 29 1 => 64 entry JTLB
825 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
828 c->cputype = CPU_R8000;
829 __cpu_name[cpu] = "RM8000";
830 set_isa(c, MIPS_CPU_ISA_IV);
831 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
832 MIPS_CPU_FPU | MIPS_CPU_32FPR |
834 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
836 case PRID_IMP_R10000:
837 c->cputype = CPU_R10000;
838 __cpu_name[cpu] = "R10000";
839 set_isa(c, MIPS_CPU_ISA_IV);
840 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
841 MIPS_CPU_FPU | MIPS_CPU_32FPR |
842 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
846 case PRID_IMP_R12000:
847 c->cputype = CPU_R12000;
848 __cpu_name[cpu] = "R12000";
849 set_isa(c, MIPS_CPU_ISA_IV);
850 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
851 MIPS_CPU_FPU | MIPS_CPU_32FPR |
852 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
856 case PRID_IMP_R14000:
857 c->cputype = CPU_R14000;
858 __cpu_name[cpu] = "R14000";
859 set_isa(c, MIPS_CPU_ISA_IV);
860 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
861 MIPS_CPU_FPU | MIPS_CPU_32FPR |
862 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
866 case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */
867 switch (c->processor_id & PRID_REV_MASK) {
868 case PRID_REV_LOONGSON2E:
869 c->cputype = CPU_LOONGSON2;
870 __cpu_name[cpu] = "ICT Loongson-2";
871 set_elf_platform(cpu, "loongson2e");
872 set_isa(c, MIPS_CPU_ISA_III);
874 case PRID_REV_LOONGSON2F:
875 c->cputype = CPU_LOONGSON2;
876 __cpu_name[cpu] = "ICT Loongson-2";
877 set_elf_platform(cpu, "loongson2f");
878 set_isa(c, MIPS_CPU_ISA_III);
880 case PRID_REV_LOONGSON3A:
881 c->cputype = CPU_LOONGSON3;
882 __cpu_name[cpu] = "ICT Loongson-3";
883 set_elf_platform(cpu, "loongson3a");
884 set_isa(c, MIPS_CPU_ISA_M64R1);
886 case PRID_REV_LOONGSON3B_R1:
887 case PRID_REV_LOONGSON3B_R2:
888 c->cputype = CPU_LOONGSON3;
889 __cpu_name[cpu] = "ICT Loongson-3";
890 set_elf_platform(cpu, "loongson3b");
891 set_isa(c, MIPS_CPU_ISA_M64R1);
895 c->options = R4K_OPTS |
896 MIPS_CPU_FPU | MIPS_CPU_LLSC |
899 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
901 case PRID_IMP_LOONGSON_32: /* Loongson-1 */
904 c->cputype = CPU_LOONGSON1;
906 switch (c->processor_id & PRID_REV_MASK) {
907 case PRID_REV_LOONGSON1B:
908 __cpu_name[cpu] = "Loongson 1B";
916 static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
918 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
919 switch (c->processor_id & PRID_IMP_MASK) {
920 case PRID_IMP_QEMU_GENERIC:
921 c->writecombine = _CACHE_UNCACHED;
922 c->cputype = CPU_QEMU_GENERIC;
923 __cpu_name[cpu] = "MIPS GENERIC QEMU";
926 c->cputype = CPU_4KC;
927 c->writecombine = _CACHE_UNCACHED;
928 __cpu_name[cpu] = "MIPS 4Kc";
931 case PRID_IMP_4KECR2:
932 c->cputype = CPU_4KEC;
933 c->writecombine = _CACHE_UNCACHED;
934 __cpu_name[cpu] = "MIPS 4KEc";
938 c->cputype = CPU_4KSC;
939 c->writecombine = _CACHE_UNCACHED;
940 __cpu_name[cpu] = "MIPS 4KSc";
943 c->cputype = CPU_5KC;
944 c->writecombine = _CACHE_UNCACHED;
945 __cpu_name[cpu] = "MIPS 5Kc";
948 c->cputype = CPU_5KE;
949 c->writecombine = _CACHE_UNCACHED;
950 __cpu_name[cpu] = "MIPS 5KE";
953 c->cputype = CPU_20KC;
954 c->writecombine = _CACHE_UNCACHED;
955 __cpu_name[cpu] = "MIPS 20Kc";
958 c->cputype = CPU_24K;
959 c->writecombine = _CACHE_UNCACHED;
960 __cpu_name[cpu] = "MIPS 24Kc";
963 c->cputype = CPU_24K;
964 c->writecombine = _CACHE_UNCACHED;
965 __cpu_name[cpu] = "MIPS 24KEc";
968 c->cputype = CPU_25KF;
969 c->writecombine = _CACHE_UNCACHED;
970 __cpu_name[cpu] = "MIPS 25Kc";
973 c->cputype = CPU_34K;
974 c->writecombine = _CACHE_UNCACHED;
975 __cpu_name[cpu] = "MIPS 34Kc";
978 c->cputype = CPU_74K;
979 c->writecombine = _CACHE_UNCACHED;
980 __cpu_name[cpu] = "MIPS 74Kc";
983 c->cputype = CPU_M14KC;
984 c->writecombine = _CACHE_UNCACHED;
985 __cpu_name[cpu] = "MIPS M14Kc";
987 case PRID_IMP_M14KEC:
988 c->cputype = CPU_M14KEC;
989 c->writecombine = _CACHE_UNCACHED;
990 __cpu_name[cpu] = "MIPS M14KEc";
993 c->cputype = CPU_1004K;
994 c->writecombine = _CACHE_UNCACHED;
995 __cpu_name[cpu] = "MIPS 1004Kc";
998 c->cputype = CPU_1074K;
999 c->writecombine = _CACHE_UNCACHED;
1000 __cpu_name[cpu] = "MIPS 1074Kc";
1002 case PRID_IMP_INTERAPTIV_UP:
1003 c->cputype = CPU_INTERAPTIV;
1004 __cpu_name[cpu] = "MIPS interAptiv";
1006 case PRID_IMP_INTERAPTIV_MP:
1007 c->cputype = CPU_INTERAPTIV;
1008 __cpu_name[cpu] = "MIPS interAptiv (multi)";
1010 case PRID_IMP_PROAPTIV_UP:
1011 c->cputype = CPU_PROAPTIV;
1012 __cpu_name[cpu] = "MIPS proAptiv";
1014 case PRID_IMP_PROAPTIV_MP:
1015 c->cputype = CPU_PROAPTIV;
1016 __cpu_name[cpu] = "MIPS proAptiv (multi)";
1018 case PRID_IMP_P5600:
1019 c->cputype = CPU_P5600;
1020 __cpu_name[cpu] = "MIPS P5600";
1022 case PRID_IMP_M5150:
1023 c->cputype = CPU_M5150;
1024 __cpu_name[cpu] = "MIPS M5150";
1033 static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
1036 switch (c->processor_id & PRID_IMP_MASK) {
1037 case PRID_IMP_AU1_REV1:
1038 case PRID_IMP_AU1_REV2:
1039 c->cputype = CPU_ALCHEMY;
1040 switch ((c->processor_id >> 24) & 0xff) {
1042 __cpu_name[cpu] = "Au1000";
1045 __cpu_name[cpu] = "Au1500";
1048 __cpu_name[cpu] = "Au1100";
1051 __cpu_name[cpu] = "Au1550";
1054 __cpu_name[cpu] = "Au1200";
1055 if ((c->processor_id & PRID_REV_MASK) == 2)
1056 __cpu_name[cpu] = "Au1250";
1059 __cpu_name[cpu] = "Au1210";
1062 __cpu_name[cpu] = "Au1xxx";
1069 static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
1073 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
1074 switch (c->processor_id & PRID_IMP_MASK) {
1076 c->cputype = CPU_SB1;
1077 __cpu_name[cpu] = "SiByte SB1";
1078 /* FPU in pass1 is known to have issues. */
1079 if ((c->processor_id & PRID_REV_MASK) < 0x02)
1080 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
1083 c->cputype = CPU_SB1A;
1084 __cpu_name[cpu] = "SiByte SB1A";
1089 static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
1092 switch (c->processor_id & PRID_IMP_MASK) {
1093 case PRID_IMP_SR71000:
1094 c->cputype = CPU_SR71000;
1095 __cpu_name[cpu] = "Sandcraft SR71000";
1102 static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
1105 switch (c->processor_id & PRID_IMP_MASK) {
1106 case PRID_IMP_PR4450:
1107 c->cputype = CPU_PR4450;
1108 __cpu_name[cpu] = "Philips PR4450";
1109 set_isa(c, MIPS_CPU_ISA_M32R1);
1114 static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
1117 switch (c->processor_id & PRID_IMP_MASK) {
1118 case PRID_IMP_BMIPS32_REV4:
1119 case PRID_IMP_BMIPS32_REV8:
1120 c->cputype = CPU_BMIPS32;
1121 __cpu_name[cpu] = "Broadcom BMIPS32";
1122 set_elf_platform(cpu, "bmips32");
1124 case PRID_IMP_BMIPS3300:
1125 case PRID_IMP_BMIPS3300_ALT:
1126 case PRID_IMP_BMIPS3300_BUG:
1127 c->cputype = CPU_BMIPS3300;
1128 __cpu_name[cpu] = "Broadcom BMIPS3300";
1129 set_elf_platform(cpu, "bmips3300");
1131 case PRID_IMP_BMIPS43XX: {
1132 int rev = c->processor_id & PRID_REV_MASK;
1134 if (rev >= PRID_REV_BMIPS4380_LO &&
1135 rev <= PRID_REV_BMIPS4380_HI) {
1136 c->cputype = CPU_BMIPS4380;
1137 __cpu_name[cpu] = "Broadcom BMIPS4380";
1138 set_elf_platform(cpu, "bmips4380");
1140 c->cputype = CPU_BMIPS4350;
1141 __cpu_name[cpu] = "Broadcom BMIPS4350";
1142 set_elf_platform(cpu, "bmips4350");
1146 case PRID_IMP_BMIPS5000:
1147 case PRID_IMP_BMIPS5200:
1148 c->cputype = CPU_BMIPS5000;
1149 __cpu_name[cpu] = "Broadcom BMIPS5000";
1150 set_elf_platform(cpu, "bmips5000");
1151 c->options |= MIPS_CPU_ULRI;
1156 static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
1159 switch (c->processor_id & PRID_IMP_MASK) {
1160 case PRID_IMP_CAVIUM_CN38XX:
1161 case PRID_IMP_CAVIUM_CN31XX:
1162 case PRID_IMP_CAVIUM_CN30XX:
1163 c->cputype = CPU_CAVIUM_OCTEON;
1164 __cpu_name[cpu] = "Cavium Octeon";
1166 case PRID_IMP_CAVIUM_CN58XX:
1167 case PRID_IMP_CAVIUM_CN56XX:
1168 case PRID_IMP_CAVIUM_CN50XX:
1169 case PRID_IMP_CAVIUM_CN52XX:
1170 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
1171 __cpu_name[cpu] = "Cavium Octeon+";
1173 set_elf_platform(cpu, "octeon");
1175 case PRID_IMP_CAVIUM_CN61XX:
1176 case PRID_IMP_CAVIUM_CN63XX:
1177 case PRID_IMP_CAVIUM_CN66XX:
1178 case PRID_IMP_CAVIUM_CN68XX:
1179 case PRID_IMP_CAVIUM_CNF71XX:
1180 c->cputype = CPU_CAVIUM_OCTEON2;
1181 __cpu_name[cpu] = "Cavium Octeon II";
1182 set_elf_platform(cpu, "octeon2");
1184 case PRID_IMP_CAVIUM_CN70XX:
1185 case PRID_IMP_CAVIUM_CN78XX:
1186 c->cputype = CPU_CAVIUM_OCTEON3;
1187 __cpu_name[cpu] = "Cavium Octeon III";
1188 set_elf_platform(cpu, "octeon3");
1191 printk(KERN_INFO "Unknown Octeon chip!\n");
1192 c->cputype = CPU_UNKNOWN;
1197 static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1200 /* JZRISC does not implement the CP0 counter. */
1201 c->options &= ~MIPS_CPU_COUNTER;
1202 BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);
1203 switch (c->processor_id & PRID_IMP_MASK) {
1204 case PRID_IMP_JZRISC:
1205 c->cputype = CPU_JZRISC;
1206 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
1207 __cpu_name[cpu] = "Ingenic JZRISC";
1210 panic("Unknown Ingenic Processor ID!");
1215 static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1219 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
1220 c->cputype = CPU_ALCHEMY;
1221 __cpu_name[cpu] = "Au1300";
1222 /* following stuff is not for Alchemy */
1226 c->options = (MIPS_CPU_TLB |
1234 switch (c->processor_id & PRID_IMP_MASK) {
1235 case PRID_IMP_NETLOGIC_XLP2XX:
1236 case PRID_IMP_NETLOGIC_XLP9XX:
1237 case PRID_IMP_NETLOGIC_XLP5XX:
1238 c->cputype = CPU_XLP;
1239 __cpu_name[cpu] = "Broadcom XLPII";
1242 case PRID_IMP_NETLOGIC_XLP8XX:
1243 case PRID_IMP_NETLOGIC_XLP3XX:
1244 c->cputype = CPU_XLP;
1245 __cpu_name[cpu] = "Netlogic XLP";
1248 case PRID_IMP_NETLOGIC_XLR732:
1249 case PRID_IMP_NETLOGIC_XLR716:
1250 case PRID_IMP_NETLOGIC_XLR532:
1251 case PRID_IMP_NETLOGIC_XLR308:
1252 case PRID_IMP_NETLOGIC_XLR532C:
1253 case PRID_IMP_NETLOGIC_XLR516C:
1254 case PRID_IMP_NETLOGIC_XLR508C:
1255 case PRID_IMP_NETLOGIC_XLR308C:
1256 c->cputype = CPU_XLR;
1257 __cpu_name[cpu] = "Netlogic XLR";
1260 case PRID_IMP_NETLOGIC_XLS608:
1261 case PRID_IMP_NETLOGIC_XLS408:
1262 case PRID_IMP_NETLOGIC_XLS404:
1263 case PRID_IMP_NETLOGIC_XLS208:
1264 case PRID_IMP_NETLOGIC_XLS204:
1265 case PRID_IMP_NETLOGIC_XLS108:
1266 case PRID_IMP_NETLOGIC_XLS104:
1267 case PRID_IMP_NETLOGIC_XLS616B:
1268 case PRID_IMP_NETLOGIC_XLS608B:
1269 case PRID_IMP_NETLOGIC_XLS416B:
1270 case PRID_IMP_NETLOGIC_XLS412B:
1271 case PRID_IMP_NETLOGIC_XLS408B:
1272 case PRID_IMP_NETLOGIC_XLS404B:
1273 c->cputype = CPU_XLR;
1274 __cpu_name[cpu] = "Netlogic XLS";
1278 pr_info("Unknown Netlogic chip id [%02x]!\n",
1280 c->cputype = CPU_XLR;
1284 if (c->cputype == CPU_XLP) {
1285 set_isa(c, MIPS_CPU_ISA_M64R2);
1286 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1287 /* This will be updated again after all threads are woken up */
1288 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1290 set_isa(c, MIPS_CPU_ISA_M64R1);
1291 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1293 c->kscratch_mask = 0xf;
1297 /* For use by uaccess.h */
1299 EXPORT_SYMBOL(__ua_limit);
1302 const char *__cpu_name[NR_CPUS];
1303 const char *__elf_platform;
1305 void cpu_probe(void)
1307 struct cpuinfo_mips *c = ¤t_cpu_data;
1308 unsigned int cpu = smp_processor_id();
1310 c->processor_id = PRID_IMP_UNKNOWN;
1311 c->fpu_id = FPIR_IMP_NONE;
1312 c->cputype = CPU_UNKNOWN;
1313 c->writecombine = _CACHE_UNCACHED;
1315 c->processor_id = read_c0_prid();
1316 switch (c->processor_id & PRID_COMP_MASK) {
1317 case PRID_COMP_LEGACY:
1318 cpu_probe_legacy(c, cpu);
1320 case PRID_COMP_MIPS:
1321 cpu_probe_mips(c, cpu);
1323 case PRID_COMP_ALCHEMY:
1324 cpu_probe_alchemy(c, cpu);
1326 case PRID_COMP_SIBYTE:
1327 cpu_probe_sibyte(c, cpu);
1329 case PRID_COMP_BROADCOM:
1330 cpu_probe_broadcom(c, cpu);
1332 case PRID_COMP_SANDCRAFT:
1333 cpu_probe_sandcraft(c, cpu);
1336 cpu_probe_nxp(c, cpu);
1338 case PRID_COMP_CAVIUM:
1339 cpu_probe_cavium(c, cpu);
1341 case PRID_COMP_INGENIC:
1342 cpu_probe_ingenic(c, cpu);
1344 case PRID_COMP_NETLOGIC:
1345 cpu_probe_netlogic(c, cpu);
1349 BUG_ON(!__cpu_name[cpu]);
1350 BUG_ON(c->cputype == CPU_UNKNOWN);
1353 * Platform code can force the cpu type to optimize code
1354 * generation. In that case be sure the cpu type is correctly
1355 * manually setup otherwise it could trigger some nasty bugs.
1357 BUG_ON(current_cpu_type() != c->cputype);
1359 if (mips_fpu_disabled)
1360 c->options &= ~MIPS_CPU_FPU;
1362 if (mips_dsp_disabled)
1363 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
1365 if (mips_htw_disabled) {
1366 c->options &= ~MIPS_CPU_HTW;
1367 write_c0_pwctl(read_c0_pwctl() &
1368 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
1371 if (c->options & MIPS_CPU_FPU) {
1372 c->fpu_id = cpu_get_fpu_id();
1374 if (c->isa_level & cpu_has_mips_r) {
1375 if (c->fpu_id & MIPS_FPIR_3D)
1376 c->ases |= MIPS_ASE_MIPS3D;
1377 if (c->fpu_id & MIPS_FPIR_FREP)
1378 c->options |= MIPS_CPU_FRE;
1382 if (cpu_has_mips_r2_r6) {
1383 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1384 /* R2 has Performance Counter Interrupt indicator */
1385 c->options |= MIPS_CPU_PCI;
1391 c->msa_id = cpu_get_msa_id();
1392 WARN(c->msa_id & MSA_IR_WRPF,
1393 "Vector register partitioning unimplemented!");
1396 cpu_probe_vmbits(c);
1400 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1404 void cpu_report(void)
1406 struct cpuinfo_mips *c = ¤t_cpu_data;
1408 pr_info("CPU%d revision is: %08x (%s)\n",
1409 smp_processor_id(), c->processor_id, cpu_name_string());
1410 if (c->options & MIPS_CPU_FPU)
1411 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
1413 pr_info("MSA revision is: %08x\n", c->msa_id);