blob: 937e6534b8a0415cf3ae315b6914a677b02bf32d [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
Paul Burtone14f1db2015-07-27 12:58:23 -070035/* Hardware capabilities */
36unsigned int elf_hwcap __read_mostly;
37
Maciej W. Rozyckif6843622015-04-03 23:27:26 +010038/*
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +010039 * Get the FPU Implementation/Revision.
40 */
41static inline unsigned long cpu_get_fpu_id(void)
42{
43 unsigned long tmp, fpu_id;
44
45 tmp = read_c0_status();
46 __enable_fpu(FPU_AS_IS);
47 fpu_id = read_32bit_cp1_register(CP1_REVISION);
48 write_c0_status(tmp);
49 return fpu_id;
50}
51
52/*
53 * Check if the CPU has an external FPU.
54 */
55static inline int __cpu_has_fpu(void)
56{
57 return (cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE;
58}
59
60static inline unsigned long cpu_get_msa_id(void)
61{
62 unsigned long status, msa_id;
63
64 status = read_c0_status();
65 __enable_fpu(FPU_64BIT);
66 enable_msa();
67 msa_id = read_msa_ir();
68 disable_msa();
69 write_c0_status(status);
70 return msa_id;
71}
72
73/*
Maciej W. Rozycki9b266162015-04-03 23:27:48 +010074 * Determine the FCSR mask for FPU hardware.
75 */
76static inline void cpu_set_fpu_fcsr_mask(struct cpuinfo_mips *c)
77{
78 unsigned long sr, mask, fcsr, fcsr0, fcsr1;
79
Maciej W. Rozycki90b712d2015-06-02 17:50:59 +010080 fcsr = c->fpu_csr31;
Maciej W. Rozycki9b266162015-04-03 23:27:48 +010081 mask = FPU_CSR_ALL_X | FPU_CSR_ALL_E | FPU_CSR_ALL_S | FPU_CSR_RM;
82
83 sr = read_c0_status();
84 __enable_fpu(FPU_AS_IS);
85
Maciej W. Rozycki9b266162015-04-03 23:27:48 +010086 fcsr0 = fcsr & mask;
87 write_32bit_cp1_register(CP1_STATUS, fcsr0);
88 fcsr0 = read_32bit_cp1_register(CP1_STATUS);
89
90 fcsr1 = fcsr | ~mask;
91 write_32bit_cp1_register(CP1_STATUS, fcsr1);
92 fcsr1 = read_32bit_cp1_register(CP1_STATUS);
93
94 write_32bit_cp1_register(CP1_STATUS, fcsr);
95
96 write_c0_status(sr);
97
98 c->fpu_msk31 = ~(fcsr0 ^ fcsr1) & ~mask;
99}
100
101/*
Maciej W. Rozyckif6843622015-04-03 23:27:26 +0100102 * Set the FIR feature flags for the FPU emulator.
103 */
104static void cpu_set_nofpu_id(struct cpuinfo_mips *c)
105{
106 u32 value;
107
108 value = 0;
109 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
110 MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
111 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6))
112 value |= MIPS_FPIR_D | MIPS_FPIR_S;
113 if (c->isa_level & (MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
114 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6))
115 value |= MIPS_FPIR_F64 | MIPS_FPIR_L | MIPS_FPIR_W;
Maciej W. Rozycki90d53a92015-11-13 00:47:28 +0000116 if (c->options & MIPS_CPU_NAN_2008)
117 value |= MIPS_FPIR_HAS2008;
Maciej W. Rozyckif6843622015-04-03 23:27:26 +0100118 c->fpu_id = value;
119}
120
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100121/* Determined FPU emulator mask to use for the boot CPU with "nofpu". */
122static unsigned int mips_nofpu_msk31;
123
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +0100124/*
125 * Set options for FPU hardware.
126 */
127static void cpu_set_fpu_opts(struct cpuinfo_mips *c)
128{
129 c->fpu_id = cpu_get_fpu_id();
130 mips_nofpu_msk31 = c->fpu_msk31;
131
132 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
133 MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
134 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
135 if (c->fpu_id & MIPS_FPIR_3D)
136 c->ases |= MIPS_ASE_MIPS3D;
137 if (c->fpu_id & MIPS_FPIR_FREP)
138 c->options |= MIPS_CPU_FRE;
139 }
140
141 cpu_set_fpu_fcsr_mask(c);
Maciej W. Rozycki9519ef32015-11-13 00:46:55 +0000142 c->options |= MIPS_CPU_NAN_LEGACY;
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +0100143}
144
145/*
146 * Set options for the FPU emulator.
147 */
148static void cpu_set_nofpu_opts(struct cpuinfo_mips *c)
149{
150 c->options &= ~MIPS_CPU_FPU;
151 c->fpu_msk31 = mips_nofpu_msk31;
152
Maciej W. Rozycki9519ef32015-11-13 00:46:55 +0000153 c->options |= MIPS_CPU_NAN_LEGACY;
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +0100154 cpu_set_nofpu_id(c);
155}
156
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000157static int mips_fpu_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -0700158
159static int __init fpu_disable(char *s)
160{
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +0100161 cpu_set_nofpu_opts(&boot_cpu_data);
Kevin Cernekee0103d232010-05-02 14:43:52 -0700162 mips_fpu_disabled = 1;
163
164 return 1;
165}
166
167__setup("nofpu", fpu_disable);
168
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000169int mips_dsp_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -0700170
171static int __init dsp_disable(char *s)
172{
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500173 cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -0700174 mips_dsp_disabled = 1;
175
176 return 1;
177}
178
179__setup("nodsp", dsp_disable);
180
Markos Chandras3d528b32014-07-14 12:46:13 +0100181static int mips_htw_disabled;
182
183static int __init htw_disable(char *s)
184{
185 mips_htw_disabled = 1;
186 cpu_data[0].options &= ~MIPS_CPU_HTW;
187 write_c0_pwctl(read_c0_pwctl() &
188 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
189
190 return 1;
191}
192
193__setup("nohtw", htw_disable);
194
Markos Chandras97f4ad22014-08-29 09:37:26 +0100195static int mips_ftlb_disabled;
196static int mips_has_ftlb_configured;
197
Markos Chandras912708c2015-07-09 10:40:51 +0100198static int set_ftlb_enable(struct cpuinfo_mips *c, int enable);
Markos Chandras97f4ad22014-08-29 09:37:26 +0100199
200static int __init ftlb_disable(char *s)
201{
202 unsigned int config4, mmuextdef;
203
204 /*
205 * If the core hasn't done any FTLB configuration, there is nothing
206 * for us to do here.
207 */
208 if (!mips_has_ftlb_configured)
209 return 1;
210
211 /* Disable it in the boot cpu */
Markos Chandras912708c2015-07-09 10:40:51 +0100212 if (set_ftlb_enable(&cpu_data[0], 0)) {
213 pr_warn("Can't turn FTLB off\n");
214 return 1;
215 }
Markos Chandras97f4ad22014-08-29 09:37:26 +0100216
217 back_to_back_c0_hazard();
218
219 config4 = read_c0_config4();
220
221 /* Check that FTLB has been disabled */
222 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
223 /* MMUSIZEEXT == VTLB ON, FTLB OFF */
224 if (mmuextdef == MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT) {
225 /* This should never happen */
226 pr_warn("FTLB could not be disabled!\n");
227 return 1;
228 }
229
230 mips_ftlb_disabled = 1;
231 mips_has_ftlb_configured = 0;
232
233 /*
234 * noftlb is mainly used for debug purposes so print
235 * an informative message instead of using pr_debug()
236 */
237 pr_info("FTLB has been disabled\n");
238
239 /*
240 * Some of these bits are duplicated in the decode_config4.
241 * MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT is the only possible case
242 * once FTLB has been disabled so undo what decode_config4 did.
243 */
244 cpu_data[0].tlbsize -= cpu_data[0].tlbsizeftlbways *
245 cpu_data[0].tlbsizeftlbsets;
246 cpu_data[0].tlbsizeftlbsets = 0;
247 cpu_data[0].tlbsizeftlbways = 0;
248
249 return 1;
250}
251
252__setup("noftlb", ftlb_disable);
253
254
Marc St-Jean9267a302007-06-14 15:55:31 -0600255static inline void check_errata(void)
256{
257 struct cpuinfo_mips *c = &current_cpu_data;
258
Ralf Baechle69f24d12013-09-17 10:25:47 +0200259 switch (current_cpu_type()) {
Marc St-Jean9267a302007-06-14 15:55:31 -0600260 case CPU_34K:
261 /*
262 * Erratum "RPS May Cause Incorrect Instruction Execution"
Ralf Baechleb633648c52014-05-23 16:29:44 +0200263 * This code only handles VPE0, any SMP/RTOS code
Marc St-Jean9267a302007-06-14 15:55:31 -0600264 * making use of VPE1 will be responsable for that VPE.
265 */
266 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
267 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
268 break;
269 default:
270 break;
271 }
272}
273
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274void __init check_bugs32(void)
275{
Marc St-Jean9267a302007-06-14 15:55:31 -0600276 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277}
278
279/*
280 * Probe whether cpu has config register by trying to play with
281 * alternate cache bit and see whether it matters.
282 * It's used by cpu_probe to distinguish between R3000A and R3081.
283 */
284static inline int cpu_has_confreg(void)
285{
286#ifdef CONFIG_CPU_R3000
287 extern unsigned long r3k_cache_size(unsigned long);
288 unsigned long size1, size2;
289 unsigned long cfg = read_c0_conf();
290
291 size1 = r3k_cache_size(ST0_ISC);
292 write_c0_conf(cfg ^ R30XX_CONF_AC);
293 size2 = r3k_cache_size(ST0_ISC);
294 write_c0_conf(cfg);
295 return size1 != size2;
296#else
297 return 0;
298#endif
299}
300
Robert Millanc094c992011-04-18 11:37:55 -0700301static inline void set_elf_platform(int cpu, const char *plat)
302{
303 if (cpu == 0)
304 __elf_platform = plat;
305}
306
Guenter Roeck91dfc422010-02-02 08:52:20 -0800307static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
308{
309#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800310 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800311 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800312 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800313#endif
314}
315
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000316static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
Steven J. Hilla96102b2012-12-07 04:31:36 +0000317{
318 switch (isa) {
319 case MIPS_CPU_ISA_M64R2:
320 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
321 case MIPS_CPU_ISA_M64R1:
322 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
323 case MIPS_CPU_ISA_V:
324 c->isa_level |= MIPS_CPU_ISA_V;
325 case MIPS_CPU_ISA_IV:
326 c->isa_level |= MIPS_CPU_ISA_IV;
327 case MIPS_CPU_ISA_III:
Ralf Baechle1990e542013-06-26 17:06:34 +0200328 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000329 break;
330
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000331 /* R6 incompatible with everything else */
332 case MIPS_CPU_ISA_M64R6:
333 c->isa_level |= MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6;
334 case MIPS_CPU_ISA_M32R6:
335 c->isa_level |= MIPS_CPU_ISA_M32R6;
336 /* Break here so we don't add incompatible ISAs */
337 break;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000338 case MIPS_CPU_ISA_M32R2:
339 c->isa_level |= MIPS_CPU_ISA_M32R2;
340 case MIPS_CPU_ISA_M32R1:
341 c->isa_level |= MIPS_CPU_ISA_M32R1;
342 case MIPS_CPU_ISA_II:
343 c->isa_level |= MIPS_CPU_ISA_II;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000344 break;
345 }
346}
347
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000348static char unknown_isa[] = KERN_ERR \
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100349 "Unsupported ISA type, c0.config0: %d.";
350
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000351static unsigned int calculate_ftlb_probability(struct cpuinfo_mips *c)
352{
353
354 unsigned int probability = c->tlbsize / c->tlbsizevtlb;
355
356 /*
357 * 0 = All TLBWR instructions go to FTLB
358 * 1 = 15:1: For every 16 TBLWR instructions, 15 go to the
359 * FTLB and 1 goes to the VTLB.
360 * 2 = 7:1: As above with 7:1 ratio.
361 * 3 = 3:1: As above with 3:1 ratio.
362 *
363 * Use the linear midpoint as the probability threshold.
364 */
365 if (probability >= 12)
366 return 1;
367 else if (probability >= 6)
368 return 2;
369 else
370 /*
371 * So FTLB is less than 4 times bigger than VTLB.
372 * A 3:1 ratio can still be useful though.
373 */
374 return 3;
375}
376
Markos Chandras912708c2015-07-09 10:40:51 +0100377static int set_ftlb_enable(struct cpuinfo_mips *c, int enable)
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000378{
Markos Chandras20a7f7e2015-07-09 10:40:53 +0100379 unsigned int config;
James Hogand83b0e82014-01-22 16:19:40 +0000380
381 /* It's implementation dependent how the FTLB can be enabled */
382 switch (c->cputype) {
383 case CPU_PROAPTIV:
384 case CPU_P5600:
385 /* proAptiv & related cores use Config6 to enable the FTLB */
Markos Chandras20a7f7e2015-07-09 10:40:53 +0100386 config = read_c0_config6();
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000387 /* Clear the old probability value */
Markos Chandras20a7f7e2015-07-09 10:40:53 +0100388 config &= ~(3 << MIPS_CONF6_FTLBP_SHIFT);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000389 if (enable)
390 /* Enable FTLB */
Markos Chandras20a7f7e2015-07-09 10:40:53 +0100391 write_c0_config6(config |
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000392 (calculate_ftlb_probability(c)
393 << MIPS_CONF6_FTLBP_SHIFT)
394 | MIPS_CONF6_FTLBEN);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000395 else
396 /* Disable FTLB */
Markos Chandras20a7f7e2015-07-09 10:40:53 +0100397 write_c0_config6(config & ~MIPS_CONF6_FTLBEN);
398 break;
399 case CPU_I6400:
400 /* I6400 & related cores use Config7 to configure FTLB */
401 config = read_c0_config7();
402 /* Clear the old probability value */
403 config &= ~(3 << MIPS_CONF7_FTLBP_SHIFT);
404 write_c0_config7(config | (calculate_ftlb_probability(c)
405 << MIPS_CONF7_FTLBP_SHIFT));
James Hogand83b0e82014-01-22 16:19:40 +0000406 break;
Markos Chandras912708c2015-07-09 10:40:51 +0100407 default:
408 return 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000409 }
Markos Chandras912708c2015-07-09 10:40:51 +0100410
411 return 0;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000412}
413
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100414static inline unsigned int decode_config0(struct cpuinfo_mips *c)
415{
416 unsigned int config0;
James Hogan2f6f3132015-09-17 17:49:20 +0100417 int isa, mt;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100418
419 config0 = read_c0_config();
420
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000421 /*
422 * Look for Standard TLB or Dual VTLB and FTLB
423 */
James Hogan2f6f3132015-09-17 17:49:20 +0100424 mt = config0 & MIPS_CONF_MT;
425 if (mt == MIPS_CONF_MT_TLB)
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100426 c->options |= MIPS_CPU_TLB;
James Hogan2f6f3132015-09-17 17:49:20 +0100427 else if (mt == MIPS_CONF_MT_FTLB)
428 c->options |= MIPS_CPU_TLB | MIPS_CPU_FTLB;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000429
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100430 isa = (config0 & MIPS_CONF_AT) >> 13;
431 switch (isa) {
432 case 0:
433 switch ((config0 & MIPS_CONF_AR) >> 10) {
434 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000435 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100436 break;
437 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000438 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100439 break;
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000440 case 2:
441 set_isa(c, MIPS_CPU_ISA_M32R6);
442 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100443 default:
444 goto unknown;
445 }
446 break;
447 case 2:
448 switch ((config0 & MIPS_CONF_AR) >> 10) {
449 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000450 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100451 break;
452 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000453 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100454 break;
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000455 case 2:
456 set_isa(c, MIPS_CPU_ISA_M64R6);
457 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100458 default:
459 goto unknown;
460 }
461 break;
462 default:
463 goto unknown;
464 }
465
466 return config0 & MIPS_CONF_M;
467
468unknown:
469 panic(unknown_isa, config0);
470}
471
472static inline unsigned int decode_config1(struct cpuinfo_mips *c)
473{
474 unsigned int config1;
475
476 config1 = read_c0_config1();
477
478 if (config1 & MIPS_CONF1_MD)
479 c->ases |= MIPS_ASE_MDMX;
480 if (config1 & MIPS_CONF1_WR)
481 c->options |= MIPS_CPU_WATCH;
482 if (config1 & MIPS_CONF1_CA)
483 c->ases |= MIPS_ASE_MIPS16;
484 if (config1 & MIPS_CONF1_EP)
485 c->options |= MIPS_CPU_EJTAG;
486 if (config1 & MIPS_CONF1_FP) {
487 c->options |= MIPS_CPU_FPU;
488 c->options |= MIPS_CPU_32FPR;
489 }
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000490 if (cpu_has_tlb) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100491 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000492 c->tlbsizevtlb = c->tlbsize;
493 c->tlbsizeftlbsets = 0;
494 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100495
496 return config1 & MIPS_CONF_M;
497}
498
499static inline unsigned int decode_config2(struct cpuinfo_mips *c)
500{
501 unsigned int config2;
502
503 config2 = read_c0_config2();
504
505 if (config2 & MIPS_CONF2_SL)
506 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
507
508 return config2 & MIPS_CONF_M;
509}
510
511static inline unsigned int decode_config3(struct cpuinfo_mips *c)
512{
513 unsigned int config3;
514
515 config3 = read_c0_config3();
516
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500517 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100518 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500519 c->options |= MIPS_CPU_RIXI;
520 }
521 if (config3 & MIPS_CONF3_RXI)
522 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100523 if (config3 & MIPS_CONF3_DSP)
524 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500525 if (config3 & MIPS_CONF3_DSP2P)
526 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100527 if (config3 & MIPS_CONF3_VINT)
528 c->options |= MIPS_CPU_VINT;
529 if (config3 & MIPS_CONF3_VEIC)
530 c->options |= MIPS_CPU_VEIC;
531 if (config3 & MIPS_CONF3_MT)
532 c->ases |= MIPS_ASE_MIPSMT;
533 if (config3 & MIPS_CONF3_ULRI)
534 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000535 if (config3 & MIPS_CONF3_ISA)
536 c->options |= MIPS_CPU_MICROMIPS;
David Daney1e7decd2013-02-16 23:42:43 +0100537 if (config3 & MIPS_CONF3_VZ)
538 c->ases |= MIPS_ASE_VZ;
Steven J. Hill4a0156f2013-11-14 16:12:24 +0000539 if (config3 & MIPS_CONF3_SC)
540 c->options |= MIPS_CPU_SEGMENTS;
Paul Burtona5e9a692014-01-27 15:23:10 +0000541 if (config3 & MIPS_CONF3_MSA)
542 c->ases |= MIPS_ASE_MSA;
Paul Burtoncab25bc2015-09-22 12:03:37 -0700543 if (config3 & MIPS_CONF3_PW) {
Markos Chandrased4cbc82015-01-26 13:04:33 +0000544 c->htw_seq = 0;
Markos Chandras3d528b32014-07-14 12:46:13 +0100545 c->options |= MIPS_CPU_HTW;
Markos Chandrased4cbc82015-01-26 13:04:33 +0000546 }
James Hogan9b3274b2015-02-02 11:45:08 +0000547 if (config3 & MIPS_CONF3_CDMM)
548 c->options |= MIPS_CPU_CDMM;
James Hoganaaa7be42015-07-15 16:17:44 +0100549 if (config3 & MIPS_CONF3_SP)
550 c->options |= MIPS_CPU_SP;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100551
552 return config3 & MIPS_CONF_M;
553}
554
555static inline unsigned int decode_config4(struct cpuinfo_mips *c)
556{
557 unsigned int config4;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000558 unsigned int newcf4;
559 unsigned int mmuextdef;
560 unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100561
562 config4 = read_c0_config4();
563
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000564 if (cpu_has_tlb) {
565 if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
566 c->options |= MIPS_CPU_TLBINV;
James Hogan43d104d2015-09-17 17:49:21 +0100567
Markos Chandrase87569c2015-07-09 10:40:52 +0100568 /*
James Hogan43d104d2015-09-17 17:49:21 +0100569 * R6 has dropped the MMUExtDef field from config4.
570 * On R6 the fields always describe the FTLB, and only if it is
571 * present according to Config.MT.
Markos Chandrase87569c2015-07-09 10:40:52 +0100572 */
James Hogan43d104d2015-09-17 17:49:21 +0100573 if (!cpu_has_mips_r6)
574 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
575 else if (cpu_has_ftlb)
Markos Chandrase87569c2015-07-09 10:40:52 +0100576 mmuextdef = MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT;
577 else
James Hogan43d104d2015-09-17 17:49:21 +0100578 mmuextdef = 0;
Markos Chandrase87569c2015-07-09 10:40:52 +0100579
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000580 switch (mmuextdef) {
581 case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:
582 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
583 c->tlbsizevtlb = c->tlbsize;
584 break;
585 case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT:
586 c->tlbsizevtlb +=
587 ((config4 & MIPS_CONF4_VTLBSIZEEXT) >>
588 MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40;
589 c->tlbsize = c->tlbsizevtlb;
590 ftlb_page = MIPS_CONF4_VFTLBPAGESIZE;
591 /* fall through */
592 case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT:
Markos Chandras97f4ad22014-08-29 09:37:26 +0100593 if (mips_ftlb_disabled)
594 break;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000595 newcf4 = (config4 & ~ftlb_page) |
596 (page_size_ftlb(mmuextdef) <<
597 MIPS_CONF4_FTLBPAGESIZE_SHIFT);
598 write_c0_config4(newcf4);
599 back_to_back_c0_hazard();
600 config4 = read_c0_config4();
601 if (config4 != newcf4) {
602 pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
603 PAGE_SIZE, config4);
604 /* Switch FTLB off */
605 set_ftlb_enable(c, 0);
606 break;
607 }
608 c->tlbsizeftlbsets = 1 <<
609 ((config4 & MIPS_CONF4_FTLBSETS) >>
610 MIPS_CONF4_FTLBSETS_SHIFT);
611 c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >>
612 MIPS_CONF4_FTLBWAYS_SHIFT) + 2;
613 c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets;
Markos Chandras97f4ad22014-08-29 09:37:26 +0100614 mips_has_ftlb_configured = 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000615 break;
616 }
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000617 }
618
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100619 c->kscratch_mask = (config4 >> 16) & 0xff;
620
621 return config4 & MIPS_CONF_M;
622}
623
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200624static inline unsigned int decode_config5(struct cpuinfo_mips *c)
625{
626 unsigned int config5;
627
628 config5 = read_c0_config5();
Paul Burtond175ed22014-09-11 08:30:19 +0100629 config5 &= ~(MIPS_CONF5_UFR | MIPS_CONF5_UFE);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200630 write_c0_config5(config5);
631
Markos Chandras49016742014-01-09 16:04:51 +0000632 if (config5 & MIPS_CONF5_EVA)
633 c->options |= MIPS_CPU_EVA;
Paul Burton1f6c52f2014-07-14 10:32:14 +0100634 if (config5 & MIPS_CONF5_MRP)
635 c->options |= MIPS_CPU_MAAR;
Markos Chandras5aed9da2014-12-02 09:46:19 +0000636 if (config5 & MIPS_CONF5_LLB)
637 c->options |= MIPS_CPU_RW_LLB;
Steven J. Hillc5b36782015-02-26 18:16:38 -0600638#ifdef CONFIG_XPA
639 if (config5 & MIPS_CONF5_MVH)
640 c->options |= MIPS_CPU_XPA;
641#endif
Markos Chandras49016742014-01-09 16:04:51 +0000642
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200643 return config5 & MIPS_CONF_M;
644}
645
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000646static void decode_configs(struct cpuinfo_mips *c)
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100647{
648 int ok;
649
650 /* MIPS32 or MIPS64 compliant CPU. */
651 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
652 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
653
654 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
655
Markos Chandras97f4ad22014-08-29 09:37:26 +0100656 /* Enable FTLB if present and not disabled */
657 set_ftlb_enable(c, !mips_ftlb_disabled);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000658
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100659 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100660 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100661 if (ok)
662 ok = decode_config1(c);
663 if (ok)
664 ok = decode_config2(c);
665 if (ok)
666 ok = decode_config3(c);
667 if (ok)
668 ok = decode_config4(c);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200669 if (ok)
670 ok = decode_config5(c);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100671
672 mips_probe_watch_registers(c);
673
Leonid Yegoshin6575b1d2014-07-15 14:09:57 +0100674 if (cpu_has_rixi) {
675 /* Enable the RIXI exceptions */
Steven J. Hilla5770df2015-02-19 10:18:52 -0600676 set_c0_pagegrain(PG_IEC);
Leonid Yegoshin6575b1d2014-07-15 14:09:57 +0100677 back_to_back_c0_hazard();
678 /* Verify the IEC bit is set */
679 if (read_c0_pagegrain() & PG_IEC)
680 c->options |= MIPS_CPU_RIXIEX;
681 }
682
Paul Burton0ee958e2014-01-15 10:31:53 +0000683#ifndef CONFIG_MIPS_CPS
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000684 if (cpu_has_mips_r2_r6) {
David Daney45b585c2014-05-28 23:52:10 +0200685 c->core = get_ebase_cpunum();
Paul Burton30ee6152014-03-27 10:57:30 +0000686 if (cpu_has_mipsmt)
687 c->core >>= fls(core_nvpes()) - 1;
688 }
Paul Burton0ee958e2014-01-15 10:31:53 +0000689#endif
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100690}
691
Ralf Baechle02cf2112005-10-01 13:06:32 +0100692#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700693 | MIPS_CPU_COUNTER)
694
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000695static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100697 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700698 case PRID_IMP_R2000:
699 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000700 __cpu_name[cpu] = "R2000";
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100701 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100702 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500703 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 if (__cpu_has_fpu())
705 c->options |= MIPS_CPU_FPU;
706 c->tlbsize = 64;
707 break;
708 case PRID_IMP_R3000:
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100709 if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000710 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000712 __cpu_name[cpu] = "R3081";
713 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000715 __cpu_name[cpu] = "R3000A";
716 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000717 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000719 __cpu_name[cpu] = "R3000";
720 }
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100721 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100722 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500723 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724 if (__cpu_has_fpu())
725 c->options |= MIPS_CPU_FPU;
726 c->tlbsize = 64;
727 break;
728 case PRID_IMP_R4000:
729 if (read_c0_config() & CONF_SC) {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100730 if ((c->processor_id & PRID_REV_MASK) >=
731 PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700732 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000733 __cpu_name[cpu] = "R4400PC";
734 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700735 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000736 __cpu_name[cpu] = "R4000PC";
737 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100739 int cca = read_c0_config() & CONF_CM_CMASK;
740 int mc;
741
742 /*
743 * SC and MC versions can't be reliably told apart,
744 * but only the latter support coherent caching
745 * modes so assume the firmware has set the KSEG0
746 * coherency attribute reasonably (if uncached, we
747 * assume SC).
748 */
749 switch (cca) {
750 case CONF_CM_CACHABLE_CE:
751 case CONF_CM_CACHABLE_COW:
752 case CONF_CM_CACHABLE_CUW:
753 mc = 1;
754 break;
755 default:
756 mc = 0;
757 break;
758 }
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100759 if ((c->processor_id & PRID_REV_MASK) >=
760 PRID_REV_R4400) {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100761 c->cputype = mc ? CPU_R4400MC : CPU_R4400SC;
762 __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000763 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100764 c->cputype = mc ? CPU_R4000MC : CPU_R4000SC;
765 __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000766 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 }
768
Steven J. Hilla96102b2012-12-07 04:31:36 +0000769 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100770 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700771 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500772 MIPS_CPU_WATCH | MIPS_CPU_VCE |
773 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774 c->tlbsize = 48;
775 break;
776 case PRID_IMP_VR41XX:
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900777 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100778 c->fpu_msk31 |= FPU_CSR_CONDX;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900779 c->options = R4K_OPTS;
780 c->tlbsize = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 case PRID_REV_VR4111:
783 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000784 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 case PRID_REV_VR4121:
787 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000788 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 break;
790 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000791 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000793 __cpu_name[cpu] = "NEC VR4122";
794 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000796 __cpu_name[cpu] = "NEC VR4181A";
797 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 break;
799 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000800 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000802 __cpu_name[cpu] = "NEC VR4131";
803 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 c->cputype = CPU_VR4133;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900805 c->options |= MIPS_CPU_LLSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000806 __cpu_name[cpu] = "NEC VR4133";
807 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700808 break;
809 default:
810 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
811 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000812 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 break;
814 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 break;
816 case PRID_IMP_R4300:
817 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000818 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000819 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100820 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500822 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 c->tlbsize = 32;
824 break;
825 case PRID_IMP_R4600:
826 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000827 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000828 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100829 c->fpu_msk31 |= FPU_CSR_CONDX;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000830 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
831 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 c->tlbsize = 48;
833 break;
834 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500835 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 /*
837 * This processor doesn't have an MMU, so it's not
838 * "real easy" to run Linux on it. It is left purely
839 * for documentation. Commented out because it shares
840 * it's c0_prid id number with the TX3900.
841 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000842 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000843 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000844 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100845 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700846 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500847 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700848 break;
849 #endif
850 case PRID_IMP_TX39:
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100851 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100852 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853
854 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
855 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000856 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 c->tlbsize = 64;
858 } else {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100859 switch (c->processor_id & PRID_REV_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860 case PRID_REV_TX3912:
861 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000862 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863 c->tlbsize = 32;
864 break;
865 case PRID_REV_TX3922:
866 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000867 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700868 c->tlbsize = 64;
869 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 }
871 }
872 break;
873 case PRID_IMP_R4700:
874 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000875 __cpu_name[cpu] = "R4700";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000876 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100877 c->fpu_msk31 |= FPU_CSR_CONDX;
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 c->tlbsize = 48;
881 break;
882 case PRID_IMP_TX49:
883 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000884 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000885 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100886 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 c->options = R4K_OPTS | MIPS_CPU_LLSC;
888 if (!(c->processor_id & 0x08))
889 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
890 c->tlbsize = 48;
891 break;
892 case PRID_IMP_R5000:
893 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000894 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000895 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500897 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 c->tlbsize = 48;
899 break;
900 case PRID_IMP_R5432:
901 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000902 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000903 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500905 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 c->tlbsize = 48;
907 break;
908 case PRID_IMP_R5500:
909 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000910 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000911 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500913 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 c->tlbsize = 48;
915 break;
916 case PRID_IMP_NEVADA:
917 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000918 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000919 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500921 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922 c->tlbsize = 48;
923 break;
924 case PRID_IMP_R6000:
925 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000926 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000927 set_isa(c, MIPS_CPU_ISA_II);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100928 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500930 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700931 c->tlbsize = 32;
932 break;
933 case PRID_IMP_R6000A:
934 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000935 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000936 set_isa(c, MIPS_CPU_ISA_II);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100937 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500939 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940 c->tlbsize = 32;
941 break;
942 case PRID_IMP_RM7000:
943 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000944 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000945 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500947 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100949 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950 * the RM7000 v2.0 indicates if the TLB has 48 or 64
951 * entries.
952 *
Ralf Baechle70342282013-01-22 12:59:30 +0100953 * 29 1 => 64 entry JTLB
954 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 */
956 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
957 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958 case PRID_IMP_R8000:
959 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000960 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000961 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700962 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500963 MIPS_CPU_FPU | MIPS_CPU_32FPR |
964 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700965 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
966 break;
967 case PRID_IMP_R10000:
968 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000969 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000970 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000971 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500972 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700973 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500974 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700975 c->tlbsize = 64;
976 break;
977 case PRID_IMP_R12000:
978 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000979 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000980 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000981 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500982 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700983 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Joshua Kinard8d5ded12015-06-02 18:21:33 -0400984 MIPS_CPU_LLSC | MIPS_CPU_BP_GHIST;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985 c->tlbsize = 64;
986 break;
Kumba44d921b2006-05-16 22:23:59 -0400987 case PRID_IMP_R14000:
Joshua Kinard30577392015-01-21 07:59:45 -0500988 if (((c->processor_id >> 4) & 0x0f) > 2) {
989 c->cputype = CPU_R16000;
990 __cpu_name[cpu] = "R16000";
991 } else {
992 c->cputype = CPU_R14000;
993 __cpu_name[cpu] = "R14000";
994 }
Steven J. Hilla96102b2012-12-07 04:31:36 +0000995 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400996 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500997 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400998 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Joshua Kinard8d5ded12015-06-02 18:21:33 -0400999 MIPS_CPU_LLSC | MIPS_CPU_BP_GHIST;
Kumba44d921b2006-05-16 22:23:59 -04001000 c->tlbsize = 64;
1001 break;
Huacai Chen26859192014-02-16 16:01:18 +08001002 case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */
Robert Millan5aac1e82011-04-16 11:29:29 -07001003 switch (c->processor_id & PRID_REV_MASK) {
1004 case PRID_REV_LOONGSON2E:
Huacai Chenc579d312014-03-21 18:44:00 +08001005 c->cputype = CPU_LOONGSON2;
1006 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -07001007 set_elf_platform(cpu, "loongson2e");
Huacai Chen7352c8b2014-11-04 14:13:23 +08001008 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +01001009 c->fpu_msk31 |= FPU_CSR_CONDX;
Robert Millan5aac1e82011-04-16 11:29:29 -07001010 break;
1011 case PRID_REV_LOONGSON2F:
Huacai Chenc579d312014-03-21 18:44:00 +08001012 c->cputype = CPU_LOONGSON2;
1013 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -07001014 set_elf_platform(cpu, "loongson2f");
Huacai Chen7352c8b2014-11-04 14:13:23 +08001015 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +01001016 c->fpu_msk31 |= FPU_CSR_CONDX;
Robert Millan5aac1e82011-04-16 11:29:29 -07001017 break;
Huacai Chenc579d312014-03-21 18:44:00 +08001018 case PRID_REV_LOONGSON3A:
1019 c->cputype = CPU_LOONGSON3;
1020 __cpu_name[cpu] = "ICT Loongson-3";
1021 set_elf_platform(cpu, "loongson3a");
Huacai Chen7352c8b2014-11-04 14:13:23 +08001022 set_isa(c, MIPS_CPU_ISA_M64R1);
Huacai Chenc579d312014-03-21 18:44:00 +08001023 break;
Huacai Chene7841be2014-06-26 11:41:30 +08001024 case PRID_REV_LOONGSON3B_R1:
1025 case PRID_REV_LOONGSON3B_R2:
1026 c->cputype = CPU_LOONGSON3;
1027 __cpu_name[cpu] = "ICT Loongson-3";
1028 set_elf_platform(cpu, "loongson3b");
Huacai Chen7352c8b2014-11-04 14:13:23 +08001029 set_isa(c, MIPS_CPU_ISA_M64R1);
Huacai Chene7841be2014-06-26 11:41:30 +08001030 break;
Robert Millan5aac1e82011-04-16 11:29:29 -07001031 }
1032
Fuxin Zhang2a21c732007-06-06 14:52:43 +08001033 c->options = R4K_OPTS |
1034 MIPS_CPU_FPU | MIPS_CPU_LLSC |
1035 MIPS_CPU_32FPR;
1036 c->tlbsize = 64;
Huacai Chencc94ea32014-11-04 14:13:22 +08001037 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Fuxin Zhang2a21c732007-06-06 14:52:43 +08001038 break;
Huacai Chen26859192014-02-16 16:01:18 +08001039 case PRID_IMP_LOONGSON_32: /* Loongson-1 */
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001040 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001042 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +00001043
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001044 switch (c->processor_id & PRID_REV_MASK) {
1045 case PRID_REV_LOONGSON1B:
1046 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +00001047 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +00001048 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001049
Ralf Baechle41943182005-05-05 16:45:59 +00001050 break;
Ralf Baechle41943182005-05-05 16:45:59 +00001051 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001052}
1053
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001054static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055{
Markos Chandras4f12b912014-07-18 10:51:32 +01001056 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001057 switch (c->processor_id & PRID_IMP_MASK) {
Leonid Yegoshinb2498af2014-11-24 12:59:44 +00001058 case PRID_IMP_QEMU_GENERIC:
1059 c->writecombine = _CACHE_UNCACHED;
1060 c->cputype = CPU_QEMU_GENERIC;
1061 __cpu_name[cpu] = "MIPS GENERIC QEMU";
1062 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 case PRID_IMP_4KC:
1064 c->cputype = CPU_4KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001065 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001066 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001067 break;
1068 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +00001069 case PRID_IMP_4KECR2:
1070 c->cputype = CPU_4KEC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001071 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001072 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +00001073 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001074 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +01001075 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001076 c->cputype = CPU_4KSC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001077 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001078 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001079 break;
1080 case PRID_IMP_5KC:
1081 c->cputype = CPU_5KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001082 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001083 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +02001085 case PRID_IMP_5KE:
1086 c->cputype = CPU_5KE;
Markos Chandras4f12b912014-07-18 10:51:32 +01001087 c->writecombine = _CACHE_UNCACHED;
Leonid Yegoshin78d48032012-07-06 21:56:01 +02001088 __cpu_name[cpu] = "MIPS 5KE";
1089 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090 case PRID_IMP_20KC:
1091 c->cputype = CPU_20KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001092 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001093 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 break;
1095 case PRID_IMP_24K:
1096 c->cputype = CPU_24K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001097 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001098 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 break;
John Crispin42f3cae2013-01-11 22:44:10 +01001100 case PRID_IMP_24KE:
1101 c->cputype = CPU_24K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001102 c->writecombine = _CACHE_UNCACHED;
John Crispin42f3cae2013-01-11 22:44:10 +01001103 __cpu_name[cpu] = "MIPS 24KEc";
1104 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 case PRID_IMP_25KF:
1106 c->cputype = CPU_25KF;
Markos Chandras4f12b912014-07-18 10:51:32 +01001107 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001108 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +00001110 case PRID_IMP_34K:
1111 c->cputype = CPU_34K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001112 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001113 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +00001114 break;
Chris Dearmanc6209532006-05-02 14:08:46 +01001115 case PRID_IMP_74K:
1116 c->cputype = CPU_74K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001117 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001118 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +01001119 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +02001120 case PRID_IMP_M14KC:
1121 c->cputype = CPU_M14KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001122 c->writecombine = _CACHE_UNCACHED;
Steven J. Hill113c62d2012-07-06 23:56:00 +02001123 __cpu_name[cpu] = "MIPS M14Kc";
1124 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +00001125 case PRID_IMP_M14KEC:
1126 c->cputype = CPU_M14KEC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001127 c->writecombine = _CACHE_UNCACHED;
Steven J. Hillf8fa4812012-12-07 03:51:35 +00001128 __cpu_name[cpu] = "MIPS M14KEc";
1129 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +01001130 case PRID_IMP_1004K:
1131 c->cputype = CPU_1004K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001132 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001133 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +01001134 break;
Steven J. Hill006a8512012-06-26 04:11:03 +00001135 case PRID_IMP_1074K:
Steven J. Hill442e14a2014-01-17 15:03:50 -06001136 c->cputype = CPU_1074K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001137 c->writecombine = _CACHE_UNCACHED;
Steven J. Hill006a8512012-06-26 04:11:03 +00001138 __cpu_name[cpu] = "MIPS 1074Kc";
1139 break;
Leonid Yegoshinb5f065e2013-11-20 10:46:02 +00001140 case PRID_IMP_INTERAPTIV_UP:
1141 c->cputype = CPU_INTERAPTIV;
1142 __cpu_name[cpu] = "MIPS interAptiv";
1143 break;
1144 case PRID_IMP_INTERAPTIV_MP:
1145 c->cputype = CPU_INTERAPTIV;
1146 __cpu_name[cpu] = "MIPS interAptiv (multi)";
1147 break;
Leonid Yegoshinb0d4d302013-11-14 16:12:28 +00001148 case PRID_IMP_PROAPTIV_UP:
1149 c->cputype = CPU_PROAPTIV;
1150 __cpu_name[cpu] = "MIPS proAptiv";
1151 break;
1152 case PRID_IMP_PROAPTIV_MP:
1153 c->cputype = CPU_PROAPTIV;
1154 __cpu_name[cpu] = "MIPS proAptiv (multi)";
1155 break;
James Hogan829dcc02014-01-22 16:19:39 +00001156 case PRID_IMP_P5600:
1157 c->cputype = CPU_P5600;
1158 __cpu_name[cpu] = "MIPS P5600";
1159 break;
Markos Chandrase57f9a22015-07-09 10:40:37 +01001160 case PRID_IMP_I6400:
1161 c->cputype = CPU_I6400;
1162 __cpu_name[cpu] = "MIPS I6400";
1163 break;
Leonid Yegoshin9943ed92014-03-04 13:34:44 +00001164 case PRID_IMP_M5150:
1165 c->cputype = CPU_M5150;
1166 __cpu_name[cpu] = "MIPS M5150";
1167 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168 }
Chris Dearman0b6d4972007-09-13 12:32:02 +01001169
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +00001170 decode_configs(c);
1171
Chris Dearman0b6d4972007-09-13 12:32:02 +01001172 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173}
1174
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001175static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176{
Ralf Baechle41943182005-05-05 16:45:59 +00001177 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001178 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179 case PRID_IMP_AU1_REV1:
1180 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +01001181 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 switch ((c->processor_id >> 24) & 0xff) {
1183 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001184 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001185 break;
1186 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001187 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001188 break;
1189 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001190 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001191 break;
1192 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001193 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001194 break;
Pete Popove3ad1c22005-03-01 06:33:16 +00001195 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001196 __cpu_name[cpu] = "Au1200";
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001197 if ((c->processor_id & PRID_REV_MASK) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001198 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +01001199 break;
1200 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001201 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +00001202 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 default:
Manuel Lauss270717a2009-03-25 17:49:28 +01001204 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205 break;
1206 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207 break;
1208 }
1209}
1210
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001211static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001212{
Ralf Baechle41943182005-05-05 16:45:59 +00001213 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +01001214
Markos Chandras4f12b912014-07-18 10:51:32 +01001215 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001216 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001217 case PRID_IMP_SB1:
1218 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001219 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 /* FPU in pass1 is known to have issues. */
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001221 if ((c->processor_id & PRID_REV_MASK) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +00001222 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001223 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -07001224 case PRID_IMP_SB1A:
1225 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001226 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -07001227 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228 }
1229}
1230
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001231static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001232{
Ralf Baechle41943182005-05-05 16:45:59 +00001233 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001234 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235 case PRID_IMP_SR71000:
1236 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001237 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238 c->scache.ways = 8;
1239 c->tlbsize = 64;
1240 break;
1241 }
1242}
1243
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001244static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +00001245{
1246 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001247 switch (c->processor_id & PRID_IMP_MASK) {
Pete Popovbdf21b12005-07-14 17:47:57 +00001248 case PRID_IMP_PR4450:
1249 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001250 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +00001251 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +00001252 break;
Pete Popovbdf21b12005-07-14 17:47:57 +00001253 }
1254}
1255
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001256static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001257{
1258 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001259 switch (c->processor_id & PRID_IMP_MASK) {
Kevin Cernekee190fca32010-11-23 10:26:45 -08001260 case PRID_IMP_BMIPS32_REV4:
1261 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -07001262 c->cputype = CPU_BMIPS32;
1263 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001264 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001265 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001266 case PRID_IMP_BMIPS3300:
1267 case PRID_IMP_BMIPS3300_ALT:
1268 case PRID_IMP_BMIPS3300_BUG:
1269 c->cputype = CPU_BMIPS3300;
1270 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001271 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001272 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001273 case PRID_IMP_BMIPS43XX: {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001274 int rev = c->processor_id & PRID_REV_MASK;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001275
1276 if (rev >= PRID_REV_BMIPS4380_LO &&
1277 rev <= PRID_REV_BMIPS4380_HI) {
1278 c->cputype = CPU_BMIPS4380;
1279 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001280 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001281 } else {
1282 c->cputype = CPU_BMIPS4350;
1283 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001284 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +01001285 }
1286 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001287 }
Kevin Cernekee602977b2010-10-16 14:22:30 -07001288 case PRID_IMP_BMIPS5000:
Kevin Cernekee68e6a782014-10-20 21:28:01 -07001289 case PRID_IMP_BMIPS5200:
Kevin Cernekee602977b2010-10-16 14:22:30 -07001290 c->cputype = CPU_BMIPS5000;
1291 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001292 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001293 c->options |= MIPS_CPU_ULRI;
1294 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001295 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001296}
1297
David Daney0dd47812008-12-11 15:33:26 -08001298static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
1299{
1300 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001301 switch (c->processor_id & PRID_IMP_MASK) {
David Daney0dd47812008-12-11 15:33:26 -08001302 case PRID_IMP_CAVIUM_CN38XX:
1303 case PRID_IMP_CAVIUM_CN31XX:
1304 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -08001305 c->cputype = CPU_CAVIUM_OCTEON;
1306 __cpu_name[cpu] = "Cavium Octeon";
1307 goto platform;
David Daney0dd47812008-12-11 15:33:26 -08001308 case PRID_IMP_CAVIUM_CN58XX:
1309 case PRID_IMP_CAVIUM_CN56XX:
1310 case PRID_IMP_CAVIUM_CN50XX:
1311 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -08001312 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
1313 __cpu_name[cpu] = "Cavium Octeon+";
1314platform:
Robert Millanc094c992011-04-18 11:37:55 -07001315 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -08001316 break;
David Daneya1431b62011-09-24 02:29:54 +02001317 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -07001318 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +02001319 case PRID_IMP_CAVIUM_CN66XX:
1320 case PRID_IMP_CAVIUM_CN68XX:
David Daneyaf04bb82013-07-29 15:07:01 -07001321 case PRID_IMP_CAVIUM_CNF71XX:
David Daney0e56b382010-10-07 16:03:45 -07001322 c->cputype = CPU_CAVIUM_OCTEON2;
1323 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001324 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001325 break;
David Daneyaf04bb82013-07-29 15:07:01 -07001326 case PRID_IMP_CAVIUM_CN70XX:
1327 case PRID_IMP_CAVIUM_CN78XX:
1328 c->cputype = CPU_CAVIUM_OCTEON3;
1329 __cpu_name[cpu] = "Cavium Octeon III";
1330 set_elf_platform(cpu, "octeon3");
1331 break;
David Daney0dd47812008-12-11 15:33:26 -08001332 default:
1333 printk(KERN_INFO "Unknown Octeon chip!\n");
1334 c->cputype = CPU_UNKNOWN;
1335 break;
1336 }
1337}
1338
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001339static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1340{
1341 decode_configs(c);
1342 /* JZRISC does not implement the CP0 counter. */
1343 c->options &= ~MIPS_CPU_COUNTER;
Maciej W. Rozycki06947aa2014-04-06 21:31:29 +01001344 BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001345 switch (c->processor_id & PRID_IMP_MASK) {
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001346 case PRID_IMP_JZRISC:
1347 c->cputype = CPU_JZRISC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001348 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001349 __cpu_name[cpu] = "Ingenic JZRISC";
1350 break;
1351 default:
1352 panic("Unknown Ingenic Processor ID!");
1353 break;
1354 }
1355}
1356
Jayachandran Ca7117c62011-05-11 12:04:58 +05301357static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1358{
1359 decode_configs(c);
1360
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001361 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
Manuel Lauss809f36c2011-11-01 20:03:30 +01001362 c->cputype = CPU_ALCHEMY;
1363 __cpu_name[cpu] = "Au1300";
1364 /* following stuff is not for Alchemy */
1365 return;
1366 }
1367
Ralf Baechle70342282013-01-22 12:59:30 +01001368 c->options = (MIPS_CPU_TLB |
1369 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301370 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +01001371 MIPS_CPU_DIVEC |
1372 MIPS_CPU_WATCH |
1373 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301374 MIPS_CPU_LLSC);
1375
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001376 switch (c->processor_id & PRID_IMP_MASK) {
Jayachandran C4ca86a22013-08-11 14:43:54 +05301377 case PRID_IMP_NETLOGIC_XLP2XX:
Jayachandran C8907c552013-12-21 16:52:20 +05301378 case PRID_IMP_NETLOGIC_XLP9XX:
Yonghong Song1c983982014-04-29 20:07:53 +05301379 case PRID_IMP_NETLOGIC_XLP5XX:
Jayachandran C4ca86a22013-08-11 14:43:54 +05301380 c->cputype = CPU_XLP;
1381 __cpu_name[cpu] = "Broadcom XLPII";
1382 break;
1383
Jayachandran C2aa54b22011-11-16 00:21:29 +00001384 case PRID_IMP_NETLOGIC_XLP8XX:
1385 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001386 c->cputype = CPU_XLP;
1387 __cpu_name[cpu] = "Netlogic XLP";
1388 break;
1389
Jayachandran Ca7117c62011-05-11 12:04:58 +05301390 case PRID_IMP_NETLOGIC_XLR732:
1391 case PRID_IMP_NETLOGIC_XLR716:
1392 case PRID_IMP_NETLOGIC_XLR532:
1393 case PRID_IMP_NETLOGIC_XLR308:
1394 case PRID_IMP_NETLOGIC_XLR532C:
1395 case PRID_IMP_NETLOGIC_XLR516C:
1396 case PRID_IMP_NETLOGIC_XLR508C:
1397 case PRID_IMP_NETLOGIC_XLR308C:
1398 c->cputype = CPU_XLR;
1399 __cpu_name[cpu] = "Netlogic XLR";
1400 break;
1401
1402 case PRID_IMP_NETLOGIC_XLS608:
1403 case PRID_IMP_NETLOGIC_XLS408:
1404 case PRID_IMP_NETLOGIC_XLS404:
1405 case PRID_IMP_NETLOGIC_XLS208:
1406 case PRID_IMP_NETLOGIC_XLS204:
1407 case PRID_IMP_NETLOGIC_XLS108:
1408 case PRID_IMP_NETLOGIC_XLS104:
1409 case PRID_IMP_NETLOGIC_XLS616B:
1410 case PRID_IMP_NETLOGIC_XLS608B:
1411 case PRID_IMP_NETLOGIC_XLS416B:
1412 case PRID_IMP_NETLOGIC_XLS412B:
1413 case PRID_IMP_NETLOGIC_XLS408B:
1414 case PRID_IMP_NETLOGIC_XLS404B:
1415 c->cputype = CPU_XLR;
1416 __cpu_name[cpu] = "Netlogic XLS";
1417 break;
1418
1419 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001420 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301421 c->processor_id);
1422 c->cputype = CPU_XLR;
1423 break;
1424 }
1425
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001426 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001427 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001428 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1429 /* This will be updated again after all threads are woken up */
1430 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1431 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001432 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001433 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1434 }
Jayachandran C7777b932013-06-11 14:41:35 +00001435 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301436}
1437
David Daney949e51b2010-10-14 11:32:33 -07001438#ifdef CONFIG_64BIT
1439/* For use by uaccess.h */
1440u64 __ua_limit;
1441EXPORT_SYMBOL(__ua_limit);
1442#endif
1443
Ralf Baechle9966db252007-10-11 23:46:17 +01001444const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001445const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001446
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001447void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001448{
1449 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001450 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001451
Ralf Baechle70342282013-01-22 12:59:30 +01001452 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001453 c->fpu_id = FPIR_IMP_NONE;
1454 c->cputype = CPU_UNKNOWN;
Markos Chandras4f12b912014-07-18 10:51:32 +01001455 c->writecombine = _CACHE_UNCACHED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456
Maciej W. Rozycki9b266162015-04-03 23:27:48 +01001457 c->fpu_csr31 = FPU_CSR_RN;
1458 c->fpu_msk31 = FPU_CSR_RSVD | FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
1459
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 c->processor_id = read_c0_prid();
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001461 switch (c->processor_id & PRID_COMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001462 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001463 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001464 break;
1465 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001466 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001467 break;
1468 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001469 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001470 break;
1471 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001472 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001473 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001474 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001475 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001476 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001477 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001478 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001479 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001480 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001481 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001482 break;
David Daney0dd47812008-12-11 15:33:26 -08001483 case PRID_COMP_CAVIUM:
1484 cpu_probe_cavium(c, cpu);
1485 break;
Paul Burton252617a2015-05-24 16:11:14 +01001486 case PRID_COMP_INGENIC_D0:
1487 case PRID_COMP_INGENIC_D1:
1488 case PRID_COMP_INGENIC_E1:
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001489 cpu_probe_ingenic(c, cpu);
1490 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301491 case PRID_COMP_NETLOGIC:
1492 cpu_probe_netlogic(c, cpu);
1493 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001494 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001495
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001496 BUG_ON(!__cpu_name[cpu]);
1497 BUG_ON(c->cputype == CPU_UNKNOWN);
1498
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001499 /*
1500 * Platform code can force the cpu type to optimize code
1501 * generation. In that case be sure the cpu type is correctly
1502 * manually setup otherwise it could trigger some nasty bugs.
1503 */
1504 BUG_ON(current_cpu_type() != c->cputype);
1505
Kevin Cernekee0103d232010-05-02 14:43:52 -07001506 if (mips_fpu_disabled)
1507 c->options &= ~MIPS_CPU_FPU;
1508
1509 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001510 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001511
Markos Chandras3d528b32014-07-14 12:46:13 +01001512 if (mips_htw_disabled) {
1513 c->options &= ~MIPS_CPU_HTW;
1514 write_c0_pwctl(read_c0_pwctl() &
1515 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
1516 }
1517
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +01001518 if (c->options & MIPS_CPU_FPU)
1519 cpu_set_fpu_opts(c);
1520 else
1521 cpu_set_nofpu_opts(c);
Ralf Baechle9966db252007-10-11 23:46:17 +01001522
Joshua Kinard8d5ded12015-06-02 18:21:33 -04001523 if (cpu_has_bp_ghist)
1524 write_c0_r10k_diag(read_c0_r10k_diag() |
1525 R10K_DIAG_E_GHIST);
1526
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +00001527 if (cpu_has_mips_r2_r6) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001528 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001529 /* R2 has Performance Counter Interrupt indicator */
1530 c->options |= MIPS_CPU_PCI;
1531 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001532 else
1533 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001534
Paul Burton4c063032015-07-27 12:58:24 -07001535 if (cpu_has_mips_r6)
1536 elf_hwcap |= HWCAP_MIPS_R6;
1537
Paul Burtona8ad1362014-01-28 14:28:43 +00001538 if (cpu_has_msa) {
Paul Burtona5e9a692014-01-27 15:23:10 +00001539 c->msa_id = cpu_get_msa_id();
Paul Burtona8ad1362014-01-28 14:28:43 +00001540 WARN(c->msa_id & MSA_IR_WRPF,
1541 "Vector register partitioning unimplemented!");
Paul Burton3cc9fa72015-07-27 12:58:25 -07001542 elf_hwcap |= HWCAP_MIPS_MSA;
Paul Burtona8ad1362014-01-28 14:28:43 +00001543 }
Paul Burtona5e9a692014-01-27 15:23:10 +00001544
Guenter Roeck91dfc422010-02-02 08:52:20 -08001545 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001546
1547#ifdef CONFIG_64BIT
1548 if (cpu == 0)
1549 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1550#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001551}
1552
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001553void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001554{
1555 struct cpuinfo_mips *c = &current_cpu_data;
1556
Leonid Yegoshind9f897c2013-10-07 10:43:32 +01001557 pr_info("CPU%d revision is: %08x (%s)\n",
1558 smp_processor_id(), c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001560 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Paul Burtona5e9a692014-01-27 15:23:10 +00001561 if (cpu_has_msa)
1562 pr_info("MSA revision is: %08x\n", c->msa_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001563}