blob: b9378cd0ce0d117424c49f499ada57b6e3da7cb3 [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>
Wu Zhangjinf8ede0f2009-11-17 01:32:59 +080019#include <linux/module.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Ralf Baechle57599062007-02-18 19:07:31 +000021#include <asm/bugs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <asm/cpu.h>
23#include <asm/fpu.h>
24#include <asm/mipsregs.h>
25#include <asm/system.h>
David Daney654f57b2008-09-23 00:07:16 -070026#include <asm/watch.h>
Chris Dearmana074f0e2009-07-10 01:51:27 -070027#include <asm/spram.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070028/*
29 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
30 * the implementation of the "wait" feature differs between CPU families. This
31 * points to the function that implements CPU specific wait.
32 * The wait instruction stops the pipeline and reduces the power consumption of
33 * the CPU very much.
34 */
Ralf Baechle982f6ff2009-09-17 02:25:07 +020035void (*cpu_wait)(void);
Wu Zhangjinf8ede0f2009-11-17 01:32:59 +080036EXPORT_SYMBOL(cpu_wait);
Linus Torvalds1da177e2005-04-16 15:20:36 -070037
38static void r3081_wait(void)
39{
40 unsigned long cfg = read_c0_conf();
41 write_c0_conf(cfg | R30XX_CONF_HALT);
42}
43
44static void r39xx_wait(void)
45{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090046 local_irq_disable();
47 if (!need_resched())
48 write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
49 local_irq_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070050}
51
Atsushi Nemotoc65a5482007-11-12 02:05:18 +090052extern void r4k_wait(void);
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090053
54/*
55 * This variant is preferable as it allows testing need_resched and going to
56 * sleep depending on the outcome atomically. Unfortunately the "It is
57 * implementation-dependent whether the pipeline restarts when a non-enabled
58 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
59 * using this version a gamble.
60 */
Kevin D. Kissell8531a352008-09-09 21:48:52 +020061void r4k_wait_irqoff(void)
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090062{
63 local_irq_disable();
64 if (!need_resched())
Kevin D. Kissell8531a352008-09-09 21:48:52 +020065 __asm__(" .set push \n"
66 " .set mips3 \n"
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090067 " wait \n"
Kevin D. Kissell8531a352008-09-09 21:48:52 +020068 " .set pop \n");
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090069 local_irq_enable();
Kevin D. Kissell8531a352008-09-09 21:48:52 +020070 __asm__(" .globl __pastwait \n"
71 "__pastwait: \n");
72 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -070073}
74
Ralf Baechle5a812992007-07-17 18:49:48 +010075/*
76 * The RM7000 variant has to handle erratum 38. The workaround is to not
77 * have any pending stores when the WAIT instruction is executed.
78 */
79static void rm7k_wait_irqoff(void)
80{
81 local_irq_disable();
82 if (!need_resched())
83 __asm__(
84 " .set push \n"
85 " .set mips3 \n"
86 " .set noat \n"
87 " mfc0 $1, $12 \n"
88 " sync \n"
89 " mtc0 $1, $12 # stalls until W stage \n"
90 " wait \n"
91 " mtc0 $1, $12 # stalls until W stage \n"
92 " .set pop \n");
93 local_irq_enable();
94}
95
Manuel Lauss2882b0c2009-08-22 18:09:27 +020096/*
97 * The Au1xxx wait is available only if using 32khz counter or
98 * external timer source, but specifically not CP0 Counter.
99 * alchemy/common/time.c may override cpu_wait!
100 */
Pete Popov494900a2005-04-07 00:42:10 +0000101static void au1k_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900103 __asm__(" .set mips3 \n"
104 " cache 0x14, 0(%0) \n"
105 " cache 0x14, 32(%0) \n"
106 " sync \n"
107 " nop \n"
108 " wait \n"
109 " nop \n"
110 " nop \n"
111 " nop \n"
112 " nop \n"
113 " .set mips0 \n"
Ralf Baechle10f650d2005-05-25 13:32:49 +0000114 : : "r" (au1k_wait));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115}
116
Ralf Baechle982f6ff2009-09-17 02:25:07 +0200117static int __initdata nowait;
Ralf Baechle55d04df2005-07-13 19:22:45 +0000118
Atsushi Nemotof49a7472007-02-18 01:02:14 +0900119static int __init wait_disable(char *s)
Ralf Baechle55d04df2005-07-13 19:22:45 +0000120{
121 nowait = 1;
122
123 return 1;
124}
125
126__setup("nowait", wait_disable);
127
Kevin Cernekee0103d232010-05-02 14:43:52 -0700128static int __cpuinitdata mips_fpu_disabled;
129
130static int __init fpu_disable(char *s)
131{
132 cpu_data[0].options &= ~MIPS_CPU_FPU;
133 mips_fpu_disabled = 1;
134
135 return 1;
136}
137
138__setup("nofpu", fpu_disable);
139
140int __cpuinitdata mips_dsp_disabled;
141
142static int __init dsp_disable(char *s)
143{
144 cpu_data[0].ases &= ~MIPS_ASE_DSP;
145 mips_dsp_disabled = 1;
146
147 return 1;
148}
149
150__setup("nodsp", dsp_disable);
151
Atsushi Nemotoc65a5482007-11-12 02:05:18 +0900152void __init check_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153{
154 struct cpuinfo_mips *c = &current_cpu_data;
155
Ralf Baechle55d04df2005-07-13 19:22:45 +0000156 if (nowait) {
Ralf Baechlec2379232006-11-30 01:14:44 +0000157 printk("Wait instruction disabled.\n");
Ralf Baechle55d04df2005-07-13 19:22:45 +0000158 return;
159 }
160
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 switch (c->cputype) {
162 case CPU_R3081:
163 case CPU_R3081E:
164 cpu_wait = r3081_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 break;
166 case CPU_TX3927:
167 cpu_wait = r39xx_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 break;
169 case CPU_R4200:
170/* case CPU_R4300: */
171 case CPU_R4600:
172 case CPU_R4640:
173 case CPU_R4650:
174 case CPU_R4700:
175 case CPU_R5000:
Shinya Kuribayashia644b272009-03-03 18:05:51 +0900176 case CPU_R5500:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 case CPU_NEVADA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 case CPU_4KC:
179 case CPU_4KEC:
180 case CPU_4KSC:
181 case CPU_5KC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 case CPU_25KF:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100183 case CPU_PR4450:
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200184 case CPU_BCM3302:
Maxime Bizon0de663e2009-08-18 13:23:37 +0100185 case CPU_BCM6338:
186 case CPU_BCM6348:
187 case CPU_BCM6358:
David Daney0dd47812008-12-11 15:33:26 -0800188 case CPU_CAVIUM_OCTEON:
David Daney6f329462010-02-10 15:12:48 -0800189 case CPU_CAVIUM_OCTEON_PLUS:
David Daney0e56b382010-10-07 16:03:45 -0700190 case CPU_CAVIUM_OCTEON2:
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +0000191 case CPU_JZRISC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100194
Ralf Baechle5a812992007-07-17 18:49:48 +0100195 case CPU_RM7000:
196 cpu_wait = rm7k_wait_irqoff;
197 break;
198
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100199 case CPU_24K:
200 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100201 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100202 cpu_wait = r4k_wait;
203 if (read_c0_config7() & MIPS_CONF7_WII)
204 cpu_wait = r4k_wait_irqoff;
205 break;
206
207 case CPU_74K:
208 cpu_wait = r4k_wait;
209 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
210 cpu_wait = r4k_wait_irqoff;
211 break;
212
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900213 case CPU_TX49XX:
214 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900215 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100216 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100217 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100219 case CPU_20KC:
220 /*
221 * WAIT on Rev1.0 has E1, E2, E3 and E16.
222 * WAIT on Rev2.0 and Rev3.0 has E16.
223 * Rev3.1 WAIT is nop, why bother
224 */
225 if ((c->processor_id & 0xff) <= 0x64)
226 break;
227
Ralf Baechle50da4692007-09-14 19:08:43 +0100228 /*
229 * Another rev is incremeting c0_count at a reduced clock
230 * rate while in WAIT mode. So we basically have the choice
231 * between using the cp0 timer as clocksource or avoiding
232 * the WAIT instruction. Until more details are known,
233 * disable the use of WAIT for 20Kc entirely.
234 cpu_wait = r4k_wait;
235 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100236 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100237 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000238 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100239 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100240 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 break;
243 }
244}
245
Marc St-Jean9267a302007-06-14 15:55:31 -0600246static inline void check_errata(void)
247{
248 struct cpuinfo_mips *c = &current_cpu_data;
249
250 switch (c->cputype) {
251 case CPU_34K:
252 /*
253 * Erratum "RPS May Cause Incorrect Instruction Execution"
254 * This code only handles VPE0, any SMP/SMTC/RTOS code
255 * making use of VPE1 will be responsable for that VPE.
256 */
257 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
258 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
259 break;
260 default:
261 break;
262 }
263}
264
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265void __init check_bugs32(void)
266{
Marc St-Jean9267a302007-06-14 15:55:31 -0600267 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268}
269
270/*
271 * Probe whether cpu has config register by trying to play with
272 * alternate cache bit and see whether it matters.
273 * It's used by cpu_probe to distinguish between R3000A and R3081.
274 */
275static inline int cpu_has_confreg(void)
276{
277#ifdef CONFIG_CPU_R3000
278 extern unsigned long r3k_cache_size(unsigned long);
279 unsigned long size1, size2;
280 unsigned long cfg = read_c0_conf();
281
282 size1 = r3k_cache_size(ST0_ISC);
283 write_c0_conf(cfg ^ R30XX_CONF_AC);
284 size2 = r3k_cache_size(ST0_ISC);
285 write_c0_conf(cfg);
286 return size1 != size2;
287#else
288 return 0;
289#endif
290}
291
292/*
293 * Get the FPU Implementation/Revision.
294 */
295static inline unsigned long cpu_get_fpu_id(void)
296{
297 unsigned long tmp, fpu_id;
298
299 tmp = read_c0_status();
300 __enable_fpu();
301 fpu_id = read_32bit_cp1_register(CP1_REVISION);
302 write_c0_status(tmp);
303 return fpu_id;
304}
305
306/*
307 * Check the CPU has an FPU the official way.
308 */
309static inline int __cpu_has_fpu(void)
310{
311 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
312}
313
Guenter Roeck91dfc422010-02-02 08:52:20 -0800314static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
315{
316#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800317 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800318 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800319 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800320#endif
321}
322
Ralf Baechle02cf2112005-10-01 13:06:32 +0100323#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 | MIPS_CPU_COUNTER)
325
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000326static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327{
328 switch (c->processor_id & 0xff00) {
329 case PRID_IMP_R2000:
330 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000331 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100333 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
334 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 if (__cpu_has_fpu())
336 c->options |= MIPS_CPU_FPU;
337 c->tlbsize = 64;
338 break;
339 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000340 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
341 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700342 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000343 __cpu_name[cpu] = "R3081";
344 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000346 __cpu_name[cpu] = "R3000A";
347 }
348 break;
349 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000351 __cpu_name[cpu] = "R3000";
352 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100354 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
355 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 if (__cpu_has_fpu())
357 c->options |= MIPS_CPU_FPU;
358 c->tlbsize = 64;
359 break;
360 case PRID_IMP_R4000:
361 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000362 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000364 __cpu_name[cpu] = "R4400PC";
365 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000367 __cpu_name[cpu] = "R4000PC";
368 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000370 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000372 __cpu_name[cpu] = "R4400SC";
373 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000375 __cpu_name[cpu] = "R4000SC";
376 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 }
378
379 c->isa_level = MIPS_CPU_ISA_III;
380 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
381 MIPS_CPU_WATCH | MIPS_CPU_VCE |
382 MIPS_CPU_LLSC;
383 c->tlbsize = 48;
384 break;
385 case PRID_IMP_VR41XX:
386 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 case PRID_REV_VR4111:
388 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000389 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 case PRID_REV_VR4121:
392 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000393 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 break;
395 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000396 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000398 __cpu_name[cpu] = "NEC VR4122";
399 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000401 __cpu_name[cpu] = "NEC VR4181A";
402 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 break;
404 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000405 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000407 __cpu_name[cpu] = "NEC VR4131";
408 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000410 __cpu_name[cpu] = "NEC VR4133";
411 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 break;
413 default:
414 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
415 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000416 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417 break;
418 }
419 c->isa_level = MIPS_CPU_ISA_III;
420 c->options = R4K_OPTS;
421 c->tlbsize = 32;
422 break;
423 case PRID_IMP_R4300:
424 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000425 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426 c->isa_level = MIPS_CPU_ISA_III;
427 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
428 MIPS_CPU_LLSC;
429 c->tlbsize = 32;
430 break;
431 case PRID_IMP_R4600:
432 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000433 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000435 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
436 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437 c->tlbsize = 48;
438 break;
439 #if 0
440 case PRID_IMP_R4650:
441 /*
442 * This processor doesn't have an MMU, so it's not
443 * "real easy" to run Linux on it. It is left purely
444 * for documentation. Commented out because it shares
445 * it's c0_prid id number with the TX3900.
446 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000447 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000448 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 c->isa_level = MIPS_CPU_ISA_III;
450 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
451 c->tlbsize = 48;
452 break;
453 #endif
454 case PRID_IMP_TX39:
455 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100456 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457
458 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
459 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000460 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 c->tlbsize = 64;
462 } else {
463 switch (c->processor_id & 0xff) {
464 case PRID_REV_TX3912:
465 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000466 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 c->tlbsize = 32;
468 break;
469 case PRID_REV_TX3922:
470 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000471 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 c->tlbsize = 64;
473 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 }
475 }
476 break;
477 case PRID_IMP_R4700:
478 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000479 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 c->isa_level = MIPS_CPU_ISA_III;
481 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
482 MIPS_CPU_LLSC;
483 c->tlbsize = 48;
484 break;
485 case PRID_IMP_TX49:
486 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000487 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 c->isa_level = MIPS_CPU_ISA_III;
489 c->options = R4K_OPTS | MIPS_CPU_LLSC;
490 if (!(c->processor_id & 0x08))
491 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
492 c->tlbsize = 48;
493 break;
494 case PRID_IMP_R5000:
495 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000496 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 c->isa_level = MIPS_CPU_ISA_IV;
498 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
499 MIPS_CPU_LLSC;
500 c->tlbsize = 48;
501 break;
502 case PRID_IMP_R5432:
503 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000504 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 c->isa_level = MIPS_CPU_ISA_IV;
506 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
507 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
508 c->tlbsize = 48;
509 break;
510 case PRID_IMP_R5500:
511 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000512 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 c->isa_level = MIPS_CPU_ISA_IV;
514 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
515 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
516 c->tlbsize = 48;
517 break;
518 case PRID_IMP_NEVADA:
519 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000520 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 c->isa_level = MIPS_CPU_ISA_IV;
522 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
523 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
524 c->tlbsize = 48;
525 break;
526 case PRID_IMP_R6000:
527 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000528 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 c->isa_level = MIPS_CPU_ISA_II;
530 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
531 MIPS_CPU_LLSC;
532 c->tlbsize = 32;
533 break;
534 case PRID_IMP_R6000A:
535 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000536 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 c->isa_level = MIPS_CPU_ISA_II;
538 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
539 MIPS_CPU_LLSC;
540 c->tlbsize = 32;
541 break;
542 case PRID_IMP_RM7000:
543 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000544 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 c->isa_level = MIPS_CPU_ISA_IV;
546 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
547 MIPS_CPU_LLSC;
548 /*
549 * Undocumented RM7000: Bit 29 in the info register of
550 * the RM7000 v2.0 indicates if the TLB has 48 or 64
551 * entries.
552 *
553 * 29 1 => 64 entry JTLB
554 * 0 => 48 entry JTLB
555 */
556 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
557 break;
558 case PRID_IMP_RM9000:
559 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000560 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 c->isa_level = MIPS_CPU_ISA_IV;
562 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
563 MIPS_CPU_LLSC;
564 /*
565 * Bit 29 in the info register of the RM9000
566 * indicates if the TLB has 48 or 64 entries.
567 *
568 * 29 1 => 64 entry JTLB
569 * 0 => 48 entry JTLB
570 */
571 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
572 break;
573 case PRID_IMP_R8000:
574 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000575 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 c->isa_level = MIPS_CPU_ISA_IV;
577 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
578 MIPS_CPU_FPU | MIPS_CPU_32FPR |
579 MIPS_CPU_LLSC;
580 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
581 break;
582 case PRID_IMP_R10000:
583 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000584 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000586 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 MIPS_CPU_FPU | MIPS_CPU_32FPR |
588 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
589 MIPS_CPU_LLSC;
590 c->tlbsize = 64;
591 break;
592 case PRID_IMP_R12000:
593 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000594 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000596 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 MIPS_CPU_FPU | MIPS_CPU_32FPR |
598 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
599 MIPS_CPU_LLSC;
600 c->tlbsize = 64;
601 break;
Kumba44d921b2006-05-16 22:23:59 -0400602 case PRID_IMP_R14000:
603 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000604 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400605 c->isa_level = MIPS_CPU_ISA_IV;
606 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
607 MIPS_CPU_FPU | MIPS_CPU_32FPR |
608 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
609 MIPS_CPU_LLSC;
610 c->tlbsize = 64;
611 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800612 case PRID_IMP_LOONGSON2:
613 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000614 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800615 c->isa_level = MIPS_CPU_ISA_III;
616 c->options = R4K_OPTS |
617 MIPS_CPU_FPU | MIPS_CPU_LLSC |
618 MIPS_CPU_32FPR;
619 c->tlbsize = 64;
620 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 }
622}
623
Ralf Baechle234fcd12008-03-08 09:56:28 +0000624static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000625 "Unsupported ISA type, c0.config0: %d.";
626
Ralf Baechle41943182005-05-05 16:45:59 +0000627static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628{
Ralf Baechle41943182005-05-05 16:45:59 +0000629 unsigned int config0;
630 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631
Ralf Baechle41943182005-05-05 16:45:59 +0000632 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633
Ralf Baechle41943182005-05-05 16:45:59 +0000634 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100635 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000636 isa = (config0 & MIPS_CONF_AT) >> 13;
637 switch (isa) {
638 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100639 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000640 case 0:
641 c->isa_level = MIPS_CPU_ISA_M32R1;
642 break;
643 case 1:
644 c->isa_level = MIPS_CPU_ISA_M32R2;
645 break;
646 default:
647 goto unknown;
648 }
Ralf Baechle41943182005-05-05 16:45:59 +0000649 break;
650 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100651 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000652 case 0:
653 c->isa_level = MIPS_CPU_ISA_M64R1;
654 break;
655 case 1:
656 c->isa_level = MIPS_CPU_ISA_M64R2;
657 break;
658 default:
659 goto unknown;
660 }
Ralf Baechle41943182005-05-05 16:45:59 +0000661 break;
662 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000663 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000664 }
665
666 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000667
668unknown:
669 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000670}
671
672static inline unsigned int decode_config1(struct cpuinfo_mips *c)
673{
674 unsigned int config1;
675
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000677
678 if (config1 & MIPS_CONF1_MD)
679 c->ases |= MIPS_ASE_MDMX;
680 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000682 if (config1 & MIPS_CONF1_CA)
683 c->ases |= MIPS_ASE_MIPS16;
684 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000686 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 c->options |= MIPS_CPU_FPU;
688 c->options |= MIPS_CPU_32FPR;
689 }
Ralf Baechle41943182005-05-05 16:45:59 +0000690 if (cpu_has_tlb)
691 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
692
693 return config1 & MIPS_CONF_M;
694}
695
696static inline unsigned int decode_config2(struct cpuinfo_mips *c)
697{
698 unsigned int config2;
699
700 config2 = read_c0_config2();
701
702 if (config2 & MIPS_CONF2_SL)
703 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
704
705 return config2 & MIPS_CONF_M;
706}
707
708static inline unsigned int decode_config3(struct cpuinfo_mips *c)
709{
710 unsigned int config3;
711
712 config3 = read_c0_config3();
713
714 if (config3 & MIPS_CONF3_SM)
715 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000716 if (config3 & MIPS_CONF3_DSP)
717 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000718 if (config3 & MIPS_CONF3_VINT)
719 c->options |= MIPS_CPU_VINT;
720 if (config3 & MIPS_CONF3_VEIC)
721 c->options |= MIPS_CPU_VEIC;
722 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000723 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100724 if (config3 & MIPS_CONF3_ULRI)
725 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000726
727 return config3 & MIPS_CONF_M;
728}
729
David Daney1b362e32010-01-22 14:41:15 -0800730static inline unsigned int decode_config4(struct cpuinfo_mips *c)
731{
732 unsigned int config4;
733
734 config4 = read_c0_config4();
735
736 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
737 && cpu_has_tlb)
738 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
739
740 return config4 & MIPS_CONF_M;
741}
742
Ralf Baechle234fcd12008-03-08 09:56:28 +0000743static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000744{
Ralf Baechle558ce122008-10-29 12:33:34 +0000745 int ok;
746
Ralf Baechle41943182005-05-05 16:45:59 +0000747 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100748 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
749 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000750
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
752
Ralf Baechle558ce122008-10-29 12:33:34 +0000753 ok = decode_config0(c); /* Read Config registers. */
754 BUG_ON(!ok); /* Arch spec violation! */
755 if (ok)
756 ok = decode_config1(c);
757 if (ok)
758 ok = decode_config2(c);
759 if (ok)
760 ok = decode_config3(c);
David Daney1b362e32010-01-22 14:41:15 -0800761 if (ok)
762 ok = decode_config4(c);
Ralf Baechle558ce122008-10-29 12:33:34 +0000763
764 mips_probe_watch_registers(c);
David Daney0c2f4552010-07-26 14:29:37 -0700765
766 if (cpu_has_mips_r2)
767 c->core = read_c0_ebase() & 0x3ff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768}
769
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000770static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771{
Ralf Baechle41943182005-05-05 16:45:59 +0000772 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 switch (c->processor_id & 0xff00) {
774 case PRID_IMP_4KC:
775 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000776 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 break;
778 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000779 case PRID_IMP_4KECR2:
780 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000781 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000782 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100784 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000786 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 break;
788 case PRID_IMP_5KC:
789 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000790 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 break;
792 case PRID_IMP_20KC:
793 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000794 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 break;
796 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000797 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000799 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 break;
801 case PRID_IMP_25KF:
802 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000803 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000805 case PRID_IMP_34K:
806 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000807 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000808 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100809 case PRID_IMP_74K:
810 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000811 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100812 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100813 case PRID_IMP_1004K:
814 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000815 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100816 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100818
819 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820}
821
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000822static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823{
Ralf Baechle41943182005-05-05 16:45:59 +0000824 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 switch (c->processor_id & 0xff00) {
826 case PRID_IMP_AU1_REV1:
827 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100828 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 switch ((c->processor_id >> 24) & 0xff) {
830 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000831 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 break;
833 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000834 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835 break;
836 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000837 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 break;
839 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000840 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000842 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000843 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100844 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000845 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100846 break;
847 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000848 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000849 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100851 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 break;
853 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 break;
855 }
856}
857
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000858static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859{
Ralf Baechle41943182005-05-05 16:45:59 +0000860 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100861
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 switch (c->processor_id & 0xff00) {
863 case PRID_IMP_SB1:
864 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000865 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100867 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000868 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700870 case PRID_IMP_SB1A:
871 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000872 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700873 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874 }
875}
876
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000877static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878{
Ralf Baechle41943182005-05-05 16:45:59 +0000879 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 switch (c->processor_id & 0xff00) {
881 case PRID_IMP_SR71000:
882 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000883 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 c->scache.ways = 8;
885 c->tlbsize = 64;
886 break;
887 }
888}
889
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000890static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000891{
892 decode_configs(c);
893 switch (c->processor_id & 0xff00) {
894 case PRID_IMP_PR4450:
895 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000896 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000897 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000898 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000899 }
900}
901
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000902static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200903{
904 decode_configs(c);
905 switch (c->processor_id & 0xff00) {
906 case PRID_IMP_BCM3302:
Maxime Bizon0de663e2009-08-18 13:23:37 +0100907 /* same as PRID_IMP_BCM6338 */
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200908 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000909 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200910 break;
911 case PRID_IMP_BCM4710:
912 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000913 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200914 break;
Maxime Bizon0de663e2009-08-18 13:23:37 +0100915 case PRID_IMP_BCM6345:
916 c->cputype = CPU_BCM6345;
917 __cpu_name[cpu] = "Broadcom BCM6345";
918 break;
919 case PRID_IMP_BCM6348:
920 c->cputype = CPU_BCM6348;
921 __cpu_name[cpu] = "Broadcom BCM6348";
922 break;
923 case PRID_IMP_BCM4350:
924 switch (c->processor_id & 0xf0) {
925 case PRID_REV_BCM6358:
926 c->cputype = CPU_BCM6358;
927 __cpu_name[cpu] = "Broadcom BCM6358";
928 break;
929 default:
930 c->cputype = CPU_UNKNOWN;
931 break;
932 }
933 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200934 }
935}
936
David Daney0dd47812008-12-11 15:33:26 -0800937static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
938{
939 decode_configs(c);
940 switch (c->processor_id & 0xff00) {
941 case PRID_IMP_CAVIUM_CN38XX:
942 case PRID_IMP_CAVIUM_CN31XX:
943 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -0800944 c->cputype = CPU_CAVIUM_OCTEON;
945 __cpu_name[cpu] = "Cavium Octeon";
946 goto platform;
David Daney0dd47812008-12-11 15:33:26 -0800947 case PRID_IMP_CAVIUM_CN58XX:
948 case PRID_IMP_CAVIUM_CN56XX:
949 case PRID_IMP_CAVIUM_CN50XX:
950 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -0800951 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
952 __cpu_name[cpu] = "Cavium Octeon+";
953platform:
David Daney368bf8e2010-01-28 16:52:13 -0800954 if (cpu == 0)
955 __elf_platform = "octeon";
David Daney0dd47812008-12-11 15:33:26 -0800956 break;
David Daney0e56b382010-10-07 16:03:45 -0700957 case PRID_IMP_CAVIUM_CN63XX:
958 c->cputype = CPU_CAVIUM_OCTEON2;
959 __cpu_name[cpu] = "Cavium Octeon II";
960 if (cpu == 0)
961 __elf_platform = "octeon2";
962 break;
David Daney0dd47812008-12-11 15:33:26 -0800963 default:
964 printk(KERN_INFO "Unknown Octeon chip!\n");
965 c->cputype = CPU_UNKNOWN;
966 break;
967 }
968}
969
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +0000970static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
971{
972 decode_configs(c);
973 /* JZRISC does not implement the CP0 counter. */
974 c->options &= ~MIPS_CPU_COUNTER;
975 switch (c->processor_id & 0xff00) {
976 case PRID_IMP_JZRISC:
977 c->cputype = CPU_JZRISC;
978 __cpu_name[cpu] = "Ingenic JZRISC";
979 break;
980 default:
981 panic("Unknown Ingenic Processor ID!");
982 break;
983 }
984}
985
Ralf Baechle9966db252007-10-11 23:46:17 +0100986const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -0800987const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +0100988
Ralf Baechle234fcd12008-03-08 09:56:28 +0000989__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990{
991 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100992 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993
994 c->processor_id = PRID_IMP_UNKNOWN;
995 c->fpu_id = FPIR_IMP_NONE;
996 c->cputype = CPU_UNKNOWN;
997
998 c->processor_id = read_c0_prid();
999 switch (c->processor_id & 0xff0000) {
1000 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001001 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002 break;
1003 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001004 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 break;
1006 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001007 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008 break;
1009 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001010 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001012 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001013 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001014 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001016 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001018 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001019 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001020 break;
David Daney0dd47812008-12-11 15:33:26 -08001021 case PRID_COMP_CAVIUM:
1022 cpu_probe_cavium(c, cpu);
1023 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001024 case PRID_COMP_INGENIC:
1025 cpu_probe_ingenic(c, cpu);
1026 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001028
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001029 BUG_ON(!__cpu_name[cpu]);
1030 BUG_ON(c->cputype == CPU_UNKNOWN);
1031
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001032 /*
1033 * Platform code can force the cpu type to optimize code
1034 * generation. In that case be sure the cpu type is correctly
1035 * manually setup otherwise it could trigger some nasty bugs.
1036 */
1037 BUG_ON(current_cpu_type() != c->cputype);
1038
Kevin Cernekee0103d232010-05-02 14:43:52 -07001039 if (mips_fpu_disabled)
1040 c->options &= ~MIPS_CPU_FPU;
1041
1042 if (mips_dsp_disabled)
1043 c->ases &= ~MIPS_ASE_DSP;
1044
Ralf Baechle41943182005-05-05 16:45:59 +00001045 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001047
Ralf Baechlee7958bb2005-12-08 13:00:20 +00001048 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +00001049 c->isa_level == MIPS_CPU_ISA_M32R2 ||
1050 c->isa_level == MIPS_CPU_ISA_M64R1 ||
1051 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +00001052 if (c->fpu_id & MIPS_FPIR_3D)
1053 c->ases |= MIPS_ASE_MIPS3D;
1054 }
1055 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001056
Ralf Baechlef6771db2007-11-08 18:02:29 +00001057 if (cpu_has_mips_r2)
1058 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1059 else
1060 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001061
1062 cpu_probe_vmbits(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063}
1064
Ralf Baechle234fcd12008-03-08 09:56:28 +00001065__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066{
1067 struct cpuinfo_mips *c = &current_cpu_data;
1068
Ralf Baechle9966db252007-10-11 23:46:17 +01001069 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1070 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001071 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001072 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073}