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>
24 #include <asm/mipsregs.h>
25 #include <asm/watch.h>
27 #include <asm/spram.h>
28 #include <asm/uaccess.h>
30 static int mips_fpu_disabled
;
32 static int __init
fpu_disable(char *s
)
34 cpu_data
[0].options
&= ~MIPS_CPU_FPU
;
35 mips_fpu_disabled
= 1;
40 __setup("nofpu", fpu_disable
);
42 int mips_dsp_disabled
;
44 static int __init
dsp_disable(char *s
)
46 cpu_data
[0].ases
&= ~(MIPS_ASE_DSP
| MIPS_ASE_DSP2P
);
47 mips_dsp_disabled
= 1;
52 __setup("nodsp", dsp_disable
);
54 static inline void check_errata(void)
56 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
61 * Erratum "RPS May Cause Incorrect Instruction Execution"
62 * This code only handles VPE0, any SMP/SMTC/RTOS code
63 * making use of VPE1 will be responsable for that VPE.
65 if ((c
->processor_id
& PRID_REV_MASK
) <= PRID_REV_34K_V1_0_2
)
66 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS
);
73 void __init
check_bugs32(void)
79 * Probe whether cpu has config register by trying to play with
80 * alternate cache bit and see whether it matters.
81 * It's used by cpu_probe to distinguish between R3000A and R3081.
83 static inline int cpu_has_confreg(void)
85 #ifdef CONFIG_CPU_R3000
86 extern unsigned long r3k_cache_size(unsigned long);
87 unsigned long size1
, size2
;
88 unsigned long cfg
= read_c0_conf();
90 size1
= r3k_cache_size(ST0_ISC
);
91 write_c0_conf(cfg
^ R30XX_CONF_AC
);
92 size2
= r3k_cache_size(ST0_ISC
);
94 return size1
!= size2
;
100 static inline void set_elf_platform(int cpu
, const char *plat
)
103 __elf_platform
= plat
;
107 * Get the FPU Implementation/Revision.
109 static inline unsigned long cpu_get_fpu_id(void)
111 unsigned long tmp
, fpu_id
;
113 tmp
= read_c0_status();
115 fpu_id
= read_32bit_cp1_register(CP1_REVISION
);
116 write_c0_status(tmp
);
121 * Check the CPU has an FPU the official way.
123 static inline int __cpu_has_fpu(void)
125 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE
);
128 static inline void cpu_probe_vmbits(struct cpuinfo_mips
*c
)
130 #ifdef __NEED_VMBITS_PROBE
131 write_c0_entryhi(0x3fffffffffffe000ULL
);
132 back_to_back_c0_hazard();
133 c
->vmbits
= fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL
);
137 static void set_isa(struct cpuinfo_mips
*c
, unsigned int isa
)
140 case MIPS_CPU_ISA_M64R2
:
141 c
->isa_level
|= MIPS_CPU_ISA_M32R2
| MIPS_CPU_ISA_M64R2
;
142 case MIPS_CPU_ISA_M64R1
:
143 c
->isa_level
|= MIPS_CPU_ISA_M32R1
| MIPS_CPU_ISA_M64R1
;
145 c
->isa_level
|= MIPS_CPU_ISA_V
;
146 case MIPS_CPU_ISA_IV
:
147 c
->isa_level
|= MIPS_CPU_ISA_IV
;
148 case MIPS_CPU_ISA_III
:
149 c
->isa_level
|= MIPS_CPU_ISA_II
| MIPS_CPU_ISA_III
;
152 case MIPS_CPU_ISA_M32R2
:
153 c
->isa_level
|= MIPS_CPU_ISA_M32R2
;
154 case MIPS_CPU_ISA_M32R1
:
155 c
->isa_level
|= MIPS_CPU_ISA_M32R1
;
156 case MIPS_CPU_ISA_II
:
157 c
->isa_level
|= MIPS_CPU_ISA_II
;
162 static char unknown_isa
[] = KERN_ERR \
163 "Unsupported ISA type, c0.config0: %d.";
165 static inline unsigned int decode_config0(struct cpuinfo_mips
*c
)
167 unsigned int config0
;
170 config0
= read_c0_config();
172 if (((config0
& MIPS_CONF_MT
) >> 7) == 1)
173 c
->options
|= MIPS_CPU_TLB
;
174 isa
= (config0
& MIPS_CONF_AT
) >> 13;
177 switch ((config0
& MIPS_CONF_AR
) >> 10) {
179 set_isa(c
, MIPS_CPU_ISA_M32R1
);
182 set_isa(c
, MIPS_CPU_ISA_M32R2
);
189 switch ((config0
& MIPS_CONF_AR
) >> 10) {
191 set_isa(c
, MIPS_CPU_ISA_M64R1
);
194 set_isa(c
, MIPS_CPU_ISA_M64R2
);
204 return config0
& MIPS_CONF_M
;
207 panic(unknown_isa
, config0
);
210 static inline unsigned int decode_config1(struct cpuinfo_mips
*c
)
212 unsigned int config1
;
214 config1
= read_c0_config1();
216 if (config1
& MIPS_CONF1_MD
)
217 c
->ases
|= MIPS_ASE_MDMX
;
218 if (config1
& MIPS_CONF1_WR
)
219 c
->options
|= MIPS_CPU_WATCH
;
220 if (config1
& MIPS_CONF1_CA
)
221 c
->ases
|= MIPS_ASE_MIPS16
;
222 if (config1
& MIPS_CONF1_EP
)
223 c
->options
|= MIPS_CPU_EJTAG
;
224 if (config1
& MIPS_CONF1_FP
) {
225 c
->options
|= MIPS_CPU_FPU
;
226 c
->options
|= MIPS_CPU_32FPR
;
229 c
->tlbsize
= ((config1
& MIPS_CONF1_TLBS
) >> 25) + 1;
231 return config1
& MIPS_CONF_M
;
234 static inline unsigned int decode_config2(struct cpuinfo_mips
*c
)
236 unsigned int config2
;
238 config2
= read_c0_config2();
240 if (config2
& MIPS_CONF2_SL
)
241 c
->scache
.flags
&= ~MIPS_CACHE_NOT_PRESENT
;
243 return config2
& MIPS_CONF_M
;
246 static inline unsigned int decode_config3(struct cpuinfo_mips
*c
)
248 unsigned int config3
;
250 config3
= read_c0_config3();
252 if (config3
& MIPS_CONF3_SM
) {
253 c
->ases
|= MIPS_ASE_SMARTMIPS
;
254 c
->options
|= MIPS_CPU_RIXI
;
256 if (config3
& MIPS_CONF3_RXI
)
257 c
->options
|= MIPS_CPU_RIXI
;
258 if (config3
& MIPS_CONF3_DSP
)
259 c
->ases
|= MIPS_ASE_DSP
;
260 if (config3
& MIPS_CONF3_DSP2P
)
261 c
->ases
|= MIPS_ASE_DSP2P
;
262 if (config3
& MIPS_CONF3_VINT
)
263 c
->options
|= MIPS_CPU_VINT
;
264 if (config3
& MIPS_CONF3_VEIC
)
265 c
->options
|= MIPS_CPU_VEIC
;
266 if (config3
& MIPS_CONF3_MT
)
267 c
->ases
|= MIPS_ASE_MIPSMT
;
268 if (config3
& MIPS_CONF3_ULRI
)
269 c
->options
|= MIPS_CPU_ULRI
;
270 if (config3
& MIPS_CONF3_ISA
)
271 c
->options
|= MIPS_CPU_MICROMIPS
;
272 if (config3
& MIPS_CONF3_VZ
)
273 c
->ases
|= MIPS_ASE_VZ
;
275 return config3
& MIPS_CONF_M
;
278 static inline unsigned int decode_config4(struct cpuinfo_mips
*c
)
280 unsigned int config4
;
282 config4
= read_c0_config4();
284 if ((config4
& MIPS_CONF4_MMUEXTDEF
) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
286 c
->tlbsize
+= (config4
& MIPS_CONF4_MMUSIZEEXT
) * 0x40;
288 c
->kscratch_mask
= (config4
>> 16) & 0xff;
290 return config4
& MIPS_CONF_M
;
293 static void decode_configs(struct cpuinfo_mips
*c
)
297 /* MIPS32 or MIPS64 compliant CPU. */
298 c
->options
= MIPS_CPU_4KEX
| MIPS_CPU_4K_CACHE
| MIPS_CPU_COUNTER
|
299 MIPS_CPU_DIVEC
| MIPS_CPU_LLSC
| MIPS_CPU_MCHECK
;
301 c
->scache
.flags
= MIPS_CACHE_NOT_PRESENT
;
303 ok
= decode_config0(c
); /* Read Config registers. */
304 BUG_ON(!ok
); /* Arch spec violation! */
306 ok
= decode_config1(c
);
308 ok
= decode_config2(c
);
310 ok
= decode_config3(c
);
312 ok
= decode_config4(c
);
314 mips_probe_watch_registers(c
);
317 c
->core
= read_c0_ebase() & 0x3ff;
320 #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
323 static inline void cpu_probe_legacy(struct cpuinfo_mips
*c
, unsigned int cpu
)
325 switch (c
->processor_id
& 0xff00) {
327 c
->cputype
= CPU_R2000
;
328 __cpu_name
[cpu
] = "R2000";
329 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_3K_CACHE
|
332 c
->options
|= MIPS_CPU_FPU
;
336 if ((c
->processor_id
& 0xff) == PRID_REV_R3000A
) {
337 if (cpu_has_confreg()) {
338 c
->cputype
= CPU_R3081E
;
339 __cpu_name
[cpu
] = "R3081";
341 c
->cputype
= CPU_R3000A
;
342 __cpu_name
[cpu
] = "R3000A";
345 c
->cputype
= CPU_R3000
;
346 __cpu_name
[cpu
] = "R3000";
348 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_3K_CACHE
|
351 c
->options
|= MIPS_CPU_FPU
;
355 if (read_c0_config() & CONF_SC
) {
356 if ((c
->processor_id
& 0xff) >= PRID_REV_R4400
) {
357 c
->cputype
= CPU_R4400PC
;
358 __cpu_name
[cpu
] = "R4400PC";
360 c
->cputype
= CPU_R4000PC
;
361 __cpu_name
[cpu
] = "R4000PC";
364 if ((c
->processor_id
& 0xff) >= PRID_REV_R4400
) {
365 c
->cputype
= CPU_R4400SC
;
366 __cpu_name
[cpu
] = "R4400SC";
368 c
->cputype
= CPU_R4000SC
;
369 __cpu_name
[cpu
] = "R4000SC";
373 set_isa(c
, MIPS_CPU_ISA_III
);
374 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
375 MIPS_CPU_WATCH
| MIPS_CPU_VCE
|
379 case PRID_IMP_VR41XX
:
380 set_isa(c
, MIPS_CPU_ISA_III
);
381 c
->options
= R4K_OPTS
;
383 switch (c
->processor_id
& 0xf0) {
384 case PRID_REV_VR4111
:
385 c
->cputype
= CPU_VR4111
;
386 __cpu_name
[cpu
] = "NEC VR4111";
388 case PRID_REV_VR4121
:
389 c
->cputype
= CPU_VR4121
;
390 __cpu_name
[cpu
] = "NEC VR4121";
392 case PRID_REV_VR4122
:
393 if ((c
->processor_id
& 0xf) < 0x3) {
394 c
->cputype
= CPU_VR4122
;
395 __cpu_name
[cpu
] = "NEC VR4122";
397 c
->cputype
= CPU_VR4181A
;
398 __cpu_name
[cpu
] = "NEC VR4181A";
401 case PRID_REV_VR4130
:
402 if ((c
->processor_id
& 0xf) < 0x4) {
403 c
->cputype
= CPU_VR4131
;
404 __cpu_name
[cpu
] = "NEC VR4131";
406 c
->cputype
= CPU_VR4133
;
407 c
->options
|= MIPS_CPU_LLSC
;
408 __cpu_name
[cpu
] = "NEC VR4133";
412 printk(KERN_INFO
"Unexpected CPU of NEC VR4100 series\n");
413 c
->cputype
= CPU_VR41XX
;
414 __cpu_name
[cpu
] = "NEC Vr41xx";
419 c
->cputype
= CPU_R4300
;
420 __cpu_name
[cpu
] = "R4300";
421 set_isa(c
, MIPS_CPU_ISA_III
);
422 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
427 c
->cputype
= CPU_R4600
;
428 __cpu_name
[cpu
] = "R4600";
429 set_isa(c
, MIPS_CPU_ISA_III
);
430 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
437 * This processor doesn't have an MMU, so it's not
438 * "real easy" to run Linux on it. It is left purely
439 * for documentation. Commented out because it shares
440 * it's c0_prid id number with the TX3900.
442 c
->cputype
= CPU_R4650
;
443 __cpu_name
[cpu
] = "R4650";
444 set_isa(c
, MIPS_CPU_ISA_III
);
445 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_LLSC
;
450 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_TX39_CACHE
;
452 if ((c
->processor_id
& 0xf0) == (PRID_REV_TX3927
& 0xf0)) {
453 c
->cputype
= CPU_TX3927
;
454 __cpu_name
[cpu
] = "TX3927";
457 switch (c
->processor_id
& 0xff) {
458 case PRID_REV_TX3912
:
459 c
->cputype
= CPU_TX3912
;
460 __cpu_name
[cpu
] = "TX3912";
463 case PRID_REV_TX3922
:
464 c
->cputype
= CPU_TX3922
;
465 __cpu_name
[cpu
] = "TX3922";
472 c
->cputype
= CPU_R4700
;
473 __cpu_name
[cpu
] = "R4700";
474 set_isa(c
, MIPS_CPU_ISA_III
);
475 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
480 c
->cputype
= CPU_TX49XX
;
481 __cpu_name
[cpu
] = "R49XX";
482 set_isa(c
, MIPS_CPU_ISA_III
);
483 c
->options
= R4K_OPTS
| MIPS_CPU_LLSC
;
484 if (!(c
->processor_id
& 0x08))
485 c
->options
|= MIPS_CPU_FPU
| MIPS_CPU_32FPR
;
489 c
->cputype
= CPU_R5000
;
490 __cpu_name
[cpu
] = "R5000";
491 set_isa(c
, MIPS_CPU_ISA_IV
);
492 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
497 c
->cputype
= CPU_R5432
;
498 __cpu_name
[cpu
] = "R5432";
499 set_isa(c
, MIPS_CPU_ISA_IV
);
500 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
501 MIPS_CPU_WATCH
| MIPS_CPU_LLSC
;
505 c
->cputype
= CPU_R5500
;
506 __cpu_name
[cpu
] = "R5500";
507 set_isa(c
, MIPS_CPU_ISA_IV
);
508 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
509 MIPS_CPU_WATCH
| MIPS_CPU_LLSC
;
512 case PRID_IMP_NEVADA
:
513 c
->cputype
= CPU_NEVADA
;
514 __cpu_name
[cpu
] = "Nevada";
515 set_isa(c
, MIPS_CPU_ISA_IV
);
516 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
517 MIPS_CPU_DIVEC
| MIPS_CPU_LLSC
;
521 c
->cputype
= CPU_R6000
;
522 __cpu_name
[cpu
] = "R6000";
523 set_isa(c
, MIPS_CPU_ISA_II
);
524 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_FPU
|
528 case PRID_IMP_R6000A
:
529 c
->cputype
= CPU_R6000A
;
530 __cpu_name
[cpu
] = "R6000A";
531 set_isa(c
, MIPS_CPU_ISA_II
);
532 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_FPU
|
536 case PRID_IMP_RM7000
:
537 c
->cputype
= CPU_RM7000
;
538 __cpu_name
[cpu
] = "RM7000";
539 set_isa(c
, MIPS_CPU_ISA_IV
);
540 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
543 * Undocumented RM7000: Bit 29 in the info register of
544 * the RM7000 v2.0 indicates if the TLB has 48 or 64
547 * 29 1 => 64 entry JTLB
550 c
->tlbsize
= (read_c0_info() & (1 << 29)) ? 64 : 48;
552 case PRID_IMP_RM9000
:
553 c
->cputype
= CPU_RM9000
;
554 __cpu_name
[cpu
] = "RM9000";
555 set_isa(c
, MIPS_CPU_ISA_IV
);
556 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
559 * Bit 29 in the info register of the RM9000
560 * indicates if the TLB has 48 or 64 entries.
562 * 29 1 => 64 entry JTLB
565 c
->tlbsize
= (read_c0_info() & (1 << 29)) ? 64 : 48;
568 c
->cputype
= CPU_R8000
;
569 __cpu_name
[cpu
] = "RM8000";
570 set_isa(c
, MIPS_CPU_ISA_IV
);
571 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4KEX
|
572 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
574 c
->tlbsize
= 384; /* has weird TLB: 3-way x 128 */
576 case PRID_IMP_R10000
:
577 c
->cputype
= CPU_R10000
;
578 __cpu_name
[cpu
] = "R10000";
579 set_isa(c
, MIPS_CPU_ISA_IV
);
580 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4K_CACHE
| MIPS_CPU_4KEX
|
581 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
582 MIPS_CPU_COUNTER
| MIPS_CPU_WATCH
|
586 case PRID_IMP_R12000
:
587 c
->cputype
= CPU_R12000
;
588 __cpu_name
[cpu
] = "R12000";
589 set_isa(c
, MIPS_CPU_ISA_IV
);
590 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4K_CACHE
| MIPS_CPU_4KEX
|
591 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
592 MIPS_CPU_COUNTER
| MIPS_CPU_WATCH
|
596 case PRID_IMP_R14000
:
597 c
->cputype
= CPU_R14000
;
598 __cpu_name
[cpu
] = "R14000";
599 set_isa(c
, MIPS_CPU_ISA_IV
);
600 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4K_CACHE
| MIPS_CPU_4KEX
|
601 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
602 MIPS_CPU_COUNTER
| MIPS_CPU_WATCH
|
606 case PRID_IMP_LOONGSON2
:
607 c
->cputype
= CPU_LOONGSON2
;
608 __cpu_name
[cpu
] = "ICT Loongson-2";
610 switch (c
->processor_id
& PRID_REV_MASK
) {
611 case PRID_REV_LOONGSON2E
:
612 set_elf_platform(cpu
, "loongson2e");
614 case PRID_REV_LOONGSON2F
:
615 set_elf_platform(cpu
, "loongson2f");
619 set_isa(c
, MIPS_CPU_ISA_III
);
620 c
->options
= R4K_OPTS
|
621 MIPS_CPU_FPU
| MIPS_CPU_LLSC
|
625 case PRID_IMP_LOONGSON1
:
628 c
->cputype
= CPU_LOONGSON1
;
630 switch (c
->processor_id
& PRID_REV_MASK
) {
631 case PRID_REV_LOONGSON1B
:
632 __cpu_name
[cpu
] = "Loongson 1B";
640 static inline void cpu_probe_mips(struct cpuinfo_mips
*c
, unsigned int cpu
)
643 switch (c
->processor_id
& 0xff00) {
645 c
->cputype
= CPU_4KC
;
646 __cpu_name
[cpu
] = "MIPS 4Kc";
649 case PRID_IMP_4KECR2
:
650 c
->cputype
= CPU_4KEC
;
651 __cpu_name
[cpu
] = "MIPS 4KEc";
655 c
->cputype
= CPU_4KSC
;
656 __cpu_name
[cpu
] = "MIPS 4KSc";
659 c
->cputype
= CPU_5KC
;
660 __cpu_name
[cpu
] = "MIPS 5Kc";
663 c
->cputype
= CPU_5KE
;
664 __cpu_name
[cpu
] = "MIPS 5KE";
667 c
->cputype
= CPU_20KC
;
668 __cpu_name
[cpu
] = "MIPS 20Kc";
671 c
->cputype
= CPU_24K
;
672 __cpu_name
[cpu
] = "MIPS 24Kc";
675 c
->cputype
= CPU_24K
;
676 __cpu_name
[cpu
] = "MIPS 24KEc";
679 c
->cputype
= CPU_25KF
;
680 __cpu_name
[cpu
] = "MIPS 25Kc";
683 c
->cputype
= CPU_34K
;
684 __cpu_name
[cpu
] = "MIPS 34Kc";
687 c
->cputype
= CPU_74K
;
688 __cpu_name
[cpu
] = "MIPS 74Kc";
691 c
->cputype
= CPU_M14KC
;
692 __cpu_name
[cpu
] = "MIPS M14Kc";
694 case PRID_IMP_M14KEC
:
695 c
->cputype
= CPU_M14KEC
;
696 __cpu_name
[cpu
] = "MIPS M14KEc";
699 c
->cputype
= CPU_1004K
;
700 __cpu_name
[cpu
] = "MIPS 1004Kc";
703 c
->cputype
= CPU_74K
;
704 __cpu_name
[cpu
] = "MIPS 1074Kc";
711 static inline void cpu_probe_alchemy(struct cpuinfo_mips
*c
, unsigned int cpu
)
714 switch (c
->processor_id
& 0xff00) {
715 case PRID_IMP_AU1_REV1
:
716 case PRID_IMP_AU1_REV2
:
717 c
->cputype
= CPU_ALCHEMY
;
718 switch ((c
->processor_id
>> 24) & 0xff) {
720 __cpu_name
[cpu
] = "Au1000";
723 __cpu_name
[cpu
] = "Au1500";
726 __cpu_name
[cpu
] = "Au1100";
729 __cpu_name
[cpu
] = "Au1550";
732 __cpu_name
[cpu
] = "Au1200";
733 if ((c
->processor_id
& 0xff) == 2)
734 __cpu_name
[cpu
] = "Au1250";
737 __cpu_name
[cpu
] = "Au1210";
740 __cpu_name
[cpu
] = "Au1xxx";
747 static inline void cpu_probe_sibyte(struct cpuinfo_mips
*c
, unsigned int cpu
)
751 switch (c
->processor_id
& 0xff00) {
753 c
->cputype
= CPU_SB1
;
754 __cpu_name
[cpu
] = "SiByte SB1";
755 /* FPU in pass1 is known to have issues. */
756 if ((c
->processor_id
& 0xff) < 0x02)
757 c
->options
&= ~(MIPS_CPU_FPU
| MIPS_CPU_32FPR
);
760 c
->cputype
= CPU_SB1A
;
761 __cpu_name
[cpu
] = "SiByte SB1A";
766 static inline void cpu_probe_sandcraft(struct cpuinfo_mips
*c
, unsigned int cpu
)
769 switch (c
->processor_id
& 0xff00) {
770 case PRID_IMP_SR71000
:
771 c
->cputype
= CPU_SR71000
;
772 __cpu_name
[cpu
] = "Sandcraft SR71000";
779 static inline void cpu_probe_nxp(struct cpuinfo_mips
*c
, unsigned int cpu
)
782 switch (c
->processor_id
& 0xff00) {
783 case PRID_IMP_PR4450
:
784 c
->cputype
= CPU_PR4450
;
785 __cpu_name
[cpu
] = "Philips PR4450";
786 set_isa(c
, MIPS_CPU_ISA_M32R1
);
791 static inline void cpu_probe_broadcom(struct cpuinfo_mips
*c
, unsigned int cpu
)
794 switch (c
->processor_id
& 0xff00) {
795 case PRID_IMP_BMIPS32_REV4
:
796 case PRID_IMP_BMIPS32_REV8
:
797 c
->cputype
= CPU_BMIPS32
;
798 __cpu_name
[cpu
] = "Broadcom BMIPS32";
799 set_elf_platform(cpu
, "bmips32");
801 case PRID_IMP_BMIPS3300
:
802 case PRID_IMP_BMIPS3300_ALT
:
803 case PRID_IMP_BMIPS3300_BUG
:
804 c
->cputype
= CPU_BMIPS3300
;
805 __cpu_name
[cpu
] = "Broadcom BMIPS3300";
806 set_elf_platform(cpu
, "bmips3300");
808 case PRID_IMP_BMIPS43XX
: {
809 int rev
= c
->processor_id
& 0xff;
811 if (rev
>= PRID_REV_BMIPS4380_LO
&&
812 rev
<= PRID_REV_BMIPS4380_HI
) {
813 c
->cputype
= CPU_BMIPS4380
;
814 __cpu_name
[cpu
] = "Broadcom BMIPS4380";
815 set_elf_platform(cpu
, "bmips4380");
817 c
->cputype
= CPU_BMIPS4350
;
818 __cpu_name
[cpu
] = "Broadcom BMIPS4350";
819 set_elf_platform(cpu
, "bmips4350");
823 case PRID_IMP_BMIPS5000
:
824 c
->cputype
= CPU_BMIPS5000
;
825 __cpu_name
[cpu
] = "Broadcom BMIPS5000";
826 set_elf_platform(cpu
, "bmips5000");
827 c
->options
|= MIPS_CPU_ULRI
;
832 static inline void cpu_probe_cavium(struct cpuinfo_mips
*c
, unsigned int cpu
)
835 switch (c
->processor_id
& 0xff00) {
836 case PRID_IMP_CAVIUM_CN38XX
:
837 case PRID_IMP_CAVIUM_CN31XX
:
838 case PRID_IMP_CAVIUM_CN30XX
:
839 c
->cputype
= CPU_CAVIUM_OCTEON
;
840 __cpu_name
[cpu
] = "Cavium Octeon";
842 case PRID_IMP_CAVIUM_CN58XX
:
843 case PRID_IMP_CAVIUM_CN56XX
:
844 case PRID_IMP_CAVIUM_CN50XX
:
845 case PRID_IMP_CAVIUM_CN52XX
:
846 c
->cputype
= CPU_CAVIUM_OCTEON_PLUS
;
847 __cpu_name
[cpu
] = "Cavium Octeon+";
849 set_elf_platform(cpu
, "octeon");
851 case PRID_IMP_CAVIUM_CN61XX
:
852 case PRID_IMP_CAVIUM_CN63XX
:
853 case PRID_IMP_CAVIUM_CN66XX
:
854 case PRID_IMP_CAVIUM_CN68XX
:
855 c
->cputype
= CPU_CAVIUM_OCTEON2
;
856 __cpu_name
[cpu
] = "Cavium Octeon II";
857 set_elf_platform(cpu
, "octeon2");
860 printk(KERN_INFO
"Unknown Octeon chip!\n");
861 c
->cputype
= CPU_UNKNOWN
;
866 static inline void cpu_probe_ingenic(struct cpuinfo_mips
*c
, unsigned int cpu
)
869 /* JZRISC does not implement the CP0 counter. */
870 c
->options
&= ~MIPS_CPU_COUNTER
;
871 switch (c
->processor_id
& 0xff00) {
872 case PRID_IMP_JZRISC
:
873 c
->cputype
= CPU_JZRISC
;
874 __cpu_name
[cpu
] = "Ingenic JZRISC";
877 panic("Unknown Ingenic Processor ID!");
882 static inline void cpu_probe_netlogic(struct cpuinfo_mips
*c
, int cpu
)
886 if ((c
->processor_id
& 0xff00) == PRID_IMP_NETLOGIC_AU13XX
) {
887 c
->cputype
= CPU_ALCHEMY
;
888 __cpu_name
[cpu
] = "Au1300";
889 /* following stuff is not for Alchemy */
893 c
->options
= (MIPS_CPU_TLB
|
901 switch (c
->processor_id
& 0xff00) {
902 case PRID_IMP_NETLOGIC_XLP8XX
:
903 case PRID_IMP_NETLOGIC_XLP3XX
:
904 c
->cputype
= CPU_XLP
;
905 __cpu_name
[cpu
] = "Netlogic XLP";
908 case PRID_IMP_NETLOGIC_XLR732
:
909 case PRID_IMP_NETLOGIC_XLR716
:
910 case PRID_IMP_NETLOGIC_XLR532
:
911 case PRID_IMP_NETLOGIC_XLR308
:
912 case PRID_IMP_NETLOGIC_XLR532C
:
913 case PRID_IMP_NETLOGIC_XLR516C
:
914 case PRID_IMP_NETLOGIC_XLR508C
:
915 case PRID_IMP_NETLOGIC_XLR308C
:
916 c
->cputype
= CPU_XLR
;
917 __cpu_name
[cpu
] = "Netlogic XLR";
920 case PRID_IMP_NETLOGIC_XLS608
:
921 case PRID_IMP_NETLOGIC_XLS408
:
922 case PRID_IMP_NETLOGIC_XLS404
:
923 case PRID_IMP_NETLOGIC_XLS208
:
924 case PRID_IMP_NETLOGIC_XLS204
:
925 case PRID_IMP_NETLOGIC_XLS108
:
926 case PRID_IMP_NETLOGIC_XLS104
:
927 case PRID_IMP_NETLOGIC_XLS616B
:
928 case PRID_IMP_NETLOGIC_XLS608B
:
929 case PRID_IMP_NETLOGIC_XLS416B
:
930 case PRID_IMP_NETLOGIC_XLS412B
:
931 case PRID_IMP_NETLOGIC_XLS408B
:
932 case PRID_IMP_NETLOGIC_XLS404B
:
933 c
->cputype
= CPU_XLR
;
934 __cpu_name
[cpu
] = "Netlogic XLS";
938 pr_info("Unknown Netlogic chip id [%02x]!\n",
940 c
->cputype
= CPU_XLR
;
944 if (c
->cputype
== CPU_XLP
) {
945 set_isa(c
, MIPS_CPU_ISA_M64R2
);
946 c
->options
|= (MIPS_CPU_FPU
| MIPS_CPU_ULRI
| MIPS_CPU_MCHECK
);
947 /* This will be updated again after all threads are woken up */
948 c
->tlbsize
= ((read_c0_config6() >> 16) & 0xffff) + 1;
950 set_isa(c
, MIPS_CPU_ISA_M64R1
);
951 c
->tlbsize
= ((read_c0_config1() >> 25) & 0x3f) + 1;
953 c
->kscratch_mask
= 0xf;
957 /* For use by uaccess.h */
959 EXPORT_SYMBOL(__ua_limit
);
962 const char *__cpu_name
[NR_CPUS
];
963 const char *__elf_platform
;
967 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
968 unsigned int cpu
= smp_processor_id();
970 c
->processor_id
= PRID_IMP_UNKNOWN
;
971 c
->fpu_id
= FPIR_IMP_NONE
;
972 c
->cputype
= CPU_UNKNOWN
;
974 c
->processor_id
= read_c0_prid();
975 switch (c
->processor_id
& 0xff0000) {
976 case PRID_COMP_LEGACY
:
977 cpu_probe_legacy(c
, cpu
);
980 cpu_probe_mips(c
, cpu
);
982 case PRID_COMP_ALCHEMY
:
983 cpu_probe_alchemy(c
, cpu
);
985 case PRID_COMP_SIBYTE
:
986 cpu_probe_sibyte(c
, cpu
);
988 case PRID_COMP_BROADCOM
:
989 cpu_probe_broadcom(c
, cpu
);
991 case PRID_COMP_SANDCRAFT
:
992 cpu_probe_sandcraft(c
, cpu
);
995 cpu_probe_nxp(c
, cpu
);
997 case PRID_COMP_CAVIUM
:
998 cpu_probe_cavium(c
, cpu
);
1000 case PRID_COMP_INGENIC
:
1001 cpu_probe_ingenic(c
, cpu
);
1003 case PRID_COMP_NETLOGIC
:
1004 cpu_probe_netlogic(c
, cpu
);
1008 BUG_ON(!__cpu_name
[cpu
]);
1009 BUG_ON(c
->cputype
== CPU_UNKNOWN
);
1012 * Platform code can force the cpu type to optimize code
1013 * generation. In that case be sure the cpu type is correctly
1014 * manually setup otherwise it could trigger some nasty bugs.
1016 BUG_ON(current_cpu_type() != c
->cputype
);
1018 if (mips_fpu_disabled
)
1019 c
->options
&= ~MIPS_CPU_FPU
;
1021 if (mips_dsp_disabled
)
1022 c
->ases
&= ~(MIPS_ASE_DSP
| MIPS_ASE_DSP2P
);
1024 if (c
->options
& MIPS_CPU_FPU
) {
1025 c
->fpu_id
= cpu_get_fpu_id();
1027 if (c
->isa_level
& (MIPS_CPU_ISA_M32R1
| MIPS_CPU_ISA_M32R2
|
1028 MIPS_CPU_ISA_M64R1
| MIPS_CPU_ISA_M64R2
)) {
1029 if (c
->fpu_id
& MIPS_FPIR_3D
)
1030 c
->ases
|= MIPS_ASE_MIPS3D
;
1034 if (cpu_has_mips_r2
) {
1035 c
->srsets
= ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1036 /* R2 has Performance Counter Interrupt indicator */
1037 c
->options
|= MIPS_CPU_PCI
;
1042 cpu_probe_vmbits(c
);
1046 __ua_limit
= ~((1ull << cpu_vmbits
) - 1);
1050 void cpu_report(void)
1052 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
1054 printk(KERN_INFO
"CPU revision is: %08x (%s)\n",
1055 c
->processor_id
, cpu_name_string());
1056 if (c
->options
& MIPS_CPU_FPU
)
1057 printk(KERN_INFO
"FPU revision is: %08x\n", c
->fpu_id
);