blob: 265c97da661929fa3732948bdfa4a18c21e0a5e9 [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:
149 c->isa_level |= MIPS_CPU_ISA_I | MIPS_CPU_ISA_II |
150 MIPS_CPU_ISA_III;
151 break;
152
153 case MIPS_CPU_ISA_M32R2:
154 c->isa_level |= MIPS_CPU_ISA_M32R2;
155 case MIPS_CPU_ISA_M32R1:
156 c->isa_level |= MIPS_CPU_ISA_M32R1;
157 case MIPS_CPU_ISA_II:
158 c->isa_level |= MIPS_CPU_ISA_II;
159 case MIPS_CPU_ISA_I:
160 c->isa_level |= MIPS_CPU_ISA_I;
161 break;
162 }
163}
164
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100165static char unknown_isa[] __cpuinitdata = KERN_ERR \
166 "Unsupported ISA type, c0.config0: %d.";
167
168static inline unsigned int decode_config0(struct cpuinfo_mips *c)
169{
170 unsigned int config0;
171 int isa;
172
173 config0 = read_c0_config();
174
175 if (((config0 & MIPS_CONF_MT) >> 7) == 1)
176 c->options |= MIPS_CPU_TLB;
177 isa = (config0 & MIPS_CONF_AT) >> 13;
178 switch (isa) {
179 case 0:
180 switch ((config0 & MIPS_CONF_AR) >> 10) {
181 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000182 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100183 break;
184 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000185 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100186 break;
187 default:
188 goto unknown;
189 }
190 break;
191 case 2:
192 switch ((config0 & MIPS_CONF_AR) >> 10) {
193 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000194 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100195 break;
196 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000197 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100198 break;
199 default:
200 goto unknown;
201 }
202 break;
203 default:
204 goto unknown;
205 }
206
207 return config0 & MIPS_CONF_M;
208
209unknown:
210 panic(unknown_isa, config0);
211}
212
213static inline unsigned int decode_config1(struct cpuinfo_mips *c)
214{
215 unsigned int config1;
216
217 config1 = read_c0_config1();
218
219 if (config1 & MIPS_CONF1_MD)
220 c->ases |= MIPS_ASE_MDMX;
221 if (config1 & MIPS_CONF1_WR)
222 c->options |= MIPS_CPU_WATCH;
223 if (config1 & MIPS_CONF1_CA)
224 c->ases |= MIPS_ASE_MIPS16;
225 if (config1 & MIPS_CONF1_EP)
226 c->options |= MIPS_CPU_EJTAG;
227 if (config1 & MIPS_CONF1_FP) {
228 c->options |= MIPS_CPU_FPU;
229 c->options |= MIPS_CPU_32FPR;
230 }
231 if (cpu_has_tlb)
232 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
233
234 return config1 & MIPS_CONF_M;
235}
236
237static inline unsigned int decode_config2(struct cpuinfo_mips *c)
238{
239 unsigned int config2;
240
241 config2 = read_c0_config2();
242
243 if (config2 & MIPS_CONF2_SL)
244 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
245
246 return config2 & MIPS_CONF_M;
247}
248
249static inline unsigned int decode_config3(struct cpuinfo_mips *c)
250{
251 unsigned int config3;
252
253 config3 = read_c0_config3();
254
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500255 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100256 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500257 c->options |= MIPS_CPU_RIXI;
258 }
259 if (config3 & MIPS_CONF3_RXI)
260 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100261 if (config3 & MIPS_CONF3_DSP)
262 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500263 if (config3 & MIPS_CONF3_DSP2P)
264 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100265 if (config3 & MIPS_CONF3_VINT)
266 c->options |= MIPS_CPU_VINT;
267 if (config3 & MIPS_CONF3_VEIC)
268 c->options |= MIPS_CPU_VEIC;
269 if (config3 & MIPS_CONF3_MT)
270 c->ases |= MIPS_ASE_MIPSMT;
271 if (config3 & MIPS_CONF3_ULRI)
272 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000273 if (config3 & MIPS_CONF3_ISA)
274 c->options |= MIPS_CPU_MICROMIPS;
Steven J. Hill2a0b24f2013-03-25 12:15:55 -0500275#ifdef CONFIG_CPU_MICROMIPS
276 write_c0_config3(read_c0_config3() | MIPS_CONF3_ISA_OE);
277#endif
David Daney1e7decd2013-02-16 23:42:43 +0100278 if (config3 & MIPS_CONF3_VZ)
279 c->ases |= MIPS_ASE_VZ;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100280
281 return config3 & MIPS_CONF_M;
282}
283
284static inline unsigned int decode_config4(struct cpuinfo_mips *c)
285{
286 unsigned int config4;
287
288 config4 = read_c0_config4();
289
290 if ((config4 & MIPS_CONF4_MMUEXTDEF) == MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT
291 && cpu_has_tlb)
292 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
293
294 c->kscratch_mask = (config4 >> 16) & 0xff;
295
296 return config4 & MIPS_CONF_M;
297}
298
299static void __cpuinit decode_configs(struct cpuinfo_mips *c)
300{
301 int ok;
302
303 /* MIPS32 or MIPS64 compliant CPU. */
304 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
305 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
306
307 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
308
309 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100310 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100311 if (ok)
312 ok = decode_config1(c);
313 if (ok)
314 ok = decode_config2(c);
315 if (ok)
316 ok = decode_config3(c);
317 if (ok)
318 ok = decode_config4(c);
319
320 mips_probe_watch_registers(c);
321
322 if (cpu_has_mips_r2)
323 c->core = read_c0_ebase() & 0x3ff;
324}
325
Ralf Baechle02cf2112005-10-01 13:06:32 +0100326#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327 | MIPS_CPU_COUNTER)
328
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000329static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700330{
331 switch (c->processor_id & 0xff00) {
332 case PRID_IMP_R2000:
333 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000334 __cpu_name[cpu] = "R2000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000335 set_isa(c, MIPS_CPU_ISA_I);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100336 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500337 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700338 if (__cpu_has_fpu())
339 c->options |= MIPS_CPU_FPU;
340 c->tlbsize = 64;
341 break;
342 case PRID_IMP_R3000:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000343 if ((c->processor_id & 0xff) == PRID_REV_R3000A) {
344 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000346 __cpu_name[cpu] = "R3081";
347 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000349 __cpu_name[cpu] = "R3000A";
350 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000351 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700352 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000353 __cpu_name[cpu] = "R3000";
354 }
Steven J. Hilla96102b2012-12-07 04:31:36 +0000355 set_isa(c, MIPS_CPU_ISA_I);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100356 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500357 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 if (__cpu_has_fpu())
359 c->options |= MIPS_CPU_FPU;
360 c->tlbsize = 64;
361 break;
362 case PRID_IMP_R4000:
363 if (read_c0_config() & CONF_SC) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000364 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700365 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000366 __cpu_name[cpu] = "R4400PC";
367 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000369 __cpu_name[cpu] = "R4000PC";
370 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 } else {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000372 if ((c->processor_id & 0xff) >= PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373 c->cputype = CPU_R4400SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000374 __cpu_name[cpu] = "R4400SC";
375 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700376 c->cputype = CPU_R4000SC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000377 __cpu_name[cpu] = "R4000SC";
378 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700379 }
380
Steven J. Hilla96102b2012-12-07 04:31:36 +0000381 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700382 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500383 MIPS_CPU_WATCH | MIPS_CPU_VCE |
384 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385 c->tlbsize = 48;
386 break;
387 case PRID_IMP_VR41XX:
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900388 set_isa(c, MIPS_CPU_ISA_III);
389 c->options = R4K_OPTS;
390 c->tlbsize = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392 case PRID_REV_VR4111:
393 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000394 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700396 case PRID_REV_VR4121:
397 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000398 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 break;
400 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000401 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000403 __cpu_name[cpu] = "NEC VR4122";
404 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000406 __cpu_name[cpu] = "NEC VR4181A";
407 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 break;
409 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000410 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000412 __cpu_name[cpu] = "NEC VR4131";
413 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700414 c->cputype = CPU_VR4133;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900415 c->options |= MIPS_CPU_LLSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000416 __cpu_name[cpu] = "NEC VR4133";
417 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418 break;
419 default:
420 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
421 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000422 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423 break;
424 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 break;
426 case PRID_IMP_R4300:
427 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000428 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000429 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500431 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 c->tlbsize = 32;
433 break;
434 case PRID_IMP_R4600:
435 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000436 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000437 set_isa(c, MIPS_CPU_ISA_III);
Thiemo Seufer075e7502005-07-27 21:48:12 +0000438 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
439 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 c->tlbsize = 48;
441 break;
442 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500443 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 /*
445 * This processor doesn't have an MMU, so it's not
446 * "real easy" to run Linux on it. It is left purely
447 * for documentation. Commented out because it shares
448 * it's c0_prid id number with the TX3900.
449 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000450 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000451 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000452 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700453 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500454 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700455 break;
456 #endif
457 case PRID_IMP_TX39:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000458 set_isa(c, MIPS_CPU_ISA_I);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100459 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460
461 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
462 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000463 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 c->tlbsize = 64;
465 } else {
466 switch (c->processor_id & 0xff) {
467 case PRID_REV_TX3912:
468 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000469 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 c->tlbsize = 32;
471 break;
472 case PRID_REV_TX3922:
473 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000474 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 c->tlbsize = 64;
476 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 }
478 }
479 break;
480 case PRID_IMP_R4700:
481 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000482 __cpu_name[cpu] = "R4700";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000483 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500485 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486 c->tlbsize = 48;
487 break;
488 case PRID_IMP_TX49:
489 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000490 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000491 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492 c->options = R4K_OPTS | MIPS_CPU_LLSC;
493 if (!(c->processor_id & 0x08))
494 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
495 c->tlbsize = 48;
496 break;
497 case PRID_IMP_R5000:
498 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000499 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000500 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500502 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 c->tlbsize = 48;
504 break;
505 case PRID_IMP_R5432:
506 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000507 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000508 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500510 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511 c->tlbsize = 48;
512 break;
513 case PRID_IMP_R5500:
514 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000515 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000516 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500518 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 c->tlbsize = 48;
520 break;
521 case PRID_IMP_NEVADA:
522 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000523 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000524 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500526 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527 c->tlbsize = 48;
528 break;
529 case PRID_IMP_R6000:
530 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000531 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000532 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500534 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 c->tlbsize = 32;
536 break;
537 case PRID_IMP_R6000A:
538 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000539 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000540 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500542 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 c->tlbsize = 32;
544 break;
545 case PRID_IMP_RM7000:
546 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000547 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000548 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500550 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700551 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100552 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 * the RM7000 v2.0 indicates if the TLB has 48 or 64
554 * entries.
555 *
Ralf Baechle70342282013-01-22 12:59:30 +0100556 * 29 1 => 64 entry JTLB
557 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 */
559 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
560 break;
561 case PRID_IMP_RM9000:
562 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000563 __cpu_name[cpu] = "RM9000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000564 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500566 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 /*
568 * Bit 29 in the info register of the RM9000
569 * indicates if the TLB has 48 or 64 entries.
570 *
Ralf Baechle70342282013-01-22 12:59:30 +0100571 * 29 1 => 64 entry JTLB
572 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 */
574 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
575 break;
576 case PRID_IMP_R8000:
577 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000578 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000579 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500581 MIPS_CPU_FPU | MIPS_CPU_32FPR |
582 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700583 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
584 break;
585 case PRID_IMP_R10000:
586 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000587 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000588 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000589 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500590 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700591 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500592 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 c->tlbsize = 64;
594 break;
595 case PRID_IMP_R12000:
596 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000597 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000598 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000599 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500600 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500602 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 c->tlbsize = 64;
604 break;
Kumba44d921b2006-05-16 22:23:59 -0400605 case PRID_IMP_R14000:
606 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000607 __cpu_name[cpu] = "R14000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000608 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400609 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500610 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400611 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500612 MIPS_CPU_LLSC;
Kumba44d921b2006-05-16 22:23:59 -0400613 c->tlbsize = 64;
614 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800615 case PRID_IMP_LOONGSON2:
616 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000617 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700618
619 switch (c->processor_id & PRID_REV_MASK) {
620 case PRID_REV_LOONGSON2E:
621 set_elf_platform(cpu, "loongson2e");
622 break;
623 case PRID_REV_LOONGSON2F:
624 set_elf_platform(cpu, "loongson2f");
625 break;
626 }
627
Steven J. Hilla96102b2012-12-07 04:31:36 +0000628 set_isa(c, MIPS_CPU_ISA_III);
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800629 c->options = R4K_OPTS |
630 MIPS_CPU_FPU | MIPS_CPU_LLSC |
631 MIPS_CPU_32FPR;
632 c->tlbsize = 64;
633 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100634 case PRID_IMP_LOONGSON1:
635 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100637 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000638
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100639 switch (c->processor_id & PRID_REV_MASK) {
640 case PRID_REV_LOONGSON1B:
641 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +0000642 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000643 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100644
Ralf Baechle41943182005-05-05 16:45:59 +0000645 break;
Ralf Baechle41943182005-05-05 16:45:59 +0000646 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647}
648
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000649static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650{
Ralf Baechle41943182005-05-05 16:45:59 +0000651 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 switch (c->processor_id & 0xff00) {
653 case PRID_IMP_4KC:
654 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000655 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 break;
657 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000658 case PRID_IMP_4KECR2:
659 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000660 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000661 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100663 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000665 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 break;
667 case PRID_IMP_5KC:
668 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000669 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +0200671 case PRID_IMP_5KE:
672 c->cputype = CPU_5KE;
673 __cpu_name[cpu] = "MIPS 5KE";
674 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 case PRID_IMP_20KC:
676 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000677 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 break;
679 case PRID_IMP_24K:
680 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000681 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 break;
John Crispin42f3cae2013-01-11 22:44:10 +0100683 case PRID_IMP_24KE:
684 c->cputype = CPU_24K;
685 __cpu_name[cpu] = "MIPS 24KEc";
686 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 case PRID_IMP_25KF:
688 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000689 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000691 case PRID_IMP_34K:
692 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000693 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000694 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100695 case PRID_IMP_74K:
696 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000697 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100698 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +0200699 case PRID_IMP_M14KC:
700 c->cputype = CPU_M14KC;
701 __cpu_name[cpu] = "MIPS M14Kc";
702 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000703 case PRID_IMP_M14KEC:
704 c->cputype = CPU_M14KEC;
705 __cpu_name[cpu] = "MIPS M14KEc";
706 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100707 case PRID_IMP_1004K:
708 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000709 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100710 break;
Steven J. Hill006a8512012-06-26 04:11:03 +0000711 case PRID_IMP_1074K:
712 c->cputype = CPU_74K;
713 __cpu_name[cpu] = "MIPS 1074Kc";
714 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700715 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100716
717 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718}
719
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000720static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721{
Ralf Baechle41943182005-05-05 16:45:59 +0000722 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 switch (c->processor_id & 0xff00) {
724 case PRID_IMP_AU1_REV1:
725 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100726 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 switch ((c->processor_id >> 24) & 0xff) {
728 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000729 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 break;
731 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000732 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 break;
734 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000735 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 break;
737 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000738 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000740 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000741 __cpu_name[cpu] = "Au1200";
Manuel Lauss270717a2009-03-25 17:49:28 +0100742 if ((c->processor_id & 0xff) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000743 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100744 break;
745 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000746 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000747 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100749 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 break;
751 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700752 break;
753 }
754}
755
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000756static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757{
Ralf Baechle41943182005-05-05 16:45:59 +0000758 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100759
Linus Torvalds1da177e2005-04-16 15:20:36 -0700760 switch (c->processor_id & 0xff00) {
761 case PRID_IMP_SB1:
762 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000763 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 /* FPU in pass1 is known to have issues. */
Ralf Baechleaa323742006-05-29 00:02:12 +0100765 if ((c->processor_id & 0xff) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000766 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700768 case PRID_IMP_SB1A:
769 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000770 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700771 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 }
773}
774
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000775static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776{
Ralf Baechle41943182005-05-05 16:45:59 +0000777 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 switch (c->processor_id & 0xff00) {
779 case PRID_IMP_SR71000:
780 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000781 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 c->scache.ways = 8;
783 c->tlbsize = 64;
784 break;
785 }
786}
787
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000788static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000789{
790 decode_configs(c);
791 switch (c->processor_id & 0xff00) {
792 case PRID_IMP_PR4450:
793 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000794 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000795 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +0000796 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000797 }
798}
799
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000800static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200801{
802 decode_configs(c);
803 switch (c->processor_id & 0xff00) {
Kevin Cernekee190fca32010-11-23 10:26:45 -0800804 case PRID_IMP_BMIPS32_REV4:
805 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -0700806 c->cputype = CPU_BMIPS32;
807 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700808 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200809 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700810 case PRID_IMP_BMIPS3300:
811 case PRID_IMP_BMIPS3300_ALT:
812 case PRID_IMP_BMIPS3300_BUG:
813 c->cputype = CPU_BMIPS3300;
814 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700815 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200816 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700817 case PRID_IMP_BMIPS43XX: {
818 int rev = c->processor_id & 0xff;
819
820 if (rev >= PRID_REV_BMIPS4380_LO &&
821 rev <= PRID_REV_BMIPS4380_HI) {
822 c->cputype = CPU_BMIPS4380;
823 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700824 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700825 } else {
826 c->cputype = CPU_BMIPS4350;
827 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700828 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +0100829 }
830 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200831 }
Kevin Cernekee602977b2010-10-16 14:22:30 -0700832 case PRID_IMP_BMIPS5000:
833 c->cputype = CPU_BMIPS5000;
834 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700835 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700836 c->options |= MIPS_CPU_ULRI;
837 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700838 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200839}
840
David Daney0dd47812008-12-11 15:33:26 -0800841static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
842{
843 decode_configs(c);
844 switch (c->processor_id & 0xff00) {
845 case PRID_IMP_CAVIUM_CN38XX:
846 case PRID_IMP_CAVIUM_CN31XX:
847 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -0800848 c->cputype = CPU_CAVIUM_OCTEON;
849 __cpu_name[cpu] = "Cavium Octeon";
850 goto platform;
David Daney0dd47812008-12-11 15:33:26 -0800851 case PRID_IMP_CAVIUM_CN58XX:
852 case PRID_IMP_CAVIUM_CN56XX:
853 case PRID_IMP_CAVIUM_CN50XX:
854 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -0800855 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
856 __cpu_name[cpu] = "Cavium Octeon+";
857platform:
Robert Millanc094c992011-04-18 11:37:55 -0700858 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -0800859 break;
David Daneya1431b62011-09-24 02:29:54 +0200860 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -0700861 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +0200862 case PRID_IMP_CAVIUM_CN66XX:
863 case PRID_IMP_CAVIUM_CN68XX:
David Daney0e56b382010-10-07 16:03:45 -0700864 c->cputype = CPU_CAVIUM_OCTEON2;
865 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -0700866 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -0700867 break;
David Daney0dd47812008-12-11 15:33:26 -0800868 default:
869 printk(KERN_INFO "Unknown Octeon chip!\n");
870 c->cputype = CPU_UNKNOWN;
871 break;
872 }
873}
874
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +0000875static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
876{
877 decode_configs(c);
878 /* JZRISC does not implement the CP0 counter. */
879 c->options &= ~MIPS_CPU_COUNTER;
880 switch (c->processor_id & 0xff00) {
881 case PRID_IMP_JZRISC:
882 c->cputype = CPU_JZRISC;
883 __cpu_name[cpu] = "Ingenic JZRISC";
884 break;
885 default:
886 panic("Unknown Ingenic Processor ID!");
887 break;
888 }
889}
890
Jayachandran Ca7117c62011-05-11 12:04:58 +0530891static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
892{
893 decode_configs(c);
894
Manuel Lauss809f36c2011-11-01 20:03:30 +0100895 if ((c->processor_id & 0xff00) == PRID_IMP_NETLOGIC_AU13XX) {
896 c->cputype = CPU_ALCHEMY;
897 __cpu_name[cpu] = "Au1300";
898 /* following stuff is not for Alchemy */
899 return;
900 }
901
Ralf Baechle70342282013-01-22 12:59:30 +0100902 c->options = (MIPS_CPU_TLB |
903 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +0530904 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +0100905 MIPS_CPU_DIVEC |
906 MIPS_CPU_WATCH |
907 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +0530908 MIPS_CPU_LLSC);
909
910 switch (c->processor_id & 0xff00) {
Jayachandran C2aa54b22011-11-16 00:21:29 +0000911 case PRID_IMP_NETLOGIC_XLP8XX:
912 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +0000913 c->cputype = CPU_XLP;
914 __cpu_name[cpu] = "Netlogic XLP";
915 break;
916
Jayachandran Ca7117c62011-05-11 12:04:58 +0530917 case PRID_IMP_NETLOGIC_XLR732:
918 case PRID_IMP_NETLOGIC_XLR716:
919 case PRID_IMP_NETLOGIC_XLR532:
920 case PRID_IMP_NETLOGIC_XLR308:
921 case PRID_IMP_NETLOGIC_XLR532C:
922 case PRID_IMP_NETLOGIC_XLR516C:
923 case PRID_IMP_NETLOGIC_XLR508C:
924 case PRID_IMP_NETLOGIC_XLR308C:
925 c->cputype = CPU_XLR;
926 __cpu_name[cpu] = "Netlogic XLR";
927 break;
928
929 case PRID_IMP_NETLOGIC_XLS608:
930 case PRID_IMP_NETLOGIC_XLS408:
931 case PRID_IMP_NETLOGIC_XLS404:
932 case PRID_IMP_NETLOGIC_XLS208:
933 case PRID_IMP_NETLOGIC_XLS204:
934 case PRID_IMP_NETLOGIC_XLS108:
935 case PRID_IMP_NETLOGIC_XLS104:
936 case PRID_IMP_NETLOGIC_XLS616B:
937 case PRID_IMP_NETLOGIC_XLS608B:
938 case PRID_IMP_NETLOGIC_XLS416B:
939 case PRID_IMP_NETLOGIC_XLS412B:
940 case PRID_IMP_NETLOGIC_XLS408B:
941 case PRID_IMP_NETLOGIC_XLS404B:
942 c->cputype = CPU_XLR;
943 __cpu_name[cpu] = "Netlogic XLS";
944 break;
945
946 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +0000947 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +0530948 c->processor_id);
949 c->cputype = CPU_XLR;
950 break;
951 }
952
Jayachandran Ca3d4fb22011-11-16 00:21:20 +0000953 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +0000954 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +0000955 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
956 /* This will be updated again after all threads are woken up */
957 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
958 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +0000959 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +0000960 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
961 }
Jayachandran C7777b932013-06-11 14:41:35 +0000962 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +0530963}
964
David Daney949e51b2010-10-14 11:32:33 -0700965#ifdef CONFIG_64BIT
966/* For use by uaccess.h */
967u64 __ua_limit;
968EXPORT_SYMBOL(__ua_limit);
969#endif
970
Ralf Baechle9966db252007-10-11 23:46:17 +0100971const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -0800972const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +0100973
Ralf Baechle234fcd12008-03-08 09:56:28 +0000974__cpuinit void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975{
976 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +0100977 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700978
Ralf Baechle70342282013-01-22 12:59:30 +0100979 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700980 c->fpu_id = FPIR_IMP_NONE;
981 c->cputype = CPU_UNKNOWN;
982
983 c->processor_id = read_c0_prid();
984 switch (c->processor_id & 0xff0000) {
985 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000986 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987 break;
988 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000989 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990 break;
991 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000992 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993 break;
994 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000995 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700996 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200997 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000998 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200999 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001001 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001002 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001003 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001004 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001005 break;
David Daney0dd47812008-12-11 15:33:26 -08001006 case PRID_COMP_CAVIUM:
1007 cpu_probe_cavium(c, cpu);
1008 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001009 case PRID_COMP_INGENIC:
1010 cpu_probe_ingenic(c, cpu);
1011 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301012 case PRID_COMP_NETLOGIC:
1013 cpu_probe_netlogic(c, cpu);
1014 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001015 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001016
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001017 BUG_ON(!__cpu_name[cpu]);
1018 BUG_ON(c->cputype == CPU_UNKNOWN);
1019
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001020 /*
1021 * Platform code can force the cpu type to optimize code
1022 * generation. In that case be sure the cpu type is correctly
1023 * manually setup otherwise it could trigger some nasty bugs.
1024 */
1025 BUG_ON(current_cpu_type() != c->cputype);
1026
Kevin Cernekee0103d232010-05-02 14:43:52 -07001027 if (mips_fpu_disabled)
1028 c->options &= ~MIPS_CPU_FPU;
1029
1030 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001031 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001032
Ralf Baechle41943182005-05-05 16:45:59 +00001033 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001035
Deng-Cheng Zhuadb37892013-04-01 18:14:28 +00001036 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 |
1037 MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)) {
Ralf Baechle41943182005-05-05 16:45:59 +00001038 if (c->fpu_id & MIPS_FPIR_3D)
1039 c->ases |= MIPS_ASE_MIPS3D;
1040 }
1041 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001042
Al Cooperda4b62c2012-07-13 16:44:51 -04001043 if (cpu_has_mips_r2) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001044 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001045 /* R2 has Performance Counter Interrupt indicator */
1046 c->options |= MIPS_CPU_PCI;
1047 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001048 else
1049 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001050
1051 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001052
1053#ifdef CONFIG_64BIT
1054 if (cpu == 0)
1055 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1056#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001057}
1058
Ralf Baechle234fcd12008-03-08 09:56:28 +00001059__cpuinit void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001060{
1061 struct cpuinfo_mips *c = &current_cpu_data;
1062
Ralf Baechle9966db252007-10-11 23:46:17 +01001063 printk(KERN_INFO "CPU revision is: %08x (%s)\n",
1064 c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001066 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067}