1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Processor capabilities determination functions.
5 * Copyright (C) xxxx the Anonymous
6 * Copyright (C) 1994 - 2006 Ralf Baechle
7 * Copyright (C) 2003, 2004 Maciej W. Rozycki
8 * Copyright (C) 2001, 2004, 2011, 2012 MIPS Technologies, Inc.
10 #include <linux/init.h>
11 #include <linux/kernel.h>
12 #include <linux/ptrace.h>
13 #include <linux/smp.h>
14 #include <linux/stddef.h>
15 #include <linux/export.h>
19 #include <asm/cpu-features.h>
20 #include <asm/cpu-type.h>
22 #include <asm/mipsregs.h>
23 #include <asm/mipsmtregs.h>
25 #include <asm/watch.h>
27 #include <asm/pgtable-bits.h>
28 #include <asm/spram.h>
29 #include <linux/uaccess.h>
31 /* Hardware capabilities */
32 unsigned int elf_hwcap __read_mostly
;
33 EXPORT_SYMBOL_GPL(elf_hwcap
);
35 #ifdef CONFIG_MIPS_FP_SUPPORT
38 * Get the FPU Implementation/Revision.
40 static inline unsigned long cpu_get_fpu_id(void)
42 unsigned long tmp
, fpu_id
;
44 tmp
= read_c0_status();
45 __enable_fpu(FPU_AS_IS
);
46 fpu_id
= read_32bit_cp1_register(CP1_REVISION
);
52 * Check if the CPU has an external FPU.
54 static inline int __cpu_has_fpu(void)
56 return (cpu_get_fpu_id() & FPIR_IMP_MASK
) != FPIR_IMP_NONE
;
60 * Determine the FCSR mask for FPU hardware.
62 static inline void cpu_set_fpu_fcsr_mask(struct cpuinfo_mips
*c
)
64 unsigned long sr
, mask
, fcsr
, fcsr0
, fcsr1
;
67 mask
= FPU_CSR_ALL_X
| FPU_CSR_ALL_E
| FPU_CSR_ALL_S
| FPU_CSR_RM
;
69 sr
= read_c0_status();
70 __enable_fpu(FPU_AS_IS
);
73 write_32bit_cp1_register(CP1_STATUS
, fcsr0
);
74 fcsr0
= read_32bit_cp1_register(CP1_STATUS
);
77 write_32bit_cp1_register(CP1_STATUS
, fcsr1
);
78 fcsr1
= read_32bit_cp1_register(CP1_STATUS
);
80 write_32bit_cp1_register(CP1_STATUS
, fcsr
);
84 c
->fpu_msk31
= ~(fcsr0
^ fcsr1
) & ~mask
;
88 * Determine the IEEE 754 NaN encodings and ABS.fmt/NEG.fmt execution modes
89 * supported by FPU hardware.
91 static void cpu_set_fpu_2008(struct cpuinfo_mips
*c
)
93 if (c
->isa_level
& (MIPS_CPU_ISA_M32R1
| MIPS_CPU_ISA_M64R1
|
94 MIPS_CPU_ISA_M32R2
| MIPS_CPU_ISA_M64R2
|
95 MIPS_CPU_ISA_M32R6
| MIPS_CPU_ISA_M64R6
)) {
96 unsigned long sr
, fir
, fcsr
, fcsr0
, fcsr1
;
98 sr
= read_c0_status();
99 __enable_fpu(FPU_AS_IS
);
101 fir
= read_32bit_cp1_register(CP1_REVISION
);
102 if (fir
& MIPS_FPIR_HAS2008
) {
103 fcsr
= read_32bit_cp1_register(CP1_STATUS
);
106 * MAC2008 toolchain never landed in real world, so we're only
107 * testing wether it can be disabled and don't try to enabled
110 fcsr0
= fcsr
& ~(FPU_CSR_ABS2008
| FPU_CSR_NAN2008
| FPU_CSR_MAC2008
);
111 write_32bit_cp1_register(CP1_STATUS
, fcsr0
);
112 fcsr0
= read_32bit_cp1_register(CP1_STATUS
);
114 fcsr1
= fcsr
| FPU_CSR_ABS2008
| FPU_CSR_NAN2008
;
115 write_32bit_cp1_register(CP1_STATUS
, fcsr1
);
116 fcsr1
= read_32bit_cp1_register(CP1_STATUS
);
118 write_32bit_cp1_register(CP1_STATUS
, fcsr
);
120 if (c
->isa_level
& (MIPS_CPU_ISA_M32R2
| MIPS_CPU_ISA_M64R2
)) {
122 * The bit for MAC2008 might be reused by R6 in future,
123 * so we only test for R2-R5.
125 if (fcsr0
& FPU_CSR_MAC2008
)
126 c
->options
|= MIPS_CPU_MAC_2008_ONLY
;
129 if (!(fcsr0
& FPU_CSR_NAN2008
))
130 c
->options
|= MIPS_CPU_NAN_LEGACY
;
131 if (fcsr1
& FPU_CSR_NAN2008
)
132 c
->options
|= MIPS_CPU_NAN_2008
;
134 if ((fcsr0
^ fcsr1
) & FPU_CSR_ABS2008
)
135 c
->fpu_msk31
&= ~FPU_CSR_ABS2008
;
137 c
->fpu_csr31
|= fcsr
& FPU_CSR_ABS2008
;
139 if ((fcsr0
^ fcsr1
) & FPU_CSR_NAN2008
)
140 c
->fpu_msk31
&= ~FPU_CSR_NAN2008
;
142 c
->fpu_csr31
|= fcsr
& FPU_CSR_NAN2008
;
144 c
->options
|= MIPS_CPU_NAN_LEGACY
;
149 c
->options
|= MIPS_CPU_NAN_LEGACY
;
154 * IEEE 754 conformance mode to use. Affects the NaN encoding and the
155 * ABS.fmt/NEG.fmt execution mode.
157 static enum { STRICT
, LEGACY
, STD2008
, RELAXED
} ieee754
= STRICT
;
160 * Set the IEEE 754 NaN encodings and the ABS.fmt/NEG.fmt execution modes
161 * to support by the FPU emulator according to the IEEE 754 conformance
162 * mode selected. Note that "relaxed" straps the emulator so that it
163 * allows 2008-NaN binaries even for legacy processors.
165 static void cpu_set_nofpu_2008(struct cpuinfo_mips
*c
)
167 c
->options
&= ~(MIPS_CPU_NAN_2008
| MIPS_CPU_NAN_LEGACY
);
168 c
->fpu_csr31
&= ~(FPU_CSR_ABS2008
| FPU_CSR_NAN2008
);
169 c
->fpu_msk31
&= ~(FPU_CSR_ABS2008
| FPU_CSR_NAN2008
);
173 if (c
->isa_level
& (MIPS_CPU_ISA_M32R1
| MIPS_CPU_ISA_M64R1
|
174 MIPS_CPU_ISA_M32R2
| MIPS_CPU_ISA_M64R2
|
175 MIPS_CPU_ISA_M32R6
| MIPS_CPU_ISA_M64R6
)) {
176 c
->options
|= MIPS_CPU_NAN_2008
| MIPS_CPU_NAN_LEGACY
;
178 c
->options
|= MIPS_CPU_NAN_LEGACY
;
179 c
->fpu_msk31
|= FPU_CSR_ABS2008
| FPU_CSR_NAN2008
;
183 c
->options
|= MIPS_CPU_NAN_LEGACY
;
184 c
->fpu_msk31
|= FPU_CSR_ABS2008
| FPU_CSR_NAN2008
;
187 c
->options
|= MIPS_CPU_NAN_2008
;
188 c
->fpu_csr31
|= FPU_CSR_ABS2008
| FPU_CSR_NAN2008
;
189 c
->fpu_msk31
|= FPU_CSR_ABS2008
| FPU_CSR_NAN2008
;
192 c
->options
|= MIPS_CPU_NAN_2008
| MIPS_CPU_NAN_LEGACY
;
198 * Override the IEEE 754 NaN encoding and ABS.fmt/NEG.fmt execution mode
199 * according to the "ieee754=" parameter.
201 static void cpu_set_nan_2008(struct cpuinfo_mips
*c
)
205 mips_use_nan_legacy
= !!cpu_has_nan_legacy
;
206 mips_use_nan_2008
= !!cpu_has_nan_2008
;
209 mips_use_nan_legacy
= !!cpu_has_nan_legacy
;
210 mips_use_nan_2008
= !cpu_has_nan_legacy
;
213 mips_use_nan_legacy
= !cpu_has_nan_2008
;
214 mips_use_nan_2008
= !!cpu_has_nan_2008
;
217 mips_use_nan_legacy
= true;
218 mips_use_nan_2008
= true;
224 * IEEE 754 NaN encoding and ABS.fmt/NEG.fmt execution mode override
227 * strict: accept binaries that request a NaN encoding supported by the FPU
228 * legacy: only accept legacy-NaN binaries
229 * 2008: only accept 2008-NaN binaries
230 * relaxed: accept any binaries regardless of whether supported by the FPU
232 static int __init
ieee754_setup(char *s
)
236 else if (!strcmp(s
, "strict"))
238 else if (!strcmp(s
, "legacy"))
240 else if (!strcmp(s
, "2008"))
242 else if (!strcmp(s
, "relaxed"))
247 if (!(boot_cpu_data
.options
& MIPS_CPU_FPU
))
248 cpu_set_nofpu_2008(&boot_cpu_data
);
249 cpu_set_nan_2008(&boot_cpu_data
);
254 early_param("ieee754", ieee754_setup
);
257 * Set the FIR feature flags for the FPU emulator.
259 static void cpu_set_nofpu_id(struct cpuinfo_mips
*c
)
264 if (c
->isa_level
& (MIPS_CPU_ISA_M32R1
| MIPS_CPU_ISA_M64R1
|
265 MIPS_CPU_ISA_M32R2
| MIPS_CPU_ISA_M64R2
|
266 MIPS_CPU_ISA_M32R6
| MIPS_CPU_ISA_M64R6
))
267 value
|= MIPS_FPIR_D
| MIPS_FPIR_S
;
268 if (c
->isa_level
& (MIPS_CPU_ISA_M32R2
| MIPS_CPU_ISA_M64R2
|
269 MIPS_CPU_ISA_M32R6
| MIPS_CPU_ISA_M64R6
))
270 value
|= MIPS_FPIR_F64
| MIPS_FPIR_L
| MIPS_FPIR_W
;
271 if (c
->options
& MIPS_CPU_NAN_2008
)
272 value
|= MIPS_FPIR_HAS2008
;
276 /* Determined FPU emulator mask to use for the boot CPU with "nofpu". */
277 static unsigned int mips_nofpu_msk31
;
280 * Set options for FPU hardware.
282 static void cpu_set_fpu_opts(struct cpuinfo_mips
*c
)
284 c
->fpu_id
= cpu_get_fpu_id();
285 mips_nofpu_msk31
= c
->fpu_msk31
;
287 if (c
->isa_level
& (MIPS_CPU_ISA_M32R1
| MIPS_CPU_ISA_M64R1
|
288 MIPS_CPU_ISA_M32R2
| MIPS_CPU_ISA_M64R2
|
289 MIPS_CPU_ISA_M32R6
| MIPS_CPU_ISA_M64R6
)) {
290 if (c
->fpu_id
& MIPS_FPIR_3D
)
291 c
->ases
|= MIPS_ASE_MIPS3D
;
292 if (c
->fpu_id
& MIPS_FPIR_UFRP
)
293 c
->options
|= MIPS_CPU_UFR
;
294 if (c
->fpu_id
& MIPS_FPIR_FREP
)
295 c
->options
|= MIPS_CPU_FRE
;
298 cpu_set_fpu_fcsr_mask(c
);
304 * Set options for the FPU emulator.
306 static void cpu_set_nofpu_opts(struct cpuinfo_mips
*c
)
308 c
->options
&= ~MIPS_CPU_FPU
;
309 c
->fpu_msk31
= mips_nofpu_msk31
;
311 cpu_set_nofpu_2008(c
);
316 static int mips_fpu_disabled
;
318 static int __init
fpu_disable(char *s
)
320 cpu_set_nofpu_opts(&boot_cpu_data
);
321 mips_fpu_disabled
= 1;
326 __setup("nofpu", fpu_disable
);
328 #else /* !CONFIG_MIPS_FP_SUPPORT */
330 #define mips_fpu_disabled 1
332 static inline unsigned long cpu_get_fpu_id(void)
334 return FPIR_IMP_NONE
;
337 static inline int __cpu_has_fpu(void)
342 static void cpu_set_fpu_opts(struct cpuinfo_mips
*c
)
347 static void cpu_set_nofpu_opts(struct cpuinfo_mips
*c
)
352 #endif /* CONFIG_MIPS_FP_SUPPORT */
354 static inline unsigned long cpu_get_msa_id(void)
356 unsigned long status
, msa_id
;
358 status
= read_c0_status();
359 __enable_fpu(FPU_64BIT
);
361 msa_id
= read_msa_ir();
363 write_c0_status(status
);
367 static int mips_dsp_disabled
;
369 static int __init
dsp_disable(char *s
)
371 cpu_data
[0].ases
&= ~(MIPS_ASE_DSP
| MIPS_ASE_DSP2P
);
372 mips_dsp_disabled
= 1;
377 __setup("nodsp", dsp_disable
);
379 static int mips_htw_disabled
;
381 static int __init
htw_disable(char *s
)
383 mips_htw_disabled
= 1;
384 cpu_data
[0].options
&= ~MIPS_CPU_HTW
;
385 write_c0_pwctl(read_c0_pwctl() &
386 ~(1 << MIPS_PWCTL_PWEN_SHIFT
));
391 __setup("nohtw", htw_disable
);
393 static int mips_ftlb_disabled
;
394 static int mips_has_ftlb_configured
;
398 FTLB_SET_PROB
= 1 << 1,
401 static int set_ftlb_enable(struct cpuinfo_mips
*c
, enum ftlb_flags flags
);
403 static int __init
ftlb_disable(char *s
)
405 unsigned int config4
, mmuextdef
;
408 * If the core hasn't done any FTLB configuration, there is nothing
411 if (!mips_has_ftlb_configured
)
414 /* Disable it in the boot cpu */
415 if (set_ftlb_enable(&cpu_data
[0], 0)) {
416 pr_warn("Can't turn FTLB off\n");
420 config4
= read_c0_config4();
422 /* Check that FTLB has been disabled */
423 mmuextdef
= config4
& MIPS_CONF4_MMUEXTDEF
;
424 /* MMUSIZEEXT == VTLB ON, FTLB OFF */
425 if (mmuextdef
== MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT
) {
426 /* This should never happen */
427 pr_warn("FTLB could not be disabled!\n");
431 mips_ftlb_disabled
= 1;
432 mips_has_ftlb_configured
= 0;
435 * noftlb is mainly used for debug purposes so print
436 * an informative message instead of using pr_debug()
438 pr_info("FTLB has been disabled\n");
441 * Some of these bits are duplicated in the decode_config4.
442 * MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT is the only possible case
443 * once FTLB has been disabled so undo what decode_config4 did.
445 cpu_data
[0].tlbsize
-= cpu_data
[0].tlbsizeftlbways
*
446 cpu_data
[0].tlbsizeftlbsets
;
447 cpu_data
[0].tlbsizeftlbsets
= 0;
448 cpu_data
[0].tlbsizeftlbways
= 0;
453 __setup("noftlb", ftlb_disable
);
456 * Check if the CPU has per tc perf counters
458 static inline void cpu_set_mt_per_tc_perf(struct cpuinfo_mips
*c
)
460 if (read_c0_config7() & MTI_CONF7_PTC
)
461 c
->options
|= MIPS_CPU_MT_PER_TC_PERF_COUNTERS
;
464 static inline void check_errata(void)
466 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
468 switch (current_cpu_type()) {
471 * Erratum "RPS May Cause Incorrect Instruction Execution"
472 * This code only handles VPE0, any SMP/RTOS code
473 * making use of VPE1 will be responsable for that VPE.
475 if ((c
->processor_id
& PRID_REV_MASK
) <= PRID_REV_34K_V1_0_2
)
476 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS
);
483 void __init
check_bugs32(void)
489 * Probe whether cpu has config register by trying to play with
490 * alternate cache bit and see whether it matters.
491 * It's used by cpu_probe to distinguish between R3000A and R3081.
493 static inline int cpu_has_confreg(void)
495 #ifdef CONFIG_CPU_R3000
496 extern unsigned long r3k_cache_size(unsigned long);
497 unsigned long size1
, size2
;
498 unsigned long cfg
= read_c0_conf();
500 size1
= r3k_cache_size(ST0_ISC
);
501 write_c0_conf(cfg
^ R30XX_CONF_AC
);
502 size2
= r3k_cache_size(ST0_ISC
);
504 return size1
!= size2
;
510 static inline void set_elf_platform(int cpu
, const char *plat
)
513 __elf_platform
= plat
;
516 static inline void cpu_probe_vmbits(struct cpuinfo_mips
*c
)
518 #ifdef __NEED_VMBITS_PROBE
519 write_c0_entryhi(0x3fffffffffffe000ULL
);
520 back_to_back_c0_hazard();
521 c
->vmbits
= fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL
);
525 static void set_isa(struct cpuinfo_mips
*c
, unsigned int isa
)
528 case MIPS_CPU_ISA_M64R2
:
529 c
->isa_level
|= MIPS_CPU_ISA_M32R2
| MIPS_CPU_ISA_M64R2
;
531 case MIPS_CPU_ISA_M64R1
:
532 c
->isa_level
|= MIPS_CPU_ISA_M32R1
| MIPS_CPU_ISA_M64R1
;
535 c
->isa_level
|= MIPS_CPU_ISA_V
;
537 case MIPS_CPU_ISA_IV
:
538 c
->isa_level
|= MIPS_CPU_ISA_IV
;
540 case MIPS_CPU_ISA_III
:
541 c
->isa_level
|= MIPS_CPU_ISA_II
| MIPS_CPU_ISA_III
;
544 /* R6 incompatible with everything else */
545 case MIPS_CPU_ISA_M64R6
:
546 c
->isa_level
|= MIPS_CPU_ISA_M32R6
| MIPS_CPU_ISA_M64R6
;
548 case MIPS_CPU_ISA_M32R6
:
549 c
->isa_level
|= MIPS_CPU_ISA_M32R6
;
550 /* Break here so we don't add incompatible ISAs */
552 case MIPS_CPU_ISA_M32R2
:
553 c
->isa_level
|= MIPS_CPU_ISA_M32R2
;
555 case MIPS_CPU_ISA_M32R1
:
556 c
->isa_level
|= MIPS_CPU_ISA_M32R1
;
558 case MIPS_CPU_ISA_II
:
559 c
->isa_level
|= MIPS_CPU_ISA_II
;
564 static char unknown_isa
[] = KERN_ERR \
565 "Unsupported ISA type, c0.config0: %d.";
567 static unsigned int calculate_ftlb_probability(struct cpuinfo_mips
*c
)
570 unsigned int probability
= c
->tlbsize
/ c
->tlbsizevtlb
;
573 * 0 = All TLBWR instructions go to FTLB
574 * 1 = 15:1: For every 16 TBLWR instructions, 15 go to the
575 * FTLB and 1 goes to the VTLB.
576 * 2 = 7:1: As above with 7:1 ratio.
577 * 3 = 3:1: As above with 3:1 ratio.
579 * Use the linear midpoint as the probability threshold.
581 if (probability
>= 12)
583 else if (probability
>= 6)
587 * So FTLB is less than 4 times bigger than VTLB.
588 * A 3:1 ratio can still be useful though.
593 static int set_ftlb_enable(struct cpuinfo_mips
*c
, enum ftlb_flags flags
)
597 /* It's implementation dependent how the FTLB can be enabled */
598 switch (c
->cputype
) {
602 /* proAptiv & related cores use Config6 to enable the FTLB */
603 config
= read_c0_config6();
606 config
|= MIPS_CONF6_FTLBEN
;
608 config
&= ~MIPS_CONF6_FTLBEN
;
610 if (flags
& FTLB_SET_PROB
) {
611 config
&= ~(3 << MIPS_CONF6_FTLBP_SHIFT
);
612 config
|= calculate_ftlb_probability(c
)
613 << MIPS_CONF6_FTLBP_SHIFT
;
616 write_c0_config6(config
);
617 back_to_back_c0_hazard();
621 /* There's no way to disable the FTLB */
622 if (!(flags
& FTLB_EN
))
626 /* Flush ITLB, DTLB, VTLB and FTLB */
627 write_c0_diag(LOONGSON_DIAG_ITLB
| LOONGSON_DIAG_DTLB
|
628 LOONGSON_DIAG_VTLB
| LOONGSON_DIAG_FTLB
);
629 /* Loongson-3 cores use Config6 to enable the FTLB */
630 config
= read_c0_config6();
633 write_c0_config6(config
& ~MIPS_CONF6_FTLBDIS
);
636 write_c0_config6(config
| MIPS_CONF6_FTLBDIS
);
645 static inline unsigned int decode_config0(struct cpuinfo_mips
*c
)
647 unsigned int config0
;
650 config0
= read_c0_config();
653 * Look for Standard TLB or Dual VTLB and FTLB
655 mt
= config0
& MIPS_CONF_MT
;
656 if (mt
== MIPS_CONF_MT_TLB
)
657 c
->options
|= MIPS_CPU_TLB
;
658 else if (mt
== MIPS_CONF_MT_FTLB
)
659 c
->options
|= MIPS_CPU_TLB
| MIPS_CPU_FTLB
;
661 isa
= (config0
& MIPS_CONF_AT
) >> 13;
664 switch ((config0
& MIPS_CONF_AR
) >> 10) {
666 set_isa(c
, MIPS_CPU_ISA_M32R1
);
669 set_isa(c
, MIPS_CPU_ISA_M32R2
);
672 set_isa(c
, MIPS_CPU_ISA_M32R6
);
679 switch ((config0
& MIPS_CONF_AR
) >> 10) {
681 set_isa(c
, MIPS_CPU_ISA_M64R1
);
684 set_isa(c
, MIPS_CPU_ISA_M64R2
);
687 set_isa(c
, MIPS_CPU_ISA_M64R6
);
697 return config0
& MIPS_CONF_M
;
700 panic(unknown_isa
, config0
);
703 static inline unsigned int decode_config1(struct cpuinfo_mips
*c
)
705 unsigned int config1
;
707 config1
= read_c0_config1();
709 if (config1
& MIPS_CONF1_MD
)
710 c
->ases
|= MIPS_ASE_MDMX
;
711 if (config1
& MIPS_CONF1_PC
)
712 c
->options
|= MIPS_CPU_PERF
;
713 if (config1
& MIPS_CONF1_WR
)
714 c
->options
|= MIPS_CPU_WATCH
;
715 if (config1
& MIPS_CONF1_CA
)
716 c
->ases
|= MIPS_ASE_MIPS16
;
717 if (config1
& MIPS_CONF1_EP
)
718 c
->options
|= MIPS_CPU_EJTAG
;
719 if (config1
& MIPS_CONF1_FP
) {
720 c
->options
|= MIPS_CPU_FPU
;
721 c
->options
|= MIPS_CPU_32FPR
;
724 c
->tlbsize
= ((config1
& MIPS_CONF1_TLBS
) >> 25) + 1;
725 c
->tlbsizevtlb
= c
->tlbsize
;
726 c
->tlbsizeftlbsets
= 0;
729 return config1
& MIPS_CONF_M
;
732 static inline unsigned int decode_config2(struct cpuinfo_mips
*c
)
734 unsigned int config2
;
736 config2
= read_c0_config2();
738 if (config2
& MIPS_CONF2_SL
)
739 c
->scache
.flags
&= ~MIPS_CACHE_NOT_PRESENT
;
741 return config2
& MIPS_CONF_M
;
744 static inline unsigned int decode_config3(struct cpuinfo_mips
*c
)
746 unsigned int config3
;
748 config3
= read_c0_config3();
750 if (config3
& MIPS_CONF3_SM
) {
751 c
->ases
|= MIPS_ASE_SMARTMIPS
;
752 c
->options
|= MIPS_CPU_RIXI
| MIPS_CPU_CTXTC
;
754 if (config3
& MIPS_CONF3_RXI
)
755 c
->options
|= MIPS_CPU_RIXI
;
756 if (config3
& MIPS_CONF3_CTXTC
)
757 c
->options
|= MIPS_CPU_CTXTC
;
758 if (config3
& MIPS_CONF3_DSP
)
759 c
->ases
|= MIPS_ASE_DSP
;
760 if (config3
& MIPS_CONF3_DSP2P
) {
761 c
->ases
|= MIPS_ASE_DSP2P
;
763 c
->ases
|= MIPS_ASE_DSP3
;
765 if (config3
& MIPS_CONF3_VINT
)
766 c
->options
|= MIPS_CPU_VINT
;
767 if (config3
& MIPS_CONF3_VEIC
)
768 c
->options
|= MIPS_CPU_VEIC
;
769 if (config3
& MIPS_CONF3_LPA
)
770 c
->options
|= MIPS_CPU_LPA
;
771 if (config3
& MIPS_CONF3_MT
)
772 c
->ases
|= MIPS_ASE_MIPSMT
;
773 if (config3
& MIPS_CONF3_ULRI
)
774 c
->options
|= MIPS_CPU_ULRI
;
775 if (config3
& MIPS_CONF3_ISA
)
776 c
->options
|= MIPS_CPU_MICROMIPS
;
777 if (config3
& MIPS_CONF3_VZ
)
778 c
->ases
|= MIPS_ASE_VZ
;
779 if (config3
& MIPS_CONF3_SC
)
780 c
->options
|= MIPS_CPU_SEGMENTS
;
781 if (config3
& MIPS_CONF3_BI
)
782 c
->options
|= MIPS_CPU_BADINSTR
;
783 if (config3
& MIPS_CONF3_BP
)
784 c
->options
|= MIPS_CPU_BADINSTRP
;
785 if (config3
& MIPS_CONF3_MSA
)
786 c
->ases
|= MIPS_ASE_MSA
;
787 if (config3
& MIPS_CONF3_PW
) {
789 c
->options
|= MIPS_CPU_HTW
;
791 if (config3
& MIPS_CONF3_CDMM
)
792 c
->options
|= MIPS_CPU_CDMM
;
793 if (config3
& MIPS_CONF3_SP
)
794 c
->options
|= MIPS_CPU_SP
;
796 return config3
& MIPS_CONF_M
;
799 static inline unsigned int decode_config4(struct cpuinfo_mips
*c
)
801 unsigned int config4
;
803 unsigned int mmuextdef
;
804 unsigned int ftlb_page
= MIPS_CONF4_FTLBPAGESIZE
;
805 unsigned long asid_mask
;
807 config4
= read_c0_config4();
810 if (((config4
& MIPS_CONF4_IE
) >> 29) == 2)
811 c
->options
|= MIPS_CPU_TLBINV
;
814 * R6 has dropped the MMUExtDef field from config4.
815 * On R6 the fields always describe the FTLB, and only if it is
816 * present according to Config.MT.
818 if (!cpu_has_mips_r6
)
819 mmuextdef
= config4
& MIPS_CONF4_MMUEXTDEF
;
820 else if (cpu_has_ftlb
)
821 mmuextdef
= MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT
;
826 case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
:
827 c
->tlbsize
+= (config4
& MIPS_CONF4_MMUSIZEEXT
) * 0x40;
828 c
->tlbsizevtlb
= c
->tlbsize
;
830 case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT
:
832 ((config4
& MIPS_CONF4_VTLBSIZEEXT
) >>
833 MIPS_CONF4_VTLBSIZEEXT_SHIFT
) * 0x40;
834 c
->tlbsize
= c
->tlbsizevtlb
;
835 ftlb_page
= MIPS_CONF4_VFTLBPAGESIZE
;
837 case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT
:
838 if (mips_ftlb_disabled
)
840 newcf4
= (config4
& ~ftlb_page
) |
841 (page_size_ftlb(mmuextdef
) <<
842 MIPS_CONF4_FTLBPAGESIZE_SHIFT
);
843 write_c0_config4(newcf4
);
844 back_to_back_c0_hazard();
845 config4
= read_c0_config4();
846 if (config4
!= newcf4
) {
847 pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
849 /* Switch FTLB off */
850 set_ftlb_enable(c
, 0);
851 mips_ftlb_disabled
= 1;
854 c
->tlbsizeftlbsets
= 1 <<
855 ((config4
& MIPS_CONF4_FTLBSETS
) >>
856 MIPS_CONF4_FTLBSETS_SHIFT
);
857 c
->tlbsizeftlbways
= ((config4
& MIPS_CONF4_FTLBWAYS
) >>
858 MIPS_CONF4_FTLBWAYS_SHIFT
) + 2;
859 c
->tlbsize
+= c
->tlbsizeftlbways
* c
->tlbsizeftlbsets
;
860 mips_has_ftlb_configured
= 1;
865 c
->kscratch_mask
= (config4
& MIPS_CONF4_KSCREXIST
)
866 >> MIPS_CONF4_KSCREXIST_SHIFT
;
868 asid_mask
= MIPS_ENTRYHI_ASID
;
869 if (config4
& MIPS_CONF4_AE
)
870 asid_mask
|= MIPS_ENTRYHI_ASIDX
;
871 set_cpu_asid_mask(c
, asid_mask
);
874 * Warn if the computed ASID mask doesn't match the mask the kernel
875 * is built for. This may indicate either a serious problem or an
876 * easy optimisation opportunity, but either way should be addressed.
878 WARN_ON(asid_mask
!= cpu_asid_mask(c
));
880 return config4
& MIPS_CONF_M
;
883 static inline unsigned int decode_config5(struct cpuinfo_mips
*c
)
885 unsigned int config5
, max_mmid_width
;
886 unsigned long asid_mask
;
888 config5
= read_c0_config5();
889 config5
&= ~(MIPS_CONF5_UFR
| MIPS_CONF5_UFE
);
891 if (cpu_has_mips_r6
) {
892 if (!__builtin_constant_p(cpu_has_mmid
) || cpu_has_mmid
)
893 config5
|= MIPS_CONF5_MI
;
895 config5
&= ~MIPS_CONF5_MI
;
898 write_c0_config5(config5
);
900 if (config5
& MIPS_CONF5_EVA
)
901 c
->options
|= MIPS_CPU_EVA
;
902 if (config5
& MIPS_CONF5_MRP
)
903 c
->options
|= MIPS_CPU_MAAR
;
904 if (config5
& MIPS_CONF5_LLB
)
905 c
->options
|= MIPS_CPU_RW_LLB
;
906 if (config5
& MIPS_CONF5_MVH
)
907 c
->options
|= MIPS_CPU_MVH
;
908 if (cpu_has_mips_r6
&& (config5
& MIPS_CONF5_VP
))
909 c
->options
|= MIPS_CPU_VP
;
910 if (config5
& MIPS_CONF5_CA2
)
911 c
->ases
|= MIPS_ASE_MIPS16E2
;
913 if (config5
& MIPS_CONF5_CRCP
)
914 elf_hwcap
|= HWCAP_MIPS_CRC32
;
916 if (cpu_has_mips_r6
) {
917 /* Ensure the write to config5 above takes effect */
918 back_to_back_c0_hazard();
920 /* Check whether we successfully enabled MMID support */
921 config5
= read_c0_config5();
922 if (config5
& MIPS_CONF5_MI
)
923 c
->options
|= MIPS_CPU_MMID
;
926 * Warn if we've hardcoded cpu_has_mmid to a value unsuitable
927 * for the CPU we're running on, or if CPUs in an SMP system
928 * have inconsistent MMID support.
930 WARN_ON(!!cpu_has_mmid
!= !!(config5
& MIPS_CONF5_MI
));
933 write_c0_memorymapid(~0ul);
934 back_to_back_c0_hazard();
935 asid_mask
= read_c0_memorymapid();
938 * We maintain a bitmap to track MMID allocation, and
939 * need a sensible upper bound on the size of that
940 * bitmap. The initial CPU with MMID support (I6500)
941 * supports 16 bit MMIDs, which gives us an 8KiB
942 * bitmap. The architecture recommends that hardware
943 * support 32 bit MMIDs, which would give us a 512MiB
944 * bitmap - that's too big in most cases.
946 * Cap MMID width at 16 bits for now & we can revisit
947 * this if & when hardware supports anything wider.
950 if (asid_mask
> GENMASK(max_mmid_width
- 1, 0)) {
951 pr_info("Capping MMID width at %d bits",
953 asid_mask
= GENMASK(max_mmid_width
- 1, 0);
956 set_cpu_asid_mask(c
, asid_mask
);
960 return config5
& MIPS_CONF_M
;
963 static void decode_configs(struct cpuinfo_mips
*c
)
967 /* MIPS32 or MIPS64 compliant CPU. */
968 c
->options
= MIPS_CPU_4KEX
| MIPS_CPU_4K_CACHE
| MIPS_CPU_COUNTER
|
969 MIPS_CPU_DIVEC
| MIPS_CPU_LLSC
| MIPS_CPU_MCHECK
;
971 c
->scache
.flags
= MIPS_CACHE_NOT_PRESENT
;
973 /* Enable FTLB if present and not disabled */
974 set_ftlb_enable(c
, mips_ftlb_disabled
? 0 : FTLB_EN
);
976 ok
= decode_config0(c
); /* Read Config registers. */
977 BUG_ON(!ok
); /* Arch spec violation! */
979 ok
= decode_config1(c
);
981 ok
= decode_config2(c
);
983 ok
= decode_config3(c
);
985 ok
= decode_config4(c
);
987 ok
= decode_config5(c
);
989 /* Probe the EBase.WG bit */
990 if (cpu_has_mips_r2_r6
) {
994 /* {read,write}_c0_ebase_64() may be UNDEFINED prior to r6 */
995 ebase
= cpu_has_mips64r6
? read_c0_ebase_64()
996 : (s32
)read_c0_ebase();
997 if (ebase
& MIPS_EBASE_WG
) {
998 /* WG bit already set, we can avoid the clumsy probe */
999 c
->options
|= MIPS_CPU_EBASE_WG
;
1001 /* Its UNDEFINED to change EBase while BEV=0 */
1002 status
= read_c0_status();
1003 write_c0_status(status
| ST0_BEV
);
1004 irq_enable_hazard();
1006 * On pre-r6 cores, this may well clobber the upper bits
1007 * of EBase. This is hard to avoid without potentially
1008 * hitting UNDEFINED dm*c0 behaviour if EBase is 32-bit.
1010 if (cpu_has_mips64r6
)
1011 write_c0_ebase_64(ebase
| MIPS_EBASE_WG
);
1013 write_c0_ebase(ebase
| MIPS_EBASE_WG
);
1014 back_to_back_c0_hazard();
1016 write_c0_status(status
);
1017 if (read_c0_ebase() & MIPS_EBASE_WG
) {
1018 c
->options
|= MIPS_CPU_EBASE_WG
;
1019 write_c0_ebase(ebase
);
1024 /* configure the FTLB write probability */
1025 set_ftlb_enable(c
, (mips_ftlb_disabled
? 0 : FTLB_EN
) | FTLB_SET_PROB
);
1027 mips_probe_watch_registers(c
);
1029 #ifndef CONFIG_MIPS_CPS
1030 if (cpu_has_mips_r2_r6
) {
1033 core
= get_ebase_cpunum();
1035 core
>>= fls(core_nvpes()) - 1;
1036 cpu_set_core(c
, core
);
1042 * Probe for certain guest capabilities by writing config bits and reading back.
1043 * Finally write back the original value.
1045 #define probe_gc0_config(name, maxconf, bits) \
1048 tmp = read_gc0_##name(); \
1049 write_gc0_##name(tmp | (bits)); \
1050 back_to_back_c0_hazard(); \
1051 maxconf = read_gc0_##name(); \
1052 write_gc0_##name(tmp); \
1056 * Probe for dynamic guest capabilities by changing certain config bits and
1057 * reading back to see if they change. Finally write back the original value.
1059 #define probe_gc0_config_dyn(name, maxconf, dynconf, bits) \
1061 maxconf = read_gc0_##name(); \
1062 write_gc0_##name(maxconf ^ (bits)); \
1063 back_to_back_c0_hazard(); \
1064 dynconf = maxconf ^ read_gc0_##name(); \
1065 write_gc0_##name(maxconf); \
1066 maxconf |= dynconf; \
1069 static inline unsigned int decode_guest_config0(struct cpuinfo_mips
*c
)
1071 unsigned int config0
;
1073 probe_gc0_config(config
, config0
, MIPS_CONF_M
);
1075 if (config0
& MIPS_CONF_M
)
1076 c
->guest
.conf
|= BIT(1);
1077 return config0
& MIPS_CONF_M
;
1080 static inline unsigned int decode_guest_config1(struct cpuinfo_mips
*c
)
1082 unsigned int config1
, config1_dyn
;
1084 probe_gc0_config_dyn(config1
, config1
, config1_dyn
,
1085 MIPS_CONF_M
| MIPS_CONF1_PC
| MIPS_CONF1_WR
|
1088 if (config1
& MIPS_CONF1_FP
)
1089 c
->guest
.options
|= MIPS_CPU_FPU
;
1090 if (config1_dyn
& MIPS_CONF1_FP
)
1091 c
->guest
.options_dyn
|= MIPS_CPU_FPU
;
1093 if (config1
& MIPS_CONF1_WR
)
1094 c
->guest
.options
|= MIPS_CPU_WATCH
;
1095 if (config1_dyn
& MIPS_CONF1_WR
)
1096 c
->guest
.options_dyn
|= MIPS_CPU_WATCH
;
1098 if (config1
& MIPS_CONF1_PC
)
1099 c
->guest
.options
|= MIPS_CPU_PERF
;
1100 if (config1_dyn
& MIPS_CONF1_PC
)
1101 c
->guest
.options_dyn
|= MIPS_CPU_PERF
;
1103 if (config1
& MIPS_CONF_M
)
1104 c
->guest
.conf
|= BIT(2);
1105 return config1
& MIPS_CONF_M
;
1108 static inline unsigned int decode_guest_config2(struct cpuinfo_mips
*c
)
1110 unsigned int config2
;
1112 probe_gc0_config(config2
, config2
, MIPS_CONF_M
);
1114 if (config2
& MIPS_CONF_M
)
1115 c
->guest
.conf
|= BIT(3);
1116 return config2
& MIPS_CONF_M
;
1119 static inline unsigned int decode_guest_config3(struct cpuinfo_mips
*c
)
1121 unsigned int config3
, config3_dyn
;
1123 probe_gc0_config_dyn(config3
, config3
, config3_dyn
,
1124 MIPS_CONF_M
| MIPS_CONF3_MSA
| MIPS_CONF3_ULRI
|
1127 if (config3
& MIPS_CONF3_CTXTC
)
1128 c
->guest
.options
|= MIPS_CPU_CTXTC
;
1129 if (config3_dyn
& MIPS_CONF3_CTXTC
)
1130 c
->guest
.options_dyn
|= MIPS_CPU_CTXTC
;
1132 if (config3
& MIPS_CONF3_PW
)
1133 c
->guest
.options
|= MIPS_CPU_HTW
;
1135 if (config3
& MIPS_CONF3_ULRI
)
1136 c
->guest
.options
|= MIPS_CPU_ULRI
;
1138 if (config3
& MIPS_CONF3_SC
)
1139 c
->guest
.options
|= MIPS_CPU_SEGMENTS
;
1141 if (config3
& MIPS_CONF3_BI
)
1142 c
->guest
.options
|= MIPS_CPU_BADINSTR
;
1143 if (config3
& MIPS_CONF3_BP
)
1144 c
->guest
.options
|= MIPS_CPU_BADINSTRP
;
1146 if (config3
& MIPS_CONF3_MSA
)
1147 c
->guest
.ases
|= MIPS_ASE_MSA
;
1148 if (config3_dyn
& MIPS_CONF3_MSA
)
1149 c
->guest
.ases_dyn
|= MIPS_ASE_MSA
;
1151 if (config3
& MIPS_CONF_M
)
1152 c
->guest
.conf
|= BIT(4);
1153 return config3
& MIPS_CONF_M
;
1156 static inline unsigned int decode_guest_config4(struct cpuinfo_mips
*c
)
1158 unsigned int config4
;
1160 probe_gc0_config(config4
, config4
,
1161 MIPS_CONF_M
| MIPS_CONF4_KSCREXIST
);
1163 c
->guest
.kscratch_mask
= (config4
& MIPS_CONF4_KSCREXIST
)
1164 >> MIPS_CONF4_KSCREXIST_SHIFT
;
1166 if (config4
& MIPS_CONF_M
)
1167 c
->guest
.conf
|= BIT(5);
1168 return config4
& MIPS_CONF_M
;
1171 static inline unsigned int decode_guest_config5(struct cpuinfo_mips
*c
)
1173 unsigned int config5
, config5_dyn
;
1175 probe_gc0_config_dyn(config5
, config5
, config5_dyn
,
1176 MIPS_CONF_M
| MIPS_CONF5_MVH
| MIPS_CONF5_MRP
);
1178 if (config5
& MIPS_CONF5_MRP
)
1179 c
->guest
.options
|= MIPS_CPU_MAAR
;
1180 if (config5_dyn
& MIPS_CONF5_MRP
)
1181 c
->guest
.options_dyn
|= MIPS_CPU_MAAR
;
1183 if (config5
& MIPS_CONF5_LLB
)
1184 c
->guest
.options
|= MIPS_CPU_RW_LLB
;
1186 if (config5
& MIPS_CONF5_MVH
)
1187 c
->guest
.options
|= MIPS_CPU_MVH
;
1189 if (config5
& MIPS_CONF_M
)
1190 c
->guest
.conf
|= BIT(6);
1191 return config5
& MIPS_CONF_M
;
1194 static inline void decode_guest_configs(struct cpuinfo_mips
*c
)
1198 ok
= decode_guest_config0(c
);
1200 ok
= decode_guest_config1(c
);
1202 ok
= decode_guest_config2(c
);
1204 ok
= decode_guest_config3(c
);
1206 ok
= decode_guest_config4(c
);
1208 decode_guest_config5(c
);
1211 static inline void cpu_probe_guestctl0(struct cpuinfo_mips
*c
)
1213 unsigned int guestctl0
, temp
;
1215 guestctl0
= read_c0_guestctl0();
1217 if (guestctl0
& MIPS_GCTL0_G0E
)
1218 c
->options
|= MIPS_CPU_GUESTCTL0EXT
;
1219 if (guestctl0
& MIPS_GCTL0_G1
)
1220 c
->options
|= MIPS_CPU_GUESTCTL1
;
1221 if (guestctl0
& MIPS_GCTL0_G2
)
1222 c
->options
|= MIPS_CPU_GUESTCTL2
;
1223 if (!(guestctl0
& MIPS_GCTL0_RAD
)) {
1224 c
->options
|= MIPS_CPU_GUESTID
;
1227 * Probe for Direct Root to Guest (DRG). Set GuestCtl1.RID = 0
1228 * first, otherwise all data accesses will be fully virtualised
1229 * as if they were performed by guest mode.
1231 write_c0_guestctl1(0);
1234 write_c0_guestctl0(guestctl0
| MIPS_GCTL0_DRG
);
1235 back_to_back_c0_hazard();
1236 temp
= read_c0_guestctl0();
1238 if (temp
& MIPS_GCTL0_DRG
) {
1239 write_c0_guestctl0(guestctl0
);
1240 c
->options
|= MIPS_CPU_DRG
;
1245 static inline void cpu_probe_guestctl1(struct cpuinfo_mips
*c
)
1247 if (cpu_has_guestid
) {
1248 /* determine the number of bits of GuestID available */
1249 write_c0_guestctl1(MIPS_GCTL1_ID
);
1250 back_to_back_c0_hazard();
1251 c
->guestid_mask
= (read_c0_guestctl1() & MIPS_GCTL1_ID
)
1252 >> MIPS_GCTL1_ID_SHIFT
;
1253 write_c0_guestctl1(0);
1257 static inline void cpu_probe_gtoffset(struct cpuinfo_mips
*c
)
1259 /* determine the number of bits of GTOffset available */
1260 write_c0_gtoffset(0xffffffff);
1261 back_to_back_c0_hazard();
1262 c
->gtoffset_mask
= read_c0_gtoffset();
1263 write_c0_gtoffset(0);
1266 static inline void cpu_probe_vz(struct cpuinfo_mips
*c
)
1268 cpu_probe_guestctl0(c
);
1269 if (cpu_has_guestctl1
)
1270 cpu_probe_guestctl1(c
);
1272 cpu_probe_gtoffset(c
);
1274 decode_guest_configs(c
);
1277 #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
1280 static inline void cpu_probe_legacy(struct cpuinfo_mips
*c
, unsigned int cpu
)
1282 switch (c
->processor_id
& PRID_IMP_MASK
) {
1283 case PRID_IMP_R2000
:
1284 c
->cputype
= CPU_R2000
;
1285 __cpu_name
[cpu
] = "R2000";
1286 c
->fpu_msk31
|= FPU_CSR_CONDX
| FPU_CSR_FS
;
1287 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_3K_CACHE
|
1289 if (__cpu_has_fpu())
1290 c
->options
|= MIPS_CPU_FPU
;
1293 case PRID_IMP_R3000
:
1294 if ((c
->processor_id
& PRID_REV_MASK
) == PRID_REV_R3000A
) {
1295 if (cpu_has_confreg()) {
1296 c
->cputype
= CPU_R3081E
;
1297 __cpu_name
[cpu
] = "R3081";
1299 c
->cputype
= CPU_R3000A
;
1300 __cpu_name
[cpu
] = "R3000A";
1303 c
->cputype
= CPU_R3000
;
1304 __cpu_name
[cpu
] = "R3000";
1306 c
->fpu_msk31
|= FPU_CSR_CONDX
| FPU_CSR_FS
;
1307 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_3K_CACHE
|
1309 if (__cpu_has_fpu())
1310 c
->options
|= MIPS_CPU_FPU
;
1313 case PRID_IMP_R4000
:
1314 if (read_c0_config() & CONF_SC
) {
1315 if ((c
->processor_id
& PRID_REV_MASK
) >=
1317 c
->cputype
= CPU_R4400PC
;
1318 __cpu_name
[cpu
] = "R4400PC";
1320 c
->cputype
= CPU_R4000PC
;
1321 __cpu_name
[cpu
] = "R4000PC";
1324 int cca
= read_c0_config() & CONF_CM_CMASK
;
1328 * SC and MC versions can't be reliably told apart,
1329 * but only the latter support coherent caching
1330 * modes so assume the firmware has set the KSEG0
1331 * coherency attribute reasonably (if uncached, we
1335 case CONF_CM_CACHABLE_CE
:
1336 case CONF_CM_CACHABLE_COW
:
1337 case CONF_CM_CACHABLE_CUW
:
1344 if ((c
->processor_id
& PRID_REV_MASK
) >=
1346 c
->cputype
= mc
? CPU_R4400MC
: CPU_R4400SC
;
1347 __cpu_name
[cpu
] = mc
? "R4400MC" : "R4400SC";
1349 c
->cputype
= mc
? CPU_R4000MC
: CPU_R4000SC
;
1350 __cpu_name
[cpu
] = mc
? "R4000MC" : "R4000SC";
1354 set_isa(c
, MIPS_CPU_ISA_III
);
1355 c
->fpu_msk31
|= FPU_CSR_CONDX
;
1356 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
1357 MIPS_CPU_WATCH
| MIPS_CPU_VCE
|
1361 case PRID_IMP_VR41XX
:
1362 set_isa(c
, MIPS_CPU_ISA_III
);
1363 c
->fpu_msk31
|= FPU_CSR_CONDX
;
1364 c
->options
= R4K_OPTS
;
1366 switch (c
->processor_id
& 0xf0) {
1367 case PRID_REV_VR4111
:
1368 c
->cputype
= CPU_VR4111
;
1369 __cpu_name
[cpu
] = "NEC VR4111";
1371 case PRID_REV_VR4121
:
1372 c
->cputype
= CPU_VR4121
;
1373 __cpu_name
[cpu
] = "NEC VR4121";
1375 case PRID_REV_VR4122
:
1376 if ((c
->processor_id
& 0xf) < 0x3) {
1377 c
->cputype
= CPU_VR4122
;
1378 __cpu_name
[cpu
] = "NEC VR4122";
1380 c
->cputype
= CPU_VR4181A
;
1381 __cpu_name
[cpu
] = "NEC VR4181A";
1384 case PRID_REV_VR4130
:
1385 if ((c
->processor_id
& 0xf) < 0x4) {
1386 c
->cputype
= CPU_VR4131
;
1387 __cpu_name
[cpu
] = "NEC VR4131";
1389 c
->cputype
= CPU_VR4133
;
1390 c
->options
|= MIPS_CPU_LLSC
;
1391 __cpu_name
[cpu
] = "NEC VR4133";
1395 printk(KERN_INFO
"Unexpected CPU of NEC VR4100 series\n");
1396 c
->cputype
= CPU_VR41XX
;
1397 __cpu_name
[cpu
] = "NEC Vr41xx";
1401 case PRID_IMP_R4600
:
1402 c
->cputype
= CPU_R4600
;
1403 __cpu_name
[cpu
] = "R4600";
1404 set_isa(c
, MIPS_CPU_ISA_III
);
1405 c
->fpu_msk31
|= FPU_CSR_CONDX
;
1406 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
1411 case PRID_IMP_R4650
:
1413 * This processor doesn't have an MMU, so it's not
1414 * "real easy" to run Linux on it. It is left purely
1415 * for documentation. Commented out because it shares
1416 * it's c0_prid id number with the TX3900.
1418 c
->cputype
= CPU_R4650
;
1419 __cpu_name
[cpu
] = "R4650";
1420 set_isa(c
, MIPS_CPU_ISA_III
);
1421 c
->fpu_msk31
|= FPU_CSR_CONDX
;
1422 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_LLSC
;
1427 c
->fpu_msk31
|= FPU_CSR_CONDX
| FPU_CSR_FS
;
1428 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_TX39_CACHE
;
1430 if ((c
->processor_id
& 0xf0) == (PRID_REV_TX3927
& 0xf0)) {
1431 c
->cputype
= CPU_TX3927
;
1432 __cpu_name
[cpu
] = "TX3927";
1435 switch (c
->processor_id
& PRID_REV_MASK
) {
1436 case PRID_REV_TX3912
:
1437 c
->cputype
= CPU_TX3912
;
1438 __cpu_name
[cpu
] = "TX3912";
1441 case PRID_REV_TX3922
:
1442 c
->cputype
= CPU_TX3922
;
1443 __cpu_name
[cpu
] = "TX3922";
1449 case PRID_IMP_R4700
:
1450 c
->cputype
= CPU_R4700
;
1451 __cpu_name
[cpu
] = "R4700";
1452 set_isa(c
, MIPS_CPU_ISA_III
);
1453 c
->fpu_msk31
|= FPU_CSR_CONDX
;
1454 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
1459 c
->cputype
= CPU_TX49XX
;
1460 __cpu_name
[cpu
] = "R49XX";
1461 set_isa(c
, MIPS_CPU_ISA_III
);
1462 c
->fpu_msk31
|= FPU_CSR_CONDX
;
1463 c
->options
= R4K_OPTS
| MIPS_CPU_LLSC
;
1464 if (!(c
->processor_id
& 0x08))
1465 c
->options
|= MIPS_CPU_FPU
| MIPS_CPU_32FPR
;
1468 case PRID_IMP_R5000
:
1469 c
->cputype
= CPU_R5000
;
1470 __cpu_name
[cpu
] = "R5000";
1471 set_isa(c
, MIPS_CPU_ISA_IV
);
1472 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
1476 case PRID_IMP_R5500
:
1477 c
->cputype
= CPU_R5500
;
1478 __cpu_name
[cpu
] = "R5500";
1479 set_isa(c
, MIPS_CPU_ISA_IV
);
1480 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
1481 MIPS_CPU_WATCH
| MIPS_CPU_LLSC
;
1484 case PRID_IMP_NEVADA
:
1485 c
->cputype
= CPU_NEVADA
;
1486 __cpu_name
[cpu
] = "Nevada";
1487 set_isa(c
, MIPS_CPU_ISA_IV
);
1488 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
1489 MIPS_CPU_DIVEC
| MIPS_CPU_LLSC
;
1492 case PRID_IMP_RM7000
:
1493 c
->cputype
= CPU_RM7000
;
1494 __cpu_name
[cpu
] = "RM7000";
1495 set_isa(c
, MIPS_CPU_ISA_IV
);
1496 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
1499 * Undocumented RM7000: Bit 29 in the info register of
1500 * the RM7000 v2.0 indicates if the TLB has 48 or 64
1503 * 29 1 => 64 entry JTLB
1504 * 0 => 48 entry JTLB
1506 c
->tlbsize
= (read_c0_info() & (1 << 29)) ? 64 : 48;
1508 case PRID_IMP_R10000
:
1509 c
->cputype
= CPU_R10000
;
1510 __cpu_name
[cpu
] = "R10000";
1511 set_isa(c
, MIPS_CPU_ISA_IV
);
1512 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4K_CACHE
| MIPS_CPU_4KEX
|
1513 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
1514 MIPS_CPU_COUNTER
| MIPS_CPU_WATCH
|
1518 case PRID_IMP_R12000
:
1519 c
->cputype
= CPU_R12000
;
1520 __cpu_name
[cpu
] = "R12000";
1521 set_isa(c
, MIPS_CPU_ISA_IV
);
1522 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4K_CACHE
| MIPS_CPU_4KEX
|
1523 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
1524 MIPS_CPU_COUNTER
| MIPS_CPU_WATCH
|
1525 MIPS_CPU_LLSC
| MIPS_CPU_BP_GHIST
;
1528 case PRID_IMP_R14000
:
1529 if (((c
->processor_id
>> 4) & 0x0f) > 2) {
1530 c
->cputype
= CPU_R16000
;
1531 __cpu_name
[cpu
] = "R16000";
1533 c
->cputype
= CPU_R14000
;
1534 __cpu_name
[cpu
] = "R14000";
1536 set_isa(c
, MIPS_CPU_ISA_IV
);
1537 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4K_CACHE
| MIPS_CPU_4KEX
|
1538 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
1539 MIPS_CPU_COUNTER
| MIPS_CPU_WATCH
|
1540 MIPS_CPU_LLSC
| MIPS_CPU_BP_GHIST
;
1543 case PRID_IMP_LOONGSON_64C
: /* Loongson-2/3 */
1544 switch (c
->processor_id
& PRID_REV_MASK
) {
1545 case PRID_REV_LOONGSON2E
:
1546 c
->cputype
= CPU_LOONGSON2EF
;
1547 __cpu_name
[cpu
] = "ICT Loongson-2";
1548 set_elf_platform(cpu
, "loongson2e");
1549 set_isa(c
, MIPS_CPU_ISA_III
);
1550 c
->fpu_msk31
|= FPU_CSR_CONDX
;
1552 case PRID_REV_LOONGSON2F
:
1553 c
->cputype
= CPU_LOONGSON2EF
;
1554 __cpu_name
[cpu
] = "ICT Loongson-2";
1555 set_elf_platform(cpu
, "loongson2f");
1556 set_isa(c
, MIPS_CPU_ISA_III
);
1557 c
->fpu_msk31
|= FPU_CSR_CONDX
;
1559 case PRID_REV_LOONGSON3A_R1
:
1560 c
->cputype
= CPU_LOONGSON64
;
1561 __cpu_name
[cpu
] = "ICT Loongson-3";
1562 set_elf_platform(cpu
, "loongson3a");
1563 set_isa(c
, MIPS_CPU_ISA_M64R1
);
1564 c
->ases
|= (MIPS_ASE_LOONGSON_MMI
| MIPS_ASE_LOONGSON_CAM
|
1565 MIPS_ASE_LOONGSON_EXT
);
1567 case PRID_REV_LOONGSON3B_R1
:
1568 case PRID_REV_LOONGSON3B_R2
:
1569 c
->cputype
= CPU_LOONGSON64
;
1570 __cpu_name
[cpu
] = "ICT Loongson-3";
1571 set_elf_platform(cpu
, "loongson3b");
1572 set_isa(c
, MIPS_CPU_ISA_M64R1
);
1573 c
->ases
|= (MIPS_ASE_LOONGSON_MMI
| MIPS_ASE_LOONGSON_CAM
|
1574 MIPS_ASE_LOONGSON_EXT
);
1578 c
->options
= R4K_OPTS
|
1579 MIPS_CPU_FPU
| MIPS_CPU_LLSC
|
1582 set_cpu_asid_mask(c
, MIPS_ENTRYHI_ASID
);
1583 c
->writecombine
= _CACHE_UNCACHED_ACCELERATED
;
1585 case PRID_IMP_LOONGSON_32
: /* Loongson-1 */
1588 c
->cputype
= CPU_LOONGSON32
;
1590 switch (c
->processor_id
& PRID_REV_MASK
) {
1591 case PRID_REV_LOONGSON1B
:
1592 __cpu_name
[cpu
] = "Loongson 1B";
1600 static inline void cpu_probe_mips(struct cpuinfo_mips
*c
, unsigned int cpu
)
1602 c
->writecombine
= _CACHE_UNCACHED_ACCELERATED
;
1603 switch (c
->processor_id
& PRID_IMP_MASK
) {
1604 case PRID_IMP_QEMU_GENERIC
:
1605 c
->writecombine
= _CACHE_UNCACHED
;
1606 c
->cputype
= CPU_QEMU_GENERIC
;
1607 __cpu_name
[cpu
] = "MIPS GENERIC QEMU";
1610 c
->cputype
= CPU_4KC
;
1611 c
->writecombine
= _CACHE_UNCACHED
;
1612 __cpu_name
[cpu
] = "MIPS 4Kc";
1615 case PRID_IMP_4KECR2
:
1616 c
->cputype
= CPU_4KEC
;
1617 c
->writecombine
= _CACHE_UNCACHED
;
1618 __cpu_name
[cpu
] = "MIPS 4KEc";
1622 c
->cputype
= CPU_4KSC
;
1623 c
->writecombine
= _CACHE_UNCACHED
;
1624 __cpu_name
[cpu
] = "MIPS 4KSc";
1627 c
->cputype
= CPU_5KC
;
1628 c
->writecombine
= _CACHE_UNCACHED
;
1629 __cpu_name
[cpu
] = "MIPS 5Kc";
1632 c
->cputype
= CPU_5KE
;
1633 c
->writecombine
= _CACHE_UNCACHED
;
1634 __cpu_name
[cpu
] = "MIPS 5KE";
1637 c
->cputype
= CPU_20KC
;
1638 c
->writecombine
= _CACHE_UNCACHED
;
1639 __cpu_name
[cpu
] = "MIPS 20Kc";
1642 c
->cputype
= CPU_24K
;
1643 c
->writecombine
= _CACHE_UNCACHED
;
1644 __cpu_name
[cpu
] = "MIPS 24Kc";
1647 c
->cputype
= CPU_24K
;
1648 c
->writecombine
= _CACHE_UNCACHED
;
1649 __cpu_name
[cpu
] = "MIPS 24KEc";
1652 c
->cputype
= CPU_25KF
;
1653 c
->writecombine
= _CACHE_UNCACHED
;
1654 __cpu_name
[cpu
] = "MIPS 25Kc";
1657 c
->cputype
= CPU_34K
;
1658 c
->writecombine
= _CACHE_UNCACHED
;
1659 __cpu_name
[cpu
] = "MIPS 34Kc";
1660 cpu_set_mt_per_tc_perf(c
);
1663 c
->cputype
= CPU_74K
;
1664 c
->writecombine
= _CACHE_UNCACHED
;
1665 __cpu_name
[cpu
] = "MIPS 74Kc";
1667 case PRID_IMP_M14KC
:
1668 c
->cputype
= CPU_M14KC
;
1669 c
->writecombine
= _CACHE_UNCACHED
;
1670 __cpu_name
[cpu
] = "MIPS M14Kc";
1672 case PRID_IMP_M14KEC
:
1673 c
->cputype
= CPU_M14KEC
;
1674 c
->writecombine
= _CACHE_UNCACHED
;
1675 __cpu_name
[cpu
] = "MIPS M14KEc";
1677 case PRID_IMP_1004K
:
1678 c
->cputype
= CPU_1004K
;
1679 c
->writecombine
= _CACHE_UNCACHED
;
1680 __cpu_name
[cpu
] = "MIPS 1004Kc";
1681 cpu_set_mt_per_tc_perf(c
);
1683 case PRID_IMP_1074K
:
1684 c
->cputype
= CPU_1074K
;
1685 c
->writecombine
= _CACHE_UNCACHED
;
1686 __cpu_name
[cpu
] = "MIPS 1074Kc";
1688 case PRID_IMP_INTERAPTIV_UP
:
1689 c
->cputype
= CPU_INTERAPTIV
;
1690 __cpu_name
[cpu
] = "MIPS interAptiv";
1691 cpu_set_mt_per_tc_perf(c
);
1693 case PRID_IMP_INTERAPTIV_MP
:
1694 c
->cputype
= CPU_INTERAPTIV
;
1695 __cpu_name
[cpu
] = "MIPS interAptiv (multi)";
1696 cpu_set_mt_per_tc_perf(c
);
1698 case PRID_IMP_PROAPTIV_UP
:
1699 c
->cputype
= CPU_PROAPTIV
;
1700 __cpu_name
[cpu
] = "MIPS proAptiv";
1702 case PRID_IMP_PROAPTIV_MP
:
1703 c
->cputype
= CPU_PROAPTIV
;
1704 __cpu_name
[cpu
] = "MIPS proAptiv (multi)";
1706 case PRID_IMP_P5600
:
1707 c
->cputype
= CPU_P5600
;
1708 __cpu_name
[cpu
] = "MIPS P5600";
1710 case PRID_IMP_P6600
:
1711 c
->cputype
= CPU_P6600
;
1712 __cpu_name
[cpu
] = "MIPS P6600";
1714 case PRID_IMP_I6400
:
1715 c
->cputype
= CPU_I6400
;
1716 __cpu_name
[cpu
] = "MIPS I6400";
1718 case PRID_IMP_I6500
:
1719 c
->cputype
= CPU_I6500
;
1720 __cpu_name
[cpu
] = "MIPS I6500";
1722 case PRID_IMP_M5150
:
1723 c
->cputype
= CPU_M5150
;
1724 __cpu_name
[cpu
] = "MIPS M5150";
1726 case PRID_IMP_M6250
:
1727 c
->cputype
= CPU_M6250
;
1728 __cpu_name
[cpu
] = "MIPS M6250";
1736 switch (__get_cpu_type(c
->cputype
)) {
1738 c
->options
|= MIPS_CPU_SHARED_FTLB_ENTRIES
;
1741 c
->options
|= MIPS_CPU_SHARED_FTLB_RAM
;
1748 static inline void cpu_probe_alchemy(struct cpuinfo_mips
*c
, unsigned int cpu
)
1751 switch (c
->processor_id
& PRID_IMP_MASK
) {
1752 case PRID_IMP_AU1_REV1
:
1753 case PRID_IMP_AU1_REV2
:
1754 c
->cputype
= CPU_ALCHEMY
;
1755 switch ((c
->processor_id
>> 24) & 0xff) {
1757 __cpu_name
[cpu
] = "Au1000";
1760 __cpu_name
[cpu
] = "Au1500";
1763 __cpu_name
[cpu
] = "Au1100";
1766 __cpu_name
[cpu
] = "Au1550";
1769 __cpu_name
[cpu
] = "Au1200";
1770 if ((c
->processor_id
& PRID_REV_MASK
) == 2)
1771 __cpu_name
[cpu
] = "Au1250";
1774 __cpu_name
[cpu
] = "Au1210";
1777 __cpu_name
[cpu
] = "Au1xxx";
1784 static inline void cpu_probe_sibyte(struct cpuinfo_mips
*c
, unsigned int cpu
)
1788 c
->writecombine
= _CACHE_UNCACHED_ACCELERATED
;
1789 switch (c
->processor_id
& PRID_IMP_MASK
) {
1791 c
->cputype
= CPU_SB1
;
1792 __cpu_name
[cpu
] = "SiByte SB1";
1793 /* FPU in pass1 is known to have issues. */
1794 if ((c
->processor_id
& PRID_REV_MASK
) < 0x02)
1795 c
->options
&= ~(MIPS_CPU_FPU
| MIPS_CPU_32FPR
);
1798 c
->cputype
= CPU_SB1A
;
1799 __cpu_name
[cpu
] = "SiByte SB1A";
1804 static inline void cpu_probe_sandcraft(struct cpuinfo_mips
*c
, unsigned int cpu
)
1807 switch (c
->processor_id
& PRID_IMP_MASK
) {
1808 case PRID_IMP_SR71000
:
1809 c
->cputype
= CPU_SR71000
;
1810 __cpu_name
[cpu
] = "Sandcraft SR71000";
1817 static inline void cpu_probe_nxp(struct cpuinfo_mips
*c
, unsigned int cpu
)
1820 switch (c
->processor_id
& PRID_IMP_MASK
) {
1821 case PRID_IMP_PR4450
:
1822 c
->cputype
= CPU_PR4450
;
1823 __cpu_name
[cpu
] = "Philips PR4450";
1824 set_isa(c
, MIPS_CPU_ISA_M32R1
);
1829 static inline void cpu_probe_broadcom(struct cpuinfo_mips
*c
, unsigned int cpu
)
1832 switch (c
->processor_id
& PRID_IMP_MASK
) {
1833 case PRID_IMP_BMIPS32_REV4
:
1834 case PRID_IMP_BMIPS32_REV8
:
1835 c
->cputype
= CPU_BMIPS32
;
1836 __cpu_name
[cpu
] = "Broadcom BMIPS32";
1837 set_elf_platform(cpu
, "bmips32");
1839 case PRID_IMP_BMIPS3300
:
1840 case PRID_IMP_BMIPS3300_ALT
:
1841 case PRID_IMP_BMIPS3300_BUG
:
1842 c
->cputype
= CPU_BMIPS3300
;
1843 __cpu_name
[cpu
] = "Broadcom BMIPS3300";
1844 set_elf_platform(cpu
, "bmips3300");
1846 case PRID_IMP_BMIPS43XX
: {
1847 int rev
= c
->processor_id
& PRID_REV_MASK
;
1849 if (rev
>= PRID_REV_BMIPS4380_LO
&&
1850 rev
<= PRID_REV_BMIPS4380_HI
) {
1851 c
->cputype
= CPU_BMIPS4380
;
1852 __cpu_name
[cpu
] = "Broadcom BMIPS4380";
1853 set_elf_platform(cpu
, "bmips4380");
1854 c
->options
|= MIPS_CPU_RIXI
;
1856 c
->cputype
= CPU_BMIPS4350
;
1857 __cpu_name
[cpu
] = "Broadcom BMIPS4350";
1858 set_elf_platform(cpu
, "bmips4350");
1862 case PRID_IMP_BMIPS5000
:
1863 case PRID_IMP_BMIPS5200
:
1864 c
->cputype
= CPU_BMIPS5000
;
1865 if ((c
->processor_id
& PRID_IMP_MASK
) == PRID_IMP_BMIPS5200
)
1866 __cpu_name
[cpu
] = "Broadcom BMIPS5200";
1868 __cpu_name
[cpu
] = "Broadcom BMIPS5000";
1869 set_elf_platform(cpu
, "bmips5000");
1870 c
->options
|= MIPS_CPU_ULRI
| MIPS_CPU_RIXI
;
1875 static inline void cpu_probe_cavium(struct cpuinfo_mips
*c
, unsigned int cpu
)
1878 switch (c
->processor_id
& PRID_IMP_MASK
) {
1879 case PRID_IMP_CAVIUM_CN38XX
:
1880 case PRID_IMP_CAVIUM_CN31XX
:
1881 case PRID_IMP_CAVIUM_CN30XX
:
1882 c
->cputype
= CPU_CAVIUM_OCTEON
;
1883 __cpu_name
[cpu
] = "Cavium Octeon";
1885 case PRID_IMP_CAVIUM_CN58XX
:
1886 case PRID_IMP_CAVIUM_CN56XX
:
1887 case PRID_IMP_CAVIUM_CN50XX
:
1888 case PRID_IMP_CAVIUM_CN52XX
:
1889 c
->cputype
= CPU_CAVIUM_OCTEON_PLUS
;
1890 __cpu_name
[cpu
] = "Cavium Octeon+";
1892 set_elf_platform(cpu
, "octeon");
1894 case PRID_IMP_CAVIUM_CN61XX
:
1895 case PRID_IMP_CAVIUM_CN63XX
:
1896 case PRID_IMP_CAVIUM_CN66XX
:
1897 case PRID_IMP_CAVIUM_CN68XX
:
1898 case PRID_IMP_CAVIUM_CNF71XX
:
1899 c
->cputype
= CPU_CAVIUM_OCTEON2
;
1900 __cpu_name
[cpu
] = "Cavium Octeon II";
1901 set_elf_platform(cpu
, "octeon2");
1903 case PRID_IMP_CAVIUM_CN70XX
:
1904 case PRID_IMP_CAVIUM_CN73XX
:
1905 case PRID_IMP_CAVIUM_CNF75XX
:
1906 case PRID_IMP_CAVIUM_CN78XX
:
1907 c
->cputype
= CPU_CAVIUM_OCTEON3
;
1908 __cpu_name
[cpu
] = "Cavium Octeon III";
1909 set_elf_platform(cpu
, "octeon3");
1912 printk(KERN_INFO
"Unknown Octeon chip!\n");
1913 c
->cputype
= CPU_UNKNOWN
;
1918 static inline void cpu_probe_loongson(struct cpuinfo_mips
*c
, unsigned int cpu
)
1920 switch (c
->processor_id
& PRID_IMP_MASK
) {
1921 case PRID_IMP_LOONGSON_64C
: /* Loongson-2/3 */
1922 switch (c
->processor_id
& PRID_REV_MASK
) {
1923 case PRID_REV_LOONGSON3A_R2_0
:
1924 case PRID_REV_LOONGSON3A_R2_1
:
1925 c
->cputype
= CPU_LOONGSON64
;
1926 __cpu_name
[cpu
] = "ICT Loongson-3";
1927 set_elf_platform(cpu
, "loongson3a");
1928 set_isa(c
, MIPS_CPU_ISA_M64R2
);
1930 case PRID_REV_LOONGSON3A_R3_0
:
1931 case PRID_REV_LOONGSON3A_R3_1
:
1932 c
->cputype
= CPU_LOONGSON64
;
1933 __cpu_name
[cpu
] = "ICT Loongson-3";
1934 set_elf_platform(cpu
, "loongson3a");
1935 set_isa(c
, MIPS_CPU_ISA_M64R2
);
1940 c
->options
|= MIPS_CPU_FTLB
| MIPS_CPU_TLBINV
| MIPS_CPU_LDPTE
;
1941 c
->writecombine
= _CACHE_UNCACHED_ACCELERATED
;
1942 c
->ases
|= (MIPS_ASE_LOONGSON_MMI
| MIPS_ASE_LOONGSON_CAM
|
1943 MIPS_ASE_LOONGSON_EXT
| MIPS_ASE_LOONGSON_EXT2
);
1945 case PRID_IMP_LOONGSON_64G
:
1946 c
->cputype
= CPU_LOONGSON64
;
1947 __cpu_name
[cpu
] = "ICT Loongson-3";
1948 set_elf_platform(cpu
, "loongson3a");
1949 set_isa(c
, MIPS_CPU_ISA_M64R2
);
1951 c
->options
|= MIPS_CPU_FTLB
| MIPS_CPU_TLBINV
| MIPS_CPU_LDPTE
;
1952 c
->writecombine
= _CACHE_UNCACHED_ACCELERATED
;
1953 c
->ases
|= (MIPS_ASE_LOONGSON_MMI
| MIPS_ASE_LOONGSON_CAM
|
1954 MIPS_ASE_LOONGSON_EXT
| MIPS_ASE_LOONGSON_EXT2
);
1957 panic("Unknown Loongson Processor ID!");
1962 static inline void cpu_probe_ingenic(struct cpuinfo_mips
*c
, unsigned int cpu
)
1967 * XBurst misses a config2 register, so config3 decode was skipped in
1972 /* XBurst does not implement the CP0 counter. */
1973 c
->options
&= ~MIPS_CPU_COUNTER
;
1974 BUG_ON(!__builtin_constant_p(cpu_has_counter
) || cpu_has_counter
);
1976 switch (c
->processor_id
& PRID_IMP_MASK
) {
1977 case PRID_IMP_XBURST_REV1
:
1980 * The XBurst core by default attempts to avoid branch target
1981 * buffer lookups by detecting & special casing loops. This
1982 * feature will cause BogoMIPS and lpj calculate in error.
1983 * Set cp0 config7 bit 4 to disable this feature.
1985 set_c0_config7(MIPS_CONF7_BTB_LOOP_EN
);
1987 switch (c
->processor_id
& PRID_COMP_MASK
) {
1990 * The config0 register in the XBurst CPUs with a processor ID of
1991 * PRID_COMP_INGENIC_D0 report themselves as MIPS32r2 compatible,
1992 * but they don't actually support this ISA.
1994 case PRID_COMP_INGENIC_D0
:
1995 c
->isa_level
&= ~MIPS_CPU_ISA_M32R2
;
1999 * The config0 register in the XBurst CPUs with a processor ID of
2000 * PRID_COMP_INGENIC_D1 has an abandoned huge page tlb mode, this
2001 * mode is not compatible with the MIPS standard, it will cause
2002 * tlbmiss and into an infinite loop (line 21 in the tlb-funcs.S)
2003 * when starting the init process. After chip reset, the default
2004 * is HPTLB mode, Write 0xa9000000 to cp0 register 5 sel 4 to
2005 * switch back to VTLB mode to prevent getting stuck.
2007 case PRID_COMP_INGENIC_D1
:
2008 write_c0_page_ctrl(XBURST_PAGECTRL_HPTLB_DIS
);
2015 case PRID_IMP_XBURST_REV2
:
2016 c
->cputype
= CPU_XBURST
;
2017 c
->writecombine
= _CACHE_UNCACHED_ACCELERATED
;
2018 __cpu_name
[cpu
] = "Ingenic XBurst";
2022 panic("Unknown Ingenic Processor ID!");
2027 static inline void cpu_probe_netlogic(struct cpuinfo_mips
*c
, int cpu
)
2031 if ((c
->processor_id
& PRID_IMP_MASK
) == PRID_IMP_NETLOGIC_AU13XX
) {
2032 c
->cputype
= CPU_ALCHEMY
;
2033 __cpu_name
[cpu
] = "Au1300";
2034 /* following stuff is not for Alchemy */
2038 c
->options
= (MIPS_CPU_TLB
|
2046 switch (c
->processor_id
& PRID_IMP_MASK
) {
2047 case PRID_IMP_NETLOGIC_XLP2XX
:
2048 case PRID_IMP_NETLOGIC_XLP9XX
:
2049 case PRID_IMP_NETLOGIC_XLP5XX
:
2050 c
->cputype
= CPU_XLP
;
2051 __cpu_name
[cpu
] = "Broadcom XLPII";
2054 case PRID_IMP_NETLOGIC_XLP8XX
:
2055 case PRID_IMP_NETLOGIC_XLP3XX
:
2056 c
->cputype
= CPU_XLP
;
2057 __cpu_name
[cpu
] = "Netlogic XLP";
2060 case PRID_IMP_NETLOGIC_XLR732
:
2061 case PRID_IMP_NETLOGIC_XLR716
:
2062 case PRID_IMP_NETLOGIC_XLR532
:
2063 case PRID_IMP_NETLOGIC_XLR308
:
2064 case PRID_IMP_NETLOGIC_XLR532C
:
2065 case PRID_IMP_NETLOGIC_XLR516C
:
2066 case PRID_IMP_NETLOGIC_XLR508C
:
2067 case PRID_IMP_NETLOGIC_XLR308C
:
2068 c
->cputype
= CPU_XLR
;
2069 __cpu_name
[cpu
] = "Netlogic XLR";
2072 case PRID_IMP_NETLOGIC_XLS608
:
2073 case PRID_IMP_NETLOGIC_XLS408
:
2074 case PRID_IMP_NETLOGIC_XLS404
:
2075 case PRID_IMP_NETLOGIC_XLS208
:
2076 case PRID_IMP_NETLOGIC_XLS204
:
2077 case PRID_IMP_NETLOGIC_XLS108
:
2078 case PRID_IMP_NETLOGIC_XLS104
:
2079 case PRID_IMP_NETLOGIC_XLS616B
:
2080 case PRID_IMP_NETLOGIC_XLS608B
:
2081 case PRID_IMP_NETLOGIC_XLS416B
:
2082 case PRID_IMP_NETLOGIC_XLS412B
:
2083 case PRID_IMP_NETLOGIC_XLS408B
:
2084 case PRID_IMP_NETLOGIC_XLS404B
:
2085 c
->cputype
= CPU_XLR
;
2086 __cpu_name
[cpu
] = "Netlogic XLS";
2090 pr_info("Unknown Netlogic chip id [%02x]!\n",
2092 c
->cputype
= CPU_XLR
;
2096 if (c
->cputype
== CPU_XLP
) {
2097 set_isa(c
, MIPS_CPU_ISA_M64R2
);
2098 c
->options
|= (MIPS_CPU_FPU
| MIPS_CPU_ULRI
| MIPS_CPU_MCHECK
);
2099 /* This will be updated again after all threads are woken up */
2100 c
->tlbsize
= ((read_c0_config6() >> 16) & 0xffff) + 1;
2102 set_isa(c
, MIPS_CPU_ISA_M64R1
);
2103 c
->tlbsize
= ((read_c0_config1() >> 25) & 0x3f) + 1;
2105 c
->kscratch_mask
= 0xf;
2109 /* For use by uaccess.h */
2111 EXPORT_SYMBOL(__ua_limit
);
2114 const char *__cpu_name
[NR_CPUS
];
2115 const char *__elf_platform
;
2117 void cpu_probe(void)
2119 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
2120 unsigned int cpu
= smp_processor_id();
2123 * Set a default elf platform, cpu probe may later
2124 * overwrite it with a more precise value
2126 set_elf_platform(cpu
, "mips");
2128 c
->processor_id
= PRID_IMP_UNKNOWN
;
2129 c
->fpu_id
= FPIR_IMP_NONE
;
2130 c
->cputype
= CPU_UNKNOWN
;
2131 c
->writecombine
= _CACHE_UNCACHED
;
2133 c
->fpu_csr31
= FPU_CSR_RN
;
2134 c
->fpu_msk31
= FPU_CSR_RSVD
| FPU_CSR_ABS2008
| FPU_CSR_NAN2008
;
2136 c
->processor_id
= read_c0_prid();
2137 switch (c
->processor_id
& PRID_COMP_MASK
) {
2138 case PRID_COMP_LEGACY
:
2139 cpu_probe_legacy(c
, cpu
);
2141 case PRID_COMP_MIPS
:
2142 cpu_probe_mips(c
, cpu
);
2144 case PRID_COMP_ALCHEMY
:
2145 cpu_probe_alchemy(c
, cpu
);
2147 case PRID_COMP_SIBYTE
:
2148 cpu_probe_sibyte(c
, cpu
);
2150 case PRID_COMP_BROADCOM
:
2151 cpu_probe_broadcom(c
, cpu
);
2153 case PRID_COMP_SANDCRAFT
:
2154 cpu_probe_sandcraft(c
, cpu
);
2157 cpu_probe_nxp(c
, cpu
);
2159 case PRID_COMP_CAVIUM
:
2160 cpu_probe_cavium(c
, cpu
);
2162 case PRID_COMP_LOONGSON
:
2163 cpu_probe_loongson(c
, cpu
);
2165 case PRID_COMP_INGENIC_D0
:
2166 case PRID_COMP_INGENIC_D1
:
2167 case PRID_COMP_INGENIC_E1
:
2168 cpu_probe_ingenic(c
, cpu
);
2170 case PRID_COMP_NETLOGIC
:
2171 cpu_probe_netlogic(c
, cpu
);
2175 BUG_ON(!__cpu_name
[cpu
]);
2176 BUG_ON(c
->cputype
== CPU_UNKNOWN
);
2179 * Platform code can force the cpu type to optimize code
2180 * generation. In that case be sure the cpu type is correctly
2181 * manually setup otherwise it could trigger some nasty bugs.
2183 BUG_ON(current_cpu_type() != c
->cputype
);
2186 /* Enable the RIXI exceptions */
2187 set_c0_pagegrain(PG_IEC
);
2188 back_to_back_c0_hazard();
2189 /* Verify the IEC bit is set */
2190 if (read_c0_pagegrain() & PG_IEC
)
2191 c
->options
|= MIPS_CPU_RIXIEX
;
2194 if (mips_fpu_disabled
)
2195 c
->options
&= ~MIPS_CPU_FPU
;
2197 if (mips_dsp_disabled
)
2198 c
->ases
&= ~(MIPS_ASE_DSP
| MIPS_ASE_DSP2P
);
2200 if (mips_htw_disabled
) {
2201 c
->options
&= ~MIPS_CPU_HTW
;
2202 write_c0_pwctl(read_c0_pwctl() &
2203 ~(1 << MIPS_PWCTL_PWEN_SHIFT
));
2206 if (c
->options
& MIPS_CPU_FPU
)
2207 cpu_set_fpu_opts(c
);
2209 cpu_set_nofpu_opts(c
);
2211 if (cpu_has_bp_ghist
)
2212 write_c0_r10k_diag(read_c0_r10k_diag() |
2215 if (cpu_has_mips_r2_r6
) {
2216 c
->srsets
= ((read_c0_srsctl() >> 26) & 0x0f) + 1;
2217 /* R2 has Performance Counter Interrupt indicator */
2218 c
->options
|= MIPS_CPU_PCI
;
2223 if (cpu_has_mips_r6
)
2224 elf_hwcap
|= HWCAP_MIPS_R6
;
2227 c
->msa_id
= cpu_get_msa_id();
2228 WARN(c
->msa_id
& MSA_IR_WRPF
,
2229 "Vector register partitioning unimplemented!");
2230 elf_hwcap
|= HWCAP_MIPS_MSA
;
2234 elf_hwcap
|= HWCAP_MIPS_MIPS16
;
2237 elf_hwcap
|= HWCAP_MIPS_MDMX
;
2240 elf_hwcap
|= HWCAP_MIPS_MIPS3D
;
2242 if (cpu_has_smartmips
)
2243 elf_hwcap
|= HWCAP_MIPS_SMARTMIPS
;
2246 elf_hwcap
|= HWCAP_MIPS_DSP
;
2249 elf_hwcap
|= HWCAP_MIPS_DSP2
;
2252 elf_hwcap
|= HWCAP_MIPS_DSP3
;
2254 if (cpu_has_mips16e2
)
2255 elf_hwcap
|= HWCAP_MIPS_MIPS16E2
;
2257 if (cpu_has_loongson_mmi
)
2258 elf_hwcap
|= HWCAP_LOONGSON_MMI
;
2260 if (cpu_has_loongson_ext
)
2261 elf_hwcap
|= HWCAP_LOONGSON_EXT
;
2263 if (cpu_has_loongson_ext2
)
2264 elf_hwcap
|= HWCAP_LOONGSON_EXT2
;
2269 cpu_probe_vmbits(c
);
2273 __ua_limit
= ~((1ull << cpu_vmbits
) - 1);
2277 void cpu_report(void)
2279 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
2281 pr_info("CPU%d revision is: %08x (%s)\n",
2282 smp_processor_id(), c
->processor_id
, cpu_name_string());
2283 if (c
->options
& MIPS_CPU_FPU
)
2284 printk(KERN_INFO
"FPU revision is: %08x\n", c
->fpu_id
);
2286 pr_info("MSA revision is: %08x\n", c
->msa_id
);
2289 void cpu_set_cluster(struct cpuinfo_mips
*cpuinfo
, unsigned int cluster
)
2291 /* Ensure the core number fits in the field */
2292 WARN_ON(cluster
> (MIPS_GLOBALNUMBER_CLUSTER
>>
2293 MIPS_GLOBALNUMBER_CLUSTER_SHF
));
2295 cpuinfo
->globalnumber
&= ~MIPS_GLOBALNUMBER_CLUSTER
;
2296 cpuinfo
->globalnumber
|= cluster
<< MIPS_GLOBALNUMBER_CLUSTER_SHF
;
2299 void cpu_set_core(struct cpuinfo_mips
*cpuinfo
, unsigned int core
)
2301 /* Ensure the core number fits in the field */
2302 WARN_ON(core
> (MIPS_GLOBALNUMBER_CORE
>> MIPS_GLOBALNUMBER_CORE_SHF
));
2304 cpuinfo
->globalnumber
&= ~MIPS_GLOBALNUMBER_CORE
;
2305 cpuinfo
->globalnumber
|= core
<< MIPS_GLOBALNUMBER_CORE_SHF
;
2308 void cpu_set_vpe_id(struct cpuinfo_mips
*cpuinfo
, unsigned int vpe
)
2310 /* Ensure the VP(E) ID fits in the field */
2311 WARN_ON(vpe
> (MIPS_GLOBALNUMBER_VP
>> MIPS_GLOBALNUMBER_VP_SHF
));
2313 /* Ensure we're not using VP(E)s without support */
2314 WARN_ON(vpe
&& !IS_ENABLED(CONFIG_MIPS_MT_SMP
) &&
2315 !IS_ENABLED(CONFIG_CPU_MIPSR6
));
2317 cpuinfo
->globalnumber
&= ~MIPS_GLOBALNUMBER_VP
;
2318 cpuinfo
->globalnumber
|= vpe
<< MIPS_GLOBALNUMBER_VP_SHF
;