blob: 420d2fc595d028563c27f93143b1f1fac300f700 [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 Burtona5e9a692014-01-27 15:23:10 +000026#include <asm/msa.h>
David Daney654f57b2008-09-23 00:07:16 -070027#include <asm/watch.h>
Paul Gortmaker06372a62011-07-23 16:26:41 -040028#include <asm/elf.h>
Chris Dearmana074f0e2009-07-10 01:51:27 -070029#include <asm/spram.h>
David Daney949e51b2010-10-14 11:32:33 -070030#include <asm/uaccess.h>
31
Paul Gortmaker078a55f2013-06-18 13:38:59 +000032static int mips_fpu_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -070033
34static int __init fpu_disable(char *s)
35{
36 cpu_data[0].options &= ~MIPS_CPU_FPU;
37 mips_fpu_disabled = 1;
38
39 return 1;
40}
41
42__setup("nofpu", fpu_disable);
43
Paul Gortmaker078a55f2013-06-18 13:38:59 +000044int mips_dsp_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -070045
46static int __init dsp_disable(char *s)
47{
Steven J. Hillee80f7c72012-08-03 10:26:04 -050048 cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -070049 mips_dsp_disabled = 1;
50
51 return 1;
52}
53
54__setup("nodsp", dsp_disable);
55
Marc St-Jean9267a302007-06-14 15:55:31 -060056static inline void check_errata(void)
57{
58 struct cpuinfo_mips *c = &current_cpu_data;
59
Ralf Baechle69f24d12013-09-17 10:25:47 +020060 switch (current_cpu_type()) {
Marc St-Jean9267a302007-06-14 15:55:31 -060061 case CPU_34K:
62 /*
63 * Erratum "RPS May Cause Incorrect Instruction Execution"
64 * This code only handles VPE0, any SMP/SMTC/RTOS code
65 * making use of VPE1 will be responsable for that VPE.
66 */
67 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
68 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
69 break;
70 default:
71 break;
72 }
73}
74
Linus Torvalds1da177e2005-04-16 15:20:36 -070075void __init check_bugs32(void)
76{
Marc St-Jean9267a302007-06-14 15:55:31 -060077 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -070078}
79
80/*
81 * Probe whether cpu has config register by trying to play with
82 * alternate cache bit and see whether it matters.
83 * It's used by cpu_probe to distinguish between R3000A and R3081.
84 */
85static inline int cpu_has_confreg(void)
86{
87#ifdef CONFIG_CPU_R3000
88 extern unsigned long r3k_cache_size(unsigned long);
89 unsigned long size1, size2;
90 unsigned long cfg = read_c0_conf();
91
92 size1 = r3k_cache_size(ST0_ISC);
93 write_c0_conf(cfg ^ R30XX_CONF_AC);
94 size2 = r3k_cache_size(ST0_ISC);
95 write_c0_conf(cfg);
96 return size1 != size2;
97#else
98 return 0;
99#endif
100}
101
Robert Millanc094c992011-04-18 11:37:55 -0700102static inline void set_elf_platform(int cpu, const char *plat)
103{
104 if (cpu == 0)
105 __elf_platform = plat;
106}
107
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108/*
109 * Get the FPU Implementation/Revision.
110 */
111static inline unsigned long cpu_get_fpu_id(void)
112{
113 unsigned long tmp, fpu_id;
114
115 tmp = read_c0_status();
Paul Burton597ce172013-11-22 13:12:07 +0000116 __enable_fpu(FPU_AS_IS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 fpu_id = read_32bit_cp1_register(CP1_REVISION);
118 write_c0_status(tmp);
119 return fpu_id;
120}
121
122/*
123 * Check the CPU has an FPU the official way.
124 */
125static inline int __cpu_has_fpu(void)
126{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100127 return ((cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128}
129
Paul Burtona5e9a692014-01-27 15:23:10 +0000130static inline unsigned long cpu_get_msa_id(void)
131{
132 unsigned long status, conf5, msa_id;
133
134 status = read_c0_status();
135 __enable_fpu(FPU_64BIT);
136 conf5 = read_c0_config5();
137 enable_msa();
138 msa_id = read_msa_ir();
139 write_c0_config5(conf5);
140 write_c0_status(status);
141 return msa_id;
142}
143
Guenter Roeck91dfc422010-02-02 08:52:20 -0800144static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
145{
146#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800147 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800148 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800149 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800150#endif
151}
152
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000153static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
Steven J. Hilla96102b2012-12-07 04:31:36 +0000154{
155 switch (isa) {
156 case MIPS_CPU_ISA_M64R2:
157 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
158 case MIPS_CPU_ISA_M64R1:
159 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
160 case MIPS_CPU_ISA_V:
161 c->isa_level |= MIPS_CPU_ISA_V;
162 case MIPS_CPU_ISA_IV:
163 c->isa_level |= MIPS_CPU_ISA_IV;
164 case MIPS_CPU_ISA_III:
Ralf Baechle1990e542013-06-26 17:06:34 +0200165 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000166 break;
167
168 case MIPS_CPU_ISA_M32R2:
169 c->isa_level |= MIPS_CPU_ISA_M32R2;
170 case MIPS_CPU_ISA_M32R1:
171 c->isa_level |= MIPS_CPU_ISA_M32R1;
172 case MIPS_CPU_ISA_II:
173 c->isa_level |= MIPS_CPU_ISA_II;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000174 break;
175 }
176}
177
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000178static char unknown_isa[] = KERN_ERR \
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100179 "Unsupported ISA type, c0.config0: %d.";
180
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000181static void set_ftlb_enable(struct cpuinfo_mips *c, int enable)
182{
183 unsigned int config6;
184 /*
185 * Config6 is implementation dependent and it's currently only
186 * used by proAptiv
187 */
188 if (c->cputype == CPU_PROAPTIV) {
189 config6 = read_c0_config6();
190 if (enable)
191 /* Enable FTLB */
192 write_c0_config6(config6 | MIPS_CONF6_FTLBEN);
193 else
194 /* Disable FTLB */
195 write_c0_config6(config6 & ~MIPS_CONF6_FTLBEN);
196 back_to_back_c0_hazard();
197 }
198}
199
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100200static inline unsigned int decode_config0(struct cpuinfo_mips *c)
201{
202 unsigned int config0;
203 int isa;
204
205 config0 = read_c0_config();
206
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000207 /*
208 * Look for Standard TLB or Dual VTLB and FTLB
209 */
210 if ((((config0 & MIPS_CONF_MT) >> 7) == 1) ||
211 (((config0 & MIPS_CONF_MT) >> 7) == 4))
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100212 c->options |= MIPS_CPU_TLB;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000213
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100214 isa = (config0 & MIPS_CONF_AT) >> 13;
215 switch (isa) {
216 case 0:
217 switch ((config0 & MIPS_CONF_AR) >> 10) {
218 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000219 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100220 break;
221 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000222 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100223 break;
224 default:
225 goto unknown;
226 }
227 break;
228 case 2:
229 switch ((config0 & MIPS_CONF_AR) >> 10) {
230 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000231 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100232 break;
233 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000234 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100235 break;
236 default:
237 goto unknown;
238 }
239 break;
240 default:
241 goto unknown;
242 }
243
244 return config0 & MIPS_CONF_M;
245
246unknown:
247 panic(unknown_isa, config0);
248}
249
250static inline unsigned int decode_config1(struct cpuinfo_mips *c)
251{
252 unsigned int config1;
253
254 config1 = read_c0_config1();
255
256 if (config1 & MIPS_CONF1_MD)
257 c->ases |= MIPS_ASE_MDMX;
258 if (config1 & MIPS_CONF1_WR)
259 c->options |= MIPS_CPU_WATCH;
260 if (config1 & MIPS_CONF1_CA)
261 c->ases |= MIPS_ASE_MIPS16;
262 if (config1 & MIPS_CONF1_EP)
263 c->options |= MIPS_CPU_EJTAG;
264 if (config1 & MIPS_CONF1_FP) {
265 c->options |= MIPS_CPU_FPU;
266 c->options |= MIPS_CPU_32FPR;
267 }
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000268 if (cpu_has_tlb) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100269 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000270 c->tlbsizevtlb = c->tlbsize;
271 c->tlbsizeftlbsets = 0;
272 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100273
274 return config1 & MIPS_CONF_M;
275}
276
277static inline unsigned int decode_config2(struct cpuinfo_mips *c)
278{
279 unsigned int config2;
280
281 config2 = read_c0_config2();
282
283 if (config2 & MIPS_CONF2_SL)
284 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
285
286 return config2 & MIPS_CONF_M;
287}
288
289static inline unsigned int decode_config3(struct cpuinfo_mips *c)
290{
291 unsigned int config3;
292
293 config3 = read_c0_config3();
294
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500295 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100296 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500297 c->options |= MIPS_CPU_RIXI;
298 }
299 if (config3 & MIPS_CONF3_RXI)
300 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100301 if (config3 & MIPS_CONF3_DSP)
302 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500303 if (config3 & MIPS_CONF3_DSP2P)
304 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100305 if (config3 & MIPS_CONF3_VINT)
306 c->options |= MIPS_CPU_VINT;
307 if (config3 & MIPS_CONF3_VEIC)
308 c->options |= MIPS_CPU_VEIC;
309 if (config3 & MIPS_CONF3_MT)
310 c->ases |= MIPS_ASE_MIPSMT;
311 if (config3 & MIPS_CONF3_ULRI)
312 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000313 if (config3 & MIPS_CONF3_ISA)
314 c->options |= MIPS_CPU_MICROMIPS;
David Daney1e7decd2013-02-16 23:42:43 +0100315 if (config3 & MIPS_CONF3_VZ)
316 c->ases |= MIPS_ASE_VZ;
Steven J. Hill4a0156f2013-11-14 16:12:24 +0000317 if (config3 & MIPS_CONF3_SC)
318 c->options |= MIPS_CPU_SEGMENTS;
Paul Burtona5e9a692014-01-27 15:23:10 +0000319 if (config3 & MIPS_CONF3_MSA)
320 c->ases |= MIPS_ASE_MSA;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100321
322 return config3 & MIPS_CONF_M;
323}
324
325static inline unsigned int decode_config4(struct cpuinfo_mips *c)
326{
327 unsigned int config4;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000328 unsigned int newcf4;
329 unsigned int mmuextdef;
330 unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100331
332 config4 = read_c0_config4();
333
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000334 if (cpu_has_tlb) {
335 if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
336 c->options |= MIPS_CPU_TLBINV;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000337 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
338 switch (mmuextdef) {
339 case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:
340 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
341 c->tlbsizevtlb = c->tlbsize;
342 break;
343 case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT:
344 c->tlbsizevtlb +=
345 ((config4 & MIPS_CONF4_VTLBSIZEEXT) >>
346 MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40;
347 c->tlbsize = c->tlbsizevtlb;
348 ftlb_page = MIPS_CONF4_VFTLBPAGESIZE;
349 /* fall through */
350 case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT:
351 newcf4 = (config4 & ~ftlb_page) |
352 (page_size_ftlb(mmuextdef) <<
353 MIPS_CONF4_FTLBPAGESIZE_SHIFT);
354 write_c0_config4(newcf4);
355 back_to_back_c0_hazard();
356 config4 = read_c0_config4();
357 if (config4 != newcf4) {
358 pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
359 PAGE_SIZE, config4);
360 /* Switch FTLB off */
361 set_ftlb_enable(c, 0);
362 break;
363 }
364 c->tlbsizeftlbsets = 1 <<
365 ((config4 & MIPS_CONF4_FTLBSETS) >>
366 MIPS_CONF4_FTLBSETS_SHIFT);
367 c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >>
368 MIPS_CONF4_FTLBWAYS_SHIFT) + 2;
369 c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets;
370 break;
371 }
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000372 }
373
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100374 c->kscratch_mask = (config4 >> 16) & 0xff;
375
376 return config4 & MIPS_CONF_M;
377}
378
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200379static inline unsigned int decode_config5(struct cpuinfo_mips *c)
380{
381 unsigned int config5;
382
383 config5 = read_c0_config5();
384 config5 &= ~MIPS_CONF5_UFR;
385 write_c0_config5(config5);
386
387 return config5 & MIPS_CONF_M;
388}
389
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000390static void decode_configs(struct cpuinfo_mips *c)
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100391{
392 int ok;
393
394 /* MIPS32 or MIPS64 compliant CPU. */
395 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
396 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
397
398 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
399
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000400 /* Enable FTLB if present */
401 set_ftlb_enable(c, 1);
402
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100403 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100404 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100405 if (ok)
406 ok = decode_config1(c);
407 if (ok)
408 ok = decode_config2(c);
409 if (ok)
410 ok = decode_config3(c);
411 if (ok)
412 ok = decode_config4(c);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200413 if (ok)
414 ok = decode_config5(c);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100415
416 mips_probe_watch_registers(c);
417
Paul Burton0ee958e2014-01-15 10:31:53 +0000418#ifndef CONFIG_MIPS_CPS
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100419 if (cpu_has_mips_r2)
420 c->core = read_c0_ebase() & 0x3ff;
Paul Burton0ee958e2014-01-15 10:31:53 +0000421#endif
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100422}
423
Ralf Baechle02cf2112005-10-01 13:06:32 +0100424#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700425 | MIPS_CPU_COUNTER)
426
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000427static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100429 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 case PRID_IMP_R2000:
431 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000432 __cpu_name[cpu] = "R2000";
Ralf Baechle02cf2112005-10-01 13:06:32 +0100433 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500434 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700435 if (__cpu_has_fpu())
436 c->options |= MIPS_CPU_FPU;
437 c->tlbsize = 64;
438 break;
439 case PRID_IMP_R3000:
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100440 if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000441 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000443 __cpu_name[cpu] = "R3081";
444 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000446 __cpu_name[cpu] = "R3000A";
447 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000448 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000450 __cpu_name[cpu] = "R3000";
451 }
Ralf Baechle02cf2112005-10-01 13:06:32 +0100452 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500453 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454 if (__cpu_has_fpu())
455 c->options |= MIPS_CPU_FPU;
456 c->tlbsize = 64;
457 break;
458 case PRID_IMP_R4000:
459 if (read_c0_config() & CONF_SC) {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100460 if ((c->processor_id & PRID_REV_MASK) >=
461 PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000463 __cpu_name[cpu] = "R4400PC";
464 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000466 __cpu_name[cpu] = "R4000PC";
467 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100469 int cca = read_c0_config() & CONF_CM_CMASK;
470 int mc;
471
472 /*
473 * SC and MC versions can't be reliably told apart,
474 * but only the latter support coherent caching
475 * modes so assume the firmware has set the KSEG0
476 * coherency attribute reasonably (if uncached, we
477 * assume SC).
478 */
479 switch (cca) {
480 case CONF_CM_CACHABLE_CE:
481 case CONF_CM_CACHABLE_COW:
482 case CONF_CM_CACHABLE_CUW:
483 mc = 1;
484 break;
485 default:
486 mc = 0;
487 break;
488 }
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100489 if ((c->processor_id & PRID_REV_MASK) >=
490 PRID_REV_R4400) {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100491 c->cputype = mc ? CPU_R4400MC : CPU_R4400SC;
492 __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000493 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100494 c->cputype = mc ? CPU_R4000MC : CPU_R4000SC;
495 __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000496 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497 }
498
Steven J. Hilla96102b2012-12-07 04:31:36 +0000499 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500501 MIPS_CPU_WATCH | MIPS_CPU_VCE |
502 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 c->tlbsize = 48;
504 break;
505 case PRID_IMP_VR41XX:
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900506 set_isa(c, MIPS_CPU_ISA_III);
507 c->options = R4K_OPTS;
508 c->tlbsize = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700510 case PRID_REV_VR4111:
511 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000512 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 case PRID_REV_VR4121:
515 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000516 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700517 break;
518 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000519 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700520 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000521 __cpu_name[cpu] = "NEC VR4122";
522 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000524 __cpu_name[cpu] = "NEC VR4181A";
525 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 break;
527 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000528 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000530 __cpu_name[cpu] = "NEC VR4131";
531 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700532 c->cputype = CPU_VR4133;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900533 c->options |= MIPS_CPU_LLSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000534 __cpu_name[cpu] = "NEC VR4133";
535 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 break;
537 default:
538 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
539 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000540 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700541 break;
542 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 break;
544 case PRID_IMP_R4300:
545 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000546 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000547 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700548 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500549 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700550 c->tlbsize = 32;
551 break;
552 case PRID_IMP_R4600:
553 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000554 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000555 set_isa(c, MIPS_CPU_ISA_III);
Thiemo Seufer075e7502005-07-27 21:48:12 +0000556 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
557 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 c->tlbsize = 48;
559 break;
560 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500561 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 /*
563 * This processor doesn't have an MMU, so it's not
564 * "real easy" to run Linux on it. It is left purely
565 * for documentation. Commented out because it shares
566 * it's c0_prid id number with the TX3900.
567 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000568 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000569 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000570 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500572 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 break;
574 #endif
575 case PRID_IMP_TX39:
Ralf Baechle02cf2112005-10-01 13:06:32 +0100576 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700577
578 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
579 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000580 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581 c->tlbsize = 64;
582 } else {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100583 switch (c->processor_id & PRID_REV_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 case PRID_REV_TX3912:
585 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000586 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587 c->tlbsize = 32;
588 break;
589 case PRID_REV_TX3922:
590 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000591 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700592 c->tlbsize = 64;
593 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700594 }
595 }
596 break;
597 case PRID_IMP_R4700:
598 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000599 __cpu_name[cpu] = "R4700";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000600 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700601 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500602 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603 c->tlbsize = 48;
604 break;
605 case PRID_IMP_TX49:
606 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000607 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000608 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 c->options = R4K_OPTS | MIPS_CPU_LLSC;
610 if (!(c->processor_id & 0x08))
611 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
612 c->tlbsize = 48;
613 break;
614 case PRID_IMP_R5000:
615 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000616 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000617 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500619 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 c->tlbsize = 48;
621 break;
622 case PRID_IMP_R5432:
623 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000624 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000625 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700626 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500627 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700628 c->tlbsize = 48;
629 break;
630 case PRID_IMP_R5500:
631 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000632 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000633 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500635 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700636 c->tlbsize = 48;
637 break;
638 case PRID_IMP_NEVADA:
639 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000640 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000641 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500643 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 c->tlbsize = 48;
645 break;
646 case PRID_IMP_R6000:
647 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000648 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000649 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700650 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500651 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 c->tlbsize = 32;
653 break;
654 case PRID_IMP_R6000A:
655 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000656 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000657 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500659 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 c->tlbsize = 32;
661 break;
662 case PRID_IMP_RM7000:
663 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000664 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000665 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500667 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100669 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 * the RM7000 v2.0 indicates if the TLB has 48 or 64
671 * entries.
672 *
Ralf Baechle70342282013-01-22 12:59:30 +0100673 * 29 1 => 64 entry JTLB
674 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675 */
676 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
677 break;
678 case PRID_IMP_RM9000:
679 c->cputype = CPU_RM9000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000680 __cpu_name[cpu] = "RM9000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000681 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700682 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500683 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 /*
685 * Bit 29 in the info register of the RM9000
686 * indicates if the TLB has 48 or 64 entries.
687 *
Ralf Baechle70342282013-01-22 12:59:30 +0100688 * 29 1 => 64 entry JTLB
689 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700690 */
691 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
692 break;
693 case PRID_IMP_R8000:
694 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000695 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000696 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700697 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500698 MIPS_CPU_FPU | MIPS_CPU_32FPR |
699 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700700 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
701 break;
702 case PRID_IMP_R10000:
703 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000704 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000705 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000706 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500707 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500709 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700710 c->tlbsize = 64;
711 break;
712 case PRID_IMP_R12000:
713 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000714 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000715 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000716 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500717 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700718 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500719 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700720 c->tlbsize = 64;
721 break;
Kumba44d921b2006-05-16 22:23:59 -0400722 case PRID_IMP_R14000:
723 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000724 __cpu_name[cpu] = "R14000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000725 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400726 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500727 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400728 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500729 MIPS_CPU_LLSC;
Kumba44d921b2006-05-16 22:23:59 -0400730 c->tlbsize = 64;
731 break;
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800732 case PRID_IMP_LOONGSON2:
733 c->cputype = CPU_LOONGSON2;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000734 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700735
736 switch (c->processor_id & PRID_REV_MASK) {
737 case PRID_REV_LOONGSON2E:
738 set_elf_platform(cpu, "loongson2e");
739 break;
740 case PRID_REV_LOONGSON2F:
741 set_elf_platform(cpu, "loongson2f");
742 break;
743 }
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;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100751 case PRID_IMP_LOONGSON1:
752 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;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700847 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100848
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000849 decode_configs(c);
850
Chris Dearman0b6d4972007-09-13 12:32:02 +0100851 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700852}
853
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000854static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700855{
Ralf Baechle41943182005-05-05 16:45:59 +0000856 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100857 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700858 case PRID_IMP_AU1_REV1:
859 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100860 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700861 switch ((c->processor_id >> 24) & 0xff) {
862 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000863 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700864 break;
865 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000866 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700867 break;
868 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000869 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 break;
871 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000872 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700873 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000874 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000875 __cpu_name[cpu] = "Au1200";
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100876 if ((c->processor_id & PRID_REV_MASK) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000877 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100878 break;
879 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000880 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000881 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100883 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700884 break;
885 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 break;
887 }
888}
889
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000890static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700891{
Ralf Baechle41943182005-05-05 16:45:59 +0000892 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100893
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100894 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895 case PRID_IMP_SB1:
896 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000897 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 /* FPU in pass1 is known to have issues. */
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100899 if ((c->processor_id & PRID_REV_MASK) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000900 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700902 case PRID_IMP_SB1A:
903 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000904 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700905 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700906 }
907}
908
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000909static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700910{
Ralf Baechle41943182005-05-05 16:45:59 +0000911 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100912 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 case PRID_IMP_SR71000:
914 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000915 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700916 c->scache.ways = 8;
917 c->tlbsize = 64;
918 break;
919 }
920}
921
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000922static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000923{
924 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100925 switch (c->processor_id & PRID_IMP_MASK) {
Pete Popovbdf21b12005-07-14 17:47:57 +0000926 case PRID_IMP_PR4450:
927 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000928 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000929 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +0000930 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000931 }
932}
933
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000934static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200935{
936 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100937 switch (c->processor_id & PRID_IMP_MASK) {
Kevin Cernekee190fca32010-11-23 10:26:45 -0800938 case PRID_IMP_BMIPS32_REV4:
939 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -0700940 c->cputype = CPU_BMIPS32;
941 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700942 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200943 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700944 case PRID_IMP_BMIPS3300:
945 case PRID_IMP_BMIPS3300_ALT:
946 case PRID_IMP_BMIPS3300_BUG:
947 c->cputype = CPU_BMIPS3300;
948 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700949 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200950 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700951 case PRID_IMP_BMIPS43XX: {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100952 int rev = c->processor_id & PRID_REV_MASK;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700953
954 if (rev >= PRID_REV_BMIPS4380_LO &&
955 rev <= PRID_REV_BMIPS4380_HI) {
956 c->cputype = CPU_BMIPS4380;
957 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700958 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700959 } else {
960 c->cputype = CPU_BMIPS4350;
961 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700962 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +0100963 }
964 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200965 }
Kevin Cernekee602977b2010-10-16 14:22:30 -0700966 case PRID_IMP_BMIPS5000:
967 c->cputype = CPU_BMIPS5000;
968 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700969 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700970 c->options |= MIPS_CPU_ULRI;
971 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700972 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200973}
974
David Daney0dd47812008-12-11 15:33:26 -0800975static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
976{
977 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100978 switch (c->processor_id & PRID_IMP_MASK) {
David Daney0dd47812008-12-11 15:33:26 -0800979 case PRID_IMP_CAVIUM_CN38XX:
980 case PRID_IMP_CAVIUM_CN31XX:
981 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -0800982 c->cputype = CPU_CAVIUM_OCTEON;
983 __cpu_name[cpu] = "Cavium Octeon";
984 goto platform;
David Daney0dd47812008-12-11 15:33:26 -0800985 case PRID_IMP_CAVIUM_CN58XX:
986 case PRID_IMP_CAVIUM_CN56XX:
987 case PRID_IMP_CAVIUM_CN50XX:
988 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -0800989 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
990 __cpu_name[cpu] = "Cavium Octeon+";
991platform:
Robert Millanc094c992011-04-18 11:37:55 -0700992 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -0800993 break;
David Daneya1431b62011-09-24 02:29:54 +0200994 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -0700995 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +0200996 case PRID_IMP_CAVIUM_CN66XX:
997 case PRID_IMP_CAVIUM_CN68XX:
David Daneyaf04bb82013-07-29 15:07:01 -0700998 case PRID_IMP_CAVIUM_CNF71XX:
David Daney0e56b382010-10-07 16:03:45 -0700999 c->cputype = CPU_CAVIUM_OCTEON2;
1000 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001001 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001002 break;
David Daneyaf04bb82013-07-29 15:07:01 -07001003 case PRID_IMP_CAVIUM_CN70XX:
1004 case PRID_IMP_CAVIUM_CN78XX:
1005 c->cputype = CPU_CAVIUM_OCTEON3;
1006 __cpu_name[cpu] = "Cavium Octeon III";
1007 set_elf_platform(cpu, "octeon3");
1008 break;
David Daney0dd47812008-12-11 15:33:26 -08001009 default:
1010 printk(KERN_INFO "Unknown Octeon chip!\n");
1011 c->cputype = CPU_UNKNOWN;
1012 break;
1013 }
1014}
1015
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001016static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1017{
1018 decode_configs(c);
1019 /* JZRISC does not implement the CP0 counter. */
1020 c->options &= ~MIPS_CPU_COUNTER;
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001021 switch (c->processor_id & PRID_IMP_MASK) {
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001022 case PRID_IMP_JZRISC:
1023 c->cputype = CPU_JZRISC;
1024 __cpu_name[cpu] = "Ingenic JZRISC";
1025 break;
1026 default:
1027 panic("Unknown Ingenic Processor ID!");
1028 break;
1029 }
1030}
1031
Jayachandran Ca7117c62011-05-11 12:04:58 +05301032static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1033{
1034 decode_configs(c);
1035
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001036 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
Manuel Lauss809f36c2011-11-01 20:03:30 +01001037 c->cputype = CPU_ALCHEMY;
1038 __cpu_name[cpu] = "Au1300";
1039 /* following stuff is not for Alchemy */
1040 return;
1041 }
1042
Ralf Baechle70342282013-01-22 12:59:30 +01001043 c->options = (MIPS_CPU_TLB |
1044 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301045 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +01001046 MIPS_CPU_DIVEC |
1047 MIPS_CPU_WATCH |
1048 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301049 MIPS_CPU_LLSC);
1050
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001051 switch (c->processor_id & PRID_IMP_MASK) {
Jayachandran C4ca86a22013-08-11 14:43:54 +05301052 case PRID_IMP_NETLOGIC_XLP2XX:
Jayachandran C8907c552013-12-21 16:52:20 +05301053 case PRID_IMP_NETLOGIC_XLP9XX:
Jayachandran C4ca86a22013-08-11 14:43:54 +05301054 c->cputype = CPU_XLP;
1055 __cpu_name[cpu] = "Broadcom XLPII";
1056 break;
1057
Jayachandran C2aa54b22011-11-16 00:21:29 +00001058 case PRID_IMP_NETLOGIC_XLP8XX:
1059 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001060 c->cputype = CPU_XLP;
1061 __cpu_name[cpu] = "Netlogic XLP";
1062 break;
1063
Jayachandran Ca7117c62011-05-11 12:04:58 +05301064 case PRID_IMP_NETLOGIC_XLR732:
1065 case PRID_IMP_NETLOGIC_XLR716:
1066 case PRID_IMP_NETLOGIC_XLR532:
1067 case PRID_IMP_NETLOGIC_XLR308:
1068 case PRID_IMP_NETLOGIC_XLR532C:
1069 case PRID_IMP_NETLOGIC_XLR516C:
1070 case PRID_IMP_NETLOGIC_XLR508C:
1071 case PRID_IMP_NETLOGIC_XLR308C:
1072 c->cputype = CPU_XLR;
1073 __cpu_name[cpu] = "Netlogic XLR";
1074 break;
1075
1076 case PRID_IMP_NETLOGIC_XLS608:
1077 case PRID_IMP_NETLOGIC_XLS408:
1078 case PRID_IMP_NETLOGIC_XLS404:
1079 case PRID_IMP_NETLOGIC_XLS208:
1080 case PRID_IMP_NETLOGIC_XLS204:
1081 case PRID_IMP_NETLOGIC_XLS108:
1082 case PRID_IMP_NETLOGIC_XLS104:
1083 case PRID_IMP_NETLOGIC_XLS616B:
1084 case PRID_IMP_NETLOGIC_XLS608B:
1085 case PRID_IMP_NETLOGIC_XLS416B:
1086 case PRID_IMP_NETLOGIC_XLS412B:
1087 case PRID_IMP_NETLOGIC_XLS408B:
1088 case PRID_IMP_NETLOGIC_XLS404B:
1089 c->cputype = CPU_XLR;
1090 __cpu_name[cpu] = "Netlogic XLS";
1091 break;
1092
1093 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001094 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301095 c->processor_id);
1096 c->cputype = CPU_XLR;
1097 break;
1098 }
1099
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001100 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001101 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001102 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1103 /* This will be updated again after all threads are woken up */
1104 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1105 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001106 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001107 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1108 }
Jayachandran C7777b932013-06-11 14:41:35 +00001109 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301110}
1111
David Daney949e51b2010-10-14 11:32:33 -07001112#ifdef CONFIG_64BIT
1113/* For use by uaccess.h */
1114u64 __ua_limit;
1115EXPORT_SYMBOL(__ua_limit);
1116#endif
1117
Ralf Baechle9966db252007-10-11 23:46:17 +01001118const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001119const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001120
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001121void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001122{
1123 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001124 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001125
Ralf Baechle70342282013-01-22 12:59:30 +01001126 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001127 c->fpu_id = FPIR_IMP_NONE;
1128 c->cputype = CPU_UNKNOWN;
1129
1130 c->processor_id = read_c0_prid();
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001131 switch (c->processor_id & PRID_COMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001132 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001133 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 break;
1135 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001136 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001137 break;
1138 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001139 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001140 break;
1141 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001142 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001144 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001145 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001146 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001148 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001150 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001151 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001152 break;
David Daney0dd47812008-12-11 15:33:26 -08001153 case PRID_COMP_CAVIUM:
1154 cpu_probe_cavium(c, cpu);
1155 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001156 case PRID_COMP_INGENIC:
1157 cpu_probe_ingenic(c, cpu);
1158 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301159 case PRID_COMP_NETLOGIC:
1160 cpu_probe_netlogic(c, cpu);
1161 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001162 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001163
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001164 BUG_ON(!__cpu_name[cpu]);
1165 BUG_ON(c->cputype == CPU_UNKNOWN);
1166
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001167 /*
1168 * Platform code can force the cpu type to optimize code
1169 * generation. In that case be sure the cpu type is correctly
1170 * manually setup otherwise it could trigger some nasty bugs.
1171 */
1172 BUG_ON(current_cpu_type() != c->cputype);
1173
Kevin Cernekee0103d232010-05-02 14:43:52 -07001174 if (mips_fpu_disabled)
1175 c->options &= ~MIPS_CPU_FPU;
1176
1177 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001178 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001179
Ralf Baechle41943182005-05-05 16:45:59 +00001180 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001182
Deng-Cheng Zhuadb37892013-04-01 18:14:28 +00001183 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 |
1184 MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)) {
Ralf Baechle41943182005-05-05 16:45:59 +00001185 if (c->fpu_id & MIPS_FPIR_3D)
1186 c->ases |= MIPS_ASE_MIPS3D;
1187 }
1188 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001189
Al Cooperda4b62c2012-07-13 16:44:51 -04001190 if (cpu_has_mips_r2) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001191 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001192 /* R2 has Performance Counter Interrupt indicator */
1193 c->options |= MIPS_CPU_PCI;
1194 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001195 else
1196 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001197
Paul Burtona5e9a692014-01-27 15:23:10 +00001198 if (cpu_has_msa)
1199 c->msa_id = cpu_get_msa_id();
1200
Guenter Roeck91dfc422010-02-02 08:52:20 -08001201 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001202
1203#ifdef CONFIG_64BIT
1204 if (cpu == 0)
1205 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1206#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207}
1208
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001209void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001210{
1211 struct cpuinfo_mips *c = &current_cpu_data;
1212
Leonid Yegoshind9f897c2013-10-07 10:43:32 +01001213 pr_info("CPU%d revision is: %08x (%s)\n",
1214 smp_processor_id(), c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001215 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001216 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Paul Burtona5e9a692014-01-27 15:23:10 +00001217 if (cpu_has_msa)
1218 pr_info("MSA revision is: %08x\n", c->msa_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001219}