blob: f89eaa79785a6b55fdda93afffb150d248f1d483 [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>
Maciej W. Rozyckif6843622015-04-03 23:27:26 +010023#include <asm/cpu-features.h>
Ralf Baechle69f24d12013-09-17 10:25:47 +020024#include <asm/cpu-type.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <asm/fpu.h>
26#include <asm/mipsregs.h>
Paul Burton30ee6152014-03-27 10:57:30 +000027#include <asm/mipsmtregs.h>
Paul Burtona5e9a692014-01-27 15:23:10 +000028#include <asm/msa.h>
David Daney654f57b2008-09-23 00:07:16 -070029#include <asm/watch.h>
Paul Gortmaker06372a62011-07-23 16:26:41 -040030#include <asm/elf.h>
Markos Chandras4f12b912014-07-18 10:51:32 +010031#include <asm/pgtable-bits.h>
Chris Dearmana074f0e2009-07-10 01:51:27 -070032#include <asm/spram.h>
David Daney949e51b2010-10-14 11:32:33 -070033#include <asm/uaccess.h>
34
Maciej W. Rozyckif6843622015-04-03 23:27:26 +010035/*
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +010036 * Get the FPU Implementation/Revision.
37 */
38static inline unsigned long cpu_get_fpu_id(void)
39{
40 unsigned long tmp, fpu_id;
41
42 tmp = read_c0_status();
43 __enable_fpu(FPU_AS_IS);
44 fpu_id = read_32bit_cp1_register(CP1_REVISION);
45 write_c0_status(tmp);
46 return fpu_id;
47}
48
49/*
50 * Check if the CPU has an external FPU.
51 */
52static inline int __cpu_has_fpu(void)
53{
54 return (cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE;
55}
56
57static inline unsigned long cpu_get_msa_id(void)
58{
59 unsigned long status, msa_id;
60
61 status = read_c0_status();
62 __enable_fpu(FPU_64BIT);
63 enable_msa();
64 msa_id = read_msa_ir();
65 disable_msa();
66 write_c0_status(status);
67 return msa_id;
68}
69
70/*
Maciej W. Rozycki9b266162015-04-03 23:27:48 +010071 * Determine the FCSR mask for FPU hardware.
72 */
73static inline void cpu_set_fpu_fcsr_mask(struct cpuinfo_mips *c)
74{
75 unsigned long sr, mask, fcsr, fcsr0, fcsr1;
76
Maciej W. Rozycki90b712d2015-06-02 17:50:59 +010077 fcsr = c->fpu_csr31;
Maciej W. Rozycki9b266162015-04-03 23:27:48 +010078 mask = FPU_CSR_ALL_X | FPU_CSR_ALL_E | FPU_CSR_ALL_S | FPU_CSR_RM;
79
80 sr = read_c0_status();
81 __enable_fpu(FPU_AS_IS);
82
Maciej W. Rozycki9b266162015-04-03 23:27:48 +010083 fcsr0 = fcsr & mask;
84 write_32bit_cp1_register(CP1_STATUS, fcsr0);
85 fcsr0 = read_32bit_cp1_register(CP1_STATUS);
86
87 fcsr1 = fcsr | ~mask;
88 write_32bit_cp1_register(CP1_STATUS, fcsr1);
89 fcsr1 = read_32bit_cp1_register(CP1_STATUS);
90
91 write_32bit_cp1_register(CP1_STATUS, fcsr);
92
93 write_c0_status(sr);
94
95 c->fpu_msk31 = ~(fcsr0 ^ fcsr1) & ~mask;
96}
97
98/*
Maciej W. Rozyckif6843622015-04-03 23:27:26 +010099 * Set the FIR feature flags for the FPU emulator.
100 */
101static void cpu_set_nofpu_id(struct cpuinfo_mips *c)
102{
103 u32 value;
104
105 value = 0;
106 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
107 MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
108 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6))
109 value |= MIPS_FPIR_D | MIPS_FPIR_S;
110 if (c->isa_level & (MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
111 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6))
112 value |= MIPS_FPIR_F64 | MIPS_FPIR_L | MIPS_FPIR_W;
113 c->fpu_id = value;
114}
115
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100116/* Determined FPU emulator mask to use for the boot CPU with "nofpu". */
117static unsigned int mips_nofpu_msk31;
118
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +0100119/*
120 * Set options for FPU hardware.
121 */
122static void cpu_set_fpu_opts(struct cpuinfo_mips *c)
123{
124 c->fpu_id = cpu_get_fpu_id();
125 mips_nofpu_msk31 = c->fpu_msk31;
126
127 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
128 MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
129 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
130 if (c->fpu_id & MIPS_FPIR_3D)
131 c->ases |= MIPS_ASE_MIPS3D;
132 if (c->fpu_id & MIPS_FPIR_FREP)
133 c->options |= MIPS_CPU_FRE;
134 }
135
136 cpu_set_fpu_fcsr_mask(c);
137}
138
139/*
140 * Set options for the FPU emulator.
141 */
142static void cpu_set_nofpu_opts(struct cpuinfo_mips *c)
143{
144 c->options &= ~MIPS_CPU_FPU;
145 c->fpu_msk31 = mips_nofpu_msk31;
146
147 cpu_set_nofpu_id(c);
148}
149
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000150static int mips_fpu_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -0700151
152static int __init fpu_disable(char *s)
153{
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +0100154 cpu_set_nofpu_opts(&boot_cpu_data);
Kevin Cernekee0103d232010-05-02 14:43:52 -0700155 mips_fpu_disabled = 1;
156
157 return 1;
158}
159
160__setup("nofpu", fpu_disable);
161
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000162int mips_dsp_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -0700163
164static int __init dsp_disable(char *s)
165{
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500166 cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -0700167 mips_dsp_disabled = 1;
168
169 return 1;
170}
171
172__setup("nodsp", dsp_disable);
173
Markos Chandras3d528b32014-07-14 12:46:13 +0100174static int mips_htw_disabled;
175
176static int __init htw_disable(char *s)
177{
178 mips_htw_disabled = 1;
179 cpu_data[0].options &= ~MIPS_CPU_HTW;
180 write_c0_pwctl(read_c0_pwctl() &
181 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
182
183 return 1;
184}
185
186__setup("nohtw", htw_disable);
187
Markos Chandras97f4ad22014-08-29 09:37:26 +0100188static int mips_ftlb_disabled;
189static int mips_has_ftlb_configured;
190
191static void set_ftlb_enable(struct cpuinfo_mips *c, int enable);
192
193static int __init ftlb_disable(char *s)
194{
195 unsigned int config4, mmuextdef;
196
197 /*
198 * If the core hasn't done any FTLB configuration, there is nothing
199 * for us to do here.
200 */
201 if (!mips_has_ftlb_configured)
202 return 1;
203
204 /* Disable it in the boot cpu */
205 set_ftlb_enable(&cpu_data[0], 0);
206
207 back_to_back_c0_hazard();
208
209 config4 = read_c0_config4();
210
211 /* Check that FTLB has been disabled */
212 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
213 /* MMUSIZEEXT == VTLB ON, FTLB OFF */
214 if (mmuextdef == MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT) {
215 /* This should never happen */
216 pr_warn("FTLB could not be disabled!\n");
217 return 1;
218 }
219
220 mips_ftlb_disabled = 1;
221 mips_has_ftlb_configured = 0;
222
223 /*
224 * noftlb is mainly used for debug purposes so print
225 * an informative message instead of using pr_debug()
226 */
227 pr_info("FTLB has been disabled\n");
228
229 /*
230 * Some of these bits are duplicated in the decode_config4.
231 * MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT is the only possible case
232 * once FTLB has been disabled so undo what decode_config4 did.
233 */
234 cpu_data[0].tlbsize -= cpu_data[0].tlbsizeftlbways *
235 cpu_data[0].tlbsizeftlbsets;
236 cpu_data[0].tlbsizeftlbsets = 0;
237 cpu_data[0].tlbsizeftlbways = 0;
238
239 return 1;
240}
241
242__setup("noftlb", ftlb_disable);
243
244
Marc St-Jean9267a302007-06-14 15:55:31 -0600245static inline void check_errata(void)
246{
247 struct cpuinfo_mips *c = &current_cpu_data;
248
Ralf Baechle69f24d12013-09-17 10:25:47 +0200249 switch (current_cpu_type()) {
Marc St-Jean9267a302007-06-14 15:55:31 -0600250 case CPU_34K:
251 /*
252 * Erratum "RPS May Cause Incorrect Instruction Execution"
Ralf Baechleb633648c52014-05-23 16:29:44 +0200253 * This code only handles VPE0, any SMP/RTOS code
Marc St-Jean9267a302007-06-14 15:55:31 -0600254 * making use of VPE1 will be responsable for that VPE.
255 */
256 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
257 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
258 break;
259 default:
260 break;
261 }
262}
263
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264void __init check_bugs32(void)
265{
Marc St-Jean9267a302007-06-14 15:55:31 -0600266 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267}
268
269/*
270 * Probe whether cpu has config register by trying to play with
271 * alternate cache bit and see whether it matters.
272 * It's used by cpu_probe to distinguish between R3000A and R3081.
273 */
274static inline int cpu_has_confreg(void)
275{
276#ifdef CONFIG_CPU_R3000
277 extern unsigned long r3k_cache_size(unsigned long);
278 unsigned long size1, size2;
279 unsigned long cfg = read_c0_conf();
280
281 size1 = r3k_cache_size(ST0_ISC);
282 write_c0_conf(cfg ^ R30XX_CONF_AC);
283 size2 = r3k_cache_size(ST0_ISC);
284 write_c0_conf(cfg);
285 return size1 != size2;
286#else
287 return 0;
288#endif
289}
290
Robert Millanc094c992011-04-18 11:37:55 -0700291static inline void set_elf_platform(int cpu, const char *plat)
292{
293 if (cpu == 0)
294 __elf_platform = plat;
295}
296
Guenter Roeck91dfc422010-02-02 08:52:20 -0800297static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
298{
299#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800300 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800301 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800302 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800303#endif
304}
305
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000306static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
Steven J. Hilla96102b2012-12-07 04:31:36 +0000307{
308 switch (isa) {
309 case MIPS_CPU_ISA_M64R2:
310 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
311 case MIPS_CPU_ISA_M64R1:
312 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
313 case MIPS_CPU_ISA_V:
314 c->isa_level |= MIPS_CPU_ISA_V;
315 case MIPS_CPU_ISA_IV:
316 c->isa_level |= MIPS_CPU_ISA_IV;
317 case MIPS_CPU_ISA_III:
Ralf Baechle1990e542013-06-26 17:06:34 +0200318 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000319 break;
320
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000321 /* R6 incompatible with everything else */
322 case MIPS_CPU_ISA_M64R6:
323 c->isa_level |= MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6;
324 case MIPS_CPU_ISA_M32R6:
325 c->isa_level |= MIPS_CPU_ISA_M32R6;
326 /* Break here so we don't add incompatible ISAs */
327 break;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000328 case MIPS_CPU_ISA_M32R2:
329 c->isa_level |= MIPS_CPU_ISA_M32R2;
330 case MIPS_CPU_ISA_M32R1:
331 c->isa_level |= MIPS_CPU_ISA_M32R1;
332 case MIPS_CPU_ISA_II:
333 c->isa_level |= MIPS_CPU_ISA_II;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000334 break;
335 }
336}
337
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000338static char unknown_isa[] = KERN_ERR \
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100339 "Unsupported ISA type, c0.config0: %d.";
340
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000341static unsigned int calculate_ftlb_probability(struct cpuinfo_mips *c)
342{
343
344 unsigned int probability = c->tlbsize / c->tlbsizevtlb;
345
346 /*
347 * 0 = All TLBWR instructions go to FTLB
348 * 1 = 15:1: For every 16 TBLWR instructions, 15 go to the
349 * FTLB and 1 goes to the VTLB.
350 * 2 = 7:1: As above with 7:1 ratio.
351 * 3 = 3:1: As above with 3:1 ratio.
352 *
353 * Use the linear midpoint as the probability threshold.
354 */
355 if (probability >= 12)
356 return 1;
357 else if (probability >= 6)
358 return 2;
359 else
360 /*
361 * So FTLB is less than 4 times bigger than VTLB.
362 * A 3:1 ratio can still be useful though.
363 */
364 return 3;
365}
366
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000367static void set_ftlb_enable(struct cpuinfo_mips *c, int enable)
368{
369 unsigned int config6;
James Hogand83b0e82014-01-22 16:19:40 +0000370
371 /* It's implementation dependent how the FTLB can be enabled */
372 switch (c->cputype) {
373 case CPU_PROAPTIV:
374 case CPU_P5600:
375 /* proAptiv & related cores use Config6 to enable the FTLB */
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000376 config6 = read_c0_config6();
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000377 /* Clear the old probability value */
378 config6 &= ~(3 << MIPS_CONF6_FTLBP_SHIFT);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000379 if (enable)
380 /* Enable FTLB */
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000381 write_c0_config6(config6 |
382 (calculate_ftlb_probability(c)
383 << MIPS_CONF6_FTLBP_SHIFT)
384 | MIPS_CONF6_FTLBEN);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000385 else
386 /* Disable FTLB */
387 write_c0_config6(config6 & ~MIPS_CONF6_FTLBEN);
388 back_to_back_c0_hazard();
James Hogand83b0e82014-01-22 16:19:40 +0000389 break;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000390 }
391}
392
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100393static inline unsigned int decode_config0(struct cpuinfo_mips *c)
394{
395 unsigned int config0;
396 int isa;
397
398 config0 = read_c0_config();
399
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000400 /*
401 * Look for Standard TLB or Dual VTLB and FTLB
402 */
403 if ((((config0 & MIPS_CONF_MT) >> 7) == 1) ||
404 (((config0 & MIPS_CONF_MT) >> 7) == 4))
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100405 c->options |= MIPS_CPU_TLB;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000406
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100407 isa = (config0 & MIPS_CONF_AT) >> 13;
408 switch (isa) {
409 case 0:
410 switch ((config0 & MIPS_CONF_AR) >> 10) {
411 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000412 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100413 break;
414 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000415 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100416 break;
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000417 case 2:
418 set_isa(c, MIPS_CPU_ISA_M32R6);
419 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100420 default:
421 goto unknown;
422 }
423 break;
424 case 2:
425 switch ((config0 & MIPS_CONF_AR) >> 10) {
426 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000427 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100428 break;
429 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000430 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100431 break;
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000432 case 2:
433 set_isa(c, MIPS_CPU_ISA_M64R6);
434 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100435 default:
436 goto unknown;
437 }
438 break;
439 default:
440 goto unknown;
441 }
442
443 return config0 & MIPS_CONF_M;
444
445unknown:
446 panic(unknown_isa, config0);
447}
448
449static inline unsigned int decode_config1(struct cpuinfo_mips *c)
450{
451 unsigned int config1;
452
453 config1 = read_c0_config1();
454
455 if (config1 & MIPS_CONF1_MD)
456 c->ases |= MIPS_ASE_MDMX;
457 if (config1 & MIPS_CONF1_WR)
458 c->options |= MIPS_CPU_WATCH;
459 if (config1 & MIPS_CONF1_CA)
460 c->ases |= MIPS_ASE_MIPS16;
461 if (config1 & MIPS_CONF1_EP)
462 c->options |= MIPS_CPU_EJTAG;
463 if (config1 & MIPS_CONF1_FP) {
464 c->options |= MIPS_CPU_FPU;
465 c->options |= MIPS_CPU_32FPR;
466 }
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000467 if (cpu_has_tlb) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100468 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000469 c->tlbsizevtlb = c->tlbsize;
470 c->tlbsizeftlbsets = 0;
471 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100472
473 return config1 & MIPS_CONF_M;
474}
475
476static inline unsigned int decode_config2(struct cpuinfo_mips *c)
477{
478 unsigned int config2;
479
480 config2 = read_c0_config2();
481
482 if (config2 & MIPS_CONF2_SL)
483 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
484
485 return config2 & MIPS_CONF_M;
486}
487
488static inline unsigned int decode_config3(struct cpuinfo_mips *c)
489{
490 unsigned int config3;
491
492 config3 = read_c0_config3();
493
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500494 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100495 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500496 c->options |= MIPS_CPU_RIXI;
497 }
498 if (config3 & MIPS_CONF3_RXI)
499 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100500 if (config3 & MIPS_CONF3_DSP)
501 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500502 if (config3 & MIPS_CONF3_DSP2P)
503 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100504 if (config3 & MIPS_CONF3_VINT)
505 c->options |= MIPS_CPU_VINT;
506 if (config3 & MIPS_CONF3_VEIC)
507 c->options |= MIPS_CPU_VEIC;
508 if (config3 & MIPS_CONF3_MT)
509 c->ases |= MIPS_ASE_MIPSMT;
510 if (config3 & MIPS_CONF3_ULRI)
511 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000512 if (config3 & MIPS_CONF3_ISA)
513 c->options |= MIPS_CPU_MICROMIPS;
David Daney1e7decd2013-02-16 23:42:43 +0100514 if (config3 & MIPS_CONF3_VZ)
515 c->ases |= MIPS_ASE_VZ;
Steven J. Hill4a0156f2013-11-14 16:12:24 +0000516 if (config3 & MIPS_CONF3_SC)
517 c->options |= MIPS_CPU_SEGMENTS;
Paul Burtona5e9a692014-01-27 15:23:10 +0000518 if (config3 & MIPS_CONF3_MSA)
519 c->ases |= MIPS_ASE_MSA;
Markos Chandras3d528b32014-07-14 12:46:13 +0100520 /* Only tested on 32-bit cores */
Markos Chandrased4cbc82015-01-26 13:04:33 +0000521 if ((config3 & MIPS_CONF3_PW) && config_enabled(CONFIG_32BIT)) {
522 c->htw_seq = 0;
Markos Chandras3d528b32014-07-14 12:46:13 +0100523 c->options |= MIPS_CPU_HTW;
Markos Chandrased4cbc82015-01-26 13:04:33 +0000524 }
James Hogan9b3274b2015-02-02 11:45:08 +0000525 if (config3 & MIPS_CONF3_CDMM)
526 c->options |= MIPS_CPU_CDMM;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100527
528 return config3 & MIPS_CONF_M;
529}
530
531static inline unsigned int decode_config4(struct cpuinfo_mips *c)
532{
533 unsigned int config4;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000534 unsigned int newcf4;
535 unsigned int mmuextdef;
536 unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100537
538 config4 = read_c0_config4();
539
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000540 if (cpu_has_tlb) {
541 if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
542 c->options |= MIPS_CPU_TLBINV;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000543 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
544 switch (mmuextdef) {
545 case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:
546 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
547 c->tlbsizevtlb = c->tlbsize;
548 break;
549 case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT:
550 c->tlbsizevtlb +=
551 ((config4 & MIPS_CONF4_VTLBSIZEEXT) >>
552 MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40;
553 c->tlbsize = c->tlbsizevtlb;
554 ftlb_page = MIPS_CONF4_VFTLBPAGESIZE;
555 /* fall through */
556 case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT:
Markos Chandras97f4ad22014-08-29 09:37:26 +0100557 if (mips_ftlb_disabled)
558 break;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000559 newcf4 = (config4 & ~ftlb_page) |
560 (page_size_ftlb(mmuextdef) <<
561 MIPS_CONF4_FTLBPAGESIZE_SHIFT);
562 write_c0_config4(newcf4);
563 back_to_back_c0_hazard();
564 config4 = read_c0_config4();
565 if (config4 != newcf4) {
566 pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
567 PAGE_SIZE, config4);
568 /* Switch FTLB off */
569 set_ftlb_enable(c, 0);
570 break;
571 }
572 c->tlbsizeftlbsets = 1 <<
573 ((config4 & MIPS_CONF4_FTLBSETS) >>
574 MIPS_CONF4_FTLBSETS_SHIFT);
575 c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >>
576 MIPS_CONF4_FTLBWAYS_SHIFT) + 2;
577 c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets;
Markos Chandras97f4ad22014-08-29 09:37:26 +0100578 mips_has_ftlb_configured = 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000579 break;
580 }
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000581 }
582
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100583 c->kscratch_mask = (config4 >> 16) & 0xff;
584
585 return config4 & MIPS_CONF_M;
586}
587
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200588static inline unsigned int decode_config5(struct cpuinfo_mips *c)
589{
590 unsigned int config5;
591
592 config5 = read_c0_config5();
Paul Burtond175ed22014-09-11 08:30:19 +0100593 config5 &= ~(MIPS_CONF5_UFR | MIPS_CONF5_UFE);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200594 write_c0_config5(config5);
595
Markos Chandras49016742014-01-09 16:04:51 +0000596 if (config5 & MIPS_CONF5_EVA)
597 c->options |= MIPS_CPU_EVA;
Paul Burton1f6c52f2014-07-14 10:32:14 +0100598 if (config5 & MIPS_CONF5_MRP)
599 c->options |= MIPS_CPU_MAAR;
Markos Chandras5aed9da2014-12-02 09:46:19 +0000600 if (config5 & MIPS_CONF5_LLB)
601 c->options |= MIPS_CPU_RW_LLB;
Steven J. Hillc5b36782015-02-26 18:16:38 -0600602#ifdef CONFIG_XPA
603 if (config5 & MIPS_CONF5_MVH)
604 c->options |= MIPS_CPU_XPA;
605#endif
Markos Chandras49016742014-01-09 16:04:51 +0000606
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200607 return config5 & MIPS_CONF_M;
608}
609
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000610static void decode_configs(struct cpuinfo_mips *c)
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100611{
612 int ok;
613
614 /* MIPS32 or MIPS64 compliant CPU. */
615 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
616 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
617
618 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
619
Markos Chandras97f4ad22014-08-29 09:37:26 +0100620 /* Enable FTLB if present and not disabled */
621 set_ftlb_enable(c, !mips_ftlb_disabled);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000622
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100623 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100624 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100625 if (ok)
626 ok = decode_config1(c);
627 if (ok)
628 ok = decode_config2(c);
629 if (ok)
630 ok = decode_config3(c);
631 if (ok)
632 ok = decode_config4(c);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200633 if (ok)
634 ok = decode_config5(c);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100635
636 mips_probe_watch_registers(c);
637
Leonid Yegoshin6575b1d2014-07-15 14:09:57 +0100638 if (cpu_has_rixi) {
639 /* Enable the RIXI exceptions */
Steven J. Hilla5770df2015-02-19 10:18:52 -0600640 set_c0_pagegrain(PG_IEC);
Leonid Yegoshin6575b1d2014-07-15 14:09:57 +0100641 back_to_back_c0_hazard();
642 /* Verify the IEC bit is set */
643 if (read_c0_pagegrain() & PG_IEC)
644 c->options |= MIPS_CPU_RIXIEX;
645 }
646
Paul Burton0ee958e2014-01-15 10:31:53 +0000647#ifndef CONFIG_MIPS_CPS
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000648 if (cpu_has_mips_r2_r6) {
David Daney45b585c2014-05-28 23:52:10 +0200649 c->core = get_ebase_cpunum();
Paul Burton30ee6152014-03-27 10:57:30 +0000650 if (cpu_has_mipsmt)
651 c->core >>= fls(core_nvpes()) - 1;
652 }
Paul Burton0ee958e2014-01-15 10:31:53 +0000653#endif
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100654}
655
Ralf Baechle02cf2112005-10-01 13:06:32 +0100656#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 | MIPS_CPU_COUNTER)
658
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000659static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100661 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 case PRID_IMP_R2000:
663 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000664 __cpu_name[cpu] = "R2000";
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100665 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100666 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500667 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 if (__cpu_has_fpu())
669 c->options |= MIPS_CPU_FPU;
670 c->tlbsize = 64;
671 break;
672 case PRID_IMP_R3000:
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100673 if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000674 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000676 __cpu_name[cpu] = "R3081";
677 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000679 __cpu_name[cpu] = "R3000A";
680 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000681 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000683 __cpu_name[cpu] = "R3000";
684 }
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100685 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100686 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500687 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 if (__cpu_has_fpu())
689 c->options |= MIPS_CPU_FPU;
690 c->tlbsize = 64;
691 break;
692 case PRID_IMP_R4000:
693 if (read_c0_config() & CONF_SC) {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100694 if ((c->processor_id & PRID_REV_MASK) >=
695 PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000697 __cpu_name[cpu] = "R4400PC";
698 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000700 __cpu_name[cpu] = "R4000PC";
701 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100703 int cca = read_c0_config() & CONF_CM_CMASK;
704 int mc;
705
706 /*
707 * SC and MC versions can't be reliably told apart,
708 * but only the latter support coherent caching
709 * modes so assume the firmware has set the KSEG0
710 * coherency attribute reasonably (if uncached, we
711 * assume SC).
712 */
713 switch (cca) {
714 case CONF_CM_CACHABLE_CE:
715 case CONF_CM_CACHABLE_COW:
716 case CONF_CM_CACHABLE_CUW:
717 mc = 1;
718 break;
719 default:
720 mc = 0;
721 break;
722 }
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100723 if ((c->processor_id & PRID_REV_MASK) >=
724 PRID_REV_R4400) {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100725 c->cputype = mc ? CPU_R4400MC : CPU_R4400SC;
726 __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000727 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100728 c->cputype = mc ? CPU_R4000MC : CPU_R4000SC;
729 __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000730 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 }
732
Steven J. Hilla96102b2012-12-07 04:31:36 +0000733 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100734 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500736 MIPS_CPU_WATCH | MIPS_CPU_VCE |
737 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 c->tlbsize = 48;
739 break;
740 case PRID_IMP_VR41XX:
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900741 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100742 c->fpu_msk31 |= FPU_CSR_CONDX;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900743 c->options = R4K_OPTS;
744 c->tlbsize = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700746 case PRID_REV_VR4111:
747 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000748 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 case PRID_REV_VR4121:
751 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000752 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 break;
754 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000755 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000757 __cpu_name[cpu] = "NEC VR4122";
758 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000760 __cpu_name[cpu] = "NEC VR4181A";
761 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 break;
763 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000764 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000766 __cpu_name[cpu] = "NEC VR4131";
767 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 c->cputype = CPU_VR4133;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900769 c->options |= MIPS_CPU_LLSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000770 __cpu_name[cpu] = "NEC VR4133";
771 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 break;
773 default:
774 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
775 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000776 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 break;
778 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700779 break;
780 case PRID_IMP_R4300:
781 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000782 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000783 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100784 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500786 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787 c->tlbsize = 32;
788 break;
789 case PRID_IMP_R4600:
790 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000791 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000792 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100793 c->fpu_msk31 |= FPU_CSR_CONDX;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000794 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
795 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700796 c->tlbsize = 48;
797 break;
798 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500799 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 /*
801 * This processor doesn't have an MMU, so it's not
802 * "real easy" to run Linux on it. It is left purely
803 * for documentation. Commented out because it shares
804 * it's c0_prid id number with the TX3900.
805 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000806 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000807 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000808 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100809 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700810 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500811 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 break;
813 #endif
814 case PRID_IMP_TX39:
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100815 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100816 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817
818 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
819 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000820 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 c->tlbsize = 64;
822 } else {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100823 switch (c->processor_id & PRID_REV_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 case PRID_REV_TX3912:
825 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000826 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 c->tlbsize = 32;
828 break;
829 case PRID_REV_TX3922:
830 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000831 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 c->tlbsize = 64;
833 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700834 }
835 }
836 break;
837 case PRID_IMP_R4700:
838 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000839 __cpu_name[cpu] = "R4700";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000840 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100841 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500843 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 c->tlbsize = 48;
845 break;
846 case PRID_IMP_TX49:
847 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000848 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000849 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100850 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700851 c->options = R4K_OPTS | MIPS_CPU_LLSC;
852 if (!(c->processor_id & 0x08))
853 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
854 c->tlbsize = 48;
855 break;
856 case PRID_IMP_R5000:
857 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000858 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000859 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500861 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700862 c->tlbsize = 48;
863 break;
864 case PRID_IMP_R5432:
865 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000866 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000867 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500869 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 c->tlbsize = 48;
871 break;
872 case PRID_IMP_R5500:
873 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000874 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000875 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500877 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 c->tlbsize = 48;
879 break;
880 case PRID_IMP_NEVADA:
881 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000882 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000883 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500885 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 c->tlbsize = 48;
887 break;
888 case PRID_IMP_R6000:
889 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000890 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000891 set_isa(c, MIPS_CPU_ISA_II);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100892 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500894 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895 c->tlbsize = 32;
896 break;
897 case PRID_IMP_R6000A:
898 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000899 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000900 set_isa(c, MIPS_CPU_ISA_II);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100901 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500903 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 c->tlbsize = 32;
905 break;
906 case PRID_IMP_RM7000:
907 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000908 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000909 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500911 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100913 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 * the RM7000 v2.0 indicates if the TLB has 48 or 64
915 * entries.
916 *
Ralf Baechle70342282013-01-22 12:59:30 +0100917 * 29 1 => 64 entry JTLB
918 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700919 */
920 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
921 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922 case PRID_IMP_R8000:
923 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000924 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000925 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500927 MIPS_CPU_FPU | MIPS_CPU_32FPR |
928 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
930 break;
931 case PRID_IMP_R10000:
932 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000933 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000934 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000935 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500936 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500938 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939 c->tlbsize = 64;
940 break;
941 case PRID_IMP_R12000:
942 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000943 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000944 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000945 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500946 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500948 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949 c->tlbsize = 64;
950 break;
Kumba44d921b2006-05-16 22:23:59 -0400951 case PRID_IMP_R14000:
Joshua Kinard30577392015-01-21 07:59:45 -0500952 if (((c->processor_id >> 4) & 0x0f) > 2) {
953 c->cputype = CPU_R16000;
954 __cpu_name[cpu] = "R16000";
955 } else {
956 c->cputype = CPU_R14000;
957 __cpu_name[cpu] = "R14000";
958 }
Steven J. Hilla96102b2012-12-07 04:31:36 +0000959 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400960 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500961 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400962 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500963 MIPS_CPU_LLSC;
Kumba44d921b2006-05-16 22:23:59 -0400964 c->tlbsize = 64;
965 break;
Huacai Chen26859192014-02-16 16:01:18 +0800966 case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */
Robert Millan5aac1e82011-04-16 11:29:29 -0700967 switch (c->processor_id & PRID_REV_MASK) {
968 case PRID_REV_LOONGSON2E:
Huacai Chenc579d312014-03-21 18:44:00 +0800969 c->cputype = CPU_LOONGSON2;
970 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700971 set_elf_platform(cpu, "loongson2e");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800972 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100973 c->fpu_msk31 |= FPU_CSR_CONDX;
Robert Millan5aac1e82011-04-16 11:29:29 -0700974 break;
975 case PRID_REV_LOONGSON2F:
Huacai Chenc579d312014-03-21 18:44:00 +0800976 c->cputype = CPU_LOONGSON2;
977 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700978 set_elf_platform(cpu, "loongson2f");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800979 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100980 c->fpu_msk31 |= FPU_CSR_CONDX;
Robert Millan5aac1e82011-04-16 11:29:29 -0700981 break;
Huacai Chenc579d312014-03-21 18:44:00 +0800982 case PRID_REV_LOONGSON3A:
983 c->cputype = CPU_LOONGSON3;
984 __cpu_name[cpu] = "ICT Loongson-3";
985 set_elf_platform(cpu, "loongson3a");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800986 set_isa(c, MIPS_CPU_ISA_M64R1);
Huacai Chenc579d312014-03-21 18:44:00 +0800987 break;
Huacai Chene7841be2014-06-26 11:41:30 +0800988 case PRID_REV_LOONGSON3B_R1:
989 case PRID_REV_LOONGSON3B_R2:
990 c->cputype = CPU_LOONGSON3;
991 __cpu_name[cpu] = "ICT Loongson-3";
992 set_elf_platform(cpu, "loongson3b");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800993 set_isa(c, MIPS_CPU_ISA_M64R1);
Huacai Chene7841be2014-06-26 11:41:30 +0800994 break;
Robert Millan5aac1e82011-04-16 11:29:29 -0700995 }
996
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800997 c->options = R4K_OPTS |
998 MIPS_CPU_FPU | MIPS_CPU_LLSC |
999 MIPS_CPU_32FPR;
1000 c->tlbsize = 64;
Huacai Chencc94ea32014-11-04 14:13:22 +08001001 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Fuxin Zhang2a21c732007-06-06 14:52:43 +08001002 break;
Huacai Chen26859192014-02-16 16:01:18 +08001003 case PRID_IMP_LOONGSON_32: /* Loongson-1 */
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001004 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001006 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +00001007
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001008 switch (c->processor_id & PRID_REV_MASK) {
1009 case PRID_REV_LOONGSON1B:
1010 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +00001011 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +00001012 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001013
Ralf Baechle41943182005-05-05 16:45:59 +00001014 break;
Ralf Baechle41943182005-05-05 16:45:59 +00001015 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016}
1017
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001018static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001019{
Markos Chandras4f12b912014-07-18 10:51:32 +01001020 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001021 switch (c->processor_id & PRID_IMP_MASK) {
Leonid Yegoshinb2498af2014-11-24 12:59:44 +00001022 case PRID_IMP_QEMU_GENERIC:
1023 c->writecombine = _CACHE_UNCACHED;
1024 c->cputype = CPU_QEMU_GENERIC;
1025 __cpu_name[cpu] = "MIPS GENERIC QEMU";
1026 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001027 case PRID_IMP_4KC:
1028 c->cputype = CPU_4KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001029 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001030 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001031 break;
1032 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +00001033 case PRID_IMP_4KECR2:
1034 c->cputype = CPU_4KEC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001035 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001036 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +00001037 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001038 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +01001039 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040 c->cputype = CPU_4KSC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001041 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001042 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043 break;
1044 case PRID_IMP_5KC:
1045 c->cputype = CPU_5KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001046 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001047 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +02001049 case PRID_IMP_5KE:
1050 c->cputype = CPU_5KE;
Markos Chandras4f12b912014-07-18 10:51:32 +01001051 c->writecombine = _CACHE_UNCACHED;
Leonid Yegoshin78d48032012-07-06 21:56:01 +02001052 __cpu_name[cpu] = "MIPS 5KE";
1053 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054 case PRID_IMP_20KC:
1055 c->cputype = CPU_20KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001056 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001057 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 break;
1059 case PRID_IMP_24K:
1060 c->cputype = CPU_24K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001061 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001062 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 break;
John Crispin42f3cae2013-01-11 22:44:10 +01001064 case PRID_IMP_24KE:
1065 c->cputype = CPU_24K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001066 c->writecombine = _CACHE_UNCACHED;
John Crispin42f3cae2013-01-11 22:44:10 +01001067 __cpu_name[cpu] = "MIPS 24KEc";
1068 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001069 case PRID_IMP_25KF:
1070 c->cputype = CPU_25KF;
Markos Chandras4f12b912014-07-18 10:51:32 +01001071 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001072 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +00001074 case PRID_IMP_34K:
1075 c->cputype = CPU_34K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001076 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001077 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +00001078 break;
Chris Dearmanc6209532006-05-02 14:08:46 +01001079 case PRID_IMP_74K:
1080 c->cputype = CPU_74K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001081 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001082 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +01001083 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +02001084 case PRID_IMP_M14KC:
1085 c->cputype = CPU_M14KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001086 c->writecombine = _CACHE_UNCACHED;
Steven J. Hill113c62d2012-07-06 23:56:00 +02001087 __cpu_name[cpu] = "MIPS M14Kc";
1088 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +00001089 case PRID_IMP_M14KEC:
1090 c->cputype = CPU_M14KEC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001091 c->writecombine = _CACHE_UNCACHED;
Steven J. Hillf8fa4812012-12-07 03:51:35 +00001092 __cpu_name[cpu] = "MIPS M14KEc";
1093 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +01001094 case PRID_IMP_1004K:
1095 c->cputype = CPU_1004K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001096 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001097 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +01001098 break;
Steven J. Hill006a8512012-06-26 04:11:03 +00001099 case PRID_IMP_1074K:
Steven J. Hill442e14a2014-01-17 15:03:50 -06001100 c->cputype = CPU_1074K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001101 c->writecombine = _CACHE_UNCACHED;
Steven J. Hill006a8512012-06-26 04:11:03 +00001102 __cpu_name[cpu] = "MIPS 1074Kc";
1103 break;
Leonid Yegoshinb5f065e2013-11-20 10:46:02 +00001104 case PRID_IMP_INTERAPTIV_UP:
1105 c->cputype = CPU_INTERAPTIV;
1106 __cpu_name[cpu] = "MIPS interAptiv";
1107 break;
1108 case PRID_IMP_INTERAPTIV_MP:
1109 c->cputype = CPU_INTERAPTIV;
1110 __cpu_name[cpu] = "MIPS interAptiv (multi)";
1111 break;
Leonid Yegoshinb0d4d302013-11-14 16:12:28 +00001112 case PRID_IMP_PROAPTIV_UP:
1113 c->cputype = CPU_PROAPTIV;
1114 __cpu_name[cpu] = "MIPS proAptiv";
1115 break;
1116 case PRID_IMP_PROAPTIV_MP:
1117 c->cputype = CPU_PROAPTIV;
1118 __cpu_name[cpu] = "MIPS proAptiv (multi)";
1119 break;
James Hogan829dcc02014-01-22 16:19:39 +00001120 case PRID_IMP_P5600:
1121 c->cputype = CPU_P5600;
1122 __cpu_name[cpu] = "MIPS P5600";
1123 break;
Leonid Yegoshin9943ed92014-03-04 13:34:44 +00001124 case PRID_IMP_M5150:
1125 c->cputype = CPU_M5150;
1126 __cpu_name[cpu] = "MIPS M5150";
1127 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001128 }
Chris Dearman0b6d4972007-09-13 12:32:02 +01001129
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +00001130 decode_configs(c);
1131
Chris Dearman0b6d4972007-09-13 12:32:02 +01001132 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133}
1134
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001135static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136{
Ralf Baechle41943182005-05-05 16:45:59 +00001137 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001138 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001139 case PRID_IMP_AU1_REV1:
1140 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +01001141 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142 switch ((c->processor_id >> 24) & 0xff) {
1143 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001144 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 break;
1146 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001147 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 break;
1149 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001150 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 break;
1152 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001153 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001154 break;
Pete Popove3ad1c22005-03-01 06:33:16 +00001155 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001156 __cpu_name[cpu] = "Au1200";
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001157 if ((c->processor_id & PRID_REV_MASK) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001158 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +01001159 break;
1160 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001161 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +00001162 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 default:
Manuel Lauss270717a2009-03-25 17:49:28 +01001164 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 break;
1166 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 break;
1168 }
1169}
1170
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001171static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172{
Ralf Baechle41943182005-05-05 16:45:59 +00001173 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +01001174
Markos Chandras4f12b912014-07-18 10:51:32 +01001175 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001176 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 case PRID_IMP_SB1:
1178 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001179 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 /* FPU in pass1 is known to have issues. */
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001181 if ((c->processor_id & PRID_REV_MASK) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +00001182 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -07001184 case PRID_IMP_SB1A:
1185 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001186 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -07001187 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 }
1189}
1190
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001191static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192{
Ralf Baechle41943182005-05-05 16:45:59 +00001193 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001194 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 case PRID_IMP_SR71000:
1196 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001197 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001198 c->scache.ways = 8;
1199 c->tlbsize = 64;
1200 break;
1201 }
1202}
1203
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001204static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +00001205{
1206 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001207 switch (c->processor_id & PRID_IMP_MASK) {
Pete Popovbdf21b12005-07-14 17:47:57 +00001208 case PRID_IMP_PR4450:
1209 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001210 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +00001211 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +00001212 break;
Pete Popovbdf21b12005-07-14 17:47:57 +00001213 }
1214}
1215
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001216static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001217{
1218 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001219 switch (c->processor_id & PRID_IMP_MASK) {
Kevin Cernekee190fca32010-11-23 10:26:45 -08001220 case PRID_IMP_BMIPS32_REV4:
1221 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -07001222 c->cputype = CPU_BMIPS32;
1223 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001224 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001225 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001226 case PRID_IMP_BMIPS3300:
1227 case PRID_IMP_BMIPS3300_ALT:
1228 case PRID_IMP_BMIPS3300_BUG:
1229 c->cputype = CPU_BMIPS3300;
1230 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001231 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001232 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001233 case PRID_IMP_BMIPS43XX: {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001234 int rev = c->processor_id & PRID_REV_MASK;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001235
1236 if (rev >= PRID_REV_BMIPS4380_LO &&
1237 rev <= PRID_REV_BMIPS4380_HI) {
1238 c->cputype = CPU_BMIPS4380;
1239 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001240 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001241 } else {
1242 c->cputype = CPU_BMIPS4350;
1243 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001244 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +01001245 }
1246 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001247 }
Kevin Cernekee602977b2010-10-16 14:22:30 -07001248 case PRID_IMP_BMIPS5000:
Kevin Cernekee68e6a782014-10-20 21:28:01 -07001249 case PRID_IMP_BMIPS5200:
Kevin Cernekee602977b2010-10-16 14:22:30 -07001250 c->cputype = CPU_BMIPS5000;
1251 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001252 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001253 c->options |= MIPS_CPU_ULRI;
1254 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001255 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001256}
1257
David Daney0dd47812008-12-11 15:33:26 -08001258static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
1259{
1260 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001261 switch (c->processor_id & PRID_IMP_MASK) {
David Daney0dd47812008-12-11 15:33:26 -08001262 case PRID_IMP_CAVIUM_CN38XX:
1263 case PRID_IMP_CAVIUM_CN31XX:
1264 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -08001265 c->cputype = CPU_CAVIUM_OCTEON;
1266 __cpu_name[cpu] = "Cavium Octeon";
1267 goto platform;
David Daney0dd47812008-12-11 15:33:26 -08001268 case PRID_IMP_CAVIUM_CN58XX:
1269 case PRID_IMP_CAVIUM_CN56XX:
1270 case PRID_IMP_CAVIUM_CN50XX:
1271 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -08001272 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
1273 __cpu_name[cpu] = "Cavium Octeon+";
1274platform:
Robert Millanc094c992011-04-18 11:37:55 -07001275 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -08001276 break;
David Daneya1431b62011-09-24 02:29:54 +02001277 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -07001278 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +02001279 case PRID_IMP_CAVIUM_CN66XX:
1280 case PRID_IMP_CAVIUM_CN68XX:
David Daneyaf04bb82013-07-29 15:07:01 -07001281 case PRID_IMP_CAVIUM_CNF71XX:
David Daney0e56b382010-10-07 16:03:45 -07001282 c->cputype = CPU_CAVIUM_OCTEON2;
1283 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001284 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001285 break;
David Daneyaf04bb82013-07-29 15:07:01 -07001286 case PRID_IMP_CAVIUM_CN70XX:
1287 case PRID_IMP_CAVIUM_CN78XX:
1288 c->cputype = CPU_CAVIUM_OCTEON3;
1289 __cpu_name[cpu] = "Cavium Octeon III";
1290 set_elf_platform(cpu, "octeon3");
1291 break;
David Daney0dd47812008-12-11 15:33:26 -08001292 default:
1293 printk(KERN_INFO "Unknown Octeon chip!\n");
1294 c->cputype = CPU_UNKNOWN;
1295 break;
1296 }
1297}
1298
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001299static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1300{
1301 decode_configs(c);
1302 /* JZRISC does not implement the CP0 counter. */
1303 c->options &= ~MIPS_CPU_COUNTER;
Maciej W. Rozycki06947aa2014-04-06 21:31:29 +01001304 BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001305 switch (c->processor_id & PRID_IMP_MASK) {
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001306 case PRID_IMP_JZRISC:
1307 c->cputype = CPU_JZRISC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001308 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001309 __cpu_name[cpu] = "Ingenic JZRISC";
1310 break;
1311 default:
1312 panic("Unknown Ingenic Processor ID!");
1313 break;
1314 }
1315}
1316
Jayachandran Ca7117c62011-05-11 12:04:58 +05301317static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1318{
1319 decode_configs(c);
1320
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001321 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
Manuel Lauss809f36c2011-11-01 20:03:30 +01001322 c->cputype = CPU_ALCHEMY;
1323 __cpu_name[cpu] = "Au1300";
1324 /* following stuff is not for Alchemy */
1325 return;
1326 }
1327
Ralf Baechle70342282013-01-22 12:59:30 +01001328 c->options = (MIPS_CPU_TLB |
1329 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301330 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +01001331 MIPS_CPU_DIVEC |
1332 MIPS_CPU_WATCH |
1333 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301334 MIPS_CPU_LLSC);
1335
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001336 switch (c->processor_id & PRID_IMP_MASK) {
Jayachandran C4ca86a22013-08-11 14:43:54 +05301337 case PRID_IMP_NETLOGIC_XLP2XX:
Jayachandran C8907c552013-12-21 16:52:20 +05301338 case PRID_IMP_NETLOGIC_XLP9XX:
Yonghong Song1c983982014-04-29 20:07:53 +05301339 case PRID_IMP_NETLOGIC_XLP5XX:
Jayachandran C4ca86a22013-08-11 14:43:54 +05301340 c->cputype = CPU_XLP;
1341 __cpu_name[cpu] = "Broadcom XLPII";
1342 break;
1343
Jayachandran C2aa54b22011-11-16 00:21:29 +00001344 case PRID_IMP_NETLOGIC_XLP8XX:
1345 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001346 c->cputype = CPU_XLP;
1347 __cpu_name[cpu] = "Netlogic XLP";
1348 break;
1349
Jayachandran Ca7117c62011-05-11 12:04:58 +05301350 case PRID_IMP_NETLOGIC_XLR732:
1351 case PRID_IMP_NETLOGIC_XLR716:
1352 case PRID_IMP_NETLOGIC_XLR532:
1353 case PRID_IMP_NETLOGIC_XLR308:
1354 case PRID_IMP_NETLOGIC_XLR532C:
1355 case PRID_IMP_NETLOGIC_XLR516C:
1356 case PRID_IMP_NETLOGIC_XLR508C:
1357 case PRID_IMP_NETLOGIC_XLR308C:
1358 c->cputype = CPU_XLR;
1359 __cpu_name[cpu] = "Netlogic XLR";
1360 break;
1361
1362 case PRID_IMP_NETLOGIC_XLS608:
1363 case PRID_IMP_NETLOGIC_XLS408:
1364 case PRID_IMP_NETLOGIC_XLS404:
1365 case PRID_IMP_NETLOGIC_XLS208:
1366 case PRID_IMP_NETLOGIC_XLS204:
1367 case PRID_IMP_NETLOGIC_XLS108:
1368 case PRID_IMP_NETLOGIC_XLS104:
1369 case PRID_IMP_NETLOGIC_XLS616B:
1370 case PRID_IMP_NETLOGIC_XLS608B:
1371 case PRID_IMP_NETLOGIC_XLS416B:
1372 case PRID_IMP_NETLOGIC_XLS412B:
1373 case PRID_IMP_NETLOGIC_XLS408B:
1374 case PRID_IMP_NETLOGIC_XLS404B:
1375 c->cputype = CPU_XLR;
1376 __cpu_name[cpu] = "Netlogic XLS";
1377 break;
1378
1379 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001380 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301381 c->processor_id);
1382 c->cputype = CPU_XLR;
1383 break;
1384 }
1385
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001386 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001387 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001388 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1389 /* This will be updated again after all threads are woken up */
1390 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1391 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001392 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001393 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1394 }
Jayachandran C7777b932013-06-11 14:41:35 +00001395 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301396}
1397
David Daney949e51b2010-10-14 11:32:33 -07001398#ifdef CONFIG_64BIT
1399/* For use by uaccess.h */
1400u64 __ua_limit;
1401EXPORT_SYMBOL(__ua_limit);
1402#endif
1403
Ralf Baechle9966db252007-10-11 23:46:17 +01001404const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001405const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001406
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001407void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408{
1409 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001410 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001411
Ralf Baechle70342282013-01-22 12:59:30 +01001412 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413 c->fpu_id = FPIR_IMP_NONE;
1414 c->cputype = CPU_UNKNOWN;
Markos Chandras4f12b912014-07-18 10:51:32 +01001415 c->writecombine = _CACHE_UNCACHED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001416
Maciej W. Rozycki9b266162015-04-03 23:27:48 +01001417 c->fpu_csr31 = FPU_CSR_RN;
1418 c->fpu_msk31 = FPU_CSR_RSVD | FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
1419
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420 c->processor_id = read_c0_prid();
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001421 switch (c->processor_id & PRID_COMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001422 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001423 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001424 break;
1425 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001426 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427 break;
1428 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001429 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430 break;
1431 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001432 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001433 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001434 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001435 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001436 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001437 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001438 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001439 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001440 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001441 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001442 break;
David Daney0dd47812008-12-11 15:33:26 -08001443 case PRID_COMP_CAVIUM:
1444 cpu_probe_cavium(c, cpu);
1445 break;
Paul Burton252617a2015-05-24 16:11:14 +01001446 case PRID_COMP_INGENIC_D0:
1447 case PRID_COMP_INGENIC_D1:
1448 case PRID_COMP_INGENIC_E1:
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001449 cpu_probe_ingenic(c, cpu);
1450 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301451 case PRID_COMP_NETLOGIC:
1452 cpu_probe_netlogic(c, cpu);
1453 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001454 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001455
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001456 BUG_ON(!__cpu_name[cpu]);
1457 BUG_ON(c->cputype == CPU_UNKNOWN);
1458
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001459 /*
1460 * Platform code can force the cpu type to optimize code
1461 * generation. In that case be sure the cpu type is correctly
1462 * manually setup otherwise it could trigger some nasty bugs.
1463 */
1464 BUG_ON(current_cpu_type() != c->cputype);
1465
Kevin Cernekee0103d232010-05-02 14:43:52 -07001466 if (mips_fpu_disabled)
1467 c->options &= ~MIPS_CPU_FPU;
1468
1469 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001470 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001471
Markos Chandras3d528b32014-07-14 12:46:13 +01001472 if (mips_htw_disabled) {
1473 c->options &= ~MIPS_CPU_HTW;
1474 write_c0_pwctl(read_c0_pwctl() &
1475 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
1476 }
1477
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +01001478 if (c->options & MIPS_CPU_FPU)
1479 cpu_set_fpu_opts(c);
1480 else
1481 cpu_set_nofpu_opts(c);
Ralf Baechle9966db252007-10-11 23:46:17 +01001482
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +00001483 if (cpu_has_mips_r2_r6) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001484 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001485 /* R2 has Performance Counter Interrupt indicator */
1486 c->options |= MIPS_CPU_PCI;
1487 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001488 else
1489 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001490
Paul Burtona8ad1362014-01-28 14:28:43 +00001491 if (cpu_has_msa) {
Paul Burtona5e9a692014-01-27 15:23:10 +00001492 c->msa_id = cpu_get_msa_id();
Paul Burtona8ad1362014-01-28 14:28:43 +00001493 WARN(c->msa_id & MSA_IR_WRPF,
1494 "Vector register partitioning unimplemented!");
1495 }
Paul Burtona5e9a692014-01-27 15:23:10 +00001496
Guenter Roeck91dfc422010-02-02 08:52:20 -08001497 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001498
1499#ifdef CONFIG_64BIT
1500 if (cpu == 0)
1501 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1502#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001503}
1504
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001505void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001506{
1507 struct cpuinfo_mips *c = &current_cpu_data;
1508
Leonid Yegoshind9f897c2013-10-07 10:43:32 +01001509 pr_info("CPU%d revision is: %08x (%s)\n",
1510 smp_processor_id(), c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001511 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001512 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Paul Burtona5e9a692014-01-27 15:23:10 +00001513 if (cpu_has_msa)
1514 pr_info("MSA revision is: %08x\n", c->msa_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001515}