blob: 3562b854f2cd4e0e61086073e11534d39479484f [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:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100192
Ralf Baechle5a812992007-07-17 18:49:48 +0100193 case CPU_RM7000:
194 cpu_wait = rm7k_wait_irqoff;
195 break;
196
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100197 case CPU_24K:
198 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100199 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100200 cpu_wait = r4k_wait;
201 if (read_c0_config7() & MIPS_CONF7_WII)
202 cpu_wait = r4k_wait_irqoff;
203 break;
204
205 case CPU_74K:
206 cpu_wait = r4k_wait;
207 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
208 cpu_wait = r4k_wait_irqoff;
209 break;
210
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900211 case CPU_TX49XX:
212 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900213 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100214 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100215 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100217 case CPU_20KC:
218 /*
219 * WAIT on Rev1.0 has E1, E2, E3 and E16.
220 * WAIT on Rev2.0 and Rev3.0 has E16.
221 * Rev3.1 WAIT is nop, why bother
222 */
223 if ((c->processor_id & 0xff) <= 0x64)
224 break;
225
Ralf Baechle50da4692007-09-14 19:08:43 +0100226 /*
227 * Another rev is incremeting c0_count at a reduced clock
228 * rate while in WAIT mode. So we basically have the choice
229 * between using the cp0 timer as clocksource or avoiding
230 * the WAIT instruction. Until more details are known,
231 * disable the use of WAIT for 20Kc entirely.
232 cpu_wait = r4k_wait;
233 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100234 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100235 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000236 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100237 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100238 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 break;
241 }
242}
243
Marc St-Jean9267a302007-06-14 15:55:31 -0600244static inline void check_errata(void)
245{
246 struct cpuinfo_mips *c = &current_cpu_data;
247
248 switch (c->cputype) {
249 case CPU_34K:
250 /*
251 * Erratum "RPS May Cause Incorrect Instruction Execution"
252 * This code only handles VPE0, any SMP/SMTC/RTOS code
253 * making use of VPE1 will be responsable for that VPE.
254 */
255 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
256 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
257 break;
258 default:
259 break;
260 }
261}
262
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263void __init check_bugs32(void)
264{
Marc St-Jean9267a302007-06-14 15:55:31 -0600265 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266}
267
268/*
269 * Probe whether cpu has config register by trying to play with
270 * alternate cache bit and see whether it matters.
271 * It's used by cpu_probe to distinguish between R3000A and R3081.
272 */
273static inline int cpu_has_confreg(void)
274{
275#ifdef CONFIG_CPU_R3000
276 extern unsigned long r3k_cache_size(unsigned long);
277 unsigned long size1, size2;
278 unsigned long cfg = read_c0_conf();
279
280 size1 = r3k_cache_size(ST0_ISC);
281 write_c0_conf(cfg ^ R30XX_CONF_AC);
282 size2 = r3k_cache_size(ST0_ISC);
283 write_c0_conf(cfg);
284 return size1 != size2;
285#else
286 return 0;
287#endif
288}
289
290/*
291 * Get the FPU Implementation/Revision.
292 */
293static inline unsigned long cpu_get_fpu_id(void)
294{
295 unsigned long tmp, fpu_id;
296
297 tmp = read_c0_status();
298 __enable_fpu();
299 fpu_id = read_32bit_cp1_register(CP1_REVISION);
300 write_c0_status(tmp);
301 return fpu_id;
302}
303
304/*
305 * Check the CPU has an FPU the official way.
306 */
307static inline int __cpu_has_fpu(void)
308{
309 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
310}
311
Guenter Roeck91dfc422010-02-02 08:52:20 -0800312static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
313{
314#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800315 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800316 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800317 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800318#endif
319}
320
Ralf Baechle02cf2112005-10-01 13:06:32 +0100321#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700322 | MIPS_CPU_COUNTER)
323
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000324static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325{
326 switch (c->processor_id & 0xff00) {
327 case PRID_IMP_R2000:
328 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000329 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100331 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
332 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 if (__cpu_has_fpu())
334 c->options |= MIPS_CPU_FPU;
335 c->tlbsize = 64;
336 break;
337 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000338 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
339 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000341 __cpu_name[cpu] = "R3081";
342 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000344 __cpu_name[cpu] = "R3000A";
345 }
346 break;
347 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000349 __cpu_name[cpu] = "R3000";
350 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100352 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
353 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 if (__cpu_has_fpu())
355 c->options |= MIPS_CPU_FPU;
356 c->tlbsize = 64;
357 break;
358 case PRID_IMP_R4000:
359 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000360 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000362 __cpu_name[cpu] = "R4400PC";
363 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000365 __cpu_name[cpu] = "R4000PC";
366 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000368 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000370 __cpu_name[cpu] = "R4400SC";
371 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000373 __cpu_name[cpu] = "R4000SC";
374 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 }
376
377 c->isa_level = MIPS_CPU_ISA_III;
378 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
379 MIPS_CPU_WATCH | MIPS_CPU_VCE |
380 MIPS_CPU_LLSC;
381 c->tlbsize = 48;
382 break;
383 case PRID_IMP_VR41XX:
384 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 case PRID_REV_VR4111:
386 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000387 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 case PRID_REV_VR4121:
390 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000391 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 break;
393 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000394 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000396 __cpu_name[cpu] = "NEC VR4122";
397 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000399 __cpu_name[cpu] = "NEC VR4181A";
400 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 break;
402 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000403 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000405 __cpu_name[cpu] = "NEC VR4131";
406 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000408 __cpu_name[cpu] = "NEC VR4133";
409 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 break;
411 default:
412 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
413 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000414 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700415 break;
416 }
417 c->isa_level = MIPS_CPU_ISA_III;
418 c->options = R4K_OPTS;
419 c->tlbsize = 32;
420 break;
421 case PRID_IMP_R4300:
422 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000423 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424 c->isa_level = MIPS_CPU_ISA_III;
425 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
426 MIPS_CPU_LLSC;
427 c->tlbsize = 32;
428 break;
429 case PRID_IMP_R4600:
430 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000431 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000433 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
434 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 c->tlbsize = 48;
436 break;
437 #if 0
438 case PRID_IMP_R4650:
439 /*
440 * This processor doesn't have an MMU, so it's not
441 * "real easy" to run Linux on it. It is left purely
442 * for documentation. Commented out because it shares
443 * it's c0_prid id number with the TX3900.
444 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000445 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000446 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447 c->isa_level = MIPS_CPU_ISA_III;
448 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
449 c->tlbsize = 48;
450 break;
451 #endif
452 case PRID_IMP_TX39:
453 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100454 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455
456 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
457 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000458 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459 c->tlbsize = 64;
460 } else {
461 switch (c->processor_id & 0xff) {
462 case PRID_REV_TX3912:
463 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000464 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 c->tlbsize = 32;
466 break;
467 case PRID_REV_TX3922:
468 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000469 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 c->tlbsize = 64;
471 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 }
473 }
474 break;
475 case PRID_IMP_R4700:
476 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000477 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 c->isa_level = MIPS_CPU_ISA_III;
479 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
480 MIPS_CPU_LLSC;
481 c->tlbsize = 48;
482 break;
483 case PRID_IMP_TX49:
484 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000485 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 c->isa_level = MIPS_CPU_ISA_III;
487 c->options = R4K_OPTS | MIPS_CPU_LLSC;
488 if (!(c->processor_id & 0x08))
489 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
490 c->tlbsize = 48;
491 break;
492 case PRID_IMP_R5000:
493 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000494 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 c->isa_level = MIPS_CPU_ISA_IV;
496 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
497 MIPS_CPU_LLSC;
498 c->tlbsize = 48;
499 break;
500 case PRID_IMP_R5432:
501 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000502 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 c->isa_level = MIPS_CPU_ISA_IV;
504 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
505 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
506 c->tlbsize = 48;
507 break;
508 case PRID_IMP_R5500:
509 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000510 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 c->isa_level = MIPS_CPU_ISA_IV;
512 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
513 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
514 c->tlbsize = 48;
515 break;
516 case PRID_IMP_NEVADA:
517 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000518 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 c->isa_level = MIPS_CPU_ISA_IV;
520 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
521 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
522 c->tlbsize = 48;
523 break;
524 case PRID_IMP_R6000:
525 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000526 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 c->isa_level = MIPS_CPU_ISA_II;
528 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
529 MIPS_CPU_LLSC;
530 c->tlbsize = 32;
531 break;
532 case PRID_IMP_R6000A:
533 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000534 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 c->isa_level = MIPS_CPU_ISA_II;
536 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
537 MIPS_CPU_LLSC;
538 c->tlbsize = 32;
539 break;
540 case PRID_IMP_RM7000:
541 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000542 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 c->isa_level = MIPS_CPU_ISA_IV;
544 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
545 MIPS_CPU_LLSC;
546 /*
547 * Undocumented RM7000: Bit 29 in the info register of
548 * the RM7000 v2.0 indicates if the TLB has 48 or 64
549 * entries.
550 *
551 * 29 1 => 64 entry JTLB
552 * 0 => 48 entry JTLB
553 */
554 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
555 break;
556 case PRID_IMP_RM9000:
557 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000558 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 c->isa_level = MIPS_CPU_ISA_IV;
560 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
561 MIPS_CPU_LLSC;
562 /*
563 * Bit 29 in the info register of the RM9000
564 * indicates if the TLB has 48 or 64 entries.
565 *
566 * 29 1 => 64 entry JTLB
567 * 0 => 48 entry JTLB
568 */
569 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
570 break;
571 case PRID_IMP_R8000:
572 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000573 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 c->isa_level = MIPS_CPU_ISA_IV;
575 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
576 MIPS_CPU_FPU | MIPS_CPU_32FPR |
577 MIPS_CPU_LLSC;
578 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
579 break;
580 case PRID_IMP_R10000:
581 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000582 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000584 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 MIPS_CPU_FPU | MIPS_CPU_32FPR |
586 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
587 MIPS_CPU_LLSC;
588 c->tlbsize = 64;
589 break;
590 case PRID_IMP_R12000:
591 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000592 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000594 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 MIPS_CPU_FPU | MIPS_CPU_32FPR |
596 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
597 MIPS_CPU_LLSC;
598 c->tlbsize = 64;
599 break;
Kumba44d921b2006-05-16 22:23:59 -0400600 case PRID_IMP_R14000:
601 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000602 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400603 c->isa_level = MIPS_CPU_ISA_IV;
604 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
605 MIPS_CPU_FPU | MIPS_CPU_32FPR |
606 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
607 MIPS_CPU_LLSC;
608 c->tlbsize = 64;
609 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800610 case PRID_IMP_LOONGSON2:
611 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000612 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800613 c->isa_level = MIPS_CPU_ISA_III;
614 c->options = R4K_OPTS |
615 MIPS_CPU_FPU | MIPS_CPU_LLSC |
616 MIPS_CPU_32FPR;
617 c->tlbsize = 64;
618 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 }
620}
621
Ralf Baechle234fcd12008-03-08 09:56:28 +0000622static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000623 "Unsupported ISA type, c0.config0: %d.";
624
Ralf Baechle41943182005-05-05 16:45:59 +0000625static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626{
Ralf Baechle41943182005-05-05 16:45:59 +0000627 unsigned int config0;
628 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
Ralf Baechle41943182005-05-05 16:45:59 +0000630 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631
Ralf Baechle41943182005-05-05 16:45:59 +0000632 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100633 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000634 isa = (config0 & MIPS_CONF_AT) >> 13;
635 switch (isa) {
636 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100637 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000638 case 0:
639 c->isa_level = MIPS_CPU_ISA_M32R1;
640 break;
641 case 1:
642 c->isa_level = MIPS_CPU_ISA_M32R2;
643 break;
644 default:
645 goto unknown;
646 }
Ralf Baechle41943182005-05-05 16:45:59 +0000647 break;
648 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100649 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000650 case 0:
651 c->isa_level = MIPS_CPU_ISA_M64R1;
652 break;
653 case 1:
654 c->isa_level = MIPS_CPU_ISA_M64R2;
655 break;
656 default:
657 goto unknown;
658 }
Ralf Baechle41943182005-05-05 16:45:59 +0000659 break;
660 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000661 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000662 }
663
664 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000665
666unknown:
667 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000668}
669
670static inline unsigned int decode_config1(struct cpuinfo_mips *c)
671{
672 unsigned int config1;
673
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000675
676 if (config1 & MIPS_CONF1_MD)
677 c->ases |= MIPS_ASE_MDMX;
678 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000680 if (config1 & MIPS_CONF1_CA)
681 c->ases |= MIPS_ASE_MIPS16;
682 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000684 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 c->options |= MIPS_CPU_FPU;
686 c->options |= MIPS_CPU_32FPR;
687 }
Ralf Baechle41943182005-05-05 16:45:59 +0000688 if (cpu_has_tlb)
689 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
690
691 return config1 & MIPS_CONF_M;
692}
693
694static inline unsigned int decode_config2(struct cpuinfo_mips *c)
695{
696 unsigned int config2;
697
698 config2 = read_c0_config2();
699
700 if (config2 & MIPS_CONF2_SL)
701 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
702
703 return config2 & MIPS_CONF_M;
704}
705
706static inline unsigned int decode_config3(struct cpuinfo_mips *c)
707{
708 unsigned int config3;
709
710 config3 = read_c0_config3();
711
712 if (config3 & MIPS_CONF3_SM)
713 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000714 if (config3 & MIPS_CONF3_DSP)
715 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000716 if (config3 & MIPS_CONF3_VINT)
717 c->options |= MIPS_CPU_VINT;
718 if (config3 & MIPS_CONF3_VEIC)
719 c->options |= MIPS_CPU_VEIC;
720 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000721 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100722 if (config3 & MIPS_CONF3_ULRI)
723 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000724
725 return config3 & MIPS_CONF_M;
726}
727
David Daney1b362e32010-01-22 14:41:15 -0800728static inline unsigned int decode_config4(struct cpuinfo_mips *c)
729{
730 unsigned int config4;
731
732 config4 = read_c0_config4();
733
734 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
735 && cpu_has_tlb)
736 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
737
738 return config4 & MIPS_CONF_M;
739}
740
Ralf Baechle234fcd12008-03-08 09:56:28 +0000741static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000742{
Ralf Baechle558ce122008-10-29 12:33:34 +0000743 int ok;
744
Ralf Baechle41943182005-05-05 16:45:59 +0000745 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100746 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
747 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000748
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
750
Ralf Baechle558ce122008-10-29 12:33:34 +0000751 ok = decode_config0(c); /* Read Config registers. */
752 BUG_ON(!ok); /* Arch spec violation! */
753 if (ok)
754 ok = decode_config1(c);
755 if (ok)
756 ok = decode_config2(c);
757 if (ok)
758 ok = decode_config3(c);
David Daney1b362e32010-01-22 14:41:15 -0800759 if (ok)
760 ok = decode_config4(c);
Ralf Baechle558ce122008-10-29 12:33:34 +0000761
762 mips_probe_watch_registers(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763}
764
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000765static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766{
Ralf Baechle41943182005-05-05 16:45:59 +0000767 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 switch (c->processor_id & 0xff00) {
769 case PRID_IMP_4KC:
770 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000771 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 break;
773 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000774 case PRID_IMP_4KECR2:
775 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000776 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000777 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100779 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000781 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 break;
783 case PRID_IMP_5KC:
784 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000785 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 break;
787 case PRID_IMP_20KC:
788 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000789 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 break;
791 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000792 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000794 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 break;
796 case PRID_IMP_25KF:
797 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000798 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000800 case PRID_IMP_34K:
801 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000802 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000803 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100804 case PRID_IMP_74K:
805 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000806 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100807 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100808 case PRID_IMP_1004K:
809 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000810 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100811 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100813
814 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815}
816
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000817static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818{
Ralf Baechle41943182005-05-05 16:45:59 +0000819 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 switch (c->processor_id & 0xff00) {
821 case PRID_IMP_AU1_REV1:
822 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100823 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 switch ((c->processor_id >> 24) & 0xff) {
825 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000826 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 break;
828 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000829 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 break;
831 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000832 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700833 break;
834 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000835 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000837 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000838 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100839 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000840 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100841 break;
842 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000843 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000844 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100846 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 break;
848 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849 break;
850 }
851}
852
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000853static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854{
Ralf Baechle41943182005-05-05 16:45:59 +0000855 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100856
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 switch (c->processor_id & 0xff00) {
858 case PRID_IMP_SB1:
859 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000860 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100862 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000863 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700865 case PRID_IMP_SB1A:
866 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000867 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700868 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 }
870}
871
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000872static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873{
Ralf Baechle41943182005-05-05 16:45:59 +0000874 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 switch (c->processor_id & 0xff00) {
876 case PRID_IMP_SR71000:
877 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000878 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700879 c->scache.ways = 8;
880 c->tlbsize = 64;
881 break;
882 }
883}
884
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000885static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000886{
887 decode_configs(c);
888 switch (c->processor_id & 0xff00) {
889 case PRID_IMP_PR4450:
890 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000891 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000892 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000893 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000894 }
895}
896
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000897static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200898{
899 decode_configs(c);
900 switch (c->processor_id & 0xff00) {
901 case PRID_IMP_BCM3302:
Maxime Bizon0de663e2009-08-18 13:23:37 +0100902 /* same as PRID_IMP_BCM6338 */
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200903 c->cputype = CPU_BCM3302;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000904 __cpu_name[cpu] = "Broadcom BCM3302";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200905 break;
906 case PRID_IMP_BCM4710:
907 c->cputype = CPU_BCM4710;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000908 __cpu_name[cpu] = "Broadcom BCM4710";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200909 break;
Maxime Bizon0de663e2009-08-18 13:23:37 +0100910 case PRID_IMP_BCM6345:
911 c->cputype = CPU_BCM6345;
912 __cpu_name[cpu] = "Broadcom BCM6345";
913 break;
914 case PRID_IMP_BCM6348:
915 c->cputype = CPU_BCM6348;
916 __cpu_name[cpu] = "Broadcom BCM6348";
917 break;
918 case PRID_IMP_BCM4350:
919 switch (c->processor_id & 0xf0) {
920 case PRID_REV_BCM6358:
921 c->cputype = CPU_BCM6358;
922 __cpu_name[cpu] = "Broadcom BCM6358";
923 break;
924 default:
925 c->cputype = CPU_UNKNOWN;
926 break;
927 }
928 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200929 }
930}
931
David Daney0dd47812008-12-11 15:33:26 -0800932static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
933{
934 decode_configs(c);
935 switch (c->processor_id & 0xff00) {
936 case PRID_IMP_CAVIUM_CN38XX:
937 case PRID_IMP_CAVIUM_CN31XX:
938 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -0800939 c->cputype = CPU_CAVIUM_OCTEON;
940 __cpu_name[cpu] = "Cavium Octeon";
941 goto platform;
David Daney0dd47812008-12-11 15:33:26 -0800942 case PRID_IMP_CAVIUM_CN58XX:
943 case PRID_IMP_CAVIUM_CN56XX:
944 case PRID_IMP_CAVIUM_CN50XX:
945 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -0800946 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
947 __cpu_name[cpu] = "Cavium Octeon+";
948platform:
David Daney368bf8e2010-01-28 16:52:13 -0800949 if (cpu == 0)
950 __elf_platform = "octeon";
David Daney0dd47812008-12-11 15:33:26 -0800951 break;
952 default:
953 printk(KERN_INFO "Unknown Octeon chip!\n");
954 c->cputype = CPU_UNKNOWN;
955 break;
956 }
957}
958
Ralf Baechle9966db252007-10-11 23:46:17 +0100959const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -0800960const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +0100961
Ralf Baechle234fcd12008-03-08 09:56:28 +0000962__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700963{
964 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100965 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700966
967 c->processor_id = PRID_IMP_UNKNOWN;
968 c->fpu_id = FPIR_IMP_NONE;
969 c->cputype = CPU_UNKNOWN;
970
971 c->processor_id = read_c0_prid();
972 switch (c->processor_id & 0xff0000) {
973 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000974 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975 break;
976 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000977 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978 break;
979 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000980 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981 break;
982 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000983 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200985 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000986 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200987 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000989 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990 break;
Daniel Lairda92b0582008-03-06 09:07:18 +0000991 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000992 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000993 break;
David Daney0dd47812008-12-11 15:33:26 -0800994 case PRID_COMP_CAVIUM:
995 cpu_probe_cavium(c, cpu);
996 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +0200998
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000999 BUG_ON(!__cpu_name[cpu]);
1000 BUG_ON(c->cputype == CPU_UNKNOWN);
1001
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001002 /*
1003 * Platform code can force the cpu type to optimize code
1004 * generation. In that case be sure the cpu type is correctly
1005 * manually setup otherwise it could trigger some nasty bugs.
1006 */
1007 BUG_ON(current_cpu_type() != c->cputype);
1008
Kevin Cernekee0103d232010-05-02 14:43:52 -07001009 if (mips_fpu_disabled)
1010 c->options &= ~MIPS_CPU_FPU;
1011
1012 if (mips_dsp_disabled)
1013 c->ases &= ~MIPS_ASE_DSP;
1014
Ralf Baechle41943182005-05-05 16:45:59 +00001015 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001017
Ralf Baechlee7958bb2005-12-08 13:00:20 +00001018 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +00001019 c->isa_level == MIPS_CPU_ISA_M32R2 ||
1020 c->isa_level == MIPS_CPU_ISA_M64R1 ||
1021 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +00001022 if (c->fpu_id & MIPS_FPIR_3D)
1023 c->ases |= MIPS_ASE_MIPS3D;
1024 }
1025 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001026
Ralf Baechlef6771db2007-11-08 18:02:29 +00001027 if (cpu_has_mips_r2)
1028 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1029 else
1030 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001031
1032 cpu_probe_vmbits(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001033}
1034
Ralf Baechle234fcd12008-03-08 09:56:28 +00001035__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001036{
1037 struct cpuinfo_mips *c = &current_cpu_data;
1038
Ralf Baechle9966db252007-10-11 23:46:17 +01001039 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1040 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001042 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043}