blob: e34b10be782e1dc4e81012078919029c9baad7e0 [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>
Chris Dearmana074f0e2009-07-10 01:51:27 -070030#include <asm/spram.h>
David Daney949e51b2010-10-14 11:32:33 -070031#include <asm/uaccess.h>
32
Paul Gortmaker078a55f2013-06-18 13:38:59 +000033static int mips_fpu_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -070034
35static int __init fpu_disable(char *s)
36{
37 cpu_data[0].options &= ~MIPS_CPU_FPU;
38 mips_fpu_disabled = 1;
39
40 return 1;
41}
42
43__setup("nofpu", fpu_disable);
44
Paul Gortmaker078a55f2013-06-18 13:38:59 +000045int mips_dsp_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -070046
47static int __init dsp_disable(char *s)
48{
Steven J. Hillee80f7c72012-08-03 10:26:04 -050049 cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -070050 mips_dsp_disabled = 1;
51
52 return 1;
53}
54
55__setup("nodsp", dsp_disable);
56
Markos Chandras3d528b32014-07-14 12:46:13 +010057static int mips_htw_disabled;
58
59static int __init htw_disable(char *s)
60{
61 mips_htw_disabled = 1;
62 cpu_data[0].options &= ~MIPS_CPU_HTW;
63 write_c0_pwctl(read_c0_pwctl() &
64 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
65
66 return 1;
67}
68
69__setup("nohtw", htw_disable);
70
Marc St-Jean9267a302007-06-14 15:55:31 -060071static inline void check_errata(void)
72{
73 struct cpuinfo_mips *c = &current_cpu_data;
74
Ralf Baechle69f24d12013-09-17 10:25:47 +020075 switch (current_cpu_type()) {
Marc St-Jean9267a302007-06-14 15:55:31 -060076 case CPU_34K:
77 /*
78 * Erratum "RPS May Cause Incorrect Instruction Execution"
Ralf Baechleb633648c52014-05-23 16:29:44 +020079 * This code only handles VPE0, any SMP/RTOS code
Marc St-Jean9267a302007-06-14 15:55:31 -060080 * making use of VPE1 will be responsable for that VPE.
81 */
82 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
83 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
84 break;
85 default:
86 break;
87 }
88}
89
Linus Torvalds1da177e2005-04-16 15:20:36 -070090void __init check_bugs32(void)
91{
Marc St-Jean9267a302007-06-14 15:55:31 -060092 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
94
95/*
96 * Probe whether cpu has config register by trying to play with
97 * alternate cache bit and see whether it matters.
98 * It's used by cpu_probe to distinguish between R3000A and R3081.
99 */
100static inline int cpu_has_confreg(void)
101{
102#ifdef CONFIG_CPU_R3000
103 extern unsigned long r3k_cache_size(unsigned long);
104 unsigned long size1, size2;
105 unsigned long cfg = read_c0_conf();
106
107 size1 = r3k_cache_size(ST0_ISC);
108 write_c0_conf(cfg ^ R30XX_CONF_AC);
109 size2 = r3k_cache_size(ST0_ISC);
110 write_c0_conf(cfg);
111 return size1 != size2;
112#else
113 return 0;
114#endif
115}
116
Robert Millanc094c992011-04-18 11:37:55 -0700117static inline void set_elf_platform(int cpu, const char *plat)
118{
119 if (cpu == 0)
120 __elf_platform = plat;
121}
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123/*
124 * Get the FPU Implementation/Revision.
125 */
126static inline unsigned long cpu_get_fpu_id(void)
127{
128 unsigned long tmp, fpu_id;
129
130 tmp = read_c0_status();
Paul Burton597ce172013-11-22 13:12:07 +0000131 __enable_fpu(FPU_AS_IS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 fpu_id = read_32bit_cp1_register(CP1_REVISION);
133 write_c0_status(tmp);
134 return fpu_id;
135}
136
137/*
138 * Check the CPU has an FPU the official way.
139 */
140static inline int __cpu_has_fpu(void)
141{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100142 return ((cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143}
144
Paul Burtona5e9a692014-01-27 15:23:10 +0000145static inline unsigned long cpu_get_msa_id(void)
146{
Paul Burton3587ea82014-07-11 16:44:34 +0100147 unsigned long status, msa_id;
Paul Burtona5e9a692014-01-27 15:23:10 +0000148
149 status = read_c0_status();
150 __enable_fpu(FPU_64BIT);
Paul Burtona5e9a692014-01-27 15:23:10 +0000151 enable_msa();
152 msa_id = read_msa_ir();
Paul Burton3587ea82014-07-11 16:44:34 +0100153 disable_msa();
Paul Burtona5e9a692014-01-27 15:23:10 +0000154 write_c0_status(status);
155 return msa_id;
156}
157
Guenter Roeck91dfc422010-02-02 08:52:20 -0800158static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
159{
160#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800161 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800162 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800163 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800164#endif
165}
166
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000167static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
Steven J. Hilla96102b2012-12-07 04:31:36 +0000168{
169 switch (isa) {
170 case MIPS_CPU_ISA_M64R2:
171 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
172 case MIPS_CPU_ISA_M64R1:
173 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
174 case MIPS_CPU_ISA_V:
175 c->isa_level |= MIPS_CPU_ISA_V;
176 case MIPS_CPU_ISA_IV:
177 c->isa_level |= MIPS_CPU_ISA_IV;
178 case MIPS_CPU_ISA_III:
Ralf Baechle1990e542013-06-26 17:06:34 +0200179 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000180 break;
181
182 case MIPS_CPU_ISA_M32R2:
183 c->isa_level |= MIPS_CPU_ISA_M32R2;
184 case MIPS_CPU_ISA_M32R1:
185 c->isa_level |= MIPS_CPU_ISA_M32R1;
186 case MIPS_CPU_ISA_II:
187 c->isa_level |= MIPS_CPU_ISA_II;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000188 break;
189 }
190}
191
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000192static char unknown_isa[] = KERN_ERR \
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100193 "Unsupported ISA type, c0.config0: %d.";
194
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000195static void set_ftlb_enable(struct cpuinfo_mips *c, int enable)
196{
197 unsigned int config6;
James Hogand83b0e82014-01-22 16:19:40 +0000198
199 /* It's implementation dependent how the FTLB can be enabled */
200 switch (c->cputype) {
201 case CPU_PROAPTIV:
202 case CPU_P5600:
203 /* proAptiv & related cores use Config6 to enable the FTLB */
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000204 config6 = read_c0_config6();
205 if (enable)
206 /* Enable FTLB */
207 write_c0_config6(config6 | MIPS_CONF6_FTLBEN);
208 else
209 /* Disable FTLB */
210 write_c0_config6(config6 & ~MIPS_CONF6_FTLBEN);
211 back_to_back_c0_hazard();
James Hogand83b0e82014-01-22 16:19:40 +0000212 break;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000213 }
214}
215
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100216static inline unsigned int decode_config0(struct cpuinfo_mips *c)
217{
218 unsigned int config0;
219 int isa;
220
221 config0 = read_c0_config();
222
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000223 /*
224 * Look for Standard TLB or Dual VTLB and FTLB
225 */
226 if ((((config0 & MIPS_CONF_MT) >> 7) == 1) ||
227 (((config0 & MIPS_CONF_MT) >> 7) == 4))
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100228 c->options |= MIPS_CPU_TLB;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000229
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100230 isa = (config0 & MIPS_CONF_AT) >> 13;
231 switch (isa) {
232 case 0:
233 switch ((config0 & MIPS_CONF_AR) >> 10) {
234 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000235 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100236 break;
237 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000238 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100239 break;
240 default:
241 goto unknown;
242 }
243 break;
244 case 2:
245 switch ((config0 & MIPS_CONF_AR) >> 10) {
246 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000247 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100248 break;
249 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000250 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100251 break;
252 default:
253 goto unknown;
254 }
255 break;
256 default:
257 goto unknown;
258 }
259
260 return config0 & MIPS_CONF_M;
261
262unknown:
263 panic(unknown_isa, config0);
264}
265
266static inline unsigned int decode_config1(struct cpuinfo_mips *c)
267{
268 unsigned int config1;
269
270 config1 = read_c0_config1();
271
272 if (config1 & MIPS_CONF1_MD)
273 c->ases |= MIPS_ASE_MDMX;
274 if (config1 & MIPS_CONF1_WR)
275 c->options |= MIPS_CPU_WATCH;
276 if (config1 & MIPS_CONF1_CA)
277 c->ases |= MIPS_ASE_MIPS16;
278 if (config1 & MIPS_CONF1_EP)
279 c->options |= MIPS_CPU_EJTAG;
280 if (config1 & MIPS_CONF1_FP) {
281 c->options |= MIPS_CPU_FPU;
282 c->options |= MIPS_CPU_32FPR;
283 }
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000284 if (cpu_has_tlb) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100285 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000286 c->tlbsizevtlb = c->tlbsize;
287 c->tlbsizeftlbsets = 0;
288 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100289
290 return config1 & MIPS_CONF_M;
291}
292
293static inline unsigned int decode_config2(struct cpuinfo_mips *c)
294{
295 unsigned int config2;
296
297 config2 = read_c0_config2();
298
299 if (config2 & MIPS_CONF2_SL)
300 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
301
302 return config2 & MIPS_CONF_M;
303}
304
305static inline unsigned int decode_config3(struct cpuinfo_mips *c)
306{
307 unsigned int config3;
308
309 config3 = read_c0_config3();
310
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500311 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100312 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500313 c->options |= MIPS_CPU_RIXI;
314 }
315 if (config3 & MIPS_CONF3_RXI)
316 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100317 if (config3 & MIPS_CONF3_DSP)
318 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500319 if (config3 & MIPS_CONF3_DSP2P)
320 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100321 if (config3 & MIPS_CONF3_VINT)
322 c->options |= MIPS_CPU_VINT;
323 if (config3 & MIPS_CONF3_VEIC)
324 c->options |= MIPS_CPU_VEIC;
325 if (config3 & MIPS_CONF3_MT)
326 c->ases |= MIPS_ASE_MIPSMT;
327 if (config3 & MIPS_CONF3_ULRI)
328 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000329 if (config3 & MIPS_CONF3_ISA)
330 c->options |= MIPS_CPU_MICROMIPS;
David Daney1e7decd2013-02-16 23:42:43 +0100331 if (config3 & MIPS_CONF3_VZ)
332 c->ases |= MIPS_ASE_VZ;
Steven J. Hill4a0156f2013-11-14 16:12:24 +0000333 if (config3 & MIPS_CONF3_SC)
334 c->options |= MIPS_CPU_SEGMENTS;
Paul Burtona5e9a692014-01-27 15:23:10 +0000335 if (config3 & MIPS_CONF3_MSA)
336 c->ases |= MIPS_ASE_MSA;
Markos Chandras3d528b32014-07-14 12:46:13 +0100337 /* Only tested on 32-bit cores */
338 if ((config3 & MIPS_CONF3_PW) && config_enabled(CONFIG_32BIT))
339 c->options |= MIPS_CPU_HTW;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100340
341 return config3 & MIPS_CONF_M;
342}
343
344static inline unsigned int decode_config4(struct cpuinfo_mips *c)
345{
346 unsigned int config4;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000347 unsigned int newcf4;
348 unsigned int mmuextdef;
349 unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100350
351 config4 = read_c0_config4();
352
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000353 if (cpu_has_tlb) {
354 if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
355 c->options |= MIPS_CPU_TLBINV;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000356 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
357 switch (mmuextdef) {
358 case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:
359 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
360 c->tlbsizevtlb = c->tlbsize;
361 break;
362 case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT:
363 c->tlbsizevtlb +=
364 ((config4 & MIPS_CONF4_VTLBSIZEEXT) >>
365 MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40;
366 c->tlbsize = c->tlbsizevtlb;
367 ftlb_page = MIPS_CONF4_VFTLBPAGESIZE;
368 /* fall through */
369 case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT:
370 newcf4 = (config4 & ~ftlb_page) |
371 (page_size_ftlb(mmuextdef) <<
372 MIPS_CONF4_FTLBPAGESIZE_SHIFT);
373 write_c0_config4(newcf4);
374 back_to_back_c0_hazard();
375 config4 = read_c0_config4();
376 if (config4 != newcf4) {
377 pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
378 PAGE_SIZE, config4);
379 /* Switch FTLB off */
380 set_ftlb_enable(c, 0);
381 break;
382 }
383 c->tlbsizeftlbsets = 1 <<
384 ((config4 & MIPS_CONF4_FTLBSETS) >>
385 MIPS_CONF4_FTLBSETS_SHIFT);
386 c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >>
387 MIPS_CONF4_FTLBWAYS_SHIFT) + 2;
388 c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets;
389 break;
390 }
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000391 }
392
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100393 c->kscratch_mask = (config4 >> 16) & 0xff;
394
395 return config4 & MIPS_CONF_M;
396}
397
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200398static inline unsigned int decode_config5(struct cpuinfo_mips *c)
399{
400 unsigned int config5;
401
402 config5 = read_c0_config5();
403 config5 &= ~MIPS_CONF5_UFR;
404 write_c0_config5(config5);
405
Markos Chandras49016742014-01-09 16:04:51 +0000406 if (config5 & MIPS_CONF5_EVA)
407 c->options |= MIPS_CPU_EVA;
Paul Burton1f6c52f2014-07-14 10:32:14 +0100408 if (config5 & MIPS_CONF5_MRP)
409 c->options |= MIPS_CPU_MAAR;
Markos Chandras49016742014-01-09 16:04:51 +0000410
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200411 return config5 & MIPS_CONF_M;
412}
413
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000414static void decode_configs(struct cpuinfo_mips *c)
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100415{
416 int ok;
417
418 /* MIPS32 or MIPS64 compliant CPU. */
419 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
420 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
421
422 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
423
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000424 /* Enable FTLB if present */
425 set_ftlb_enable(c, 1);
426
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100427 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100428 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100429 if (ok)
430 ok = decode_config1(c);
431 if (ok)
432 ok = decode_config2(c);
433 if (ok)
434 ok = decode_config3(c);
435 if (ok)
436 ok = decode_config4(c);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200437 if (ok)
438 ok = decode_config5(c);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100439
440 mips_probe_watch_registers(c);
441
Leonid Yegoshin6575b1d2014-07-15 14:09:57 +0100442 if (cpu_has_rixi) {
443 /* Enable the RIXI exceptions */
444 write_c0_pagegrain(read_c0_pagegrain() | PG_IEC);
445 back_to_back_c0_hazard();
446 /* Verify the IEC bit is set */
447 if (read_c0_pagegrain() & PG_IEC)
448 c->options |= MIPS_CPU_RIXIEX;
449 }
450
Paul Burton0ee958e2014-01-15 10:31:53 +0000451#ifndef CONFIG_MIPS_CPS
Paul Burton30ee6152014-03-27 10:57:30 +0000452 if (cpu_has_mips_r2) {
David Daney45b585c2014-05-28 23:52:10 +0200453 c->core = get_ebase_cpunum();
Paul Burton30ee6152014-03-27 10:57:30 +0000454 if (cpu_has_mipsmt)
455 c->core >>= fls(core_nvpes()) - 1;
456 }
Paul Burton0ee958e2014-01-15 10:31:53 +0000457#endif
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100458}
459
Ralf Baechle02cf2112005-10-01 13:06:32 +0100460#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 | MIPS_CPU_COUNTER)
462
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000463static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100465 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 case PRID_IMP_R2000:
467 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000468 __cpu_name[cpu] = "R2000";
Ralf Baechle02cf2112005-10-01 13:06:32 +0100469 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500470 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 if (__cpu_has_fpu())
472 c->options |= MIPS_CPU_FPU;
473 c->tlbsize = 64;
474 break;
475 case PRID_IMP_R3000:
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100476 if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000477 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000479 __cpu_name[cpu] = "R3081";
480 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000482 __cpu_name[cpu] = "R3000A";
483 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000484 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000486 __cpu_name[cpu] = "R3000";
487 }
Ralf Baechle02cf2112005-10-01 13:06:32 +0100488 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500489 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 if (__cpu_has_fpu())
491 c->options |= MIPS_CPU_FPU;
492 c->tlbsize = 64;
493 break;
494 case PRID_IMP_R4000:
495 if (read_c0_config() & CONF_SC) {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100496 if ((c->processor_id & PRID_REV_MASK) >=
497 PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700498 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000499 __cpu_name[cpu] = "R4400PC";
500 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000502 __cpu_name[cpu] = "R4000PC";
503 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100505 int cca = read_c0_config() & CONF_CM_CMASK;
506 int mc;
507
508 /*
509 * SC and MC versions can't be reliably told apart,
510 * but only the latter support coherent caching
511 * modes so assume the firmware has set the KSEG0
512 * coherency attribute reasonably (if uncached, we
513 * assume SC).
514 */
515 switch (cca) {
516 case CONF_CM_CACHABLE_CE:
517 case CONF_CM_CACHABLE_COW:
518 case CONF_CM_CACHABLE_CUW:
519 mc = 1;
520 break;
521 default:
522 mc = 0;
523 break;
524 }
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100525 if ((c->processor_id & PRID_REV_MASK) >=
526 PRID_REV_R4400) {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100527 c->cputype = mc ? CPU_R4400MC : CPU_R4400SC;
528 __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000529 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100530 c->cputype = mc ? CPU_R4000MC : CPU_R4000SC;
531 __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000532 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 }
534
Steven J. Hilla96102b2012-12-07 04:31:36 +0000535 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500537 MIPS_CPU_WATCH | MIPS_CPU_VCE |
538 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 c->tlbsize = 48;
540 break;
541 case PRID_IMP_VR41XX:
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900542 set_isa(c, MIPS_CPU_ISA_III);
543 c->options = R4K_OPTS;
544 c->tlbsize = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 case PRID_REV_VR4111:
547 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000548 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 case PRID_REV_VR4121:
551 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000552 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700553 break;
554 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000555 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700556 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000557 __cpu_name[cpu] = "NEC VR4122";
558 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000560 __cpu_name[cpu] = "NEC VR4181A";
561 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 break;
563 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000564 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000566 __cpu_name[cpu] = "NEC VR4131";
567 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700568 c->cputype = CPU_VR4133;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900569 c->options |= MIPS_CPU_LLSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000570 __cpu_name[cpu] = "NEC VR4133";
571 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 break;
573 default:
574 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
575 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000576 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577 break;
578 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579 break;
580 case PRID_IMP_R4300:
581 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000582 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000583 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500585 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586 c->tlbsize = 32;
587 break;
588 case PRID_IMP_R4600:
589 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000590 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000591 set_isa(c, MIPS_CPU_ISA_III);
Thiemo Seufer075e7502005-07-27 21:48:12 +0000592 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
593 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 c->tlbsize = 48;
595 break;
596 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500597 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700598 /*
599 * This processor doesn't have an MMU, so it's not
600 * "real easy" to run Linux on it. It is left purely
601 * for documentation. Commented out because it shares
602 * it's c0_prid id number with the TX3900.
603 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000604 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000605 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000606 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500608 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 break;
610 #endif
611 case PRID_IMP_TX39:
Ralf Baechle02cf2112005-10-01 13:06:32 +0100612 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613
614 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
615 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000616 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 c->tlbsize = 64;
618 } else {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100619 switch (c->processor_id & PRID_REV_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 case PRID_REV_TX3912:
621 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000622 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623 c->tlbsize = 32;
624 break;
625 case PRID_REV_TX3922:
626 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000627 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 c->tlbsize = 64;
629 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630 }
631 }
632 break;
633 case PRID_IMP_R4700:
634 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000635 __cpu_name[cpu] = "R4700";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000636 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500638 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639 c->tlbsize = 48;
640 break;
641 case PRID_IMP_TX49:
642 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000643 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000644 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 c->options = R4K_OPTS | MIPS_CPU_LLSC;
646 if (!(c->processor_id & 0x08))
647 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
648 c->tlbsize = 48;
649 break;
650 case PRID_IMP_R5000:
651 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000652 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000653 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500655 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656 c->tlbsize = 48;
657 break;
658 case PRID_IMP_R5432:
659 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000660 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000661 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500663 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664 c->tlbsize = 48;
665 break;
666 case PRID_IMP_R5500:
667 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000668 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000669 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500671 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 c->tlbsize = 48;
673 break;
674 case PRID_IMP_NEVADA:
675 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000676 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000677 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500679 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 c->tlbsize = 48;
681 break;
682 case PRID_IMP_R6000:
683 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000684 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000685 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500687 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700688 c->tlbsize = 32;
689 break;
690 case PRID_IMP_R6000A:
691 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000692 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000693 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500695 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 c->tlbsize = 32;
697 break;
698 case PRID_IMP_RM7000:
699 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000700 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000701 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500703 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100705 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 * the RM7000 v2.0 indicates if the TLB has 48 or 64
707 * entries.
708 *
Ralf Baechle70342282013-01-22 12:59:30 +0100709 * 29 1 => 64 entry JTLB
710 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 */
712 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
713 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 case PRID_IMP_R8000:
715 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000716 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000717 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500719 MIPS_CPU_FPU | MIPS_CPU_32FPR |
720 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
722 break;
723 case PRID_IMP_R10000:
724 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000725 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000726 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000727 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500728 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500730 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 c->tlbsize = 64;
732 break;
733 case PRID_IMP_R12000:
734 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000735 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000736 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000737 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500738 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500740 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741 c->tlbsize = 64;
742 break;
Kumba44d921b2006-05-16 22:23:59 -0400743 case PRID_IMP_R14000:
744 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000745 __cpu_name[cpu] = "R14000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000746 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400747 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500748 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400749 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500750 MIPS_CPU_LLSC;
Kumba44d921b2006-05-16 22:23:59 -0400751 c->tlbsize = 64;
752 break;
Huacai Chen26859192014-02-16 16:01:18 +0800753 case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */
Robert Millan5aac1e82011-04-16 11:29:29 -0700754 switch (c->processor_id & PRID_REV_MASK) {
755 case PRID_REV_LOONGSON2E:
Huacai Chenc579d312014-03-21 18:44:00 +0800756 c->cputype = CPU_LOONGSON2;
757 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700758 set_elf_platform(cpu, "loongson2e");
759 break;
760 case PRID_REV_LOONGSON2F:
Huacai Chenc579d312014-03-21 18:44:00 +0800761 c->cputype = CPU_LOONGSON2;
762 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700763 set_elf_platform(cpu, "loongson2f");
764 break;
Huacai Chenc579d312014-03-21 18:44:00 +0800765 case PRID_REV_LOONGSON3A:
766 c->cputype = CPU_LOONGSON3;
767 __cpu_name[cpu] = "ICT Loongson-3";
768 set_elf_platform(cpu, "loongson3a");
769 break;
Huacai Chene7841be2014-06-26 11:41:30 +0800770 case PRID_REV_LOONGSON3B_R1:
771 case PRID_REV_LOONGSON3B_R2:
772 c->cputype = CPU_LOONGSON3;
773 __cpu_name[cpu] = "ICT Loongson-3";
774 set_elf_platform(cpu, "loongson3b");
775 break;
Robert Millan5aac1e82011-04-16 11:29:29 -0700776 }
777
Steven J. Hilla96102b2012-12-07 04:31:36 +0000778 set_isa(c, MIPS_CPU_ISA_III);
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800779 c->options = R4K_OPTS |
780 MIPS_CPU_FPU | MIPS_CPU_LLSC |
781 MIPS_CPU_32FPR;
782 c->tlbsize = 64;
783 break;
Huacai Chen26859192014-02-16 16:01:18 +0800784 case PRID_IMP_LOONGSON_32: /* Loongson-1 */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100785 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100787 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000788
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100789 switch (c->processor_id & PRID_REV_MASK) {
790 case PRID_REV_LOONGSON1B:
791 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +0000792 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000793 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100794
Ralf Baechle41943182005-05-05 16:45:59 +0000795 break;
Ralf Baechle41943182005-05-05 16:45:59 +0000796 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797}
798
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000799static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100801 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700802 case PRID_IMP_4KC:
803 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000804 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 break;
806 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000807 case PRID_IMP_4KECR2:
808 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000809 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000810 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700811 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100812 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700813 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000814 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 break;
816 case PRID_IMP_5KC:
817 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000818 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700819 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +0200820 case PRID_IMP_5KE:
821 c->cputype = CPU_5KE;
822 __cpu_name[cpu] = "MIPS 5KE";
823 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700824 case PRID_IMP_20KC:
825 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000826 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827 break;
828 case PRID_IMP_24K:
829 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000830 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700831 break;
John Crispin42f3cae2013-01-11 22:44:10 +0100832 case PRID_IMP_24KE:
833 c->cputype = CPU_24K;
834 __cpu_name[cpu] = "MIPS 24KEc";
835 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836 case PRID_IMP_25KF:
837 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000838 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000840 case PRID_IMP_34K:
841 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000842 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000843 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100844 case PRID_IMP_74K:
845 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000846 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100847 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +0200848 case PRID_IMP_M14KC:
849 c->cputype = CPU_M14KC;
850 __cpu_name[cpu] = "MIPS M14Kc";
851 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000852 case PRID_IMP_M14KEC:
853 c->cputype = CPU_M14KEC;
854 __cpu_name[cpu] = "MIPS M14KEc";
855 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100856 case PRID_IMP_1004K:
857 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000858 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100859 break;
Steven J. Hill006a8512012-06-26 04:11:03 +0000860 case PRID_IMP_1074K:
Steven J. Hill442e14a2014-01-17 15:03:50 -0600861 c->cputype = CPU_1074K;
Steven J. Hill006a8512012-06-26 04:11:03 +0000862 __cpu_name[cpu] = "MIPS 1074Kc";
863 break;
Leonid Yegoshinb5f065e2013-11-20 10:46:02 +0000864 case PRID_IMP_INTERAPTIV_UP:
865 c->cputype = CPU_INTERAPTIV;
866 __cpu_name[cpu] = "MIPS interAptiv";
867 break;
868 case PRID_IMP_INTERAPTIV_MP:
869 c->cputype = CPU_INTERAPTIV;
870 __cpu_name[cpu] = "MIPS interAptiv (multi)";
871 break;
Leonid Yegoshinb0d4d302013-11-14 16:12:28 +0000872 case PRID_IMP_PROAPTIV_UP:
873 c->cputype = CPU_PROAPTIV;
874 __cpu_name[cpu] = "MIPS proAptiv";
875 break;
876 case PRID_IMP_PROAPTIV_MP:
877 c->cputype = CPU_PROAPTIV;
878 __cpu_name[cpu] = "MIPS proAptiv (multi)";
879 break;
James Hogan829dcc02014-01-22 16:19:39 +0000880 case PRID_IMP_P5600:
881 c->cputype = CPU_P5600;
882 __cpu_name[cpu] = "MIPS P5600";
883 break;
Leonid Yegoshin9943ed92014-03-04 13:34:44 +0000884 case PRID_IMP_M5150:
885 c->cputype = CPU_M5150;
886 __cpu_name[cpu] = "MIPS M5150";
887 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700888 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100889
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000890 decode_configs(c);
891
Chris Dearman0b6d4972007-09-13 12:32:02 +0100892 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700893}
894
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000895static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896{
Ralf Baechle41943182005-05-05 16:45:59 +0000897 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100898 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899 case PRID_IMP_AU1_REV1:
900 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100901 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902 switch ((c->processor_id >> 24) & 0xff) {
903 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000904 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905 break;
906 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000907 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700908 break;
909 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000910 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911 break;
912 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000913 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000915 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000916 __cpu_name[cpu] = "Au1200";
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100917 if ((c->processor_id & PRID_REV_MASK) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000918 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100919 break;
920 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000921 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000922 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700923 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100924 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700925 break;
926 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 break;
928 }
929}
930
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000931static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932{
Ralf Baechle41943182005-05-05 16:45:59 +0000933 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100934
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100935 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700936 case PRID_IMP_SB1:
937 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000938 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700939 /* FPU in pass1 is known to have issues. */
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100940 if ((c->processor_id & PRID_REV_MASK) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000941 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700943 case PRID_IMP_SB1A:
944 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000945 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700946 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947 }
948}
949
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000950static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951{
Ralf Baechle41943182005-05-05 16:45:59 +0000952 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100953 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700954 case PRID_IMP_SR71000:
955 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000956 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700957 c->scache.ways = 8;
958 c->tlbsize = 64;
959 break;
960 }
961}
962
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000963static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000964{
965 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100966 switch (c->processor_id & PRID_IMP_MASK) {
Pete Popovbdf21b12005-07-14 17:47:57 +0000967 case PRID_IMP_PR4450:
968 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000969 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000970 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +0000971 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000972 }
973}
974
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000975static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200976{
977 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100978 switch (c->processor_id & PRID_IMP_MASK) {
Kevin Cernekee190fca32010-11-23 10:26:45 -0800979 case PRID_IMP_BMIPS32_REV4:
980 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -0700981 c->cputype = CPU_BMIPS32;
982 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700983 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200984 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700985 case PRID_IMP_BMIPS3300:
986 case PRID_IMP_BMIPS3300_ALT:
987 case PRID_IMP_BMIPS3300_BUG:
988 c->cputype = CPU_BMIPS3300;
989 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700990 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200991 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700992 case PRID_IMP_BMIPS43XX: {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100993 int rev = c->processor_id & PRID_REV_MASK;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700994
995 if (rev >= PRID_REV_BMIPS4380_LO &&
996 rev <= PRID_REV_BMIPS4380_HI) {
997 c->cputype = CPU_BMIPS4380;
998 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700999 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001000 } else {
1001 c->cputype = CPU_BMIPS4350;
1002 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001003 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +01001004 }
1005 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001006 }
Kevin Cernekee602977b2010-10-16 14:22:30 -07001007 case PRID_IMP_BMIPS5000:
1008 c->cputype = CPU_BMIPS5000;
1009 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001010 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001011 c->options |= MIPS_CPU_ULRI;
1012 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001013 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001014}
1015
David Daney0dd47812008-12-11 15:33:26 -08001016static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
1017{
1018 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001019 switch (c->processor_id & PRID_IMP_MASK) {
David Daney0dd47812008-12-11 15:33:26 -08001020 case PRID_IMP_CAVIUM_CN38XX:
1021 case PRID_IMP_CAVIUM_CN31XX:
1022 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -08001023 c->cputype = CPU_CAVIUM_OCTEON;
1024 __cpu_name[cpu] = "Cavium Octeon";
1025 goto platform;
David Daney0dd47812008-12-11 15:33:26 -08001026 case PRID_IMP_CAVIUM_CN58XX:
1027 case PRID_IMP_CAVIUM_CN56XX:
1028 case PRID_IMP_CAVIUM_CN50XX:
1029 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -08001030 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
1031 __cpu_name[cpu] = "Cavium Octeon+";
1032platform:
Robert Millanc094c992011-04-18 11:37:55 -07001033 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -08001034 break;
David Daneya1431b62011-09-24 02:29:54 +02001035 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -07001036 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +02001037 case PRID_IMP_CAVIUM_CN66XX:
1038 case PRID_IMP_CAVIUM_CN68XX:
David Daneyaf04bb82013-07-29 15:07:01 -07001039 case PRID_IMP_CAVIUM_CNF71XX:
David Daney0e56b382010-10-07 16:03:45 -07001040 c->cputype = CPU_CAVIUM_OCTEON2;
1041 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001042 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001043 break;
David Daneyaf04bb82013-07-29 15:07:01 -07001044 case PRID_IMP_CAVIUM_CN70XX:
1045 case PRID_IMP_CAVIUM_CN78XX:
1046 c->cputype = CPU_CAVIUM_OCTEON3;
1047 __cpu_name[cpu] = "Cavium Octeon III";
1048 set_elf_platform(cpu, "octeon3");
1049 break;
David Daney0dd47812008-12-11 15:33:26 -08001050 default:
1051 printk(KERN_INFO "Unknown Octeon chip!\n");
1052 c->cputype = CPU_UNKNOWN;
1053 break;
1054 }
1055}
1056
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001057static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1058{
1059 decode_configs(c);
1060 /* JZRISC does not implement the CP0 counter. */
1061 c->options &= ~MIPS_CPU_COUNTER;
Maciej W. Rozycki06947aa2014-04-06 21:31:29 +01001062 BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001063 switch (c->processor_id & PRID_IMP_MASK) {
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001064 case PRID_IMP_JZRISC:
1065 c->cputype = CPU_JZRISC;
1066 __cpu_name[cpu] = "Ingenic JZRISC";
1067 break;
1068 default:
1069 panic("Unknown Ingenic Processor ID!");
1070 break;
1071 }
1072}
1073
Jayachandran Ca7117c62011-05-11 12:04:58 +05301074static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1075{
1076 decode_configs(c);
1077
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001078 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
Manuel Lauss809f36c2011-11-01 20:03:30 +01001079 c->cputype = CPU_ALCHEMY;
1080 __cpu_name[cpu] = "Au1300";
1081 /* following stuff is not for Alchemy */
1082 return;
1083 }
1084
Ralf Baechle70342282013-01-22 12:59:30 +01001085 c->options = (MIPS_CPU_TLB |
1086 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301087 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +01001088 MIPS_CPU_DIVEC |
1089 MIPS_CPU_WATCH |
1090 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301091 MIPS_CPU_LLSC);
1092
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001093 switch (c->processor_id & PRID_IMP_MASK) {
Jayachandran C4ca86a22013-08-11 14:43:54 +05301094 case PRID_IMP_NETLOGIC_XLP2XX:
Jayachandran C8907c552013-12-21 16:52:20 +05301095 case PRID_IMP_NETLOGIC_XLP9XX:
Yonghong Song1c983982014-04-29 20:07:53 +05301096 case PRID_IMP_NETLOGIC_XLP5XX:
Jayachandran C4ca86a22013-08-11 14:43:54 +05301097 c->cputype = CPU_XLP;
1098 __cpu_name[cpu] = "Broadcom XLPII";
1099 break;
1100
Jayachandran C2aa54b22011-11-16 00:21:29 +00001101 case PRID_IMP_NETLOGIC_XLP8XX:
1102 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001103 c->cputype = CPU_XLP;
1104 __cpu_name[cpu] = "Netlogic XLP";
1105 break;
1106
Jayachandran Ca7117c62011-05-11 12:04:58 +05301107 case PRID_IMP_NETLOGIC_XLR732:
1108 case PRID_IMP_NETLOGIC_XLR716:
1109 case PRID_IMP_NETLOGIC_XLR532:
1110 case PRID_IMP_NETLOGIC_XLR308:
1111 case PRID_IMP_NETLOGIC_XLR532C:
1112 case PRID_IMP_NETLOGIC_XLR516C:
1113 case PRID_IMP_NETLOGIC_XLR508C:
1114 case PRID_IMP_NETLOGIC_XLR308C:
1115 c->cputype = CPU_XLR;
1116 __cpu_name[cpu] = "Netlogic XLR";
1117 break;
1118
1119 case PRID_IMP_NETLOGIC_XLS608:
1120 case PRID_IMP_NETLOGIC_XLS408:
1121 case PRID_IMP_NETLOGIC_XLS404:
1122 case PRID_IMP_NETLOGIC_XLS208:
1123 case PRID_IMP_NETLOGIC_XLS204:
1124 case PRID_IMP_NETLOGIC_XLS108:
1125 case PRID_IMP_NETLOGIC_XLS104:
1126 case PRID_IMP_NETLOGIC_XLS616B:
1127 case PRID_IMP_NETLOGIC_XLS608B:
1128 case PRID_IMP_NETLOGIC_XLS416B:
1129 case PRID_IMP_NETLOGIC_XLS412B:
1130 case PRID_IMP_NETLOGIC_XLS408B:
1131 case PRID_IMP_NETLOGIC_XLS404B:
1132 c->cputype = CPU_XLR;
1133 __cpu_name[cpu] = "Netlogic XLS";
1134 break;
1135
1136 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001137 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301138 c->processor_id);
1139 c->cputype = CPU_XLR;
1140 break;
1141 }
1142
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001143 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001144 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001145 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1146 /* This will be updated again after all threads are woken up */
1147 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1148 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001149 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001150 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1151 }
Jayachandran C7777b932013-06-11 14:41:35 +00001152 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301153}
1154
David Daney949e51b2010-10-14 11:32:33 -07001155#ifdef CONFIG_64BIT
1156/* For use by uaccess.h */
1157u64 __ua_limit;
1158EXPORT_SYMBOL(__ua_limit);
1159#endif
1160
Ralf Baechle9966db252007-10-11 23:46:17 +01001161const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001162const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001163
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001164void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165{
1166 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001167 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001168
Ralf Baechle70342282013-01-22 12:59:30 +01001169 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 c->fpu_id = FPIR_IMP_NONE;
1171 c->cputype = CPU_UNKNOWN;
1172
1173 c->processor_id = read_c0_prid();
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001174 switch (c->processor_id & PRID_COMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001175 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001176 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001177 break;
1178 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001179 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 break;
1181 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001182 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001183 break;
1184 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001185 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001186 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001187 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001188 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001189 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001191 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001193 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001194 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001195 break;
David Daney0dd47812008-12-11 15:33:26 -08001196 case PRID_COMP_CAVIUM:
1197 cpu_probe_cavium(c, cpu);
1198 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001199 case PRID_COMP_INGENIC:
1200 cpu_probe_ingenic(c, cpu);
1201 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301202 case PRID_COMP_NETLOGIC:
1203 cpu_probe_netlogic(c, cpu);
1204 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001205 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001206
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001207 BUG_ON(!__cpu_name[cpu]);
1208 BUG_ON(c->cputype == CPU_UNKNOWN);
1209
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001210 /*
1211 * Platform code can force the cpu type to optimize code
1212 * generation. In that case be sure the cpu type is correctly
1213 * manually setup otherwise it could trigger some nasty bugs.
1214 */
1215 BUG_ON(current_cpu_type() != c->cputype);
1216
Kevin Cernekee0103d232010-05-02 14:43:52 -07001217 if (mips_fpu_disabled)
1218 c->options &= ~MIPS_CPU_FPU;
1219
1220 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001221 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001222
Markos Chandras3d528b32014-07-14 12:46:13 +01001223 if (mips_htw_disabled) {
1224 c->options &= ~MIPS_CPU_HTW;
1225 write_c0_pwctl(read_c0_pwctl() &
1226 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
1227 }
1228
Ralf Baechle41943182005-05-05 16:45:59 +00001229 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001230 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001231
Deng-Cheng Zhuadb37892013-04-01 18:14:28 +00001232 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 |
1233 MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)) {
Ralf Baechle41943182005-05-05 16:45:59 +00001234 if (c->fpu_id & MIPS_FPIR_3D)
1235 c->ases |= MIPS_ASE_MIPS3D;
1236 }
1237 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001238
Al Cooperda4b62c2012-07-13 16:44:51 -04001239 if (cpu_has_mips_r2) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001240 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001241 /* R2 has Performance Counter Interrupt indicator */
1242 c->options |= MIPS_CPU_PCI;
1243 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001244 else
1245 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001246
Paul Burtona8ad1362014-01-28 14:28:43 +00001247 if (cpu_has_msa) {
Paul Burtona5e9a692014-01-27 15:23:10 +00001248 c->msa_id = cpu_get_msa_id();
Paul Burtona8ad1362014-01-28 14:28:43 +00001249 WARN(c->msa_id & MSA_IR_WRPF,
1250 "Vector register partitioning unimplemented!");
1251 }
Paul Burtona5e9a692014-01-27 15:23:10 +00001252
Guenter Roeck91dfc422010-02-02 08:52:20 -08001253 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001254
1255#ifdef CONFIG_64BIT
1256 if (cpu == 0)
1257 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1258#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001259}
1260
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001261void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001262{
1263 struct cpuinfo_mips *c = &current_cpu_data;
1264
Leonid Yegoshind9f897c2013-10-07 10:43:32 +01001265 pr_info("CPU%d revision is: %08x (%s)\n",
1266 smp_processor_id(), c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001267 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001268 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Paul Burtona5e9a692014-01-27 15:23:10 +00001269 if (cpu_has_msa)
1270 pr_info("MSA revision is: %08x\n", c->msa_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001271}