blob: 0097c08dc600e2f432d6a8da965962ab9b3b2bcd [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/* cpu.c: Dinky routines to look for the kind of Sparc cpu
2 * we are on.
3 *
David S. Miller68c9f9f2007-08-07 19:09:29 -07004 * Copyright (C) 1996, 2007 David S. Miller (davem@davemloft.net)
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
6
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <linux/kernel.h>
8#include <linux/init.h>
9#include <linux/sched.h>
10#include <linux/smp.h>
11#include <asm/asi.h>
12#include <asm/system.h>
13#include <asm/fpumacro.h>
14#include <asm/cpudata.h>
David S. Miller12816ab2006-02-09 03:00:00 -080015#include <asm/spitfire.h>
David S. Miller6c70b6f2007-08-08 17:11:39 -070016#include <asm/oplib.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070017
David S. Miller3d5ae6b2008-03-25 21:51:40 -070018#include "entry.h"
19
Linus Torvalds1da177e2005-04-16 15:20:36 -070020DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 };
21
22struct cpu_iu_info {
23 short manuf;
24 short impl;
25 char* cpu_name; /* should be enough I hope... */
26};
27
28struct cpu_fp_info {
29 short manuf;
30 short impl;
31 char fpu_vers;
32 char* fp_name;
33};
34
David S. Millerc8edc892008-02-28 21:46:59 -080035static struct cpu_fp_info linux_sparc_fpu[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 { 0x17, 0x10, 0, "UltraSparc I integrated FPU"},
37 { 0x22, 0x10, 0, "UltraSparc I integrated FPU"},
38 { 0x17, 0x11, 0, "UltraSparc II integrated FPU"},
39 { 0x17, 0x12, 0, "UltraSparc IIi integrated FPU"},
40 { 0x17, 0x13, 0, "UltraSparc IIe integrated FPU"},
41 { 0x3e, 0x14, 0, "UltraSparc III integrated FPU"},
42 { 0x3e, 0x15, 0, "UltraSparc III+ integrated FPU"},
43 { 0x3e, 0x16, 0, "UltraSparc IIIi integrated FPU"},
44 { 0x3e, 0x18, 0, "UltraSparc IV integrated FPU"},
David S. Millerd2212bc2005-09-27 22:50:06 -070045 { 0x3e, 0x19, 0, "UltraSparc IV+ integrated FPU"},
46 { 0x3e, 0x22, 0, "UltraSparc IIIi+ integrated FPU"},
Linus Torvalds1da177e2005-04-16 15:20:36 -070047};
48
Tobias Klauser84c1a132005-11-09 12:03:42 -080049#define NSPARCFPU ARRAY_SIZE(linux_sparc_fpu)
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
David S. Millerc8edc892008-02-28 21:46:59 -080051static struct cpu_iu_info linux_sparc_chips[] = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070052 { 0x17, 0x10, "TI UltraSparc I (SpitFire)"},
53 { 0x22, 0x10, "TI UltraSparc I (SpitFire)"},
54 { 0x17, 0x11, "TI UltraSparc II (BlackBird)"},
55 { 0x17, 0x12, "TI UltraSparc IIi (Sabre)"},
56 { 0x17, 0x13, "TI UltraSparc IIe (Hummingbird)"},
57 { 0x3e, 0x14, "TI UltraSparc III (Cheetah)"},
58 { 0x3e, 0x15, "TI UltraSparc III+ (Cheetah+)"},
59 { 0x3e, 0x16, "TI UltraSparc IIIi (Jalapeno)"},
60 { 0x3e, 0x18, "TI UltraSparc IV (Jaguar)"},
David S. Millerd2212bc2005-09-27 22:50:06 -070061 { 0x3e, 0x19, "TI UltraSparc IV+ (Panther)"},
62 { 0x3e, 0x22, "TI UltraSparc IIIi+ (Serrano)"},
Linus Torvalds1da177e2005-04-16 15:20:36 -070063};
64
Tobias Klauser84c1a132005-11-09 12:03:42 -080065#define NSPARCCHIPS ARRAY_SIZE(linux_sparc_chips)
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
David S. Miller68c9f9f2007-08-07 19:09:29 -070067char *sparc_cpu_type;
68char *sparc_fpu_type;
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
David S. Miller68c9f9f2007-08-07 19:09:29 -070070static void __init sun4v_cpu_probe(void)
71{
David S. Miller6c70b6f2007-08-08 17:11:39 -070072 switch (sun4v_chip_type) {
73 case SUN4V_CHIP_NIAGARA1:
David S. Miller68c9f9f2007-08-07 19:09:29 -070074 sparc_cpu_type = "UltraSparc T1 (Niagara)";
75 sparc_fpu_type = "UltraSparc T1 integrated FPU";
David S. Miller6c70b6f2007-08-08 17:11:39 -070076 break;
77
78 case SUN4V_CHIP_NIAGARA2:
David S. Miller68c9f9f2007-08-07 19:09:29 -070079 sparc_cpu_type = "UltraSparc T2 (Niagara2)";
80 sparc_fpu_type = "UltraSparc T2 integrated FPU";
David S. Miller6c70b6f2007-08-08 17:11:39 -070081 break;
David S. Miller68c9f9f2007-08-07 19:09:29 -070082
David S. Miller6c70b6f2007-08-08 17:11:39 -070083 default:
84 printk(KERN_WARNING "CPU: Unknown sun4v cpu type [%s]\n",
85 prom_cpu_compatible);
86 sparc_cpu_type = "Unknown SUN4V CPU";
87 sparc_fpu_type = "Unknown SUN4V FPU";
88 break;
89 }
David S. Miller68c9f9f2007-08-07 19:09:29 -070090}
91
Linus Torvalds1da177e2005-04-16 15:20:36 -070092void __init cpu_probe(void)
93{
94 unsigned long ver, fpu_vers, manuf, impl, fprs;
95 int i;
96
David S. Miller3d5ae6b2008-03-25 21:51:40 -070097 if (tlb_type == hypervisor) {
98 sun4v_cpu_probe();
99 return;
100 }
David S. Millerd82ace72006-02-09 02:52:44 -0800101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 fprs = fprs_read();
103 fprs_write(FPRS_FEF);
104 __asm__ __volatile__ ("rdpr %%ver, %0; stx %%fsr, [%1]"
105 : "=&r" (ver)
106 : "r" (&fpu_vers));
107 fprs_write(fprs);
108
109 manuf = ((ver >> 48) & 0xffff);
110 impl = ((ver >> 32) & 0xffff);
111
112 fpu_vers = ((fpu_vers >> 17) & 0x7);
113
114retry:
115 for (i = 0; i < NSPARCCHIPS; i++) {
116 if (linux_sparc_chips[i].manuf == manuf) {
117 if (linux_sparc_chips[i].impl == impl) {
118 sparc_cpu_type =
119 linux_sparc_chips[i].cpu_name;
120 break;
121 }
122 }
123 }
124
125 if (i == NSPARCCHIPS) {
126 /* Maybe it is a cheetah+ derivative, report it as cheetah+
127 * in that case until we learn the real names.
128 */
129 if (manuf == 0x3e &&
130 impl > 0x15) {
131 impl = 0x15;
132 goto retry;
133 } else {
134 printk("DEBUG: manuf[%lx] impl[%lx]\n",
135 manuf, impl);
136 }
137 sparc_cpu_type = "Unknown CPU";
138 }
139
140 for (i = 0; i < NSPARCFPU; i++) {
141 if (linux_sparc_fpu[i].manuf == manuf &&
142 linux_sparc_fpu[i].impl == impl) {
143 if (linux_sparc_fpu[i].fpu_vers == fpu_vers) {
144 sparc_fpu_type =
145 linux_sparc_fpu[i].fp_name;
146 break;
147 }
148 }
149 }
150
151 if (i == NSPARCFPU) {
152 printk("DEBUG: manuf[%lx] impl[%lx] fsr.vers[%lx]\n",
153 manuf, impl, fpu_vers);
154 sparc_fpu_type = "Unknown FPU";
155 }
156}