blob: 2911ad5977d79183859e88fbcb26acec7b89e775 [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. Rozycki9b266162015-04-03 23:27:48 +010036 * Determine the FCSR mask for FPU hardware.
37 */
38static inline void cpu_set_fpu_fcsr_mask(struct cpuinfo_mips *c)
39{
40 unsigned long sr, mask, fcsr, fcsr0, fcsr1;
41
42 mask = FPU_CSR_ALL_X | FPU_CSR_ALL_E | FPU_CSR_ALL_S | FPU_CSR_RM;
43
44 sr = read_c0_status();
45 __enable_fpu(FPU_AS_IS);
46
47 fcsr = read_32bit_cp1_register(CP1_STATUS);
48
49 fcsr0 = fcsr & mask;
50 write_32bit_cp1_register(CP1_STATUS, fcsr0);
51 fcsr0 = read_32bit_cp1_register(CP1_STATUS);
52
53 fcsr1 = fcsr | ~mask;
54 write_32bit_cp1_register(CP1_STATUS, fcsr1);
55 fcsr1 = read_32bit_cp1_register(CP1_STATUS);
56
57 write_32bit_cp1_register(CP1_STATUS, fcsr);
58
59 write_c0_status(sr);
60
61 c->fpu_msk31 = ~(fcsr0 ^ fcsr1) & ~mask;
62}
63
64/*
Maciej W. Rozyckif6843622015-04-03 23:27:26 +010065 * Set the FIR feature flags for the FPU emulator.
66 */
67static void cpu_set_nofpu_id(struct cpuinfo_mips *c)
68{
69 u32 value;
70
71 value = 0;
72 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
73 MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
74 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6))
75 value |= MIPS_FPIR_D | MIPS_FPIR_S;
76 if (c->isa_level & (MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
77 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6))
78 value |= MIPS_FPIR_F64 | MIPS_FPIR_L | MIPS_FPIR_W;
79 c->fpu_id = value;
80}
81
Maciej W. Rozycki9b266162015-04-03 23:27:48 +010082/* Determined FPU emulator mask to use for the boot CPU with "nofpu". */
83static unsigned int mips_nofpu_msk31;
84
Paul Gortmaker078a55f2013-06-18 13:38:59 +000085static int mips_fpu_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -070086
87static int __init fpu_disable(char *s)
88{
Maciej W. Rozyckif6843622015-04-03 23:27:26 +010089 boot_cpu_data.options &= ~MIPS_CPU_FPU;
Maciej W. Rozycki9b266162015-04-03 23:27:48 +010090 boot_cpu_data.fpu_msk31 = mips_nofpu_msk31;
Maciej W. Rozyckif6843622015-04-03 23:27:26 +010091 cpu_set_nofpu_id(&boot_cpu_data);
Kevin Cernekee0103d232010-05-02 14:43:52 -070092 mips_fpu_disabled = 1;
93
94 return 1;
95}
96
97__setup("nofpu", fpu_disable);
98
Paul Gortmaker078a55f2013-06-18 13:38:59 +000099int mips_dsp_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -0700100
101static int __init dsp_disable(char *s)
102{
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500103 cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -0700104 mips_dsp_disabled = 1;
105
106 return 1;
107}
108
109__setup("nodsp", dsp_disable);
110
Markos Chandras3d528b32014-07-14 12:46:13 +0100111static int mips_htw_disabled;
112
113static int __init htw_disable(char *s)
114{
115 mips_htw_disabled = 1;
116 cpu_data[0].options &= ~MIPS_CPU_HTW;
117 write_c0_pwctl(read_c0_pwctl() &
118 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
119
120 return 1;
121}
122
123__setup("nohtw", htw_disable);
124
Markos Chandras97f4ad22014-08-29 09:37:26 +0100125static int mips_ftlb_disabled;
126static int mips_has_ftlb_configured;
127
128static void set_ftlb_enable(struct cpuinfo_mips *c, int enable);
129
130static int __init ftlb_disable(char *s)
131{
132 unsigned int config4, mmuextdef;
133
134 /*
135 * If the core hasn't done any FTLB configuration, there is nothing
136 * for us to do here.
137 */
138 if (!mips_has_ftlb_configured)
139 return 1;
140
141 /* Disable it in the boot cpu */
142 set_ftlb_enable(&cpu_data[0], 0);
143
144 back_to_back_c0_hazard();
145
146 config4 = read_c0_config4();
147
148 /* Check that FTLB has been disabled */
149 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
150 /* MMUSIZEEXT == VTLB ON, FTLB OFF */
151 if (mmuextdef == MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT) {
152 /* This should never happen */
153 pr_warn("FTLB could not be disabled!\n");
154 return 1;
155 }
156
157 mips_ftlb_disabled = 1;
158 mips_has_ftlb_configured = 0;
159
160 /*
161 * noftlb is mainly used for debug purposes so print
162 * an informative message instead of using pr_debug()
163 */
164 pr_info("FTLB has been disabled\n");
165
166 /*
167 * Some of these bits are duplicated in the decode_config4.
168 * MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT is the only possible case
169 * once FTLB has been disabled so undo what decode_config4 did.
170 */
171 cpu_data[0].tlbsize -= cpu_data[0].tlbsizeftlbways *
172 cpu_data[0].tlbsizeftlbsets;
173 cpu_data[0].tlbsizeftlbsets = 0;
174 cpu_data[0].tlbsizeftlbways = 0;
175
176 return 1;
177}
178
179__setup("noftlb", ftlb_disable);
180
181
Marc St-Jean9267a302007-06-14 15:55:31 -0600182static inline void check_errata(void)
183{
184 struct cpuinfo_mips *c = &current_cpu_data;
185
Ralf Baechle69f24d12013-09-17 10:25:47 +0200186 switch (current_cpu_type()) {
Marc St-Jean9267a302007-06-14 15:55:31 -0600187 case CPU_34K:
188 /*
189 * Erratum "RPS May Cause Incorrect Instruction Execution"
Ralf Baechleb633648c52014-05-23 16:29:44 +0200190 * This code only handles VPE0, any SMP/RTOS code
Marc St-Jean9267a302007-06-14 15:55:31 -0600191 * making use of VPE1 will be responsable for that VPE.
192 */
193 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
194 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
195 break;
196 default:
197 break;
198 }
199}
200
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201void __init check_bugs32(void)
202{
Marc St-Jean9267a302007-06-14 15:55:31 -0600203 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204}
205
206/*
207 * Probe whether cpu has config register by trying to play with
208 * alternate cache bit and see whether it matters.
209 * It's used by cpu_probe to distinguish between R3000A and R3081.
210 */
211static inline int cpu_has_confreg(void)
212{
213#ifdef CONFIG_CPU_R3000
214 extern unsigned long r3k_cache_size(unsigned long);
215 unsigned long size1, size2;
216 unsigned long cfg = read_c0_conf();
217
218 size1 = r3k_cache_size(ST0_ISC);
219 write_c0_conf(cfg ^ R30XX_CONF_AC);
220 size2 = r3k_cache_size(ST0_ISC);
221 write_c0_conf(cfg);
222 return size1 != size2;
223#else
224 return 0;
225#endif
226}
227
Robert Millanc094c992011-04-18 11:37:55 -0700228static inline void set_elf_platform(int cpu, const char *plat)
229{
230 if (cpu == 0)
231 __elf_platform = plat;
232}
233
Linus Torvalds1da177e2005-04-16 15:20:36 -0700234/*
235 * Get the FPU Implementation/Revision.
236 */
237static inline unsigned long cpu_get_fpu_id(void)
238{
239 unsigned long tmp, fpu_id;
240
241 tmp = read_c0_status();
Paul Burton597ce172013-11-22 13:12:07 +0000242 __enable_fpu(FPU_AS_IS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243 fpu_id = read_32bit_cp1_register(CP1_REVISION);
244 write_c0_status(tmp);
245 return fpu_id;
246}
247
248/*
Maciej W. Rozyckif6c70ff2015-04-03 23:24:18 +0100249 * Check if the CPU has an external FPU.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 */
251static inline int __cpu_has_fpu(void)
252{
Ralf Baechle635c99072014-10-21 14:12:49 +0200253 return (cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254}
255
Paul Burtona5e9a692014-01-27 15:23:10 +0000256static inline unsigned long cpu_get_msa_id(void)
257{
Paul Burton3587ea82014-07-11 16:44:34 +0100258 unsigned long status, msa_id;
Paul Burtona5e9a692014-01-27 15:23:10 +0000259
260 status = read_c0_status();
261 __enable_fpu(FPU_64BIT);
Paul Burtona5e9a692014-01-27 15:23:10 +0000262 enable_msa();
263 msa_id = read_msa_ir();
Paul Burton3587ea82014-07-11 16:44:34 +0100264 disable_msa();
Paul Burtona5e9a692014-01-27 15:23:10 +0000265 write_c0_status(status);
266 return msa_id;
267}
268
Guenter Roeck91dfc422010-02-02 08:52:20 -0800269static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
270{
271#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800272 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800273 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800274 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800275#endif
276}
277
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000278static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
Steven J. Hilla96102b2012-12-07 04:31:36 +0000279{
280 switch (isa) {
281 case MIPS_CPU_ISA_M64R2:
282 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
283 case MIPS_CPU_ISA_M64R1:
284 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
285 case MIPS_CPU_ISA_V:
286 c->isa_level |= MIPS_CPU_ISA_V;
287 case MIPS_CPU_ISA_IV:
288 c->isa_level |= MIPS_CPU_ISA_IV;
289 case MIPS_CPU_ISA_III:
Ralf Baechle1990e542013-06-26 17:06:34 +0200290 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000291 break;
292
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000293 /* R6 incompatible with everything else */
294 case MIPS_CPU_ISA_M64R6:
295 c->isa_level |= MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6;
296 case MIPS_CPU_ISA_M32R6:
297 c->isa_level |= MIPS_CPU_ISA_M32R6;
298 /* Break here so we don't add incompatible ISAs */
299 break;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000300 case MIPS_CPU_ISA_M32R2:
301 c->isa_level |= MIPS_CPU_ISA_M32R2;
302 case MIPS_CPU_ISA_M32R1:
303 c->isa_level |= MIPS_CPU_ISA_M32R1;
304 case MIPS_CPU_ISA_II:
305 c->isa_level |= MIPS_CPU_ISA_II;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000306 break;
307 }
308}
309
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000310static char unknown_isa[] = KERN_ERR \
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100311 "Unsupported ISA type, c0.config0: %d.";
312
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000313static unsigned int calculate_ftlb_probability(struct cpuinfo_mips *c)
314{
315
316 unsigned int probability = c->tlbsize / c->tlbsizevtlb;
317
318 /*
319 * 0 = All TLBWR instructions go to FTLB
320 * 1 = 15:1: For every 16 TBLWR instructions, 15 go to the
321 * FTLB and 1 goes to the VTLB.
322 * 2 = 7:1: As above with 7:1 ratio.
323 * 3 = 3:1: As above with 3:1 ratio.
324 *
325 * Use the linear midpoint as the probability threshold.
326 */
327 if (probability >= 12)
328 return 1;
329 else if (probability >= 6)
330 return 2;
331 else
332 /*
333 * So FTLB is less than 4 times bigger than VTLB.
334 * A 3:1 ratio can still be useful though.
335 */
336 return 3;
337}
338
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000339static void set_ftlb_enable(struct cpuinfo_mips *c, int enable)
340{
341 unsigned int config6;
James Hogand83b0e82014-01-22 16:19:40 +0000342
343 /* It's implementation dependent how the FTLB can be enabled */
344 switch (c->cputype) {
345 case CPU_PROAPTIV:
346 case CPU_P5600:
347 /* proAptiv & related cores use Config6 to enable the FTLB */
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000348 config6 = read_c0_config6();
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000349 /* Clear the old probability value */
350 config6 &= ~(3 << MIPS_CONF6_FTLBP_SHIFT);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000351 if (enable)
352 /* Enable FTLB */
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000353 write_c0_config6(config6 |
354 (calculate_ftlb_probability(c)
355 << MIPS_CONF6_FTLBP_SHIFT)
356 | MIPS_CONF6_FTLBEN);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000357 else
358 /* Disable FTLB */
359 write_c0_config6(config6 & ~MIPS_CONF6_FTLBEN);
360 back_to_back_c0_hazard();
James Hogand83b0e82014-01-22 16:19:40 +0000361 break;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000362 }
363}
364
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100365static inline unsigned int decode_config0(struct cpuinfo_mips *c)
366{
367 unsigned int config0;
368 int isa;
369
370 config0 = read_c0_config();
371
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000372 /*
373 * Look for Standard TLB or Dual VTLB and FTLB
374 */
375 if ((((config0 & MIPS_CONF_MT) >> 7) == 1) ||
376 (((config0 & MIPS_CONF_MT) >> 7) == 4))
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100377 c->options |= MIPS_CPU_TLB;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000378
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100379 isa = (config0 & MIPS_CONF_AT) >> 13;
380 switch (isa) {
381 case 0:
382 switch ((config0 & MIPS_CONF_AR) >> 10) {
383 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000384 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100385 break;
386 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000387 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100388 break;
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000389 case 2:
390 set_isa(c, MIPS_CPU_ISA_M32R6);
391 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100392 default:
393 goto unknown;
394 }
395 break;
396 case 2:
397 switch ((config0 & MIPS_CONF_AR) >> 10) {
398 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000399 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100400 break;
401 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000402 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100403 break;
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000404 case 2:
405 set_isa(c, MIPS_CPU_ISA_M64R6);
406 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100407 default:
408 goto unknown;
409 }
410 break;
411 default:
412 goto unknown;
413 }
414
415 return config0 & MIPS_CONF_M;
416
417unknown:
418 panic(unknown_isa, config0);
419}
420
421static inline unsigned int decode_config1(struct cpuinfo_mips *c)
422{
423 unsigned int config1;
424
425 config1 = read_c0_config1();
426
427 if (config1 & MIPS_CONF1_MD)
428 c->ases |= MIPS_ASE_MDMX;
429 if (config1 & MIPS_CONF1_WR)
430 c->options |= MIPS_CPU_WATCH;
431 if (config1 & MIPS_CONF1_CA)
432 c->ases |= MIPS_ASE_MIPS16;
433 if (config1 & MIPS_CONF1_EP)
434 c->options |= MIPS_CPU_EJTAG;
435 if (config1 & MIPS_CONF1_FP) {
436 c->options |= MIPS_CPU_FPU;
437 c->options |= MIPS_CPU_32FPR;
438 }
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000439 if (cpu_has_tlb) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100440 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000441 c->tlbsizevtlb = c->tlbsize;
442 c->tlbsizeftlbsets = 0;
443 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100444
445 return config1 & MIPS_CONF_M;
446}
447
448static inline unsigned int decode_config2(struct cpuinfo_mips *c)
449{
450 unsigned int config2;
451
452 config2 = read_c0_config2();
453
454 if (config2 & MIPS_CONF2_SL)
455 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
456
457 return config2 & MIPS_CONF_M;
458}
459
460static inline unsigned int decode_config3(struct cpuinfo_mips *c)
461{
462 unsigned int config3;
463
464 config3 = read_c0_config3();
465
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500466 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100467 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500468 c->options |= MIPS_CPU_RIXI;
469 }
470 if (config3 & MIPS_CONF3_RXI)
471 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100472 if (config3 & MIPS_CONF3_DSP)
473 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500474 if (config3 & MIPS_CONF3_DSP2P)
475 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100476 if (config3 & MIPS_CONF3_VINT)
477 c->options |= MIPS_CPU_VINT;
478 if (config3 & MIPS_CONF3_VEIC)
479 c->options |= MIPS_CPU_VEIC;
480 if (config3 & MIPS_CONF3_MT)
481 c->ases |= MIPS_ASE_MIPSMT;
482 if (config3 & MIPS_CONF3_ULRI)
483 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000484 if (config3 & MIPS_CONF3_ISA)
485 c->options |= MIPS_CPU_MICROMIPS;
David Daney1e7decd2013-02-16 23:42:43 +0100486 if (config3 & MIPS_CONF3_VZ)
487 c->ases |= MIPS_ASE_VZ;
Steven J. Hill4a0156f2013-11-14 16:12:24 +0000488 if (config3 & MIPS_CONF3_SC)
489 c->options |= MIPS_CPU_SEGMENTS;
Paul Burtona5e9a692014-01-27 15:23:10 +0000490 if (config3 & MIPS_CONF3_MSA)
491 c->ases |= MIPS_ASE_MSA;
Markos Chandras3d528b32014-07-14 12:46:13 +0100492 /* Only tested on 32-bit cores */
Markos Chandrased4cbc82015-01-26 13:04:33 +0000493 if ((config3 & MIPS_CONF3_PW) && config_enabled(CONFIG_32BIT)) {
494 c->htw_seq = 0;
Markos Chandras3d528b32014-07-14 12:46:13 +0100495 c->options |= MIPS_CPU_HTW;
Markos Chandrased4cbc82015-01-26 13:04:33 +0000496 }
James Hogan9b3274b2015-02-02 11:45:08 +0000497 if (config3 & MIPS_CONF3_CDMM)
498 c->options |= MIPS_CPU_CDMM;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100499
500 return config3 & MIPS_CONF_M;
501}
502
503static inline unsigned int decode_config4(struct cpuinfo_mips *c)
504{
505 unsigned int config4;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000506 unsigned int newcf4;
507 unsigned int mmuextdef;
508 unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100509
510 config4 = read_c0_config4();
511
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000512 if (cpu_has_tlb) {
513 if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
514 c->options |= MIPS_CPU_TLBINV;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000515 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
516 switch (mmuextdef) {
517 case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:
518 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
519 c->tlbsizevtlb = c->tlbsize;
520 break;
521 case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT:
522 c->tlbsizevtlb +=
523 ((config4 & MIPS_CONF4_VTLBSIZEEXT) >>
524 MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40;
525 c->tlbsize = c->tlbsizevtlb;
526 ftlb_page = MIPS_CONF4_VFTLBPAGESIZE;
527 /* fall through */
528 case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT:
Markos Chandras97f4ad22014-08-29 09:37:26 +0100529 if (mips_ftlb_disabled)
530 break;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000531 newcf4 = (config4 & ~ftlb_page) |
532 (page_size_ftlb(mmuextdef) <<
533 MIPS_CONF4_FTLBPAGESIZE_SHIFT);
534 write_c0_config4(newcf4);
535 back_to_back_c0_hazard();
536 config4 = read_c0_config4();
537 if (config4 != newcf4) {
538 pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
539 PAGE_SIZE, config4);
540 /* Switch FTLB off */
541 set_ftlb_enable(c, 0);
542 break;
543 }
544 c->tlbsizeftlbsets = 1 <<
545 ((config4 & MIPS_CONF4_FTLBSETS) >>
546 MIPS_CONF4_FTLBSETS_SHIFT);
547 c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >>
548 MIPS_CONF4_FTLBWAYS_SHIFT) + 2;
549 c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets;
Markos Chandras97f4ad22014-08-29 09:37:26 +0100550 mips_has_ftlb_configured = 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000551 break;
552 }
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000553 }
554
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100555 c->kscratch_mask = (config4 >> 16) & 0xff;
556
557 return config4 & MIPS_CONF_M;
558}
559
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200560static inline unsigned int decode_config5(struct cpuinfo_mips *c)
561{
562 unsigned int config5;
563
564 config5 = read_c0_config5();
Paul Burtond175ed22014-09-11 08:30:19 +0100565 config5 &= ~(MIPS_CONF5_UFR | MIPS_CONF5_UFE);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200566 write_c0_config5(config5);
567
Markos Chandras49016742014-01-09 16:04:51 +0000568 if (config5 & MIPS_CONF5_EVA)
569 c->options |= MIPS_CPU_EVA;
Paul Burton1f6c52f2014-07-14 10:32:14 +0100570 if (config5 & MIPS_CONF5_MRP)
571 c->options |= MIPS_CPU_MAAR;
Markos Chandras5aed9da2014-12-02 09:46:19 +0000572 if (config5 & MIPS_CONF5_LLB)
573 c->options |= MIPS_CPU_RW_LLB;
Markos Chandras49016742014-01-09 16:04:51 +0000574
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200575 return config5 & MIPS_CONF_M;
576}
577
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000578static void decode_configs(struct cpuinfo_mips *c)
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100579{
580 int ok;
581
582 /* MIPS32 or MIPS64 compliant CPU. */
583 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
584 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
585
586 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
587
Markos Chandras97f4ad22014-08-29 09:37:26 +0100588 /* Enable FTLB if present and not disabled */
589 set_ftlb_enable(c, !mips_ftlb_disabled);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000590
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100591 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100592 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100593 if (ok)
594 ok = decode_config1(c);
595 if (ok)
596 ok = decode_config2(c);
597 if (ok)
598 ok = decode_config3(c);
599 if (ok)
600 ok = decode_config4(c);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200601 if (ok)
602 ok = decode_config5(c);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100603
604 mips_probe_watch_registers(c);
605
Leonid Yegoshin6575b1d2014-07-15 14:09:57 +0100606 if (cpu_has_rixi) {
607 /* Enable the RIXI exceptions */
Steven J. Hilla5770df2015-02-19 10:18:52 -0600608 set_c0_pagegrain(PG_IEC);
Leonid Yegoshin6575b1d2014-07-15 14:09:57 +0100609 back_to_back_c0_hazard();
610 /* Verify the IEC bit is set */
611 if (read_c0_pagegrain() & PG_IEC)
612 c->options |= MIPS_CPU_RIXIEX;
613 }
614
Paul Burton0ee958e2014-01-15 10:31:53 +0000615#ifndef CONFIG_MIPS_CPS
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000616 if (cpu_has_mips_r2_r6) {
David Daney45b585c2014-05-28 23:52:10 +0200617 c->core = get_ebase_cpunum();
Paul Burton30ee6152014-03-27 10:57:30 +0000618 if (cpu_has_mipsmt)
619 c->core >>= fls(core_nvpes()) - 1;
620 }
Paul Burton0ee958e2014-01-15 10:31:53 +0000621#endif
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100622}
623
Ralf Baechle02cf2112005-10-01 13:06:32 +0100624#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700625 | MIPS_CPU_COUNTER)
626
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000627static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100629 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 case PRID_IMP_R2000:
631 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000632 __cpu_name[cpu] = "R2000";
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100633 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100634 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500635 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 if (__cpu_has_fpu())
637 c->options |= MIPS_CPU_FPU;
638 c->tlbsize = 64;
639 break;
640 case PRID_IMP_R3000:
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100641 if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000642 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000644 __cpu_name[cpu] = "R3081";
645 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000647 __cpu_name[cpu] = "R3000A";
648 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000649 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000651 __cpu_name[cpu] = "R3000";
652 }
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100653 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100654 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500655 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 if (__cpu_has_fpu())
657 c->options |= MIPS_CPU_FPU;
658 c->tlbsize = 64;
659 break;
660 case PRID_IMP_R4000:
661 if (read_c0_config() & CONF_SC) {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100662 if ((c->processor_id & PRID_REV_MASK) >=
663 PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000665 __cpu_name[cpu] = "R4400PC";
666 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000668 __cpu_name[cpu] = "R4000PC";
669 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100671 int cca = read_c0_config() & CONF_CM_CMASK;
672 int mc;
673
674 /*
675 * SC and MC versions can't be reliably told apart,
676 * but only the latter support coherent caching
677 * modes so assume the firmware has set the KSEG0
678 * coherency attribute reasonably (if uncached, we
679 * assume SC).
680 */
681 switch (cca) {
682 case CONF_CM_CACHABLE_CE:
683 case CONF_CM_CACHABLE_COW:
684 case CONF_CM_CACHABLE_CUW:
685 mc = 1;
686 break;
687 default:
688 mc = 0;
689 break;
690 }
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100691 if ((c->processor_id & PRID_REV_MASK) >=
692 PRID_REV_R4400) {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100693 c->cputype = mc ? CPU_R4400MC : CPU_R4400SC;
694 __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000695 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100696 c->cputype = mc ? CPU_R4000MC : CPU_R4000SC;
697 __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000698 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700699 }
700
Steven J. Hilla96102b2012-12-07 04:31:36 +0000701 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100702 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700703 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500704 MIPS_CPU_WATCH | MIPS_CPU_VCE |
705 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 c->tlbsize = 48;
707 break;
708 case PRID_IMP_VR41XX:
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900709 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100710 c->fpu_msk31 |= FPU_CSR_CONDX;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900711 c->options = R4K_OPTS;
712 c->tlbsize = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700713 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 case PRID_REV_VR4111:
715 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000716 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700717 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 case PRID_REV_VR4121:
719 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000720 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 break;
722 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000723 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000725 __cpu_name[cpu] = "NEC VR4122";
726 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700727 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000728 __cpu_name[cpu] = "NEC VR4181A";
729 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700730 break;
731 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000732 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000734 __cpu_name[cpu] = "NEC VR4131";
735 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700736 c->cputype = CPU_VR4133;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900737 c->options |= MIPS_CPU_LLSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000738 __cpu_name[cpu] = "NEC VR4133";
739 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700740 break;
741 default:
742 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
743 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000744 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700745 break;
746 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 break;
748 case PRID_IMP_R4300:
749 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000750 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000751 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100752 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500754 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 c->tlbsize = 32;
756 break;
757 case PRID_IMP_R4600:
758 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000759 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000760 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100761 c->fpu_msk31 |= FPU_CSR_CONDX;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000762 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
763 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764 c->tlbsize = 48;
765 break;
766 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500767 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 /*
769 * This processor doesn't have an MMU, so it's not
770 * "real easy" to run Linux on it. It is left purely
771 * for documentation. Commented out because it shares
772 * it's c0_prid id number with the TX3900.
773 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000774 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000775 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000776 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100777 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500779 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 break;
781 #endif
782 case PRID_IMP_TX39:
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100783 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100784 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785
786 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
787 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000788 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 c->tlbsize = 64;
790 } else {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100791 switch (c->processor_id & PRID_REV_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 case PRID_REV_TX3912:
793 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000794 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 c->tlbsize = 32;
796 break;
797 case PRID_REV_TX3922:
798 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000799 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 c->tlbsize = 64;
801 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 }
803 }
804 break;
805 case PRID_IMP_R4700:
806 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000807 __cpu_name[cpu] = "R4700";
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_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500811 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 c->tlbsize = 48;
813 break;
814 case PRID_IMP_TX49:
815 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000816 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000817 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100818 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 c->options = R4K_OPTS | MIPS_CPU_LLSC;
820 if (!(c->processor_id & 0x08))
821 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
822 c->tlbsize = 48;
823 break;
824 case PRID_IMP_R5000:
825 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000826 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000827 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500829 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700830 c->tlbsize = 48;
831 break;
832 case PRID_IMP_R5432:
833 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000834 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000835 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500837 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838 c->tlbsize = 48;
839 break;
840 case PRID_IMP_R5500:
841 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000842 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000843 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500845 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 c->tlbsize = 48;
847 break;
848 case PRID_IMP_NEVADA:
849 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000850 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000851 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500853 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700854 c->tlbsize = 48;
855 break;
856 case PRID_IMP_R6000:
857 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000858 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000859 set_isa(c, MIPS_CPU_ISA_II);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100860 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500862 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863 c->tlbsize = 32;
864 break;
865 case PRID_IMP_R6000A:
866 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000867 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000868 set_isa(c, MIPS_CPU_ISA_II);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100869 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500871 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 c->tlbsize = 32;
873 break;
874 case PRID_IMP_RM7000:
875 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000876 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000877 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500879 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700880 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100881 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 * the RM7000 v2.0 indicates if the TLB has 48 or 64
883 * entries.
884 *
Ralf Baechle70342282013-01-22 12:59:30 +0100885 * 29 1 => 64 entry JTLB
886 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 */
888 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
889 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890 case PRID_IMP_R8000:
891 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000892 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000893 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500895 MIPS_CPU_FPU | MIPS_CPU_32FPR |
896 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700897 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
898 break;
899 case PRID_IMP_R10000:
900 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000901 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000902 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000903 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500904 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500906 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 c->tlbsize = 64;
908 break;
909 case PRID_IMP_R12000:
910 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000911 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000912 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000913 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500914 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500916 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917 c->tlbsize = 64;
918 break;
Kumba44d921b2006-05-16 22:23:59 -0400919 case PRID_IMP_R14000:
Joshua Kinard30577392015-01-21 07:59:45 -0500920 if (((c->processor_id >> 4) & 0x0f) > 2) {
921 c->cputype = CPU_R16000;
922 __cpu_name[cpu] = "R16000";
923 } else {
924 c->cputype = CPU_R14000;
925 __cpu_name[cpu] = "R14000";
926 }
Steven J. Hilla96102b2012-12-07 04:31:36 +0000927 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400928 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500929 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400930 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500931 MIPS_CPU_LLSC;
Kumba44d921b2006-05-16 22:23:59 -0400932 c->tlbsize = 64;
933 break;
Huacai Chen26859192014-02-16 16:01:18 +0800934 case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */
Robert Millan5aac1e82011-04-16 11:29:29 -0700935 switch (c->processor_id & PRID_REV_MASK) {
936 case PRID_REV_LOONGSON2E:
Huacai Chenc579d312014-03-21 18:44:00 +0800937 c->cputype = CPU_LOONGSON2;
938 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700939 set_elf_platform(cpu, "loongson2e");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800940 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100941 c->fpu_msk31 |= FPU_CSR_CONDX;
Robert Millan5aac1e82011-04-16 11:29:29 -0700942 break;
943 case PRID_REV_LOONGSON2F:
Huacai Chenc579d312014-03-21 18:44:00 +0800944 c->cputype = CPU_LOONGSON2;
945 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700946 set_elf_platform(cpu, "loongson2f");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800947 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100948 c->fpu_msk31 |= FPU_CSR_CONDX;
Robert Millan5aac1e82011-04-16 11:29:29 -0700949 break;
Huacai Chenc579d312014-03-21 18:44:00 +0800950 case PRID_REV_LOONGSON3A:
951 c->cputype = CPU_LOONGSON3;
952 __cpu_name[cpu] = "ICT Loongson-3";
953 set_elf_platform(cpu, "loongson3a");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800954 set_isa(c, MIPS_CPU_ISA_M64R1);
Huacai Chenc579d312014-03-21 18:44:00 +0800955 break;
Huacai Chene7841be2014-06-26 11:41:30 +0800956 case PRID_REV_LOONGSON3B_R1:
957 case PRID_REV_LOONGSON3B_R2:
958 c->cputype = CPU_LOONGSON3;
959 __cpu_name[cpu] = "ICT Loongson-3";
960 set_elf_platform(cpu, "loongson3b");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800961 set_isa(c, MIPS_CPU_ISA_M64R1);
Huacai Chene7841be2014-06-26 11:41:30 +0800962 break;
Robert Millan5aac1e82011-04-16 11:29:29 -0700963 }
964
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800965 c->options = R4K_OPTS |
966 MIPS_CPU_FPU | MIPS_CPU_LLSC |
967 MIPS_CPU_32FPR;
968 c->tlbsize = 64;
Huacai Chencc94ea32014-11-04 14:13:22 +0800969 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800970 break;
Huacai Chen26859192014-02-16 16:01:18 +0800971 case PRID_IMP_LOONGSON_32: /* Loongson-1 */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100972 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100974 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000975
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100976 switch (c->processor_id & PRID_REV_MASK) {
977 case PRID_REV_LOONGSON1B:
978 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +0000979 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000980 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100981
Ralf Baechle41943182005-05-05 16:45:59 +0000982 break;
Ralf Baechle41943182005-05-05 16:45:59 +0000983 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700984}
985
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000986static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700987{
Markos Chandras4f12b912014-07-18 10:51:32 +0100988 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100989 switch (c->processor_id & PRID_IMP_MASK) {
Leonid Yegoshinb2498af2014-11-24 12:59:44 +0000990 case PRID_IMP_QEMU_GENERIC:
991 c->writecombine = _CACHE_UNCACHED;
992 c->cputype = CPU_QEMU_GENERIC;
993 __cpu_name[cpu] = "MIPS GENERIC QEMU";
994 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700995 case PRID_IMP_4KC:
996 c->cputype = CPU_4KC;
Markos Chandras4f12b912014-07-18 10:51:32 +0100997 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000998 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700999 break;
1000 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +00001001 case PRID_IMP_4KECR2:
1002 c->cputype = CPU_4KEC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001003 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001004 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +00001005 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +01001007 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008 c->cputype = CPU_4KSC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001009 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001010 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011 break;
1012 case PRID_IMP_5KC:
1013 c->cputype = CPU_5KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001014 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001015 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001016 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +02001017 case PRID_IMP_5KE:
1018 c->cputype = CPU_5KE;
Markos Chandras4f12b912014-07-18 10:51:32 +01001019 c->writecombine = _CACHE_UNCACHED;
Leonid Yegoshin78d48032012-07-06 21:56:01 +02001020 __cpu_name[cpu] = "MIPS 5KE";
1021 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001022 case PRID_IMP_20KC:
1023 c->cputype = CPU_20KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001024 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001025 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001026 break;
1027 case PRID_IMP_24K:
1028 c->cputype = CPU_24K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001029 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001030 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001031 break;
John Crispin42f3cae2013-01-11 22:44:10 +01001032 case PRID_IMP_24KE:
1033 c->cputype = CPU_24K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001034 c->writecombine = _CACHE_UNCACHED;
John Crispin42f3cae2013-01-11 22:44:10 +01001035 __cpu_name[cpu] = "MIPS 24KEc";
1036 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037 case PRID_IMP_25KF:
1038 c->cputype = CPU_25KF;
Markos Chandras4f12b912014-07-18 10:51:32 +01001039 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001040 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +00001042 case PRID_IMP_34K:
1043 c->cputype = CPU_34K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001044 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001045 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +00001046 break;
Chris Dearmanc6209532006-05-02 14:08:46 +01001047 case PRID_IMP_74K:
1048 c->cputype = CPU_74K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001049 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001050 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +01001051 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +02001052 case PRID_IMP_M14KC:
1053 c->cputype = CPU_M14KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001054 c->writecombine = _CACHE_UNCACHED;
Steven J. Hill113c62d2012-07-06 23:56:00 +02001055 __cpu_name[cpu] = "MIPS M14Kc";
1056 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +00001057 case PRID_IMP_M14KEC:
1058 c->cputype = CPU_M14KEC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001059 c->writecombine = _CACHE_UNCACHED;
Steven J. Hillf8fa4812012-12-07 03:51:35 +00001060 __cpu_name[cpu] = "MIPS M14KEc";
1061 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +01001062 case PRID_IMP_1004K:
1063 c->cputype = CPU_1004K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001064 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001065 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +01001066 break;
Steven J. Hill006a8512012-06-26 04:11:03 +00001067 case PRID_IMP_1074K:
Steven J. Hill442e14a2014-01-17 15:03:50 -06001068 c->cputype = CPU_1074K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001069 c->writecombine = _CACHE_UNCACHED;
Steven J. Hill006a8512012-06-26 04:11:03 +00001070 __cpu_name[cpu] = "MIPS 1074Kc";
1071 break;
Leonid Yegoshinb5f065e2013-11-20 10:46:02 +00001072 case PRID_IMP_INTERAPTIV_UP:
1073 c->cputype = CPU_INTERAPTIV;
1074 __cpu_name[cpu] = "MIPS interAptiv";
1075 break;
1076 case PRID_IMP_INTERAPTIV_MP:
1077 c->cputype = CPU_INTERAPTIV;
1078 __cpu_name[cpu] = "MIPS interAptiv (multi)";
1079 break;
Leonid Yegoshinb0d4d302013-11-14 16:12:28 +00001080 case PRID_IMP_PROAPTIV_UP:
1081 c->cputype = CPU_PROAPTIV;
1082 __cpu_name[cpu] = "MIPS proAptiv";
1083 break;
1084 case PRID_IMP_PROAPTIV_MP:
1085 c->cputype = CPU_PROAPTIV;
1086 __cpu_name[cpu] = "MIPS proAptiv (multi)";
1087 break;
James Hogan829dcc02014-01-22 16:19:39 +00001088 case PRID_IMP_P5600:
1089 c->cputype = CPU_P5600;
1090 __cpu_name[cpu] = "MIPS P5600";
1091 break;
Leonid Yegoshin9943ed92014-03-04 13:34:44 +00001092 case PRID_IMP_M5150:
1093 c->cputype = CPU_M5150;
1094 __cpu_name[cpu] = "MIPS M5150";
1095 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096 }
Chris Dearman0b6d4972007-09-13 12:32:02 +01001097
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +00001098 decode_configs(c);
1099
Chris Dearman0b6d4972007-09-13 12:32:02 +01001100 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101}
1102
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001103static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104{
Ralf Baechle41943182005-05-05 16:45:59 +00001105 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001106 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001107 case PRID_IMP_AU1_REV1:
1108 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +01001109 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001110 switch ((c->processor_id >> 24) & 0xff) {
1111 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001112 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001113 break;
1114 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001115 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001116 break;
1117 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001118 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001119 break;
1120 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001121 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122 break;
Pete Popove3ad1c22005-03-01 06:33:16 +00001123 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001124 __cpu_name[cpu] = "Au1200";
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001125 if ((c->processor_id & PRID_REV_MASK) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001126 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +01001127 break;
1128 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001129 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +00001130 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131 default:
Manuel Lauss270717a2009-03-25 17:49:28 +01001132 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001133 break;
1134 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 break;
1136 }
1137}
1138
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001139static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140{
Ralf Baechle41943182005-05-05 16:45:59 +00001141 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +01001142
Markos Chandras4f12b912014-07-18 10:51:32 +01001143 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001144 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 case PRID_IMP_SB1:
1146 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001147 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 /* FPU in pass1 is known to have issues. */
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001149 if ((c->processor_id & PRID_REV_MASK) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +00001150 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -07001152 case PRID_IMP_SB1A:
1153 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001154 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -07001155 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 }
1157}
1158
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001159static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001160{
Ralf Baechle41943182005-05-05 16:45:59 +00001161 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001162 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 case PRID_IMP_SR71000:
1164 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001165 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001166 c->scache.ways = 8;
1167 c->tlbsize = 64;
1168 break;
1169 }
1170}
1171
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001172static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +00001173{
1174 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001175 switch (c->processor_id & PRID_IMP_MASK) {
Pete Popovbdf21b12005-07-14 17:47:57 +00001176 case PRID_IMP_PR4450:
1177 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001178 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +00001179 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +00001180 break;
Pete Popovbdf21b12005-07-14 17:47:57 +00001181 }
1182}
1183
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001184static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001185{
1186 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001187 switch (c->processor_id & PRID_IMP_MASK) {
Kevin Cernekee190fca32010-11-23 10:26:45 -08001188 case PRID_IMP_BMIPS32_REV4:
1189 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -07001190 c->cputype = CPU_BMIPS32;
1191 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001192 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001193 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001194 case PRID_IMP_BMIPS3300:
1195 case PRID_IMP_BMIPS3300_ALT:
1196 case PRID_IMP_BMIPS3300_BUG:
1197 c->cputype = CPU_BMIPS3300;
1198 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001199 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001200 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001201 case PRID_IMP_BMIPS43XX: {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001202 int rev = c->processor_id & PRID_REV_MASK;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001203
1204 if (rev >= PRID_REV_BMIPS4380_LO &&
1205 rev <= PRID_REV_BMIPS4380_HI) {
1206 c->cputype = CPU_BMIPS4380;
1207 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001208 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001209 } else {
1210 c->cputype = CPU_BMIPS4350;
1211 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001212 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +01001213 }
1214 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001215 }
Kevin Cernekee602977b2010-10-16 14:22:30 -07001216 case PRID_IMP_BMIPS5000:
Kevin Cernekee68e6a782014-10-20 21:28:01 -07001217 case PRID_IMP_BMIPS5200:
Kevin Cernekee602977b2010-10-16 14:22:30 -07001218 c->cputype = CPU_BMIPS5000;
1219 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001220 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001221 c->options |= MIPS_CPU_ULRI;
1222 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001223 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001224}
1225
David Daney0dd47812008-12-11 15:33:26 -08001226static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
1227{
1228 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001229 switch (c->processor_id & PRID_IMP_MASK) {
David Daney0dd47812008-12-11 15:33:26 -08001230 case PRID_IMP_CAVIUM_CN38XX:
1231 case PRID_IMP_CAVIUM_CN31XX:
1232 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -08001233 c->cputype = CPU_CAVIUM_OCTEON;
1234 __cpu_name[cpu] = "Cavium Octeon";
1235 goto platform;
David Daney0dd47812008-12-11 15:33:26 -08001236 case PRID_IMP_CAVIUM_CN58XX:
1237 case PRID_IMP_CAVIUM_CN56XX:
1238 case PRID_IMP_CAVIUM_CN50XX:
1239 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -08001240 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
1241 __cpu_name[cpu] = "Cavium Octeon+";
1242platform:
Robert Millanc094c992011-04-18 11:37:55 -07001243 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -08001244 break;
David Daneya1431b62011-09-24 02:29:54 +02001245 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -07001246 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +02001247 case PRID_IMP_CAVIUM_CN66XX:
1248 case PRID_IMP_CAVIUM_CN68XX:
David Daneyaf04bb82013-07-29 15:07:01 -07001249 case PRID_IMP_CAVIUM_CNF71XX:
David Daney0e56b382010-10-07 16:03:45 -07001250 c->cputype = CPU_CAVIUM_OCTEON2;
1251 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001252 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001253 break;
David Daneyaf04bb82013-07-29 15:07:01 -07001254 case PRID_IMP_CAVIUM_CN70XX:
1255 case PRID_IMP_CAVIUM_CN78XX:
1256 c->cputype = CPU_CAVIUM_OCTEON3;
1257 __cpu_name[cpu] = "Cavium Octeon III";
1258 set_elf_platform(cpu, "octeon3");
1259 break;
David Daney0dd47812008-12-11 15:33:26 -08001260 default:
1261 printk(KERN_INFO "Unknown Octeon chip!\n");
1262 c->cputype = CPU_UNKNOWN;
1263 break;
1264 }
1265}
1266
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001267static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1268{
1269 decode_configs(c);
1270 /* JZRISC does not implement the CP0 counter. */
1271 c->options &= ~MIPS_CPU_COUNTER;
Maciej W. Rozycki06947aa2014-04-06 21:31:29 +01001272 BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001273 switch (c->processor_id & PRID_IMP_MASK) {
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001274 case PRID_IMP_JZRISC:
1275 c->cputype = CPU_JZRISC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001276 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001277 __cpu_name[cpu] = "Ingenic JZRISC";
1278 break;
1279 default:
1280 panic("Unknown Ingenic Processor ID!");
1281 break;
1282 }
1283}
1284
Jayachandran Ca7117c62011-05-11 12:04:58 +05301285static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1286{
1287 decode_configs(c);
1288
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001289 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
Manuel Lauss809f36c2011-11-01 20:03:30 +01001290 c->cputype = CPU_ALCHEMY;
1291 __cpu_name[cpu] = "Au1300";
1292 /* following stuff is not for Alchemy */
1293 return;
1294 }
1295
Ralf Baechle70342282013-01-22 12:59:30 +01001296 c->options = (MIPS_CPU_TLB |
1297 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301298 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +01001299 MIPS_CPU_DIVEC |
1300 MIPS_CPU_WATCH |
1301 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301302 MIPS_CPU_LLSC);
1303
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001304 switch (c->processor_id & PRID_IMP_MASK) {
Jayachandran C4ca86a22013-08-11 14:43:54 +05301305 case PRID_IMP_NETLOGIC_XLP2XX:
Jayachandran C8907c552013-12-21 16:52:20 +05301306 case PRID_IMP_NETLOGIC_XLP9XX:
Yonghong Song1c983982014-04-29 20:07:53 +05301307 case PRID_IMP_NETLOGIC_XLP5XX:
Jayachandran C4ca86a22013-08-11 14:43:54 +05301308 c->cputype = CPU_XLP;
1309 __cpu_name[cpu] = "Broadcom XLPII";
1310 break;
1311
Jayachandran C2aa54b22011-11-16 00:21:29 +00001312 case PRID_IMP_NETLOGIC_XLP8XX:
1313 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001314 c->cputype = CPU_XLP;
1315 __cpu_name[cpu] = "Netlogic XLP";
1316 break;
1317
Jayachandran Ca7117c62011-05-11 12:04:58 +05301318 case PRID_IMP_NETLOGIC_XLR732:
1319 case PRID_IMP_NETLOGIC_XLR716:
1320 case PRID_IMP_NETLOGIC_XLR532:
1321 case PRID_IMP_NETLOGIC_XLR308:
1322 case PRID_IMP_NETLOGIC_XLR532C:
1323 case PRID_IMP_NETLOGIC_XLR516C:
1324 case PRID_IMP_NETLOGIC_XLR508C:
1325 case PRID_IMP_NETLOGIC_XLR308C:
1326 c->cputype = CPU_XLR;
1327 __cpu_name[cpu] = "Netlogic XLR";
1328 break;
1329
1330 case PRID_IMP_NETLOGIC_XLS608:
1331 case PRID_IMP_NETLOGIC_XLS408:
1332 case PRID_IMP_NETLOGIC_XLS404:
1333 case PRID_IMP_NETLOGIC_XLS208:
1334 case PRID_IMP_NETLOGIC_XLS204:
1335 case PRID_IMP_NETLOGIC_XLS108:
1336 case PRID_IMP_NETLOGIC_XLS104:
1337 case PRID_IMP_NETLOGIC_XLS616B:
1338 case PRID_IMP_NETLOGIC_XLS608B:
1339 case PRID_IMP_NETLOGIC_XLS416B:
1340 case PRID_IMP_NETLOGIC_XLS412B:
1341 case PRID_IMP_NETLOGIC_XLS408B:
1342 case PRID_IMP_NETLOGIC_XLS404B:
1343 c->cputype = CPU_XLR;
1344 __cpu_name[cpu] = "Netlogic XLS";
1345 break;
1346
1347 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001348 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301349 c->processor_id);
1350 c->cputype = CPU_XLR;
1351 break;
1352 }
1353
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001354 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001355 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001356 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1357 /* This will be updated again after all threads are woken up */
1358 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1359 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001360 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001361 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1362 }
Jayachandran C7777b932013-06-11 14:41:35 +00001363 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301364}
1365
David Daney949e51b2010-10-14 11:32:33 -07001366#ifdef CONFIG_64BIT
1367/* For use by uaccess.h */
1368u64 __ua_limit;
1369EXPORT_SYMBOL(__ua_limit);
1370#endif
1371
Ralf Baechle9966db252007-10-11 23:46:17 +01001372const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001373const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001374
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001375void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001376{
1377 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001378 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001379
Ralf Baechle70342282013-01-22 12:59:30 +01001380 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001381 c->fpu_id = FPIR_IMP_NONE;
1382 c->cputype = CPU_UNKNOWN;
Markos Chandras4f12b912014-07-18 10:51:32 +01001383 c->writecombine = _CACHE_UNCACHED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001384
Maciej W. Rozycki9b266162015-04-03 23:27:48 +01001385 c->fpu_csr31 = FPU_CSR_RN;
1386 c->fpu_msk31 = FPU_CSR_RSVD | FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
1387
Linus Torvalds1da177e2005-04-16 15:20:36 -07001388 c->processor_id = read_c0_prid();
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001389 switch (c->processor_id & PRID_COMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001390 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001391 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001392 break;
1393 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001394 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001395 break;
1396 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001397 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001398 break;
1399 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001400 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001401 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001402 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001403 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001404 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001406 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001407 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001408 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001409 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001410 break;
David Daney0dd47812008-12-11 15:33:26 -08001411 case PRID_COMP_CAVIUM:
1412 cpu_probe_cavium(c, cpu);
1413 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001414 case PRID_COMP_INGENIC:
1415 cpu_probe_ingenic(c, cpu);
1416 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301417 case PRID_COMP_NETLOGIC:
1418 cpu_probe_netlogic(c, cpu);
1419 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001420 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001421
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001422 BUG_ON(!__cpu_name[cpu]);
1423 BUG_ON(c->cputype == CPU_UNKNOWN);
1424
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001425 /*
1426 * Platform code can force the cpu type to optimize code
1427 * generation. In that case be sure the cpu type is correctly
1428 * manually setup otherwise it could trigger some nasty bugs.
1429 */
1430 BUG_ON(current_cpu_type() != c->cputype);
1431
Kevin Cernekee0103d232010-05-02 14:43:52 -07001432 if (mips_fpu_disabled)
1433 c->options &= ~MIPS_CPU_FPU;
1434
1435 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001436 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001437
Markos Chandras3d528b32014-07-14 12:46:13 +01001438 if (mips_htw_disabled) {
1439 c->options &= ~MIPS_CPU_HTW;
1440 write_c0_pwctl(read_c0_pwctl() &
1441 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
1442 }
1443
Ralf Baechle41943182005-05-05 16:45:59 +00001444 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445 c->fpu_id = cpu_get_fpu_id();
Maciej W. Rozycki9b266162015-04-03 23:27:48 +01001446 mips_nofpu_msk31 = c->fpu_msk31;
Ralf Baechle41943182005-05-05 16:45:59 +00001447
Maciej W. Rozycki9cb60e22015-04-03 23:27:21 +01001448 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
1449 MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
1450 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
Ralf Baechle41943182005-05-05 16:45:59 +00001451 if (c->fpu_id & MIPS_FPIR_3D)
1452 c->ases |= MIPS_ASE_MIPS3D;
Paul Burtonadac5d52014-09-11 08:30:18 +01001453 if (c->fpu_id & MIPS_FPIR_FREP)
1454 c->options |= MIPS_CPU_FRE;
Ralf Baechle41943182005-05-05 16:45:59 +00001455 }
Maciej W. Rozycki9b266162015-04-03 23:27:48 +01001456
1457 cpu_set_fpu_fcsr_mask(c);
Maciej W. Rozyckif6843622015-04-03 23:27:26 +01001458 } else
1459 cpu_set_nofpu_id(c);
Ralf Baechle9966db252007-10-11 23:46:17 +01001460
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +00001461 if (cpu_has_mips_r2_r6) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001462 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001463 /* R2 has Performance Counter Interrupt indicator */
1464 c->options |= MIPS_CPU_PCI;
1465 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001466 else
1467 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001468
Paul Burtona8ad1362014-01-28 14:28:43 +00001469 if (cpu_has_msa) {
Paul Burtona5e9a692014-01-27 15:23:10 +00001470 c->msa_id = cpu_get_msa_id();
Paul Burtona8ad1362014-01-28 14:28:43 +00001471 WARN(c->msa_id & MSA_IR_WRPF,
1472 "Vector register partitioning unimplemented!");
1473 }
Paul Burtona5e9a692014-01-27 15:23:10 +00001474
Guenter Roeck91dfc422010-02-02 08:52:20 -08001475 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001476
1477#ifdef CONFIG_64BIT
1478 if (cpu == 0)
1479 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1480#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001481}
1482
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001483void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001484{
1485 struct cpuinfo_mips *c = &current_cpu_data;
1486
Leonid Yegoshind9f897c2013-10-07 10:43:32 +01001487 pr_info("CPU%d revision is: %08x (%s)\n",
1488 smp_processor_id(), c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001489 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001490 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Paul Burtona5e9a692014-01-27 15:23:10 +00001491 if (cpu_has_msa)
1492 pr_info("MSA revision is: %08x\n", c->msa_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001493}