blob: 7a51866068a4796631cfd4132dc07d7918dc105f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Processor capabilities determination functions.
3 *
4 * Copyright (C) xxxx the Anonymous
Ralf Baechle010b8532006-01-29 18:42:08 +00005 * Copyright (C) 1994 - 2006 Ralf Baechle
Ralf Baechle41943182005-05-05 16:45:59 +00006 * Copyright (C) 2003, 2004 Maciej W. Rozycki
Ralf Baechle41943182005-05-05 16:45:59 +00007 * Copyright (C) 2001, 2004 MIPS Inc.
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
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.
13 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/ptrace.h>
Ralf Baechle631330f2009-06-19 14:05:26 +010017#include <linux/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/stddef.h>
19
Ralf Baechle57599062007-02-18 19:07:31 +000020#include <asm/bugs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070021#include <asm/cpu.h>
22#include <asm/fpu.h>
23#include <asm/mipsregs.h>
24#include <asm/system.h>
David Daney654f57b2008-09-23 00:07:16 -070025#include <asm/watch.h>
Chris Dearmana074f0e2009-07-10 01:51:27 -070026#include <asm/spram.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027/*
28 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
29 * the implementation of the "wait" feature differs between CPU families. This
30 * points to the function that implements CPU specific wait.
31 * The wait instruction stops the pipeline and reduces the power consumption of
32 * the CPU very much.
33 */
Ralf Baechle982f6ff2009-09-17 02:25:07 +020034void (*cpu_wait)(void);
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36static void r3081_wait(void)
37{
38 unsigned long cfg = read_c0_conf();
39 write_c0_conf(cfg | R30XX_CONF_HALT);
40}
41
42static void r39xx_wait(void)
43{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090044 local_irq_disable();
45 if (!need_resched())
46 write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
47 local_irq_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070048}
49
Atsushi Nemotoc65a5482007-11-12 02:05:18 +090050extern void r4k_wait(void);
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090051
52/*
53 * This variant is preferable as it allows testing need_resched and going to
54 * sleep depending on the outcome atomically. Unfortunately the "It is
55 * implementation-dependent whether the pipeline restarts when a non-enabled
56 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
57 * using this version a gamble.
58 */
Kevin D. Kissell8531a352008-09-09 21:48:52 +020059void r4k_wait_irqoff(void)
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090060{
61 local_irq_disable();
62 if (!need_resched())
Kevin D. Kissell8531a352008-09-09 21:48:52 +020063 __asm__(" .set push \n"
64 " .set mips3 \n"
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090065 " wait \n"
Kevin D. Kissell8531a352008-09-09 21:48:52 +020066 " .set pop \n");
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090067 local_irq_enable();
Kevin D. Kissell8531a352008-09-09 21:48:52 +020068 __asm__(" .globl __pastwait \n"
69 "__pastwait: \n");
70 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -070071}
72
Ralf Baechle5a812992007-07-17 18:49:48 +010073/*
74 * The RM7000 variant has to handle erratum 38. The workaround is to not
75 * have any pending stores when the WAIT instruction is executed.
76 */
77static void rm7k_wait_irqoff(void)
78{
79 local_irq_disable();
80 if (!need_resched())
81 __asm__(
82 " .set push \n"
83 " .set mips3 \n"
84 " .set noat \n"
85 " mfc0 $1, $12 \n"
86 " sync \n"
87 " mtc0 $1, $12 # stalls until W stage \n"
88 " wait \n"
89 " mtc0 $1, $12 # stalls until W stage \n"
90 " .set pop \n");
91 local_irq_enable();
92}
93
Manuel Lauss2882b0c2009-08-22 18:09:27 +020094/*
95 * The Au1xxx wait is available only if using 32khz counter or
96 * external timer source, but specifically not CP0 Counter.
97 * alchemy/common/time.c may override cpu_wait!
98 */
Pete Popov494900a2005-04-07 00:42:10 +000099static void au1k_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900101 __asm__(" .set mips3 \n"
102 " cache 0x14, 0(%0) \n"
103 " cache 0x14, 32(%0) \n"
104 " sync \n"
105 " nop \n"
106 " wait \n"
107 " nop \n"
108 " nop \n"
109 " nop \n"
110 " nop \n"
111 " .set mips0 \n"
Ralf Baechle10f650d2005-05-25 13:32:49 +0000112 : : "r" (au1k_wait));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113}
114
Ralf Baechle982f6ff2009-09-17 02:25:07 +0200115static int __initdata nowait;
Ralf Baechle55d04df2005-07-13 19:22:45 +0000116
Atsushi Nemotof49a7472007-02-18 01:02:14 +0900117static int __init wait_disable(char *s)
Ralf Baechle55d04df2005-07-13 19:22:45 +0000118{
119 nowait = 1;
120
121 return 1;
122}
123
124__setup("nowait", wait_disable);
125
Atsushi Nemotoc65a5482007-11-12 02:05:18 +0900126void __init check_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700127{
128 struct cpuinfo_mips *c = &current_cpu_data;
129
Ralf Baechle55d04df2005-07-13 19:22:45 +0000130 if (nowait) {
Ralf Baechlec2379232006-11-30 01:14:44 +0000131 printk("Wait instruction disabled.\n");
Ralf Baechle55d04df2005-07-13 19:22:45 +0000132 return;
133 }
134
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135 switch (c->cputype) {
136 case CPU_R3081:
137 case CPU_R3081E:
138 cpu_wait = r3081_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 break;
140 case CPU_TX3927:
141 cpu_wait = r39xx_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 break;
143 case CPU_R4200:
144/* case CPU_R4300: */
145 case CPU_R4600:
146 case CPU_R4640:
147 case CPU_R4650:
148 case CPU_R4700:
149 case CPU_R5000:
Shinya Kuribayashia644b272009-03-03 18:05:51 +0900150 case CPU_R5500:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151 case CPU_NEVADA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 case CPU_4KC:
153 case CPU_4KEC:
154 case CPU_4KSC:
155 case CPU_5KC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 case CPU_25KF:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100157 case CPU_PR4450:
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200158 case CPU_BCM3302:
Maxime Bizon0de663e2009-08-18 13:23:37 +0100159 case CPU_BCM6338:
160 case CPU_BCM6348:
161 case CPU_BCM6358:
David Daney0dd47812008-12-11 15:33:26 -0800162 case CPU_CAVIUM_OCTEON:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700164 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100165
Ralf Baechle5a812992007-07-17 18:49:48 +0100166 case CPU_RM7000:
167 cpu_wait = rm7k_wait_irqoff;
168 break;
169
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100170 case CPU_24K:
171 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100172 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100173 cpu_wait = r4k_wait;
174 if (read_c0_config7() & MIPS_CONF7_WII)
175 cpu_wait = r4k_wait_irqoff;
176 break;
177
178 case CPU_74K:
179 cpu_wait = r4k_wait;
180 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
181 cpu_wait = r4k_wait_irqoff;
182 break;
183
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900184 case CPU_TX49XX:
185 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900186 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100187 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100188 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100190 case CPU_20KC:
191 /*
192 * WAIT on Rev1.0 has E1, E2, E3 and E16.
193 * WAIT on Rev2.0 and Rev3.0 has E16.
194 * Rev3.1 WAIT is nop, why bother
195 */
196 if ((c->processor_id & 0xff) <= 0x64)
197 break;
198
Ralf Baechle50da4692007-09-14 19:08:43 +0100199 /*
200 * Another rev is incremeting c0_count at a reduced clock
201 * rate while in WAIT mode. So we basically have the choice
202 * between using the cp0 timer as clocksource or avoiding
203 * the WAIT instruction. Until more details are known,
204 * disable the use of WAIT for 20Kc entirely.
205 cpu_wait = r4k_wait;
206 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100207 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100208 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000209 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100210 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100211 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213 break;
214 }
215}
216
Marc St-Jean9267a302007-06-14 15:55:31 -0600217static inline void check_errata(void)
218{
219 struct cpuinfo_mips *c = &current_cpu_data;
220
221 switch (c->cputype) {
222 case CPU_34K:
223 /*
224 * Erratum "RPS May Cause Incorrect Instruction Execution"
225 * This code only handles VPE0, any SMP/SMTC/RTOS code
226 * making use of VPE1 will be responsable for that VPE.
227 */
228 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
229 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
230 break;
231 default:
232 break;
233 }
234}
235
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236void __init check_bugs32(void)
237{
Marc St-Jean9267a302007-06-14 15:55:31 -0600238 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239}
240
241/*
242 * Probe whether cpu has config register by trying to play with
243 * alternate cache bit and see whether it matters.
244 * It's used by cpu_probe to distinguish between R3000A and R3081.
245 */
246static inline int cpu_has_confreg(void)
247{
248#ifdef CONFIG_CPU_R3000
249 extern unsigned long r3k_cache_size(unsigned long);
250 unsigned long size1, size2;
251 unsigned long cfg = read_c0_conf();
252
253 size1 = r3k_cache_size(ST0_ISC);
254 write_c0_conf(cfg ^ R30XX_CONF_AC);
255 size2 = r3k_cache_size(ST0_ISC);
256 write_c0_conf(cfg);
257 return size1 != size2;
258#else
259 return 0;
260#endif
261}
262
263/*
264 * Get the FPU Implementation/Revision.
265 */
266static inline unsigned long cpu_get_fpu_id(void)
267{
268 unsigned long tmp, fpu_id;
269
270 tmp = read_c0_status();
271 __enable_fpu();
272 fpu_id = read_32bit_cp1_register(CP1_REVISION);
273 write_c0_status(tmp);
274 return fpu_id;
275}
276
277/*
278 * Check the CPU has an FPU the official way.
279 */
280static inline int __cpu_has_fpu(void)
281{
282 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
283}
284
Ralf Baechle02cf2112005-10-01 13:06:32 +0100285#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700286 | MIPS_CPU_COUNTER)
287
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000288static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289{
290 switch (c->processor_id & 0xff00) {
291 case PRID_IMP_R2000:
292 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000293 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700294 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100295 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
296 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297 if (__cpu_has_fpu())
298 c->options |= MIPS_CPU_FPU;
299 c->tlbsize = 64;
300 break;
301 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000302 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
303 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000305 __cpu_name[cpu] = "R3081";
306 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000308 __cpu_name[cpu] = "R3000A";
309 }
310 break;
311 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000313 __cpu_name[cpu] = "R3000";
314 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100316 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
317 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318 if (__cpu_has_fpu())
319 c->options |= MIPS_CPU_FPU;
320 c->tlbsize = 64;
321 break;
322 case PRID_IMP_R4000:
323 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000324 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000326 __cpu_name[cpu] = "R4400PC";
327 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000329 __cpu_name[cpu] = "R4000PC";
330 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000332 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000334 __cpu_name[cpu] = "R4400SC";
335 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700336 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000337 __cpu_name[cpu] = "R4000SC";
338 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 }
340
341 c->isa_level = MIPS_CPU_ISA_III;
342 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
343 MIPS_CPU_WATCH | MIPS_CPU_VCE |
344 MIPS_CPU_LLSC;
345 c->tlbsize = 48;
346 break;
347 case PRID_IMP_VR41XX:
348 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 case PRID_REV_VR4111:
350 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000351 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 case PRID_REV_VR4121:
354 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000355 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 break;
357 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000358 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000360 __cpu_name[cpu] = "NEC VR4122";
361 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000363 __cpu_name[cpu] = "NEC VR4181A";
364 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 break;
366 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000367 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000369 __cpu_name[cpu] = "NEC VR4131";
370 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000372 __cpu_name[cpu] = "NEC VR4133";
373 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 break;
375 default:
376 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
377 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000378 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 break;
380 }
381 c->isa_level = MIPS_CPU_ISA_III;
382 c->options = R4K_OPTS;
383 c->tlbsize = 32;
384 break;
385 case PRID_IMP_R4300:
386 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000387 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 c->isa_level = MIPS_CPU_ISA_III;
389 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
390 MIPS_CPU_LLSC;
391 c->tlbsize = 32;
392 break;
393 case PRID_IMP_R4600:
394 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000395 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000397 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
398 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 c->tlbsize = 48;
400 break;
401 #if 0
402 case PRID_IMP_R4650:
403 /*
404 * This processor doesn't have an MMU, so it's not
405 * "real easy" to run Linux on it. It is left purely
406 * for documentation. Commented out because it shares
407 * it's c0_prid id number with the TX3900.
408 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000409 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000410 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 c->isa_level = MIPS_CPU_ISA_III;
412 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
413 c->tlbsize = 48;
414 break;
415 #endif
416 case PRID_IMP_TX39:
417 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100418 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419
420 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
421 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000422 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 c->tlbsize = 64;
424 } else {
425 switch (c->processor_id & 0xff) {
426 case PRID_REV_TX3912:
427 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000428 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 c->tlbsize = 32;
430 break;
431 case PRID_REV_TX3922:
432 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000433 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 c->tlbsize = 64;
435 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 }
437 }
438 break;
439 case PRID_IMP_R4700:
440 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000441 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 c->isa_level = MIPS_CPU_ISA_III;
443 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
444 MIPS_CPU_LLSC;
445 c->tlbsize = 48;
446 break;
447 case PRID_IMP_TX49:
448 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000449 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 c->isa_level = MIPS_CPU_ISA_III;
451 c->options = R4K_OPTS | MIPS_CPU_LLSC;
452 if (!(c->processor_id & 0x08))
453 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
454 c->tlbsize = 48;
455 break;
456 case PRID_IMP_R5000:
457 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000458 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 c->isa_level = MIPS_CPU_ISA_IV;
460 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
461 MIPS_CPU_LLSC;
462 c->tlbsize = 48;
463 break;
464 case PRID_IMP_R5432:
465 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000466 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 c->isa_level = MIPS_CPU_ISA_IV;
468 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
469 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
470 c->tlbsize = 48;
471 break;
472 case PRID_IMP_R5500:
473 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000474 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 c->isa_level = MIPS_CPU_ISA_IV;
476 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
477 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
478 c->tlbsize = 48;
479 break;
480 case PRID_IMP_NEVADA:
481 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000482 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483 c->isa_level = MIPS_CPU_ISA_IV;
484 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
485 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
486 c->tlbsize = 48;
487 break;
488 case PRID_IMP_R6000:
489 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000490 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 c->isa_level = MIPS_CPU_ISA_II;
492 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
493 MIPS_CPU_LLSC;
494 c->tlbsize = 32;
495 break;
496 case PRID_IMP_R6000A:
497 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000498 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 c->isa_level = MIPS_CPU_ISA_II;
500 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
501 MIPS_CPU_LLSC;
502 c->tlbsize = 32;
503 break;
504 case PRID_IMP_RM7000:
505 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000506 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 c->isa_level = MIPS_CPU_ISA_IV;
508 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
509 MIPS_CPU_LLSC;
510 /*
511 * Undocumented RM7000: Bit 29 in the info register of
512 * the RM7000 v2.0 indicates if the TLB has 48 or 64
513 * entries.
514 *
515 * 29 1 => 64 entry JTLB
516 * 0 => 48 entry JTLB
517 */
518 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
519 break;
520 case PRID_IMP_RM9000:
521 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000522 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 c->isa_level = MIPS_CPU_ISA_IV;
524 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
525 MIPS_CPU_LLSC;
526 /*
527 * Bit 29 in the info register of the RM9000
528 * indicates if the TLB has 48 or 64 entries.
529 *
530 * 29 1 => 64 entry JTLB
531 * 0 => 48 entry JTLB
532 */
533 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
534 break;
535 case PRID_IMP_R8000:
536 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000537 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 c->isa_level = MIPS_CPU_ISA_IV;
539 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
540 MIPS_CPU_FPU | MIPS_CPU_32FPR |
541 MIPS_CPU_LLSC;
542 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
543 break;
544 case PRID_IMP_R10000:
545 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000546 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000548 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 MIPS_CPU_FPU | MIPS_CPU_32FPR |
550 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
551 MIPS_CPU_LLSC;
552 c->tlbsize = 64;
553 break;
554 case PRID_IMP_R12000:
555 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000556 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000558 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 MIPS_CPU_FPU | MIPS_CPU_32FPR |
560 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
561 MIPS_CPU_LLSC;
562 c->tlbsize = 64;
563 break;
Kumba44d921b2006-05-16 22:23:59 -0400564 case PRID_IMP_R14000:
565 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000566 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400567 c->isa_level = MIPS_CPU_ISA_IV;
568 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
569 MIPS_CPU_FPU | MIPS_CPU_32FPR |
570 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
571 MIPS_CPU_LLSC;
572 c->tlbsize = 64;
573 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800574 case PRID_IMP_LOONGSON2:
575 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000576 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800577 c->isa_level = MIPS_CPU_ISA_III;
578 c->options = R4K_OPTS |
579 MIPS_CPU_FPU | MIPS_CPU_LLSC |
580 MIPS_CPU_32FPR;
581 c->tlbsize = 64;
582 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 }
584}
585
Ralf Baechle234fcd12008-03-08 09:56:28 +0000586static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000587 "Unsupported ISA type, c0.config0: %d.";
588
Ralf Baechle41943182005-05-05 16:45:59 +0000589static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590{
Ralf Baechle41943182005-05-05 16:45:59 +0000591 unsigned int config0;
592 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593
Ralf Baechle41943182005-05-05 16:45:59 +0000594 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595
Ralf Baechle41943182005-05-05 16:45:59 +0000596 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100597 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000598 isa = (config0 & MIPS_CONF_AT) >> 13;
599 switch (isa) {
600 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100601 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000602 case 0:
603 c->isa_level = MIPS_CPU_ISA_M32R1;
604 break;
605 case 1:
606 c->isa_level = MIPS_CPU_ISA_M32R2;
607 break;
608 default:
609 goto unknown;
610 }
Ralf Baechle41943182005-05-05 16:45:59 +0000611 break;
612 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100613 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000614 case 0:
615 c->isa_level = MIPS_CPU_ISA_M64R1;
616 break;
617 case 1:
618 c->isa_level = MIPS_CPU_ISA_M64R2;
619 break;
620 default:
621 goto unknown;
622 }
Ralf Baechle41943182005-05-05 16:45:59 +0000623 break;
624 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000625 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000626 }
627
628 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000629
630unknown:
631 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000632}
633
634static inline unsigned int decode_config1(struct cpuinfo_mips *c)
635{
636 unsigned int config1;
637
Linus Torvalds1da177e2005-04-16 15:20:36 -0700638 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000639
640 if (config1 & MIPS_CONF1_MD)
641 c->ases |= MIPS_ASE_MDMX;
642 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000644 if (config1 & MIPS_CONF1_CA)
645 c->ases |= MIPS_ASE_MIPS16;
646 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000648 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 c->options |= MIPS_CPU_FPU;
650 c->options |= MIPS_CPU_32FPR;
651 }
Ralf Baechle41943182005-05-05 16:45:59 +0000652 if (cpu_has_tlb)
653 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
654
655 return config1 & MIPS_CONF_M;
656}
657
658static inline unsigned int decode_config2(struct cpuinfo_mips *c)
659{
660 unsigned int config2;
661
662 config2 = read_c0_config2();
663
664 if (config2 & MIPS_CONF2_SL)
665 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
666
667 return config2 & MIPS_CONF_M;
668}
669
670static inline unsigned int decode_config3(struct cpuinfo_mips *c)
671{
672 unsigned int config3;
673
674 config3 = read_c0_config3();
675
676 if (config3 & MIPS_CONF3_SM)
677 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000678 if (config3 & MIPS_CONF3_DSP)
679 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000680 if (config3 & MIPS_CONF3_VINT)
681 c->options |= MIPS_CPU_VINT;
682 if (config3 & MIPS_CONF3_VEIC)
683 c->options |= MIPS_CPU_VEIC;
684 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000685 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100686 if (config3 & MIPS_CONF3_ULRI)
687 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000688
689 return config3 & MIPS_CONF_M;
690}
691
Ralf Baechle234fcd12008-03-08 09:56:28 +0000692static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000693{
Ralf Baechle558ce122008-10-29 12:33:34 +0000694 int ok;
695
Ralf Baechle41943182005-05-05 16:45:59 +0000696 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100697 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
698 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000699
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
701
Ralf Baechle558ce122008-10-29 12:33:34 +0000702 ok = decode_config0(c); /* Read Config registers. */
703 BUG_ON(!ok); /* Arch spec violation! */
704 if (ok)
705 ok = decode_config1(c);
706 if (ok)
707 ok = decode_config2(c);
708 if (ok)
709 ok = decode_config3(c);
710
711 mips_probe_watch_registers(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712}
713
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000714static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715{
Ralf Baechle41943182005-05-05 16:45:59 +0000716 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 switch (c->processor_id & 0xff00) {
718 case PRID_IMP_4KC:
719 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000720 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 break;
722 case PRID_IMP_4KEC:
723 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000724 __cpu_name[cpu] = "MIPS 4KEc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 break;
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000726 case PRID_IMP_4KECR2:
727 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000728 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000729 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100731 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000733 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 break;
735 case PRID_IMP_5KC:
736 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000737 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 break;
739 case PRID_IMP_20KC:
740 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000741 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 break;
743 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000744 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000746 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 break;
748 case PRID_IMP_25KF:
749 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000750 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000752 case PRID_IMP_34K:
753 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000754 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000755 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100756 case PRID_IMP_74K:
757 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000758 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100759 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100760 case PRID_IMP_1004K:
761 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000762 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100763 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100765
766 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767}
768
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000769static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770{
Ralf Baechle41943182005-05-05 16:45:59 +0000771 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 switch (c->processor_id & 0xff00) {
773 case PRID_IMP_AU1_REV1:
774 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100775 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 switch ((c->processor_id >> 24) & 0xff) {
777 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000778 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 break;
780 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000781 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 break;
783 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000784 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 break;
786 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000787 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000789 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000790 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100791 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000792 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100793 break;
794 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000795 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000796 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100798 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 break;
800 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 break;
802 }
803}
804
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000805static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806{
Ralf Baechle41943182005-05-05 16:45:59 +0000807 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100808
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 switch (c->processor_id & 0xff00) {
810 case PRID_IMP_SB1:
811 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000812 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100814 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000815 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700817 case PRID_IMP_SB1A:
818 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000819 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700820 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 }
822}
823
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000824static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825{
Ralf Baechle41943182005-05-05 16:45:59 +0000826 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 switch (c->processor_id & 0xff00) {
828 case PRID_IMP_SR71000:
829 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000830 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 c->scache.ways = 8;
832 c->tlbsize = 64;
833 break;
834 }
835}
836
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000837static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000838{
839 decode_configs(c);
840 switch (c->processor_id & 0xff00) {
841 case PRID_IMP_PR4450:
842 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000843 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000844 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000845 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000846 }
847}
848
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000849static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200850{
851 decode_configs(c);
852 switch (c->processor_id & 0xff00) {
853 case PRID_IMP_BCM3302:
Maxime Bizon0de663e2009-08-18 13:23:37 +0100854 /* same as PRID_IMP_BCM6338 */
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200855 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000856 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200857 break;
858 case PRID_IMP_BCM4710:
859 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000860 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200861 break;
Maxime Bizon0de663e2009-08-18 13:23:37 +0100862 case PRID_IMP_BCM6345:
863 c->cputype = CPU_BCM6345;
864 __cpu_name[cpu] = "Broadcom BCM6345";
865 break;
866 case PRID_IMP_BCM6348:
867 c->cputype = CPU_BCM6348;
868 __cpu_name[cpu] = "Broadcom BCM6348";
869 break;
870 case PRID_IMP_BCM4350:
871 switch (c->processor_id & 0xf0) {
872 case PRID_REV_BCM6358:
873 c->cputype = CPU_BCM6358;
874 __cpu_name[cpu] = "Broadcom BCM6358";
875 break;
876 default:
877 c->cputype = CPU_UNKNOWN;
878 break;
879 }
880 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200881 }
882}
883
David Daney0dd47812008-12-11 15:33:26 -0800884static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
885{
886 decode_configs(c);
887 switch (c->processor_id & 0xff00) {
888 case PRID_IMP_CAVIUM_CN38XX:
889 case PRID_IMP_CAVIUM_CN31XX:
890 case PRID_IMP_CAVIUM_CN30XX:
891 case PRID_IMP_CAVIUM_CN58XX:
892 case PRID_IMP_CAVIUM_CN56XX:
893 case PRID_IMP_CAVIUM_CN50XX:
894 case PRID_IMP_CAVIUM_CN52XX:
895 c->cputype = CPU_CAVIUM_OCTEON;
896 __cpu_name[cpu] = "Cavium Octeon";
897 break;
898 default:
899 printk(KERN_INFO "Unknown Octeon chip!\n");
900 c->cputype = CPU_UNKNOWN;
901 break;
902 }
903}
904
Ralf Baechle9966db252007-10-11 23:46:17 +0100905const char *__cpu_name[NR_CPUS];
906
Ralf Baechle234fcd12008-03-08 09:56:28 +0000907__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908{
909 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100910 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911
912 c->processor_id = PRID_IMP_UNKNOWN;
913 c->fpu_id = FPIR_IMP_NONE;
914 c->cputype = CPU_UNKNOWN;
915
916 c->processor_id = read_c0_prid();
917 switch (c->processor_id & 0xff0000) {
918 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000919 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 break;
921 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000922 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923 break;
924 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000925 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926 break;
927 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000928 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200930 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000931 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200932 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000934 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700935 break;
Daniel Lairda92b0582008-03-06 09:07:18 +0000936 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000937 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000938 break;
David Daney0dd47812008-12-11 15:33:26 -0800939 case PRID_COMP_CAVIUM:
940 cpu_probe_cavium(c, cpu);
941 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200943
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000944 BUG_ON(!__cpu_name[cpu]);
945 BUG_ON(c->cputype == CPU_UNKNOWN);
946
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200947 /*
948 * Platform code can force the cpu type to optimize code
949 * generation. In that case be sure the cpu type is correctly
950 * manually setup otherwise it could trigger some nasty bugs.
951 */
952 BUG_ON(current_cpu_type() != c->cputype);
953
Ralf Baechle41943182005-05-05 16:45:59 +0000954 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +0000956
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000957 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +0000958 c->isa_level == MIPS_CPU_ISA_M32R2 ||
959 c->isa_level == MIPS_CPU_ISA_M64R1 ||
960 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +0000961 if (c->fpu_id & MIPS_FPIR_3D)
962 c->ases |= MIPS_ASE_MIPS3D;
963 }
964 }
Ralf Baechle9966db252007-10-11 23:46:17 +0100965
Ralf Baechlef6771db2007-11-08 18:02:29 +0000966 if (cpu_has_mips_r2)
967 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
968 else
969 c->srsets = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970}
971
Ralf Baechle234fcd12008-03-08 09:56:28 +0000972__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973{
974 struct cpuinfo_mips *c = &current_cpu_data;
975
Ralf Baechle9966db252007-10-11 23:46:17 +0100976 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
977 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +0100979 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980}