blob: 6b9064499bd3dfb49ef0c09ad3da48034dea0ff2 [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;
116 c->fpu_id = value;
117}
118
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100119/* Determined FPU emulator mask to use for the boot CPU with "nofpu". */
120static unsigned int mips_nofpu_msk31;
121
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +0100122/*
123 * Set options for FPU hardware.
124 */
125static void cpu_set_fpu_opts(struct cpuinfo_mips *c)
126{
127 c->fpu_id = cpu_get_fpu_id();
128 mips_nofpu_msk31 = c->fpu_msk31;
129
130 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1 |
131 MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2 |
132 MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6)) {
133 if (c->fpu_id & MIPS_FPIR_3D)
134 c->ases |= MIPS_ASE_MIPS3D;
135 if (c->fpu_id & MIPS_FPIR_FREP)
136 c->options |= MIPS_CPU_FRE;
137 }
138
139 cpu_set_fpu_fcsr_mask(c);
140}
141
142/*
143 * Set options for the FPU emulator.
144 */
145static void cpu_set_nofpu_opts(struct cpuinfo_mips *c)
146{
147 c->options &= ~MIPS_CPU_FPU;
148 c->fpu_msk31 = mips_nofpu_msk31;
149
150 cpu_set_nofpu_id(c);
151}
152
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000153static int mips_fpu_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -0700154
155static int __init fpu_disable(char *s)
156{
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +0100157 cpu_set_nofpu_opts(&boot_cpu_data);
Kevin Cernekee0103d232010-05-02 14:43:52 -0700158 mips_fpu_disabled = 1;
159
160 return 1;
161}
162
163__setup("nofpu", fpu_disable);
164
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000165int mips_dsp_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -0700166
167static int __init dsp_disable(char *s)
168{
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500169 cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -0700170 mips_dsp_disabled = 1;
171
172 return 1;
173}
174
175__setup("nodsp", dsp_disable);
176
Markos Chandras3d528b32014-07-14 12:46:13 +0100177static int mips_htw_disabled;
178
179static int __init htw_disable(char *s)
180{
181 mips_htw_disabled = 1;
182 cpu_data[0].options &= ~MIPS_CPU_HTW;
183 write_c0_pwctl(read_c0_pwctl() &
184 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
185
186 return 1;
187}
188
189__setup("nohtw", htw_disable);
190
Markos Chandras97f4ad22014-08-29 09:37:26 +0100191static int mips_ftlb_disabled;
192static int mips_has_ftlb_configured;
193
Markos Chandras912708c2015-07-09 10:40:51 +0100194static int set_ftlb_enable(struct cpuinfo_mips *c, int enable);
Markos Chandras97f4ad22014-08-29 09:37:26 +0100195
196static int __init ftlb_disable(char *s)
197{
198 unsigned int config4, mmuextdef;
199
200 /*
201 * If the core hasn't done any FTLB configuration, there is nothing
202 * for us to do here.
203 */
204 if (!mips_has_ftlb_configured)
205 return 1;
206
207 /* Disable it in the boot cpu */
Markos Chandras912708c2015-07-09 10:40:51 +0100208 if (set_ftlb_enable(&cpu_data[0], 0)) {
209 pr_warn("Can't turn FTLB off\n");
210 return 1;
211 }
Markos Chandras97f4ad22014-08-29 09:37:26 +0100212
213 back_to_back_c0_hazard();
214
215 config4 = read_c0_config4();
216
217 /* Check that FTLB has been disabled */
218 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
219 /* MMUSIZEEXT == VTLB ON, FTLB OFF */
220 if (mmuextdef == MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT) {
221 /* This should never happen */
222 pr_warn("FTLB could not be disabled!\n");
223 return 1;
224 }
225
226 mips_ftlb_disabled = 1;
227 mips_has_ftlb_configured = 0;
228
229 /*
230 * noftlb is mainly used for debug purposes so print
231 * an informative message instead of using pr_debug()
232 */
233 pr_info("FTLB has been disabled\n");
234
235 /*
236 * Some of these bits are duplicated in the decode_config4.
237 * MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT is the only possible case
238 * once FTLB has been disabled so undo what decode_config4 did.
239 */
240 cpu_data[0].tlbsize -= cpu_data[0].tlbsizeftlbways *
241 cpu_data[0].tlbsizeftlbsets;
242 cpu_data[0].tlbsizeftlbsets = 0;
243 cpu_data[0].tlbsizeftlbways = 0;
244
245 return 1;
246}
247
248__setup("noftlb", ftlb_disable);
249
250
Marc St-Jean9267a302007-06-14 15:55:31 -0600251static inline void check_errata(void)
252{
253 struct cpuinfo_mips *c = &current_cpu_data;
254
Ralf Baechle69f24d12013-09-17 10:25:47 +0200255 switch (current_cpu_type()) {
Marc St-Jean9267a302007-06-14 15:55:31 -0600256 case CPU_34K:
257 /*
258 * Erratum "RPS May Cause Incorrect Instruction Execution"
Ralf Baechleb633648c52014-05-23 16:29:44 +0200259 * This code only handles VPE0, any SMP/RTOS code
Marc St-Jean9267a302007-06-14 15:55:31 -0600260 * making use of VPE1 will be responsable for that VPE.
261 */
262 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
263 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
264 break;
265 default:
266 break;
267 }
268}
269
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270void __init check_bugs32(void)
271{
Marc St-Jean9267a302007-06-14 15:55:31 -0600272 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700273}
274
275/*
276 * Probe whether cpu has config register by trying to play with
277 * alternate cache bit and see whether it matters.
278 * It's used by cpu_probe to distinguish between R3000A and R3081.
279 */
280static inline int cpu_has_confreg(void)
281{
282#ifdef CONFIG_CPU_R3000
283 extern unsigned long r3k_cache_size(unsigned long);
284 unsigned long size1, size2;
285 unsigned long cfg = read_c0_conf();
286
287 size1 = r3k_cache_size(ST0_ISC);
288 write_c0_conf(cfg ^ R30XX_CONF_AC);
289 size2 = r3k_cache_size(ST0_ISC);
290 write_c0_conf(cfg);
291 return size1 != size2;
292#else
293 return 0;
294#endif
295}
296
Robert Millanc094c992011-04-18 11:37:55 -0700297static inline void set_elf_platform(int cpu, const char *plat)
298{
299 if (cpu == 0)
300 __elf_platform = plat;
301}
302
Guenter Roeck91dfc422010-02-02 08:52:20 -0800303static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
304{
305#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800306 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800307 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800308 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800309#endif
310}
311
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000312static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
Steven J. Hilla96102b2012-12-07 04:31:36 +0000313{
314 switch (isa) {
315 case MIPS_CPU_ISA_M64R2:
316 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
317 case MIPS_CPU_ISA_M64R1:
318 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
319 case MIPS_CPU_ISA_V:
320 c->isa_level |= MIPS_CPU_ISA_V;
321 case MIPS_CPU_ISA_IV:
322 c->isa_level |= MIPS_CPU_ISA_IV;
323 case MIPS_CPU_ISA_III:
Ralf Baechle1990e542013-06-26 17:06:34 +0200324 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000325 break;
326
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000327 /* R6 incompatible with everything else */
328 case MIPS_CPU_ISA_M64R6:
329 c->isa_level |= MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6;
330 case MIPS_CPU_ISA_M32R6:
331 c->isa_level |= MIPS_CPU_ISA_M32R6;
332 /* Break here so we don't add incompatible ISAs */
333 break;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000334 case MIPS_CPU_ISA_M32R2:
335 c->isa_level |= MIPS_CPU_ISA_M32R2;
336 case MIPS_CPU_ISA_M32R1:
337 c->isa_level |= MIPS_CPU_ISA_M32R1;
338 case MIPS_CPU_ISA_II:
339 c->isa_level |= MIPS_CPU_ISA_II;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000340 break;
341 }
342}
343
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000344static char unknown_isa[] = KERN_ERR \
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100345 "Unsupported ISA type, c0.config0: %d.";
346
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000347static unsigned int calculate_ftlb_probability(struct cpuinfo_mips *c)
348{
349
350 unsigned int probability = c->tlbsize / c->tlbsizevtlb;
351
352 /*
353 * 0 = All TLBWR instructions go to FTLB
354 * 1 = 15:1: For every 16 TBLWR instructions, 15 go to the
355 * FTLB and 1 goes to the VTLB.
356 * 2 = 7:1: As above with 7:1 ratio.
357 * 3 = 3:1: As above with 3:1 ratio.
358 *
359 * Use the linear midpoint as the probability threshold.
360 */
361 if (probability >= 12)
362 return 1;
363 else if (probability >= 6)
364 return 2;
365 else
366 /*
367 * So FTLB is less than 4 times bigger than VTLB.
368 * A 3:1 ratio can still be useful though.
369 */
370 return 3;
371}
372
Markos Chandras912708c2015-07-09 10:40:51 +0100373static int set_ftlb_enable(struct cpuinfo_mips *c, int enable)
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000374{
Markos Chandras20a7f7e2015-07-09 10:40:53 +0100375 unsigned int config;
James Hogand83b0e82014-01-22 16:19:40 +0000376
377 /* It's implementation dependent how the FTLB can be enabled */
378 switch (c->cputype) {
379 case CPU_PROAPTIV:
380 case CPU_P5600:
381 /* proAptiv & related cores use Config6 to enable the FTLB */
Markos Chandras20a7f7e2015-07-09 10:40:53 +0100382 config = read_c0_config6();
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000383 /* Clear the old probability value */
Markos Chandras20a7f7e2015-07-09 10:40:53 +0100384 config &= ~(3 << MIPS_CONF6_FTLBP_SHIFT);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000385 if (enable)
386 /* Enable FTLB */
Markos Chandras20a7f7e2015-07-09 10:40:53 +0100387 write_c0_config6(config |
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000388 (calculate_ftlb_probability(c)
389 << MIPS_CONF6_FTLBP_SHIFT)
390 | MIPS_CONF6_FTLBEN);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000391 else
392 /* Disable FTLB */
Markos Chandras20a7f7e2015-07-09 10:40:53 +0100393 write_c0_config6(config & ~MIPS_CONF6_FTLBEN);
394 break;
395 case CPU_I6400:
396 /* I6400 & related cores use Config7 to configure FTLB */
397 config = read_c0_config7();
398 /* Clear the old probability value */
399 config &= ~(3 << MIPS_CONF7_FTLBP_SHIFT);
400 write_c0_config7(config | (calculate_ftlb_probability(c)
401 << MIPS_CONF7_FTLBP_SHIFT));
James Hogand83b0e82014-01-22 16:19:40 +0000402 break;
Markos Chandras912708c2015-07-09 10:40:51 +0100403 default:
404 return 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000405 }
Markos Chandras912708c2015-07-09 10:40:51 +0100406
407 return 0;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000408}
409
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100410static inline unsigned int decode_config0(struct cpuinfo_mips *c)
411{
412 unsigned int config0;
James Hogan2f6f3132015-09-17 17:49:20 +0100413 int isa, mt;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100414
415 config0 = read_c0_config();
416
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000417 /*
418 * Look for Standard TLB or Dual VTLB and FTLB
419 */
James Hogan2f6f3132015-09-17 17:49:20 +0100420 mt = config0 & MIPS_CONF_MT;
421 if (mt == MIPS_CONF_MT_TLB)
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100422 c->options |= MIPS_CPU_TLB;
James Hogan2f6f3132015-09-17 17:49:20 +0100423 else if (mt == MIPS_CONF_MT_FTLB)
424 c->options |= MIPS_CPU_TLB | MIPS_CPU_FTLB;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000425
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100426 isa = (config0 & MIPS_CONF_AT) >> 13;
427 switch (isa) {
428 case 0:
429 switch ((config0 & MIPS_CONF_AR) >> 10) {
430 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000431 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100432 break;
433 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000434 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100435 break;
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000436 case 2:
437 set_isa(c, MIPS_CPU_ISA_M32R6);
438 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100439 default:
440 goto unknown;
441 }
442 break;
443 case 2:
444 switch ((config0 & MIPS_CONF_AR) >> 10) {
445 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000446 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100447 break;
448 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000449 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100450 break;
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000451 case 2:
452 set_isa(c, MIPS_CPU_ISA_M64R6);
453 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100454 default:
455 goto unknown;
456 }
457 break;
458 default:
459 goto unknown;
460 }
461
462 return config0 & MIPS_CONF_M;
463
464unknown:
465 panic(unknown_isa, config0);
466}
467
468static inline unsigned int decode_config1(struct cpuinfo_mips *c)
469{
470 unsigned int config1;
471
472 config1 = read_c0_config1();
473
474 if (config1 & MIPS_CONF1_MD)
475 c->ases |= MIPS_ASE_MDMX;
476 if (config1 & MIPS_CONF1_WR)
477 c->options |= MIPS_CPU_WATCH;
478 if (config1 & MIPS_CONF1_CA)
479 c->ases |= MIPS_ASE_MIPS16;
480 if (config1 & MIPS_CONF1_EP)
481 c->options |= MIPS_CPU_EJTAG;
482 if (config1 & MIPS_CONF1_FP) {
483 c->options |= MIPS_CPU_FPU;
484 c->options |= MIPS_CPU_32FPR;
485 }
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000486 if (cpu_has_tlb) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100487 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000488 c->tlbsizevtlb = c->tlbsize;
489 c->tlbsizeftlbsets = 0;
490 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100491
492 return config1 & MIPS_CONF_M;
493}
494
495static inline unsigned int decode_config2(struct cpuinfo_mips *c)
496{
497 unsigned int config2;
498
499 config2 = read_c0_config2();
500
501 if (config2 & MIPS_CONF2_SL)
502 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
503
504 return config2 & MIPS_CONF_M;
505}
506
507static inline unsigned int decode_config3(struct cpuinfo_mips *c)
508{
509 unsigned int config3;
510
511 config3 = read_c0_config3();
512
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500513 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100514 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500515 c->options |= MIPS_CPU_RIXI;
516 }
517 if (config3 & MIPS_CONF3_RXI)
518 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100519 if (config3 & MIPS_CONF3_DSP)
520 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500521 if (config3 & MIPS_CONF3_DSP2P)
522 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100523 if (config3 & MIPS_CONF3_VINT)
524 c->options |= MIPS_CPU_VINT;
525 if (config3 & MIPS_CONF3_VEIC)
526 c->options |= MIPS_CPU_VEIC;
527 if (config3 & MIPS_CONF3_MT)
528 c->ases |= MIPS_ASE_MIPSMT;
529 if (config3 & MIPS_CONF3_ULRI)
530 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000531 if (config3 & MIPS_CONF3_ISA)
532 c->options |= MIPS_CPU_MICROMIPS;
David Daney1e7decd2013-02-16 23:42:43 +0100533 if (config3 & MIPS_CONF3_VZ)
534 c->ases |= MIPS_ASE_VZ;
Steven J. Hill4a0156f2013-11-14 16:12:24 +0000535 if (config3 & MIPS_CONF3_SC)
536 c->options |= MIPS_CPU_SEGMENTS;
Paul Burtona5e9a692014-01-27 15:23:10 +0000537 if (config3 & MIPS_CONF3_MSA)
538 c->ases |= MIPS_ASE_MSA;
Paul Burtoncab25bc2015-09-22 12:03:37 -0700539 if (config3 & MIPS_CONF3_PW) {
Markos Chandrased4cbc82015-01-26 13:04:33 +0000540 c->htw_seq = 0;
Markos Chandras3d528b32014-07-14 12:46:13 +0100541 c->options |= MIPS_CPU_HTW;
Markos Chandrased4cbc82015-01-26 13:04:33 +0000542 }
James Hogan9b3274b2015-02-02 11:45:08 +0000543 if (config3 & MIPS_CONF3_CDMM)
544 c->options |= MIPS_CPU_CDMM;
James Hoganaaa7be42015-07-15 16:17:44 +0100545 if (config3 & MIPS_CONF3_SP)
546 c->options |= MIPS_CPU_SP;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100547
548 return config3 & MIPS_CONF_M;
549}
550
551static inline unsigned int decode_config4(struct cpuinfo_mips *c)
552{
553 unsigned int config4;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000554 unsigned int newcf4;
555 unsigned int mmuextdef;
556 unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100557
558 config4 = read_c0_config4();
559
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000560 if (cpu_has_tlb) {
561 if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
562 c->options |= MIPS_CPU_TLBINV;
James Hogan43d104d2015-09-17 17:49:21 +0100563
Markos Chandrase87569c2015-07-09 10:40:52 +0100564 /*
James Hogan43d104d2015-09-17 17:49:21 +0100565 * R6 has dropped the MMUExtDef field from config4.
566 * On R6 the fields always describe the FTLB, and only if it is
567 * present according to Config.MT.
Markos Chandrase87569c2015-07-09 10:40:52 +0100568 */
James Hogan43d104d2015-09-17 17:49:21 +0100569 if (!cpu_has_mips_r6)
570 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
571 else if (cpu_has_ftlb)
Markos Chandrase87569c2015-07-09 10:40:52 +0100572 mmuextdef = MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT;
573 else
James Hogan43d104d2015-09-17 17:49:21 +0100574 mmuextdef = 0;
Markos Chandrase87569c2015-07-09 10:40:52 +0100575
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000576 switch (mmuextdef) {
577 case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:
578 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
579 c->tlbsizevtlb = c->tlbsize;
580 break;
581 case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT:
582 c->tlbsizevtlb +=
583 ((config4 & MIPS_CONF4_VTLBSIZEEXT) >>
584 MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40;
585 c->tlbsize = c->tlbsizevtlb;
586 ftlb_page = MIPS_CONF4_VFTLBPAGESIZE;
587 /* fall through */
588 case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT:
Markos Chandras97f4ad22014-08-29 09:37:26 +0100589 if (mips_ftlb_disabled)
590 break;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000591 newcf4 = (config4 & ~ftlb_page) |
592 (page_size_ftlb(mmuextdef) <<
593 MIPS_CONF4_FTLBPAGESIZE_SHIFT);
594 write_c0_config4(newcf4);
595 back_to_back_c0_hazard();
596 config4 = read_c0_config4();
597 if (config4 != newcf4) {
598 pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
599 PAGE_SIZE, config4);
600 /* Switch FTLB off */
601 set_ftlb_enable(c, 0);
602 break;
603 }
604 c->tlbsizeftlbsets = 1 <<
605 ((config4 & MIPS_CONF4_FTLBSETS) >>
606 MIPS_CONF4_FTLBSETS_SHIFT);
607 c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >>
608 MIPS_CONF4_FTLBWAYS_SHIFT) + 2;
609 c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets;
Markos Chandras97f4ad22014-08-29 09:37:26 +0100610 mips_has_ftlb_configured = 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000611 break;
612 }
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000613 }
614
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100615 c->kscratch_mask = (config4 >> 16) & 0xff;
616
617 return config4 & MIPS_CONF_M;
618}
619
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200620static inline unsigned int decode_config5(struct cpuinfo_mips *c)
621{
622 unsigned int config5;
623
624 config5 = read_c0_config5();
Paul Burtond175ed22014-09-11 08:30:19 +0100625 config5 &= ~(MIPS_CONF5_UFR | MIPS_CONF5_UFE);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200626 write_c0_config5(config5);
627
Markos Chandras49016742014-01-09 16:04:51 +0000628 if (config5 & MIPS_CONF5_EVA)
629 c->options |= MIPS_CPU_EVA;
Paul Burton1f6c52f2014-07-14 10:32:14 +0100630 if (config5 & MIPS_CONF5_MRP)
631 c->options |= MIPS_CPU_MAAR;
Markos Chandras5aed9da2014-12-02 09:46:19 +0000632 if (config5 & MIPS_CONF5_LLB)
633 c->options |= MIPS_CPU_RW_LLB;
Steven J. Hillc5b36782015-02-26 18:16:38 -0600634#ifdef CONFIG_XPA
635 if (config5 & MIPS_CONF5_MVH)
636 c->options |= MIPS_CPU_XPA;
637#endif
Markos Chandras49016742014-01-09 16:04:51 +0000638
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200639 return config5 & MIPS_CONF_M;
640}
641
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000642static void decode_configs(struct cpuinfo_mips *c)
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100643{
644 int ok;
645
646 /* MIPS32 or MIPS64 compliant CPU. */
647 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
648 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
649
650 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
651
Markos Chandras97f4ad22014-08-29 09:37:26 +0100652 /* Enable FTLB if present and not disabled */
653 set_ftlb_enable(c, !mips_ftlb_disabled);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000654
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100655 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100656 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100657 if (ok)
658 ok = decode_config1(c);
659 if (ok)
660 ok = decode_config2(c);
661 if (ok)
662 ok = decode_config3(c);
663 if (ok)
664 ok = decode_config4(c);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200665 if (ok)
666 ok = decode_config5(c);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100667
668 mips_probe_watch_registers(c);
669
Leonid Yegoshin6575b1d2014-07-15 14:09:57 +0100670 if (cpu_has_rixi) {
671 /* Enable the RIXI exceptions */
Steven J. Hilla5770df2015-02-19 10:18:52 -0600672 set_c0_pagegrain(PG_IEC);
Leonid Yegoshin6575b1d2014-07-15 14:09:57 +0100673 back_to_back_c0_hazard();
674 /* Verify the IEC bit is set */
675 if (read_c0_pagegrain() & PG_IEC)
676 c->options |= MIPS_CPU_RIXIEX;
677 }
678
Paul Burton0ee958e2014-01-15 10:31:53 +0000679#ifndef CONFIG_MIPS_CPS
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000680 if (cpu_has_mips_r2_r6) {
David Daney45b585c2014-05-28 23:52:10 +0200681 c->core = get_ebase_cpunum();
Paul Burton30ee6152014-03-27 10:57:30 +0000682 if (cpu_has_mipsmt)
683 c->core >>= fls(core_nvpes()) - 1;
684 }
Paul Burton0ee958e2014-01-15 10:31:53 +0000685#endif
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100686}
687
Ralf Baechle02cf2112005-10-01 13:06:32 +0100688#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700689 | MIPS_CPU_COUNTER)
690
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000691static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100693 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 case PRID_IMP_R2000:
695 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000696 __cpu_name[cpu] = "R2000";
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100697 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100698 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500699 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 if (__cpu_has_fpu())
701 c->options |= MIPS_CPU_FPU;
702 c->tlbsize = 64;
703 break;
704 case PRID_IMP_R3000:
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100705 if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000706 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700707 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000708 __cpu_name[cpu] = "R3081";
709 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000711 __cpu_name[cpu] = "R3000A";
712 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000713 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000715 __cpu_name[cpu] = "R3000";
716 }
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100717 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100718 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500719 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 if (__cpu_has_fpu())
721 c->options |= MIPS_CPU_FPU;
722 c->tlbsize = 64;
723 break;
724 case PRID_IMP_R4000:
725 if (read_c0_config() & CONF_SC) {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100726 if ((c->processor_id & PRID_REV_MASK) >=
727 PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000729 __cpu_name[cpu] = "R4400PC";
730 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000732 __cpu_name[cpu] = "R4000PC";
733 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100735 int cca = read_c0_config() & CONF_CM_CMASK;
736 int mc;
737
738 /*
739 * SC and MC versions can't be reliably told apart,
740 * but only the latter support coherent caching
741 * modes so assume the firmware has set the KSEG0
742 * coherency attribute reasonably (if uncached, we
743 * assume SC).
744 */
745 switch (cca) {
746 case CONF_CM_CACHABLE_CE:
747 case CONF_CM_CACHABLE_COW:
748 case CONF_CM_CACHABLE_CUW:
749 mc = 1;
750 break;
751 default:
752 mc = 0;
753 break;
754 }
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100755 if ((c->processor_id & PRID_REV_MASK) >=
756 PRID_REV_R4400) {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100757 c->cputype = mc ? CPU_R4400MC : CPU_R4400SC;
758 __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000759 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100760 c->cputype = mc ? CPU_R4000MC : CPU_R4000SC;
761 __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000762 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700763 }
764
Steven J. Hilla96102b2012-12-07 04:31:36 +0000765 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100766 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500768 MIPS_CPU_WATCH | MIPS_CPU_VCE |
769 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770 c->tlbsize = 48;
771 break;
772 case PRID_IMP_VR41XX:
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900773 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100774 c->fpu_msk31 |= FPU_CSR_CONDX;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900775 c->options = R4K_OPTS;
776 c->tlbsize = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700777 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 case PRID_REV_VR4111:
779 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000780 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 case PRID_REV_VR4121:
783 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000784 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700785 break;
786 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000787 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000789 __cpu_name[cpu] = "NEC VR4122";
790 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000792 __cpu_name[cpu] = "NEC VR4181A";
793 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 break;
795 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000796 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000798 __cpu_name[cpu] = "NEC VR4131";
799 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 c->cputype = CPU_VR4133;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900801 c->options |= MIPS_CPU_LLSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000802 __cpu_name[cpu] = "NEC VR4133";
803 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 break;
805 default:
806 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
807 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000808 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 break;
810 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 break;
812 case PRID_IMP_R4300:
813 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000814 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000815 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100816 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500818 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 c->tlbsize = 32;
820 break;
821 case PRID_IMP_R4600:
822 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000823 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000824 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100825 c->fpu_msk31 |= FPU_CSR_CONDX;
Thiemo Seufer075e7502005-07-27 21:48:12 +0000826 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
827 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828 c->tlbsize = 48;
829 break;
830 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500831 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 /*
833 * This processor doesn't have an MMU, so it's not
834 * "real easy" to run Linux on it. It is left purely
835 * for documentation. Commented out because it shares
836 * it's c0_prid id number with the TX3900.
837 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000838 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000839 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000840 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100841 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500843 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844 break;
845 #endif
846 case PRID_IMP_TX39:
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100847 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Ralf Baechle02cf2112005-10-01 13:06:32 +0100848 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700849
850 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
851 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000852 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 c->tlbsize = 64;
854 } else {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100855 switch (c->processor_id & PRID_REV_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856 case PRID_REV_TX3912:
857 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000858 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700859 c->tlbsize = 32;
860 break;
861 case PRID_REV_TX3922:
862 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000863 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 c->tlbsize = 64;
865 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 }
867 }
868 break;
869 case PRID_IMP_R4700:
870 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000871 __cpu_name[cpu] = "R4700";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000872 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100873 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700874 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500875 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700876 c->tlbsize = 48;
877 break;
878 case PRID_IMP_TX49:
879 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000880 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000881 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100882 c->fpu_msk31 |= FPU_CSR_CONDX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883 c->options = R4K_OPTS | MIPS_CPU_LLSC;
884 if (!(c->processor_id & 0x08))
885 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
886 c->tlbsize = 48;
887 break;
888 case PRID_IMP_R5000:
889 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000890 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000891 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500893 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894 c->tlbsize = 48;
895 break;
896 case PRID_IMP_R5432:
897 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000898 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000899 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500901 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 c->tlbsize = 48;
903 break;
904 case PRID_IMP_R5500:
905 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000906 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000907 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500909 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910 c->tlbsize = 48;
911 break;
912 case PRID_IMP_NEVADA:
913 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000914 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000915 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500917 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918 c->tlbsize = 48;
919 break;
920 case PRID_IMP_R6000:
921 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000922 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000923 set_isa(c, MIPS_CPU_ISA_II);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100924 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500926 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 c->tlbsize = 32;
928 break;
929 case PRID_IMP_R6000A:
930 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000931 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000932 set_isa(c, MIPS_CPU_ISA_II);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +0100933 c->fpu_msk31 |= FPU_CSR_CONDX | FPU_CSR_FS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500935 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 c->tlbsize = 32;
937 break;
938 case PRID_IMP_RM7000:
939 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000940 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000941 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500943 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100945 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700946 * the RM7000 v2.0 indicates if the TLB has 48 or 64
947 * entries.
948 *
Ralf Baechle70342282013-01-22 12:59:30 +0100949 * 29 1 => 64 entry JTLB
950 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951 */
952 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
953 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954 case PRID_IMP_R8000:
955 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000956 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000957 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700958 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500959 MIPS_CPU_FPU | MIPS_CPU_32FPR |
960 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700961 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
962 break;
963 case PRID_IMP_R10000:
964 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000965 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000966 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000967 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500968 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500970 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971 c->tlbsize = 64;
972 break;
973 case PRID_IMP_R12000:
974 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000975 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000976 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000977 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500978 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700979 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Joshua Kinard8d5ded12015-06-02 18:21:33 -0400980 MIPS_CPU_LLSC | MIPS_CPU_BP_GHIST;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700981 c->tlbsize = 64;
982 break;
Kumba44d921b2006-05-16 22:23:59 -0400983 case PRID_IMP_R14000:
Joshua Kinard30577392015-01-21 07:59:45 -0500984 if (((c->processor_id >> 4) & 0x0f) > 2) {
985 c->cputype = CPU_R16000;
986 __cpu_name[cpu] = "R16000";
987 } else {
988 c->cputype = CPU_R14000;
989 __cpu_name[cpu] = "R14000";
990 }
Steven J. Hilla96102b2012-12-07 04:31:36 +0000991 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400992 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500993 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400994 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Joshua Kinard8d5ded12015-06-02 18:21:33 -0400995 MIPS_CPU_LLSC | MIPS_CPU_BP_GHIST;
Kumba44d921b2006-05-16 22:23:59 -0400996 c->tlbsize = 64;
997 break;
Huacai Chen26859192014-02-16 16:01:18 +0800998 case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */
Robert Millan5aac1e82011-04-16 11:29:29 -0700999 switch (c->processor_id & PRID_REV_MASK) {
1000 case PRID_REV_LOONGSON2E:
Huacai Chenc579d312014-03-21 18:44:00 +08001001 c->cputype = CPU_LOONGSON2;
1002 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -07001003 set_elf_platform(cpu, "loongson2e");
Huacai Chen7352c8b2014-11-04 14:13:23 +08001004 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +01001005 c->fpu_msk31 |= FPU_CSR_CONDX;
Robert Millan5aac1e82011-04-16 11:29:29 -07001006 break;
1007 case PRID_REV_LOONGSON2F:
Huacai Chenc579d312014-03-21 18:44:00 +08001008 c->cputype = CPU_LOONGSON2;
1009 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -07001010 set_elf_platform(cpu, "loongson2f");
Huacai Chen7352c8b2014-11-04 14:13:23 +08001011 set_isa(c, MIPS_CPU_ISA_III);
Maciej W. Rozycki9b266162015-04-03 23:27:48 +01001012 c->fpu_msk31 |= FPU_CSR_CONDX;
Robert Millan5aac1e82011-04-16 11:29:29 -07001013 break;
Huacai Chenc579d312014-03-21 18:44:00 +08001014 case PRID_REV_LOONGSON3A:
1015 c->cputype = CPU_LOONGSON3;
1016 __cpu_name[cpu] = "ICT Loongson-3";
1017 set_elf_platform(cpu, "loongson3a");
Huacai Chen7352c8b2014-11-04 14:13:23 +08001018 set_isa(c, MIPS_CPU_ISA_M64R1);
Huacai Chenc579d312014-03-21 18:44:00 +08001019 break;
Huacai Chene7841be2014-06-26 11:41:30 +08001020 case PRID_REV_LOONGSON3B_R1:
1021 case PRID_REV_LOONGSON3B_R2:
1022 c->cputype = CPU_LOONGSON3;
1023 __cpu_name[cpu] = "ICT Loongson-3";
1024 set_elf_platform(cpu, "loongson3b");
Huacai Chen7352c8b2014-11-04 14:13:23 +08001025 set_isa(c, MIPS_CPU_ISA_M64R1);
Huacai Chene7841be2014-06-26 11:41:30 +08001026 break;
Robert Millan5aac1e82011-04-16 11:29:29 -07001027 }
1028
Fuxin Zhang2a21c732007-06-06 14:52:43 +08001029 c->options = R4K_OPTS |
1030 MIPS_CPU_FPU | MIPS_CPU_LLSC |
1031 MIPS_CPU_32FPR;
1032 c->tlbsize = 64;
Huacai Chencc94ea32014-11-04 14:13:22 +08001033 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Fuxin Zhang2a21c732007-06-06 14:52:43 +08001034 break;
Huacai Chen26859192014-02-16 16:01:18 +08001035 case PRID_IMP_LOONGSON_32: /* Loongson-1 */
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001036 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001038 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +00001039
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001040 switch (c->processor_id & PRID_REV_MASK) {
1041 case PRID_REV_LOONGSON1B:
1042 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +00001043 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +00001044 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +01001045
Ralf Baechle41943182005-05-05 16:45:59 +00001046 break;
Ralf Baechle41943182005-05-05 16:45:59 +00001047 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001048}
1049
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001050static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051{
Markos Chandras4f12b912014-07-18 10:51:32 +01001052 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001053 switch (c->processor_id & PRID_IMP_MASK) {
Leonid Yegoshinb2498af2014-11-24 12:59:44 +00001054 case PRID_IMP_QEMU_GENERIC:
1055 c->writecombine = _CACHE_UNCACHED;
1056 c->cputype = CPU_QEMU_GENERIC;
1057 __cpu_name[cpu] = "MIPS GENERIC QEMU";
1058 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059 case PRID_IMP_4KC:
1060 c->cputype = CPU_4KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001061 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001062 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001063 break;
1064 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +00001065 case PRID_IMP_4KECR2:
1066 c->cputype = CPU_4KEC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001067 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001068 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +00001069 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001070 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +01001071 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001072 c->cputype = CPU_4KSC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001073 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001074 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001075 break;
1076 case PRID_IMP_5KC:
1077 c->cputype = CPU_5KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001078 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001079 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +02001081 case PRID_IMP_5KE:
1082 c->cputype = CPU_5KE;
Markos Chandras4f12b912014-07-18 10:51:32 +01001083 c->writecombine = _CACHE_UNCACHED;
Leonid Yegoshin78d48032012-07-06 21:56:01 +02001084 __cpu_name[cpu] = "MIPS 5KE";
1085 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001086 case PRID_IMP_20KC:
1087 c->cputype = CPU_20KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001088 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001089 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001090 break;
1091 case PRID_IMP_24K:
1092 c->cputype = CPU_24K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001093 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001094 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001095 break;
John Crispin42f3cae2013-01-11 22:44:10 +01001096 case PRID_IMP_24KE:
1097 c->cputype = CPU_24K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001098 c->writecombine = _CACHE_UNCACHED;
John Crispin42f3cae2013-01-11 22:44:10 +01001099 __cpu_name[cpu] = "MIPS 24KEc";
1100 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001101 case PRID_IMP_25KF:
1102 c->cputype = CPU_25KF;
Markos Chandras4f12b912014-07-18 10:51:32 +01001103 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001104 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +00001106 case PRID_IMP_34K:
1107 c->cputype = CPU_34K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001108 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001109 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +00001110 break;
Chris Dearmanc6209532006-05-02 14:08:46 +01001111 case PRID_IMP_74K:
1112 c->cputype = CPU_74K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001113 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001114 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +01001115 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +02001116 case PRID_IMP_M14KC:
1117 c->cputype = CPU_M14KC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001118 c->writecombine = _CACHE_UNCACHED;
Steven J. Hill113c62d2012-07-06 23:56:00 +02001119 __cpu_name[cpu] = "MIPS M14Kc";
1120 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +00001121 case PRID_IMP_M14KEC:
1122 c->cputype = CPU_M14KEC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001123 c->writecombine = _CACHE_UNCACHED;
Steven J. Hillf8fa4812012-12-07 03:51:35 +00001124 __cpu_name[cpu] = "MIPS M14KEc";
1125 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +01001126 case PRID_IMP_1004K:
1127 c->cputype = CPU_1004K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001128 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001129 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +01001130 break;
Steven J. Hill006a8512012-06-26 04:11:03 +00001131 case PRID_IMP_1074K:
Steven J. Hill442e14a2014-01-17 15:03:50 -06001132 c->cputype = CPU_1074K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001133 c->writecombine = _CACHE_UNCACHED;
Steven J. Hill006a8512012-06-26 04:11:03 +00001134 __cpu_name[cpu] = "MIPS 1074Kc";
1135 break;
Leonid Yegoshinb5f065e2013-11-20 10:46:02 +00001136 case PRID_IMP_INTERAPTIV_UP:
1137 c->cputype = CPU_INTERAPTIV;
1138 __cpu_name[cpu] = "MIPS interAptiv";
1139 break;
1140 case PRID_IMP_INTERAPTIV_MP:
1141 c->cputype = CPU_INTERAPTIV;
1142 __cpu_name[cpu] = "MIPS interAptiv (multi)";
1143 break;
Leonid Yegoshinb0d4d302013-11-14 16:12:28 +00001144 case PRID_IMP_PROAPTIV_UP:
1145 c->cputype = CPU_PROAPTIV;
1146 __cpu_name[cpu] = "MIPS proAptiv";
1147 break;
1148 case PRID_IMP_PROAPTIV_MP:
1149 c->cputype = CPU_PROAPTIV;
1150 __cpu_name[cpu] = "MIPS proAptiv (multi)";
1151 break;
James Hogan829dcc02014-01-22 16:19:39 +00001152 case PRID_IMP_P5600:
1153 c->cputype = CPU_P5600;
1154 __cpu_name[cpu] = "MIPS P5600";
1155 break;
Markos Chandrase57f9a22015-07-09 10:40:37 +01001156 case PRID_IMP_I6400:
1157 c->cputype = CPU_I6400;
1158 __cpu_name[cpu] = "MIPS I6400";
1159 break;
Leonid Yegoshin9943ed92014-03-04 13:34:44 +00001160 case PRID_IMP_M5150:
1161 c->cputype = CPU_M5150;
1162 __cpu_name[cpu] = "MIPS M5150";
1163 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001164 }
Chris Dearman0b6d4972007-09-13 12:32:02 +01001165
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +00001166 decode_configs(c);
1167
Chris Dearman0b6d4972007-09-13 12:32:02 +01001168 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001169}
1170
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001171static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001172{
Ralf Baechle41943182005-05-05 16:45:59 +00001173 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001174 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 case PRID_IMP_AU1_REV1:
1176 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +01001177 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 switch ((c->processor_id >> 24) & 0xff) {
1179 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001180 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 break;
1182 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001183 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001184 break;
1185 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001186 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187 break;
1188 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001189 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 break;
Pete Popove3ad1c22005-03-01 06:33:16 +00001191 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001192 __cpu_name[cpu] = "Au1200";
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001193 if ((c->processor_id & PRID_REV_MASK) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001194 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +01001195 break;
1196 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001197 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +00001198 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 default:
Manuel Lauss270717a2009-03-25 17:49:28 +01001200 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201 break;
1202 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001203 break;
1204 }
1205}
1206
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001207static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001208{
Ralf Baechle41943182005-05-05 16:45:59 +00001209 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +01001210
Markos Chandras4f12b912014-07-18 10:51:32 +01001211 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001212 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001213 case PRID_IMP_SB1:
1214 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001215 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001216 /* FPU in pass1 is known to have issues. */
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001217 if ((c->processor_id & PRID_REV_MASK) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +00001218 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -07001220 case PRID_IMP_SB1A:
1221 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001222 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -07001223 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001224 }
1225}
1226
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001227static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001228{
Ralf Baechle41943182005-05-05 16:45:59 +00001229 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001230 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231 case PRID_IMP_SR71000:
1232 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001233 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234 c->scache.ways = 8;
1235 c->tlbsize = 64;
1236 break;
1237 }
1238}
1239
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001240static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +00001241{
1242 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001243 switch (c->processor_id & PRID_IMP_MASK) {
Pete Popovbdf21b12005-07-14 17:47:57 +00001244 case PRID_IMP_PR4450:
1245 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001246 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +00001247 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +00001248 break;
Pete Popovbdf21b12005-07-14 17:47:57 +00001249 }
1250}
1251
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001252static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001253{
1254 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001255 switch (c->processor_id & PRID_IMP_MASK) {
Kevin Cernekee190fca32010-11-23 10:26:45 -08001256 case PRID_IMP_BMIPS32_REV4:
1257 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -07001258 c->cputype = CPU_BMIPS32;
1259 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001260 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001261 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001262 case PRID_IMP_BMIPS3300:
1263 case PRID_IMP_BMIPS3300_ALT:
1264 case PRID_IMP_BMIPS3300_BUG:
1265 c->cputype = CPU_BMIPS3300;
1266 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001267 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001268 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001269 case PRID_IMP_BMIPS43XX: {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001270 int rev = c->processor_id & PRID_REV_MASK;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001271
1272 if (rev >= PRID_REV_BMIPS4380_LO &&
1273 rev <= PRID_REV_BMIPS4380_HI) {
1274 c->cputype = CPU_BMIPS4380;
1275 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001276 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001277 } else {
1278 c->cputype = CPU_BMIPS4350;
1279 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001280 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +01001281 }
1282 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001283 }
Kevin Cernekee602977b2010-10-16 14:22:30 -07001284 case PRID_IMP_BMIPS5000:
Kevin Cernekee68e6a782014-10-20 21:28:01 -07001285 case PRID_IMP_BMIPS5200:
Kevin Cernekee602977b2010-10-16 14:22:30 -07001286 c->cputype = CPU_BMIPS5000;
1287 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001288 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001289 c->options |= MIPS_CPU_ULRI;
1290 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001291 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001292}
1293
David Daney0dd47812008-12-11 15:33:26 -08001294static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
1295{
1296 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001297 switch (c->processor_id & PRID_IMP_MASK) {
David Daney0dd47812008-12-11 15:33:26 -08001298 case PRID_IMP_CAVIUM_CN38XX:
1299 case PRID_IMP_CAVIUM_CN31XX:
1300 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -08001301 c->cputype = CPU_CAVIUM_OCTEON;
1302 __cpu_name[cpu] = "Cavium Octeon";
1303 goto platform;
David Daney0dd47812008-12-11 15:33:26 -08001304 case PRID_IMP_CAVIUM_CN58XX:
1305 case PRID_IMP_CAVIUM_CN56XX:
1306 case PRID_IMP_CAVIUM_CN50XX:
1307 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -08001308 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
1309 __cpu_name[cpu] = "Cavium Octeon+";
1310platform:
Robert Millanc094c992011-04-18 11:37:55 -07001311 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -08001312 break;
David Daneya1431b62011-09-24 02:29:54 +02001313 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -07001314 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +02001315 case PRID_IMP_CAVIUM_CN66XX:
1316 case PRID_IMP_CAVIUM_CN68XX:
David Daneyaf04bb82013-07-29 15:07:01 -07001317 case PRID_IMP_CAVIUM_CNF71XX:
David Daney0e56b382010-10-07 16:03:45 -07001318 c->cputype = CPU_CAVIUM_OCTEON2;
1319 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001320 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001321 break;
David Daneyaf04bb82013-07-29 15:07:01 -07001322 case PRID_IMP_CAVIUM_CN70XX:
1323 case PRID_IMP_CAVIUM_CN78XX:
1324 c->cputype = CPU_CAVIUM_OCTEON3;
1325 __cpu_name[cpu] = "Cavium Octeon III";
1326 set_elf_platform(cpu, "octeon3");
1327 break;
David Daney0dd47812008-12-11 15:33:26 -08001328 default:
1329 printk(KERN_INFO "Unknown Octeon chip!\n");
1330 c->cputype = CPU_UNKNOWN;
1331 break;
1332 }
1333}
1334
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001335static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1336{
1337 decode_configs(c);
1338 /* JZRISC does not implement the CP0 counter. */
1339 c->options &= ~MIPS_CPU_COUNTER;
Maciej W. Rozycki06947aa2014-04-06 21:31:29 +01001340 BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001341 switch (c->processor_id & PRID_IMP_MASK) {
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001342 case PRID_IMP_JZRISC:
1343 c->cputype = CPU_JZRISC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001344 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001345 __cpu_name[cpu] = "Ingenic JZRISC";
1346 break;
1347 default:
1348 panic("Unknown Ingenic Processor ID!");
1349 break;
1350 }
1351}
1352
Jayachandran Ca7117c62011-05-11 12:04:58 +05301353static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1354{
1355 decode_configs(c);
1356
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001357 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
Manuel Lauss809f36c2011-11-01 20:03:30 +01001358 c->cputype = CPU_ALCHEMY;
1359 __cpu_name[cpu] = "Au1300";
1360 /* following stuff is not for Alchemy */
1361 return;
1362 }
1363
Ralf Baechle70342282013-01-22 12:59:30 +01001364 c->options = (MIPS_CPU_TLB |
1365 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301366 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +01001367 MIPS_CPU_DIVEC |
1368 MIPS_CPU_WATCH |
1369 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301370 MIPS_CPU_LLSC);
1371
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001372 switch (c->processor_id & PRID_IMP_MASK) {
Jayachandran C4ca86a22013-08-11 14:43:54 +05301373 case PRID_IMP_NETLOGIC_XLP2XX:
Jayachandran C8907c552013-12-21 16:52:20 +05301374 case PRID_IMP_NETLOGIC_XLP9XX:
Yonghong Song1c983982014-04-29 20:07:53 +05301375 case PRID_IMP_NETLOGIC_XLP5XX:
Jayachandran C4ca86a22013-08-11 14:43:54 +05301376 c->cputype = CPU_XLP;
1377 __cpu_name[cpu] = "Broadcom XLPII";
1378 break;
1379
Jayachandran C2aa54b22011-11-16 00:21:29 +00001380 case PRID_IMP_NETLOGIC_XLP8XX:
1381 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001382 c->cputype = CPU_XLP;
1383 __cpu_name[cpu] = "Netlogic XLP";
1384 break;
1385
Jayachandran Ca7117c62011-05-11 12:04:58 +05301386 case PRID_IMP_NETLOGIC_XLR732:
1387 case PRID_IMP_NETLOGIC_XLR716:
1388 case PRID_IMP_NETLOGIC_XLR532:
1389 case PRID_IMP_NETLOGIC_XLR308:
1390 case PRID_IMP_NETLOGIC_XLR532C:
1391 case PRID_IMP_NETLOGIC_XLR516C:
1392 case PRID_IMP_NETLOGIC_XLR508C:
1393 case PRID_IMP_NETLOGIC_XLR308C:
1394 c->cputype = CPU_XLR;
1395 __cpu_name[cpu] = "Netlogic XLR";
1396 break;
1397
1398 case PRID_IMP_NETLOGIC_XLS608:
1399 case PRID_IMP_NETLOGIC_XLS408:
1400 case PRID_IMP_NETLOGIC_XLS404:
1401 case PRID_IMP_NETLOGIC_XLS208:
1402 case PRID_IMP_NETLOGIC_XLS204:
1403 case PRID_IMP_NETLOGIC_XLS108:
1404 case PRID_IMP_NETLOGIC_XLS104:
1405 case PRID_IMP_NETLOGIC_XLS616B:
1406 case PRID_IMP_NETLOGIC_XLS608B:
1407 case PRID_IMP_NETLOGIC_XLS416B:
1408 case PRID_IMP_NETLOGIC_XLS412B:
1409 case PRID_IMP_NETLOGIC_XLS408B:
1410 case PRID_IMP_NETLOGIC_XLS404B:
1411 c->cputype = CPU_XLR;
1412 __cpu_name[cpu] = "Netlogic XLS";
1413 break;
1414
1415 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001416 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301417 c->processor_id);
1418 c->cputype = CPU_XLR;
1419 break;
1420 }
1421
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001422 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001423 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001424 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1425 /* This will be updated again after all threads are woken up */
1426 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1427 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001428 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001429 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1430 }
Jayachandran C7777b932013-06-11 14:41:35 +00001431 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301432}
1433
David Daney949e51b2010-10-14 11:32:33 -07001434#ifdef CONFIG_64BIT
1435/* For use by uaccess.h */
1436u64 __ua_limit;
1437EXPORT_SYMBOL(__ua_limit);
1438#endif
1439
Ralf Baechle9966db252007-10-11 23:46:17 +01001440const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001441const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001442
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001443void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001444{
1445 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001446 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001447
Ralf Baechle70342282013-01-22 12:59:30 +01001448 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001449 c->fpu_id = FPIR_IMP_NONE;
1450 c->cputype = CPU_UNKNOWN;
Markos Chandras4f12b912014-07-18 10:51:32 +01001451 c->writecombine = _CACHE_UNCACHED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001452
Maciej W. Rozycki9b266162015-04-03 23:27:48 +01001453 c->fpu_csr31 = FPU_CSR_RN;
1454 c->fpu_msk31 = FPU_CSR_RSVD | FPU_CSR_ABS2008 | FPU_CSR_NAN2008;
1455
Linus Torvalds1da177e2005-04-16 15:20:36 -07001456 c->processor_id = read_c0_prid();
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001457 switch (c->processor_id & PRID_COMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001458 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001459 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001460 break;
1461 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001462 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001463 break;
1464 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001465 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001466 break;
1467 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001468 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001469 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001470 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001471 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001472 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001473 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001474 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001475 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001476 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001477 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001478 break;
David Daney0dd47812008-12-11 15:33:26 -08001479 case PRID_COMP_CAVIUM:
1480 cpu_probe_cavium(c, cpu);
1481 break;
Paul Burton252617a2015-05-24 16:11:14 +01001482 case PRID_COMP_INGENIC_D0:
1483 case PRID_COMP_INGENIC_D1:
1484 case PRID_COMP_INGENIC_E1:
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001485 cpu_probe_ingenic(c, cpu);
1486 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301487 case PRID_COMP_NETLOGIC:
1488 cpu_probe_netlogic(c, cpu);
1489 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001490 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001491
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001492 BUG_ON(!__cpu_name[cpu]);
1493 BUG_ON(c->cputype == CPU_UNKNOWN);
1494
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001495 /*
1496 * Platform code can force the cpu type to optimize code
1497 * generation. In that case be sure the cpu type is correctly
1498 * manually setup otherwise it could trigger some nasty bugs.
1499 */
1500 BUG_ON(current_cpu_type() != c->cputype);
1501
Kevin Cernekee0103d232010-05-02 14:43:52 -07001502 if (mips_fpu_disabled)
1503 c->options &= ~MIPS_CPU_FPU;
1504
1505 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001506 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001507
Markos Chandras3d528b32014-07-14 12:46:13 +01001508 if (mips_htw_disabled) {
1509 c->options &= ~MIPS_CPU_HTW;
1510 write_c0_pwctl(read_c0_pwctl() &
1511 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
1512 }
1513
Maciej W. Rozycki7aecd5c2015-04-03 23:27:54 +01001514 if (c->options & MIPS_CPU_FPU)
1515 cpu_set_fpu_opts(c);
1516 else
1517 cpu_set_nofpu_opts(c);
Ralf Baechle9966db252007-10-11 23:46:17 +01001518
Joshua Kinard8d5ded12015-06-02 18:21:33 -04001519 if (cpu_has_bp_ghist)
1520 write_c0_r10k_diag(read_c0_r10k_diag() |
1521 R10K_DIAG_E_GHIST);
1522
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +00001523 if (cpu_has_mips_r2_r6) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001524 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001525 /* R2 has Performance Counter Interrupt indicator */
1526 c->options |= MIPS_CPU_PCI;
1527 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001528 else
1529 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001530
Paul Burton4c063032015-07-27 12:58:24 -07001531 if (cpu_has_mips_r6)
1532 elf_hwcap |= HWCAP_MIPS_R6;
1533
Paul Burtona8ad1362014-01-28 14:28:43 +00001534 if (cpu_has_msa) {
Paul Burtona5e9a692014-01-27 15:23:10 +00001535 c->msa_id = cpu_get_msa_id();
Paul Burtona8ad1362014-01-28 14:28:43 +00001536 WARN(c->msa_id & MSA_IR_WRPF,
1537 "Vector register partitioning unimplemented!");
Paul Burton3cc9fa72015-07-27 12:58:25 -07001538 elf_hwcap |= HWCAP_MIPS_MSA;
Paul Burtona8ad1362014-01-28 14:28:43 +00001539 }
Paul Burtona5e9a692014-01-27 15:23:10 +00001540
Guenter Roeck91dfc422010-02-02 08:52:20 -08001541 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001542
1543#ifdef CONFIG_64BIT
1544 if (cpu == 0)
1545 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1546#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001547}
1548
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001549void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001550{
1551 struct cpuinfo_mips *c = &current_cpu_data;
1552
Leonid Yegoshind9f897c2013-10-07 10:43:32 +01001553 pr_info("CPU%d revision is: %08x (%s)\n",
1554 smp_processor_id(), c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001555 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001556 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Paul Burtona5e9a692014-01-27 15:23:10 +00001557 if (cpu_has_msa)
1558 pr_info("MSA revision is: %08x\n", c->msa_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001559}