cpu.c 3.6 KB
Newer Older
L
Linus Torvalds 已提交
1 2 3
/* cpu.c: Dinky routines to look for the kind of Sparc cpu
 *        we are on.
 *
4
 * Copyright (C) 1996, 2007, 2008 David S. Miller (davem@davemloft.net)
L
Linus Torvalds 已提交
5 6 7 8 9 10 11 12 13 14
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/smp.h>
#include <asm/asi.h>
#include <asm/system.h>
#include <asm/fpumacro.h>
#include <asm/cpudata.h>
15
#include <asm/spitfire.h>
16
#include <asm/oplib.h>
L
Linus Torvalds 已提交
17

18 19
#include "entry.h"

L
Linus Torvalds 已提交
20 21
DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 };

22 23 24 25 26
struct cpu_chip_info {
	unsigned short	manuf;
	unsigned short	impl;
	const char	*cpu_name;
	const char	*fp_name;
L
Linus Torvalds 已提交
27 28
};

29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
static const struct cpu_chip_info cpu_chips[] = {
	{
		.manuf		= 0x17,
		.impl		= 0x10,
		.cpu_name	= "TI UltraSparc I   (SpitFire)",
		.fp_name	= "UltraSparc I integrated FPU",
	},
	{
		.manuf		= 0x22,
		.impl		= 0x10,
		.cpu_name	= "TI UltraSparc I   (SpitFire)",
		.fp_name	= "UltraSparc I integrated FPU",
	},
	{
		.manuf		= 0x17,
		.impl		= 0x11,
		.cpu_name	= "TI UltraSparc II  (BlackBird)",
		.fp_name	= "UltraSparc II integrated FPU",
	},
	{
		.manuf		= 0x17,
		.impl		= 0x12,
		.cpu_name	= "TI UltraSparc IIi (Sabre)",
		.fp_name	= "UltraSparc IIi integrated FPU",
	},
	{
		.manuf		= 0x17,
		.impl		= 0x13,
		.cpu_name	= "TI UltraSparc IIe (Hummingbird)",
		.fp_name	= "UltraSparc IIe integrated FPU",
	},
	{
		.manuf		= 0x3e,
		.impl		= 0x14,
		.cpu_name	= "TI UltraSparc III (Cheetah)",
		.fp_name	= "UltraSparc III integrated FPU",
	},
	{
		.manuf		= 0x3e,
		.impl		= 0x15,
		.cpu_name	= "TI UltraSparc III+ (Cheetah+)",
		.fp_name	= "UltraSparc III+ integrated FPU",
	},
	{
		.manuf		= 0x3e,
		.impl		= 0x16,
		.cpu_name	= "TI UltraSparc IIIi (Jalapeno)",
		.fp_name	= "UltraSparc IIIi integrated FPU",
	},
	{
		.manuf		= 0x3e,
		.impl		= 0x18,
		.cpu_name	= "TI UltraSparc IV (Jaguar)",
		.fp_name	= "UltraSparc IV integrated FPU",
	},
	{
		.manuf		= 0x3e,
		.impl		= 0x19,
		.cpu_name	= "TI UltraSparc IV+ (Panther)",
		.fp_name	= "UltraSparc IV+ integrated FPU",
	},
	{
		.manuf		= 0x3e,
		.impl		= 0x22,
		.cpu_name	= "TI UltraSparc IIIi+ (Serrano)",
		.fp_name	= "UltraSparc IIIi+ integrated FPU",
	},
L
Linus Torvalds 已提交
96 97
};

98
#define NSPARCCHIPS ARRAY_SIZE(linux_sparc_chips)
L
Linus Torvalds 已提交
99

100 101
const char *sparc_cpu_type;
const char *sparc_fpu_type;
L
Linus Torvalds 已提交
102

103 104
static void __init sun4v_cpu_probe(void)
{
105 106
	switch (sun4v_chip_type) {
	case SUN4V_CHIP_NIAGARA1:
107 108
		sparc_cpu_type = "UltraSparc T1 (Niagara)";
		sparc_fpu_type = "UltraSparc T1 integrated FPU";
109 110 111
		break;

	case SUN4V_CHIP_NIAGARA2:
112 113
		sparc_cpu_type = "UltraSparc T2 (Niagara2)";
		sparc_fpu_type = "UltraSparc T2 integrated FPU";
114 115 116 117 118 119 120 121 122
		break;

	default:
		printk(KERN_WARNING "CPU: Unknown sun4v cpu type [%s]\n",
		       prom_cpu_compatible);
		sparc_cpu_type = "Unknown SUN4V CPU";
		sparc_fpu_type = "Unknown SUN4V FPU";
		break;
	}
123 124
}

125 126
static const struct cpu_chip_info * __init find_cpu_chip(unsigned short manuf,
							 unsigned short impl)
L
Linus Torvalds 已提交
127 128
{
	int i;
129

130 131
	for (i = 0; i < ARRAY_SIZE(cpu_chips); i++) {
		const struct cpu_chip_info *p = &cpu_chips[i];
L
Linus Torvalds 已提交
132

133 134
		if (p->manuf == manuf && p->impl == impl)
			return p;
L
Linus Torvalds 已提交
135
	}
136 137
	return NULL;
}
L
Linus Torvalds 已提交
138

139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
static int __init cpu_type_probe(void)
{
	if (tlb_type == hypervisor) {
		sun4v_cpu_probe();
	} else {
		unsigned long ver, manuf, impl;
		const struct cpu_chip_info *p;
	
		__asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
	
		manuf = ((ver >> 48) & 0xffff);
		impl = ((ver >> 32) & 0xffff);

		p = find_cpu_chip(manuf, impl);
		if (p) {
			sparc_cpu_type = p->cpu_name;
			sparc_fpu_type = p->fp_name;
		} else {
			printk(KERN_ERR "CPU: Unknown chip, manuf[%lx] impl[%lx]\n",
			       manuf, impl);
			sparc_cpu_type = "Unknown CPU";
			sparc_fpu_type = "Unknown FPU";
L
Linus Torvalds 已提交
161 162
		}
	}
163
	return 0;
L
Linus Torvalds 已提交
164
}
165 166

arch_initcall(cpu_type_probe);