blob: 71620e19827ad681a7834f0e400104cec4968ef2 [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>
David Daney949e51b2010-10-14 11:32:33 -070028#include <asm/uaccess.h>
29
Linus Torvalds1da177e2005-04-16 15:20:36 -070030/*
31 * Not all of the MIPS CPUs have the "wait" instruction available. Moreover,
32 * the implementation of the "wait" feature differs between CPU families. This
33 * points to the function that implements CPU specific wait.
34 * The wait instruction stops the pipeline and reduces the power consumption of
35 * the CPU very much.
36 */
Ralf Baechle982f6ff2009-09-17 02:25:07 +020037void (*cpu_wait)(void);
Wu Zhangjinf8ede0f2009-11-17 01:32:59 +080038EXPORT_SYMBOL(cpu_wait);
Linus Torvalds1da177e2005-04-16 15:20:36 -070039
40static void r3081_wait(void)
41{
42 unsigned long cfg = read_c0_conf();
43 write_c0_conf(cfg | R30XX_CONF_HALT);
44}
45
46static void r39xx_wait(void)
47{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090048 local_irq_disable();
49 if (!need_resched())
50 write_c0_conf(read_c0_conf() | TX39_CONF_HALT);
51 local_irq_enable();
Linus Torvalds1da177e2005-04-16 15:20:36 -070052}
53
Atsushi Nemotoc65a5482007-11-12 02:05:18 +090054extern void r4k_wait(void);
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090055
56/*
57 * This variant is preferable as it allows testing need_resched and going to
58 * sleep depending on the outcome atomically. Unfortunately the "It is
59 * implementation-dependent whether the pipeline restarts when a non-enabled
60 * interrupt is requested" restriction in the MIPS32/MIPS64 architecture makes
61 * using this version a gamble.
62 */
Kevin D. Kissell8531a352008-09-09 21:48:52 +020063void r4k_wait_irqoff(void)
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090064{
65 local_irq_disable();
66 if (!need_resched())
Kevin D. Kissell8531a352008-09-09 21:48:52 +020067 __asm__(" .set push \n"
68 " .set mips3 \n"
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090069 " wait \n"
Kevin D. Kissell8531a352008-09-09 21:48:52 +020070 " .set pop \n");
Atsushi Nemoto60a6c372006-06-08 01:09:01 +090071 local_irq_enable();
Kevin D. Kissell8531a352008-09-09 21:48:52 +020072 __asm__(" .globl __pastwait \n"
73 "__pastwait: \n");
74 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -070075}
76
Ralf Baechle5a812992007-07-17 18:49:48 +010077/*
78 * The RM7000 variant has to handle erratum 38. The workaround is to not
79 * have any pending stores when the WAIT instruction is executed.
80 */
81static void rm7k_wait_irqoff(void)
82{
83 local_irq_disable();
84 if (!need_resched())
85 __asm__(
86 " .set push \n"
87 " .set mips3 \n"
88 " .set noat \n"
89 " mfc0 $1, $12 \n"
90 " sync \n"
91 " mtc0 $1, $12 # stalls until W stage \n"
92 " wait \n"
93 " mtc0 $1, $12 # stalls until W stage \n"
94 " .set pop \n");
95 local_irq_enable();
96}
97
Manuel Lauss2882b0c2009-08-22 18:09:27 +020098/*
99 * The Au1xxx wait is available only if using 32khz counter or
100 * external timer source, but specifically not CP0 Counter.
101 * alchemy/common/time.c may override cpu_wait!
102 */
Pete Popov494900a2005-04-07 00:42:10 +0000103static void au1k_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900105 __asm__(" .set mips3 \n"
106 " cache 0x14, 0(%0) \n"
107 " cache 0x14, 32(%0) \n"
108 " sync \n"
109 " nop \n"
110 " wait \n"
111 " nop \n"
112 " nop \n"
113 " nop \n"
114 " nop \n"
115 " .set mips0 \n"
Ralf Baechle10f650d2005-05-25 13:32:49 +0000116 : : "r" (au1k_wait));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117}
118
Ralf Baechle982f6ff2009-09-17 02:25:07 +0200119static int __initdata nowait;
Ralf Baechle55d04df2005-07-13 19:22:45 +0000120
Atsushi Nemotof49a7472007-02-18 01:02:14 +0900121static int __init wait_disable(char *s)
Ralf Baechle55d04df2005-07-13 19:22:45 +0000122{
123 nowait = 1;
124
125 return 1;
126}
127
128__setup("nowait", wait_disable);
129
Kevin Cernekee0103d232010-05-02 14:43:52 -0700130static int __cpuinitdata mips_fpu_disabled;
131
132static int __init fpu_disable(char *s)
133{
134 cpu_data[0].options &= ~MIPS_CPU_FPU;
135 mips_fpu_disabled = 1;
136
137 return 1;
138}
139
140__setup("nofpu", fpu_disable);
141
142int __cpuinitdata mips_dsp_disabled;
143
144static int __init dsp_disable(char *s)
145{
146 cpu_data[0].ases &= ~MIPS_ASE_DSP;
147 mips_dsp_disabled = 1;
148
149 return 1;
150}
151
152__setup("nodsp", dsp_disable);
153
Atsushi Nemotoc65a5482007-11-12 02:05:18 +0900154void __init check_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155{
156 struct cpuinfo_mips *c = &current_cpu_data;
157
Ralf Baechle55d04df2005-07-13 19:22:45 +0000158 if (nowait) {
Ralf Baechlec2379232006-11-30 01:14:44 +0000159 printk("Wait instruction disabled.\n");
Ralf Baechle55d04df2005-07-13 19:22:45 +0000160 return;
161 }
162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 switch (c->cputype) {
164 case CPU_R3081:
165 case CPU_R3081E:
166 cpu_wait = r3081_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167 break;
168 case CPU_TX3927:
169 cpu_wait = r39xx_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 break;
171 case CPU_R4200:
172/* case CPU_R4300: */
173 case CPU_R4600:
174 case CPU_R4640:
175 case CPU_R4650:
176 case CPU_R4700:
177 case CPU_R5000:
Shinya Kuribayashia644b272009-03-03 18:05:51 +0900178 case CPU_R5500:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 case CPU_NEVADA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 case CPU_4KC:
181 case CPU_4KEC:
182 case CPU_4KSC:
183 case CPU_5KC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 case CPU_25KF:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100185 case CPU_PR4450:
Kevin Cernekee602977b2010-10-16 14:22:30 -0700186 case CPU_BMIPS3300:
187 case CPU_BMIPS4350:
188 case CPU_BMIPS4380:
189 case CPU_BMIPS5000:
David Daney0dd47812008-12-11 15:33:26 -0800190 case CPU_CAVIUM_OCTEON:
David Daney6f329462010-02-10 15:12:48 -0800191 case CPU_CAVIUM_OCTEON_PLUS:
David Daney0e56b382010-10-07 16:03:45 -0700192 case CPU_CAVIUM_OCTEON2:
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +0000193 case CPU_JZRISC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100196
Ralf Baechle5a812992007-07-17 18:49:48 +0100197 case CPU_RM7000:
198 cpu_wait = rm7k_wait_irqoff;
199 break;
200
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100201 case CPU_24K:
202 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100203 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100204 cpu_wait = r4k_wait;
205 if (read_c0_config7() & MIPS_CONF7_WII)
206 cpu_wait = r4k_wait_irqoff;
207 break;
208
209 case CPU_74K:
210 cpu_wait = r4k_wait;
211 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
212 cpu_wait = r4k_wait_irqoff;
213 break;
214
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900215 case CPU_TX49XX:
216 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900217 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100218 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100219 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100221 case CPU_20KC:
222 /*
223 * WAIT on Rev1.0 has E1, E2, E3 and E16.
224 * WAIT on Rev2.0 and Rev3.0 has E16.
225 * Rev3.1 WAIT is nop, why bother
226 */
227 if ((c->processor_id & 0xff) <= 0x64)
228 break;
229
Ralf Baechle50da4692007-09-14 19:08:43 +0100230 /*
231 * Another rev is incremeting c0_count at a reduced clock
232 * rate while in WAIT mode. So we basically have the choice
233 * between using the cp0 timer as clocksource or avoiding
234 * the WAIT instruction. Until more details are known,
235 * disable the use of WAIT for 20Kc entirely.
236 cpu_wait = r4k_wait;
237 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100238 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100239 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000240 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100241 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100242 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 break;
245 }
246}
247
Marc St-Jean9267a302007-06-14 15:55:31 -0600248static inline void check_errata(void)
249{
250 struct cpuinfo_mips *c = &current_cpu_data;
251
252 switch (c->cputype) {
253 case CPU_34K:
254 /*
255 * Erratum "RPS May Cause Incorrect Instruction Execution"
256 * This code only handles VPE0, any SMP/SMTC/RTOS code
257 * making use of VPE1 will be responsable for that VPE.
258 */
259 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
260 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
261 break;
262 default:
263 break;
264 }
265}
266
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267void __init check_bugs32(void)
268{
Marc St-Jean9267a302007-06-14 15:55:31 -0600269 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270}
271
272/*
273 * Probe whether cpu has config register by trying to play with
274 * alternate cache bit and see whether it matters.
275 * It's used by cpu_probe to distinguish between R3000A and R3081.
276 */
277static inline int cpu_has_confreg(void)
278{
279#ifdef CONFIG_CPU_R3000
280 extern unsigned long r3k_cache_size(unsigned long);
281 unsigned long size1, size2;
282 unsigned long cfg = read_c0_conf();
283
284 size1 = r3k_cache_size(ST0_ISC);
285 write_c0_conf(cfg ^ R30XX_CONF_AC);
286 size2 = r3k_cache_size(ST0_ISC);
287 write_c0_conf(cfg);
288 return size1 != size2;
289#else
290 return 0;
291#endif
292}
293
294/*
295 * Get the FPU Implementation/Revision.
296 */
297static inline unsigned long cpu_get_fpu_id(void)
298{
299 unsigned long tmp, fpu_id;
300
301 tmp = read_c0_status();
302 __enable_fpu();
303 fpu_id = read_32bit_cp1_register(CP1_REVISION);
304 write_c0_status(tmp);
305 return fpu_id;
306}
307
308/*
309 * Check the CPU has an FPU the official way.
310 */
311static inline int __cpu_has_fpu(void)
312{
313 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
314}
315
Guenter Roeck91dfc422010-02-02 08:52:20 -0800316static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
317{
318#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800319 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800320 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800321 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800322#endif
323}
324
Ralf Baechle02cf2112005-10-01 13:06:32 +0100325#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 | MIPS_CPU_COUNTER)
327
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000328static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329{
330 switch (c->processor_id & 0xff00) {
331 case PRID_IMP_R2000:
332 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000333 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100335 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
336 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 if (__cpu_has_fpu())
338 c->options |= MIPS_CPU_FPU;
339 c->tlbsize = 64;
340 break;
341 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000342 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
343 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000345 __cpu_name[cpu] = "R3081";
346 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700347 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000348 __cpu_name[cpu] = "R3000A";
349 }
350 break;
351 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000353 __cpu_name[cpu] = "R3000";
354 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100356 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
357 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 if (__cpu_has_fpu())
359 c->options |= MIPS_CPU_FPU;
360 c->tlbsize = 64;
361 break;
362 case PRID_IMP_R4000:
363 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000364 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000366 __cpu_name[cpu] = "R4400PC";
367 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000369 __cpu_name[cpu] = "R4000PC";
370 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000372 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000374 __cpu_name[cpu] = "R4400SC";
375 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000377 __cpu_name[cpu] = "R4000SC";
378 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 }
380
381 c->isa_level = MIPS_CPU_ISA_III;
382 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
383 MIPS_CPU_WATCH | MIPS_CPU_VCE |
384 MIPS_CPU_LLSC;
385 c->tlbsize = 48;
386 break;
387 case PRID_IMP_VR41XX:
388 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 case PRID_REV_VR4111:
390 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000391 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 case PRID_REV_VR4121:
394 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000395 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 break;
397 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000398 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000400 __cpu_name[cpu] = "NEC VR4122";
401 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000403 __cpu_name[cpu] = "NEC VR4181A";
404 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 break;
406 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000407 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000409 __cpu_name[cpu] = "NEC VR4131";
410 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000412 __cpu_name[cpu] = "NEC VR4133";
413 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 break;
415 default:
416 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
417 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000418 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419 break;
420 }
421 c->isa_level = MIPS_CPU_ISA_III;
422 c->options = R4K_OPTS;
423 c->tlbsize = 32;
424 break;
425 case PRID_IMP_R4300:
426 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000427 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428 c->isa_level = MIPS_CPU_ISA_III;
429 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
430 MIPS_CPU_LLSC;
431 c->tlbsize = 32;
432 break;
433 case PRID_IMP_R4600:
434 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000435 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000437 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
438 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 c->tlbsize = 48;
440 break;
441 #if 0
442 case PRID_IMP_R4650:
443 /*
444 * This processor doesn't have an MMU, so it's not
445 * "real easy" to run Linux on it. It is left purely
446 * for documentation. Commented out because it shares
447 * it's c0_prid id number with the TX3900.
448 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000449 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000450 __cpu_name[cpu] = "R4650";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 c->isa_level = MIPS_CPU_ISA_III;
452 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
453 c->tlbsize = 48;
454 break;
455 #endif
456 case PRID_IMP_TX39:
457 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100458 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459
460 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
461 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000462 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 c->tlbsize = 64;
464 } else {
465 switch (c->processor_id & 0xff) {
466 case PRID_REV_TX3912:
467 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000468 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 c->tlbsize = 32;
470 break;
471 case PRID_REV_TX3922:
472 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000473 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 c->tlbsize = 64;
475 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 }
477 }
478 break;
479 case PRID_IMP_R4700:
480 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000481 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482 c->isa_level = MIPS_CPU_ISA_III;
483 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
484 MIPS_CPU_LLSC;
485 c->tlbsize = 48;
486 break;
487 case PRID_IMP_TX49:
488 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000489 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 c->isa_level = MIPS_CPU_ISA_III;
491 c->options = R4K_OPTS | MIPS_CPU_LLSC;
492 if (!(c->processor_id & 0x08))
493 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
494 c->tlbsize = 48;
495 break;
496 case PRID_IMP_R5000:
497 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000498 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 c->isa_level = MIPS_CPU_ISA_IV;
500 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
501 MIPS_CPU_LLSC;
502 c->tlbsize = 48;
503 break;
504 case PRID_IMP_R5432:
505 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000506 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 c->isa_level = MIPS_CPU_ISA_IV;
508 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
509 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
510 c->tlbsize = 48;
511 break;
512 case PRID_IMP_R5500:
513 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000514 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 c->isa_level = MIPS_CPU_ISA_IV;
516 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
517 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
518 c->tlbsize = 48;
519 break;
520 case PRID_IMP_NEVADA:
521 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000522 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 c->isa_level = MIPS_CPU_ISA_IV;
524 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
525 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
526 c->tlbsize = 48;
527 break;
528 case PRID_IMP_R6000:
529 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000530 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 c->isa_level = MIPS_CPU_ISA_II;
532 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
533 MIPS_CPU_LLSC;
534 c->tlbsize = 32;
535 break;
536 case PRID_IMP_R6000A:
537 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000538 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 c->isa_level = MIPS_CPU_ISA_II;
540 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
541 MIPS_CPU_LLSC;
542 c->tlbsize = 32;
543 break;
544 case PRID_IMP_RM7000:
545 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000546 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 c->isa_level = MIPS_CPU_ISA_IV;
548 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
549 MIPS_CPU_LLSC;
550 /*
551 * Undocumented RM7000: Bit 29 in the info register of
552 * the RM7000 v2.0 indicates if the TLB has 48 or 64
553 * entries.
554 *
555 * 29 1 => 64 entry JTLB
556 * 0 => 48 entry JTLB
557 */
558 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
559 break;
560 case PRID_IMP_RM9000:
561 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000562 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 c->isa_level = MIPS_CPU_ISA_IV;
564 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
565 MIPS_CPU_LLSC;
566 /*
567 * Bit 29 in the info register of the RM9000
568 * indicates if the TLB has 48 or 64 entries.
569 *
570 * 29 1 => 64 entry JTLB
571 * 0 => 48 entry JTLB
572 */
573 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
574 break;
575 case PRID_IMP_R8000:
576 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000577 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 c->isa_level = MIPS_CPU_ISA_IV;
579 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
580 MIPS_CPU_FPU | MIPS_CPU_32FPR |
581 MIPS_CPU_LLSC;
582 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
583 break;
584 case PRID_IMP_R10000:
585 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000586 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000588 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 MIPS_CPU_FPU | MIPS_CPU_32FPR |
590 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
591 MIPS_CPU_LLSC;
592 c->tlbsize = 64;
593 break;
594 case PRID_IMP_R12000:
595 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000596 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000598 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 MIPS_CPU_FPU | MIPS_CPU_32FPR |
600 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
601 MIPS_CPU_LLSC;
602 c->tlbsize = 64;
603 break;
Kumba44d921b2006-05-16 22:23:59 -0400604 case PRID_IMP_R14000:
605 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000606 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400607 c->isa_level = MIPS_CPU_ISA_IV;
608 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
609 MIPS_CPU_FPU | MIPS_CPU_32FPR |
610 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
611 MIPS_CPU_LLSC;
612 c->tlbsize = 64;
613 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800614 case PRID_IMP_LOONGSON2:
615 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000616 __cpu_name[cpu] = "ICT Loongson-2";
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800617 c->isa_level = MIPS_CPU_ISA_III;
618 c->options = R4K_OPTS |
619 MIPS_CPU_FPU | MIPS_CPU_LLSC |
620 MIPS_CPU_32FPR;
621 c->tlbsize = 64;
622 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 }
624}
625
Ralf Baechle234fcd12008-03-08 09:56:28 +0000626static char unknown_isa[] __cpuinitdata = KERN_ERR \
Ralf Baechleb4672d32005-12-08 14:04:24 +0000627 "Unsupported ISA type, c0.config0: %d.";
628
Ralf Baechle41943182005-05-05 16:45:59 +0000629static inline unsigned int decode_config0(struct cpuinfo_mips *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630{
Ralf Baechle41943182005-05-05 16:45:59 +0000631 unsigned int config0;
632 int isa;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633
Ralf Baechle41943182005-05-05 16:45:59 +0000634 config0 = read_c0_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635
Ralf Baechle41943182005-05-05 16:45:59 +0000636 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
Ralf Baechle02cf2112005-10-01 13:06:32 +0100637 c->options |= MIPS_CPU_TLB;
Ralf Baechle41943182005-05-05 16:45:59 +0000638 isa = (config0 & MIPS_CONF_AT) >> 13;
639 switch (isa) {
640 case 0:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100641 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000642 case 0:
643 c->isa_level = MIPS_CPU_ISA_M32R1;
644 break;
645 case 1:
646 c->isa_level = MIPS_CPU_ISA_M32R2;
647 break;
648 default:
649 goto unknown;
650 }
Ralf Baechle41943182005-05-05 16:45:59 +0000651 break;
652 case 2:
Thiemo Seufer3a01c492006-07-03 13:30:01 +0100653 switch ((config0 & MIPS_CONF_AR) >> 10) {
Ralf Baechleb4672d32005-12-08 14:04:24 +0000654 case 0:
655 c->isa_level = MIPS_CPU_ISA_M64R1;
656 break;
657 case 1:
658 c->isa_level = MIPS_CPU_ISA_M64R2;
659 break;
660 default:
661 goto unknown;
662 }
Ralf Baechle41943182005-05-05 16:45:59 +0000663 break;
664 default:
Ralf Baechleb4672d32005-12-08 14:04:24 +0000665 goto unknown;
Ralf Baechle41943182005-05-05 16:45:59 +0000666 }
667
668 return config0 & MIPS_CONF_M;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000669
670unknown:
671 panic(unknown_isa, config0);
Ralf Baechle41943182005-05-05 16:45:59 +0000672}
673
674static inline unsigned int decode_config1(struct cpuinfo_mips *c)
675{
676 unsigned int config1;
677
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 config1 = read_c0_config1();
Ralf Baechle41943182005-05-05 16:45:59 +0000679
680 if (config1 & MIPS_CONF1_MD)
681 c->ases |= MIPS_ASE_MDMX;
682 if (config1 & MIPS_CONF1_WR)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 c->options |= MIPS_CPU_WATCH;
Ralf Baechle41943182005-05-05 16:45:59 +0000684 if (config1 & MIPS_CONF1_CA)
685 c->ases |= MIPS_ASE_MIPS16;
686 if (config1 & MIPS_CONF1_EP)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 c->options |= MIPS_CPU_EJTAG;
Ralf Baechle41943182005-05-05 16:45:59 +0000688 if (config1 & MIPS_CONF1_FP) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 c->options |= MIPS_CPU_FPU;
690 c->options |= MIPS_CPU_32FPR;
691 }
Ralf Baechle41943182005-05-05 16:45:59 +0000692 if (cpu_has_tlb)
693 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
694
695 return config1 & MIPS_CONF_M;
696}
697
698static inline unsigned int decode_config2(struct cpuinfo_mips *c)
699{
700 unsigned int config2;
701
702 config2 = read_c0_config2();
703
704 if (config2 & MIPS_CONF2_SL)
705 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
706
707 return config2 & MIPS_CONF_M;
708}
709
710static inline unsigned int decode_config3(struct cpuinfo_mips *c)
711{
712 unsigned int config3;
713
714 config3 = read_c0_config3();
715
716 if (config3 & MIPS_CONF3_SM)
717 c->ases |= MIPS_ASE_SMARTMIPS;
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000718 if (config3 & MIPS_CONF3_DSP)
719 c->ases |= MIPS_ASE_DSP;
Ralf Baechle8f406112005-07-14 07:34:18 +0000720 if (config3 & MIPS_CONF3_VINT)
721 c->options |= MIPS_CPU_VINT;
722 if (config3 & MIPS_CONF3_VEIC)
723 c->options |= MIPS_CPU_VEIC;
724 if (config3 & MIPS_CONF3_MT)
Ralf Baechlee0daad42007-02-05 00:10:11 +0000725 c->ases |= MIPS_ASE_MIPSMT;
Ralf Baechlea3692022007-07-10 17:33:02 +0100726 if (config3 & MIPS_CONF3_ULRI)
727 c->options |= MIPS_CPU_ULRI;
Ralf Baechle41943182005-05-05 16:45:59 +0000728
729 return config3 & MIPS_CONF_M;
730}
731
David Daney1b362e32010-01-22 14:41:15 -0800732static inline unsigned int decode_config4(struct cpuinfo_mips *c)
733{
734 unsigned int config4;
735
736 config4 = read_c0_config4();
737
738 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
739 && cpu_has_tlb)
740 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
741
742 return config4 & MIPS_CONF_M;
743}
744
Ralf Baechle234fcd12008-03-08 09:56:28 +0000745static void __cpuinit decode_configs(struct cpuinfo_mips *c)
Ralf Baechle41943182005-05-05 16:45:59 +0000746{
Ralf Baechle558ce122008-10-29 12:33:34 +0000747 int ok;
748
Ralf Baechle41943182005-05-05 16:45:59 +0000749 /* MIPS32 or MIPS64 compliant CPU. */
Ralf Baechle02cf2112005-10-01 13:06:32 +0100750 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
751 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
Ralf Baechle41943182005-05-05 16:45:59 +0000752
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
754
Ralf Baechle558ce122008-10-29 12:33:34 +0000755 ok = decode_config0(c); /* Read Config registers. */
756 BUG_ON(!ok); /* Arch spec violation! */
757 if (ok)
758 ok = decode_config1(c);
759 if (ok)
760 ok = decode_config2(c);
761 if (ok)
762 ok = decode_config3(c);
David Daney1b362e32010-01-22 14:41:15 -0800763 if (ok)
764 ok = decode_config4(c);
Ralf Baechle558ce122008-10-29 12:33:34 +0000765
766 mips_probe_watch_registers(c);
David Daney0c2f4552010-07-26 14:29:37 -0700767
768 if (cpu_has_mips_r2)
769 c->core = read_c0_ebase() & 0x3ff;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770}
771
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000772static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773{
Ralf Baechle41943182005-05-05 16:45:59 +0000774 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 switch (c->processor_id & 0xff00) {
776 case PRID_IMP_4KC:
777 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000778 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 break;
780 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000781 case PRID_IMP_4KECR2:
782 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000783 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000784 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100786 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000788 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 break;
790 case PRID_IMP_5KC:
791 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000792 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700793 break;
794 case PRID_IMP_20KC:
795 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000796 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 break;
798 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000799 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000801 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 break;
803 case PRID_IMP_25KF:
804 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000805 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000807 case PRID_IMP_34K:
808 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000809 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000810 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100811 case PRID_IMP_74K:
812 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000813 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100814 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100815 case PRID_IMP_1004K:
816 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000817 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100818 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100820
821 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822}
823
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000824static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825{
Ralf Baechle41943182005-05-05 16:45:59 +0000826 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 switch (c->processor_id & 0xff00) {
828 case PRID_IMP_AU1_REV1:
829 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100830 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 switch ((c->processor_id >> 24) & 0xff) {
832 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000833 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 break;
835 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000836 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700837 break;
838 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000839 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 break;
841 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000842 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000844 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000845 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100846 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000847 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100848 break;
849 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000850 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000851 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100853 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 break;
855 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 break;
857 }
858}
859
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000860static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861{
Ralf Baechle41943182005-05-05 16:45:59 +0000862 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100863
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 switch (c->processor_id & 0xff00) {
865 case PRID_IMP_SB1:
866 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000867 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100869 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000870 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700872 case PRID_IMP_SB1A:
873 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000874 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700875 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 }
877}
878
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000879static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880{
Ralf Baechle41943182005-05-05 16:45:59 +0000881 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 switch (c->processor_id & 0xff00) {
883 case PRID_IMP_SR71000:
884 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000885 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 c->scache.ways = 8;
887 c->tlbsize = 64;
888 break;
889 }
890}
891
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000892static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000893{
894 decode_configs(c);
895 switch (c->processor_id & 0xff00) {
896 case PRID_IMP_PR4450:
897 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000898 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000899 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000900 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000901 }
902}
903
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000904static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200905{
906 decode_configs(c);
907 switch (c->processor_id & 0xff00) {
Kevin Cernekee602977b2010-10-16 14:22:30 -0700908 case PRID_IMP_BMIPS32:
909 c->cputype = CPU_BMIPS32;
910 __cpu_name[cpu] = "Broadcom BMIPS32";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200911 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700912 case PRID_IMP_BMIPS3300:
913 case PRID_IMP_BMIPS3300_ALT:
914 case PRID_IMP_BMIPS3300_BUG:
915 c->cputype = CPU_BMIPS3300;
916 __cpu_name[cpu] = "Broadcom BMIPS3300";
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200917 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700918 case PRID_IMP_BMIPS43XX: {
919 int rev = c->processor_id & 0xff;
920
921 if (rev >= PRID_REV_BMIPS4380_LO &&
922 rev <= PRID_REV_BMIPS4380_HI) {
923 c->cputype = CPU_BMIPS4380;
924 __cpu_name[cpu] = "Broadcom BMIPS4380";
925 } else {
926 c->cputype = CPU_BMIPS4350;
927 __cpu_name[cpu] = "Broadcom BMIPS4350";
Maxime Bizon0de663e2009-08-18 13:23:37 +0100928 }
929 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200930 }
Kevin Cernekee602977b2010-10-16 14:22:30 -0700931 case PRID_IMP_BMIPS5000:
932 c->cputype = CPU_BMIPS5000;
933 __cpu_name[cpu] = "Broadcom BMIPS5000";
934 c->options |= MIPS_CPU_ULRI;
935 break;
936 case PRID_IMP_BMIPS4KC:
937 c->cputype = CPU_4KC;
938 __cpu_name[cpu] = "MIPS 4Kc";
939 break;
940 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200941}
942
David Daney0dd47812008-12-11 15:33:26 -0800943static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
944{
945 decode_configs(c);
946 switch (c->processor_id & 0xff00) {
947 case PRID_IMP_CAVIUM_CN38XX:
948 case PRID_IMP_CAVIUM_CN31XX:
949 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -0800950 c->cputype = CPU_CAVIUM_OCTEON;
951 __cpu_name[cpu] = "Cavium Octeon";
952 goto platform;
David Daney0dd47812008-12-11 15:33:26 -0800953 case PRID_IMP_CAVIUM_CN58XX:
954 case PRID_IMP_CAVIUM_CN56XX:
955 case PRID_IMP_CAVIUM_CN50XX:
956 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -0800957 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
958 __cpu_name[cpu] = "Cavium Octeon+";
959platform:
David Daney368bf8e2010-01-28 16:52:13 -0800960 if (cpu == 0)
961 __elf_platform = "octeon";
David Daney0dd47812008-12-11 15:33:26 -0800962 break;
David Daney0e56b382010-10-07 16:03:45 -0700963 case PRID_IMP_CAVIUM_CN63XX:
964 c->cputype = CPU_CAVIUM_OCTEON2;
965 __cpu_name[cpu] = "Cavium Octeon II";
966 if (cpu == 0)
967 __elf_platform = "octeon2";
968 break;
David Daney0dd47812008-12-11 15:33:26 -0800969 default:
970 printk(KERN_INFO "Unknown Octeon chip!\n");
971 c->cputype = CPU_UNKNOWN;
972 break;
973 }
974}
975
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +0000976static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
977{
978 decode_configs(c);
979 /* JZRISC does not implement the CP0 counter. */
980 c->options &= ~MIPS_CPU_COUNTER;
981 switch (c->processor_id & 0xff00) {
982 case PRID_IMP_JZRISC:
983 c->cputype = CPU_JZRISC;
984 __cpu_name[cpu] = "Ingenic JZRISC";
985 break;
986 default:
987 panic("Unknown Ingenic Processor ID!");
988 break;
989 }
990}
991
David Daney949e51b2010-10-14 11:32:33 -0700992#ifdef CONFIG_64BIT
993/* For use by uaccess.h */
994u64 __ua_limit;
995EXPORT_SYMBOL(__ua_limit);
996#endif
997
Ralf Baechle9966db252007-10-11 23:46:17 +0100998const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -0800999const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001000
Ralf Baechle234fcd12008-03-08 09:56:28 +00001001__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002{
1003 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001004 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005
1006 c->processor_id = PRID_IMP_UNKNOWN;
1007 c->fpu_id = FPIR_IMP_NONE;
1008 c->cputype = CPU_UNKNOWN;
1009
1010 c->processor_id = read_c0_prid();
1011 switch (c->processor_id & 0xff0000) {
1012 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001013 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001014 break;
1015 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001016 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001017 break;
1018 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001019 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001020 break;
1021 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001022 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001023 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001024 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001025 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001026 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001028 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001029 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001030 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001031 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001032 break;
David Daney0dd47812008-12-11 15:33:26 -08001033 case PRID_COMP_CAVIUM:
1034 cpu_probe_cavium(c, cpu);
1035 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001036 case PRID_COMP_INGENIC:
1037 cpu_probe_ingenic(c, cpu);
1038 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001040
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001041 BUG_ON(!__cpu_name[cpu]);
1042 BUG_ON(c->cputype == CPU_UNKNOWN);
1043
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001044 /*
1045 * Platform code can force the cpu type to optimize code
1046 * generation. In that case be sure the cpu type is correctly
1047 * manually setup otherwise it could trigger some nasty bugs.
1048 */
1049 BUG_ON(current_cpu_type() != c->cputype);
1050
Kevin Cernekee0103d232010-05-02 14:43:52 -07001051 if (mips_fpu_disabled)
1052 c->options &= ~MIPS_CPU_FPU;
1053
1054 if (mips_dsp_disabled)
1055 c->ases &= ~MIPS_ASE_DSP;
1056
Ralf Baechle41943182005-05-05 16:45:59 +00001057 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001059
Ralf Baechlee7958bb2005-12-08 13:00:20 +00001060 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +00001061 c->isa_level == MIPS_CPU_ISA_M32R2 ||
1062 c->isa_level == MIPS_CPU_ISA_M64R1 ||
1063 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +00001064 if (c->fpu_id & MIPS_FPIR_3D)
1065 c->ases |= MIPS_ASE_MIPS3D;
1066 }
1067 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001068
Ralf Baechlef6771db2007-11-08 18:02:29 +00001069 if (cpu_has_mips_r2)
1070 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
1071 else
1072 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001073
1074 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001075
1076#ifdef CONFIG_64BIT
1077 if (cpu == 0)
1078 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1079#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080}
1081
Ralf Baechle234fcd12008-03-08 09:56:28 +00001082__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001083{
1084 struct cpuinfo_mips *c = &current_cpu_data;
1085
Ralf Baechle9966db252007-10-11 23:46:17 +01001086 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1087 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001089 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090}