blob: f87039dbefe96cf166a5a12a4afca1ac173e6580 [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
Kevin Cernekee0103d232010-05-02 14:43:52 -070030static int __cpuinitdata mips_fpu_disabled;
31
32static int __init fpu_disable(char *s)
33{
34 cpu_data[0].options &= ~MIPS_CPU_FPU;
35 mips_fpu_disabled = 1;
36
37 return 1;
38}
39
40__setup("nofpu", fpu_disable);
41
42int __cpuinitdata mips_dsp_disabled;
43
44static int __init dsp_disable(char *s)
45{
Steven J. Hillee80f7c72012-08-03 10:26:04 -050046 cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -070047 mips_dsp_disabled = 1;
48
49 return 1;
50}
51
52__setup("nodsp", dsp_disable);
53
Marc St-Jean9267a302007-06-14 15:55:31 -060054static inline void check_errata(void)
55{
56 struct cpuinfo_mips *c = &current_cpu_data;
57
58 switch (c->cputype) {
59 case CPU_34K:
60 /*
61 * Erratum "RPS May Cause Incorrect Instruction Execution"
62 * This code only handles VPE0, any SMP/SMTC/RTOS code
63 * making use of VPE1 will be responsable for that VPE.
64 */
65 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
66 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
67 break;
68 default:
69 break;
70 }
71}
72
Linus Torvalds1da177e2005-04-16 15:20:36 -070073void __init check_bugs32(void)
74{
Marc St-Jean9267a302007-06-14 15:55:31 -060075 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -070076}
77
78/*
79 * Probe whether cpu has config register by trying to play with
80 * alternate cache bit and see whether it matters.
81 * It's used by cpu_probe to distinguish between R3000A and R3081.
82 */
83static inline int cpu_has_confreg(void)
84{
85#ifdef CONFIG_CPU_R3000
86 extern unsigned long r3k_cache_size(unsigned long);
87 unsigned long size1, size2;
88 unsigned long cfg = read_c0_conf();
89
90 size1 = r3k_cache_size(ST0_ISC);
91 write_c0_conf(cfg ^ R30XX_CONF_AC);
92 size2 = r3k_cache_size(ST0_ISC);
93 write_c0_conf(cfg);
94 return size1 != size2;
95#else
96 return 0;
97#endif
98}
99
Robert Millanc094c992011-04-18 11:37:55 -0700100static inline void set_elf_platform(int cpu, const char *plat)
101{
102 if (cpu == 0)
103 __elf_platform = plat;
104}
105
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106/*
107 * Get the FPU Implementation/Revision.
108 */
109static inline unsigned long cpu_get_fpu_id(void)
110{
111 unsigned long tmp, fpu_id;
112
113 tmp = read_c0_status();
114 __enable_fpu();
115 fpu_id = read_32bit_cp1_register(CP1_REVISION);
116 write_c0_status(tmp);
117 return fpu_id;
118}
119
120/*
121 * Check the CPU has an FPU the official way.
122 */
123static inline int __cpu_has_fpu(void)
124{
125 return ((cpu_get_fpu_id() & 0xff00) != FPIR_IMP_NONE);
126}
127
Guenter Roeck91dfc422010-02-02 08:52:20 -0800128static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
129{
130#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800131 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800132 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800133 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800134#endif
135}
136
Steven J. Hilla96102b2012-12-07 04:31:36 +0000137static void __cpuinit set_isa(struct cpuinfo_mips *c, unsigned int isa)
138{
139 switch (isa) {
140 case MIPS_CPU_ISA_M64R2:
141 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
142 case MIPS_CPU_ISA_M64R1:
143 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
144 case MIPS_CPU_ISA_V:
145 c->isa_level |= MIPS_CPU_ISA_V;
146 case MIPS_CPU_ISA_IV:
147 c->isa_level |= MIPS_CPU_ISA_IV;
148 case MIPS_CPU_ISA_III:
Ralf Baechle1990e542013-06-26 17:06:34 +0200149 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000150 break;
151
152 case MIPS_CPU_ISA_M32R2:
153 c->isa_level |= MIPS_CPU_ISA_M32R2;
154 case MIPS_CPU_ISA_M32R1:
155 c->isa_level |= MIPS_CPU_ISA_M32R1;
156 case MIPS_CPU_ISA_II:
157 c->isa_level |= MIPS_CPU_ISA_II;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000158 break;
159 }
160}
161
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100162static char unknown_isa[] __cpuinitdata = KERN_ERR \
163 "Unsupported ISA type, c0.config0: %d.";
164
165static inline unsigned int decode_config0(struct cpuinfo_mips *c)
166{
167 unsigned int config0;
168 int isa;
169
170 config0 = read_c0_config();
171
172 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
173 c->options |= MIPS_CPU_TLB;
174 isa = (config0 & MIPS_CONF_AT) >> 13;
175 switch (isa) {
176 case 0:
177 switch ((config0 & MIPS_CONF_AR) >> 10) {
178 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000179 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100180 break;
181 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000182 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100183 break;
184 default:
185 goto unknown;
186 }
187 break;
188 case 2:
189 switch ((config0 & MIPS_CONF_AR) >> 10) {
190 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000191 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100192 break;
193 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000194 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100195 break;
196 default:
197 goto unknown;
198 }
199 break;
200 default:
201 goto unknown;
202 }
203
204 return config0 & MIPS_CONF_M;
205
206unknown:
207 panic(unknown_isa, config0);
208}
209
210static inline unsigned int decode_config1(struct cpuinfo_mips *c)
211{
212 unsigned int config1;
213
214 config1 = read_c0_config1();
215
216 if (config1 & MIPS_CONF1_MD)
217 c->ases |= MIPS_ASE_MDMX;
218 if (config1 & MIPS_CONF1_WR)
219 c->options |= MIPS_CPU_WATCH;
220 if (config1 & MIPS_CONF1_CA)
221 c->ases |= MIPS_ASE_MIPS16;
222 if (config1 & MIPS_CONF1_EP)
223 c->options |= MIPS_CPU_EJTAG;
224 if (config1 & MIPS_CONF1_FP) {
225 c->options |= MIPS_CPU_FPU;
226 c->options |= MIPS_CPU_32FPR;
227 }
228 if (cpu_has_tlb)
229 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
230
231 return config1 & MIPS_CONF_M;
232}
233
234static inline unsigned int decode_config2(struct cpuinfo_mips *c)
235{
236 unsigned int config2;
237
238 config2 = read_c0_config2();
239
240 if (config2 & MIPS_CONF2_SL)
241 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
242
243 return config2 & MIPS_CONF_M;
244}
245
246static inline unsigned int decode_config3(struct cpuinfo_mips *c)
247{
248 unsigned int config3;
249
250 config3 = read_c0_config3();
251
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500252 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100253 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500254 c->options |= MIPS_CPU_RIXI;
255 }
256 if (config3 & MIPS_CONF3_RXI)
257 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100258 if (config3 & MIPS_CONF3_DSP)
259 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500260 if (config3 & MIPS_CONF3_DSP2P)
261 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100262 if (config3 & MIPS_CONF3_VINT)
263 c->options |= MIPS_CPU_VINT;
264 if (config3 & MIPS_CONF3_VEIC)
265 c->options |= MIPS_CPU_VEIC;
266 if (config3 & MIPS_CONF3_MT)
267 c->ases |= MIPS_ASE_MIPSMT;
268 if (config3 & MIPS_CONF3_ULRI)
269 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000270 if (config3 & MIPS_CONF3_ISA)
271 c->options |= MIPS_CPU_MICROMIPS;
Steven J. Hill2a0b24f2013-03-25 12:15:55 -0500272#ifdef CONFIG_CPU_MICROMIPS
273 write_c0_config3(read_c0_config3() | MIPS_CONF3_ISA_OE);
274#endif
David Daney1e7decd2013-02-16 23:42:43 +0100275 if (config3 & MIPS_CONF3_VZ)
276 c->ases |= MIPS_ASE_VZ;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100277
278 return config3 & MIPS_CONF_M;
279}
280
281static inline unsigned int decode_config4(struct cpuinfo_mips *c)
282{
283 unsigned int config4;
284
285 config4 = read_c0_config4();
286
287 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
288 && cpu_has_tlb)
289 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
290
291 c->kscratch_mask = (config4 >> 16) & 0xff;
292
293 return config4 & MIPS_CONF_M;
294}
295
296static void __cpuinit decode_configs(struct cpuinfo_mips *c)
297{
298 int ok;
299
300 /* MIPS32 or MIPS64 compliant CPU. */
301 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
302 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
303
304 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
305
306 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100307 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100308 if (ok)
309 ok = decode_config1(c);
310 if (ok)
311 ok = decode_config2(c);
312 if (ok)
313 ok = decode_config3(c);
314 if (ok)
315 ok = decode_config4(c);
316
317 mips_probe_watch_registers(c);
318
319 if (cpu_has_mips_r2)
320 c->core = read_c0_ebase() & 0x3ff;
321}
322
Ralf Baechle02cf2112005-10-01 13:06:32 +0100323#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 | MIPS_CPU_COUNTER)
325
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000326static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327{
328 switch (c->processor_id & 0xff00) {
329 case PRID_IMP_R2000:
330 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000331 __cpu_name[cpu] = "R2000";
Ralf Baechle02cf2112005-10-01 13:06:32 +0100332 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500333 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700334 if (__cpu_has_fpu())
335 c->options |= MIPS_CPU_FPU;
336 c->tlbsize = 64;
337 break;
338 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000339 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
340 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700341 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000342 __cpu_name[cpu] = "R3081";
343 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700344 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000345 __cpu_name[cpu] = "R3000A";
346 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000347 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000349 __cpu_name[cpu] = "R3000";
350 }
Ralf Baechle02cf2112005-10-01 13:06:32 +0100351 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500352 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700353 if (__cpu_has_fpu())
354 c->options |= MIPS_CPU_FPU;
355 c->tlbsize = 64;
356 break;
357 case PRID_IMP_R4000:
358 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000359 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000361 __cpu_name[cpu] = "R4400PC";
362 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700363 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000364 __cpu_name[cpu] = "R4000PC";
365 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000367 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000369 __cpu_name[cpu] = "R4400SC";
370 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000372 __cpu_name[cpu] = "R4000SC";
373 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 }
375
Steven J. Hilla96102b2012-12-07 04:31:36 +0000376 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500378 MIPS_CPU_WATCH | MIPS_CPU_VCE |
379 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380 c->tlbsize = 48;
381 break;
382 case PRID_IMP_VR41XX:
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900383 set_isa(c, MIPS_CPU_ISA_III);
384 c->options = R4K_OPTS;
385 c->tlbsize = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700386 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 case PRID_REV_VR4111:
388 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000389 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 case PRID_REV_VR4121:
392 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000393 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 break;
395 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000396 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000398 __cpu_name[cpu] = "NEC VR4122";
399 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000401 __cpu_name[cpu] = "NEC VR4181A";
402 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700403 break;
404 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000405 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000407 __cpu_name[cpu] = "NEC VR4131";
408 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 c->cputype = CPU_VR4133;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900410 c->options |= MIPS_CPU_LLSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000411 __cpu_name[cpu] = "NEC VR4133";
412 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 break;
414 default:
415 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
416 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000417 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 break;
419 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420 break;
421 case PRID_IMP_R4300:
422 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000423 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000424 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500426 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 c->tlbsize = 32;
428 break;
429 case PRID_IMP_R4600:
430 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000431 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000432 set_isa(c, MIPS_CPU_ISA_III);
Thiemo Seufer075e7502005-07-27 21:48:12 +0000433 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
434 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 c->tlbsize = 48;
436 break;
437 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500438 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 /*
440 * This processor doesn't have an MMU, so it's not
441 * "real easy" to run Linux on it. It is left purely
442 * for documentation. Commented out because it shares
443 * it's c0_prid id number with the TX3900.
444 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000445 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000446 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000447 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500449 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450 break;
451 #endif
452 case PRID_IMP_TX39:
Ralf Baechle02cf2112005-10-01 13:06:32 +0100453 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
455 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
456 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000457 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 c->tlbsize = 64;
459 } else {
460 switch (c->processor_id & 0xff) {
461 case PRID_REV_TX3912:
462 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000463 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 c->tlbsize = 32;
465 break;
466 case PRID_REV_TX3922:
467 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000468 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469 c->tlbsize = 64;
470 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 }
472 }
473 break;
474 case PRID_IMP_R4700:
475 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000476 __cpu_name[cpu] = "R4700";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000477 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500479 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 c->tlbsize = 48;
481 break;
482 case PRID_IMP_TX49:
483 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000484 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000485 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 c->options = R4K_OPTS | MIPS_CPU_LLSC;
487 if (!(c->processor_id & 0x08))
488 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
489 c->tlbsize = 48;
490 break;
491 case PRID_IMP_R5000:
492 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000493 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000494 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500496 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 c->tlbsize = 48;
498 break;
499 case PRID_IMP_R5432:
500 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000501 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000502 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500504 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 c->tlbsize = 48;
506 break;
507 case PRID_IMP_R5500:
508 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000509 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000510 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500512 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 c->tlbsize = 48;
514 break;
515 case PRID_IMP_NEVADA:
516 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000517 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000518 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500520 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521 c->tlbsize = 48;
522 break;
523 case PRID_IMP_R6000:
524 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000525 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000526 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500528 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 c->tlbsize = 32;
530 break;
531 case PRID_IMP_R6000A:
532 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000533 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000534 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500536 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537 c->tlbsize = 32;
538 break;
539 case PRID_IMP_RM7000:
540 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000541 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000542 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500544 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100546 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547 * the RM7000 v2.0 indicates if the TLB has 48 or 64
548 * entries.
549 *
Ralf Baechle70342282013-01-22 12:59:30 +0100550 * 29 1 => 64 entry JTLB
551 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 */
553 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
554 break;
555 case PRID_IMP_RM9000:
556 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000557 __cpu_name[cpu] = "RM9000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000558 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500560 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700561 /*
562 * Bit 29 in the info register of the RM9000
563 * indicates if the TLB has 48 or 64 entries.
564 *
Ralf Baechle70342282013-01-22 12:59:30 +0100565 * 29 1 => 64 entry JTLB
566 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 */
568 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
569 break;
570 case PRID_IMP_R8000:
571 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000572 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000573 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500575 MIPS_CPU_FPU | MIPS_CPU_32FPR |
576 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
578 break;
579 case PRID_IMP_R10000:
580 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000581 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000582 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000583 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500584 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700585 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500586 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 c->tlbsize = 64;
588 break;
589 case PRID_IMP_R12000:
590 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000591 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000592 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000593 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500594 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500596 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 c->tlbsize = 64;
598 break;
Kumba44d921b2006-05-16 22:23:59 -0400599 case PRID_IMP_R14000:
600 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000601 __cpu_name[cpu] = "R14000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000602 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400603 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500604 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400605 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500606 MIPS_CPU_LLSC;
Kumba44d921b2006-05-16 22:23:59 -0400607 c->tlbsize = 64;
608 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800609 case PRID_IMP_LOONGSON2:
610 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000611 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700612
613 switch (c->processor_id & PRID_REV_MASK) {
614 case PRID_REV_LOONGSON2E:
615 set_elf_platform(cpu, "loongson2e");
616 break;
617 case PRID_REV_LOONGSON2F:
618 set_elf_platform(cpu, "loongson2f");
619 break;
620 }
621
Steven J. Hilla96102b2012-12-07 04:31:36 +0000622 set_isa(c, MIPS_CPU_ISA_III);
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800623 c->options = R4K_OPTS |
624 MIPS_CPU_FPU | MIPS_CPU_LLSC |
625 MIPS_CPU_32FPR;
626 c->tlbsize = 64;
627 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100628 case PRID_IMP_LOONGSON1:
629 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100631 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000632
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100633 switch (c->processor_id & PRID_REV_MASK) {
634 case PRID_REV_LOONGSON1B:
635 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +0000636 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000637 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100638
Ralf Baechle41943182005-05-05 16:45:59 +0000639 break;
Ralf Baechle41943182005-05-05 16:45:59 +0000640 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641}
642
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000643static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644{
Ralf Baechle41943182005-05-05 16:45:59 +0000645 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 switch (c->processor_id & 0xff00) {
647 case PRID_IMP_4KC:
648 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000649 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 break;
651 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000652 case PRID_IMP_4KECR2:
653 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000654 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000655 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100657 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000659 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 break;
661 case PRID_IMP_5KC:
662 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000663 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +0200665 case PRID_IMP_5KE:
666 c->cputype = CPU_5KE;
667 __cpu_name[cpu] = "MIPS 5KE";
668 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 case PRID_IMP_20KC:
670 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000671 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 break;
673 case PRID_IMP_24K:
674 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000675 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 break;
John Crispin42f3cae2013-01-11 22:44:10 +0100677 case PRID_IMP_24KE:
678 c->cputype = CPU_24K;
679 __cpu_name[cpu] = "MIPS 24KEc";
680 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681 case PRID_IMP_25KF:
682 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000683 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000685 case PRID_IMP_34K:
686 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000687 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000688 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100689 case PRID_IMP_74K:
690 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000691 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100692 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +0200693 case PRID_IMP_M14KC:
694 c->cputype = CPU_M14KC;
695 __cpu_name[cpu] = "MIPS M14Kc";
696 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000697 case PRID_IMP_M14KEC:
698 c->cputype = CPU_M14KEC;
699 __cpu_name[cpu] = "MIPS M14KEc";
700 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100701 case PRID_IMP_1004K:
702 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000703 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100704 break;
Steven J. Hill006a8512012-06-26 04:11:03 +0000705 case PRID_IMP_1074K:
706 c->cputype = CPU_74K;
707 __cpu_name[cpu] = "MIPS 1074Kc";
708 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100710
711 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712}
713
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000714static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715{
Ralf Baechle41943182005-05-05 16:45:59 +0000716 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 switch (c->processor_id & 0xff00) {
718 case PRID_IMP_AU1_REV1:
719 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100720 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 switch ((c->processor_id >> 24) & 0xff) {
722 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000723 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 break;
725 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000726 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 break;
728 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000729 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 break;
731 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000732 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000734 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000735 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100736 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000737 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100738 break;
739 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000740 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000741 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100743 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744 break;
745 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 break;
747 }
748}
749
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000750static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751{
Ralf Baechle41943182005-05-05 16:45:59 +0000752 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100753
Linus Torvalds1da177e2005-04-16 15:20:36 -0700754 switch (c->processor_id & 0xff00) {
755 case PRID_IMP_SB1:
756 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000757 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100759 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000760 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700762 case PRID_IMP_SB1A:
763 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000764 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700765 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 }
767}
768
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000769static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770{
Ralf Baechle41943182005-05-05 16:45:59 +0000771 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 switch (c->processor_id & 0xff00) {
773 case PRID_IMP_SR71000:
774 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000775 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776 c->scache.ways = 8;
777 c->tlbsize = 64;
778 break;
779 }
780}
781
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000782static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000783{
784 decode_configs(c);
785 switch (c->processor_id & 0xff00) {
786 case PRID_IMP_PR4450:
787 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000788 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000789 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +0000790 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000791 }
792}
793
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000794static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200795{
796 decode_configs(c);
797 switch (c->processor_id & 0xff00) {
Kevin Cernekee190fca32010-11-23 10:26:45 -0800798 case PRID_IMP_BMIPS32_REV4:
799 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -0700800 c->cputype = CPU_BMIPS32;
801 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700802 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200803 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700804 case PRID_IMP_BMIPS3300:
805 case PRID_IMP_BMIPS3300_ALT:
806 case PRID_IMP_BMIPS3300_BUG:
807 c->cputype = CPU_BMIPS3300;
808 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700809 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200810 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700811 case PRID_IMP_BMIPS43XX: {
812 int rev = c->processor_id & 0xff;
813
814 if (rev >= PRID_REV_BMIPS4380_LO &&
815 rev <= PRID_REV_BMIPS4380_HI) {
816 c->cputype = CPU_BMIPS4380;
817 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700818 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700819 } else {
820 c->cputype = CPU_BMIPS4350;
821 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700822 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +0100823 }
824 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200825 }
Kevin Cernekee602977b2010-10-16 14:22:30 -0700826 case PRID_IMP_BMIPS5000:
827 c->cputype = CPU_BMIPS5000;
828 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700829 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700830 c->options |= MIPS_CPU_ULRI;
831 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700832 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200833}
834
David Daney0dd47812008-12-11 15:33:26 -0800835static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
836{
837 decode_configs(c);
838 switch (c->processor_id & 0xff00) {
839 case PRID_IMP_CAVIUM_CN38XX:
840 case PRID_IMP_CAVIUM_CN31XX:
841 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -0800842 c->cputype = CPU_CAVIUM_OCTEON;
843 __cpu_name[cpu] = "Cavium Octeon";
844 goto platform;
David Daney0dd47812008-12-11 15:33:26 -0800845 case PRID_IMP_CAVIUM_CN58XX:
846 case PRID_IMP_CAVIUM_CN56XX:
847 case PRID_IMP_CAVIUM_CN50XX:
848 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -0800849 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
850 __cpu_name[cpu] = "Cavium Octeon+";
851platform:
Robert Millanc094c992011-04-18 11:37:55 -0700852 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -0800853 break;
David Daneya1431b62011-09-24 02:29:54 +0200854 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -0700855 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +0200856 case PRID_IMP_CAVIUM_CN66XX:
857 case PRID_IMP_CAVIUM_CN68XX:
David Daney0e56b382010-10-07 16:03:45 -0700858 c->cputype = CPU_CAVIUM_OCTEON2;
859 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -0700860 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -0700861 break;
David Daney0dd47812008-12-11 15:33:26 -0800862 default:
863 printk(KERN_INFO "Unknown Octeon chip!\n");
864 c->cputype = CPU_UNKNOWN;
865 break;
866 }
867}
868
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +0000869static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
870{
871 decode_configs(c);
872 /* JZRISC does not implement the CP0 counter. */
873 c->options &= ~MIPS_CPU_COUNTER;
874 switch (c->processor_id & 0xff00) {
875 case PRID_IMP_JZRISC:
876 c->cputype = CPU_JZRISC;
877 __cpu_name[cpu] = "Ingenic JZRISC";
878 break;
879 default:
880 panic("Unknown Ingenic Processor ID!");
881 break;
882 }
883}
884
Jayachandran Ca7117c62011-05-11 12:04:58 +0530885static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
886{
887 decode_configs(c);
888
Manuel Lauss809f36c2011-11-01 20:03:30 +0100889 if ((c->processor_id & 0xff00) == PRID_IMP_NETLOGIC_AU13XX) {
890 c->cputype = CPU_ALCHEMY;
891 __cpu_name[cpu] = "Au1300";
892 /* following stuff is not for Alchemy */
893 return;
894 }
895
Ralf Baechle70342282013-01-22 12:59:30 +0100896 c->options = (MIPS_CPU_TLB |
897 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +0530898 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +0100899 MIPS_CPU_DIVEC |
900 MIPS_CPU_WATCH |
901 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +0530902 MIPS_CPU_LLSC);
903
904 switch (c->processor_id & 0xff00) {
Jayachandran C2aa54b22011-11-16 00:21:29 +0000905 case PRID_IMP_NETLOGIC_XLP8XX:
906 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +0000907 c->cputype = CPU_XLP;
908 __cpu_name[cpu] = "Netlogic XLP";
909 break;
910
Jayachandran Ca7117c62011-05-11 12:04:58 +0530911 case PRID_IMP_NETLOGIC_XLR732:
912 case PRID_IMP_NETLOGIC_XLR716:
913 case PRID_IMP_NETLOGIC_XLR532:
914 case PRID_IMP_NETLOGIC_XLR308:
915 case PRID_IMP_NETLOGIC_XLR532C:
916 case PRID_IMP_NETLOGIC_XLR516C:
917 case PRID_IMP_NETLOGIC_XLR508C:
918 case PRID_IMP_NETLOGIC_XLR308C:
919 c->cputype = CPU_XLR;
920 __cpu_name[cpu] = "Netlogic XLR";
921 break;
922
923 case PRID_IMP_NETLOGIC_XLS608:
924 case PRID_IMP_NETLOGIC_XLS408:
925 case PRID_IMP_NETLOGIC_XLS404:
926 case PRID_IMP_NETLOGIC_XLS208:
927 case PRID_IMP_NETLOGIC_XLS204:
928 case PRID_IMP_NETLOGIC_XLS108:
929 case PRID_IMP_NETLOGIC_XLS104:
930 case PRID_IMP_NETLOGIC_XLS616B:
931 case PRID_IMP_NETLOGIC_XLS608B:
932 case PRID_IMP_NETLOGIC_XLS416B:
933 case PRID_IMP_NETLOGIC_XLS412B:
934 case PRID_IMP_NETLOGIC_XLS408B:
935 case PRID_IMP_NETLOGIC_XLS404B:
936 c->cputype = CPU_XLR;
937 __cpu_name[cpu] = "Netlogic XLS";
938 break;
939
940 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +0000941 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +0530942 c->processor_id);
943 c->cputype = CPU_XLR;
944 break;
945 }
946
Jayachandran Ca3d4fb22011-11-16 00:21:20 +0000947 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +0000948 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +0000949 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
950 /* This will be updated again after all threads are woken up */
951 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
952 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +0000953 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +0000954 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
955 }
Jayachandran C7777b932013-06-11 14:41:35 +0000956 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +0530957}
958
David Daney949e51b2010-10-14 11:32:33 -0700959#ifdef CONFIG_64BIT
960/* For use by uaccess.h */
961u64 __ua_limit;
962EXPORT_SYMBOL(__ua_limit);
963#endif
964
Ralf Baechle9966db252007-10-11 23:46:17 +0100965const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -0800966const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +0100967
Ralf Baechle234fcd12008-03-08 09:56:28 +0000968__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969{
970 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100971 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700972
Ralf Baechle70342282013-01-22 12:59:30 +0100973 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 c->fpu_id = FPIR_IMP_NONE;
975 c->cputype = CPU_UNKNOWN;
976
977 c->processor_id = read_c0_prid();
978 switch (c->processor_id & 0xff0000) {
979 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000980 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981 break;
982 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000983 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984 break;
985 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000986 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 break;
988 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000989 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200991 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000992 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200993 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700994 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000995 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 break;
Daniel Lairda92b0582008-03-06 09:07:18 +0000997 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000998 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000999 break;
David Daney0dd47812008-12-11 15:33:26 -08001000 case PRID_COMP_CAVIUM:
1001 cpu_probe_cavium(c, cpu);
1002 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001003 case PRID_COMP_INGENIC:
1004 cpu_probe_ingenic(c, cpu);
1005 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301006 case PRID_COMP_NETLOGIC:
1007 cpu_probe_netlogic(c, cpu);
1008 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001010
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001011 BUG_ON(!__cpu_name[cpu]);
1012 BUG_ON(c->cputype == CPU_UNKNOWN);
1013
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001014 /*
1015 * Platform code can force the cpu type to optimize code
1016 * generation. In that case be sure the cpu type is correctly
1017 * manually setup otherwise it could trigger some nasty bugs.
1018 */
1019 BUG_ON(current_cpu_type() != c->cputype);
1020
Kevin Cernekee0103d232010-05-02 14:43:52 -07001021 if (mips_fpu_disabled)
1022 c->options &= ~MIPS_CPU_FPU;
1023
1024 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001025 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001026
Ralf Baechle41943182005-05-05 16:45:59 +00001027 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001028 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001029
Deng-Cheng Zhuadb37892013-04-01 18:14:28 +00001030 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 |
1031 MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)) {
Ralf Baechle41943182005-05-05 16:45:59 +00001032 if (c->fpu_id & MIPS_FPIR_3D)
1033 c->ases |= MIPS_ASE_MIPS3D;
1034 }
1035 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001036
Al Cooperda4b62c2012-07-13 16:44:51 -04001037 if (cpu_has_mips_r2) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001038 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001039 /* R2 has Performance Counter Interrupt indicator */
1040 c->options |= MIPS_CPU_PCI;
1041 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001042 else
1043 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001044
1045 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001046
1047#ifdef CONFIG_64BIT
1048 if (cpu == 0)
1049 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1050#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051}
1052
Ralf Baechle234fcd12008-03-08 09:56:28 +00001053__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054{
1055 struct cpuinfo_mips *c = &current_cpu_data;
1056
Ralf Baechle9966db252007-10-11 23:46:17 +01001057 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1058 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001060 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001061}