blob: 2656c898e33766565f7f8699090ca98b00508a5e [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 Baechle70342282013-01-22 12:59:30 +01007 * 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();
Ralf Baechle70342282013-01-22 12:59:30 +010072 __asm__(" .globl __pastwait \n"
Kevin D. Kissell8531a352008-09-09 21:48:52 +020073 "__pastwait: \n");
Linus Torvalds1da177e2005-04-16 15:20:36 -070074}
75
Ralf Baechle5a812992007-07-17 18:49:48 +010076/*
Ralf Baechle70342282013-01-22 12:59:30 +010077 * The RM7000 variant has to handle erratum 38. The workaround is to not
Ralf Baechle5a812992007-07-17 18:49:48 +010078 * 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:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100204 case CPU_24K:
205 case CPU_34K:
Ralf Baechle39b8d522008-04-28 17:14:26 +0100206 case CPU_1004K:
Ralf Baechle4b3e9752007-06-21 00:22:34 +0100207 cpu_wait = r4k_wait;
208 if (read_c0_config7() & MIPS_CONF7_WII)
209 cpu_wait = r4k_wait_irqoff;
210 break;
211
212 case CPU_74K:
213 cpu_wait = r4k_wait;
214 if ((c->processor_id & 0xff) >= PRID_REV_ENCODE_332(2, 1, 0))
215 cpu_wait = r4k_wait_irqoff;
216 break;
217
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900218 case CPU_TX49XX:
219 cpu_wait = r4k_wait_irqoff;
Atsushi Nemoto60a6c372006-06-08 01:09:01 +0900220 break;
Manuel Lauss270717a2009-03-25 17:49:28 +0100221 case CPU_ALCHEMY:
Manuel Lauss0c694de2008-12-21 09:26:23 +0100222 cpu_wait = au1k_wait;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 break;
Ralf Baechlec8eae712007-06-12 13:04:09 +0100224 case CPU_20KC:
225 /*
226 * WAIT on Rev1.0 has E1, E2, E3 and E16.
227 * WAIT on Rev2.0 and Rev3.0 has E16.
228 * Rev3.1 WAIT is nop, why bother
229 */
230 if ((c->processor_id & 0xff) <= 0x64)
231 break;
232
Ralf Baechle50da4692007-09-14 19:08:43 +0100233 /*
234 * Another rev is incremeting c0_count at a reduced clock
235 * rate while in WAIT mode. So we basically have the choice
236 * between using the cp0 timer as clocksource or avoiding
237 * the WAIT instruction. Until more details are known,
238 * disable the use of WAIT for 20Kc entirely.
239 cpu_wait = r4k_wait;
240 */
Ralf Baechlec8eae712007-06-12 13:04:09 +0100241 break;
Ralf Baechle441ee342006-06-02 11:48:11 +0100242 case CPU_RM9000:
Ralf Baechlec2379232006-11-30 01:14:44 +0000243 if ((c->processor_id & 0x00ff) >= 0x40)
Ralf Baechle441ee342006-06-02 11:48:11 +0100244 cpu_wait = r4k_wait;
Ralf Baechle441ee342006-06-02 11:48:11 +0100245 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 default:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247 break;
248 }
249}
250
Marc St-Jean9267a302007-06-14 15:55:31 -0600251static inline void check_errata(void)
252{
253 struct cpuinfo_mips *c = &current_cpu_data;
254
255 switch (c->cputype) {
256 case CPU_34K:
257 /*
258 * Erratum "RPS May Cause Incorrect Instruction Execution"
259 * This code only handles VPE0, any SMP/SMTC/RTOS code
260 * making use of VPE1 will be responsable for that VPE.
261 */
262 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
263 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
264 break;
265 default:
266 break;
267 }
268}
269
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270void __init check_bugs32(void)
271{
Marc St-Jean9267a302007-06-14 15:55:31 -0600272 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273}
274
275/*
276 * Probe whether cpu has config register by trying to play with
277 * alternate cache bit and see whether it matters.
278 * It's used by cpu_probe to distinguish between R3000A and R3081.
279 */
280static inline int cpu_has_confreg(void)
281{
282#ifdef CONFIG_CPU_R3000
283 extern unsigned long r3k_cache_size(unsigned long);
284 unsigned long size1, size2;
285 unsigned long cfg = read_c0_conf();
286
287 size1 = r3k_cache_size(ST0_ISC);
288 write_c0_conf(cfg ^ R30XX_CONF_AC);
289 size2 = r3k_cache_size(ST0_ISC);
290 write_c0_conf(cfg);
291 return size1 != size2;
292#else
293 return 0;
294#endif
295}
296
Robert Millanc094c992011-04-18 11:37:55 -0700297static inline void set_elf_platform(int cpu, const char *plat)
298{
299 if (cpu == 0)
300 __elf_platform = plat;
301}
302
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303/*
304 * Get the FPU Implementation/Revision.
305 */
306static inline unsigned long cpu_get_fpu_id(void)
307{
308 unsigned long tmp, fpu_id;
309
310 tmp = read_c0_status();
311 __enable_fpu();
312 fpu_id = read_32bit_cp1_register(CP1_REVISION);
313 write_c0_status(tmp);
314 return fpu_id;
315}
316
317/*
318 * Check the CPU has an FPU the official way.
319 */
320static inline int __cpu_has_fpu(void)
321{
322 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
323}
324
Guenter Roeck91dfc422010-02-02 08:52:20 -0800325static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
326{
327#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800328 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800329 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800330 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800331#endif
332}
333
Steven J. Hilla96102b2012-12-07 04:31:36 +0000334static void __cpuinit set_isa(struct cpuinfo_mips *c, unsigned int isa)
335{
336 switch (isa) {
337 case MIPS_CPU_ISA_M64R2:
338 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
339 case MIPS_CPU_ISA_M64R1:
340 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
341 case MIPS_CPU_ISA_V:
342 c->isa_level |= MIPS_CPU_ISA_V;
343 case MIPS_CPU_ISA_IV:
344 c->isa_level |= MIPS_CPU_ISA_IV;
345 case MIPS_CPU_ISA_III:
346 c->isa_level |= MIPS_CPU_ISA_I | MIPS_CPU_ISA_II |
347 MIPS_CPU_ISA_III;
348 break;
349
350 case MIPS_CPU_ISA_M32R2:
351 c->isa_level |= MIPS_CPU_ISA_M32R2;
352 case MIPS_CPU_ISA_M32R1:
353 c->isa_level |= MIPS_CPU_ISA_M32R1;
354 case MIPS_CPU_ISA_II:
355 c->isa_level |= MIPS_CPU_ISA_II;
356 case MIPS_CPU_ISA_I:
357 c->isa_level |= MIPS_CPU_ISA_I;
358 break;
359 }
360}
361
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100362static char unknown_isa[] __cpuinitdata = KERN_ERR \
363 "Unsupported ISA type, c0.config0: %d.";
364
365static inline unsigned int decode_config0(struct cpuinfo_mips *c)
366{
367 unsigned int config0;
368 int isa;
369
370 config0 = read_c0_config();
371
372 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
373 c->options |= MIPS_CPU_TLB;
374 isa = (config0 & MIPS_CONF_AT) >> 13;
375 switch (isa) {
376 case 0:
377 switch ((config0 & MIPS_CONF_AR) >> 10) {
378 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000379 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100380 break;
381 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000382 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100383 break;
384 default:
385 goto unknown;
386 }
387 break;
388 case 2:
389 switch ((config0 & MIPS_CONF_AR) >> 10) {
390 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000391 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100392 break;
393 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000394 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100395 break;
396 default:
397 goto unknown;
398 }
399 break;
400 default:
401 goto unknown;
402 }
403
404 return config0 & MIPS_CONF_M;
405
406unknown:
407 panic(unknown_isa, config0);
408}
409
410static inline unsigned int decode_config1(struct cpuinfo_mips *c)
411{
412 unsigned int config1;
413
414 config1 = read_c0_config1();
415
416 if (config1 & MIPS_CONF1_MD)
417 c->ases |= MIPS_ASE_MDMX;
418 if (config1 & MIPS_CONF1_WR)
419 c->options |= MIPS_CPU_WATCH;
420 if (config1 & MIPS_CONF1_CA)
421 c->ases |= MIPS_ASE_MIPS16;
422 if (config1 & MIPS_CONF1_EP)
423 c->options |= MIPS_CPU_EJTAG;
424 if (config1 & MIPS_CONF1_FP) {
425 c->options |= MIPS_CPU_FPU;
426 c->options |= MIPS_CPU_32FPR;
427 }
428 if (cpu_has_tlb)
429 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
430
431 return config1 & MIPS_CONF_M;
432}
433
434static inline unsigned int decode_config2(struct cpuinfo_mips *c)
435{
436 unsigned int config2;
437
438 config2 = read_c0_config2();
439
440 if (config2 & MIPS_CONF2_SL)
441 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
442
443 return config2 & MIPS_CONF_M;
444}
445
446static inline unsigned int decode_config3(struct cpuinfo_mips *c)
447{
448 unsigned int config3;
449
450 config3 = read_c0_config3();
451
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500452 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100453 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500454 c->options |= MIPS_CPU_RIXI;
455 }
456 if (config3 & MIPS_CONF3_RXI)
457 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100458 if (config3 & MIPS_CONF3_DSP)
459 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500460 if (config3 & MIPS_CONF3_DSP2P)
461 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100462 if (config3 & MIPS_CONF3_VINT)
463 c->options |= MIPS_CPU_VINT;
464 if (config3 & MIPS_CONF3_VEIC)
465 c->options |= MIPS_CPU_VEIC;
466 if (config3 & MIPS_CONF3_MT)
467 c->ases |= MIPS_ASE_MIPSMT;
468 if (config3 & MIPS_CONF3_ULRI)
469 c->options |= MIPS_CPU_ULRI;
470
471 return config3 & MIPS_CONF_M;
472}
473
474static inline unsigned int decode_config4(struct cpuinfo_mips *c)
475{
476 unsigned int config4;
477
478 config4 = read_c0_config4();
479
480 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
481 && cpu_has_tlb)
482 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
483
484 c->kscratch_mask = (config4 >> 16) & 0xff;
485
486 return config4 & MIPS_CONF_M;
487}
488
489static void __cpuinit decode_configs(struct cpuinfo_mips *c)
490{
491 int ok;
492
493 /* MIPS32 or MIPS64 compliant CPU. */
494 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
495 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
496
497 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
498
499 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100500 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100501 if (ok)
502 ok = decode_config1(c);
503 if (ok)
504 ok = decode_config2(c);
505 if (ok)
506 ok = decode_config3(c);
507 if (ok)
508 ok = decode_config4(c);
509
510 mips_probe_watch_registers(c);
511
512 if (cpu_has_mips_r2)
513 c->core = read_c0_ebase() & 0x3ff;
514}
515
Ralf Baechle02cf2112005-10-01 13:06:32 +0100516#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 | MIPS_CPU_COUNTER)
518
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000519static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520{
521 switch (c->processor_id & 0xff00) {
522 case PRID_IMP_R2000:
523 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000524 __cpu_name[cpu] = "R2000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000525 set_isa(c, MIPS_CPU_ISA_I);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100526 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500527 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700528 if (__cpu_has_fpu())
529 c->options |= MIPS_CPU_FPU;
530 c->tlbsize = 64;
531 break;
532 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000533 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
534 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000536 __cpu_name[cpu] = "R3081";
537 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000539 __cpu_name[cpu] = "R3000A";
540 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000541 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000543 __cpu_name[cpu] = "R3000";
544 }
Steven J. Hilla96102b2012-12-07 04:31:36 +0000545 set_isa(c, MIPS_CPU_ISA_I);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100546 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500547 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 if (__cpu_has_fpu())
549 c->options |= MIPS_CPU_FPU;
550 c->tlbsize = 64;
551 break;
552 case PRID_IMP_R4000:
553 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000554 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000556 __cpu_name[cpu] = "R4400PC";
557 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000559 __cpu_name[cpu] = "R4000PC";
560 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000562 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700563 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000564 __cpu_name[cpu] = "R4400SC";
565 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700566 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000567 __cpu_name[cpu] = "R4000SC";
568 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 }
570
Steven J. Hilla96102b2012-12-07 04:31:36 +0000571 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500573 MIPS_CPU_WATCH | MIPS_CPU_VCE |
574 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575 c->tlbsize = 48;
576 break;
577 case PRID_IMP_VR41XX:
578 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 case PRID_REV_VR4111:
580 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000581 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 case PRID_REV_VR4121:
584 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000585 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 break;
587 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000588 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000590 __cpu_name[cpu] = "NEC VR4122";
591 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000593 __cpu_name[cpu] = "NEC VR4181A";
594 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 break;
596 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000597 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000599 __cpu_name[cpu] = "NEC VR4131";
600 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 c->cputype = CPU_VR4133;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000602 __cpu_name[cpu] = "NEC VR4133";
603 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700604 break;
605 default:
606 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
607 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000608 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 break;
610 }
Steven J. Hilla96102b2012-12-07 04:31:36 +0000611 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 c->options = R4K_OPTS;
613 c->tlbsize = 32;
614 break;
615 case PRID_IMP_R4300:
616 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000617 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000618 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700619 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500620 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 c->tlbsize = 32;
622 break;
623 case PRID_IMP_R4600:
624 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000625 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000626 set_isa(c, MIPS_CPU_ISA_III);
Thiemo Seufer075e7502005-07-27 21:48:12 +0000627 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
628 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 c->tlbsize = 48;
630 break;
631 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500632 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700633 /*
634 * This processor doesn't have an MMU, so it's not
635 * "real easy" to run Linux on it. It is left purely
636 * for documentation. Commented out because it shares
637 * it's c0_prid id number with the TX3900.
638 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000639 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000640 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000641 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500643 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 break;
645 #endif
646 case PRID_IMP_TX39:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000647 set_isa(c, MIPS_CPU_ISA_I);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100648 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649
650 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
651 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000652 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 c->tlbsize = 64;
654 } else {
655 switch (c->processor_id & 0xff) {
656 case PRID_REV_TX3912:
657 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000658 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 c->tlbsize = 32;
660 break;
661 case PRID_REV_TX3922:
662 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000663 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 c->tlbsize = 64;
665 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 }
667 }
668 break;
669 case PRID_IMP_R4700:
670 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000671 __cpu_name[cpu] = "R4700";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000672 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500674 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 c->tlbsize = 48;
676 break;
677 case PRID_IMP_TX49:
678 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000679 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000680 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 c->options = R4K_OPTS | MIPS_CPU_LLSC;
682 if (!(c->processor_id & 0x08))
683 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
684 c->tlbsize = 48;
685 break;
686 case PRID_IMP_R5000:
687 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000688 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000689 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500691 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 c->tlbsize = 48;
693 break;
694 case PRID_IMP_R5432:
695 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000696 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000697 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500699 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 c->tlbsize = 48;
701 break;
702 case PRID_IMP_R5500:
703 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000704 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000705 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500707 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 c->tlbsize = 48;
709 break;
710 case PRID_IMP_NEVADA:
711 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000712 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000713 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500715 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716 c->tlbsize = 48;
717 break;
718 case PRID_IMP_R6000:
719 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000720 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000721 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700722 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500723 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 c->tlbsize = 32;
725 break;
726 case PRID_IMP_R6000A:
727 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000728 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000729 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500731 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 c->tlbsize = 32;
733 break;
734 case PRID_IMP_RM7000:
735 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000736 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000737 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500739 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100741 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 * the RM7000 v2.0 indicates if the TLB has 48 or 64
743 * entries.
744 *
Ralf Baechle70342282013-01-22 12:59:30 +0100745 * 29 1 => 64 entry JTLB
746 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 */
748 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
749 break;
750 case PRID_IMP_RM9000:
751 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000752 __cpu_name[cpu] = "RM9000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000753 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500755 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 /*
757 * Bit 29 in the info register of the RM9000
758 * indicates if the TLB has 48 or 64 entries.
759 *
Ralf Baechle70342282013-01-22 12:59:30 +0100760 * 29 1 => 64 entry JTLB
761 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 */
763 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
764 break;
765 case PRID_IMP_R8000:
766 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000767 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000768 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500770 MIPS_CPU_FPU | MIPS_CPU_32FPR |
771 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
773 break;
774 case PRID_IMP_R10000:
775 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000776 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000777 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000778 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500779 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500781 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 c->tlbsize = 64;
783 break;
784 case PRID_IMP_R12000:
785 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000786 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000787 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000788 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500789 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500791 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 c->tlbsize = 64;
793 break;
Kumba44d921b2006-05-16 22:23:59 -0400794 case PRID_IMP_R14000:
795 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000796 __cpu_name[cpu] = "R14000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000797 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400798 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500799 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400800 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500801 MIPS_CPU_LLSC;
Kumba44d921b2006-05-16 22:23:59 -0400802 c->tlbsize = 64;
803 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800804 case PRID_IMP_LOONGSON2:
805 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000806 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700807
808 switch (c->processor_id & PRID_REV_MASK) {
809 case PRID_REV_LOONGSON2E:
810 set_elf_platform(cpu, "loongson2e");
811 break;
812 case PRID_REV_LOONGSON2F:
813 set_elf_platform(cpu, "loongson2f");
814 break;
815 }
816
Steven J. Hilla96102b2012-12-07 04:31:36 +0000817 set_isa(c, MIPS_CPU_ISA_III);
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800818 c->options = R4K_OPTS |
819 MIPS_CPU_FPU | MIPS_CPU_LLSC |
820 MIPS_CPU_32FPR;
821 c->tlbsize = 64;
822 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100823 case PRID_IMP_LOONGSON1:
824 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100826 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000827
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100828 switch (c->processor_id & PRID_REV_MASK) {
829 case PRID_REV_LOONGSON1B:
830 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +0000831 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000832 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100833
Ralf Baechle41943182005-05-05 16:45:59 +0000834 break;
Ralf Baechle41943182005-05-05 16:45:59 +0000835 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836}
837
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000838static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839{
Ralf Baechle41943182005-05-05 16:45:59 +0000840 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841 switch (c->processor_id & 0xff00) {
842 case PRID_IMP_4KC:
843 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000844 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700845 break;
846 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000847 case PRID_IMP_4KECR2:
848 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000849 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000850 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100852 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000854 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 break;
856 case PRID_IMP_5KC:
857 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000858 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +0200860 case PRID_IMP_5KE:
861 c->cputype = CPU_5KE;
862 __cpu_name[cpu] = "MIPS 5KE";
863 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 case PRID_IMP_20KC:
865 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000866 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 break;
868 case PRID_IMP_24K:
Ralf Baechlee50c0a82005-05-31 11:49:19 +0000869 case PRID_IMP_24KE:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000871 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 break;
873 case PRID_IMP_25KF:
874 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000875 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000877 case PRID_IMP_34K:
878 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000879 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000880 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100881 case PRID_IMP_74K:
882 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000883 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100884 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +0200885 case PRID_IMP_M14KC:
886 c->cputype = CPU_M14KC;
887 __cpu_name[cpu] = "MIPS M14Kc";
888 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100889 case PRID_IMP_1004K:
890 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000891 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100892 break;
Steven J. Hill006a8512012-06-26 04:11:03 +0000893 case PRID_IMP_1074K:
894 c->cputype = CPU_74K;
895 __cpu_name[cpu] = "MIPS 1074Kc";
896 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100898
899 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900}
901
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000902static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903{
Ralf Baechle41943182005-05-05 16:45:59 +0000904 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 switch (c->processor_id & 0xff00) {
906 case PRID_IMP_AU1_REV1:
907 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100908 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 switch ((c->processor_id >> 24) & 0xff) {
910 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000911 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912 break;
913 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000914 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 break;
916 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000917 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918 break;
919 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000920 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000922 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000923 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100924 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000925 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100926 break;
927 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000928 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000929 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100931 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 break;
933 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 break;
935 }
936}
937
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000938static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939{
Ralf Baechle41943182005-05-05 16:45:59 +0000940 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100941
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942 switch (c->processor_id & 0xff00) {
943 case PRID_IMP_SB1:
944 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000945 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100947 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000948 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700950 case PRID_IMP_SB1A:
951 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000952 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700953 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954 }
955}
956
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000957static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958{
Ralf Baechle41943182005-05-05 16:45:59 +0000959 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700960 switch (c->processor_id & 0xff00) {
961 case PRID_IMP_SR71000:
962 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000963 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 c->scache.ways = 8;
965 c->tlbsize = 64;
966 break;
967 }
968}
969
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000970static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000971{
972 decode_configs(c);
973 switch (c->processor_id & 0xff00) {
974 case PRID_IMP_PR4450:
975 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000976 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000977 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +0000978 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000979 }
980}
981
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000982static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200983{
984 decode_configs(c);
985 switch (c->processor_id & 0xff00) {
Kevin Cernekee190fca32010-11-23 10:26:45 -0800986 case PRID_IMP_BMIPS32_REV4:
987 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -0700988 c->cputype = CPU_BMIPS32;
989 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700990 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200991 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700992 case PRID_IMP_BMIPS3300:
993 case PRID_IMP_BMIPS3300_ALT:
994 case PRID_IMP_BMIPS3300_BUG:
995 c->cputype = CPU_BMIPS3300;
996 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700997 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200998 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700999 case PRID_IMP_BMIPS43XX: {
1000 int rev = c->processor_id & 0xff;
1001
1002 if (rev >= PRID_REV_BMIPS4380_LO &&
1003 rev <= PRID_REV_BMIPS4380_HI) {
1004 c->cputype = CPU_BMIPS4380;
1005 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001006 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001007 } else {
1008 c->cputype = CPU_BMIPS4350;
1009 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001010 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +01001011 }
1012 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001013 }
Kevin Cernekee602977b2010-10-16 14:22:30 -07001014 case PRID_IMP_BMIPS5000:
1015 c->cputype = CPU_BMIPS5000;
1016 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001017 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001018 c->options |= MIPS_CPU_ULRI;
1019 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001020 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001021}
1022
David Daney0dd47812008-12-11 15:33:26 -08001023static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
1024{
1025 decode_configs(c);
1026 switch (c->processor_id & 0xff00) {
1027 case PRID_IMP_CAVIUM_CN38XX:
1028 case PRID_IMP_CAVIUM_CN31XX:
1029 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -08001030 c->cputype = CPU_CAVIUM_OCTEON;
1031 __cpu_name[cpu] = "Cavium Octeon";
1032 goto platform;
David Daney0dd47812008-12-11 15:33:26 -08001033 case PRID_IMP_CAVIUM_CN58XX:
1034 case PRID_IMP_CAVIUM_CN56XX:
1035 case PRID_IMP_CAVIUM_CN50XX:
1036 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -08001037 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
1038 __cpu_name[cpu] = "Cavium Octeon+";
1039platform:
Robert Millanc094c992011-04-18 11:37:55 -07001040 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -08001041 break;
David Daneya1431b62011-09-24 02:29:54 +02001042 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -07001043 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +02001044 case PRID_IMP_CAVIUM_CN66XX:
1045 case PRID_IMP_CAVIUM_CN68XX:
David Daney0e56b382010-10-07 16:03:45 -07001046 c->cputype = CPU_CAVIUM_OCTEON2;
1047 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001048 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001049 break;
David Daney0dd47812008-12-11 15:33:26 -08001050 default:
1051 printk(KERN_INFO "Unknown Octeon chip!\n");
1052 c->cputype = CPU_UNKNOWN;
1053 break;
1054 }
1055}
1056
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001057static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1058{
1059 decode_configs(c);
1060 /* JZRISC does not implement the CP0 counter. */
1061 c->options &= ~MIPS_CPU_COUNTER;
1062 switch (c->processor_id & 0xff00) {
1063 case PRID_IMP_JZRISC:
1064 c->cputype = CPU_JZRISC;
1065 __cpu_name[cpu] = "Ingenic JZRISC";
1066 break;
1067 default:
1068 panic("Unknown Ingenic Processor ID!");
1069 break;
1070 }
1071}
1072
Jayachandran Ca7117c62011-05-11 12:04:58 +05301073static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1074{
1075 decode_configs(c);
1076
Manuel Lauss809f36c2011-11-01 20:03:30 +01001077 if ((c->processor_id & 0xff00) == PRID_IMP_NETLOGIC_AU13XX) {
1078 c->cputype = CPU_ALCHEMY;
1079 __cpu_name[cpu] = "Au1300";
1080 /* following stuff is not for Alchemy */
1081 return;
1082 }
1083
Ralf Baechle70342282013-01-22 12:59:30 +01001084 c->options = (MIPS_CPU_TLB |
1085 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301086 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +01001087 MIPS_CPU_DIVEC |
1088 MIPS_CPU_WATCH |
1089 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301090 MIPS_CPU_LLSC);
1091
1092 switch (c->processor_id & 0xff00) {
Jayachandran C2aa54b22011-11-16 00:21:29 +00001093 case PRID_IMP_NETLOGIC_XLP8XX:
1094 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001095 c->cputype = CPU_XLP;
1096 __cpu_name[cpu] = "Netlogic XLP";
1097 break;
1098
Jayachandran Ca7117c62011-05-11 12:04:58 +05301099 case PRID_IMP_NETLOGIC_XLR732:
1100 case PRID_IMP_NETLOGIC_XLR716:
1101 case PRID_IMP_NETLOGIC_XLR532:
1102 case PRID_IMP_NETLOGIC_XLR308:
1103 case PRID_IMP_NETLOGIC_XLR532C:
1104 case PRID_IMP_NETLOGIC_XLR516C:
1105 case PRID_IMP_NETLOGIC_XLR508C:
1106 case PRID_IMP_NETLOGIC_XLR308C:
1107 c->cputype = CPU_XLR;
1108 __cpu_name[cpu] = "Netlogic XLR";
1109 break;
1110
1111 case PRID_IMP_NETLOGIC_XLS608:
1112 case PRID_IMP_NETLOGIC_XLS408:
1113 case PRID_IMP_NETLOGIC_XLS404:
1114 case PRID_IMP_NETLOGIC_XLS208:
1115 case PRID_IMP_NETLOGIC_XLS204:
1116 case PRID_IMP_NETLOGIC_XLS108:
1117 case PRID_IMP_NETLOGIC_XLS104:
1118 case PRID_IMP_NETLOGIC_XLS616B:
1119 case PRID_IMP_NETLOGIC_XLS608B:
1120 case PRID_IMP_NETLOGIC_XLS416B:
1121 case PRID_IMP_NETLOGIC_XLS412B:
1122 case PRID_IMP_NETLOGIC_XLS408B:
1123 case PRID_IMP_NETLOGIC_XLS404B:
1124 c->cputype = CPU_XLR;
1125 __cpu_name[cpu] = "Netlogic XLS";
1126 break;
1127
1128 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001129 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301130 c->processor_id);
1131 c->cputype = CPU_XLR;
1132 break;
1133 }
1134
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001135 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001136 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001137 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1138 /* This will be updated again after all threads are woken up */
1139 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1140 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001141 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001142 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1143 }
Jayachandran Ca7117c62011-05-11 12:04:58 +05301144}
1145
David Daney949e51b2010-10-14 11:32:33 -07001146#ifdef CONFIG_64BIT
1147/* For use by uaccess.h */
1148u64 __ua_limit;
1149EXPORT_SYMBOL(__ua_limit);
1150#endif
1151
Ralf Baechle9966db252007-10-11 23:46:17 +01001152const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001153const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001154
Ralf Baechle234fcd12008-03-08 09:56:28 +00001155__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156{
1157 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001158 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159
Ralf Baechle70342282013-01-22 12:59:30 +01001160 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001161 c->fpu_id = FPIR_IMP_NONE;
1162 c->cputype = CPU_UNKNOWN;
1163
1164 c->processor_id = read_c0_prid();
1165 switch (c->processor_id & 0xff0000) {
1166 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001167 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 break;
1169 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001170 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171 break;
1172 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001173 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001174 break;
1175 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001176 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001178 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001179 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001180 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001182 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001184 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001185 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001186 break;
David Daney0dd47812008-12-11 15:33:26 -08001187 case PRID_COMP_CAVIUM:
1188 cpu_probe_cavium(c, cpu);
1189 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001190 case PRID_COMP_INGENIC:
1191 cpu_probe_ingenic(c, cpu);
1192 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301193 case PRID_COMP_NETLOGIC:
1194 cpu_probe_netlogic(c, cpu);
1195 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001197
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001198 BUG_ON(!__cpu_name[cpu]);
1199 BUG_ON(c->cputype == CPU_UNKNOWN);
1200
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001201 /*
1202 * Platform code can force the cpu type to optimize code
1203 * generation. In that case be sure the cpu type is correctly
1204 * manually setup otherwise it could trigger some nasty bugs.
1205 */
1206 BUG_ON(current_cpu_type() != c->cputype);
1207
Kevin Cernekee0103d232010-05-02 14:43:52 -07001208 if (mips_fpu_disabled)
1209 c->options &= ~MIPS_CPU_FPU;
1210
1211 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001212 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001213
Ralf Baechle41943182005-05-05 16:45:59 +00001214 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001215 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001216
Ralf Baechlee7958bb2005-12-08 13:00:20 +00001217 if (c->isa_level == MIPS_CPU_ISA_M32R1 ||
Ralf Baechleb4672d32005-12-08 14:04:24 +00001218 c->isa_level == MIPS_CPU_ISA_M32R2 ||
1219 c->isa_level == MIPS_CPU_ISA_M64R1 ||
1220 c->isa_level == MIPS_CPU_ISA_M64R2) {
Ralf Baechle41943182005-05-05 16:45:59 +00001221 if (c->fpu_id & MIPS_FPIR_3D)
1222 c->ases |= MIPS_ASE_MIPS3D;
1223 }
1224 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001225
Al Cooperda4b62c2012-07-13 16:44:51 -04001226 if (cpu_has_mips_r2) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001227 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001228 /* R2 has Performance Counter Interrupt indicator */
1229 c->options |= MIPS_CPU_PCI;
1230 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001231 else
1232 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001233
1234 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001235
1236#ifdef CONFIG_64BIT
1237 if (cpu == 0)
1238 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1239#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001240}
1241
Ralf Baechle234fcd12008-03-08 09:56:28 +00001242__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001243{
1244 struct cpuinfo_mips *c = &current_cpu_data;
1245
Ralf Baechle9966db252007-10-11 23:46:17 +01001246 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1247 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001249 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001250}