ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / 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 #include <asm/cpudata.h>
16
17 DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 };
18
19 struct cpu_iu_info {
20   short manuf;
21   short impl;
22   char* cpu_name;   /* should be enough I hope... */
23 };
24
25 struct cpu_fp_info {
26   short manuf;
27   short impl;
28   char fpu_vers;
29   char* fp_name;
30 };
31
32 struct cpu_fp_info linux_sparc_fpu[] = {
33   { 0x17, 0x10, 0, "UltraSparc I integrated FPU"},
34   { 0x22, 0x10, 0, "UltraSparc I 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   { 0x3e, 0x15, 0, "UltraSparc III+ integrated FPU"},
40   { 0x3e, 0x16, 0, "UltraSparc IIIi integrated FPU"},
41 };
42
43 #define NSPARCFPU  (sizeof(linux_sparc_fpu)/sizeof(struct cpu_fp_info))
44
45 struct cpu_iu_info linux_sparc_chips[] = {
46   { 0x17, 0x10, "TI UltraSparc I   (SpitFire)"},
47   { 0x22, 0x10, "TI UltraSparc I   (SpitFire)"},
48   { 0x17, 0x11, "TI UltraSparc II  (BlackBird)"},
49   { 0x17, 0x12, "TI UltraSparc IIi (Sabre)"},
50   { 0x17, 0x13, "TI UltraSparc IIe (Hummingbird)"},
51   { 0x3e, 0x14, "TI UltraSparc III (Cheetah)"},
52   { 0x3e, 0x15, "TI UltraSparc III+ (Cheetah+)"},
53   { 0x3e, 0x16, "TI UltraSparc IIIi (Jalapeno)"},
54 };
55
56 #define NSPARCCHIPS  (sizeof(linux_sparc_chips)/sizeof(struct cpu_iu_info))
57
58 char *sparc_cpu_type = "cpu-oops";
59 char *sparc_fpu_type = "fpu-oops";
60
61 unsigned int fsr_storage;
62
63 void __init cpu_probe(void)
64 {
65         unsigned long ver, fpu_vers, manuf, impl, fprs;
66         int i;
67         
68         fprs = fprs_read();
69         fprs_write(FPRS_FEF);
70         __asm__ __volatile__ ("rdpr %%ver, %0; stx %%fsr, [%1]"
71                               : "=&r" (ver)
72                               : "r" (&fpu_vers));
73         fprs_write(fprs);
74         
75         manuf = ((ver >> 48) & 0xffff);
76         impl = ((ver >> 32) & 0xffff);
77
78         fpu_vers = ((fpu_vers >> 17) & 0x7);
79
80 retry:
81         for (i = 0; i < NSPARCCHIPS; i++) {
82                 if (linux_sparc_chips[i].manuf == manuf) {
83                         if (linux_sparc_chips[i].impl == impl) {
84                                 sparc_cpu_type =
85                                         linux_sparc_chips[i].cpu_name;
86                                 break;
87                         }
88                 }
89         }
90
91         if (i == NSPARCCHIPS) {
92                 /* Maybe it is a cheetah+ derivative, report it as cheetah+
93                  * in that case until we learn the real names.
94                  */
95                 if (manuf == 0x3e &&
96                     impl > 0x15) {
97                         impl = 0x15;
98                         goto retry;
99                 } else {
100                         printk("DEBUG: manuf[%lx] impl[%lx]\n",
101                                manuf, impl);
102                 }
103                 sparc_cpu_type = "Unknown CPU";
104         }
105
106         for (i = 0; i < NSPARCFPU; i++) {
107                 if (linux_sparc_fpu[i].manuf == manuf &&
108                     linux_sparc_fpu[i].impl == impl) {
109                         if (linux_sparc_fpu[i].fpu_vers == fpu_vers) {
110                                 sparc_fpu_type =
111                                         linux_sparc_fpu[i].fp_name;
112                                 break;
113                         }
114                 }
115         }
116
117         if (i == NSPARCFPU) {
118                 printk("DEBUG: manuf[%lx] impl[%lx] fsr.vers[%lx]\n",
119                        manuf, impl, fpu_vers);
120                 sparc_fpu_type = "Unknown FPU";
121         }
122 }