File: /usr/src/linux/arch/sparc64/kernel/cpu.c
1 /* cpu.c: Dinky routines to look for the kind of Sparc cpu
2 * we are on.
3 *
4 * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
5 */
6
7 #include <linux/config.h>
8 #include <linux/kernel.h>
9 #include <linux/init.h>
10 #include <linux/sched.h>
11 #include <linux/smp.h>
12 #include <asm/asi.h>
13 #include <asm/system.h>
14 #include <asm/fpumacro.h>
15
16 struct cpu_iu_info {
17 short manuf;
18 short impl;
19 char* cpu_name; /* should be enough I hope... */
20 };
21
22 struct cpu_fp_info {
23 short manuf;
24 short impl;
25 char fpu_vers;
26 char* fp_name;
27 };
28
29 /* In order to get the fpu type correct, you need to take the IDPROM's
30 * machine type value into consideration too. I will fix this.
31 */
32 struct cpu_fp_info linux_sparc_fpu[] = {
33 { 0x17, 0x10, 0, "UltraSparc I integrated FPU"},
34 { 0x22, 0x10, 0, "UltraSparc II integrated FPU"},
35 { 0x17, 0x11, 0, "UltraSparc II integrated FPU"},
36 { 0x17, 0x12, 0, "UltraSparc IIi integrated FPU"},
37 { 0x17, 0x13, 0, "UltraSparc IIe integrated FPU"},
38 { 0x3e, 0x14, 0, "UltraSparc III integrated FPU"},
39 };
40
41 #define NSPARCFPU (sizeof(linux_sparc_fpu)/sizeof(struct cpu_fp_info))
42
43 struct cpu_iu_info linux_sparc_chips[] = {
44 { 0x17, 0x10, "TI UltraSparc I (SpitFire)"},
45 { 0x22, 0x10, "TI UltraSparc II (BlackBird)"},
46 { 0x17, 0x11, "TI UltraSparc II (BlackBird)"},
47 { 0x17, 0x12, "TI UltraSparc IIi"},
48 { 0x17, 0x13, "TI UltraSparc IIe"},
49 { 0x3e, 0x14, "TI UltraSparc III (Cheetah)"},
50 };
51
52 #define NSPARCCHIPS (sizeof(linux_sparc_chips)/sizeof(struct cpu_iu_info))
53
54 #ifdef CONFIG_SMP
55 char *sparc_cpu_type[64] = { "cpu-oops", "cpu-oops1", "cpu-oops2", "cpu-oops3" };
56 char *sparc_fpu_type[64] = { "fpu-oops", "fpu-oops1", "fpu-oops2", "fpu-oops3" };
57 #else
58 char *sparc_cpu_type[64] = { "cpu-oops", };
59 char *sparc_fpu_type[64] = { "fpu-oops", };
60 #endif
61
62 unsigned int fsr_storage;
63
64 void __init cpu_probe(void)
65 {
66 int manuf, impl;
67 unsigned i, cpuid;
68 long ver, fpu_vers;
69 long fprs;
70
71 cpuid = hard_smp_processor_id();
72
73 fprs = fprs_read ();
74 fprs_write (FPRS_FEF);
75 __asm__ __volatile__ ("rdpr %%ver, %0; stx %%fsr, [%1]" : "=&r" (ver) : "r" (&fpu_vers));
76 fprs_write (fprs);
77
78 manuf = ((ver >> 48)&0xffff);
79 impl = ((ver >> 32)&0xffff);
80
81 fpu_vers = ((fpu_vers>>17)&0x7);
82
83 for(i = 0; i<NSPARCCHIPS; i++) {
84 if(linux_sparc_chips[i].manuf == manuf)
85 if(linux_sparc_chips[i].impl == impl) {
86 sparc_cpu_type[cpuid] = linux_sparc_chips[i].cpu_name;
87 break;
88 }
89 }
90
91 if(i==NSPARCCHIPS) {
92 printk("DEBUG: manuf = 0x%x impl = 0x%x\n", manuf,
93 impl);
94 sparc_cpu_type[cpuid] = "Unknown CPU";
95 }
96
97 for(i = 0; i<NSPARCFPU; i++) {
98 if(linux_sparc_fpu[i].manuf == manuf && linux_sparc_fpu[i].impl == impl)
99 if(linux_sparc_fpu[i].fpu_vers == fpu_vers) {
100 sparc_fpu_type[cpuid] = linux_sparc_fpu[i].fp_name;
101 break;
102 }
103 }
104
105 if(i == NSPARCFPU) {
106 printk("DEBUG: manuf = 0x%x impl = 0x%x fsr.vers = 0x%x\n", manuf, impl,
107 (unsigned)fpu_vers);
108 sparc_fpu_type[cpuid] = "Unknown FPU";
109 }
110 }
111