blob: 9b6633171a1fab4d318caca4e5458a81de0190d9 [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:
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +0000190 case CPU_JZRISC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100193
Ralf Baechle5a812992007-07-17 18:49:48 +0100194 case CPU_RM7000:
195 cpu_wait = rm7k_wait_irqoff;
196 break;
197
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100198 case CPU_24K:
199 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100200 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100201 cpu_wait = r4k_wait;
202 if (read_c0_config7() & MIPS_CONF7_WII)
203 cpu_wait = r4k_wait_irqoff;
204 break;
205
206 case CPU_74K:
207 cpu_wait = r4k_wait;
208 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
209 cpu_wait = r4k_wait_irqoff;
210 break;
211
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900212 case CPU_TX49XX:
213 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900214 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100215 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100216 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100218 case CPU_20KC:
219 /*
220 * WAIT on Rev1.0 has E1, E2, E3 and E16.
221 * WAIT on Rev2.0 and Rev3.0 has E16.
222 * Rev3.1 WAIT is nop, why bother
223 */
224 if ((c->processor_id & 0xff) <= 0x64)
225 break;
226
Ralf Baechle50da4692007-09-14 19:08:43 +0100227 /*
228 * Another rev is incremeting c0_count at a reduced clock
229 * rate while in WAIT mode. So we basically have the choice
230 * between using the cp0 timer as clocksource or avoiding
231 * the WAIT instruction. Until more details are known,
232 * disable the use of WAIT for 20Kc entirely.
233 cpu_wait = r4k_wait;
234 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100235 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100236 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000237 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100238 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100239 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700241 break;
242 }
243}
244
Marc St-Jean9267a302007-06-14 15:55:31 -0600245static inline void check_errata(void)
246{
247 struct cpuinfo_mips *c = &current_cpu_data;
248
249 switch (c->cputype) {
250 case CPU_34K:
251 /*
252 * Erratum "RPS May Cause Incorrect Instruction Execution"
253 * This code only handles VPE0, any SMP/SMTC/RTOS code
254 * making use of VPE1 will be responsable for that VPE.
255 */
256 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
257 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
258 break;
259 default:
260 break;
261 }
262}
263
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264void __init check_bugs32(void)
265{
Marc St-Jean9267a302007-06-14 15:55:31 -0600266 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267}
268
269/*
270 * Probe whether cpu has config register by trying to play with
271 * alternate cache bit and see whether it matters.
272 * It's used by cpu_probe to distinguish between R3000A and R3081.
273 */
274static inline int cpu_has_confreg(void)
275{
276#ifdef CONFIG_CPU_R3000
277 extern unsigned long r3k_cache_size(unsigned long);
278 unsigned long size1, size2;
279 unsigned long cfg = read_c0_conf();
280
281 size1 = r3k_cache_size(ST0_ISC);
282 write_c0_conf(cfg ^ R30XX_CONF_AC);
283 size2 = r3k_cache_size(ST0_ISC);
284 write_c0_conf(cfg);
285 return size1 != size2;
286#else
287 return 0;
288#endif
289}
290
291/*
292 * Get the FPU Implementation/Revision.
293 */
294static inline unsigned long cpu_get_fpu_id(void)
295{
296 unsigned long tmp, fpu_id;
297
298 tmp = read_c0_status();
299 __enable_fpu();
300 fpu_id = read_32bit_cp1_register(CP1_REVISION);
301 write_c0_status(tmp);
302 return fpu_id;
303}
304
305/*
306 * Check the CPU has an FPU the official way.
307 */
308static inline int __cpu_has_fpu(void)
309{
310 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
311}
312
Guenter Roeck91dfc422010-02-02 08:52:20 -0800313static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
314{
315#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800316 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800317 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800318 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800319#endif
320}
321
Ralf Baechle02cf2112005-10-01 13:06:32 +0100322#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 | MIPS_CPU_COUNTER)
324
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000325static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326{
327 switch (c->processor_id & 0xff00) {
328 case PRID_IMP_R2000:
329 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000330 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100332 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
333 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 if (__cpu_has_fpu())
335 c->options |= MIPS_CPU_FPU;
336 c->tlbsize = 64;
337 break;
338 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000339 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
340 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000342 __cpu_name[cpu] = "R3081";
343 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000345 __cpu_name[cpu] = "R3000A";
346 }
347 break;
348 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000350 __cpu_name[cpu] = "R3000";
351 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100353 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
354 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 if (__cpu_has_fpu())
356 c->options |= MIPS_CPU_FPU;
357 c->tlbsize = 64;
358 break;
359 case PRID_IMP_R4000:
360 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000361 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700362 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000363 __cpu_name[cpu] = "R4400PC";
364 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000366 __cpu_name[cpu] = "R4000PC";
367 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000369 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000371 __cpu_name[cpu] = "R4400SC";
372 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000374 __cpu_name[cpu] = "R4000SC";
375 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 }
377
378 c->isa_level = MIPS_CPU_ISA_III;
379 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
380 MIPS_CPU_WATCH | MIPS_CPU_VCE |
381 MIPS_CPU_LLSC;
382 c->tlbsize = 48;
383 break;
384 case PRID_IMP_VR41XX:
385 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 case PRID_REV_VR4111:
387 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000388 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 case PRID_REV_VR4121:
391 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000392 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 break;
394 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000395 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000397 __cpu_name[cpu] = "NEC VR4122";
398 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000400 __cpu_name[cpu] = "NEC VR4181A";
401 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 break;
403 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000404 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000406 __cpu_name[cpu] = "NEC VR4131";
407 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000409 __cpu_name[cpu] = "NEC VR4133";
410 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 break;
412 default:
413 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
414 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000415 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700416 break;
417 }
418 c->isa_level = MIPS_CPU_ISA_III;
419 c->options = R4K_OPTS;
420 c->tlbsize = 32;
421 break;
422 case PRID_IMP_R4300:
423 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000424 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 c->isa_level = MIPS_CPU_ISA_III;
426 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
427 MIPS_CPU_LLSC;
428 c->tlbsize = 32;
429 break;
430 case PRID_IMP_R4600:
431 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000432 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700433 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000434 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
435 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 c->tlbsize = 48;
437 break;
438 #if 0
439 case PRID_IMP_R4650:
440 /*
441 * This processor doesn't have an MMU, so it's not
442 * "real easy" to run Linux on it. It is left purely
443 * for documentation. Commented out because it shares
444 * it's c0_prid id number with the TX3900.
445 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000446 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000447 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 c->isa_level = MIPS_CPU_ISA_III;
449 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
450 c->tlbsize = 48;
451 break;
452 #endif
453 case PRID_IMP_TX39:
454 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100455 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456
457 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
458 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000459 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 c->tlbsize = 64;
461 } else {
462 switch (c->processor_id & 0xff) {
463 case PRID_REV_TX3912:
464 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000465 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 c->tlbsize = 32;
467 break;
468 case PRID_REV_TX3922:
469 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000470 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 c->tlbsize = 64;
472 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473 }
474 }
475 break;
476 case PRID_IMP_R4700:
477 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000478 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479 c->isa_level = MIPS_CPU_ISA_III;
480 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
481 MIPS_CPU_LLSC;
482 c->tlbsize = 48;
483 break;
484 case PRID_IMP_TX49:
485 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000486 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487 c->isa_level = MIPS_CPU_ISA_III;
488 c->options = R4K_OPTS | MIPS_CPU_LLSC;
489 if (!(c->processor_id & 0x08))
490 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
491 c->tlbsize = 48;
492 break;
493 case PRID_IMP_R5000:
494 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000495 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 c->isa_level = MIPS_CPU_ISA_IV;
497 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
498 MIPS_CPU_LLSC;
499 c->tlbsize = 48;
500 break;
501 case PRID_IMP_R5432:
502 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000503 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 c->isa_level = MIPS_CPU_ISA_IV;
505 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
506 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
507 c->tlbsize = 48;
508 break;
509 case PRID_IMP_R5500:
510 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000511 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 c->isa_level = MIPS_CPU_ISA_IV;
513 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
514 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
515 c->tlbsize = 48;
516 break;
517 case PRID_IMP_NEVADA:
518 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000519 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 c->isa_level = MIPS_CPU_ISA_IV;
521 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
522 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
523 c->tlbsize = 48;
524 break;
525 case PRID_IMP_R6000:
526 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000527 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 c->isa_level = MIPS_CPU_ISA_II;
529 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
530 MIPS_CPU_LLSC;
531 c->tlbsize = 32;
532 break;
533 case PRID_IMP_R6000A:
534 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000535 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 c->isa_level = MIPS_CPU_ISA_II;
537 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
538 MIPS_CPU_LLSC;
539 c->tlbsize = 32;
540 break;
541 case PRID_IMP_RM7000:
542 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000543 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700544 c->isa_level = MIPS_CPU_ISA_IV;
545 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
546 MIPS_CPU_LLSC;
547 /*
548 * Undocumented RM7000: Bit 29 in the info register of
549 * the RM7000 v2.0 indicates if the TLB has 48 or 64
550 * entries.
551 *
552 * 29 1 => 64 entry JTLB
553 * 0 => 48 entry JTLB
554 */
555 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
556 break;
557 case PRID_IMP_RM9000:
558 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000559 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 c->isa_level = MIPS_CPU_ISA_IV;
561 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
562 MIPS_CPU_LLSC;
563 /*
564 * Bit 29 in the info register of the RM9000
565 * indicates if the TLB has 48 or 64 entries.
566 *
567 * 29 1 => 64 entry JTLB
568 * 0 => 48 entry JTLB
569 */
570 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
571 break;
572 case PRID_IMP_R8000:
573 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000574 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 c->isa_level = MIPS_CPU_ISA_IV;
576 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
577 MIPS_CPU_FPU | MIPS_CPU_32FPR |
578 MIPS_CPU_LLSC;
579 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
580 break;
581 case PRID_IMP_R10000:
582 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000583 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000585 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 MIPS_CPU_FPU | MIPS_CPU_32FPR |
587 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
588 MIPS_CPU_LLSC;
589 c->tlbsize = 64;
590 break;
591 case PRID_IMP_R12000:
592 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000593 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000595 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 MIPS_CPU_FPU | MIPS_CPU_32FPR |
597 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
598 MIPS_CPU_LLSC;
599 c->tlbsize = 64;
600 break;
Kumba44d921b2006-05-16 22:23:59 -0400601 case PRID_IMP_R14000:
602 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000603 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400604 c->isa_level = MIPS_CPU_ISA_IV;
605 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
606 MIPS_CPU_FPU | MIPS_CPU_32FPR |
607 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
608 MIPS_CPU_LLSC;
609 c->tlbsize = 64;
610 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800611 case PRID_IMP_LOONGSON2:
612 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000613 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800614 c->isa_level = MIPS_CPU_ISA_III;
615 c->options = R4K_OPTS |
616 MIPS_CPU_FPU | MIPS_CPU_LLSC |
617 MIPS_CPU_32FPR;
618 c->tlbsize = 64;
619 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 }
621}
622
Ralf Baechle234fcd12008-03-08 09:56:28 +0000623static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000624 "Unsupported ISA type, c0.config0: %d.";
625
Ralf Baechle41943182005-05-05 16:45:59 +0000626static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627{
Ralf Baechle41943182005-05-05 16:45:59 +0000628 unsigned int config0;
629 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630
Ralf Baechle41943182005-05-05 16:45:59 +0000631 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632
Ralf Baechle41943182005-05-05 16:45:59 +0000633 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100634 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000635 isa = (config0 & MIPS_CONF_AT) >> 13;
636 switch (isa) {
637 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100638 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000639 case 0:
640 c->isa_level = MIPS_CPU_ISA_M32R1;
641 break;
642 case 1:
643 c->isa_level = MIPS_CPU_ISA_M32R2;
644 break;
645 default:
646 goto unknown;
647 }
Ralf Baechle41943182005-05-05 16:45:59 +0000648 break;
649 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100650 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000651 case 0:
652 c->isa_level = MIPS_CPU_ISA_M64R1;
653 break;
654 case 1:
655 c->isa_level = MIPS_CPU_ISA_M64R2;
656 break;
657 default:
658 goto unknown;
659 }
Ralf Baechle41943182005-05-05 16:45:59 +0000660 break;
661 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000662 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000663 }
664
665 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000666
667unknown:
668 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000669}
670
671static inline unsigned int decode_config1(struct cpuinfo_mips *c)
672{
673 unsigned int config1;
674
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000676
677 if (config1 & MIPS_CONF1_MD)
678 c->ases |= MIPS_ASE_MDMX;
679 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000681 if (config1 & MIPS_CONF1_CA)
682 c->ases |= MIPS_ASE_MIPS16;
683 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000685 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 c->options |= MIPS_CPU_FPU;
687 c->options |= MIPS_CPU_32FPR;
688 }
Ralf Baechle41943182005-05-05 16:45:59 +0000689 if (cpu_has_tlb)
690 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
691
692 return config1 & MIPS_CONF_M;
693}
694
695static inline unsigned int decode_config2(struct cpuinfo_mips *c)
696{
697 unsigned int config2;
698
699 config2 = read_c0_config2();
700
701 if (config2 & MIPS_CONF2_SL)
702 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
703
704 return config2 & MIPS_CONF_M;
705}
706
707static inline unsigned int decode_config3(struct cpuinfo_mips *c)
708{
709 unsigned int config3;
710
711 config3 = read_c0_config3();
712
713 if (config3 & MIPS_CONF3_SM)
714 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000715 if (config3 & MIPS_CONF3_DSP)
716 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000717 if (config3 & MIPS_CONF3_VINT)
718 c->options |= MIPS_CPU_VINT;
719 if (config3 & MIPS_CONF3_VEIC)
720 c->options |= MIPS_CPU_VEIC;
721 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000722 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100723 if (config3 & MIPS_CONF3_ULRI)
724 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000725
726 return config3 & MIPS_CONF_M;
727}
728
David Daney1b362e32010-01-22 14:41:15 -0800729static inline unsigned int decode_config4(struct cpuinfo_mips *c)
730{
731 unsigned int config4;
732
733 config4 = read_c0_config4();
734
735 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
736 && cpu_has_tlb)
737 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
738
739 return config4 & MIPS_CONF_M;
740}
741
Ralf Baechle234fcd12008-03-08 09:56:28 +0000742static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000743{
Ralf Baechle558ce122008-10-29 12:33:34 +0000744 int ok;
745
Ralf Baechle41943182005-05-05 16:45:59 +0000746 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100747 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
748 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000749
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
751
Ralf Baechle558ce122008-10-29 12:33:34 +0000752 ok = decode_config0(c); /* Read Config registers. */
753 BUG_ON(!ok); /* Arch spec violation! */
754 if (ok)
755 ok = decode_config1(c);
756 if (ok)
757 ok = decode_config2(c);
758 if (ok)
759 ok = decode_config3(c);
David Daney1b362e32010-01-22 14:41:15 -0800760 if (ok)
761 ok = decode_config4(c);
Ralf Baechle558ce122008-10-29 12:33:34 +0000762
763 mips_probe_watch_registers(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764}
765
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000766static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767{
Ralf Baechle41943182005-05-05 16:45:59 +0000768 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 switch (c->processor_id & 0xff00) {
770 case PRID_IMP_4KC:
771 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000772 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 break;
774 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000775 case PRID_IMP_4KECR2:
776 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000777 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000778 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100780 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000782 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 break;
784 case PRID_IMP_5KC:
785 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000786 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 break;
788 case PRID_IMP_20KC:
789 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000790 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 break;
792 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000793 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000795 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 break;
797 case PRID_IMP_25KF:
798 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000799 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000801 case PRID_IMP_34K:
802 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000803 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000804 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100805 case PRID_IMP_74K:
806 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000807 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100808 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100809 case PRID_IMP_1004K:
810 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000811 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100812 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100814
815 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816}
817
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000818static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819{
Ralf Baechle41943182005-05-05 16:45:59 +0000820 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 switch (c->processor_id & 0xff00) {
822 case PRID_IMP_AU1_REV1:
823 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100824 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 switch ((c->processor_id >> 24) & 0xff) {
826 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000827 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 break;
829 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000830 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 break;
832 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000833 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 break;
835 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000836 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000838 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000839 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100840 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000841 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100842 break;
843 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000844 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000845 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100847 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 break;
849 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 break;
851 }
852}
853
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000854static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855{
Ralf Baechle41943182005-05-05 16:45:59 +0000856 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100857
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858 switch (c->processor_id & 0xff00) {
859 case PRID_IMP_SB1:
860 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000861 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100863 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000864 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700865 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700866 case PRID_IMP_SB1A:
867 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000868 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700869 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 }
871}
872
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000873static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874{
Ralf Baechle41943182005-05-05 16:45:59 +0000875 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 switch (c->processor_id & 0xff00) {
877 case PRID_IMP_SR71000:
878 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000879 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 c->scache.ways = 8;
881 c->tlbsize = 64;
882 break;
883 }
884}
885
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000886static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000887{
888 decode_configs(c);
889 switch (c->processor_id & 0xff00) {
890 case PRID_IMP_PR4450:
891 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000892 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000893 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000894 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000895 }
896}
897
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000898static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200899{
900 decode_configs(c);
901 switch (c->processor_id & 0xff00) {
902 case PRID_IMP_BCM3302:
Maxime Bizon0de663e2009-08-18 13:23:37 +0100903 /* same as PRID_IMP_BCM6338 */
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200904 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000905 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200906 break;
907 case PRID_IMP_BCM4710:
908 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000909 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200910 break;
Maxime Bizon0de663e2009-08-18 13:23:37 +0100911 case PRID_IMP_BCM6345:
912 c->cputype = CPU_BCM6345;
913 __cpu_name[cpu] = "Broadcom BCM6345";
914 break;
915 case PRID_IMP_BCM6348:
916 c->cputype = CPU_BCM6348;
917 __cpu_name[cpu] = "Broadcom BCM6348";
918 break;
919 case PRID_IMP_BCM4350:
920 switch (c->processor_id & 0xf0) {
921 case PRID_REV_BCM6358:
922 c->cputype = CPU_BCM6358;
923 __cpu_name[cpu] = "Broadcom BCM6358";
924 break;
925 default:
926 c->cputype = CPU_UNKNOWN;
927 break;
928 }
929 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200930 }
931}
932
David Daney0dd47812008-12-11 15:33:26 -0800933static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
934{
935 decode_configs(c);
936 switch (c->processor_id & 0xff00) {
937 case PRID_IMP_CAVIUM_CN38XX:
938 case PRID_IMP_CAVIUM_CN31XX:
939 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -0800940 c->cputype = CPU_CAVIUM_OCTEON;
941 __cpu_name[cpu] = "Cavium Octeon";
942 goto platform;
David Daney0dd47812008-12-11 15:33:26 -0800943 case PRID_IMP_CAVIUM_CN58XX:
944 case PRID_IMP_CAVIUM_CN56XX:
945 case PRID_IMP_CAVIUM_CN50XX:
946 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -0800947 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
948 __cpu_name[cpu] = "Cavium Octeon+";
949platform:
David Daney368bf8e2010-01-28 16:52:13 -0800950 if (cpu == 0)
951 __elf_platform = "octeon";
David Daney0dd47812008-12-11 15:33:26 -0800952 break;
953 default:
954 printk(KERN_INFO "Unknown Octeon chip!\n");
955 c->cputype = CPU_UNKNOWN;
956 break;
957 }
958}
959
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +0000960static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
961{
962 decode_configs(c);
963 /* JZRISC does not implement the CP0 counter. */
964 c->options &= ~MIPS_CPU_COUNTER;
965 switch (c->processor_id & 0xff00) {
966 case PRID_IMP_JZRISC:
967 c->cputype = CPU_JZRISC;
968 __cpu_name[cpu] = "Ingenic JZRISC";
969 break;
970 default:
971 panic("Unknown Ingenic Processor ID!");
972 break;
973 }
974}
975
Ralf Baechle9966db252007-10-11 23:46:17 +0100976const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -0800977const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +0100978
Ralf Baechle234fcd12008-03-08 09:56:28 +0000979__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980{
981 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100982 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983
984 c->processor_id = PRID_IMP_UNKNOWN;
985 c->fpu_id = FPIR_IMP_NONE;
986 c->cputype = CPU_UNKNOWN;
987
988 c->processor_id = read_c0_prid();
989 switch (c->processor_id & 0xff0000) {
990 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000991 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992 break;
993 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000994 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995 break;
996 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000997 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998 break;
999 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001000 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001002 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001003 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001004 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001006 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001007 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001008 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001009 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001010 break;
David Daney0dd47812008-12-11 15:33:26 -08001011 case PRID_COMP_CAVIUM:
1012 cpu_probe_cavium(c, cpu);
1013 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001014 case PRID_COMP_INGENIC:
1015 cpu_probe_ingenic(c, cpu);
1016 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001018
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001019 BUG_ON(!__cpu_name[cpu]);
1020 BUG_ON(c->cputype == CPU_UNKNOWN);
1021
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001022 /*
1023 * Platform code can force the cpu type to optimize code
1024 * generation. In that case be sure the cpu type is correctly
1025 * manually setup otherwise it could trigger some nasty bugs.
1026 */
1027 BUG_ON(current_cpu_type() != c->cputype);
1028
Kevin Cernekee0103d232010-05-02 14:43:52 -07001029 if (mips_fpu_disabled)
1030 c->options &= ~MIPS_CPU_FPU;
1031
1032 if (mips_dsp_disabled)
1033 c->ases &= ~MIPS_ASE_DSP;
1034
Ralf Baechle41943182005-05-05 16:45:59 +00001035 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001037
Ralf Baechlee7958bb2005-12-08 13:00:20 +00001038 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +00001039 c->isa_level == MIPS_CPU_ISA_M32R2 ||
1040 c->isa_level == MIPS_CPU_ISA_M64R1 ||
1041 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +00001042 if (c->fpu_id & MIPS_FPIR_3D)
1043 c->ases |= MIPS_ASE_MIPS3D;
1044 }
1045 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001046
Ralf Baechlef6771db2007-11-08 18:02:29 +00001047 if (cpu_has_mips_r2)
1048 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1049 else
1050 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001051
1052 cpu_probe_vmbits(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001053}
1054
Ralf Baechle234fcd12008-03-08 09:56:28 +00001055__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001056{
1057 struct cpuinfo_mips *c = &current_cpu_data;
1058
Ralf Baechle9966db252007-10-11 23:46:17 +01001059 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1060 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001061 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001062 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063}