1 // SPDX-License-Identifier: GPL-2.0
2 /* cpu.c: Dinky routines to look for the kind of Sparc cpu
8 #include <linux/seq_file.h>
9 #include <linux/kernel.h>
10 #include <linux/export.h>
11 #include <linux/init.h>
12 #include <linux/smp.h>
13 #include <linux/threads.h>
14 #include <linux/pgtable.h>
16 #include <asm/spitfire.h>
17 #include <asm/oplib.h>
18 #include <asm/setup.h>
23 #include <asm/cpudata.h>
28 DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 };
29 EXPORT_PER_CPU_SYMBOL(__cpu_data);
32 unsigned int fsr_storage;
48 struct manufacturer_info {
50 struct cpu_info cpu_info[NOCPU];
51 struct fpu_info fpu_info[NOFPU];
54 #define CPU(ver, _name) \
55 { .psr_vers = ver, .name = _name }
57 #define CPU_PMU(ver, _name, _pmu_name) \
58 { .psr_vers = ver, .name = _name, .pmu_name = _pmu_name }
60 #define FPU(ver, _name) \
61 { .fp_vers = ver, .name = _name }
63 static const struct manufacturer_info __initconst manufacturer_info[] = {
66 /* Sun4/100, 4/200, SLC */
68 CPU(0, "Fujitsu MB86900/1A or LSI L64831 SparcKIT-40"),
69 /* borned STP1012PGA */
70 CPU(4, "Fujitsu MB86904"),
71 CPU(5, "Fujitsu TurboSparc MB86907"),
75 FPU(0, "Fujitsu MB86910 or Weitek WTL1164/5"),
76 FPU(1, "Fujitsu MB86911 or Weitek WTL1164/5 or LSI L64831"),
77 FPU(2, "LSI Logic L64802 or Texas Instruments ACT8847"),
78 /* SparcStation SLC, SparcStation1 */
79 FPU(3, "Weitek WTL3170/2"),
81 FPU(4, "Lsi Logic/Meiko L64804 or compatible"),
87 /* SparcStation2, SparcServer 490 & 690 */
88 CPU(0, "LSI Logic Corporation - L64811"),
90 CPU(1, "Cypress/ROSS CY7C601"),
91 /* Embedded controller */
92 CPU(3, "Cypress/ROSS CY7C611"),
93 /* Ross Technologies HyperSparc */
94 CPU(0xf, "ROSS HyperSparc RT620"),
95 CPU(0xe, "ROSS HyperSparc RT625 or RT626"),
99 FPU(0, "ROSS HyperSparc combined IU/FPU"),
100 FPU(1, "Lsi Logic L64814"),
101 FPU(2, "Texas Instruments TMS390-C602A"),
102 FPU(3, "Cypress CY7C602 FPU"),
108 /* ECL Implementation, CRAY S-MP Supercomputer... AIEEE! */
109 /* Someone please write the code to support this beast! ;) */
110 CPU(0, "Bipolar Integrated Technology - B5010"),
119 CPU(0, "LSI Logic Corporation - unknown-type"),
128 CPU(0, "Texas Instruments, Inc. - SuperSparc-(II)"),
129 /* SparcClassic -- borned STP1010TAB-50*/
130 CPU(1, "Texas Instruments, Inc. - MicroSparc"),
131 CPU(2, "Texas Instruments, Inc. - MicroSparc II"),
132 CPU(3, "Texas Instruments, Inc. - SuperSparc 51"),
133 CPU(4, "Texas Instruments, Inc. - SuperSparc 61"),
134 CPU(5, "Texas Instruments, Inc. - unknown"),
138 /* SuperSparc 50 module */
139 FPU(0, "SuperSparc on-chip FPU"),
141 FPU(4, "TI MicroSparc on chip FPU"),
147 CPU(0, "Matsushita - MN10501"),
151 FPU(0, "Matsushita MN10501"),
157 CPU(0, "Philips Corporation - unknown"),
166 CPU(0, "Harvest VLSI Design Center, Inc. - unknown"),
175 CPU(0, "Systems and Processes Engineering Corporation (SPEC)"),
184 /* Gallium arsenide 200MHz, BOOOOGOOOOMIPS!!! */
185 CPU(0, "Fujitsu or Weitek Power-UP"),
186 CPU(1, "Fujitsu or Weitek Power-UP"),
187 CPU(2, "Fujitsu or Weitek Power-UP"),
188 CPU(3, "Fujitsu or Weitek Power-UP"),
192 FPU(3, "Fujitsu or Weitek on-chip FPU"),
196 PSR_IMPL_LEON, /* Aeroflex Gaisler */
203 FPU(3, "GRFPU-Lite"),
209 CPU_PMU(0x10, "TI UltraSparc I (SpitFire)", "ultra12"),
210 CPU_PMU(0x11, "TI UltraSparc II (BlackBird)", "ultra12"),
211 CPU_PMU(0x12, "TI UltraSparc IIi (Sabre)", "ultra12"),
212 CPU_PMU(0x13, "TI UltraSparc IIe (Hummingbird)", "ultra12"),
216 FPU(0x10, "UltraSparc I integrated FPU"),
217 FPU(0x11, "UltraSparc II integrated FPU"),
218 FPU(0x12, "UltraSparc IIi integrated FPU"),
219 FPU(0x13, "UltraSparc IIe integrated FPU"),
225 CPU_PMU(0x10, "TI UltraSparc I (SpitFire)", "ultra12"),
229 FPU(0x10, "UltraSparc I integrated FPU"),
235 CPU_PMU(0x14, "TI UltraSparc III (Cheetah)", "ultra3"),
236 CPU_PMU(0x15, "TI UltraSparc III+ (Cheetah+)", "ultra3+"),
237 CPU_PMU(0x16, "TI UltraSparc IIIi (Jalapeno)", "ultra3i"),
238 CPU_PMU(0x18, "TI UltraSparc IV (Jaguar)", "ultra3+"),
239 CPU_PMU(0x19, "TI UltraSparc IV+ (Panther)", "ultra4+"),
240 CPU_PMU(0x22, "TI UltraSparc IIIi+ (Serrano)", "ultra3i"),
244 FPU(0x14, "UltraSparc III integrated FPU"),
245 FPU(0x15, "UltraSparc III+ integrated FPU"),
246 FPU(0x16, "UltraSparc IIIi integrated FPU"),
247 FPU(0x18, "UltraSparc IV integrated FPU"),
248 FPU(0x19, "UltraSparc IV+ integrated FPU"),
249 FPU(0x22, "UltraSparc IIIi+ integrated FPU"),
254 /* In order to get the fpu type correct, you need to take the IDPROM's
255 * machine type value into consideration too. I will fix this.
258 static const char *sparc_cpu_type;
259 static const char *sparc_fpu_type;
260 const char *sparc_pmu_type;
263 static void __init set_cpu_and_fpu(int psr_impl, int psr_vers, int fpu_vers)
265 const struct manufacturer_info *manuf;
268 sparc_cpu_type = NULL;
269 sparc_fpu_type = NULL;
270 sparc_pmu_type = NULL;
273 for (i = 0; i < ARRAY_SIZE(manufacturer_info); i++)
275 if (psr_impl == manufacturer_info[i].psr_impl) {
276 manuf = &manufacturer_info[i];
282 const struct cpu_info *cpu;
283 const struct fpu_info *fpu;
285 cpu = &manuf->cpu_info[0];
286 while (cpu->psr_vers != -1)
288 if (cpu->psr_vers == psr_vers) {
289 sparc_cpu_type = cpu->name;
290 sparc_pmu_type = cpu->pmu_name;
291 sparc_fpu_type = "No FPU";
296 fpu = &manuf->fpu_info[0];
297 while (fpu->fp_vers != -1)
299 if (fpu->fp_vers == fpu_vers) {
300 sparc_fpu_type = fpu->name;
306 if (sparc_cpu_type == NULL)
308 printk(KERN_ERR "CPU: Unknown chip, impl[0x%x] vers[0x%x]\n",
310 sparc_cpu_type = "Unknown CPU";
312 if (sparc_fpu_type == NULL)
314 printk(KERN_ERR "FPU: Unknown chip, impl[0x%x] vers[0x%x]\n",
316 sparc_fpu_type = "Unknown FPU";
318 if (sparc_pmu_type == NULL)
319 sparc_pmu_type = "Unknown PMU";
322 #ifdef CONFIG_SPARC32
323 static int show_cpuinfo(struct seq_file *m, void *__unused)
328 "promlib\t\t: Version %d Revision %d\n"
331 "ncpus probed\t: %d\n"
332 "ncpus active\t: %d\n"
334 "CPU0Bogo\t: %lu.%02lu\n"
335 "CPU0ClkTck\t: %ld\n"
342 romvec->pv_printrev >> 16,
343 romvec->pv_printrev & 0xffff,
348 , cpu_data(0).udelay_val/(500000/HZ),
349 (cpu_data(0).udelay_val/(5000/HZ)) % 100,
350 cpu_data(0).clock_tick
363 #endif /* CONFIG_SPARC32 */
365 #ifdef CONFIG_SPARC64
366 unsigned int dcache_parity_tl1_occurred;
367 unsigned int icache_parity_tl1_occurred;
370 static int show_cpuinfo(struct seq_file *m, void *__unused)
378 "ncpus probed\t: %d\n"
379 "ncpus active\t: %d\n"
380 "D$ parity tl1\t: %u\n"
381 "I$ parity tl1\t: %u\n"
383 "Cpu0ClkTck\t: %016lx\n"
390 ((tlb_type == hypervisor) ?
395 dcache_parity_tl1_occurred,
396 icache_parity_tl1_occurred
398 , cpu_data(0).clock_tick
411 #endif /* CONFIG_SPARC64 */
413 static void *c_start(struct seq_file *m, loff_t *pos)
415 /* The pointer we are returning is arbitrary,
416 * it just has to be non-NULL and not IS_ERR
417 * in the success case.
419 return *pos == 0 ? &c_start : NULL;
422 static void *c_next(struct seq_file *m, void *v, loff_t *pos)
425 return c_start(m, pos);
428 static void c_stop(struct seq_file *m, void *v)
432 const struct seq_operations cpuinfo_op = {
436 .show = show_cpuinfo,
439 #ifdef CONFIG_SPARC32
440 static int __init cpu_type_probe(void)
442 int psr_impl, psr_vers, fpu_vers;
445 psr_impl = ((get_psr() >> PSR_IMPL_SHIFT) & PSR_IMPL_SHIFTED_MASK);
446 psr_vers = ((get_psr() >> PSR_VERS_SHIFT) & PSR_VERS_SHIFTED_MASK);
449 put_psr(psr | PSR_EF);
451 if (psr_impl == PSR_IMPL_LEON)
452 fpu_vers = get_psr() & PSR_EF ? ((get_fsr() >> 17) & 0x7) : 7;
454 fpu_vers = ((get_fsr() >> 17) & 0x7);
458 set_cpu_and_fpu(psr_impl, psr_vers, fpu_vers);
462 #endif /* CONFIG_SPARC32 */
464 #ifdef CONFIG_SPARC64
465 static void __init sun4v_cpu_probe(void)
467 switch (sun4v_chip_type) {
468 case SUN4V_CHIP_NIAGARA1:
469 sparc_cpu_type = "UltraSparc T1 (Niagara)";
470 sparc_fpu_type = "UltraSparc T1 integrated FPU";
471 sparc_pmu_type = "niagara";
474 case SUN4V_CHIP_NIAGARA2:
475 sparc_cpu_type = "UltraSparc T2 (Niagara2)";
476 sparc_fpu_type = "UltraSparc T2 integrated FPU";
477 sparc_pmu_type = "niagara2";
480 case SUN4V_CHIP_NIAGARA3:
481 sparc_cpu_type = "UltraSparc T3 (Niagara3)";
482 sparc_fpu_type = "UltraSparc T3 integrated FPU";
483 sparc_pmu_type = "niagara3";
486 case SUN4V_CHIP_NIAGARA4:
487 sparc_cpu_type = "UltraSparc T4 (Niagara4)";
488 sparc_fpu_type = "UltraSparc T4 integrated FPU";
489 sparc_pmu_type = "niagara4";
492 case SUN4V_CHIP_NIAGARA5:
493 sparc_cpu_type = "UltraSparc T5 (Niagara5)";
494 sparc_fpu_type = "UltraSparc T5 integrated FPU";
495 sparc_pmu_type = "niagara5";
498 case SUN4V_CHIP_SPARC_M6:
499 sparc_cpu_type = "SPARC-M6";
500 sparc_fpu_type = "SPARC-M6 integrated FPU";
501 sparc_pmu_type = "sparc-m6";
504 case SUN4V_CHIP_SPARC_M7:
505 sparc_cpu_type = "SPARC-M7";
506 sparc_fpu_type = "SPARC-M7 integrated FPU";
507 sparc_pmu_type = "sparc-m7";
510 case SUN4V_CHIP_SPARC_M8:
511 sparc_cpu_type = "SPARC-M8";
512 sparc_fpu_type = "SPARC-M8 integrated FPU";
513 sparc_pmu_type = "sparc-m8";
516 case SUN4V_CHIP_SPARC_SN:
517 sparc_cpu_type = "SPARC-SN";
518 sparc_fpu_type = "SPARC-SN integrated FPU";
519 sparc_pmu_type = "sparc-sn";
522 case SUN4V_CHIP_SPARC64X:
523 sparc_cpu_type = "SPARC64-X";
524 sparc_fpu_type = "SPARC64-X integrated FPU";
525 sparc_pmu_type = "sparc64-x";
529 printk(KERN_WARNING "CPU: Unknown sun4v cpu type [%s]\n",
530 prom_cpu_compatible);
531 sparc_cpu_type = "Unknown SUN4V CPU";
532 sparc_fpu_type = "Unknown SUN4V FPU";
533 sparc_pmu_type = "Unknown SUN4V PMU";
538 static int __init cpu_type_probe(void)
540 if (tlb_type == hypervisor) {
546 __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
548 manuf = ((ver >> 48) & 0xffff);
549 impl = ((ver >> 32) & 0xffff);
550 set_cpu_and_fpu(manuf, impl, impl);
554 #endif /* CONFIG_SPARC64 */
556 early_initcall(cpu_type_probe);