2 * Processor capabilities determination functions.
4 * Copyright (C) xxxx the Anonymous
5 * Copyright (C) 1994 - 2006 Ralf Baechle
6 * Copyright (C) 2003, 2004 Maciej W. Rozycki
7 * Copyright (C) 2001, 2004 MIPS Inc.
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
14 #include <linux/init.h>
15 #include <linux/kernel.h>
16 #include <linux/ptrace.h>
17 #include <linux/stddef.h>
22 #include <asm/mipsregs.h>
23 #include <asm/system.h>
26 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
27 * the implementation of the "wait" feature differs between CPU families. This
28 * points to the function that implements CPU specific wait.
29 * The wait instruction stops the pipeline and reduces the power consumption of
32 void (*cpu_wait
)(void) = NULL
;
34 static void r3081_wait(void)
36 unsigned long cfg
= read_c0_conf();
37 write_c0_conf(cfg
| R30XX_CONF_HALT
);
40 static void r39xx_wait(void)
44 write_c0_conf(read_c0_conf() | TX39_CONF_HALT
);
49 * There is a race when WAIT instruction executed with interrupt
51 * But it is implementation-dependent wheter the pipelie restarts when
52 * a non-enabled interrupt is requested.
54 static void r4k_wait(void)
56 __asm__(" .set mips3 \n"
62 * This variant is preferable as it allows testing need_resched and going to
63 * sleep depending on the outcome atomically. Unfortunately the "It is
64 * implementation-dependent whether the pipeline restarts when a non-enabled
65 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
66 * using this version a gamble.
68 static void r4k_wait_irqoff(void)
72 __asm__(" .set mips3 \n"
78 /* The Au1xxx wait is available only if using 32khz counter or
79 * external timer source, but specifically not CP0 Counter. */
82 static void au1k_wait(void)
84 /* using the wait instruction makes CP0 counter unusable */
85 __asm__(" .set mips3 \n"
86 " cache 0x14, 0(%0) \n"
87 " cache 0x14, 32(%0) \n"
99 static int __initdata nowait
= 0;
101 static int __init
wait_disable(char *s
)
108 __setup("nowait", wait_disable
);
110 static inline void check_wait(void)
112 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
115 printk("Wait instruction disabled.\n");
119 switch (c
->cputype
) {
122 cpu_wait
= r3081_wait
;
125 cpu_wait
= r39xx_wait
;
128 /* case CPU_R4300: */
148 if (read_c0_config7() & MIPS_CONF7_WII
)
149 cpu_wait
= r4k_wait_irqoff
;
154 if ((c
->processor_id
& 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
155 cpu_wait
= r4k_wait_irqoff
;
159 cpu_wait
= r4k_wait_irqoff
;
167 cpu_wait
= au1k_wait
;
171 * WAIT on Rev1.0 has E1, E2, E3 and E16.
172 * WAIT on Rev2.0 and Rev3.0 has E16.
173 * Rev3.1 WAIT is nop, why bother
175 if ((c
->processor_id
& 0xff) <= 0x64)
181 if ((c
->processor_id
& 0x00ff) >= 0x40)
189 static inline void check_errata(void)
191 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
193 switch (c
->cputype
) {
196 * Erratum "RPS May Cause Incorrect Instruction Execution"
197 * This code only handles VPE0, any SMP/SMTC/RTOS code
198 * making use of VPE1 will be responsable for that VPE.
200 if ((c
->processor_id
& PRID_REV_MASK
) <= PRID_REV_34K_V1_0_2
)
201 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS
);
208 void __init
check_bugs32(void)
215 * Probe whether cpu has config register by trying to play with
216 * alternate cache bit and see whether it matters.
217 * It's used by cpu_probe to distinguish between R3000A and R3081.
219 static inline int cpu_has_confreg(void)
221 #ifdef CONFIG_CPU_R3000
222 extern unsigned long r3k_cache_size(unsigned long);
223 unsigned long size1
, size2
;
224 unsigned long cfg
= read_c0_conf();
226 size1
= r3k_cache_size(ST0_ISC
);
227 write_c0_conf(cfg
^ R30XX_CONF_AC
);
228 size2
= r3k_cache_size(ST0_ISC
);
230 return size1
!= size2
;
237 * Get the FPU Implementation/Revision.
239 static inline unsigned long cpu_get_fpu_id(void)
241 unsigned long tmp
, fpu_id
;
243 tmp
= read_c0_status();
245 fpu_id
= read_32bit_cp1_register(CP1_REVISION
);
246 write_c0_status(tmp
);
251 * Check the CPU has an FPU the official way.
253 static inline int __cpu_has_fpu(void)
255 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE
);
258 #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
261 static inline void cpu_probe_legacy(struct cpuinfo_mips
*c
)
263 switch (c
->processor_id
& 0xff00) {
265 c
->cputype
= CPU_R2000
;
266 c
->isa_level
= MIPS_CPU_ISA_I
;
267 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_3K_CACHE
|
270 c
->options
|= MIPS_CPU_FPU
;
274 if ((c
->processor_id
& 0xff) == PRID_REV_R3000A
)
275 if (cpu_has_confreg())
276 c
->cputype
= CPU_R3081E
;
278 c
->cputype
= CPU_R3000A
;
280 c
->cputype
= CPU_R3000
;
281 c
->isa_level
= MIPS_CPU_ISA_I
;
282 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_3K_CACHE
|
285 c
->options
|= MIPS_CPU_FPU
;
289 if (read_c0_config() & CONF_SC
) {
290 if ((c
->processor_id
& 0xff) >= PRID_REV_R4400
)
291 c
->cputype
= CPU_R4400PC
;
293 c
->cputype
= CPU_R4000PC
;
295 if ((c
->processor_id
& 0xff) >= PRID_REV_R4400
)
296 c
->cputype
= CPU_R4400SC
;
298 c
->cputype
= CPU_R4000SC
;
301 c
->isa_level
= MIPS_CPU_ISA_III
;
302 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
303 MIPS_CPU_WATCH
| MIPS_CPU_VCE
|
307 case PRID_IMP_VR41XX
:
308 switch (c
->processor_id
& 0xf0) {
309 case PRID_REV_VR4111
:
310 c
->cputype
= CPU_VR4111
;
312 case PRID_REV_VR4121
:
313 c
->cputype
= CPU_VR4121
;
315 case PRID_REV_VR4122
:
316 if ((c
->processor_id
& 0xf) < 0x3)
317 c
->cputype
= CPU_VR4122
;
319 c
->cputype
= CPU_VR4181A
;
321 case PRID_REV_VR4130
:
322 if ((c
->processor_id
& 0xf) < 0x4)
323 c
->cputype
= CPU_VR4131
;
325 c
->cputype
= CPU_VR4133
;
328 printk(KERN_INFO
"Unexpected CPU of NEC VR4100 series\n");
329 c
->cputype
= CPU_VR41XX
;
332 c
->isa_level
= MIPS_CPU_ISA_III
;
333 c
->options
= R4K_OPTS
;
337 c
->cputype
= CPU_R4300
;
338 c
->isa_level
= MIPS_CPU_ISA_III
;
339 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
344 c
->cputype
= CPU_R4600
;
345 c
->isa_level
= MIPS_CPU_ISA_III
;
346 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
353 * This processor doesn't have an MMU, so it's not
354 * "real easy" to run Linux on it. It is left purely
355 * for documentation. Commented out because it shares
356 * it's c0_prid id number with the TX3900.
358 c
->cputype
= CPU_R4650
;
359 c
->isa_level
= MIPS_CPU_ISA_III
;
360 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_LLSC
;
365 c
->isa_level
= MIPS_CPU_ISA_I
;
366 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_TX39_CACHE
;
368 if ((c
->processor_id
& 0xf0) == (PRID_REV_TX3927
& 0xf0)) {
369 c
->cputype
= CPU_TX3927
;
372 switch (c
->processor_id
& 0xff) {
373 case PRID_REV_TX3912
:
374 c
->cputype
= CPU_TX3912
;
377 case PRID_REV_TX3922
:
378 c
->cputype
= CPU_TX3922
;
382 c
->cputype
= CPU_UNKNOWN
;
388 c
->cputype
= CPU_R4700
;
389 c
->isa_level
= MIPS_CPU_ISA_III
;
390 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
395 c
->cputype
= CPU_TX49XX
;
396 c
->isa_level
= MIPS_CPU_ISA_III
;
397 c
->options
= R4K_OPTS
| MIPS_CPU_LLSC
;
398 if (!(c
->processor_id
& 0x08))
399 c
->options
|= MIPS_CPU_FPU
| MIPS_CPU_32FPR
;
403 c
->cputype
= CPU_R5000
;
404 c
->isa_level
= MIPS_CPU_ISA_IV
;
405 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
410 c
->cputype
= CPU_R5432
;
411 c
->isa_level
= MIPS_CPU_ISA_IV
;
412 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
413 MIPS_CPU_WATCH
| MIPS_CPU_LLSC
;
417 c
->cputype
= CPU_R5500
;
418 c
->isa_level
= MIPS_CPU_ISA_IV
;
419 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
420 MIPS_CPU_WATCH
| MIPS_CPU_LLSC
;
423 case PRID_IMP_NEVADA
:
424 c
->cputype
= CPU_NEVADA
;
425 c
->isa_level
= MIPS_CPU_ISA_IV
;
426 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
427 MIPS_CPU_DIVEC
| MIPS_CPU_LLSC
;
431 c
->cputype
= CPU_R6000
;
432 c
->isa_level
= MIPS_CPU_ISA_II
;
433 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_FPU
|
437 case PRID_IMP_R6000A
:
438 c
->cputype
= CPU_R6000A
;
439 c
->isa_level
= MIPS_CPU_ISA_II
;
440 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_FPU
|
444 case PRID_IMP_RM7000
:
445 c
->cputype
= CPU_RM7000
;
446 c
->isa_level
= MIPS_CPU_ISA_IV
;
447 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
450 * Undocumented RM7000: Bit 29 in the info register of
451 * the RM7000 v2.0 indicates if the TLB has 48 or 64
454 * 29 1 => 64 entry JTLB
457 c
->tlbsize
= (read_c0_info() & (1 << 29)) ? 64 : 48;
459 case PRID_IMP_RM9000
:
460 c
->cputype
= CPU_RM9000
;
461 c
->isa_level
= MIPS_CPU_ISA_IV
;
462 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
465 * Bit 29 in the info register of the RM9000
466 * indicates if the TLB has 48 or 64 entries.
468 * 29 1 => 64 entry JTLB
471 c
->tlbsize
= (read_c0_info() & (1 << 29)) ? 64 : 48;
474 c
->cputype
= CPU_R8000
;
475 c
->isa_level
= MIPS_CPU_ISA_IV
;
476 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4KEX
|
477 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
479 c
->tlbsize
= 384; /* has weird TLB: 3-way x 128 */
481 case PRID_IMP_R10000
:
482 c
->cputype
= CPU_R10000
;
483 c
->isa_level
= MIPS_CPU_ISA_IV
;
484 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4K_CACHE
| MIPS_CPU_4KEX
|
485 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
486 MIPS_CPU_COUNTER
| MIPS_CPU_WATCH
|
490 case PRID_IMP_R12000
:
491 c
->cputype
= CPU_R12000
;
492 c
->isa_level
= MIPS_CPU_ISA_IV
;
493 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4K_CACHE
| MIPS_CPU_4KEX
|
494 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
495 MIPS_CPU_COUNTER
| MIPS_CPU_WATCH
|
499 case PRID_IMP_R14000
:
500 c
->cputype
= CPU_R14000
;
501 c
->isa_level
= MIPS_CPU_ISA_IV
;
502 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4K_CACHE
| MIPS_CPU_4KEX
|
503 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
504 MIPS_CPU_COUNTER
| MIPS_CPU_WATCH
|
508 case PRID_IMP_LOONGSON2
:
509 c
->cputype
= CPU_LOONGSON2
;
510 c
->isa_level
= MIPS_CPU_ISA_III
;
511 c
->options
= R4K_OPTS
|
512 MIPS_CPU_FPU
| MIPS_CPU_LLSC
|
519 static char unknown_isa
[] __initdata
= KERN_ERR \
520 "Unsupported ISA type, c0.config0: %d.";
522 static inline unsigned int decode_config0(struct cpuinfo_mips
*c
)
524 unsigned int config0
;
527 config0
= read_c0_config();
529 if (((config0
& MIPS_CONF_MT
) >> 7) == 1)
530 c
->options
|= MIPS_CPU_TLB
;
531 isa
= (config0
& MIPS_CONF_AT
) >> 13;
534 switch ((config0
& MIPS_CONF_AR
) >> 10) {
536 c
->isa_level
= MIPS_CPU_ISA_M32R1
;
539 c
->isa_level
= MIPS_CPU_ISA_M32R2
;
546 switch ((config0
& MIPS_CONF_AR
) >> 10) {
548 c
->isa_level
= MIPS_CPU_ISA_M64R1
;
551 c
->isa_level
= MIPS_CPU_ISA_M64R2
;
561 return config0
& MIPS_CONF_M
;
564 panic(unknown_isa
, config0
);
567 static inline unsigned int decode_config1(struct cpuinfo_mips
*c
)
569 unsigned int config1
;
571 config1
= read_c0_config1();
573 if (config1
& MIPS_CONF1_MD
)
574 c
->ases
|= MIPS_ASE_MDMX
;
575 if (config1
& MIPS_CONF1_WR
)
576 c
->options
|= MIPS_CPU_WATCH
;
577 if (config1
& MIPS_CONF1_CA
)
578 c
->ases
|= MIPS_ASE_MIPS16
;
579 if (config1
& MIPS_CONF1_EP
)
580 c
->options
|= MIPS_CPU_EJTAG
;
581 if (config1
& MIPS_CONF1_FP
) {
582 c
->options
|= MIPS_CPU_FPU
;
583 c
->options
|= MIPS_CPU_32FPR
;
586 c
->tlbsize
= ((config1
& MIPS_CONF1_TLBS
) >> 25) + 1;
588 return config1
& MIPS_CONF_M
;
591 static inline unsigned int decode_config2(struct cpuinfo_mips
*c
)
593 unsigned int config2
;
595 config2
= read_c0_config2();
597 if (config2
& MIPS_CONF2_SL
)
598 c
->scache
.flags
&= ~MIPS_CACHE_NOT_PRESENT
;
600 return config2
& MIPS_CONF_M
;
603 static inline unsigned int decode_config3(struct cpuinfo_mips
*c
)
605 unsigned int config3
;
607 config3
= read_c0_config3();
609 if (config3
& MIPS_CONF3_SM
)
610 c
->ases
|= MIPS_ASE_SMARTMIPS
;
611 if (config3
& MIPS_CONF3_DSP
)
612 c
->ases
|= MIPS_ASE_DSP
;
613 if (config3
& MIPS_CONF3_VINT
)
614 c
->options
|= MIPS_CPU_VINT
;
615 if (config3
& MIPS_CONF3_VEIC
)
616 c
->options
|= MIPS_CPU_VEIC
;
617 if (config3
& MIPS_CONF3_MT
)
618 c
->ases
|= MIPS_ASE_MIPSMT
;
619 if (config3
& MIPS_CONF3_ULRI
)
620 c
->options
|= MIPS_CPU_ULRI
;
622 return config3
& MIPS_CONF_M
;
625 static void __init
decode_configs(struct cpuinfo_mips
*c
)
627 /* MIPS32 or MIPS64 compliant CPU. */
628 c
->options
= MIPS_CPU_4KEX
| MIPS_CPU_4K_CACHE
| MIPS_CPU_COUNTER
|
629 MIPS_CPU_DIVEC
| MIPS_CPU_LLSC
| MIPS_CPU_MCHECK
;
631 c
->scache
.flags
= MIPS_CACHE_NOT_PRESENT
;
633 /* Read Config registers. */
634 if (!decode_config0(c
))
635 return; /* actually worth a panic() */
636 if (!decode_config1(c
))
638 if (!decode_config2(c
))
640 if (!decode_config3(c
))
644 static inline void cpu_probe_mips(struct cpuinfo_mips
*c
)
647 switch (c
->processor_id
& 0xff00) {
649 c
->cputype
= CPU_4KC
;
652 c
->cputype
= CPU_4KEC
;
654 case PRID_IMP_4KECR2
:
655 c
->cputype
= CPU_4KEC
;
659 c
->cputype
= CPU_4KSC
;
662 c
->cputype
= CPU_5KC
;
665 c
->cputype
= CPU_20KC
;
669 c
->cputype
= CPU_24K
;
672 c
->cputype
= CPU_25KF
;
675 c
->cputype
= CPU_34K
;
678 c
->cputype
= CPU_74K
;
683 static inline void cpu_probe_alchemy(struct cpuinfo_mips
*c
)
686 switch (c
->processor_id
& 0xff00) {
687 case PRID_IMP_AU1_REV1
:
688 case PRID_IMP_AU1_REV2
:
689 switch ((c
->processor_id
>> 24) & 0xff) {
691 c
->cputype
= CPU_AU1000
;
694 c
->cputype
= CPU_AU1500
;
697 c
->cputype
= CPU_AU1100
;
700 c
->cputype
= CPU_AU1550
;
703 c
->cputype
= CPU_AU1200
;
706 panic("Unknown Au Core!");
713 static inline void cpu_probe_sibyte(struct cpuinfo_mips
*c
)
718 * For historical reasons the SB1 comes with it's own variant of
719 * cache code which eventually will be folded into c-r4k.c. Until
720 * then we pretend it's got it's own cache architecture.
722 c
->options
&= ~MIPS_CPU_4K_CACHE
;
723 c
->options
|= MIPS_CPU_SB1_CACHE
;
725 switch (c
->processor_id
& 0xff00) {
727 c
->cputype
= CPU_SB1
;
728 /* FPU in pass1 is known to have issues. */
729 if ((c
->processor_id
& 0xff) < 0x02)
730 c
->options
&= ~(MIPS_CPU_FPU
| MIPS_CPU_32FPR
);
733 c
->cputype
= CPU_SB1A
;
738 static inline void cpu_probe_sandcraft(struct cpuinfo_mips
*c
)
741 switch (c
->processor_id
& 0xff00) {
742 case PRID_IMP_SR71000
:
743 c
->cputype
= CPU_SR71000
;
750 static inline void cpu_probe_philips(struct cpuinfo_mips
*c
)
753 switch (c
->processor_id
& 0xff00) {
754 case PRID_IMP_PR4450
:
755 c
->cputype
= CPU_PR4450
;
756 c
->isa_level
= MIPS_CPU_ISA_M32R1
;
759 panic("Unknown Philips Core!"); /* REVISIT: die? */
765 __init
void cpu_probe(void)
767 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
769 c
->processor_id
= PRID_IMP_UNKNOWN
;
770 c
->fpu_id
= FPIR_IMP_NONE
;
771 c
->cputype
= CPU_UNKNOWN
;
773 c
->processor_id
= read_c0_prid();
774 switch (c
->processor_id
& 0xff0000) {
775 case PRID_COMP_LEGACY
:
781 case PRID_COMP_ALCHEMY
:
782 cpu_probe_alchemy(c
);
784 case PRID_COMP_SIBYTE
:
787 case PRID_COMP_SANDCRAFT
:
788 cpu_probe_sandcraft(c
);
790 case PRID_COMP_PHILIPS
:
791 cpu_probe_philips(c
);
794 c
->cputype
= CPU_UNKNOWN
;
796 if (c
->options
& MIPS_CPU_FPU
) {
797 c
->fpu_id
= cpu_get_fpu_id();
799 if (c
->isa_level
== MIPS_CPU_ISA_M32R1
||
800 c
->isa_level
== MIPS_CPU_ISA_M32R2
||
801 c
->isa_level
== MIPS_CPU_ISA_M64R1
||
802 c
->isa_level
== MIPS_CPU_ISA_M64R2
) {
803 if (c
->fpu_id
& MIPS_FPIR_3D
)
804 c
->ases
|= MIPS_ASE_MIPS3D
;
809 __init
void cpu_report(void)
811 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
813 printk("CPU revision is: %08x\n", c
->processor_id
);
814 if (c
->options
& MIPS_CPU_FPU
)
815 printk("FPU revision is: %08x\n", c
->fpu_id
);
This page took 0.049174 seconds and 6 git commands to generate.