blob: 0d30433db54bab2376a61e517f5ad3d8bb173381 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Processor capabilities determination functions.
3 *
4 * Copyright (C) xxxx the Anonymous
Ralf Baechle010b8532006-01-29 18:42:08 +00005 * Copyright (C) 1994 - 2006 Ralf Baechle
Ralf Baechle41943182005-05-05 16:45:59 +00006 * Copyright (C) 2003, 2004 Maciej W. Rozycki
Ralf Baechle70342282013-01-22 12:59:30 +01007 * Copyright (C) 2001, 2004, 2011, 2012 MIPS Technologies, Inc.
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#include <linux/init.h>
15#include <linux/kernel.h>
16#include <linux/ptrace.h>
Ralf Baechle631330f2009-06-19 14:05:26 +010017#include <linux/smp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070018#include <linux/stddef.h>
Paul Gortmaker73bc2562011-07-23 16:30:40 -040019#include <linux/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Ralf Baechle57599062007-02-18 19:07:31 +000021#include <asm/bugs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070022#include <asm/cpu.h>
Ralf Baechle69f24d12013-09-17 10:25:47 +020023#include <asm/cpu-type.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070024#include <asm/fpu.h>
25#include <asm/mipsregs.h>
Paul Burton30ee6152014-03-27 10:57:30 +000026#include <asm/mipsmtregs.h>
Paul Burtona5e9a692014-01-27 15:23:10 +000027#include <asm/msa.h>
David Daney654f57b2008-09-23 00:07:16 -070028#include <asm/watch.h>
Paul Gortmaker06372a62011-07-23 16:26:41 -040029#include <asm/elf.h>
Chris Dearmana074f0e2009-07-10 01:51:27 -070030#include <asm/spram.h>
David Daney949e51b2010-10-14 11:32:33 -070031#include <asm/uaccess.h>
32
Paul Gortmaker078a55f2013-06-18 13:38:59 +000033static int mips_fpu_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -070034
35static int __init fpu_disable(char *s)
36{
37 cpu_data[0].options &= ~MIPS_CPU_FPU;
38 mips_fpu_disabled = 1;
39
40 return 1;
41}
42
43__setup("nofpu", fpu_disable);
44
Paul Gortmaker078a55f2013-06-18 13:38:59 +000045int mips_dsp_disabled;
Kevin Cernekee0103d232010-05-02 14:43:52 -070046
47static int __init dsp_disable(char *s)
48{
Steven J. Hillee80f7c72012-08-03 10:26:04 -050049 cpu_data[0].ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -070050 mips_dsp_disabled = 1;
51
52 return 1;
53}
54
55__setup("nodsp", dsp_disable);
56
Markos Chandras3d528b32014-07-14 12:46:13 +010057static int mips_htw_disabled;
58
59static int __init htw_disable(char *s)
60{
61 mips_htw_disabled = 1;
62 cpu_data[0].options &= ~MIPS_CPU_HTW;
63 write_c0_pwctl(read_c0_pwctl() &
64 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
65
66 return 1;
67}
68
69__setup("nohtw", htw_disable);
70
Marc St-Jean9267a302007-06-14 15:55:31 -060071static inline void check_errata(void)
72{
73 struct cpuinfo_mips *c = &current_cpu_data;
74
Ralf Baechle69f24d12013-09-17 10:25:47 +020075 switch (current_cpu_type()) {
Marc St-Jean9267a302007-06-14 15:55:31 -060076 case CPU_34K:
77 /*
78 * Erratum "RPS May Cause Incorrect Instruction Execution"
Ralf Baechleb633648c52014-05-23 16:29:44 +020079 * This code only handles VPE0, any SMP/RTOS code
Marc St-Jean9267a302007-06-14 15:55:31 -060080 * making use of VPE1 will be responsable for that VPE.
81 */
82 if ((c->processor_id & PRID_REV_MASK) <= PRID_REV_34K_V1_0_2)
83 write_c0_config7(read_c0_config7() | MIPS_CONF7_RPS);
84 break;
85 default:
86 break;
87 }
88}
89
Linus Torvalds1da177e2005-04-16 15:20:36 -070090void __init check_bugs32(void)
91{
Marc St-Jean9267a302007-06-14 15:55:31 -060092 check_errata();
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
94
95/*
96 * Probe whether cpu has config register by trying to play with
97 * alternate cache bit and see whether it matters.
98 * It's used by cpu_probe to distinguish between R3000A and R3081.
99 */
100static inline int cpu_has_confreg(void)
101{
102#ifdef CONFIG_CPU_R3000
103 extern unsigned long r3k_cache_size(unsigned long);
104 unsigned long size1, size2;
105 unsigned long cfg = read_c0_conf();
106
107 size1 = r3k_cache_size(ST0_ISC);
108 write_c0_conf(cfg ^ R30XX_CONF_AC);
109 size2 = r3k_cache_size(ST0_ISC);
110 write_c0_conf(cfg);
111 return size1 != size2;
112#else
113 return 0;
114#endif
115}
116
Robert Millanc094c992011-04-18 11:37:55 -0700117static inline void set_elf_platform(int cpu, const char *plat)
118{
119 if (cpu == 0)
120 __elf_platform = plat;
121}
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123/*
124 * Get the FPU Implementation/Revision.
125 */
126static inline unsigned long cpu_get_fpu_id(void)
127{
128 unsigned long tmp, fpu_id;
129
130 tmp = read_c0_status();
Paul Burton597ce172013-11-22 13:12:07 +0000131 __enable_fpu(FPU_AS_IS);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 fpu_id = read_32bit_cp1_register(CP1_REVISION);
133 write_c0_status(tmp);
134 return fpu_id;
135}
136
137/*
138 * Check the CPU has an FPU the official way.
139 */
140static inline int __cpu_has_fpu(void)
141{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100142 return ((cpu_get_fpu_id() & FPIR_IMP_MASK) != FPIR_IMP_NONE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143}
144
Paul Burtona5e9a692014-01-27 15:23:10 +0000145static inline unsigned long cpu_get_msa_id(void)
146{
147 unsigned long status, conf5, msa_id;
148
149 status = read_c0_status();
150 __enable_fpu(FPU_64BIT);
151 conf5 = read_c0_config5();
152 enable_msa();
153 msa_id = read_msa_ir();
154 write_c0_config5(conf5);
155 write_c0_status(status);
156 return msa_id;
157}
158
Guenter Roeck91dfc422010-02-02 08:52:20 -0800159static inline void cpu_probe_vmbits(struct cpuinfo_mips *c)
160{
161#ifdef __NEED_VMBITS_PROBE
David Daney5b7efa82010-02-08 12:27:00 -0800162 write_c0_entryhi(0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800163 back_to_back_c0_hazard();
David Daney5b7efa82010-02-08 12:27:00 -0800164 c->vmbits = fls64(read_c0_entryhi() & 0x3fffffffffffe000ULL);
Guenter Roeck91dfc422010-02-02 08:52:20 -0800165#endif
166}
167
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000168static void set_isa(struct cpuinfo_mips *c, unsigned int isa)
Steven J. Hilla96102b2012-12-07 04:31:36 +0000169{
170 switch (isa) {
171 case MIPS_CPU_ISA_M64R2:
172 c->isa_level |= MIPS_CPU_ISA_M32R2 | MIPS_CPU_ISA_M64R2;
173 case MIPS_CPU_ISA_M64R1:
174 c->isa_level |= MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M64R1;
175 case MIPS_CPU_ISA_V:
176 c->isa_level |= MIPS_CPU_ISA_V;
177 case MIPS_CPU_ISA_IV:
178 c->isa_level |= MIPS_CPU_ISA_IV;
179 case MIPS_CPU_ISA_III:
Ralf Baechle1990e542013-06-26 17:06:34 +0200180 c->isa_level |= MIPS_CPU_ISA_II | MIPS_CPU_ISA_III;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000181 break;
182
183 case MIPS_CPU_ISA_M32R2:
184 c->isa_level |= MIPS_CPU_ISA_M32R2;
185 case MIPS_CPU_ISA_M32R1:
186 c->isa_level |= MIPS_CPU_ISA_M32R1;
187 case MIPS_CPU_ISA_II:
188 c->isa_level |= MIPS_CPU_ISA_II;
Steven J. Hilla96102b2012-12-07 04:31:36 +0000189 break;
190 }
191}
192
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000193static char unknown_isa[] = KERN_ERR \
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100194 "Unsupported ISA type, c0.config0: %d.";
195
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000196static void set_ftlb_enable(struct cpuinfo_mips *c, int enable)
197{
198 unsigned int config6;
James Hogand83b0e82014-01-22 16:19:40 +0000199
200 /* It's implementation dependent how the FTLB can be enabled */
201 switch (c->cputype) {
202 case CPU_PROAPTIV:
203 case CPU_P5600:
204 /* proAptiv & related cores use Config6 to enable the FTLB */
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000205 config6 = read_c0_config6();
206 if (enable)
207 /* Enable FTLB */
208 write_c0_config6(config6 | MIPS_CONF6_FTLBEN);
209 else
210 /* Disable FTLB */
211 write_c0_config6(config6 & ~MIPS_CONF6_FTLBEN);
212 back_to_back_c0_hazard();
James Hogand83b0e82014-01-22 16:19:40 +0000213 break;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000214 }
215}
216
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100217static inline unsigned int decode_config0(struct cpuinfo_mips *c)
218{
219 unsigned int config0;
220 int isa;
221
222 config0 = read_c0_config();
223
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000224 /*
225 * Look for Standard TLB or Dual VTLB and FTLB
226 */
227 if ((((config0 & MIPS_CONF_MT) >> 7) == 1) ||
228 (((config0 & MIPS_CONF_MT) >> 7) == 4))
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100229 c->options |= MIPS_CPU_TLB;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000230
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100231 isa = (config0 & MIPS_CONF_AT) >> 13;
232 switch (isa) {
233 case 0:
234 switch ((config0 & MIPS_CONF_AR) >> 10) {
235 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000236 set_isa(c, MIPS_CPU_ISA_M32R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100237 break;
238 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000239 set_isa(c, MIPS_CPU_ISA_M32R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100240 break;
241 default:
242 goto unknown;
243 }
244 break;
245 case 2:
246 switch ((config0 & MIPS_CONF_AR) >> 10) {
247 case 0:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000248 set_isa(c, MIPS_CPU_ISA_M64R1);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100249 break;
250 case 1:
Steven J. Hilla96102b2012-12-07 04:31:36 +0000251 set_isa(c, MIPS_CPU_ISA_M64R2);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100252 break;
253 default:
254 goto unknown;
255 }
256 break;
257 default:
258 goto unknown;
259 }
260
261 return config0 & MIPS_CONF_M;
262
263unknown:
264 panic(unknown_isa, config0);
265}
266
267static inline unsigned int decode_config1(struct cpuinfo_mips *c)
268{
269 unsigned int config1;
270
271 config1 = read_c0_config1();
272
273 if (config1 & MIPS_CONF1_MD)
274 c->ases |= MIPS_ASE_MDMX;
275 if (config1 & MIPS_CONF1_WR)
276 c->options |= MIPS_CPU_WATCH;
277 if (config1 & MIPS_CONF1_CA)
278 c->ases |= MIPS_ASE_MIPS16;
279 if (config1 & MIPS_CONF1_EP)
280 c->options |= MIPS_CPU_EJTAG;
281 if (config1 & MIPS_CONF1_FP) {
282 c->options |= MIPS_CPU_FPU;
283 c->options |= MIPS_CPU_32FPR;
284 }
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000285 if (cpu_has_tlb) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100286 c->tlbsize = ((config1 & MIPS_CONF1_TLBS) >> 25) + 1;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000287 c->tlbsizevtlb = c->tlbsize;
288 c->tlbsizeftlbsets = 0;
289 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100290
291 return config1 & MIPS_CONF_M;
292}
293
294static inline unsigned int decode_config2(struct cpuinfo_mips *c)
295{
296 unsigned int config2;
297
298 config2 = read_c0_config2();
299
300 if (config2 & MIPS_CONF2_SL)
301 c->scache.flags &= ~MIPS_CACHE_NOT_PRESENT;
302
303 return config2 & MIPS_CONF_M;
304}
305
306static inline unsigned int decode_config3(struct cpuinfo_mips *c)
307{
308 unsigned int config3;
309
310 config3 = read_c0_config3();
311
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500312 if (config3 & MIPS_CONF3_SM) {
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100313 c->ases |= MIPS_ASE_SMARTMIPS;
Steven J. Hillb2ab4f02012-09-13 16:47:58 -0500314 c->options |= MIPS_CPU_RIXI;
315 }
316 if (config3 & MIPS_CONF3_RXI)
317 c->options |= MIPS_CPU_RIXI;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100318 if (config3 & MIPS_CONF3_DSP)
319 c->ases |= MIPS_ASE_DSP;
Steven J. Hillee80f7c72012-08-03 10:26:04 -0500320 if (config3 & MIPS_CONF3_DSP2P)
321 c->ases |= MIPS_ASE_DSP2P;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100322 if (config3 & MIPS_CONF3_VINT)
323 c->options |= MIPS_CPU_VINT;
324 if (config3 & MIPS_CONF3_VEIC)
325 c->options |= MIPS_CPU_VEIC;
326 if (config3 & MIPS_CONF3_MT)
327 c->ases |= MIPS_ASE_MIPSMT;
328 if (config3 & MIPS_CONF3_ULRI)
329 c->options |= MIPS_CPU_ULRI;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000330 if (config3 & MIPS_CONF3_ISA)
331 c->options |= MIPS_CPU_MICROMIPS;
David Daney1e7decd2013-02-16 23:42:43 +0100332 if (config3 & MIPS_CONF3_VZ)
333 c->ases |= MIPS_ASE_VZ;
Steven J. Hill4a0156f2013-11-14 16:12:24 +0000334 if (config3 & MIPS_CONF3_SC)
335 c->options |= MIPS_CPU_SEGMENTS;
Paul Burtona5e9a692014-01-27 15:23:10 +0000336 if (config3 & MIPS_CONF3_MSA)
337 c->ases |= MIPS_ASE_MSA;
Markos Chandras3d528b32014-07-14 12:46:13 +0100338 /* Only tested on 32-bit cores */
339 if ((config3 & MIPS_CONF3_PW) && config_enabled(CONFIG_32BIT))
340 c->options |= MIPS_CPU_HTW;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100341
342 return config3 & MIPS_CONF_M;
343}
344
345static inline unsigned int decode_config4(struct cpuinfo_mips *c)
346{
347 unsigned int config4;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000348 unsigned int newcf4;
349 unsigned int mmuextdef;
350 unsigned int ftlb_page = MIPS_CONF4_FTLBPAGESIZE;
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100351
352 config4 = read_c0_config4();
353
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000354 if (cpu_has_tlb) {
355 if (((config4 & MIPS_CONF4_IE) >> 29) == 2)
356 c->options |= MIPS_CPU_TLBINV;
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000357 mmuextdef = config4 & MIPS_CONF4_MMUEXTDEF;
358 switch (mmuextdef) {
359 case MIPS_CONF4_MMUEXTDEF_MMUSIZEEXT:
360 c->tlbsize += (config4 & MIPS_CONF4_MMUSIZEEXT) * 0x40;
361 c->tlbsizevtlb = c->tlbsize;
362 break;
363 case MIPS_CONF4_MMUEXTDEF_VTLBSIZEEXT:
364 c->tlbsizevtlb +=
365 ((config4 & MIPS_CONF4_VTLBSIZEEXT) >>
366 MIPS_CONF4_VTLBSIZEEXT_SHIFT) * 0x40;
367 c->tlbsize = c->tlbsizevtlb;
368 ftlb_page = MIPS_CONF4_VFTLBPAGESIZE;
369 /* fall through */
370 case MIPS_CONF4_MMUEXTDEF_FTLBSIZEEXT:
371 newcf4 = (config4 & ~ftlb_page) |
372 (page_size_ftlb(mmuextdef) <<
373 MIPS_CONF4_FTLBPAGESIZE_SHIFT);
374 write_c0_config4(newcf4);
375 back_to_back_c0_hazard();
376 config4 = read_c0_config4();
377 if (config4 != newcf4) {
378 pr_err("PAGE_SIZE 0x%lx is not supported by FTLB (config4=0x%x)\n",
379 PAGE_SIZE, config4);
380 /* Switch FTLB off */
381 set_ftlb_enable(c, 0);
382 break;
383 }
384 c->tlbsizeftlbsets = 1 <<
385 ((config4 & MIPS_CONF4_FTLBSETS) >>
386 MIPS_CONF4_FTLBSETS_SHIFT);
387 c->tlbsizeftlbways = ((config4 & MIPS_CONF4_FTLBWAYS) >>
388 MIPS_CONF4_FTLBWAYS_SHIFT) + 2;
389 c->tlbsize += c->tlbsizeftlbways * c->tlbsizeftlbsets;
390 break;
391 }
Leonid Yegoshin1745c1e2013-11-14 16:12:23 +0000392 }
393
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100394 c->kscratch_mask = (config4 >> 16) & 0xff;
395
396 return config4 & MIPS_CONF_M;
397}
398
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200399static inline unsigned int decode_config5(struct cpuinfo_mips *c)
400{
401 unsigned int config5;
402
403 config5 = read_c0_config5();
404 config5 &= ~MIPS_CONF5_UFR;
405 write_c0_config5(config5);
406
Markos Chandras49016742014-01-09 16:04:51 +0000407 if (config5 & MIPS_CONF5_EVA)
408 c->options |= MIPS_CPU_EVA;
409
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200410 return config5 & MIPS_CONF_M;
411}
412
Paul Gortmaker078a55f2013-06-18 13:38:59 +0000413static void decode_configs(struct cpuinfo_mips *c)
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100414{
415 int ok;
416
417 /* MIPS32 or MIPS64 compliant CPU. */
418 c->options = MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE | MIPS_CPU_COUNTER |
419 MIPS_CPU_DIVEC | MIPS_CPU_LLSC | MIPS_CPU_MCHECK;
420
421 c->scache.flags = MIPS_CACHE_NOT_PRESENT;
422
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000423 /* Enable FTLB if present */
424 set_ftlb_enable(c, 1);
425
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100426 ok = decode_config0(c); /* Read Config registers. */
Ralf Baechle70342282013-01-22 12:59:30 +0100427 BUG_ON(!ok); /* Arch spec violation! */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100428 if (ok)
429 ok = decode_config1(c);
430 if (ok)
431 ok = decode_config2(c);
432 if (ok)
433 ok = decode_config3(c);
434 if (ok)
435 ok = decode_config4(c);
Ralf Baechle8b8a76342013-09-19 11:15:49 +0200436 if (ok)
437 ok = decode_config5(c);
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100438
439 mips_probe_watch_registers(c);
440
Paul Burton0ee958e2014-01-15 10:31:53 +0000441#ifndef CONFIG_MIPS_CPS
Paul Burton30ee6152014-03-27 10:57:30 +0000442 if (cpu_has_mips_r2) {
David Daney45b585c2014-05-28 23:52:10 +0200443 c->core = get_ebase_cpunum();
Paul Burton30ee6152014-03-27 10:57:30 +0000444 if (cpu_has_mipsmt)
445 c->core >>= fls(core_nvpes()) - 1;
446 }
Paul Burton0ee958e2014-01-15 10:31:53 +0000447#endif
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100448}
449
Ralf Baechle02cf2112005-10-01 13:06:32 +0100450#define R4K_OPTS (MIPS_CPU_TLB | MIPS_CPU_4KEX | MIPS_CPU_4K_CACHE \
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451 | MIPS_CPU_COUNTER)
452
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000453static inline void cpu_probe_legacy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100455 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456 case PRID_IMP_R2000:
457 c->cputype = CPU_R2000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000458 __cpu_name[cpu] = "R2000";
Ralf Baechle02cf2112005-10-01 13:06:32 +0100459 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500460 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700461 if (__cpu_has_fpu())
462 c->options |= MIPS_CPU_FPU;
463 c->tlbsize = 64;
464 break;
465 case PRID_IMP_R3000:
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100466 if ((c->processor_id & PRID_REV_MASK) == PRID_REV_R3000A) {
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000467 if (cpu_has_confreg()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 c->cputype = CPU_R3081E;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000469 __cpu_name[cpu] = "R3081";
470 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471 c->cputype = CPU_R3000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000472 __cpu_name[cpu] = "R3000A";
473 }
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000474 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475 c->cputype = CPU_R3000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000476 __cpu_name[cpu] = "R3000";
477 }
Ralf Baechle02cf2112005-10-01 13:06:32 +0100478 c->options = MIPS_CPU_TLB | MIPS_CPU_3K_CACHE |
Steven J. Hill03751e72012-05-10 23:21:18 -0500479 MIPS_CPU_NOFPUEX;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480 if (__cpu_has_fpu())
481 c->options |= MIPS_CPU_FPU;
482 c->tlbsize = 64;
483 break;
484 case PRID_IMP_R4000:
485 if (read_c0_config() & CONF_SC) {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100486 if ((c->processor_id & PRID_REV_MASK) >=
487 PRID_REV_R4400) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 c->cputype = CPU_R4400PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000489 __cpu_name[cpu] = "R4400PC";
490 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491 c->cputype = CPU_R4000PC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000492 __cpu_name[cpu] = "R4000PC";
493 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100495 int cca = read_c0_config() & CONF_CM_CMASK;
496 int mc;
497
498 /*
499 * SC and MC versions can't be reliably told apart,
500 * but only the latter support coherent caching
501 * modes so assume the firmware has set the KSEG0
502 * coherency attribute reasonably (if uncached, we
503 * assume SC).
504 */
505 switch (cca) {
506 case CONF_CM_CACHABLE_CE:
507 case CONF_CM_CACHABLE_COW:
508 case CONF_CM_CACHABLE_CUW:
509 mc = 1;
510 break;
511 default:
512 mc = 0;
513 break;
514 }
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100515 if ((c->processor_id & PRID_REV_MASK) >=
516 PRID_REV_R4400) {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100517 c->cputype = mc ? CPU_R4400MC : CPU_R4400SC;
518 __cpu_name[cpu] = mc ? "R4400MC" : "R4400SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000519 } else {
Maciej W. Rozycki7f177a52013-09-23 14:01:53 +0100520 c->cputype = mc ? CPU_R4000MC : CPU_R4000SC;
521 __cpu_name[cpu] = mc ? "R4000MC" : "R4000SC";
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000522 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 }
524
Steven J. Hilla96102b2012-12-07 04:31:36 +0000525 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700526 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500527 MIPS_CPU_WATCH | MIPS_CPU_VCE |
528 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700529 c->tlbsize = 48;
530 break;
531 case PRID_IMP_VR41XX:
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900532 set_isa(c, MIPS_CPU_ISA_III);
533 c->options = R4K_OPTS;
534 c->tlbsize = 32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 switch (c->processor_id & 0xf0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 case PRID_REV_VR4111:
537 c->cputype = CPU_VR4111;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000538 __cpu_name[cpu] = "NEC VR4111";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700540 case PRID_REV_VR4121:
541 c->cputype = CPU_VR4121;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000542 __cpu_name[cpu] = "NEC VR4121";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700543 break;
544 case PRID_REV_VR4122:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000545 if ((c->processor_id & 0xf) < 0x3) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546 c->cputype = CPU_VR4122;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000547 __cpu_name[cpu] = "NEC VR4122";
548 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700549 c->cputype = CPU_VR4181A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000550 __cpu_name[cpu] = "NEC VR4181A";
551 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700552 break;
553 case PRID_REV_VR4130:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000554 if ((c->processor_id & 0xf) < 0x4) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700555 c->cputype = CPU_VR4131;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000556 __cpu_name[cpu] = "NEC VR4131";
557 } else {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700558 c->cputype = CPU_VR4133;
Yoichi Yuasa9f91e502013-02-21 15:38:19 +0900559 c->options |= MIPS_CPU_LLSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000560 __cpu_name[cpu] = "NEC VR4133";
561 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700562 break;
563 default:
564 printk(KERN_INFO "Unexpected CPU of NEC VR4100 series\n");
565 c->cputype = CPU_VR41XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000566 __cpu_name[cpu] = "NEC Vr41xx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567 break;
568 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700569 break;
570 case PRID_IMP_R4300:
571 c->cputype = CPU_R4300;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000572 __cpu_name[cpu] = "R4300";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000573 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500575 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700576 c->tlbsize = 32;
577 break;
578 case PRID_IMP_R4600:
579 c->cputype = CPU_R4600;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000580 __cpu_name[cpu] = "R4600";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000581 set_isa(c, MIPS_CPU_ISA_III);
Thiemo Seufer075e7502005-07-27 21:48:12 +0000582 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
583 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584 c->tlbsize = 48;
585 break;
586 #if 0
Steven J. Hill03751e72012-05-10 23:21:18 -0500587 case PRID_IMP_R4650:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700588 /*
589 * This processor doesn't have an MMU, so it's not
590 * "real easy" to run Linux on it. It is left purely
591 * for documentation. Commented out because it shares
592 * it's c0_prid id number with the TX3900.
593 */
Ralf Baechlea3dddd52006-03-11 08:18:41 +0000594 c->cputype = CPU_R4650;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000595 __cpu_name[cpu] = "R4650";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000596 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_LLSC;
Steven J. Hill03751e72012-05-10 23:21:18 -0500598 c->tlbsize = 48;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 break;
600 #endif
601 case PRID_IMP_TX39:
Ralf Baechle02cf2112005-10-01 13:06:32 +0100602 c->options = MIPS_CPU_TLB | MIPS_CPU_TX39_CACHE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700603
604 if ((c->processor_id & 0xf0) == (PRID_REV_TX3927 & 0xf0)) {
605 c->cputype = CPU_TX3927;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000606 __cpu_name[cpu] = "TX3927";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 c->tlbsize = 64;
608 } else {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100609 switch (c->processor_id & PRID_REV_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700610 case PRID_REV_TX3912:
611 c->cputype = CPU_TX3912;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000612 __cpu_name[cpu] = "TX3912";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700613 c->tlbsize = 32;
614 break;
615 case PRID_REV_TX3922:
616 c->cputype = CPU_TX3922;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000617 __cpu_name[cpu] = "TX3922";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618 c->tlbsize = 64;
619 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700620 }
621 }
622 break;
623 case PRID_IMP_R4700:
624 c->cputype = CPU_R4700;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000625 __cpu_name[cpu] = "R4700";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000626 set_isa(c, MIPS_CPU_ISA_III);
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_TX49:
632 c->cputype = CPU_TX49XX;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000633 __cpu_name[cpu] = "R49XX";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000634 set_isa(c, MIPS_CPU_ISA_III);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 c->options = R4K_OPTS | MIPS_CPU_LLSC;
636 if (!(c->processor_id & 0x08))
637 c->options |= MIPS_CPU_FPU | MIPS_CPU_32FPR;
638 c->tlbsize = 48;
639 break;
640 case PRID_IMP_R5000:
641 c->cputype = CPU_R5000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000642 __cpu_name[cpu] = "R5000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000643 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500645 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 c->tlbsize = 48;
647 break;
648 case PRID_IMP_R5432:
649 c->cputype = CPU_R5432;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000650 __cpu_name[cpu] = "R5432";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000651 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700652 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500653 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700654 c->tlbsize = 48;
655 break;
656 case PRID_IMP_R5500:
657 c->cputype = CPU_R5500;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000658 __cpu_name[cpu] = "R5500";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000659 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700660 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500661 MIPS_CPU_WATCH | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700662 c->tlbsize = 48;
663 break;
664 case PRID_IMP_NEVADA:
665 c->cputype = CPU_NEVADA;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000666 __cpu_name[cpu] = "Nevada";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000667 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700668 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500669 MIPS_CPU_DIVEC | MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700670 c->tlbsize = 48;
671 break;
672 case PRID_IMP_R6000:
673 c->cputype = CPU_R6000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000674 __cpu_name[cpu] = "R6000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000675 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500677 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 c->tlbsize = 32;
679 break;
680 case PRID_IMP_R6000A:
681 c->cputype = CPU_R6000A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000682 __cpu_name[cpu] = "R6000A";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000683 set_isa(c, MIPS_CPU_ISA_II);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700684 c->options = MIPS_CPU_TLB | MIPS_CPU_FPU |
Steven J. Hill03751e72012-05-10 23:21:18 -0500685 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700686 c->tlbsize = 32;
687 break;
688 case PRID_IMP_RM7000:
689 c->cputype = CPU_RM7000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000690 __cpu_name[cpu] = "RM7000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000691 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700692 c->options = R4K_OPTS | MIPS_CPU_FPU | MIPS_CPU_32FPR |
Steven J. Hill03751e72012-05-10 23:21:18 -0500693 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700694 /*
Ralf Baechle70342282013-01-22 12:59:30 +0100695 * Undocumented RM7000: Bit 29 in the info register of
Linus Torvalds1da177e2005-04-16 15:20:36 -0700696 * the RM7000 v2.0 indicates if the TLB has 48 or 64
697 * entries.
698 *
Ralf Baechle70342282013-01-22 12:59:30 +0100699 * 29 1 => 64 entry JTLB
700 * 0 => 48 entry JTLB
Linus Torvalds1da177e2005-04-16 15:20:36 -0700701 */
702 c->tlbsize = (read_c0_info() & (1 << 29)) ? 64 : 48;
703 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700704 case PRID_IMP_R8000:
705 c->cputype = CPU_R8000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000706 __cpu_name[cpu] = "RM8000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000707 set_isa(c, MIPS_CPU_ISA_IV);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700708 c->options = MIPS_CPU_TLB | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500709 MIPS_CPU_FPU | MIPS_CPU_32FPR |
710 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700711 c->tlbsize = 384; /* has weird TLB: 3-way x 128 */
712 break;
713 case PRID_IMP_R10000:
714 c->cputype = CPU_R10000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000715 __cpu_name[cpu] = "R10000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000716 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000717 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500718 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500720 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 c->tlbsize = 64;
722 break;
723 case PRID_IMP_R12000:
724 c->cputype = CPU_R12000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000725 __cpu_name[cpu] = "R12000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000726 set_isa(c, MIPS_CPU_ISA_IV);
Ralf Baechle8b366122005-11-22 17:53:59 +0000727 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500728 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500730 MIPS_CPU_LLSC;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731 c->tlbsize = 64;
732 break;
Kumba44d921b2006-05-16 22:23:59 -0400733 case PRID_IMP_R14000:
734 c->cputype = CPU_R14000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000735 __cpu_name[cpu] = "R14000";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000736 set_isa(c, MIPS_CPU_ISA_IV);
Kumba44d921b2006-05-16 22:23:59 -0400737 c->options = MIPS_CPU_TLB | MIPS_CPU_4K_CACHE | MIPS_CPU_4KEX |
Steven J. Hill03751e72012-05-10 23:21:18 -0500738 MIPS_CPU_FPU | MIPS_CPU_32FPR |
Kumba44d921b2006-05-16 22:23:59 -0400739 MIPS_CPU_COUNTER | MIPS_CPU_WATCH |
Steven J. Hill03751e72012-05-10 23:21:18 -0500740 MIPS_CPU_LLSC;
Kumba44d921b2006-05-16 22:23:59 -0400741 c->tlbsize = 64;
742 break;
Huacai Chen26859192014-02-16 16:01:18 +0800743 case PRID_IMP_LOONGSON_64: /* Loongson-2/3 */
Robert Millan5aac1e82011-04-16 11:29:29 -0700744 switch (c->processor_id & PRID_REV_MASK) {
745 case PRID_REV_LOONGSON2E:
Huacai Chenc579d312014-03-21 18:44:00 +0800746 c->cputype = CPU_LOONGSON2;
747 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700748 set_elf_platform(cpu, "loongson2e");
749 break;
750 case PRID_REV_LOONGSON2F:
Huacai Chenc579d312014-03-21 18:44:00 +0800751 c->cputype = CPU_LOONGSON2;
752 __cpu_name[cpu] = "ICT Loongson-2";
Robert Millan5aac1e82011-04-16 11:29:29 -0700753 set_elf_platform(cpu, "loongson2f");
754 break;
Huacai Chenc579d312014-03-21 18:44:00 +0800755 case PRID_REV_LOONGSON3A:
756 c->cputype = CPU_LOONGSON3;
757 __cpu_name[cpu] = "ICT Loongson-3";
758 set_elf_platform(cpu, "loongson3a");
759 break;
Huacai Chene7841be2014-06-26 11:41:30 +0800760 case PRID_REV_LOONGSON3B_R1:
761 case PRID_REV_LOONGSON3B_R2:
762 c->cputype = CPU_LOONGSON3;
763 __cpu_name[cpu] = "ICT Loongson-3";
764 set_elf_platform(cpu, "loongson3b");
765 break;
Robert Millan5aac1e82011-04-16 11:29:29 -0700766 }
767
Steven J. Hilla96102b2012-12-07 04:31:36 +0000768 set_isa(c, MIPS_CPU_ISA_III);
Fuxin Zhang2a21c732007-06-06 14:52:43 +0800769 c->options = R4K_OPTS |
770 MIPS_CPU_FPU | MIPS_CPU_LLSC |
771 MIPS_CPU_32FPR;
772 c->tlbsize = 64;
773 break;
Huacai Chen26859192014-02-16 16:01:18 +0800774 case PRID_IMP_LOONGSON_32: /* Loongson-1 */
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100775 decode_configs(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100777 c->cputype = CPU_LOONGSON1;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000778
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100779 switch (c->processor_id & PRID_REV_MASK) {
780 case PRID_REV_LOONGSON1B:
781 __cpu_name[cpu] = "Loongson 1B";
Ralf Baechleb4672d32005-12-08 14:04:24 +0000782 break;
Ralf Baechleb4672d32005-12-08 14:04:24 +0000783 }
Kelvin Cheung2fa36392012-06-20 20:05:32 +0100784
Ralf Baechle41943182005-05-05 16:45:59 +0000785 break;
Ralf Baechle41943182005-05-05 16:45:59 +0000786 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700787}
788
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000789static inline void cpu_probe_mips(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700790{
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100791 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 case PRID_IMP_4KC:
793 c->cputype = CPU_4KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000794 __cpu_name[cpu] = "MIPS 4Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700795 break;
796 case PRID_IMP_4KEC:
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000797 case PRID_IMP_4KECR2:
798 c->cputype = CPU_4KEC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000799 __cpu_name[cpu] = "MIPS 4KEc";
Ralf Baechle2b07bd02005-04-08 20:36:05 +0000800 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700801 case PRID_IMP_4KSC:
Ralf Baechle8afcb5d2005-10-04 15:01:26 +0100802 case PRID_IMP_4KSD:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700803 c->cputype = CPU_4KSC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000804 __cpu_name[cpu] = "MIPS 4KSc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700805 break;
806 case PRID_IMP_5KC:
807 c->cputype = CPU_5KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000808 __cpu_name[cpu] = "MIPS 5Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700809 break;
Leonid Yegoshin78d48032012-07-06 21:56:01 +0200810 case PRID_IMP_5KE:
811 c->cputype = CPU_5KE;
812 __cpu_name[cpu] = "MIPS 5KE";
813 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700814 case PRID_IMP_20KC:
815 c->cputype = CPU_20KC;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000816 __cpu_name[cpu] = "MIPS 20Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700817 break;
818 case PRID_IMP_24K:
819 c->cputype = CPU_24K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000820 __cpu_name[cpu] = "MIPS 24Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 break;
John Crispin42f3cae2013-01-11 22:44:10 +0100822 case PRID_IMP_24KE:
823 c->cputype = CPU_24K;
824 __cpu_name[cpu] = "MIPS 24KEc";
825 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826 case PRID_IMP_25KF:
827 c->cputype = CPU_25KF;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000828 __cpu_name[cpu] = "MIPS 25Kc";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700829 break;
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000830 case PRID_IMP_34K:
831 c->cputype = CPU_34K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000832 __cpu_name[cpu] = "MIPS 34Kc";
Ralf Baechlebbc7f222005-07-12 16:12:05 +0000833 break;
Chris Dearmanc6209532006-05-02 14:08:46 +0100834 case PRID_IMP_74K:
835 c->cputype = CPU_74K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000836 __cpu_name[cpu] = "MIPS 74Kc";
Chris Dearmanc6209532006-05-02 14:08:46 +0100837 break;
Steven J. Hill113c62d2012-07-06 23:56:00 +0200838 case PRID_IMP_M14KC:
839 c->cputype = CPU_M14KC;
840 __cpu_name[cpu] = "MIPS M14Kc";
841 break;
Steven J. Hillf8fa4812012-12-07 03:51:35 +0000842 case PRID_IMP_M14KEC:
843 c->cputype = CPU_M14KEC;
844 __cpu_name[cpu] = "MIPS M14KEc";
845 break;
Ralf Baechle39b8d522008-04-28 17:14:26 +0100846 case PRID_IMP_1004K:
847 c->cputype = CPU_1004K;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000848 __cpu_name[cpu] = "MIPS 1004Kc";
Ralf Baechle39b8d522008-04-28 17:14:26 +0100849 break;
Steven J. Hill006a8512012-06-26 04:11:03 +0000850 case PRID_IMP_1074K:
Steven J. Hill442e14a2014-01-17 15:03:50 -0600851 c->cputype = CPU_1074K;
Steven J. Hill006a8512012-06-26 04:11:03 +0000852 __cpu_name[cpu] = "MIPS 1074Kc";
853 break;
Leonid Yegoshinb5f065e2013-11-20 10:46:02 +0000854 case PRID_IMP_INTERAPTIV_UP:
855 c->cputype = CPU_INTERAPTIV;
856 __cpu_name[cpu] = "MIPS interAptiv";
857 break;
858 case PRID_IMP_INTERAPTIV_MP:
859 c->cputype = CPU_INTERAPTIV;
860 __cpu_name[cpu] = "MIPS interAptiv (multi)";
861 break;
Leonid Yegoshinb0d4d302013-11-14 16:12:28 +0000862 case PRID_IMP_PROAPTIV_UP:
863 c->cputype = CPU_PROAPTIV;
864 __cpu_name[cpu] = "MIPS proAptiv";
865 break;
866 case PRID_IMP_PROAPTIV_MP:
867 c->cputype = CPU_PROAPTIV;
868 __cpu_name[cpu] = "MIPS proAptiv (multi)";
869 break;
James Hogan829dcc02014-01-22 16:19:39 +0000870 case PRID_IMP_P5600:
871 c->cputype = CPU_P5600;
872 __cpu_name[cpu] = "MIPS P5600";
873 break;
Leonid Yegoshin9943ed92014-03-04 13:34:44 +0000874 case PRID_IMP_M5150:
875 c->cputype = CPU_M5150;
876 __cpu_name[cpu] = "MIPS M5150";
877 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 }
Chris Dearman0b6d4972007-09-13 12:32:02 +0100879
Leonid Yegoshin75b5b5e2013-11-14 16:12:31 +0000880 decode_configs(c);
881
Chris Dearman0b6d4972007-09-13 12:32:02 +0100882 spram_config();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700883}
884
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000885static inline void cpu_probe_alchemy(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886{
Ralf Baechle41943182005-05-05 16:45:59 +0000887 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100888 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889 case PRID_IMP_AU1_REV1:
890 case PRID_IMP_AU1_REV2:
Manuel Lauss270717a2009-03-25 17:49:28 +0100891 c->cputype = CPU_ALCHEMY;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700892 switch ((c->processor_id >> 24) & 0xff) {
893 case 0:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000894 __cpu_name[cpu] = "Au1000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895 break;
896 case 1:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000897 __cpu_name[cpu] = "Au1500";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700898 break;
899 case 2:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000900 __cpu_name[cpu] = "Au1100";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700901 break;
902 case 3:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000903 __cpu_name[cpu] = "Au1550";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904 break;
Pete Popove3ad1c22005-03-01 06:33:16 +0000905 case 4:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000906 __cpu_name[cpu] = "Au1200";
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100907 if ((c->processor_id & PRID_REV_MASK) == 2)
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000908 __cpu_name[cpu] = "Au1250";
Manuel Lauss237cfee2007-12-06 09:07:55 +0100909 break;
910 case 5:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000911 __cpu_name[cpu] = "Au1210";
Pete Popove3ad1c22005-03-01 06:33:16 +0000912 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700913 default:
Manuel Lauss270717a2009-03-25 17:49:28 +0100914 __cpu_name[cpu] = "Au1xxx";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915 break;
916 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700917 break;
918 }
919}
920
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000921static inline void cpu_probe_sibyte(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700922{
Ralf Baechle41943182005-05-05 16:45:59 +0000923 decode_configs(c);
Ralf Baechle02cf2112005-10-01 13:06:32 +0100924
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100925 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700926 case PRID_IMP_SB1:
927 c->cputype = CPU_SB1;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000928 __cpu_name[cpu] = "SiByte SB1";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700929 /* FPU in pass1 is known to have issues. */
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100930 if ((c->processor_id & PRID_REV_MASK) < 0x02)
Ralf Baechle010b8532006-01-29 18:42:08 +0000931 c->options &= ~(MIPS_CPU_FPU | MIPS_CPU_32FPR);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700932 break;
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700933 case PRID_IMP_SB1A:
934 c->cputype = CPU_SB1A;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000935 __cpu_name[cpu] = "SiByte SB1A";
Andrew Isaacson93ce2f522005-10-19 23:56:20 -0700936 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937 }
938}
939
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000940static inline void cpu_probe_sandcraft(struct cpuinfo_mips *c, unsigned int cpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941{
Ralf Baechle41943182005-05-05 16:45:59 +0000942 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100943 switch (c->processor_id & PRID_IMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944 case PRID_IMP_SR71000:
945 c->cputype = CPU_SR71000;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000946 __cpu_name[cpu] = "Sandcraft SR71000";
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947 c->scache.ways = 8;
948 c->tlbsize = 64;
949 break;
950 }
951}
952
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000953static inline void cpu_probe_nxp(struct cpuinfo_mips *c, unsigned int cpu)
Pete Popovbdf21b12005-07-14 17:47:57 +0000954{
955 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100956 switch (c->processor_id & PRID_IMP_MASK) {
Pete Popovbdf21b12005-07-14 17:47:57 +0000957 case PRID_IMP_PR4450:
958 c->cputype = CPU_PR4450;
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000959 __cpu_name[cpu] = "Philips PR4450";
Steven J. Hilla96102b2012-12-07 04:31:36 +0000960 set_isa(c, MIPS_CPU_ISA_M32R1);
Pete Popovbdf21b12005-07-14 17:47:57 +0000961 break;
Pete Popovbdf21b12005-07-14 17:47:57 +0000962 }
963}
964
Ralf Baechlecea7e2d2008-10-30 13:38:45 +0000965static inline void cpu_probe_broadcom(struct cpuinfo_mips *c, unsigned int cpu)
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200966{
967 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100968 switch (c->processor_id & PRID_IMP_MASK) {
Kevin Cernekee190fca32010-11-23 10:26:45 -0800969 case PRID_IMP_BMIPS32_REV4:
970 case PRID_IMP_BMIPS32_REV8:
Kevin Cernekee602977b2010-10-16 14:22:30 -0700971 c->cputype = CPU_BMIPS32;
972 __cpu_name[cpu] = "Broadcom BMIPS32";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700973 set_elf_platform(cpu, "bmips32");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200974 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700975 case PRID_IMP_BMIPS3300:
976 case PRID_IMP_BMIPS3300_ALT:
977 case PRID_IMP_BMIPS3300_BUG:
978 c->cputype = CPU_BMIPS3300;
979 __cpu_name[cpu] = "Broadcom BMIPS3300";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700980 set_elf_platform(cpu, "bmips3300");
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200981 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700982 case PRID_IMP_BMIPS43XX: {
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +0100983 int rev = c->processor_id & PRID_REV_MASK;
Kevin Cernekee602977b2010-10-16 14:22:30 -0700984
985 if (rev >= PRID_REV_BMIPS4380_LO &&
986 rev <= PRID_REV_BMIPS4380_HI) {
987 c->cputype = CPU_BMIPS4380;
988 __cpu_name[cpu] = "Broadcom BMIPS4380";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700989 set_elf_platform(cpu, "bmips4380");
Kevin Cernekee602977b2010-10-16 14:22:30 -0700990 } else {
991 c->cputype = CPU_BMIPS4350;
992 __cpu_name[cpu] = "Broadcom BMIPS4350";
Kevin Cernekee06785df2011-04-16 11:29:28 -0700993 set_elf_platform(cpu, "bmips4350");
Maxime Bizon0de663e2009-08-18 13:23:37 +0100994 }
995 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +0200996 }
Kevin Cernekee602977b2010-10-16 14:22:30 -0700997 case PRID_IMP_BMIPS5000:
998 c->cputype = CPU_BMIPS5000;
999 __cpu_name[cpu] = "Broadcom BMIPS5000";
Kevin Cernekee06785df2011-04-16 11:29:28 -07001000 set_elf_platform(cpu, "bmips5000");
Kevin Cernekee602977b2010-10-16 14:22:30 -07001001 c->options |= MIPS_CPU_ULRI;
1002 break;
Kevin Cernekee602977b2010-10-16 14:22:30 -07001003 }
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001004}
1005
David Daney0dd47812008-12-11 15:33:26 -08001006static inline void cpu_probe_cavium(struct cpuinfo_mips *c, unsigned int cpu)
1007{
1008 decode_configs(c);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001009 switch (c->processor_id & PRID_IMP_MASK) {
David Daney0dd47812008-12-11 15:33:26 -08001010 case PRID_IMP_CAVIUM_CN38XX:
1011 case PRID_IMP_CAVIUM_CN31XX:
1012 case PRID_IMP_CAVIUM_CN30XX:
David Daney6f329462010-02-10 15:12:48 -08001013 c->cputype = CPU_CAVIUM_OCTEON;
1014 __cpu_name[cpu] = "Cavium Octeon";
1015 goto platform;
David Daney0dd47812008-12-11 15:33:26 -08001016 case PRID_IMP_CAVIUM_CN58XX:
1017 case PRID_IMP_CAVIUM_CN56XX:
1018 case PRID_IMP_CAVIUM_CN50XX:
1019 case PRID_IMP_CAVIUM_CN52XX:
David Daney6f329462010-02-10 15:12:48 -08001020 c->cputype = CPU_CAVIUM_OCTEON_PLUS;
1021 __cpu_name[cpu] = "Cavium Octeon+";
1022platform:
Robert Millanc094c992011-04-18 11:37:55 -07001023 set_elf_platform(cpu, "octeon");
David Daney0dd47812008-12-11 15:33:26 -08001024 break;
David Daneya1431b62011-09-24 02:29:54 +02001025 case PRID_IMP_CAVIUM_CN61XX:
David Daney0e56b382010-10-07 16:03:45 -07001026 case PRID_IMP_CAVIUM_CN63XX:
David Daneya1431b62011-09-24 02:29:54 +02001027 case PRID_IMP_CAVIUM_CN66XX:
1028 case PRID_IMP_CAVIUM_CN68XX:
David Daneyaf04bb82013-07-29 15:07:01 -07001029 case PRID_IMP_CAVIUM_CNF71XX:
David Daney0e56b382010-10-07 16:03:45 -07001030 c->cputype = CPU_CAVIUM_OCTEON2;
1031 __cpu_name[cpu] = "Cavium Octeon II";
Robert Millanc094c992011-04-18 11:37:55 -07001032 set_elf_platform(cpu, "octeon2");
David Daney0e56b382010-10-07 16:03:45 -07001033 break;
David Daneyaf04bb82013-07-29 15:07:01 -07001034 case PRID_IMP_CAVIUM_CN70XX:
1035 case PRID_IMP_CAVIUM_CN78XX:
1036 c->cputype = CPU_CAVIUM_OCTEON3;
1037 __cpu_name[cpu] = "Cavium Octeon III";
1038 set_elf_platform(cpu, "octeon3");
1039 break;
David Daney0dd47812008-12-11 15:33:26 -08001040 default:
1041 printk(KERN_INFO "Unknown Octeon chip!\n");
1042 c->cputype = CPU_UNKNOWN;
1043 break;
1044 }
1045}
1046
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001047static inline void cpu_probe_ingenic(struct cpuinfo_mips *c, unsigned int cpu)
1048{
1049 decode_configs(c);
1050 /* JZRISC does not implement the CP0 counter. */
1051 c->options &= ~MIPS_CPU_COUNTER;
Maciej W. Rozycki06947aa2014-04-06 21:31:29 +01001052 BUG_ON(!__builtin_constant_p(cpu_has_counter) || cpu_has_counter);
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001053 switch (c->processor_id & PRID_IMP_MASK) {
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001054 case PRID_IMP_JZRISC:
1055 c->cputype = CPU_JZRISC;
1056 __cpu_name[cpu] = "Ingenic JZRISC";
1057 break;
1058 default:
1059 panic("Unknown Ingenic Processor ID!");
1060 break;
1061 }
1062}
1063
Jayachandran Ca7117c62011-05-11 12:04:58 +05301064static inline void cpu_probe_netlogic(struct cpuinfo_mips *c, int cpu)
1065{
1066 decode_configs(c);
1067
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001068 if ((c->processor_id & PRID_IMP_MASK) == PRID_IMP_NETLOGIC_AU13XX) {
Manuel Lauss809f36c2011-11-01 20:03:30 +01001069 c->cputype = CPU_ALCHEMY;
1070 __cpu_name[cpu] = "Au1300";
1071 /* following stuff is not for Alchemy */
1072 return;
1073 }
1074
Ralf Baechle70342282013-01-22 12:59:30 +01001075 c->options = (MIPS_CPU_TLB |
1076 MIPS_CPU_4KEX |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301077 MIPS_CPU_COUNTER |
Ralf Baechle70342282013-01-22 12:59:30 +01001078 MIPS_CPU_DIVEC |
1079 MIPS_CPU_WATCH |
1080 MIPS_CPU_EJTAG |
Jayachandran Ca7117c62011-05-11 12:04:58 +05301081 MIPS_CPU_LLSC);
1082
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001083 switch (c->processor_id & PRID_IMP_MASK) {
Jayachandran C4ca86a22013-08-11 14:43:54 +05301084 case PRID_IMP_NETLOGIC_XLP2XX:
Jayachandran C8907c552013-12-21 16:52:20 +05301085 case PRID_IMP_NETLOGIC_XLP9XX:
Yonghong Song1c983982014-04-29 20:07:53 +05301086 case PRID_IMP_NETLOGIC_XLP5XX:
Jayachandran C4ca86a22013-08-11 14:43:54 +05301087 c->cputype = CPU_XLP;
1088 __cpu_name[cpu] = "Broadcom XLPII";
1089 break;
1090
Jayachandran C2aa54b22011-11-16 00:21:29 +00001091 case PRID_IMP_NETLOGIC_XLP8XX:
1092 case PRID_IMP_NETLOGIC_XLP3XX:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001093 c->cputype = CPU_XLP;
1094 __cpu_name[cpu] = "Netlogic XLP";
1095 break;
1096
Jayachandran Ca7117c62011-05-11 12:04:58 +05301097 case PRID_IMP_NETLOGIC_XLR732:
1098 case PRID_IMP_NETLOGIC_XLR716:
1099 case PRID_IMP_NETLOGIC_XLR532:
1100 case PRID_IMP_NETLOGIC_XLR308:
1101 case PRID_IMP_NETLOGIC_XLR532C:
1102 case PRID_IMP_NETLOGIC_XLR516C:
1103 case PRID_IMP_NETLOGIC_XLR508C:
1104 case PRID_IMP_NETLOGIC_XLR308C:
1105 c->cputype = CPU_XLR;
1106 __cpu_name[cpu] = "Netlogic XLR";
1107 break;
1108
1109 case PRID_IMP_NETLOGIC_XLS608:
1110 case PRID_IMP_NETLOGIC_XLS408:
1111 case PRID_IMP_NETLOGIC_XLS404:
1112 case PRID_IMP_NETLOGIC_XLS208:
1113 case PRID_IMP_NETLOGIC_XLS204:
1114 case PRID_IMP_NETLOGIC_XLS108:
1115 case PRID_IMP_NETLOGIC_XLS104:
1116 case PRID_IMP_NETLOGIC_XLS616B:
1117 case PRID_IMP_NETLOGIC_XLS608B:
1118 case PRID_IMP_NETLOGIC_XLS416B:
1119 case PRID_IMP_NETLOGIC_XLS412B:
1120 case PRID_IMP_NETLOGIC_XLS408B:
1121 case PRID_IMP_NETLOGIC_XLS404B:
1122 c->cputype = CPU_XLR;
1123 __cpu_name[cpu] = "Netlogic XLS";
1124 break;
1125
1126 default:
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001127 pr_info("Unknown Netlogic chip id [%02x]!\n",
Jayachandran Ca7117c62011-05-11 12:04:58 +05301128 c->processor_id);
1129 c->cputype = CPU_XLR;
1130 break;
1131 }
1132
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001133 if (c->cputype == CPU_XLP) {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001134 set_isa(c, MIPS_CPU_ISA_M64R2);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001135 c->options |= (MIPS_CPU_FPU | MIPS_CPU_ULRI | MIPS_CPU_MCHECK);
1136 /* This will be updated again after all threads are woken up */
1137 c->tlbsize = ((read_c0_config6() >> 16) & 0xffff) + 1;
1138 } else {
Steven J. Hilla96102b2012-12-07 04:31:36 +00001139 set_isa(c, MIPS_CPU_ISA_M64R1);
Jayachandran Ca3d4fb22011-11-16 00:21:20 +00001140 c->tlbsize = ((read_c0_config1() >> 25) & 0x3f) + 1;
1141 }
Jayachandran C7777b932013-06-11 14:41:35 +00001142 c->kscratch_mask = 0xf;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301143}
1144
David Daney949e51b2010-10-14 11:32:33 -07001145#ifdef CONFIG_64BIT
1146/* For use by uaccess.h */
1147u64 __ua_limit;
1148EXPORT_SYMBOL(__ua_limit);
1149#endif
1150
Ralf Baechle9966db252007-10-11 23:46:17 +01001151const char *__cpu_name[NR_CPUS];
David Daney874fd3b2010-01-28 16:52:12 -08001152const char *__elf_platform;
Ralf Baechle9966db252007-10-11 23:46:17 +01001153
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001154void cpu_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155{
1156 struct cpuinfo_mips *c = &current_cpu_data;
Ralf Baechle9966db252007-10-11 23:46:17 +01001157 unsigned int cpu = smp_processor_id();
Linus Torvalds1da177e2005-04-16 15:20:36 -07001158
Ralf Baechle70342282013-01-22 12:59:30 +01001159 c->processor_id = PRID_IMP_UNKNOWN;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001160 c->fpu_id = FPIR_IMP_NONE;
1161 c->cputype = CPU_UNKNOWN;
1162
1163 c->processor_id = read_c0_prid();
Maciej W. Rozycki8ff374b2013-09-17 16:58:10 +01001164 switch (c->processor_id & PRID_COMP_MASK) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001165 case PRID_COMP_LEGACY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001166 cpu_probe_legacy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001167 break;
1168 case PRID_COMP_MIPS:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001169 cpu_probe_mips(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001170 break;
1171 case PRID_COMP_ALCHEMY:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001172 cpu_probe_alchemy(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001173 break;
1174 case PRID_COMP_SIBYTE:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001175 cpu_probe_sibyte(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001176 break;
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001177 case PRID_COMP_BROADCOM:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001178 cpu_probe_broadcom(c, cpu);
Aurelien Jarno1c0c13e2007-09-25 15:40:12 +02001179 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180 case PRID_COMP_SANDCRAFT:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001181 cpu_probe_sandcraft(c, cpu);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001182 break;
Daniel Lairda92b0582008-03-06 09:07:18 +00001183 case PRID_COMP_NXP:
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001184 cpu_probe_nxp(c, cpu);
Ralf Baechlea3dddd52006-03-11 08:18:41 +00001185 break;
David Daney0dd47812008-12-11 15:33:26 -08001186 case PRID_COMP_CAVIUM:
1187 cpu_probe_cavium(c, cpu);
1188 break;
Lars-Peter Clausen83ccf692010-07-17 11:07:51 +00001189 case PRID_COMP_INGENIC:
1190 cpu_probe_ingenic(c, cpu);
1191 break;
Jayachandran Ca7117c62011-05-11 12:04:58 +05301192 case PRID_COMP_NETLOGIC:
1193 cpu_probe_netlogic(c, cpu);
1194 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001195 }
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001196
Ralf Baechlecea7e2d2008-10-30 13:38:45 +00001197 BUG_ON(!__cpu_name[cpu]);
1198 BUG_ON(c->cputype == CPU_UNKNOWN);
1199
Franck Bui-Huudec8b1c2007-10-08 16:11:51 +02001200 /*
1201 * Platform code can force the cpu type to optimize code
1202 * generation. In that case be sure the cpu type is correctly
1203 * manually setup otherwise it could trigger some nasty bugs.
1204 */
1205 BUG_ON(current_cpu_type() != c->cputype);
1206
Kevin Cernekee0103d232010-05-02 14:43:52 -07001207 if (mips_fpu_disabled)
1208 c->options &= ~MIPS_CPU_FPU;
1209
1210 if (mips_dsp_disabled)
Steven J. Hillee80f7c72012-08-03 10:26:04 -05001211 c->ases &= ~(MIPS_ASE_DSP | MIPS_ASE_DSP2P);
Kevin Cernekee0103d232010-05-02 14:43:52 -07001212
Markos Chandras3d528b32014-07-14 12:46:13 +01001213 if (mips_htw_disabled) {
1214 c->options &= ~MIPS_CPU_HTW;
1215 write_c0_pwctl(read_c0_pwctl() &
1216 ~(1 << MIPS_PWCTL_PWEN_SHIFT));
1217 }
1218
Ralf Baechle41943182005-05-05 16:45:59 +00001219 if (c->options & MIPS_CPU_FPU) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001220 c->fpu_id = cpu_get_fpu_id();
Ralf Baechle41943182005-05-05 16:45:59 +00001221
Deng-Cheng Zhuadb37892013-04-01 18:14:28 +00001222 if (c->isa_level & (MIPS_CPU_ISA_M32R1 | MIPS_CPU_ISA_M32R2 |
1223 MIPS_CPU_ISA_M64R1 | MIPS_CPU_ISA_M64R2)) {
Ralf Baechle41943182005-05-05 16:45:59 +00001224 if (c->fpu_id & MIPS_FPIR_3D)
1225 c->ases |= MIPS_ASE_MIPS3D;
1226 }
1227 }
Ralf Baechle9966db252007-10-11 23:46:17 +01001228
Al Cooperda4b62c2012-07-13 16:44:51 -04001229 if (cpu_has_mips_r2) {
Ralf Baechlef6771db2007-11-08 18:02:29 +00001230 c->srsets = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
Al Cooperda4b62c2012-07-13 16:44:51 -04001231 /* R2 has Performance Counter Interrupt indicator */
1232 c->options |= MIPS_CPU_PCI;
1233 }
Ralf Baechlef6771db2007-11-08 18:02:29 +00001234 else
1235 c->srsets = 1;
Guenter Roeck91dfc422010-02-02 08:52:20 -08001236
Paul Burtona8ad1362014-01-28 14:28:43 +00001237 if (cpu_has_msa) {
Paul Burtona5e9a692014-01-27 15:23:10 +00001238 c->msa_id = cpu_get_msa_id();
Paul Burtona8ad1362014-01-28 14:28:43 +00001239 WARN(c->msa_id & MSA_IR_WRPF,
1240 "Vector register partitioning unimplemented!");
1241 }
Paul Burtona5e9a692014-01-27 15:23:10 +00001242
Guenter Roeck91dfc422010-02-02 08:52:20 -08001243 cpu_probe_vmbits(c);
David Daney949e51b2010-10-14 11:32:33 -07001244
1245#ifdef CONFIG_64BIT
1246 if (cpu == 0)
1247 __ua_limit = ~((1ull << cpu_vmbits) - 1);
1248#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249}
1250
Paul Gortmaker078a55f2013-06-18 13:38:59 +00001251void cpu_report(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001252{
1253 struct cpuinfo_mips *c = &current_cpu_data;
1254
Leonid Yegoshind9f897c2013-10-07 10:43:32 +01001255 pr_info("CPU%d revision is: %08x (%s)\n",
1256 smp_processor_id(), c->processor_id, cpu_name_string());
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257 if (c->options & MIPS_CPU_FPU)
Ralf Baechle9966db252007-10-11 23:46:17 +01001258 printk(KERN_INFO "FPU revision is: %08x\n", c->fpu_id);
Paul Burtona5e9a692014-01-27 15:23:10 +00001259 if (cpu_has_msa)
1260 pr_info("MSA revision is: %08x\n", c->msa_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001261}