blob: 2d2e2877b1ea8a98765cd5ad4eef07f8eb249e1d [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
Marc St-Jean9267a302007-06-14 15:55:31 -060057static inline void check_errata(void)
58{
59 struct cpuinfo_mips *c = &current_cpu_data;
60
Ralf Baechle69f24d12013-09-17 10:25:47 +020061 switch (current_cpu_type()) {
Marc St-Jean9267a302007-06-14 15:55:31 -060062 case CPU_34K:
63 /*
64 * Erratum "RPS May Cause Incorrect Instruction Execution"
Ralf Baechleb633648c52014-05-23 16:29:44 +020065 * This code only handles VPE0, any SMP/RTOS code
Marc St-Jean9267a302007-06-14 15:55:31 -060066 * making use of VPE1 will be responsable for that VPE.
67 */
68 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
69 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
70 break;
71 default:
72 break;
73 }
74}
75
Linus Torvalds1da177e2005-04-16 15:20:36 -070076void __init check_bugs32(void)
77{
Marc St-Jean9267a302007-06-14 15:55:31 -060078 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -070079}
80
81/*
82 * Probe whether cpu has config register by trying to play with
83 * alternate cache bit and see whether it matters.
84 * It's used by cpu_probe to distinguish between R3000A and R3081.
85 */
86static inline int cpu_has_confreg(void)
87{
88#ifdef CONFIG_CPU_R3000
89 extern unsigned long r3k_cache_size(unsigned long);
90 unsigned long size1, size2;
91 unsigned long cfg = read_c0_conf();
92
93 size1 = r3k_cache_size(ST0_ISC);
94 write_c0_conf(cfg ^ R30XX_CONF_AC);
95 size2 = r3k_cache_size(ST0_ISC);
96 write_c0_conf(cfg);
97 return size1 != size2;
98#else
99 return 0;
100#endif
101}
102
Robert Millanc094c992011-04-18 11:37:55 -0700103static inline void set_elf_platform(int cpu, const char *plat)
104{
105 if (cpu == 0)
106 __elf_platform = plat;
107}
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109/*
110 * Get the FPU Implementation/Revision.
111 */
112static inline unsigned long cpu_get_fpu_id(void)
113{
114 unsigned long tmp, fpu_id;
115
116 tmp = read_c0_status();
Paul Burton597ce172013-11-22 13:12:07 +0000117 __enable_fpu(FPU_AS_IS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 fpu_id = read_32bit_cp1_register(CP1_REVISION);
119 write_c0_status(tmp);
120 return fpu_id;
121}
122
123/*
124 * Check the CPU has an FPU the official way.
125 */
126static inline int __cpu_has_fpu(void)
127{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100128 return ((cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129}
130
Paul Burtona5e9a692014-01-27 15:23:10 +0000131static inline unsigned long cpu_get_msa_id(void)
132{
133 unsigned long status, conf5, msa_id;
134
135 status = read_c0_status();
136 __enable_fpu(FPU_64BIT);
137 conf5 = read_c0_config5();
138 enable_msa();
139 msa_id = read_msa_ir();
140 write_c0_config5(conf5);
141 write_c0_status(status);
142 return msa_id;
143}
144
Guenter Roeck91dfc422010-02-02 08:52:20 -0800145static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
146{
147#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800148 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800149 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800150 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800151#endif
152}
153
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000154static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
Steven J. Hilla96102b2012-12-07 04:31:36 +0000155{
156 switch (isa) {
157 case MIPS_CPU_ISA_M64R2:
158 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
159 case MIPS_CPU_ISA_M64R1:
160 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
161 case MIPS_CPU_ISA_V:
162 c->isa_level |= MIPS_CPU_ISA_V;
163 case MIPS_CPU_ISA_IV:
164 c->isa_level |= MIPS_CPU_ISA_IV;
165 case MIPS_CPU_ISA_III:
Ralf Baechle1990e542013-06-26 17:06:34 +0200166 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000167 break;
168
169 case MIPS_CPU_ISA_M32R2:
170 c->isa_level |= MIPS_CPU_ISA_M32R2;
171 case MIPS_CPU_ISA_M32R1:
172 c->isa_level |= MIPS_CPU_ISA_M32R1;
173 case MIPS_CPU_ISA_II:
174 c->isa_level |= MIPS_CPU_ISA_II;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000175 break;
176 }
177}
178
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000179static char unknown_isa[] = KERN_ERR \
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100180 "Unsupported ISA type, c0.config0: %d.";
181
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000182static void set_ftlb_enable(struct cpuinfo_mips *c, int enable)
183{
184 unsigned int config6;
James Hogand83b0e82014-01-22 16:19:40 +0000185
186 /* It's implementation dependent how the FTLB can be enabled */
187 switch (c->cputype) {
188 case CPU_PROAPTIV:
189 case CPU_P5600:
190 /* proAptiv & related cores use Config6 to enable the FTLB */
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000191 config6 = read_c0_config6();
192 if (enable)
193 /* Enable FTLB */
194 write_c0_config6(config6 | MIPS_CONF6_FTLBEN);
195 else
196 /* Disable FTLB */
197 write_c0_config6(config6 & ~MIPS_CONF6_FTLBEN);
198 back_to_back_c0_hazard();
James Hogand83b0e82014-01-22 16:19:40 +0000199 break;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000200 }
201}
202
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100203static inline unsigned int decode_config0(struct cpuinfo_mips *c)
204{
205 unsigned int config0;
206 int isa;
207
208 config0 = read_c0_config();
209
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000210 /*
211 * Look for Standard TLB or Dual VTLB and FTLB
212 */
213 if ((((config0 & MIPS_CONF_MT) >> 7) == 1) ||
214 (((config0 & MIPS_CONF_MT) >> 7) == 4))
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100215 c->options |= MIPS_CPU_TLB;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000216
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100217 isa = (config0 & MIPS_CONF_AT) >> 13;
218 switch (isa) {
219 case 0:
220 switch ((config0 & MIPS_CONF_AR) >> 10) {
221 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000222 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100223 break;
224 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000225 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100226 break;
227 default:
228 goto unknown;
229 }
230 break;
231 case 2:
232 switch ((config0 & MIPS_CONF_AR) >> 10) {
233 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000234 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100235 break;
236 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000237 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100238 break;
239 default:
240 goto unknown;
241 }
242 break;
243 default:
244 goto unknown;
245 }
246
247 return config0 & MIPS_CONF_M;
248
249unknown:
250 panic(unknown_isa, config0);
251}
252
253static inline unsigned int decode_config1(struct cpuinfo_mips *c)
254{
255 unsigned int config1;
256
257 config1 = read_c0_config1();
258
259 if (config1 & MIPS_CONF1_MD)
260 c->ases |= MIPS_ASE_MDMX;
261 if (config1 & MIPS_CONF1_WR)
262 c->options |= MIPS_CPU_WATCH;
263 if (config1 & MIPS_CONF1_CA)
264 c->ases |= MIPS_ASE_MIPS16;
265 if (config1 & MIPS_CONF1_EP)
266 c->options |= MIPS_CPU_EJTAG;
267 if (config1 & MIPS_CONF1_FP) {
268 c->options |= MIPS_CPU_FPU;
269 c->options |= MIPS_CPU_32FPR;
270 }
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000271 if (cpu_has_tlb) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100272 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000273 c->tlbsizevtlb = c->tlbsize;
274 c->tlbsizeftlbsets = 0;
275 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100276
277 return config1 & MIPS_CONF_M;
278}
279
280static inline unsigned int decode_config2(struct cpuinfo_mips *c)
281{
282 unsigned int config2;
283
284 config2 = read_c0_config2();
285
286 if (config2 & MIPS_CONF2_SL)
287 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
288
289 return config2 & MIPS_CONF_M;
290}
291
292static inline unsigned int decode_config3(struct cpuinfo_mips *c)
293{
294 unsigned int config3;
295
296 config3 = read_c0_config3();
297
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500298 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100299 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500300 c->options |= MIPS_CPU_RIXI;
301 }
302 if (config3 & MIPS_CONF3_RXI)
303 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100304 if (config3 & MIPS_CONF3_DSP)
305 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500306 if (config3 & MIPS_CONF3_DSP2P)
307 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100308 if (config3 & MIPS_CONF3_VINT)
309 c->options |= MIPS_CPU_VINT;
310 if (config3 & MIPS_CONF3_VEIC)
311 c->options |= MIPS_CPU_VEIC;
312 if (config3 & MIPS_CONF3_MT)
313 c->ases |= MIPS_ASE_MIPSMT;
314 if (config3 & MIPS_CONF3_ULRI)
315 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000316 if (config3 & MIPS_CONF3_ISA)
317 c->options |= MIPS_CPU_MICROMIPS;
David Daney1e7decd2013-02-16 23:42:43 +0100318 if (config3 & MIPS_CONF3_VZ)
319 c->ases |= MIPS_ASE_VZ;
Steven J. Hill4a0156f2013-11-14 16:12:24 +0000320 if (config3 & MIPS_CONF3_SC)
321 c->options |= MIPS_CPU_SEGMENTS;
Paul Burtona5e9a692014-01-27 15:23:10 +0000322 if (config3 & MIPS_CONF3_MSA)
323 c->ases |= MIPS_ASE_MSA;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100324
325 return config3 & MIPS_CONF_M;
326}
327
328static inline unsigned int decode_config4(struct cpuinfo_mips *c)
329{
330 unsigned int config4;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000331 unsigned int newcf4;
332 unsigned int mmuextdef;
333 unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100334
335 config4 = read_c0_config4();
336
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000337 if (cpu_has_tlb) {
338 if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
339 c->options |= MIPS_CPU_TLBINV;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000340 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
341 switch (mmuextdef) {
342 case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:
343 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
344 c->tlbsizevtlb = c->tlbsize;
345 break;
346 case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT:
347 c->tlbsizevtlb +=
348 ((config4 & MIPS_CONF4_VTLBSIZEEXT) >>
349 MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40;
350 c->tlbsize = c->tlbsizevtlb;
351 ftlb_page = MIPS_CONF4_VFTLBPAGESIZE;
352 /* fall through */
353 case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT:
354 newcf4 = (config4 & ~ftlb_page) |
355 (page_size_ftlb(mmuextdef) <<
356 MIPS_CONF4_FTLBPAGESIZE_SHIFT);
357 write_c0_config4(newcf4);
358 back_to_back_c0_hazard();
359 config4 = read_c0_config4();
360 if (config4 != newcf4) {
361 pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
362 PAGE_SIZE, config4);
363 /* Switch FTLB off */
364 set_ftlb_enable(c, 0);
365 break;
366 }
367 c->tlbsizeftlbsets = 1 <<
368 ((config4 & MIPS_CONF4_FTLBSETS) >>
369 MIPS_CONF4_FTLBSETS_SHIFT);
370 c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >>
371 MIPS_CONF4_FTLBWAYS_SHIFT) + 2;
372 c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets;
373 break;
374 }
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000375 }
376
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100377 c->kscratch_mask = (config4 >> 16) & 0xff;
378
379 return config4 & MIPS_CONF_M;
380}
381
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200382static inline unsigned int decode_config5(struct cpuinfo_mips *c)
383{
384 unsigned int config5;
385
386 config5 = read_c0_config5();
387 config5 &= ~MIPS_CONF5_UFR;
388 write_c0_config5(config5);
389
Markos Chandras49016742014-01-09 16:04:51 +0000390 if (config5 & MIPS_CONF5_EVA)
391 c->options |= MIPS_CPU_EVA;
392
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200393 return config5 & MIPS_CONF_M;
394}
395
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000396static void decode_configs(struct cpuinfo_mips *c)
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100397{
398 int ok;
399
400 /* MIPS32 or MIPS64 compliant CPU. */
401 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
402 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
403
404 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
405
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000406 /* Enable FTLB if present */
407 set_ftlb_enable(c, 1);
408
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100409 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100410 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100411 if (ok)
412 ok = decode_config1(c);
413 if (ok)
414 ok = decode_config2(c);
415 if (ok)
416 ok = decode_config3(c);
417 if (ok)
418 ok = decode_config4(c);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200419 if (ok)
420 ok = decode_config5(c);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100421
422 mips_probe_watch_registers(c);
423
Paul Burton0ee958e2014-01-15 10:31:53 +0000424#ifndef CONFIG_MIPS_CPS
Paul Burton30ee6152014-03-27 10:57:30 +0000425 if (cpu_has_mips_r2) {
David Daney45b585c2014-05-28 23:52:10 +0200426 c->core = get_ebase_cpunum();
Paul Burton30ee6152014-03-27 10:57:30 +0000427 if (cpu_has_mipsmt)
428 c->core >>= fls(core_nvpes()) - 1;
429 }
Paul Burton0ee958e2014-01-15 10:31:53 +0000430#endif
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100431}
432
Ralf Baechle02cf2112005-10-01 13:06:32 +0100433#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 | MIPS_CPU_COUNTER)
435
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000436static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700437{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100438 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700439 case PRID_IMP_R2000:
440 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000441 __cpu_name[cpu] = "R2000";
Ralf Baechle02cf2112005-10-01 13:06:32 +0100442 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500443 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 if (__cpu_has_fpu())
445 c->options |= MIPS_CPU_FPU;
446 c->tlbsize = 64;
447 break;
448 case PRID_IMP_R3000:
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100449 if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000450 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000452 __cpu_name[cpu] = "R3081";
453 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000455 __cpu_name[cpu] = "R3000A";
456 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000457 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000459 __cpu_name[cpu] = "R3000";
460 }
Ralf Baechle02cf2112005-10-01 13:06:32 +0100461 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500462 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700463 if (__cpu_has_fpu())
464 c->options |= MIPS_CPU_FPU;
465 c->tlbsize = 64;
466 break;
467 case PRID_IMP_R4000:
468 if (read_c0_config() & CONF_SC) {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100469 if ((c->processor_id & PRID_REV_MASK) >=
470 PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000472 __cpu_name[cpu] = "R4400PC";
473 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000475 __cpu_name[cpu] = "R4000PC";
476 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100478 int cca = read_c0_config() & CONF_CM_CMASK;
479 int mc;
480
481 /*
482 * SC and MC versions can't be reliably told apart,
483 * but only the latter support coherent caching
484 * modes so assume the firmware has set the KSEG0
485 * coherency attribute reasonably (if uncached, we
486 * assume SC).
487 */
488 switch (cca) {
489 case CONF_CM_CACHABLE_CE:
490 case CONF_CM_CACHABLE_COW:
491 case CONF_CM_CACHABLE_CUW:
492 mc = 1;
493 break;
494 default:
495 mc = 0;
496 break;
497 }
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100498 if ((c->processor_id & PRID_REV_MASK) >=
499 PRID_REV_R4400) {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100500 c->cputype = mc ? CPU_R4400MC : CPU_R4400SC;
501 __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000502 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100503 c->cputype = mc ? CPU_R4000MC : CPU_R4000SC;
504 __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000505 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 }
507
Steven J. Hilla96102b2012-12-07 04:31:36 +0000508 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500510 MIPS_CPU_WATCH | MIPS_CPU_VCE |
511 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 c->tlbsize = 48;
513 break;
514 case PRID_IMP_VR41XX:
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900515 set_isa(c, MIPS_CPU_ISA_III);
516 c->options = R4K_OPTS;
517 c->tlbsize = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 case PRID_REV_VR4111:
520 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000521 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700522 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 case PRID_REV_VR4121:
524 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000525 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 break;
527 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000528 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000530 __cpu_name[cpu] = "NEC VR4122";
531 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000533 __cpu_name[cpu] = "NEC VR4181A";
534 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 break;
536 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000537 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700538 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000539 __cpu_name[cpu] = "NEC VR4131";
540 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 c->cputype = CPU_VR4133;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900542 c->options |= MIPS_CPU_LLSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000543 __cpu_name[cpu] = "NEC VR4133";
544 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700545 break;
546 default:
547 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
548 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000549 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 break;
551 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 break;
553 case PRID_IMP_R4300:
554 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000555 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000556 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700557 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500558 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700559 c->tlbsize = 32;
560 break;
561 case PRID_IMP_R4600:
562 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000563 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000564 set_isa(c, MIPS_CPU_ISA_III);
Thiemo Seufer075e7502005-07-27 21:48:12 +0000565 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
566 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 c->tlbsize = 48;
568 break;
569 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500570 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 /*
572 * This processor doesn't have an MMU, so it's not
573 * "real easy" to run Linux on it. It is left purely
574 * for documentation. Commented out because it shares
575 * it's c0_prid id number with the TX3900.
576 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000577 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000578 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000579 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700580 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500581 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700582 break;
583 #endif
584 case PRID_IMP_TX39:
Ralf Baechle02cf2112005-10-01 13:06:32 +0100585 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586
587 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
588 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000589 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700590 c->tlbsize = 64;
591 } else {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100592 switch (c->processor_id & PRID_REV_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593 case PRID_REV_TX3912:
594 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000595 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700596 c->tlbsize = 32;
597 break;
598 case PRID_REV_TX3922:
599 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000600 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 c->tlbsize = 64;
602 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 }
604 }
605 break;
606 case PRID_IMP_R4700:
607 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000608 __cpu_name[cpu] = "R4700";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000609 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500611 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 c->tlbsize = 48;
613 break;
614 case PRID_IMP_TX49:
615 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000616 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000617 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 c->options = R4K_OPTS | MIPS_CPU_LLSC;
619 if (!(c->processor_id & 0x08))
620 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
621 c->tlbsize = 48;
622 break;
623 case PRID_IMP_R5000:
624 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000625 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000626 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500628 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629 c->tlbsize = 48;
630 break;
631 case PRID_IMP_R5432:
632 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000633 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000634 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500636 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 c->tlbsize = 48;
638 break;
639 case PRID_IMP_R5500:
640 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000641 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000642 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500644 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700645 c->tlbsize = 48;
646 break;
647 case PRID_IMP_NEVADA:
648 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000649 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000650 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500652 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700653 c->tlbsize = 48;
654 break;
655 case PRID_IMP_R6000:
656 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000657 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000658 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700659 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500660 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 c->tlbsize = 32;
662 break;
663 case PRID_IMP_R6000A:
664 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000665 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000666 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500668 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669 c->tlbsize = 32;
670 break;
671 case PRID_IMP_RM7000:
672 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000673 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000674 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500676 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700677 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100678 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679 * the RM7000 v2.0 indicates if the TLB has 48 or 64
680 * entries.
681 *
Ralf Baechle70342282013-01-22 12:59:30 +0100682 * 29 1 => 64 entry JTLB
683 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 */
685 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
686 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700687 case PRID_IMP_R8000:
688 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000689 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000690 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700691 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500692 MIPS_CPU_FPU | MIPS_CPU_32FPR |
693 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
695 break;
696 case PRID_IMP_R10000:
697 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000698 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000699 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000700 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500701 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700702 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500703 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 c->tlbsize = 64;
705 break;
706 case PRID_IMP_R12000:
707 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000708 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000709 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000710 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500711 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700712 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500713 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714 c->tlbsize = 64;
715 break;
Kumba44d921b2006-05-16 22:23:59 -0400716 case PRID_IMP_R14000:
717 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000718 __cpu_name[cpu] = "R14000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000719 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400720 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500721 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400722 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500723 MIPS_CPU_LLSC;
Kumba44d921b2006-05-16 22:23:59 -0400724 c->tlbsize = 64;
725 break;
Huacai Chen26859192014-02-16 16:01:18 +0800726 case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */
Robert Millan5aac1e82011-04-16 11:29:29 -0700727 switch (c->processor_id & PRID_REV_MASK) {
728 case PRID_REV_LOONGSON2E:
Huacai Chenc579d312014-03-21 18:44:00 +0800729 c->cputype = CPU_LOONGSON2;
730 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700731 set_elf_platform(cpu, "loongson2e");
732 break;
733 case PRID_REV_LOONGSON2F:
Huacai Chenc579d312014-03-21 18:44:00 +0800734 c->cputype = CPU_LOONGSON2;
735 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700736 set_elf_platform(cpu, "loongson2f");
737 break;
Huacai Chenc579d312014-03-21 18:44:00 +0800738 case PRID_REV_LOONGSON3A:
739 c->cputype = CPU_LOONGSON3;
740 __cpu_name[cpu] = "ICT Loongson-3";
741 set_elf_platform(cpu, "loongson3a");
742 break;
Huacai Chene7841be2014-06-26 11:41:30 +0800743 case PRID_REV_LOONGSON3B_R1:
744 case PRID_REV_LOONGSON3B_R2:
745 c->cputype = CPU_LOONGSON3;
746 __cpu_name[cpu] = "ICT Loongson-3";
747 set_elf_platform(cpu, "loongson3b");
748 break;
Robert Millan5aac1e82011-04-16 11:29:29 -0700749 }
750
Steven J. Hilla96102b2012-12-07 04:31:36 +0000751 set_isa(c, MIPS_CPU_ISA_III);
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800752 c->options = R4K_OPTS |
753 MIPS_CPU_FPU | MIPS_CPU_LLSC |
754 MIPS_CPU_32FPR;
755 c->tlbsize = 64;
756 break;
Huacai Chen26859192014-02-16 16:01:18 +0800757 case PRID_IMP_LOONGSON_32: /* Loongson-1 */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100758 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100760 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000761
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100762 switch (c->processor_id & PRID_REV_MASK) {
763 case PRID_REV_LOONGSON1B:
764 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +0000765 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000766 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100767
Ralf Baechle41943182005-05-05 16:45:59 +0000768 break;
Ralf Baechle41943182005-05-05 16:45:59 +0000769 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700770}
771
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000772static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100774 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700775 case PRID_IMP_4KC:
776 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000777 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 break;
779 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000780 case PRID_IMP_4KECR2:
781 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000782 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000783 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100785 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000787 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700788 break;
789 case PRID_IMP_5KC:
790 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000791 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +0200793 case PRID_IMP_5KE:
794 c->cputype = CPU_5KE;
795 __cpu_name[cpu] = "MIPS 5KE";
796 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700797 case PRID_IMP_20KC:
798 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000799 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700800 break;
801 case PRID_IMP_24K:
802 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000803 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700804 break;
John Crispin42f3cae2013-01-11 22:44:10 +0100805 case PRID_IMP_24KE:
806 c->cputype = CPU_24K;
807 __cpu_name[cpu] = "MIPS 24KEc";
808 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 case PRID_IMP_25KF:
810 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000811 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700812 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000813 case PRID_IMP_34K:
814 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000815 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000816 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100817 case PRID_IMP_74K:
818 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000819 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100820 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +0200821 case PRID_IMP_M14KC:
822 c->cputype = CPU_M14KC;
823 __cpu_name[cpu] = "MIPS M14Kc";
824 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000825 case PRID_IMP_M14KEC:
826 c->cputype = CPU_M14KEC;
827 __cpu_name[cpu] = "MIPS M14KEc";
828 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100829 case PRID_IMP_1004K:
830 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000831 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100832 break;
Steven J. Hill006a8512012-06-26 04:11:03 +0000833 case PRID_IMP_1074K:
Steven J. Hill442e14a2014-01-17 15:03:50 -0600834 c->cputype = CPU_1074K;
Steven J. Hill006a8512012-06-26 04:11:03 +0000835 __cpu_name[cpu] = "MIPS 1074Kc";
836 break;
Leonid Yegoshinb5f065e2013-11-20 10:46:02 +0000837 case PRID_IMP_INTERAPTIV_UP:
838 c->cputype = CPU_INTERAPTIV;
839 __cpu_name[cpu] = "MIPS interAptiv";
840 break;
841 case PRID_IMP_INTERAPTIV_MP:
842 c->cputype = CPU_INTERAPTIV;
843 __cpu_name[cpu] = "MIPS interAptiv (multi)";
844 break;
Leonid Yegoshinb0d4d302013-11-14 16:12:28 +0000845 case PRID_IMP_PROAPTIV_UP:
846 c->cputype = CPU_PROAPTIV;
847 __cpu_name[cpu] = "MIPS proAptiv";
848 break;
849 case PRID_IMP_PROAPTIV_MP:
850 c->cputype = CPU_PROAPTIV;
851 __cpu_name[cpu] = "MIPS proAptiv (multi)";
852 break;
James Hogan829dcc02014-01-22 16:19:39 +0000853 case PRID_IMP_P5600:
854 c->cputype = CPU_P5600;
855 __cpu_name[cpu] = "MIPS P5600";
856 break;
Leonid Yegoshin9943ed92014-03-04 13:34:44 +0000857 case PRID_IMP_M5150:
858 c->cputype = CPU_M5150;
859 __cpu_name[cpu] = "MIPS M5150";
860 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100862
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000863 decode_configs(c);
864
Chris Dearman0b6d4972007-09-13 12:32:02 +0100865 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866}
867
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000868static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869{
Ralf Baechle41943182005-05-05 16:45:59 +0000870 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100871 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 case PRID_IMP_AU1_REV1:
873 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100874 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 switch ((c->processor_id >> 24) & 0xff) {
876 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000877 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 break;
879 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000880 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 break;
882 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000883 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 break;
885 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000886 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700887 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000888 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000889 __cpu_name[cpu] = "Au1200";
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100890 if ((c->processor_id & PRID_REV_MASK) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000891 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100892 break;
893 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000894 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000895 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700896 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100897 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 break;
899 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700900 break;
901 }
902}
903
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000904static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700905{
Ralf Baechle41943182005-05-05 16:45:59 +0000906 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100907
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100908 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 case PRID_IMP_SB1:
910 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000911 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912 /* FPU in pass1 is known to have issues. */
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100913 if ((c->processor_id & PRID_REV_MASK) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000914 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700916 case PRID_IMP_SB1A:
917 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000918 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700919 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920 }
921}
922
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000923static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924{
Ralf Baechle41943182005-05-05 16:45:59 +0000925 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100926 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700927 case PRID_IMP_SR71000:
928 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000929 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700930 c->scache.ways = 8;
931 c->tlbsize = 64;
932 break;
933 }
934}
935
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000936static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000937{
938 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100939 switch (c->processor_id & PRID_IMP_MASK) {
Pete Popovbdf21b12005-07-14 17:47:57 +0000940 case PRID_IMP_PR4450:
941 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000942 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000943 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +0000944 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000945 }
946}
947
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000948static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200949{
950 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100951 switch (c->processor_id & PRID_IMP_MASK) {
Kevin Cernekee190fca32010-11-23 10:26:45 -0800952 case PRID_IMP_BMIPS32_REV4:
953 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -0700954 c->cputype = CPU_BMIPS32;
955 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700956 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200957 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700958 case PRID_IMP_BMIPS3300:
959 case PRID_IMP_BMIPS3300_ALT:
960 case PRID_IMP_BMIPS3300_BUG:
961 c->cputype = CPU_BMIPS3300;
962 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700963 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200964 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700965 case PRID_IMP_BMIPS43XX: {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100966 int rev = c->processor_id & PRID_REV_MASK;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700967
968 if (rev >= PRID_REV_BMIPS4380_LO &&
969 rev <= PRID_REV_BMIPS4380_HI) {
970 c->cputype = CPU_BMIPS4380;
971 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700972 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700973 } else {
974 c->cputype = CPU_BMIPS4350;
975 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700976 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +0100977 }
978 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200979 }
Kevin Cernekee602977b2010-10-16 14:22:30 -0700980 case PRID_IMP_BMIPS5000:
981 c->cputype = CPU_BMIPS5000;
982 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700983 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700984 c->options |= MIPS_CPU_ULRI;
985 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700986 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200987}
988
David Daney0dd47812008-12-11 15:33:26 -0800989static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
990{
991 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100992 switch (c->processor_id & PRID_IMP_MASK) {
David Daney0dd47812008-12-11 15:33:26 -0800993 case PRID_IMP_CAVIUM_CN38XX:
994 case PRID_IMP_CAVIUM_CN31XX:
995 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -0800996 c->cputype = CPU_CAVIUM_OCTEON;
997 __cpu_name[cpu] = "Cavium Octeon";
998 goto platform;
David Daney0dd47812008-12-11 15:33:26 -0800999 case PRID_IMP_CAVIUM_CN58XX:
1000 case PRID_IMP_CAVIUM_CN56XX:
1001 case PRID_IMP_CAVIUM_CN50XX:
1002 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -08001003 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
1004 __cpu_name[cpu] = "Cavium Octeon+";
1005platform:
Robert Millanc094c992011-04-18 11:37:55 -07001006 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -08001007 break;
David Daneya1431b62011-09-24 02:29:54 +02001008 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -07001009 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +02001010 case PRID_IMP_CAVIUM_CN66XX:
1011 case PRID_IMP_CAVIUM_CN68XX:
David Daneyaf04bb82013-07-29 15:07:01 -07001012 case PRID_IMP_CAVIUM_CNF71XX:
David Daney0e56b382010-10-07 16:03:45 -07001013 c->cputype = CPU_CAVIUM_OCTEON2;
1014 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001015 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001016 break;
David Daneyaf04bb82013-07-29 15:07:01 -07001017 case PRID_IMP_CAVIUM_CN70XX:
1018 case PRID_IMP_CAVIUM_CN78XX:
1019 c->cputype = CPU_CAVIUM_OCTEON3;
1020 __cpu_name[cpu] = "Cavium Octeon III";
1021 set_elf_platform(cpu, "octeon3");
1022 break;
David Daney0dd47812008-12-11 15:33:26 -08001023 default:
1024 printk(KERN_INFO "Unknown Octeon chip!\n");
1025 c->cputype = CPU_UNKNOWN;
1026 break;
1027 }
1028}
1029
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001030static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1031{
1032 decode_configs(c);
1033 /* JZRISC does not implement the CP0 counter. */
1034 c->options &= ~MIPS_CPU_COUNTER;
Maciej W. Rozycki06947aa2014-04-06 21:31:29 +01001035 BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001036 switch (c->processor_id & PRID_IMP_MASK) {
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001037 case PRID_IMP_JZRISC:
1038 c->cputype = CPU_JZRISC;
1039 __cpu_name[cpu] = "Ingenic JZRISC";
1040 break;
1041 default:
1042 panic("Unknown Ingenic Processor ID!");
1043 break;
1044 }
1045}
1046
Jayachandran Ca7117c62011-05-11 12:04:58 +05301047static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1048{
1049 decode_configs(c);
1050
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001051 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
Manuel Lauss809f36c2011-11-01 20:03:30 +01001052 c->cputype = CPU_ALCHEMY;
1053 __cpu_name[cpu] = "Au1300";
1054 /* following stuff is not for Alchemy */
1055 return;
1056 }
1057
Ralf Baechle70342282013-01-22 12:59:30 +01001058 c->options = (MIPS_CPU_TLB |
1059 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301060 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +01001061 MIPS_CPU_DIVEC |
1062 MIPS_CPU_WATCH |
1063 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301064 MIPS_CPU_LLSC);
1065
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001066 switch (c->processor_id & PRID_IMP_MASK) {
Jayachandran C4ca86a22013-08-11 14:43:54 +05301067 case PRID_IMP_NETLOGIC_XLP2XX:
Jayachandran C8907c552013-12-21 16:52:20 +05301068 case PRID_IMP_NETLOGIC_XLP9XX:
Yonghong Song1c983982014-04-29 20:07:53 +05301069 case PRID_IMP_NETLOGIC_XLP5XX:
Jayachandran C4ca86a22013-08-11 14:43:54 +05301070 c->cputype = CPU_XLP;
1071 __cpu_name[cpu] = "Broadcom XLPII";
1072 break;
1073
Jayachandran C2aa54b22011-11-16 00:21:29 +00001074 case PRID_IMP_NETLOGIC_XLP8XX:
1075 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001076 c->cputype = CPU_XLP;
1077 __cpu_name[cpu] = "Netlogic XLP";
1078 break;
1079
Jayachandran Ca7117c62011-05-11 12:04:58 +05301080 case PRID_IMP_NETLOGIC_XLR732:
1081 case PRID_IMP_NETLOGIC_XLR716:
1082 case PRID_IMP_NETLOGIC_XLR532:
1083 case PRID_IMP_NETLOGIC_XLR308:
1084 case PRID_IMP_NETLOGIC_XLR532C:
1085 case PRID_IMP_NETLOGIC_XLR516C:
1086 case PRID_IMP_NETLOGIC_XLR508C:
1087 case PRID_IMP_NETLOGIC_XLR308C:
1088 c->cputype = CPU_XLR;
1089 __cpu_name[cpu] = "Netlogic XLR";
1090 break;
1091
1092 case PRID_IMP_NETLOGIC_XLS608:
1093 case PRID_IMP_NETLOGIC_XLS408:
1094 case PRID_IMP_NETLOGIC_XLS404:
1095 case PRID_IMP_NETLOGIC_XLS208:
1096 case PRID_IMP_NETLOGIC_XLS204:
1097 case PRID_IMP_NETLOGIC_XLS108:
1098 case PRID_IMP_NETLOGIC_XLS104:
1099 case PRID_IMP_NETLOGIC_XLS616B:
1100 case PRID_IMP_NETLOGIC_XLS608B:
1101 case PRID_IMP_NETLOGIC_XLS416B:
1102 case PRID_IMP_NETLOGIC_XLS412B:
1103 case PRID_IMP_NETLOGIC_XLS408B:
1104 case PRID_IMP_NETLOGIC_XLS404B:
1105 c->cputype = CPU_XLR;
1106 __cpu_name[cpu] = "Netlogic XLS";
1107 break;
1108
1109 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001110 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301111 c->processor_id);
1112 c->cputype = CPU_XLR;
1113 break;
1114 }
1115
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001116 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001117 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001118 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1119 /* This will be updated again after all threads are woken up */
1120 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1121 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001122 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001123 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1124 }
Jayachandran C7777b932013-06-11 14:41:35 +00001125 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301126}
1127
David Daney949e51b2010-10-14 11:32:33 -07001128#ifdef CONFIG_64BIT
1129/* For use by uaccess.h */
1130u64 __ua_limit;
1131EXPORT_SYMBOL(__ua_limit);
1132#endif
1133
Ralf Baechle9966db252007-10-11 23:46:17 +01001134const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001135const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001136
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001137void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001138{
1139 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001140 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141
Ralf Baechle70342282013-01-22 12:59:30 +01001142 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 c->fpu_id = FPIR_IMP_NONE;
1144 c->cputype = CPU_UNKNOWN;
1145
1146 c->processor_id = read_c0_prid();
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001147 switch (c->processor_id & PRID_COMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001149 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001150 break;
1151 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001152 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001153 break;
1154 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001155 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 break;
1157 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001158 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001159 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001160 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001161 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001162 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001163 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001164 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001166 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001167 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001168 break;
David Daney0dd47812008-12-11 15:33:26 -08001169 case PRID_COMP_CAVIUM:
1170 cpu_probe_cavium(c, cpu);
1171 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001172 case PRID_COMP_INGENIC:
1173 cpu_probe_ingenic(c, cpu);
1174 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301175 case PRID_COMP_NETLOGIC:
1176 cpu_probe_netlogic(c, cpu);
1177 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001179
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001180 BUG_ON(!__cpu_name[cpu]);
1181 BUG_ON(c->cputype == CPU_UNKNOWN);
1182
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001183 /*
1184 * Platform code can force the cpu type to optimize code
1185 * generation. In that case be sure the cpu type is correctly
1186 * manually setup otherwise it could trigger some nasty bugs.
1187 */
1188 BUG_ON(current_cpu_type() != c->cputype);
1189
Kevin Cernekee0103d232010-05-02 14:43:52 -07001190 if (mips_fpu_disabled)
1191 c->options &= ~MIPS_CPU_FPU;
1192
1193 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001194 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001195
Ralf Baechle41943182005-05-05 16:45:59 +00001196 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001197 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001198
Deng-Cheng Zhuadb37892013-04-01 18:14:28 +00001199 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 |
1200 MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)) {
Ralf Baechle41943182005-05-05 16:45:59 +00001201 if (c->fpu_id & MIPS_FPIR_3D)
1202 c->ases |= MIPS_ASE_MIPS3D;
1203 }
1204 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001205
Al Cooperda4b62c2012-07-13 16:44:51 -04001206 if (cpu_has_mips_r2) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001207 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001208 /* R2 has Performance Counter Interrupt indicator */
1209 c->options |= MIPS_CPU_PCI;
1210 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001211 else
1212 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001213
Paul Burtona8ad1362014-01-28 14:28:43 +00001214 if (cpu_has_msa) {
Paul Burtona5e9a692014-01-27 15:23:10 +00001215 c->msa_id = cpu_get_msa_id();
Paul Burtona8ad1362014-01-28 14:28:43 +00001216 WARN(c->msa_id & MSA_IR_WRPF,
1217 "Vector register partitioning unimplemented!");
1218 }
Paul Burtona5e9a692014-01-27 15:23:10 +00001219
Guenter Roeck91dfc422010-02-02 08:52:20 -08001220 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001221
1222#ifdef CONFIG_64BIT
1223 if (cpu == 0)
1224 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1225#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001226}
1227
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001228void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001229{
1230 struct cpuinfo_mips *c = &current_cpu_data;
1231
Leonid Yegoshind9f897c2013-10-07 10:43:32 +01001232 pr_info("CPU%d revision is: %08x (%s)\n",
1233 smp_processor_id(), c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001234 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001235 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Paul Burtona5e9a692014-01-27 15:23:10 +00001236 if (cpu_has_msa)
1237 pr_info("MSA revision is: %08x\n", c->msa_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001238}