blob: 0c69d1d14080b8408a80381528f3b67c44eb55d1 [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
Steven J. Hill113c62d2012-07-06 23:56:00 +02007 * Copyright (C) 2001, 2004, 2011, 2012 MIPS Technologies, 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>
Paul Gortmaker73bc2562011-07-23 16:30:40 -040019#include <linux/export.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>
David Daney654f57b2008-09-23 00:07:16 -070025#include <asm/watch.h>
Paul Gortmaker06372a62011-07-23 16:26:41 -040026#include <asm/elf.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");
Linus Torvalds1da177e2005-04-16 15:20:36 -070074}
75
Ralf Baechle5a812992007-07-17 18:49:48 +010076/*
77 * The RM7000 variant has to handle erratum 38. The workaround is to not
78 * have any pending stores when the WAIT instruction is executed.
79 */
80static void rm7k_wait_irqoff(void)
81{
82 local_irq_disable();
83 if (!need_resched())
84 __asm__(
85 " .set push \n"
86 " .set mips3 \n"
87 " .set noat \n"
88 " mfc0 $1, $12 \n"
89 " sync \n"
90 " mtc0 $1, $12 # stalls until W stage \n"
91 " wait \n"
92 " mtc0 $1, $12 # stalls until W stage \n"
93 " .set pop \n");
94 local_irq_enable();
95}
96
Manuel Lauss2882b0c2009-08-22 18:09:27 +020097/*
98 * The Au1xxx wait is available only if using 32khz counter or
99 * external timer source, but specifically not CP0 Counter.
100 * alchemy/common/time.c may override cpu_wait!
101 */
Pete Popov494900a2005-04-07 00:42:10 +0000102static void au1k_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103{
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900104 __asm__(" .set mips3 \n"
105 " cache 0x14, 0(%0) \n"
106 " cache 0x14, 32(%0) \n"
107 " sync \n"
108 " nop \n"
109 " wait \n"
110 " nop \n"
111 " nop \n"
112 " nop \n"
113 " nop \n"
114 " .set mips0 \n"
Ralf Baechle10f650d2005-05-25 13:32:49 +0000115 : : "r" (au1k_wait));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116}
117
Ralf Baechle982f6ff2009-09-17 02:25:07 +0200118static int __initdata nowait;
Ralf Baechle55d04df2005-07-13 19:22:45 +0000119
Atsushi Nemotof49a7472007-02-18 01:02:14 +0900120static int __init wait_disable(char *s)
Ralf Baechle55d04df2005-07-13 19:22:45 +0000121{
122 nowait = 1;
123
124 return 1;
125}
126
127__setup("nowait", wait_disable);
128
Kevin Cernekee0103d232010-05-02 14:43:52 -0700129static int __cpuinitdata mips_fpu_disabled;
130
131static int __init fpu_disable(char *s)
132{
133 cpu_data[0].options &= ~MIPS_CPU_FPU;
134 mips_fpu_disabled = 1;
135
136 return 1;
137}
138
139__setup("nofpu", fpu_disable);
140
141int __cpuinitdata mips_dsp_disabled;
142
143static int __init dsp_disable(char *s)
144{
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500145 cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -0700146 mips_dsp_disabled = 1;
147
148 return 1;
149}
150
151__setup("nodsp", dsp_disable);
152
Atsushi Nemotoc65a5482007-11-12 02:05:18 +0900153void __init check_wait(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154{
155 struct cpuinfo_mips *c = &current_cpu_data;
156
Ralf Baechle55d04df2005-07-13 19:22:45 +0000157 if (nowait) {
Ralf Baechlec2379232006-11-30 01:14:44 +0000158 printk("Wait instruction disabled.\n");
Ralf Baechle55d04df2005-07-13 19:22:45 +0000159 return;
160 }
161
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 switch (c->cputype) {
163 case CPU_R3081:
164 case CPU_R3081E:
165 cpu_wait = r3081_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166 break;
167 case CPU_TX3927:
168 cpu_wait = r39xx_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169 break;
170 case CPU_R4200:
171/* case CPU_R4300: */
172 case CPU_R4600:
173 case CPU_R4640:
174 case CPU_R4650:
175 case CPU_R4700:
176 case CPU_R5000:
Shinya Kuribayashia644b272009-03-03 18:05:51 +0900177 case CPU_R5500:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 case CPU_NEVADA:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179 case CPU_4KC:
180 case CPU_4KEC:
181 case CPU_4KSC:
182 case CPU_5KC:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183 case CPU_25KF:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100184 case CPU_PR4450:
Kevin Cernekee602977b2010-10-16 14:22:30 -0700185 case CPU_BMIPS3300:
186 case CPU_BMIPS4350:
187 case CPU_BMIPS4380:
188 case CPU_BMIPS5000:
David Daney0dd47812008-12-11 15:33:26 -0800189 case CPU_CAVIUM_OCTEON:
David Daney6f329462010-02-10 15:12:48 -0800190 case CPU_CAVIUM_OCTEON_PLUS:
David Daney0e56b382010-10-07 16:03:45 -0700191 case CPU_CAVIUM_OCTEON2:
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +0000192 case CPU_JZRISC:
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100193 case CPU_LOONGSON1:
Jayachandran C11d48aa2011-08-23 13:35:30 +0530194 case CPU_XLR:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +0000195 case CPU_XLP:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 cpu_wait = r4k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197 break;
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100198
Ralf Baechle5a812992007-07-17 18:49:48 +0100199 case CPU_RM7000:
200 cpu_wait = rm7k_wait_irqoff;
201 break;
202
Steven J. Hill113c62d2012-07-06 23:56:00 +0200203 case CPU_M14KC:
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000204 case CPU_M14KEC:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100205 case CPU_24K:
206 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100207 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100208 cpu_wait = r4k_wait;
209 if (read_c0_config7() & MIPS_CONF7_WII)
210 cpu_wait = r4k_wait_irqoff;
211 break;
212
213 case CPU_74K:
214 cpu_wait = r4k_wait;
215 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
216 cpu_wait = r4k_wait_irqoff;
217 break;
218
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900219 case CPU_TX49XX:
220 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900221 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100222 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100223 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100225 case CPU_20KC:
226 /*
227 * WAIT on Rev1.0 has E1, E2, E3 and E16.
228 * WAIT on Rev2.0 and Rev3.0 has E16.
229 * Rev3.1 WAIT is nop, why bother
230 */
231 if ((c->processor_id & 0xff) <= 0x64)
232 break;
233
Ralf Baechle50da4692007-09-14 19:08:43 +0100234 /*
235 * Another rev is incremeting c0_count at a reduced clock
236 * rate while in WAIT mode. So we basically have the choice
237 * between using the cp0 timer as clocksource or avoiding
238 * the WAIT instruction. Until more details are known,
239 * disable the use of WAIT for 20Kc entirely.
240 cpu_wait = r4k_wait;
241 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100242 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100243 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000244 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100245 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100246 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 break;
249 }
250}
251
Marc St-Jean9267a302007-06-14 15:55:31 -0600252static inline void check_errata(void)
253{
254 struct cpuinfo_mips *c = &current_cpu_data;
255
256 switch (c->cputype) {
257 case CPU_34K:
258 /*
259 * Erratum "RPS May Cause Incorrect Instruction Execution"
260 * This code only handles VPE0, any SMP/SMTC/RTOS code
261 * making use of VPE1 will be responsable for that VPE.
262 */
263 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
264 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
265 break;
266 default:
267 break;
268 }
269}
270
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271void __init check_bugs32(void)
272{
Marc St-Jean9267a302007-06-14 15:55:31 -0600273 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274}
275
276/*
277 * Probe whether cpu has config register by trying to play with
278 * alternate cache bit and see whether it matters.
279 * It's used by cpu_probe to distinguish between R3000A and R3081.
280 */
281static inline int cpu_has_confreg(void)
282{
283#ifdef CONFIG_CPU_R3000
284 extern unsigned long r3k_cache_size(unsigned long);
285 unsigned long size1, size2;
286 unsigned long cfg = read_c0_conf();
287
288 size1 = r3k_cache_size(ST0_ISC);
289 write_c0_conf(cfg ^ R30XX_CONF_AC);
290 size2 = r3k_cache_size(ST0_ISC);
291 write_c0_conf(cfg);
292 return size1 != size2;
293#else
294 return 0;
295#endif
296}
297
Robert Millanc094c992011-04-18 11:37:55 -0700298static inline void set_elf_platform(int cpu, const char *plat)
299{
300 if (cpu == 0)
301 __elf_platform = plat;
302}
303
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304/*
305 * Get the FPU Implementation/Revision.
306 */
307static inline unsigned long cpu_get_fpu_id(void)
308{
309 unsigned long tmp, fpu_id;
310
311 tmp = read_c0_status();
312 __enable_fpu();
313 fpu_id = read_32bit_cp1_register(CP1_REVISION);
314 write_c0_status(tmp);
315 return fpu_id;
316}
317
318/*
319 * Check the CPU has an FPU the official way.
320 */
321static inline int __cpu_has_fpu(void)
322{
323 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
324}
325
Guenter Roeck91dfc422010-02-02 08:52:20 -0800326static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
327{
328#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800329 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800330 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800331 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800332#endif
333}
334
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100335static char unknown_isa[] __cpuinitdata = KERN_ERR \
336 "Unsupported ISA type, c0.config0: %d.";
337
338static inline unsigned int decode_config0(struct cpuinfo_mips *c)
339{
340 unsigned int config0;
341 int isa;
342
343 config0 = read_c0_config();
344
345 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
346 c->options |= MIPS_CPU_TLB;
347 isa = (config0 & MIPS_CONF_AT) >> 13;
348 switch (isa) {
349 case 0:
350 switch ((config0 & MIPS_CONF_AR) >> 10) {
351 case 0:
352 c->isa_level = MIPS_CPU_ISA_M32R1;
353 break;
354 case 1:
355 c->isa_level = MIPS_CPU_ISA_M32R2;
356 break;
357 default:
358 goto unknown;
359 }
360 break;
361 case 2:
362 switch ((config0 & MIPS_CONF_AR) >> 10) {
363 case 0:
364 c->isa_level = MIPS_CPU_ISA_M64R1;
365 break;
366 case 1:
367 c->isa_level = MIPS_CPU_ISA_M64R2;
368 break;
369 default:
370 goto unknown;
371 }
372 break;
373 default:
374 goto unknown;
375 }
376
377 return config0 & MIPS_CONF_M;
378
379unknown:
380 panic(unknown_isa, config0);
381}
382
383static inline unsigned int decode_config1(struct cpuinfo_mips *c)
384{
385 unsigned int config1;
386
387 config1 = read_c0_config1();
388
389 if (config1 & MIPS_CONF1_MD)
390 c->ases |= MIPS_ASE_MDMX;
391 if (config1 & MIPS_CONF1_WR)
392 c->options |= MIPS_CPU_WATCH;
393 if (config1 & MIPS_CONF1_CA)
394 c->ases |= MIPS_ASE_MIPS16;
395 if (config1 & MIPS_CONF1_EP)
396 c->options |= MIPS_CPU_EJTAG;
397 if (config1 & MIPS_CONF1_FP) {
398 c->options |= MIPS_CPU_FPU;
399 c->options |= MIPS_CPU_32FPR;
400 }
401 if (cpu_has_tlb)
402 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
403
404 return config1 & MIPS_CONF_M;
405}
406
407static inline unsigned int decode_config2(struct cpuinfo_mips *c)
408{
409 unsigned int config2;
410
411 config2 = read_c0_config2();
412
413 if (config2 & MIPS_CONF2_SL)
414 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
415
416 return config2 & MIPS_CONF_M;
417}
418
419static inline unsigned int decode_config3(struct cpuinfo_mips *c)
420{
421 unsigned int config3;
422
423 config3 = read_c0_config3();
424
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500425 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100426 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500427 c->options |= MIPS_CPU_RIXI;
428 }
429 if (config3 & MIPS_CONF3_RXI)
430 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100431 if (config3 & MIPS_CONF3_DSP)
432 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500433 if (config3 & MIPS_CONF3_DSP2P)
434 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100435 if (config3 & MIPS_CONF3_VINT)
436 c->options |= MIPS_CPU_VINT;
437 if (config3 & MIPS_CONF3_VEIC)
438 c->options |= MIPS_CPU_VEIC;
439 if (config3 & MIPS_CONF3_MT)
440 c->ases |= MIPS_ASE_MIPSMT;
441 if (config3 & MIPS_CONF3_ULRI)
442 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000443 if (config3 & MIPS_CONF3_ISA)
444 c->options |= MIPS_CPU_MICROMIPS;
David Daney1e7decd2013-02-16 23:42:43 +0100445 if (config3 & MIPS_CONF3_VZ)
446 c->ases |= MIPS_ASE_VZ;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100447
448 return config3 & MIPS_CONF_M;
449}
450
451static inline unsigned int decode_config4(struct cpuinfo_mips *c)
452{
453 unsigned int config4;
454
455 config4 = read_c0_config4();
456
457 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
458 && cpu_has_tlb)
459 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
460
461 c->kscratch_mask = (config4 >> 16) & 0xff;
462
463 return config4 & MIPS_CONF_M;
464}
465
466static void __cpuinit decode_configs(struct cpuinfo_mips *c)
467{
468 int ok;
469
470 /* MIPS32 or MIPS64 compliant CPU. */
471 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
472 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
473
474 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
475
476 ok = decode_config0(c); /* Read Config registers. */
477 BUG_ON(!ok); /* Arch spec violation! */
478 if (ok)
479 ok = decode_config1(c);
480 if (ok)
481 ok = decode_config2(c);
482 if (ok)
483 ok = decode_config3(c);
484 if (ok)
485 ok = decode_config4(c);
486
487 mips_probe_watch_registers(c);
488
489 if (cpu_has_mips_r2)
490 c->core = read_c0_ebase() & 0x3ff;
491}
492
Ralf Baechle02cf2112005-10-01 13:06:32 +0100493#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 | MIPS_CPU_COUNTER)
495
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000496static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497{
498 switch (c->processor_id & 0xff00) {
499 case PRID_IMP_R2000:
500 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000501 __cpu_name[cpu] = "R2000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100503 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500504 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 if (__cpu_has_fpu())
506 c->options |= MIPS_CPU_FPU;
507 c->tlbsize = 64;
508 break;
509 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000510 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
511 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000513 __cpu_name[cpu] = "R3081";
514 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000516 __cpu_name[cpu] = "R3000A";
517 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000518 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000520 __cpu_name[cpu] = "R3000";
521 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100523 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500524 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 if (__cpu_has_fpu())
526 c->options |= MIPS_CPU_FPU;
527 c->tlbsize = 64;
528 break;
529 case PRID_IMP_R4000:
530 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000531 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000533 __cpu_name[cpu] = "R4400PC";
534 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000536 __cpu_name[cpu] = "R4000PC";
537 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000539 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000541 __cpu_name[cpu] = "R4400SC";
542 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000544 __cpu_name[cpu] = "R4000SC";
545 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 }
547
548 c->isa_level = MIPS_CPU_ISA_III;
549 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500550 MIPS_CPU_WATCH | MIPS_CPU_VCE |
551 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 c->tlbsize = 48;
553 break;
554 case PRID_IMP_VR41XX:
555 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 case PRID_REV_VR4111:
557 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000558 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700560 case PRID_REV_VR4121:
561 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000562 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 break;
564 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000565 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000567 __cpu_name[cpu] = "NEC VR4122";
568 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000570 __cpu_name[cpu] = "NEC VR4181A";
571 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 break;
573 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000574 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000576 __cpu_name[cpu] = "NEC VR4131";
577 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700578 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000579 __cpu_name[cpu] = "NEC VR4133";
580 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 break;
582 default:
583 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
584 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000585 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 break;
587 }
588 c->isa_level = MIPS_CPU_ISA_III;
589 c->options = R4K_OPTS;
590 c->tlbsize = 32;
591 break;
592 case PRID_IMP_R4300:
593 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000594 __cpu_name[cpu] = "R4300";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 c->isa_level = MIPS_CPU_ISA_III;
596 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500597 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 c->tlbsize = 32;
599 break;
600 case PRID_IMP_R4600:
601 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000602 __cpu_name[cpu] = "R4600";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 c->isa_level = MIPS_CPU_ISA_III;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000604 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
605 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700606 c->tlbsize = 48;
607 break;
608 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500609 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 /*
611 * This processor doesn't have an MMU, so it's not
612 * "real easy" to run Linux on it. It is left purely
613 * for documentation. Commented out because it shares
614 * it's c0_prid id number with the TX3900.
615 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000616 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000617 __cpu_name[cpu] = "R4650";
Steven J. Hill03751e72012-05-10 23:21:18 -0500618 c->isa_level = MIPS_CPU_ISA_III;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500620 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 break;
622 #endif
623 case PRID_IMP_TX39:
624 c->isa_level = MIPS_CPU_ISA_I;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100625 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626
627 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
628 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000629 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 c->tlbsize = 64;
631 } else {
632 switch (c->processor_id & 0xff) {
633 case PRID_REV_TX3912:
634 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000635 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 c->tlbsize = 32;
637 break;
638 case PRID_REV_TX3922:
639 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000640 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641 c->tlbsize = 64;
642 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 }
644 }
645 break;
646 case PRID_IMP_R4700:
647 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000648 __cpu_name[cpu] = "R4700";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 c->isa_level = MIPS_CPU_ISA_III;
650 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500651 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 c->tlbsize = 48;
653 break;
654 case PRID_IMP_TX49:
655 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000656 __cpu_name[cpu] = "R49XX";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 c->isa_level = MIPS_CPU_ISA_III;
658 c->options = R4K_OPTS | MIPS_CPU_LLSC;
659 if (!(c->processor_id & 0x08))
660 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
661 c->tlbsize = 48;
662 break;
663 case PRID_IMP_R5000:
664 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000665 __cpu_name[cpu] = "R5000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 c->isa_level = MIPS_CPU_ISA_IV;
667 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500668 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 c->tlbsize = 48;
670 break;
671 case PRID_IMP_R5432:
672 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000673 __cpu_name[cpu] = "R5432";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 c->isa_level = MIPS_CPU_ISA_IV;
675 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500676 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 c->tlbsize = 48;
678 break;
679 case PRID_IMP_R5500:
680 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000681 __cpu_name[cpu] = "R5500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 c->isa_level = MIPS_CPU_ISA_IV;
683 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500684 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685 c->tlbsize = 48;
686 break;
687 case PRID_IMP_NEVADA:
688 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000689 __cpu_name[cpu] = "Nevada";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 c->isa_level = MIPS_CPU_ISA_IV;
691 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500692 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 c->tlbsize = 48;
694 break;
695 case PRID_IMP_R6000:
696 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000697 __cpu_name[cpu] = "R6000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 c->isa_level = MIPS_CPU_ISA_II;
699 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500700 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 c->tlbsize = 32;
702 break;
703 case PRID_IMP_R6000A:
704 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000705 __cpu_name[cpu] = "R6000A";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 c->isa_level = MIPS_CPU_ISA_II;
707 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500708 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 c->tlbsize = 32;
710 break;
711 case PRID_IMP_RM7000:
712 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000713 __cpu_name[cpu] = "RM7000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 c->isa_level = MIPS_CPU_ISA_IV;
715 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500716 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 /*
718 * Undocumented RM7000: Bit 29 in the info register of
719 * the RM7000 v2.0 indicates if the TLB has 48 or 64
720 * entries.
721 *
722 * 29 1 => 64 entry JTLB
723 * 0 => 48 entry JTLB
724 */
725 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
726 break;
727 case PRID_IMP_RM9000:
728 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000729 __cpu_name[cpu] = "RM9000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 c->isa_level = MIPS_CPU_ISA_IV;
731 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500732 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 /*
734 * Bit 29 in the info register of the RM9000
735 * indicates if the TLB has 48 or 64 entries.
736 *
737 * 29 1 => 64 entry JTLB
738 * 0 => 48 entry JTLB
739 */
740 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
741 break;
742 case PRID_IMP_R8000:
743 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000744 __cpu_name[cpu] = "RM8000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 c->isa_level = MIPS_CPU_ISA_IV;
746 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500747 MIPS_CPU_FPU | MIPS_CPU_32FPR |
748 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
750 break;
751 case PRID_IMP_R10000:
752 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000753 __cpu_name[cpu] = "R10000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000755 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500756 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500758 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 c->tlbsize = 64;
760 break;
761 case PRID_IMP_R12000:
762 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000763 __cpu_name[cpu] = "R12000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 c->isa_level = MIPS_CPU_ISA_IV;
Ralf Baechle8b366122005-11-22 17:53:59 +0000765 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500766 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500768 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 c->tlbsize = 64;
770 break;
Kumba44d921b2006-05-16 22:23:59 -0400771 case PRID_IMP_R14000:
772 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000773 __cpu_name[cpu] = "R14000";
Kumba44d921b2006-05-16 22:23:59 -0400774 c->isa_level = MIPS_CPU_ISA_IV;
775 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500776 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400777 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500778 MIPS_CPU_LLSC;
Kumba44d921b2006-05-16 22:23:59 -0400779 c->tlbsize = 64;
780 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800781 case PRID_IMP_LOONGSON2:
782 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000783 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700784
785 switch (c->processor_id & PRID_REV_MASK) {
786 case PRID_REV_LOONGSON2E:
787 set_elf_platform(cpu, "loongson2e");
788 break;
789 case PRID_REV_LOONGSON2F:
790 set_elf_platform(cpu, "loongson2f");
791 break;
792 }
793
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800794 c->isa_level = MIPS_CPU_ISA_III;
795 c->options = R4K_OPTS |
796 MIPS_CPU_FPU | MIPS_CPU_LLSC |
797 MIPS_CPU_32FPR;
798 c->tlbsize = 64;
799 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100800 case PRID_IMP_LOONGSON1:
801 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100803 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000804
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100805 switch (c->processor_id & PRID_REV_MASK) {
806 case PRID_REV_LOONGSON1B:
807 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +0000808 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000809 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100810
Ralf Baechle41943182005-05-05 16:45:59 +0000811 break;
Ralf Baechle41943182005-05-05 16:45:59 +0000812 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813}
814
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000815static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700816{
Ralf Baechle41943182005-05-05 16:45:59 +0000817 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700818 switch (c->processor_id & 0xff00) {
819 case PRID_IMP_4KC:
820 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000821 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 break;
823 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000824 case PRID_IMP_4KECR2:
825 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000826 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000827 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100829 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000831 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 break;
833 case PRID_IMP_5KC:
834 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000835 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +0200837 case PRID_IMP_5KE:
838 c->cputype = CPU_5KE;
839 __cpu_name[cpu] = "MIPS 5KE";
840 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841 case PRID_IMP_20KC:
842 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000843 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 break;
845 case PRID_IMP_24K:
846 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000847 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 break;
John Crispin42f3cae2013-01-11 22:44:10 +0100849 case PRID_IMP_24KE:
850 c->cputype = CPU_24K;
851 __cpu_name[cpu] = "MIPS 24KEc";
852 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 case PRID_IMP_25KF:
854 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000855 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000857 case PRID_IMP_34K:
858 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000859 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000860 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100861 case PRID_IMP_74K:
862 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000863 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100864 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +0200865 case PRID_IMP_M14KC:
866 c->cputype = CPU_M14KC;
867 __cpu_name[cpu] = "MIPS M14Kc";
868 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000869 case PRID_IMP_M14KEC:
870 c->cputype = CPU_M14KEC;
871 __cpu_name[cpu] = "MIPS M14KEc";
872 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100873 case PRID_IMP_1004K:
874 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000875 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100876 break;
Steven J. Hill006a8512012-06-26 04:11:03 +0000877 case PRID_IMP_1074K:
878 c->cputype = CPU_74K;
879 __cpu_name[cpu] = "MIPS 1074Kc";
880 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100882
883 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884}
885
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000886static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887{
Ralf Baechle41943182005-05-05 16:45:59 +0000888 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 switch (c->processor_id & 0xff00) {
890 case PRID_IMP_AU1_REV1:
891 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100892 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893 switch ((c->processor_id >> 24) & 0xff) {
894 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000895 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 break;
897 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000898 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 break;
900 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000901 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 break;
903 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000904 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000906 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000907 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100908 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000909 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100910 break;
911 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000912 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000913 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100915 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916 break;
917 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918 break;
919 }
920}
921
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000922static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923{
Ralf Baechle41943182005-05-05 16:45:59 +0000924 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100925
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926 switch (c->processor_id & 0xff00) {
927 case PRID_IMP_SB1:
928 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000929 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100931 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000932 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700934 case PRID_IMP_SB1A:
935 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000936 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700937 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938 }
939}
940
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000941static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942{
Ralf Baechle41943182005-05-05 16:45:59 +0000943 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944 switch (c->processor_id & 0xff00) {
945 case PRID_IMP_SR71000:
946 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000947 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 c->scache.ways = 8;
949 c->tlbsize = 64;
950 break;
951 }
952}
953
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000954static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000955{
956 decode_configs(c);
957 switch (c->processor_id & 0xff00) {
958 case PRID_IMP_PR4450:
959 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000960 __cpu_name[cpu] = "Philips PR4450";
Ralf Baechlee7958bb2005-12-08 13:00:20 +0000961 c->isa_level = MIPS_CPU_ISA_M32R1;
Pete Popovbdf21b12005-07-14 17:47:57 +0000962 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000963 }
964}
965
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000966static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200967{
968 decode_configs(c);
969 switch (c->processor_id & 0xff00) {
Kevin Cernekee190fca32010-11-23 10:26:45 -0800970 case PRID_IMP_BMIPS32_REV4:
971 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -0700972 c->cputype = CPU_BMIPS32;
973 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700974 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200975 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700976 case PRID_IMP_BMIPS3300:
977 case PRID_IMP_BMIPS3300_ALT:
978 case PRID_IMP_BMIPS3300_BUG:
979 c->cputype = CPU_BMIPS3300;
980 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700981 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200982 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700983 case PRID_IMP_BMIPS43XX: {
984 int rev = c->processor_id & 0xff;
985
986 if (rev >= PRID_REV_BMIPS4380_LO &&
987 rev <= PRID_REV_BMIPS4380_HI) {
988 c->cputype = CPU_BMIPS4380;
989 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700990 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700991 } else {
992 c->cputype = CPU_BMIPS4350;
993 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700994 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +0100995 }
996 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200997 }
Kevin Cernekee602977b2010-10-16 14:22:30 -0700998 case PRID_IMP_BMIPS5000:
999 c->cputype = CPU_BMIPS5000;
1000 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001001 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001002 c->options |= MIPS_CPU_ULRI;
1003 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001004 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001005}
1006
David Daney0dd47812008-12-11 15:33:26 -08001007static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
1008{
1009 decode_configs(c);
1010 switch (c->processor_id & 0xff00) {
1011 case PRID_IMP_CAVIUM_CN38XX:
1012 case PRID_IMP_CAVIUM_CN31XX:
1013 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -08001014 c->cputype = CPU_CAVIUM_OCTEON;
1015 __cpu_name[cpu] = "Cavium Octeon";
1016 goto platform;
David Daney0dd47812008-12-11 15:33:26 -08001017 case PRID_IMP_CAVIUM_CN58XX:
1018 case PRID_IMP_CAVIUM_CN56XX:
1019 case PRID_IMP_CAVIUM_CN50XX:
1020 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -08001021 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
1022 __cpu_name[cpu] = "Cavium Octeon+";
1023platform:
Robert Millanc094c992011-04-18 11:37:55 -07001024 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -08001025 break;
David Daneya1431b62011-09-24 02:29:54 +02001026 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -07001027 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +02001028 case PRID_IMP_CAVIUM_CN66XX:
1029 case PRID_IMP_CAVIUM_CN68XX:
David Daney0e56b382010-10-07 16:03:45 -07001030 c->cputype = CPU_CAVIUM_OCTEON2;
1031 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001032 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001033 break;
David Daney0dd47812008-12-11 15:33:26 -08001034 default:
1035 printk(KERN_INFO "Unknown Octeon chip!\n");
1036 c->cputype = CPU_UNKNOWN;
1037 break;
1038 }
1039}
1040
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001041static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1042{
1043 decode_configs(c);
1044 /* JZRISC does not implement the CP0 counter. */
1045 c->options &= ~MIPS_CPU_COUNTER;
1046 switch (c->processor_id & 0xff00) {
1047 case PRID_IMP_JZRISC:
1048 c->cputype = CPU_JZRISC;
1049 __cpu_name[cpu] = "Ingenic JZRISC";
1050 break;
1051 default:
1052 panic("Unknown Ingenic Processor ID!");
1053 break;
1054 }
1055}
1056
Jayachandran Ca7117c62011-05-11 12:04:58 +05301057static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1058{
1059 decode_configs(c);
1060
Manuel Lauss809f36c2011-11-01 20:03:30 +01001061 if ((c->processor_id & 0xff00) == PRID_IMP_NETLOGIC_AU13XX) {
1062 c->cputype = CPU_ALCHEMY;
1063 __cpu_name[cpu] = "Au1300";
1064 /* following stuff is not for Alchemy */
1065 return;
1066 }
1067
Jayachandran Ca7117c62011-05-11 12:04:58 +05301068 c->options = (MIPS_CPU_TLB |
1069 MIPS_CPU_4KEX |
1070 MIPS_CPU_COUNTER |
1071 MIPS_CPU_DIVEC |
1072 MIPS_CPU_WATCH |
1073 MIPS_CPU_EJTAG |
1074 MIPS_CPU_LLSC);
1075
1076 switch (c->processor_id & 0xff00) {
Jayachandran C2aa54b22011-11-16 00:21:29 +00001077 case PRID_IMP_NETLOGIC_XLP8XX:
1078 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001079 c->cputype = CPU_XLP;
1080 __cpu_name[cpu] = "Netlogic XLP";
1081 break;
1082
Jayachandran Ca7117c62011-05-11 12:04:58 +05301083 case PRID_IMP_NETLOGIC_XLR732:
1084 case PRID_IMP_NETLOGIC_XLR716:
1085 case PRID_IMP_NETLOGIC_XLR532:
1086 case PRID_IMP_NETLOGIC_XLR308:
1087 case PRID_IMP_NETLOGIC_XLR532C:
1088 case PRID_IMP_NETLOGIC_XLR516C:
1089 case PRID_IMP_NETLOGIC_XLR508C:
1090 case PRID_IMP_NETLOGIC_XLR308C:
1091 c->cputype = CPU_XLR;
1092 __cpu_name[cpu] = "Netlogic XLR";
1093 break;
1094
1095 case PRID_IMP_NETLOGIC_XLS608:
1096 case PRID_IMP_NETLOGIC_XLS408:
1097 case PRID_IMP_NETLOGIC_XLS404:
1098 case PRID_IMP_NETLOGIC_XLS208:
1099 case PRID_IMP_NETLOGIC_XLS204:
1100 case PRID_IMP_NETLOGIC_XLS108:
1101 case PRID_IMP_NETLOGIC_XLS104:
1102 case PRID_IMP_NETLOGIC_XLS616B:
1103 case PRID_IMP_NETLOGIC_XLS608B:
1104 case PRID_IMP_NETLOGIC_XLS416B:
1105 case PRID_IMP_NETLOGIC_XLS412B:
1106 case PRID_IMP_NETLOGIC_XLS408B:
1107 case PRID_IMP_NETLOGIC_XLS404B:
1108 c->cputype = CPU_XLR;
1109 __cpu_name[cpu] = "Netlogic XLS";
1110 break;
1111
1112 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001113 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301114 c->processor_id);
1115 c->cputype = CPU_XLR;
1116 break;
1117 }
1118
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001119 if (c->cputype == CPU_XLP) {
1120 c->isa_level = MIPS_CPU_ISA_M64R2;
1121 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1122 /* This will be updated again after all threads are woken up */
1123 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1124 } else {
1125 c->isa_level = MIPS_CPU_ISA_M64R1;
1126 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1127 }
Jayachandran Ca7117c62011-05-11 12:04:58 +05301128}
1129
David Daney949e51b2010-10-14 11:32:33 -07001130#ifdef CONFIG_64BIT
1131/* For use by uaccess.h */
1132u64 __ua_limit;
1133EXPORT_SYMBOL(__ua_limit);
1134#endif
1135
Ralf Baechle9966db252007-10-11 23:46:17 +01001136const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001137const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001138
Ralf Baechle234fcd12008-03-08 09:56:28 +00001139__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140{
1141 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001142 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143
1144 c->processor_id = PRID_IMP_UNKNOWN;
1145 c->fpu_id = FPIR_IMP_NONE;
1146 c->cputype = CPU_UNKNOWN;
1147
1148 c->processor_id = read_c0_prid();
1149 switch (c->processor_id & 0xff0000) {
1150 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001151 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 break;
1153 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001154 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155 break;
1156 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001157 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 break;
1159 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001160 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001162 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001163 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001164 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001166 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001168 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001169 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001170 break;
David Daney0dd47812008-12-11 15:33:26 -08001171 case PRID_COMP_CAVIUM:
1172 cpu_probe_cavium(c, cpu);
1173 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001174 case PRID_COMP_INGENIC:
1175 cpu_probe_ingenic(c, cpu);
1176 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301177 case PRID_COMP_NETLOGIC:
1178 cpu_probe_netlogic(c, cpu);
1179 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001181
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001182 BUG_ON(!__cpu_name[cpu]);
1183 BUG_ON(c->cputype == CPU_UNKNOWN);
1184
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001185 /*
1186 * Platform code can force the cpu type to optimize code
1187 * generation. In that case be sure the cpu type is correctly
1188 * manually setup otherwise it could trigger some nasty bugs.
1189 */
1190 BUG_ON(current_cpu_type() != c->cputype);
1191
Kevin Cernekee0103d232010-05-02 14:43:52 -07001192 if (mips_fpu_disabled)
1193 c->options &= ~MIPS_CPU_FPU;
1194
1195 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001196 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001197
Ralf Baechle41943182005-05-05 16:45:59 +00001198 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001200
Ralf Baechlee7958bb2005-12-08 13:00:20 +00001201 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +00001202 c->isa_level == MIPS_CPU_ISA_M32R2 ||
1203 c->isa_level == MIPS_CPU_ISA_M64R1 ||
1204 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +00001205 if (c->fpu_id & MIPS_FPIR_3D)
1206 c->ases |= MIPS_ASE_MIPS3D;
1207 }
1208 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001209
Al Cooperda4b62c2012-07-13 16:44:51 -04001210 if (cpu_has_mips_r2) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001211 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001212 /* R2 has Performance Counter Interrupt indicator */
1213 c->options |= MIPS_CPU_PCI;
1214 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001215 else
1216 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001217
1218 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001219
1220#ifdef CONFIG_64BIT
1221 if (cpu == 0)
1222 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1223#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224}
1225
Ralf Baechle234fcd12008-03-08 09:56:28 +00001226__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227{
1228 struct cpuinfo_mips *c = &current_cpu_data;
1229
Ralf Baechle9966db252007-10-11 23:46:17 +01001230 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1231 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001233 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234}