1 #include <linux/init.h>
2 #include <linux/kernel.h>
3 #include <linux/stddef.h>
7 #include <asm/mipsregs.h>
10 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
11 * the implementation of the "wait" feature differs between CPU families. This
12 * points to the function that implements CPU specific wait.
13 * The wait instruction stops the pipeline and reduces the power consumption of
16 void (*cpu_wait
)(void) = NULL
;
18 static void r3081_wait(void)
20 unsigned long cfg
= read_c0_conf();
21 write_c0_conf(cfg
| R30XX_CONF_HALT
);
24 static void r39xx_wait(void)
26 unsigned long cfg
= read_c0_conf();
27 write_c0_conf(cfg
| TX39_CONF_HALT
);
30 static void r4k_wait(void)
32 __asm__(".set\tmips3\n\t"
40 /* using the wait instruction makes CP0 counter unusable */
41 __asm__(".set\tmips3\n\t"
54 static inline void check_wait(void)
56 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
58 printk("Checking for 'wait' instruction... ");
62 cpu_wait
= r3081_wait
;
63 printk(" available.\n");
66 cpu_wait
= r39xx_wait
;
67 printk(" available.\n");
85 printk(" available.\n");
91 printk(" available.\n");
94 printk(" unavailable.\n");
99 void __init
check_bugs(void)
105 * Probe whether cpu has config register by trying to play with
106 * alternate cache bit and see whether it matters.
107 * It's used by cpu_probe to distinguish between R3000A and R3081.
109 static inline int cpu_has_confreg(void)
111 #ifdef CONFIG_CPU_R3000
112 extern unsigned long r3k_cache_size(unsigned long);
113 unsigned long size1
, size2
;
114 unsigned long cfg
= read_c0_conf();
116 size1
= r3k_cache_size(ST0_ISC
);
117 write_c0_conf(cfg
^ R30XX_CONF_AC
);
118 size2
= r3k_cache_size(ST0_ISC
);
120 return size1
!= size2
;
127 * Get the FPU Implementation/Revision.
129 static inline unsigned long cpu_get_fpu_id(void)
131 unsigned long tmp
, fpu_id
;
133 tmp
= read_c0_status();
135 fpu_id
= read_32bit_cp1_register(CP1_REVISION
);
136 write_c0_status(tmp
);
141 * Check the CPU has an FPU the official way.
143 static inline int __cpu_has_fpu(void)
145 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE
);
148 #define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4KTLB \
149 | MIPS_CPU_COUNTER | MIPS_CPU_CACHE_CDEX)
151 __init
void cpu_probe(void)
153 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
154 unsigned long config0
= read_c0_config();
155 unsigned long config1
;
157 c
->processor_id
= PRID_IMP_UNKNOWN
;
158 c
->fpu_id
= FPIR_IMP_NONE
;
159 c
->cputype
= CPU_UNKNOWN
;
161 if (config0
& (1 << 31)) {
162 /* MIPS32 or MIPS64 compliant CPU. Read Config 1 register. */
163 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4KEX
|
164 MIPS_CPU_4KTLB
| MIPS_CPU_COUNTER
| MIPS_CPU_DIVEC
|
166 config1
= read_c0_config1();
167 if (config1
& (1 << 3))
168 c
->options
|= MIPS_CPU_WATCH
;
169 if (config1
& (1 << 2))
170 c
->options
|= MIPS_CPU_MIPS16
;
171 if (config1
& (1 << 1))
172 c
->options
|= MIPS_CPU_EJTAG
;
174 c
->options
|= MIPS_CPU_FPU
;
175 c
->options
|= MIPS_CPU_32FPR
;
177 c
->scache
.flags
= MIPS_CACHE_NOT_PRESENT
;
179 c
->tlbsize
= ((config1
>> 25) & 0x3f) + 1;
182 c
->processor_id
= read_c0_prid();
183 switch (c
->processor_id
& 0xff0000) {
184 case PRID_COMP_LEGACY
:
185 switch (c
->processor_id
& 0xff00) {
187 c
->cputype
= CPU_R2000
;
188 c
->isa_level
= MIPS_CPU_ISA_I
;
189 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_NOFPUEX
|
192 c
->options
|= MIPS_CPU_FPU
;
196 if ((c
->processor_id
& 0xff) == PRID_REV_R3000A
)
197 if (cpu_has_confreg())
198 c
->cputype
= CPU_R3081E
;
200 c
->cputype
= CPU_R3000A
;
202 c
->cputype
= CPU_R3000
;
203 c
->isa_level
= MIPS_CPU_ISA_I
;
204 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_NOFPUEX
|
207 c
->options
|= MIPS_CPU_FPU
;
211 if ((c
->processor_id
& 0xff) >= PRID_REV_R4400
)
212 c
->cputype
= CPU_R4400SC
;
214 c
->cputype
= CPU_R4000SC
;
215 c
->isa_level
= MIPS_CPU_ISA_III
;
216 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
217 MIPS_CPU_WATCH
| MIPS_CPU_VCE
|
221 case PRID_IMP_VR41XX
:
222 switch (c
->processor_id
& 0xf0) {
223 #ifndef CONFIG_VR4181
224 case PRID_REV_VR4111
:
225 c
->cputype
= CPU_VR4111
;
228 case PRID_REV_VR4181
:
229 c
->cputype
= CPU_VR4181
;
232 case PRID_REV_VR4121
:
233 c
->cputype
= CPU_VR4121
;
235 case PRID_REV_VR4122
:
236 if ((c
->processor_id
& 0xf) < 0x3)
237 c
->cputype
= CPU_VR4122
;
239 c
->cputype
= CPU_VR4181A
;
241 case PRID_REV_VR4131
:
242 c
->cputype
= CPU_VR4131
;
245 printk(KERN_INFO
"Unexpected CPU of NEC VR4100 series\n");
246 c
->cputype
= CPU_VR41XX
;
249 c
->isa_level
= MIPS_CPU_ISA_III
;
250 c
->options
= R4K_OPTS
;
254 c
->cputype
= CPU_R4300
;
255 c
->isa_level
= MIPS_CPU_ISA_III
;
256 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
261 c
->cputype
= CPU_R4600
;
262 c
->isa_level
= MIPS_CPU_ISA_III
;
263 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_LLSC
;
269 * This processor doesn't have an MMU, so it's not
270 * "real easy" to run Linux on it. It is left purely
271 * for documentation. Commented out because it shares
272 * it's c0_prid id number with the TX3900.
274 c
->cputype
= CPU_R4650
;
275 c
->isa_level
= MIPS_CPU_ISA_III
;
276 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_LLSC
;
281 c
->isa_level
= MIPS_CPU_ISA_I
;
282 c
->options
= MIPS_CPU_TLB
;
284 if ((c
->processor_id
& 0xf0) ==
285 (PRID_REV_TX3927
& 0xf0)) {
286 c
->cputype
= CPU_TX3927
;
289 switch (c
->processor_id
& 0xff) {
290 case PRID_REV_TX3912
:
291 c
->cputype
= CPU_TX3912
;
294 case PRID_REV_TX3922
:
295 c
->cputype
= CPU_TX3922
;
299 c
->cputype
= CPU_UNKNOWN
;
305 c
->cputype
= CPU_R4700
;
306 c
->isa_level
= MIPS_CPU_ISA_III
;
307 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
312 c
->cputype
= CPU_TX49XX
;
313 c
->isa_level
= MIPS_CPU_ISA_III
;
314 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
319 c
->cputype
= CPU_R5000
;
320 c
->isa_level
= MIPS_CPU_ISA_IV
;
321 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
326 c
->cputype
= CPU_R5432
;
327 c
->isa_level
= MIPS_CPU_ISA_IV
;
328 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
329 MIPS_CPU_WATCH
| MIPS_CPU_LLSC
;
333 c
->cputype
= CPU_R5500
;
334 c
->isa_level
= MIPS_CPU_ISA_IV
;
335 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
336 MIPS_CPU_WATCH
| MIPS_CPU_LLSC
;
339 case PRID_IMP_NEVADA
:
340 c
->cputype
= CPU_NEVADA
;
341 c
->isa_level
= MIPS_CPU_ISA_IV
;
342 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
343 MIPS_CPU_DIVEC
| MIPS_CPU_LLSC
;
347 c
->cputype
= CPU_R6000
;
348 c
->isa_level
= MIPS_CPU_ISA_II
;
349 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_FPU
|
353 case PRID_IMP_R6000A
:
354 c
->cputype
= CPU_R6000A
;
355 c
->isa_level
= MIPS_CPU_ISA_II
;
356 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_FPU
|
360 case PRID_IMP_RM7000
:
361 c
->cputype
= CPU_RM7000
;
362 c
->isa_level
= MIPS_CPU_ISA_IV
;
363 c
->options
= R4K_OPTS
| MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
366 * Undocumented RM7000: Bit 29 in the info register of
367 * the RM7000 v2.0 indicates if the TLB has 48 or 64
370 * 29 1 => 64 entry JTLB
373 c
->tlbsize
= (read_c0_info() & (1 << 29)) ? 64 : 48;
376 c
->cputype
= CPU_R8000
;
377 c
->isa_level
= MIPS_CPU_ISA_IV
;
378 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4KEX
|
379 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
381 c
->tlbsize
= 384; /* has weird TLB: 3-way x 128 */
383 case PRID_IMP_R10000
:
384 c
->cputype
= CPU_R10000
;
385 c
->isa_level
= MIPS_CPU_ISA_IV
;
386 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4KEX
|
387 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
388 MIPS_CPU_COUNTER
| MIPS_CPU_WATCH
|
392 case PRID_IMP_R12000
:
393 c
->cputype
= CPU_R12000
;
394 c
->isa_level
= MIPS_CPU_ISA_IV
;
395 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4KEX
|
396 MIPS_CPU_FPU
| MIPS_CPU_32FPR
|
397 MIPS_CPU_COUNTER
| MIPS_CPU_WATCH
|
402 c
->cputype
= CPU_UNKNOWN
;
407 switch (c
->processor_id
& 0xff00) {
409 c
->cputype
= CPU_4KC
;
410 c
->isa_level
= MIPS_CPU_ISA_M32
;
413 c
->cputype
= CPU_4KEC
;
414 c
->isa_level
= MIPS_CPU_ISA_M32
;
417 c
->cputype
= CPU_4KSC
;
418 c
->isa_level
= MIPS_CPU_ISA_M32
;
421 c
->cputype
= CPU_5KC
;
422 c
->isa_level
= MIPS_CPU_ISA_M64
;
425 c
->cputype
= CPU_20KC
;
426 c
->isa_level
= MIPS_CPU_ISA_M64
;
429 c
->cputype
= CPU_UNKNOWN
;
433 case PRID_COMP_ALCHEMY
:
434 switch (c
->processor_id
& 0xff00) {
435 case PRID_IMP_AU1_REV1
:
436 case PRID_IMP_AU1_REV2
:
437 switch ((c
->processor_id
>> 24) & 0xff) {
439 c
->cputype
= CPU_AU1000
;
442 c
->cputype
= CPU_AU1500
;
445 c
->cputype
= CPU_AU1100
;
448 panic("Unknown Au Core!");
451 c
->isa_level
= MIPS_CPU_ISA_M32
;
454 c
->cputype
= CPU_UNKNOWN
;
458 case PRID_COMP_SIBYTE
:
459 switch (c
->processor_id
& 0xff00) {
461 c
->cputype
= CPU_SB1
;
462 c
->isa_level
= MIPS_CPU_ISA_M64
;
463 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4KEX
|
464 MIPS_CPU_COUNTER
| MIPS_CPU_DIVEC
|
465 MIPS_CPU_MCHECK
| MIPS_CPU_EJTAG
|
466 MIPS_CPU_WATCH
| MIPS_CPU_LLSC
;
467 #ifndef CONFIG_SB1_PASS_1_WORKAROUNDS
468 /* FPU in pass1 is known to have issues. */
469 c
->options
|= MIPS_CPU_FPU
| MIPS_CPU_32FPR
;
473 c
->cputype
= CPU_UNKNOWN
;
478 case PRID_COMP_SANDCRAFT
:
479 switch (c
->processor_id
& 0xff00) {
480 case PRID_IMP_SR71000
:
481 c
->cputype
= CPU_SR71000
;
482 c
->isa_level
= MIPS_CPU_ISA_M64
;
483 c
->options
= MIPS_CPU_TLB
| MIPS_CPU_4KEX
|
484 MIPS_CPU_4KTLB
| MIPS_CPU_FPU
|
485 MIPS_CPU_COUNTER
| MIPS_CPU_MCHECK
;
490 c
->cputype
= CPU_UNKNOWN
;
495 c
->cputype
= CPU_UNKNOWN
;
497 if (c
->options
& MIPS_CPU_FPU
)
498 c
->fpu_id
= cpu_get_fpu_id();
501 __init
void cpu_report(void)
503 struct cpuinfo_mips
*c
= ¤t_cpu_data
;
505 printk("CPU revision is: %08x\n", c
->processor_id
);
506 if (c
->options
& MIPS_CPU_FPU
)
507 printk("FPU revision is: %08x\n", c
->fpu_id
);