blob: cb436f585bfa03cb671018b17651505797d79998 [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>
Ralf Baechle69f24d12013-09-17 10:25:47 +020023#include <asm/cpu-type.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/fpu.h>
25#include <asm/mipsregs.h>
Paul Burton30ee6152014-03-27 10:57:30 +000026#include <asm/mipsmtregs.h>
Paul Burtona5e9a692014-01-27 15:23:10 +000027#include <asm/msa.h>
David Daney654f57b2008-09-23 00:07:16 -070028#include <asm/watch.h>
Paul Gortmaker06372a62011-07-23 16:26:41 -040029#include <asm/elf.h>
Markos Chandras4f12b912014-07-18 10:51:32 +010030#include <asm/pgtable-bits.h>
Chris Dearmana074f0e2009-07-10 01:51:27 -070031#include <asm/spram.h>
David Daney949e51b2010-10-14 11:32:33 -070032#include <asm/uaccess.h>
33
Paul Gortmaker078a55f2013-06-18 13:38:59 +000034static int mips_fpu_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -070035
36static int __init fpu_disable(char *s)
37{
38 cpu_data[0].options &= ~MIPS_CPU_FPU;
39 mips_fpu_disabled = 1;
40
41 return 1;
42}
43
44__setup("nofpu", fpu_disable);
45
Paul Gortmaker078a55f2013-06-18 13:38:59 +000046int mips_dsp_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -070047
48static int __init dsp_disable(char *s)
49{
Steven J. Hillee80f7c72012-08-03 10:26:04 -050050 cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -070051 mips_dsp_disabled = 1;
52
53 return 1;
54}
55
56__setup("nodsp", dsp_disable);
57
Markos Chandras3d528b32014-07-14 12:46:13 +010058static int mips_htw_disabled;
59
60static int __init htw_disable(char *s)
61{
62 mips_htw_disabled = 1;
63 cpu_data[0].options &= ~MIPS_CPU_HTW;
64 write_c0_pwctl(read_c0_pwctl() &
65 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
66
67 return 1;
68}
69
70__setup("nohtw", htw_disable);
71
Markos Chandras97f4ad22014-08-29 09:37:26 +010072static int mips_ftlb_disabled;
73static int mips_has_ftlb_configured;
74
75static void set_ftlb_enable(struct cpuinfo_mips *c, int enable);
76
77static int __init ftlb_disable(char *s)
78{
79 unsigned int config4, mmuextdef;
80
81 /*
82 * If the core hasn't done any FTLB configuration, there is nothing
83 * for us to do here.
84 */
85 if (!mips_has_ftlb_configured)
86 return 1;
87
88 /* Disable it in the boot cpu */
89 set_ftlb_enable(&cpu_data[0], 0);
90
91 back_to_back_c0_hazard();
92
93 config4 = read_c0_config4();
94
95 /* Check that FTLB has been disabled */
96 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
97 /* MMUSIZEEXT == VTLB ON, FTLB OFF */
98 if (mmuextdef == MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT) {
99 /* This should never happen */
100 pr_warn("FTLB could not be disabled!\n");
101 return 1;
102 }
103
104 mips_ftlb_disabled = 1;
105 mips_has_ftlb_configured = 0;
106
107 /*
108 * noftlb is mainly used for debug purposes so print
109 * an informative message instead of using pr_debug()
110 */
111 pr_info("FTLB has been disabled\n");
112
113 /*
114 * Some of these bits are duplicated in the decode_config4.
115 * MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT is the only possible case
116 * once FTLB has been disabled so undo what decode_config4 did.
117 */
118 cpu_data[0].tlbsize -= cpu_data[0].tlbsizeftlbways *
119 cpu_data[0].tlbsizeftlbsets;
120 cpu_data[0].tlbsizeftlbsets = 0;
121 cpu_data[0].tlbsizeftlbways = 0;
122
123 return 1;
124}
125
126__setup("noftlb", ftlb_disable);
127
128
Marc St-Jean9267a302007-06-14 15:55:31 -0600129static inline void check_errata(void)
130{
131 struct cpuinfo_mips *c = &current_cpu_data;
132
Ralf Baechle69f24d12013-09-17 10:25:47 +0200133 switch (current_cpu_type()) {
Marc St-Jean9267a302007-06-14 15:55:31 -0600134 case CPU_34K:
135 /*
136 * Erratum "RPS May Cause Incorrect Instruction Execution"
Ralf Baechleb633648c52014-05-23 16:29:44 +0200137 * This code only handles VPE0, any SMP/RTOS code
Marc St-Jean9267a302007-06-14 15:55:31 -0600138 * making use of VPE1 will be responsable for that VPE.
139 */
140 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
141 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
142 break;
143 default:
144 break;
145 }
146}
147
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148void __init check_bugs32(void)
149{
Marc St-Jean9267a302007-06-14 15:55:31 -0600150 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700151}
152
153/*
154 * Probe whether cpu has config register by trying to play with
155 * alternate cache bit and see whether it matters.
156 * It's used by cpu_probe to distinguish between R3000A and R3081.
157 */
158static inline int cpu_has_confreg(void)
159{
160#ifdef CONFIG_CPU_R3000
161 extern unsigned long r3k_cache_size(unsigned long);
162 unsigned long size1, size2;
163 unsigned long cfg = read_c0_conf();
164
165 size1 = r3k_cache_size(ST0_ISC);
166 write_c0_conf(cfg ^ R30XX_CONF_AC);
167 size2 = r3k_cache_size(ST0_ISC);
168 write_c0_conf(cfg);
169 return size1 != size2;
170#else
171 return 0;
172#endif
173}
174
Robert Millanc094c992011-04-18 11:37:55 -0700175static inline void set_elf_platform(int cpu, const char *plat)
176{
177 if (cpu == 0)
178 __elf_platform = plat;
179}
180
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181/*
182 * Get the FPU Implementation/Revision.
183 */
184static inline unsigned long cpu_get_fpu_id(void)
185{
186 unsigned long tmp, fpu_id;
187
188 tmp = read_c0_status();
Paul Burton597ce172013-11-22 13:12:07 +0000189 __enable_fpu(FPU_AS_IS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 fpu_id = read_32bit_cp1_register(CP1_REVISION);
191 write_c0_status(tmp);
192 return fpu_id;
193}
194
195/*
196 * Check the CPU has an FPU the official way.
197 */
198static inline int __cpu_has_fpu(void)
199{
Ralf Baechle635c99072014-10-21 14:12:49 +0200200 return (cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201}
202
Paul Burtona5e9a692014-01-27 15:23:10 +0000203static inline unsigned long cpu_get_msa_id(void)
204{
Paul Burton3587ea82014-07-11 16:44:34 +0100205 unsigned long status, msa_id;
Paul Burtona5e9a692014-01-27 15:23:10 +0000206
207 status = read_c0_status();
208 __enable_fpu(FPU_64BIT);
Paul Burtona5e9a692014-01-27 15:23:10 +0000209 enable_msa();
210 msa_id = read_msa_ir();
Paul Burton3587ea82014-07-11 16:44:34 +0100211 disable_msa();
Paul Burtona5e9a692014-01-27 15:23:10 +0000212 write_c0_status(status);
213 return msa_id;
214}
215
Guenter Roeck91dfc422010-02-02 08:52:20 -0800216static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
217{
218#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800219 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800220 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800221 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800222#endif
223}
224
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000225static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
Steven J. Hilla96102b2012-12-07 04:31:36 +0000226{
227 switch (isa) {
228 case MIPS_CPU_ISA_M64R2:
229 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
230 case MIPS_CPU_ISA_M64R1:
231 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
232 case MIPS_CPU_ISA_V:
233 c->isa_level |= MIPS_CPU_ISA_V;
234 case MIPS_CPU_ISA_IV:
235 c->isa_level |= MIPS_CPU_ISA_IV;
236 case MIPS_CPU_ISA_III:
Ralf Baechle1990e542013-06-26 17:06:34 +0200237 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000238 break;
239
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000240 /* R6 incompatible with everything else */
241 case MIPS_CPU_ISA_M64R6:
242 c->isa_level |= MIPS_CPU_ISA_M32R6 | MIPS_CPU_ISA_M64R6;
243 case MIPS_CPU_ISA_M32R6:
244 c->isa_level |= MIPS_CPU_ISA_M32R6;
245 /* Break here so we don't add incompatible ISAs */
246 break;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000247 case MIPS_CPU_ISA_M32R2:
248 c->isa_level |= MIPS_CPU_ISA_M32R2;
249 case MIPS_CPU_ISA_M32R1:
250 c->isa_level |= MIPS_CPU_ISA_M32R1;
251 case MIPS_CPU_ISA_II:
252 c->isa_level |= MIPS_CPU_ISA_II;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000253 break;
254 }
255}
256
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000257static char unknown_isa[] = KERN_ERR \
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100258 "Unsupported ISA type, c0.config0: %d.";
259
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000260static unsigned int calculate_ftlb_probability(struct cpuinfo_mips *c)
261{
262
263 unsigned int probability = c->tlbsize / c->tlbsizevtlb;
264
265 /*
266 * 0 = All TLBWR instructions go to FTLB
267 * 1 = 15:1: For every 16 TBLWR instructions, 15 go to the
268 * FTLB and 1 goes to the VTLB.
269 * 2 = 7:1: As above with 7:1 ratio.
270 * 3 = 3:1: As above with 3:1 ratio.
271 *
272 * Use the linear midpoint as the probability threshold.
273 */
274 if (probability >= 12)
275 return 1;
276 else if (probability >= 6)
277 return 2;
278 else
279 /*
280 * So FTLB is less than 4 times bigger than VTLB.
281 * A 3:1 ratio can still be useful though.
282 */
283 return 3;
284}
285
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000286static void set_ftlb_enable(struct cpuinfo_mips *c, int enable)
287{
288 unsigned int config6;
James Hogand83b0e82014-01-22 16:19:40 +0000289
290 /* It's implementation dependent how the FTLB can be enabled */
291 switch (c->cputype) {
292 case CPU_PROAPTIV:
293 case CPU_P5600:
294 /* proAptiv & related cores use Config6 to enable the FTLB */
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000295 config6 = read_c0_config6();
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000296 /* Clear the old probability value */
297 config6 &= ~(3 << MIPS_CONF6_FTLBP_SHIFT);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000298 if (enable)
299 /* Enable FTLB */
Markos Chandrascf0a8aa2014-11-10 12:25:34 +0000300 write_c0_config6(config6 |
301 (calculate_ftlb_probability(c)
302 << MIPS_CONF6_FTLBP_SHIFT)
303 | MIPS_CONF6_FTLBEN);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000304 else
305 /* Disable FTLB */
306 write_c0_config6(config6 & ~MIPS_CONF6_FTLBEN);
307 back_to_back_c0_hazard();
James Hogand83b0e82014-01-22 16:19:40 +0000308 break;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000309 }
310}
311
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100312static inline unsigned int decode_config0(struct cpuinfo_mips *c)
313{
314 unsigned int config0;
315 int isa;
316
317 config0 = read_c0_config();
318
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000319 /*
320 * Look for Standard TLB or Dual VTLB and FTLB
321 */
322 if ((((config0 & MIPS_CONF_MT) >> 7) == 1) ||
323 (((config0 & MIPS_CONF_MT) >> 7) == 4))
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100324 c->options |= MIPS_CPU_TLB;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000325
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100326 isa = (config0 & MIPS_CONF_AT) >> 13;
327 switch (isa) {
328 case 0:
329 switch ((config0 & MIPS_CONF_AR) >> 10) {
330 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000331 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100332 break;
333 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000334 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100335 break;
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000336 case 2:
337 set_isa(c, MIPS_CPU_ISA_M32R6);
338 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100339 default:
340 goto unknown;
341 }
342 break;
343 case 2:
344 switch ((config0 & MIPS_CONF_AR) >> 10) {
345 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000346 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100347 break;
348 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000349 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100350 break;
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000351 case 2:
352 set_isa(c, MIPS_CPU_ISA_M64R6);
353 break;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100354 default:
355 goto unknown;
356 }
357 break;
358 default:
359 goto unknown;
360 }
361
362 return config0 & MIPS_CONF_M;
363
364unknown:
365 panic(unknown_isa, config0);
366}
367
368static inline unsigned int decode_config1(struct cpuinfo_mips *c)
369{
370 unsigned int config1;
371
372 config1 = read_c0_config1();
373
374 if (config1 & MIPS_CONF1_MD)
375 c->ases |= MIPS_ASE_MDMX;
376 if (config1 & MIPS_CONF1_WR)
377 c->options |= MIPS_CPU_WATCH;
378 if (config1 & MIPS_CONF1_CA)
379 c->ases |= MIPS_ASE_MIPS16;
380 if (config1 & MIPS_CONF1_EP)
381 c->options |= MIPS_CPU_EJTAG;
382 if (config1 & MIPS_CONF1_FP) {
383 c->options |= MIPS_CPU_FPU;
384 c->options |= MIPS_CPU_32FPR;
385 }
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000386 if (cpu_has_tlb) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100387 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000388 c->tlbsizevtlb = c->tlbsize;
389 c->tlbsizeftlbsets = 0;
390 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100391
392 return config1 & MIPS_CONF_M;
393}
394
395static inline unsigned int decode_config2(struct cpuinfo_mips *c)
396{
397 unsigned int config2;
398
399 config2 = read_c0_config2();
400
401 if (config2 & MIPS_CONF2_SL)
402 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
403
404 return config2 & MIPS_CONF_M;
405}
406
407static inline unsigned int decode_config3(struct cpuinfo_mips *c)
408{
409 unsigned int config3;
410
411 config3 = read_c0_config3();
412
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500413 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100414 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500415 c->options |= MIPS_CPU_RIXI;
416 }
417 if (config3 & MIPS_CONF3_RXI)
418 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100419 if (config3 & MIPS_CONF3_DSP)
420 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500421 if (config3 & MIPS_CONF3_DSP2P)
422 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100423 if (config3 & MIPS_CONF3_VINT)
424 c->options |= MIPS_CPU_VINT;
425 if (config3 & MIPS_CONF3_VEIC)
426 c->options |= MIPS_CPU_VEIC;
427 if (config3 & MIPS_CONF3_MT)
428 c->ases |= MIPS_ASE_MIPSMT;
429 if (config3 & MIPS_CONF3_ULRI)
430 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000431 if (config3 & MIPS_CONF3_ISA)
432 c->options |= MIPS_CPU_MICROMIPS;
David Daney1e7decd2013-02-16 23:42:43 +0100433 if (config3 & MIPS_CONF3_VZ)
434 c->ases |= MIPS_ASE_VZ;
Steven J. Hill4a0156f2013-11-14 16:12:24 +0000435 if (config3 & MIPS_CONF3_SC)
436 c->options |= MIPS_CPU_SEGMENTS;
Paul Burtona5e9a692014-01-27 15:23:10 +0000437 if (config3 & MIPS_CONF3_MSA)
438 c->ases |= MIPS_ASE_MSA;
Markos Chandras3d528b32014-07-14 12:46:13 +0100439 /* Only tested on 32-bit cores */
Markos Chandrased4cbc82015-01-26 13:04:33 +0000440 if ((config3 & MIPS_CONF3_PW) && config_enabled(CONFIG_32BIT)) {
441 c->htw_seq = 0;
Markos Chandras3d528b32014-07-14 12:46:13 +0100442 c->options |= MIPS_CPU_HTW;
Markos Chandrased4cbc82015-01-26 13:04:33 +0000443 }
James Hogan9b3274b2015-02-02 11:45:08 +0000444 if (config3 & MIPS_CONF3_CDMM)
445 c->options |= MIPS_CPU_CDMM;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100446
447 return config3 & MIPS_CONF_M;
448}
449
450static inline unsigned int decode_config4(struct cpuinfo_mips *c)
451{
452 unsigned int config4;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000453 unsigned int newcf4;
454 unsigned int mmuextdef;
455 unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100456
457 config4 = read_c0_config4();
458
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000459 if (cpu_has_tlb) {
460 if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
461 c->options |= MIPS_CPU_TLBINV;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000462 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
463 switch (mmuextdef) {
464 case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:
465 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
466 c->tlbsizevtlb = c->tlbsize;
467 break;
468 case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT:
469 c->tlbsizevtlb +=
470 ((config4 & MIPS_CONF4_VTLBSIZEEXT) >>
471 MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40;
472 c->tlbsize = c->tlbsizevtlb;
473 ftlb_page = MIPS_CONF4_VFTLBPAGESIZE;
474 /* fall through */
475 case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT:
Markos Chandras97f4ad22014-08-29 09:37:26 +0100476 if (mips_ftlb_disabled)
477 break;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000478 newcf4 = (config4 & ~ftlb_page) |
479 (page_size_ftlb(mmuextdef) <<
480 MIPS_CONF4_FTLBPAGESIZE_SHIFT);
481 write_c0_config4(newcf4);
482 back_to_back_c0_hazard();
483 config4 = read_c0_config4();
484 if (config4 != newcf4) {
485 pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
486 PAGE_SIZE, config4);
487 /* Switch FTLB off */
488 set_ftlb_enable(c, 0);
489 break;
490 }
491 c->tlbsizeftlbsets = 1 <<
492 ((config4 & MIPS_CONF4_FTLBSETS) >>
493 MIPS_CONF4_FTLBSETS_SHIFT);
494 c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >>
495 MIPS_CONF4_FTLBWAYS_SHIFT) + 2;
496 c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets;
Markos Chandras97f4ad22014-08-29 09:37:26 +0100497 mips_has_ftlb_configured = 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000498 break;
499 }
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000500 }
501
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100502 c->kscratch_mask = (config4 >> 16) & 0xff;
503
504 return config4 & MIPS_CONF_M;
505}
506
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200507static inline unsigned int decode_config5(struct cpuinfo_mips *c)
508{
509 unsigned int config5;
510
511 config5 = read_c0_config5();
Paul Burtond175ed22014-09-11 08:30:19 +0100512 config5 &= ~(MIPS_CONF5_UFR | MIPS_CONF5_UFE);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200513 write_c0_config5(config5);
514
Markos Chandras49016742014-01-09 16:04:51 +0000515 if (config5 & MIPS_CONF5_EVA)
516 c->options |= MIPS_CPU_EVA;
Paul Burton1f6c52f2014-07-14 10:32:14 +0100517 if (config5 & MIPS_CONF5_MRP)
518 c->options |= MIPS_CPU_MAAR;
Markos Chandras5aed9da2014-12-02 09:46:19 +0000519 if (config5 & MIPS_CONF5_LLB)
520 c->options |= MIPS_CPU_RW_LLB;
Markos Chandras49016742014-01-09 16:04:51 +0000521
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200522 return config5 & MIPS_CONF_M;
523}
524
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000525static void decode_configs(struct cpuinfo_mips *c)
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100526{
527 int ok;
528
529 /* MIPS32 or MIPS64 compliant CPU. */
530 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
531 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
532
533 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
534
Markos Chandras97f4ad22014-08-29 09:37:26 +0100535 /* Enable FTLB if present and not disabled */
536 set_ftlb_enable(c, !mips_ftlb_disabled);
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000537
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100538 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100539 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100540 if (ok)
541 ok = decode_config1(c);
542 if (ok)
543 ok = decode_config2(c);
544 if (ok)
545 ok = decode_config3(c);
546 if (ok)
547 ok = decode_config4(c);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200548 if (ok)
549 ok = decode_config5(c);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100550
551 mips_probe_watch_registers(c);
552
Leonid Yegoshin6575b1d2014-07-15 14:09:57 +0100553 if (cpu_has_rixi) {
554 /* Enable the RIXI exceptions */
Steven J. Hilla5770df2015-02-19 10:18:52 -0600555 set_c0_pagegrain(PG_IEC);
Leonid Yegoshin6575b1d2014-07-15 14:09:57 +0100556 back_to_back_c0_hazard();
557 /* Verify the IEC bit is set */
558 if (read_c0_pagegrain() & PG_IEC)
559 c->options |= MIPS_CPU_RIXIEX;
560 }
561
Paul Burton0ee958e2014-01-15 10:31:53 +0000562#ifndef CONFIG_MIPS_CPS
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +0000563 if (cpu_has_mips_r2_r6) {
David Daney45b585c2014-05-28 23:52:10 +0200564 c->core = get_ebase_cpunum();
Paul Burton30ee6152014-03-27 10:57:30 +0000565 if (cpu_has_mipsmt)
566 c->core >>= fls(core_nvpes()) - 1;
567 }
Paul Burton0ee958e2014-01-15 10:31:53 +0000568#endif
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100569}
570
Ralf Baechle02cf2112005-10-01 13:06:32 +0100571#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 | MIPS_CPU_COUNTER)
573
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000574static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700575{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100576 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 case PRID_IMP_R2000:
578 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000579 __cpu_name[cpu] = "R2000";
Ralf Baechle02cf2112005-10-01 13:06:32 +0100580 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500581 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 if (__cpu_has_fpu())
583 c->options |= MIPS_CPU_FPU;
584 c->tlbsize = 64;
585 break;
586 case PRID_IMP_R3000:
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100587 if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000588 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000590 __cpu_name[cpu] = "R3081";
591 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000593 __cpu_name[cpu] = "R3000A";
594 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000595 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000597 __cpu_name[cpu] = "R3000";
598 }
Ralf Baechle02cf2112005-10-01 13:06:32 +0100599 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500600 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 if (__cpu_has_fpu())
602 c->options |= MIPS_CPU_FPU;
603 c->tlbsize = 64;
604 break;
605 case PRID_IMP_R4000:
606 if (read_c0_config() & CONF_SC) {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100607 if ((c->processor_id & PRID_REV_MASK) >=
608 PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000610 __cpu_name[cpu] = "R4400PC";
611 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000613 __cpu_name[cpu] = "R4000PC";
614 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100616 int cca = read_c0_config() & CONF_CM_CMASK;
617 int mc;
618
619 /*
620 * SC and MC versions can't be reliably told apart,
621 * but only the latter support coherent caching
622 * modes so assume the firmware has set the KSEG0
623 * coherency attribute reasonably (if uncached, we
624 * assume SC).
625 */
626 switch (cca) {
627 case CONF_CM_CACHABLE_CE:
628 case CONF_CM_CACHABLE_COW:
629 case CONF_CM_CACHABLE_CUW:
630 mc = 1;
631 break;
632 default:
633 mc = 0;
634 break;
635 }
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100636 if ((c->processor_id & PRID_REV_MASK) >=
637 PRID_REV_R4400) {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100638 c->cputype = mc ? CPU_R4400MC : CPU_R4400SC;
639 __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000640 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100641 c->cputype = mc ? CPU_R4000MC : CPU_R4000SC;
642 __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000643 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 }
645
Steven J. Hilla96102b2012-12-07 04:31:36 +0000646 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700647 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500648 MIPS_CPU_WATCH | MIPS_CPU_VCE |
649 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 c->tlbsize = 48;
651 break;
652 case PRID_IMP_VR41XX:
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900653 set_isa(c, MIPS_CPU_ISA_III);
654 c->options = R4K_OPTS;
655 c->tlbsize = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700657 case PRID_REV_VR4111:
658 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000659 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 case PRID_REV_VR4121:
662 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000663 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 break;
665 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000666 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000668 __cpu_name[cpu] = "NEC VR4122";
669 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000671 __cpu_name[cpu] = "NEC VR4181A";
672 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700673 break;
674 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000675 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000677 __cpu_name[cpu] = "NEC VR4131";
678 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 c->cputype = CPU_VR4133;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900680 c->options |= MIPS_CPU_LLSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000681 __cpu_name[cpu] = "NEC VR4133";
682 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 break;
684 default:
685 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
686 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000687 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 break;
689 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 break;
691 case PRID_IMP_R4300:
692 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000693 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000694 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700695 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500696 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 c->tlbsize = 32;
698 break;
699 case PRID_IMP_R4600:
700 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000701 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000702 set_isa(c, MIPS_CPU_ISA_III);
Thiemo Seufer075e7502005-07-27 21:48:12 +0000703 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
704 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700705 c->tlbsize = 48;
706 break;
707 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500708 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700709 /*
710 * This processor doesn't have an MMU, so it's not
711 * "real easy" to run Linux on it. It is left purely
712 * for documentation. Commented out because it shares
713 * it's c0_prid id number with the TX3900.
714 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000715 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000716 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000717 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500719 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 break;
721 #endif
722 case PRID_IMP_TX39:
Ralf Baechle02cf2112005-10-01 13:06:32 +0100723 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700724
725 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
726 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000727 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700728 c->tlbsize = 64;
729 } else {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100730 switch (c->processor_id & PRID_REV_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 case PRID_REV_TX3912:
732 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000733 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700734 c->tlbsize = 32;
735 break;
736 case PRID_REV_TX3922:
737 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000738 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 c->tlbsize = 64;
740 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 }
742 }
743 break;
744 case PRID_IMP_R4700:
745 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000746 __cpu_name[cpu] = "R4700";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000747 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700748 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500749 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700750 c->tlbsize = 48;
751 break;
752 case PRID_IMP_TX49:
753 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000754 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000755 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700756 c->options = R4K_OPTS | MIPS_CPU_LLSC;
757 if (!(c->processor_id & 0x08))
758 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
759 c->tlbsize = 48;
760 break;
761 case PRID_IMP_R5000:
762 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000763 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000764 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500766 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767 c->tlbsize = 48;
768 break;
769 case PRID_IMP_R5432:
770 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000771 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000772 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500774 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 c->tlbsize = 48;
776 break;
777 case PRID_IMP_R5500:
778 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000779 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000780 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500782 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700783 c->tlbsize = 48;
784 break;
785 case PRID_IMP_NEVADA:
786 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000787 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000788 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700789 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500790 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 c->tlbsize = 48;
792 break;
793 case PRID_IMP_R6000:
794 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000795 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000796 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500798 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799 c->tlbsize = 32;
800 break;
801 case PRID_IMP_R6000A:
802 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000803 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000804 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500806 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807 c->tlbsize = 32;
808 break;
809 case PRID_IMP_RM7000:
810 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000811 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000812 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500814 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100816 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 * the RM7000 v2.0 indicates if the TLB has 48 or 64
818 * entries.
819 *
Ralf Baechle70342282013-01-22 12:59:30 +0100820 * 29 1 => 64 entry JTLB
821 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822 */
823 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
824 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825 case PRID_IMP_R8000:
826 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000827 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000828 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500830 MIPS_CPU_FPU | MIPS_CPU_32FPR |
831 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700832 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
833 break;
834 case PRID_IMP_R10000:
835 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000836 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000837 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000838 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500839 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700840 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500841 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700842 c->tlbsize = 64;
843 break;
844 case PRID_IMP_R12000:
845 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000846 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000847 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000848 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500849 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700850 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500851 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852 c->tlbsize = 64;
853 break;
Kumba44d921b2006-05-16 22:23:59 -0400854 case PRID_IMP_R14000:
Joshua Kinard30577392015-01-21 07:59:45 -0500855 if (((c->processor_id >> 4) & 0x0f) > 2) {
856 c->cputype = CPU_R16000;
857 __cpu_name[cpu] = "R16000";
858 } else {
859 c->cputype = CPU_R14000;
860 __cpu_name[cpu] = "R14000";
861 }
Steven J. Hilla96102b2012-12-07 04:31:36 +0000862 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400863 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500864 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400865 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500866 MIPS_CPU_LLSC;
Kumba44d921b2006-05-16 22:23:59 -0400867 c->tlbsize = 64;
868 break;
Huacai Chen26859192014-02-16 16:01:18 +0800869 case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */
Robert Millan5aac1e82011-04-16 11:29:29 -0700870 switch (c->processor_id & PRID_REV_MASK) {
871 case PRID_REV_LOONGSON2E:
Huacai Chenc579d312014-03-21 18:44:00 +0800872 c->cputype = CPU_LOONGSON2;
873 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700874 set_elf_platform(cpu, "loongson2e");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800875 set_isa(c, MIPS_CPU_ISA_III);
Robert Millan5aac1e82011-04-16 11:29:29 -0700876 break;
877 case PRID_REV_LOONGSON2F:
Huacai Chenc579d312014-03-21 18:44:00 +0800878 c->cputype = CPU_LOONGSON2;
879 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700880 set_elf_platform(cpu, "loongson2f");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800881 set_isa(c, MIPS_CPU_ISA_III);
Robert Millan5aac1e82011-04-16 11:29:29 -0700882 break;
Huacai Chenc579d312014-03-21 18:44:00 +0800883 case PRID_REV_LOONGSON3A:
884 c->cputype = CPU_LOONGSON3;
885 __cpu_name[cpu] = "ICT Loongson-3";
886 set_elf_platform(cpu, "loongson3a");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800887 set_isa(c, MIPS_CPU_ISA_M64R1);
Huacai Chenc579d312014-03-21 18:44:00 +0800888 break;
Huacai Chene7841be2014-06-26 11:41:30 +0800889 case PRID_REV_LOONGSON3B_R1:
890 case PRID_REV_LOONGSON3B_R2:
891 c->cputype = CPU_LOONGSON3;
892 __cpu_name[cpu] = "ICT Loongson-3";
893 set_elf_platform(cpu, "loongson3b");
Huacai Chen7352c8b2014-11-04 14:13:23 +0800894 set_isa(c, MIPS_CPU_ISA_M64R1);
Huacai Chene7841be2014-06-26 11:41:30 +0800895 break;
Robert Millan5aac1e82011-04-16 11:29:29 -0700896 }
897
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800898 c->options = R4K_OPTS |
899 MIPS_CPU_FPU | MIPS_CPU_LLSC |
900 MIPS_CPU_32FPR;
901 c->tlbsize = 64;
Huacai Chencc94ea32014-11-04 14:13:22 +0800902 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800903 break;
Huacai Chen26859192014-02-16 16:01:18 +0800904 case PRID_IMP_LOONGSON_32: /* Loongson-1 */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100905 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100907 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000908
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100909 switch (c->processor_id & PRID_REV_MASK) {
910 case PRID_REV_LOONGSON1B:
911 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +0000912 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000913 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100914
Ralf Baechle41943182005-05-05 16:45:59 +0000915 break;
Ralf Baechle41943182005-05-05 16:45:59 +0000916 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917}
918
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000919static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920{
Markos Chandras4f12b912014-07-18 10:51:32 +0100921 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100922 switch (c->processor_id & PRID_IMP_MASK) {
Leonid Yegoshinb2498af2014-11-24 12:59:44 +0000923 case PRID_IMP_QEMU_GENERIC:
924 c->writecombine = _CACHE_UNCACHED;
925 c->cputype = CPU_QEMU_GENERIC;
926 __cpu_name[cpu] = "MIPS GENERIC QEMU";
927 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700928 case PRID_IMP_4KC:
929 c->cputype = CPU_4KC;
Markos Chandras4f12b912014-07-18 10:51:32 +0100930 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000931 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 break;
933 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000934 case PRID_IMP_4KECR2:
935 c->cputype = CPU_4KEC;
Markos Chandras4f12b912014-07-18 10:51:32 +0100936 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000937 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000938 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100940 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941 c->cputype = CPU_4KSC;
Markos Chandras4f12b912014-07-18 10:51:32 +0100942 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000943 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944 break;
945 case PRID_IMP_5KC:
946 c->cputype = CPU_5KC;
Markos Chandras4f12b912014-07-18 10:51:32 +0100947 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000948 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700949 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +0200950 case PRID_IMP_5KE:
951 c->cputype = CPU_5KE;
Markos Chandras4f12b912014-07-18 10:51:32 +0100952 c->writecombine = _CACHE_UNCACHED;
Leonid Yegoshin78d48032012-07-06 21:56:01 +0200953 __cpu_name[cpu] = "MIPS 5KE";
954 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 case PRID_IMP_20KC:
956 c->cputype = CPU_20KC;
Markos Chandras4f12b912014-07-18 10:51:32 +0100957 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000958 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959 break;
960 case PRID_IMP_24K:
961 c->cputype = CPU_24K;
Markos Chandras4f12b912014-07-18 10:51:32 +0100962 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000963 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700964 break;
John Crispin42f3cae2013-01-11 22:44:10 +0100965 case PRID_IMP_24KE:
966 c->cputype = CPU_24K;
Markos Chandras4f12b912014-07-18 10:51:32 +0100967 c->writecombine = _CACHE_UNCACHED;
John Crispin42f3cae2013-01-11 22:44:10 +0100968 __cpu_name[cpu] = "MIPS 24KEc";
969 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700970 case PRID_IMP_25KF:
971 c->cputype = CPU_25KF;
Markos Chandras4f12b912014-07-18 10:51:32 +0100972 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000973 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700974 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000975 case PRID_IMP_34K:
976 c->cputype = CPU_34K;
Markos Chandras4f12b912014-07-18 10:51:32 +0100977 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000978 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000979 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100980 case PRID_IMP_74K:
981 c->cputype = CPU_74K;
Markos Chandras4f12b912014-07-18 10:51:32 +0100982 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000983 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100984 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +0200985 case PRID_IMP_M14KC:
986 c->cputype = CPU_M14KC;
Markos Chandras4f12b912014-07-18 10:51:32 +0100987 c->writecombine = _CACHE_UNCACHED;
Steven J. Hill113c62d2012-07-06 23:56:00 +0200988 __cpu_name[cpu] = "MIPS M14Kc";
989 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000990 case PRID_IMP_M14KEC:
991 c->cputype = CPU_M14KEC;
Markos Chandras4f12b912014-07-18 10:51:32 +0100992 c->writecombine = _CACHE_UNCACHED;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000993 __cpu_name[cpu] = "MIPS M14KEc";
994 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100995 case PRID_IMP_1004K:
996 c->cputype = CPU_1004K;
Markos Chandras4f12b912014-07-18 10:51:32 +0100997 c->writecombine = _CACHE_UNCACHED;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000998 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100999 break;
Steven J. Hill006a8512012-06-26 04:11:03 +00001000 case PRID_IMP_1074K:
Steven J. Hill442e14a2014-01-17 15:03:50 -06001001 c->cputype = CPU_1074K;
Markos Chandras4f12b912014-07-18 10:51:32 +01001002 c->writecombine = _CACHE_UNCACHED;
Steven J. Hill006a8512012-06-26 04:11:03 +00001003 __cpu_name[cpu] = "MIPS 1074Kc";
1004 break;
Leonid Yegoshinb5f065e2013-11-20 10:46:02 +00001005 case PRID_IMP_INTERAPTIV_UP:
1006 c->cputype = CPU_INTERAPTIV;
1007 __cpu_name[cpu] = "MIPS interAptiv";
1008 break;
1009 case PRID_IMP_INTERAPTIV_MP:
1010 c->cputype = CPU_INTERAPTIV;
1011 __cpu_name[cpu] = "MIPS interAptiv (multi)";
1012 break;
Leonid Yegoshinb0d4d302013-11-14 16:12:28 +00001013 case PRID_IMP_PROAPTIV_UP:
1014 c->cputype = CPU_PROAPTIV;
1015 __cpu_name[cpu] = "MIPS proAptiv";
1016 break;
1017 case PRID_IMP_PROAPTIV_MP:
1018 c->cputype = CPU_PROAPTIV;
1019 __cpu_name[cpu] = "MIPS proAptiv (multi)";
1020 break;
James Hogan829dcc02014-01-22 16:19:39 +00001021 case PRID_IMP_P5600:
1022 c->cputype = CPU_P5600;
1023 __cpu_name[cpu] = "MIPS P5600";
1024 break;
Leonid Yegoshin9943ed92014-03-04 13:34:44 +00001025 case PRID_IMP_M5150:
1026 c->cputype = CPU_M5150;
1027 __cpu_name[cpu] = "MIPS M5150";
1028 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001029 }
Chris Dearman0b6d4972007-09-13 12:32:02 +01001030
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +00001031 decode_configs(c);
1032
Chris Dearman0b6d4972007-09-13 12:32:02 +01001033 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034}
1035
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001036static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037{
Ralf Baechle41943182005-05-05 16:45:59 +00001038 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001039 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040 case PRID_IMP_AU1_REV1:
1041 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +01001042 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001043 switch ((c->processor_id >> 24) & 0xff) {
1044 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001045 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001046 break;
1047 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001048 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049 break;
1050 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001051 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001052 break;
1053 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001054 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055 break;
Pete Popove3ad1c22005-03-01 06:33:16 +00001056 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001057 __cpu_name[cpu] = "Au1200";
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001058 if ((c->processor_id & PRID_REV_MASK) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001059 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +01001060 break;
1061 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001062 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +00001063 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001064 default:
Manuel Lauss270717a2009-03-25 17:49:28 +01001065 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001066 break;
1067 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001068 break;
1069 }
1070}
1071
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001072static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073{
Ralf Baechle41943182005-05-05 16:45:59 +00001074 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +01001075
Markos Chandras4f12b912014-07-18 10:51:32 +01001076 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001077 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001078 case PRID_IMP_SB1:
1079 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001080 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001081 /* FPU in pass1 is known to have issues. */
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001082 if ((c->processor_id & PRID_REV_MASK) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +00001083 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -07001085 case PRID_IMP_SB1A:
1086 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001087 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -07001088 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001089 }
1090}
1091
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001092static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001093{
Ralf Baechle41943182005-05-05 16:45:59 +00001094 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001095 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001096 case PRID_IMP_SR71000:
1097 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001098 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -07001099 c->scache.ways = 8;
1100 c->tlbsize = 64;
1101 break;
1102 }
1103}
1104
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001105static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +00001106{
1107 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001108 switch (c->processor_id & PRID_IMP_MASK) {
Pete Popovbdf21b12005-07-14 17:47:57 +00001109 case PRID_IMP_PR4450:
1110 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001111 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +00001112 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +00001113 break;
Pete Popovbdf21b12005-07-14 17:47:57 +00001114 }
1115}
1116
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001117static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001118{
1119 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001120 switch (c->processor_id & PRID_IMP_MASK) {
Kevin Cernekee190fca32010-11-23 10:26:45 -08001121 case PRID_IMP_BMIPS32_REV4:
1122 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -07001123 c->cputype = CPU_BMIPS32;
1124 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001125 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001126 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001127 case PRID_IMP_BMIPS3300:
1128 case PRID_IMP_BMIPS3300_ALT:
1129 case PRID_IMP_BMIPS3300_BUG:
1130 c->cputype = CPU_BMIPS3300;
1131 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001132 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001133 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001134 case PRID_IMP_BMIPS43XX: {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001135 int rev = c->processor_id & PRID_REV_MASK;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001136
1137 if (rev >= PRID_REV_BMIPS4380_LO &&
1138 rev <= PRID_REV_BMIPS4380_HI) {
1139 c->cputype = CPU_BMIPS4380;
1140 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001141 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001142 } else {
1143 c->cputype = CPU_BMIPS4350;
1144 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001145 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +01001146 }
1147 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001148 }
Kevin Cernekee602977b2010-10-16 14:22:30 -07001149 case PRID_IMP_BMIPS5000:
Kevin Cernekee68e6a782014-10-20 21:28:01 -07001150 case PRID_IMP_BMIPS5200:
Kevin Cernekee602977b2010-10-16 14:22:30 -07001151 c->cputype = CPU_BMIPS5000;
1152 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001153 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001154 c->options |= MIPS_CPU_ULRI;
1155 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001156 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001157}
1158
David Daney0dd47812008-12-11 15:33:26 -08001159static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
1160{
1161 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001162 switch (c->processor_id & PRID_IMP_MASK) {
David Daney0dd47812008-12-11 15:33:26 -08001163 case PRID_IMP_CAVIUM_CN38XX:
1164 case PRID_IMP_CAVIUM_CN31XX:
1165 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -08001166 c->cputype = CPU_CAVIUM_OCTEON;
1167 __cpu_name[cpu] = "Cavium Octeon";
1168 goto platform;
David Daney0dd47812008-12-11 15:33:26 -08001169 case PRID_IMP_CAVIUM_CN58XX:
1170 case PRID_IMP_CAVIUM_CN56XX:
1171 case PRID_IMP_CAVIUM_CN50XX:
1172 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -08001173 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
1174 __cpu_name[cpu] = "Cavium Octeon+";
1175platform:
Robert Millanc094c992011-04-18 11:37:55 -07001176 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -08001177 break;
David Daneya1431b62011-09-24 02:29:54 +02001178 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -07001179 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +02001180 case PRID_IMP_CAVIUM_CN66XX:
1181 case PRID_IMP_CAVIUM_CN68XX:
David Daneyaf04bb82013-07-29 15:07:01 -07001182 case PRID_IMP_CAVIUM_CNF71XX:
David Daney0e56b382010-10-07 16:03:45 -07001183 c->cputype = CPU_CAVIUM_OCTEON2;
1184 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001185 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001186 break;
David Daneyaf04bb82013-07-29 15:07:01 -07001187 case PRID_IMP_CAVIUM_CN70XX:
1188 case PRID_IMP_CAVIUM_CN78XX:
1189 c->cputype = CPU_CAVIUM_OCTEON3;
1190 __cpu_name[cpu] = "Cavium Octeon III";
1191 set_elf_platform(cpu, "octeon3");
1192 break;
David Daney0dd47812008-12-11 15:33:26 -08001193 default:
1194 printk(KERN_INFO "Unknown Octeon chip!\n");
1195 c->cputype = CPU_UNKNOWN;
1196 break;
1197 }
1198}
1199
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001200static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1201{
1202 decode_configs(c);
1203 /* JZRISC does not implement the CP0 counter. */
1204 c->options &= ~MIPS_CPU_COUNTER;
Maciej W. Rozycki06947aa2014-04-06 21:31:29 +01001205 BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001206 switch (c->processor_id & PRID_IMP_MASK) {
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001207 case PRID_IMP_JZRISC:
1208 c->cputype = CPU_JZRISC;
Markos Chandras4f12b912014-07-18 10:51:32 +01001209 c->writecombine = _CACHE_UNCACHED_ACCELERATED;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001210 __cpu_name[cpu] = "Ingenic JZRISC";
1211 break;
1212 default:
1213 panic("Unknown Ingenic Processor ID!");
1214 break;
1215 }
1216}
1217
Jayachandran Ca7117c62011-05-11 12:04:58 +05301218static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1219{
1220 decode_configs(c);
1221
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001222 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
Manuel Lauss809f36c2011-11-01 20:03:30 +01001223 c->cputype = CPU_ALCHEMY;
1224 __cpu_name[cpu] = "Au1300";
1225 /* following stuff is not for Alchemy */
1226 return;
1227 }
1228
Ralf Baechle70342282013-01-22 12:59:30 +01001229 c->options = (MIPS_CPU_TLB |
1230 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301231 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +01001232 MIPS_CPU_DIVEC |
1233 MIPS_CPU_WATCH |
1234 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301235 MIPS_CPU_LLSC);
1236
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001237 switch (c->processor_id & PRID_IMP_MASK) {
Jayachandran C4ca86a22013-08-11 14:43:54 +05301238 case PRID_IMP_NETLOGIC_XLP2XX:
Jayachandran C8907c552013-12-21 16:52:20 +05301239 case PRID_IMP_NETLOGIC_XLP9XX:
Yonghong Song1c983982014-04-29 20:07:53 +05301240 case PRID_IMP_NETLOGIC_XLP5XX:
Jayachandran C4ca86a22013-08-11 14:43:54 +05301241 c->cputype = CPU_XLP;
1242 __cpu_name[cpu] = "Broadcom XLPII";
1243 break;
1244
Jayachandran C2aa54b22011-11-16 00:21:29 +00001245 case PRID_IMP_NETLOGIC_XLP8XX:
1246 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001247 c->cputype = CPU_XLP;
1248 __cpu_name[cpu] = "Netlogic XLP";
1249 break;
1250
Jayachandran Ca7117c62011-05-11 12:04:58 +05301251 case PRID_IMP_NETLOGIC_XLR732:
1252 case PRID_IMP_NETLOGIC_XLR716:
1253 case PRID_IMP_NETLOGIC_XLR532:
1254 case PRID_IMP_NETLOGIC_XLR308:
1255 case PRID_IMP_NETLOGIC_XLR532C:
1256 case PRID_IMP_NETLOGIC_XLR516C:
1257 case PRID_IMP_NETLOGIC_XLR508C:
1258 case PRID_IMP_NETLOGIC_XLR308C:
1259 c->cputype = CPU_XLR;
1260 __cpu_name[cpu] = "Netlogic XLR";
1261 break;
1262
1263 case PRID_IMP_NETLOGIC_XLS608:
1264 case PRID_IMP_NETLOGIC_XLS408:
1265 case PRID_IMP_NETLOGIC_XLS404:
1266 case PRID_IMP_NETLOGIC_XLS208:
1267 case PRID_IMP_NETLOGIC_XLS204:
1268 case PRID_IMP_NETLOGIC_XLS108:
1269 case PRID_IMP_NETLOGIC_XLS104:
1270 case PRID_IMP_NETLOGIC_XLS616B:
1271 case PRID_IMP_NETLOGIC_XLS608B:
1272 case PRID_IMP_NETLOGIC_XLS416B:
1273 case PRID_IMP_NETLOGIC_XLS412B:
1274 case PRID_IMP_NETLOGIC_XLS408B:
1275 case PRID_IMP_NETLOGIC_XLS404B:
1276 c->cputype = CPU_XLR;
1277 __cpu_name[cpu] = "Netlogic XLS";
1278 break;
1279
1280 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001281 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301282 c->processor_id);
1283 c->cputype = CPU_XLR;
1284 break;
1285 }
1286
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001287 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001288 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001289 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1290 /* This will be updated again after all threads are woken up */
1291 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1292 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001293 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001294 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1295 }
Jayachandran C7777b932013-06-11 14:41:35 +00001296 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301297}
1298
David Daney949e51b2010-10-14 11:32:33 -07001299#ifdef CONFIG_64BIT
1300/* For use by uaccess.h */
1301u64 __ua_limit;
1302EXPORT_SYMBOL(__ua_limit);
1303#endif
1304
Ralf Baechle9966db252007-10-11 23:46:17 +01001305const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001306const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001307
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001308void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001309{
1310 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001311 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312
Ralf Baechle70342282013-01-22 12:59:30 +01001313 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001314 c->fpu_id = FPIR_IMP_NONE;
1315 c->cputype = CPU_UNKNOWN;
Markos Chandras4f12b912014-07-18 10:51:32 +01001316 c->writecombine = _CACHE_UNCACHED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001317
1318 c->processor_id = read_c0_prid();
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001319 switch (c->processor_id & PRID_COMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001320 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001321 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001322 break;
1323 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001324 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001325 break;
1326 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001327 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001328 break;
1329 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001330 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001332 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001333 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001334 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001335 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001336 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001337 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001338 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001339 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001340 break;
David Daney0dd47812008-12-11 15:33:26 -08001341 case PRID_COMP_CAVIUM:
1342 cpu_probe_cavium(c, cpu);
1343 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001344 case PRID_COMP_INGENIC:
1345 cpu_probe_ingenic(c, cpu);
1346 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301347 case PRID_COMP_NETLOGIC:
1348 cpu_probe_netlogic(c, cpu);
1349 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001350 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001351
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001352 BUG_ON(!__cpu_name[cpu]);
1353 BUG_ON(c->cputype == CPU_UNKNOWN);
1354
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001355 /*
1356 * Platform code can force the cpu type to optimize code
1357 * generation. In that case be sure the cpu type is correctly
1358 * manually setup otherwise it could trigger some nasty bugs.
1359 */
1360 BUG_ON(current_cpu_type() != c->cputype);
1361
Kevin Cernekee0103d232010-05-02 14:43:52 -07001362 if (mips_fpu_disabled)
1363 c->options &= ~MIPS_CPU_FPU;
1364
1365 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001366 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001367
Markos Chandras3d528b32014-07-14 12:46:13 +01001368 if (mips_htw_disabled) {
1369 c->options &= ~MIPS_CPU_HTW;
1370 write_c0_pwctl(read_c0_pwctl() &
1371 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
1372 }
1373
Ralf Baechle41943182005-05-05 16:45:59 +00001374 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001375 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001376
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +00001377 if (c->isa_level & cpu_has_mips_r) {
Ralf Baechle41943182005-05-05 16:45:59 +00001378 if (c->fpu_id & MIPS_FPIR_3D)
1379 c->ases |= MIPS_ASE_MIPS3D;
Paul Burtonadac5d52014-09-11 08:30:18 +01001380 if (c->fpu_id & MIPS_FPIR_FREP)
1381 c->options |= MIPS_CPU_FRE;
Ralf Baechle41943182005-05-05 16:45:59 +00001382 }
1383 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001384
Leonid Yegoshin8b8aa632014-11-13 13:51:51 +00001385 if (cpu_has_mips_r2_r6) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001386 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001387 /* R2 has Performance Counter Interrupt indicator */
1388 c->options |= MIPS_CPU_PCI;
1389 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001390 else
1391 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001392
Paul Burtona8ad1362014-01-28 14:28:43 +00001393 if (cpu_has_msa) {
Paul Burtona5e9a692014-01-27 15:23:10 +00001394 c->msa_id = cpu_get_msa_id();
Paul Burtona8ad1362014-01-28 14:28:43 +00001395 WARN(c->msa_id & MSA_IR_WRPF,
1396 "Vector register partitioning unimplemented!");
1397 }
Paul Burtona5e9a692014-01-27 15:23:10 +00001398
Guenter Roeck91dfc422010-02-02 08:52:20 -08001399 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001400
1401#ifdef CONFIG_64BIT
1402 if (cpu == 0)
1403 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1404#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001405}
1406
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001407void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001408{
1409 struct cpuinfo_mips *c = &current_cpu_data;
1410
Leonid Yegoshind9f897c2013-10-07 10:43:32 +01001411 pr_info("CPU%d revision is: %08x (%s)\n",
1412 smp_processor_id(), c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001413 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001414 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Paul Burtona5e9a692014-01-27 15:23:10 +00001415 if (cpu_has_msa)
1416 pr_info("MSA revision is: %08x\n", c->msa_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001417}