blob: f34000b27bf1d068945e6d086721738464b11ba1 [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) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100426 c->core = read_c0_ebase() & 0x3ff;
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;
Robert Millan5aac1e82011-04-16 11:29:29 -0700743 }
744
Steven J. Hilla96102b2012-12-07 04:31:36 +0000745 set_isa(c, MIPS_CPU_ISA_III);
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800746 c->options = R4K_OPTS |
747 MIPS_CPU_FPU | MIPS_CPU_LLSC |
748 MIPS_CPU_32FPR;
749 c->tlbsize = 64;
750 break;
Huacai Chen26859192014-02-16 16:01:18 +0800751 case PRID_IMP_LOONGSON_32: /* Loongson-1 */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100752 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100754 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000755
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100756 switch (c->processor_id & PRID_REV_MASK) {
757 case PRID_REV_LOONGSON1B:
758 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +0000759 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000760 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100761
Ralf Baechle41943182005-05-05 16:45:59 +0000762 break;
Ralf Baechle41943182005-05-05 16:45:59 +0000763 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700764}
765
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000766static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100768 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 case PRID_IMP_4KC:
770 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000771 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772 break;
773 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000774 case PRID_IMP_4KECR2:
775 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000776 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000777 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700778 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100779 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000781 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700782 break;
783 case PRID_IMP_5KC:
784 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000785 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +0200787 case PRID_IMP_5KE:
788 c->cputype = CPU_5KE;
789 __cpu_name[cpu] = "MIPS 5KE";
790 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700791 case PRID_IMP_20KC:
792 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000793 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700794 break;
795 case PRID_IMP_24K:
796 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000797 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 break;
John Crispin42f3cae2013-01-11 22:44:10 +0100799 case PRID_IMP_24KE:
800 c->cputype = CPU_24K;
801 __cpu_name[cpu] = "MIPS 24KEc";
802 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 case PRID_IMP_25KF:
804 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000805 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700806 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000807 case PRID_IMP_34K:
808 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000809 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000810 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100811 case PRID_IMP_74K:
812 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000813 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100814 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +0200815 case PRID_IMP_M14KC:
816 c->cputype = CPU_M14KC;
817 __cpu_name[cpu] = "MIPS M14Kc";
818 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000819 case PRID_IMP_M14KEC:
820 c->cputype = CPU_M14KEC;
821 __cpu_name[cpu] = "MIPS M14KEc";
822 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100823 case PRID_IMP_1004K:
824 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000825 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100826 break;
Steven J. Hill006a8512012-06-26 04:11:03 +0000827 case PRID_IMP_1074K:
Steven J. Hill442e14a2014-01-17 15:03:50 -0600828 c->cputype = CPU_1074K;
Steven J. Hill006a8512012-06-26 04:11:03 +0000829 __cpu_name[cpu] = "MIPS 1074Kc";
830 break;
Leonid Yegoshinb5f065e2013-11-20 10:46:02 +0000831 case PRID_IMP_INTERAPTIV_UP:
832 c->cputype = CPU_INTERAPTIV;
833 __cpu_name[cpu] = "MIPS interAptiv";
834 break;
835 case PRID_IMP_INTERAPTIV_MP:
836 c->cputype = CPU_INTERAPTIV;
837 __cpu_name[cpu] = "MIPS interAptiv (multi)";
838 break;
Leonid Yegoshinb0d4d302013-11-14 16:12:28 +0000839 case PRID_IMP_PROAPTIV_UP:
840 c->cputype = CPU_PROAPTIV;
841 __cpu_name[cpu] = "MIPS proAptiv";
842 break;
843 case PRID_IMP_PROAPTIV_MP:
844 c->cputype = CPU_PROAPTIV;
845 __cpu_name[cpu] = "MIPS proAptiv (multi)";
846 break;
James Hogan829dcc02014-01-22 16:19:39 +0000847 case PRID_IMP_P5600:
848 c->cputype = CPU_P5600;
849 __cpu_name[cpu] = "MIPS P5600";
850 break;
Leonid Yegoshin9943ed92014-03-04 13:34:44 +0000851 case PRID_IMP_M5150:
852 c->cputype = CPU_M5150;
853 __cpu_name[cpu] = "MIPS M5150";
854 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100856
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000857 decode_configs(c);
858
Chris Dearman0b6d4972007-09-13 12:32:02 +0100859 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700860}
861
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000862static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700863{
Ralf Baechle41943182005-05-05 16:45:59 +0000864 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100865 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700866 case PRID_IMP_AU1_REV1:
867 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100868 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700869 switch ((c->processor_id >> 24) & 0xff) {
870 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000871 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700872 break;
873 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000874 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 break;
876 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000877 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 break;
879 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000880 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000882 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000883 __cpu_name[cpu] = "Au1200";
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100884 if ((c->processor_id & PRID_REV_MASK) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000885 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100886 break;
887 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000888 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000889 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100891 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892 break;
893 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894 break;
895 }
896}
897
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000898static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700899{
Ralf Baechle41943182005-05-05 16:45:59 +0000900 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100901
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100902 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700903 case PRID_IMP_SB1:
904 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000905 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 /* FPU in pass1 is known to have issues. */
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100907 if ((c->processor_id & PRID_REV_MASK) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000908 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700909 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700910 case PRID_IMP_SB1A:
911 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000912 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700913 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700914 }
915}
916
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000917static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700918{
Ralf Baechle41943182005-05-05 16:45:59 +0000919 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100920 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700921 case PRID_IMP_SR71000:
922 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000923 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700924 c->scache.ways = 8;
925 c->tlbsize = 64;
926 break;
927 }
928}
929
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000930static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000931{
932 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100933 switch (c->processor_id & PRID_IMP_MASK) {
Pete Popovbdf21b12005-07-14 17:47:57 +0000934 case PRID_IMP_PR4450:
935 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000936 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000937 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +0000938 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000939 }
940}
941
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000942static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200943{
944 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100945 switch (c->processor_id & PRID_IMP_MASK) {
Kevin Cernekee190fca32010-11-23 10:26:45 -0800946 case PRID_IMP_BMIPS32_REV4:
947 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -0700948 c->cputype = CPU_BMIPS32;
949 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700950 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200951 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700952 case PRID_IMP_BMIPS3300:
953 case PRID_IMP_BMIPS3300_ALT:
954 case PRID_IMP_BMIPS3300_BUG:
955 c->cputype = CPU_BMIPS3300;
956 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700957 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200958 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700959 case PRID_IMP_BMIPS43XX: {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100960 int rev = c->processor_id & PRID_REV_MASK;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700961
962 if (rev >= PRID_REV_BMIPS4380_LO &&
963 rev <= PRID_REV_BMIPS4380_HI) {
964 c->cputype = CPU_BMIPS4380;
965 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700966 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700967 } else {
968 c->cputype = CPU_BMIPS4350;
969 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700970 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +0100971 }
972 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200973 }
Kevin Cernekee602977b2010-10-16 14:22:30 -0700974 case PRID_IMP_BMIPS5000:
975 c->cputype = CPU_BMIPS5000;
976 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700977 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700978 c->options |= MIPS_CPU_ULRI;
979 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700980 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200981}
982
David Daney0dd47812008-12-11 15:33:26 -0800983static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
984{
985 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100986 switch (c->processor_id & PRID_IMP_MASK) {
David Daney0dd47812008-12-11 15:33:26 -0800987 case PRID_IMP_CAVIUM_CN38XX:
988 case PRID_IMP_CAVIUM_CN31XX:
989 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -0800990 c->cputype = CPU_CAVIUM_OCTEON;
991 __cpu_name[cpu] = "Cavium Octeon";
992 goto platform;
David Daney0dd47812008-12-11 15:33:26 -0800993 case PRID_IMP_CAVIUM_CN58XX:
994 case PRID_IMP_CAVIUM_CN56XX:
995 case PRID_IMP_CAVIUM_CN50XX:
996 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -0800997 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
998 __cpu_name[cpu] = "Cavium Octeon+";
999platform:
Robert Millanc094c992011-04-18 11:37:55 -07001000 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -08001001 break;
David Daneya1431b62011-09-24 02:29:54 +02001002 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -07001003 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +02001004 case PRID_IMP_CAVIUM_CN66XX:
1005 case PRID_IMP_CAVIUM_CN68XX:
David Daneyaf04bb82013-07-29 15:07:01 -07001006 case PRID_IMP_CAVIUM_CNF71XX:
David Daney0e56b382010-10-07 16:03:45 -07001007 c->cputype = CPU_CAVIUM_OCTEON2;
1008 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001009 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001010 break;
David Daneyaf04bb82013-07-29 15:07:01 -07001011 case PRID_IMP_CAVIUM_CN70XX:
1012 case PRID_IMP_CAVIUM_CN78XX:
1013 c->cputype = CPU_CAVIUM_OCTEON3;
1014 __cpu_name[cpu] = "Cavium Octeon III";
1015 set_elf_platform(cpu, "octeon3");
1016 break;
David Daney0dd47812008-12-11 15:33:26 -08001017 default:
1018 printk(KERN_INFO "Unknown Octeon chip!\n");
1019 c->cputype = CPU_UNKNOWN;
1020 break;
1021 }
1022}
1023
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001024static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1025{
1026 decode_configs(c);
1027 /* JZRISC does not implement the CP0 counter. */
1028 c->options &= ~MIPS_CPU_COUNTER;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001029 switch (c->processor_id & PRID_IMP_MASK) {
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001030 case PRID_IMP_JZRISC:
1031 c->cputype = CPU_JZRISC;
1032 __cpu_name[cpu] = "Ingenic JZRISC";
1033 break;
1034 default:
1035 panic("Unknown Ingenic Processor ID!");
1036 break;
1037 }
1038}
1039
Jayachandran Ca7117c62011-05-11 12:04:58 +05301040static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1041{
1042 decode_configs(c);
1043
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001044 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
Manuel Lauss809f36c2011-11-01 20:03:30 +01001045 c->cputype = CPU_ALCHEMY;
1046 __cpu_name[cpu] = "Au1300";
1047 /* following stuff is not for Alchemy */
1048 return;
1049 }
1050
Ralf Baechle70342282013-01-22 12:59:30 +01001051 c->options = (MIPS_CPU_TLB |
1052 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301053 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +01001054 MIPS_CPU_DIVEC |
1055 MIPS_CPU_WATCH |
1056 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301057 MIPS_CPU_LLSC);
1058
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001059 switch (c->processor_id & PRID_IMP_MASK) {
Jayachandran C4ca86a22013-08-11 14:43:54 +05301060 case PRID_IMP_NETLOGIC_XLP2XX:
Jayachandran C8907c552013-12-21 16:52:20 +05301061 case PRID_IMP_NETLOGIC_XLP9XX:
Yonghong Song1c983982014-04-29 20:07:53 +05301062 case PRID_IMP_NETLOGIC_XLP5XX:
Jayachandran C4ca86a22013-08-11 14:43:54 +05301063 c->cputype = CPU_XLP;
1064 __cpu_name[cpu] = "Broadcom XLPII";
1065 break;
1066
Jayachandran C2aa54b22011-11-16 00:21:29 +00001067 case PRID_IMP_NETLOGIC_XLP8XX:
1068 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001069 c->cputype = CPU_XLP;
1070 __cpu_name[cpu] = "Netlogic XLP";
1071 break;
1072
Jayachandran Ca7117c62011-05-11 12:04:58 +05301073 case PRID_IMP_NETLOGIC_XLR732:
1074 case PRID_IMP_NETLOGIC_XLR716:
1075 case PRID_IMP_NETLOGIC_XLR532:
1076 case PRID_IMP_NETLOGIC_XLR308:
1077 case PRID_IMP_NETLOGIC_XLR532C:
1078 case PRID_IMP_NETLOGIC_XLR516C:
1079 case PRID_IMP_NETLOGIC_XLR508C:
1080 case PRID_IMP_NETLOGIC_XLR308C:
1081 c->cputype = CPU_XLR;
1082 __cpu_name[cpu] = "Netlogic XLR";
1083 break;
1084
1085 case PRID_IMP_NETLOGIC_XLS608:
1086 case PRID_IMP_NETLOGIC_XLS408:
1087 case PRID_IMP_NETLOGIC_XLS404:
1088 case PRID_IMP_NETLOGIC_XLS208:
1089 case PRID_IMP_NETLOGIC_XLS204:
1090 case PRID_IMP_NETLOGIC_XLS108:
1091 case PRID_IMP_NETLOGIC_XLS104:
1092 case PRID_IMP_NETLOGIC_XLS616B:
1093 case PRID_IMP_NETLOGIC_XLS608B:
1094 case PRID_IMP_NETLOGIC_XLS416B:
1095 case PRID_IMP_NETLOGIC_XLS412B:
1096 case PRID_IMP_NETLOGIC_XLS408B:
1097 case PRID_IMP_NETLOGIC_XLS404B:
1098 c->cputype = CPU_XLR;
1099 __cpu_name[cpu] = "Netlogic XLS";
1100 break;
1101
1102 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001103 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301104 c->processor_id);
1105 c->cputype = CPU_XLR;
1106 break;
1107 }
1108
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001109 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001110 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001111 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1112 /* This will be updated again after all threads are woken up */
1113 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1114 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001115 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001116 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1117 }
Jayachandran C7777b932013-06-11 14:41:35 +00001118 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301119}
1120
David Daney949e51b2010-10-14 11:32:33 -07001121#ifdef CONFIG_64BIT
1122/* For use by uaccess.h */
1123u64 __ua_limit;
1124EXPORT_SYMBOL(__ua_limit);
1125#endif
1126
Ralf Baechle9966db252007-10-11 23:46:17 +01001127const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001128const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001129
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001130void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001131{
1132 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001133 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134
Ralf Baechle70342282013-01-22 12:59:30 +01001135 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136 c->fpu_id = FPIR_IMP_NONE;
1137 c->cputype = CPU_UNKNOWN;
1138
1139 c->processor_id = read_c0_prid();
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001140 switch (c->processor_id & PRID_COMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001141 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001142 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 break;
1144 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001145 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146 break;
1147 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001148 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 break;
1150 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001151 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001152 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001153 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001154 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001155 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001156 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001157 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001159 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001160 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001161 break;
David Daney0dd47812008-12-11 15:33:26 -08001162 case PRID_COMP_CAVIUM:
1163 cpu_probe_cavium(c, cpu);
1164 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001165 case PRID_COMP_INGENIC:
1166 cpu_probe_ingenic(c, cpu);
1167 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301168 case PRID_COMP_NETLOGIC:
1169 cpu_probe_netlogic(c, cpu);
1170 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001171 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001172
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001173 BUG_ON(!__cpu_name[cpu]);
1174 BUG_ON(c->cputype == CPU_UNKNOWN);
1175
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001176 /*
1177 * Platform code can force the cpu type to optimize code
1178 * generation. In that case be sure the cpu type is correctly
1179 * manually setup otherwise it could trigger some nasty bugs.
1180 */
1181 BUG_ON(current_cpu_type() != c->cputype);
1182
Kevin Cernekee0103d232010-05-02 14:43:52 -07001183 if (mips_fpu_disabled)
1184 c->options &= ~MIPS_CPU_FPU;
1185
1186 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001187 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001188
Ralf Baechle41943182005-05-05 16:45:59 +00001189 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001190 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001191
Deng-Cheng Zhuadb37892013-04-01 18:14:28 +00001192 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 |
1193 MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)) {
Ralf Baechle41943182005-05-05 16:45:59 +00001194 if (c->fpu_id & MIPS_FPIR_3D)
1195 c->ases |= MIPS_ASE_MIPS3D;
1196 }
1197 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001198
Al Cooperda4b62c2012-07-13 16:44:51 -04001199 if (cpu_has_mips_r2) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001200 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001201 /* R2 has Performance Counter Interrupt indicator */
1202 c->options |= MIPS_CPU_PCI;
1203 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001204 else
1205 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001206
Paul Burtona8ad1362014-01-28 14:28:43 +00001207 if (cpu_has_msa) {
Paul Burtona5e9a692014-01-27 15:23:10 +00001208 c->msa_id = cpu_get_msa_id();
Paul Burtona8ad1362014-01-28 14:28:43 +00001209 WARN(c->msa_id & MSA_IR_WRPF,
1210 "Vector register partitioning unimplemented!");
1211 }
Paul Burtona5e9a692014-01-27 15:23:10 +00001212
Guenter Roeck91dfc422010-02-02 08:52:20 -08001213 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001214
1215#ifdef CONFIG_64BIT
1216 if (cpu == 0)
1217 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1218#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219}
1220
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001221void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001222{
1223 struct cpuinfo_mips *c = &current_cpu_data;
1224
Leonid Yegoshind9f897c2013-10-07 10:43:32 +01001225 pr_info("CPU%d revision is: %08x (%s)\n",
1226 smp_processor_id(), c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001227 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001228 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Paul Burtona5e9a692014-01-27 15:23:10 +00001229 if (cpu_has_msa)
1230 pr_info("MSA revision is: %08x\n", c->msa_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001231}