transmeta.c 2.9 KB
Newer Older
L
Linus Torvalds 已提交
1
#include <linux/kernel.h>
P
Peter Zijlstra 已提交
2
#include <linux/sched.h>
3
#include <linux/sched/clock.h>
4
#include <linux/mm.h>
5
#include <asm/cpufeature.h>
L
Linus Torvalds 已提交
6 7 8
#include <asm/msr.h>
#include "cpu.h"

9
static void early_init_transmeta(struct cpuinfo_x86 *c)
10 11 12 13 14 15 16
{
	u32 xlvl;

	/* Transmeta-defined flags: level 0x80860001 */
	xlvl = cpuid_eax(0x80860000);
	if ((xlvl & 0xffff0000) == 0x80860000) {
		if (xlvl >= 0x80860001)
17
			c->x86_capability[CPUID_8086_0001_EDX] = cpuid_edx(0x80860001);
18
	}
P
Peter Zijlstra 已提交
19 20

	clear_sched_clock_stable();
21 22
}

23
static void init_transmeta(struct cpuinfo_x86 *c)
L
Linus Torvalds 已提交
24 25 26
{
	unsigned int cap_mask, uk, max, dummy;
	unsigned int cms_rev1, cms_rev2;
27
	unsigned int cpu_rev, cpu_freq = 0, cpu_flags, new_cpu_rev;
L
Linus Torvalds 已提交
28 29
	char cpu_info[65];

30 31
	early_init_transmeta(c);

32
	cpu_detect_cache_sizes(c);
L
Linus Torvalds 已提交
33 34 35 36

	/* Print CMS and CPU revision */
	max = cpuid_eax(0x80860000);
	cpu_rev = 0;
37 38
	if (max >= 0x80860001) {
		cpuid(0x80860001, &dummy, &cpu_rev, &cpu_freq, &cpu_flags);
L
Linus Torvalds 已提交
39
		if (cpu_rev != 0x02000000) {
40
			pr_info("CPU: Processor revision %u.%u.%u.%u, %u MHz\n",
L
Linus Torvalds 已提交
41 42 43 44 45 46 47
				(cpu_rev >> 24) & 0xff,
				(cpu_rev >> 16) & 0xff,
				(cpu_rev >> 8) & 0xff,
				cpu_rev & 0xff,
				cpu_freq);
		}
	}
48
	if (max >= 0x80860002) {
L
Linus Torvalds 已提交
49 50
		cpuid(0x80860002, &new_cpu_rev, &cms_rev1, &cms_rev2, &dummy);
		if (cpu_rev == 0x02000000) {
51
			pr_info("CPU: Processor revision %08X, %u MHz\n",
L
Linus Torvalds 已提交
52 53
				new_cpu_rev, cpu_freq);
		}
54
		pr_info("CPU: Code Morphing Software revision %u.%u.%u-%u-%u\n",
L
Linus Torvalds 已提交
55 56 57 58 59 60
		       (cms_rev1 >> 24) & 0xff,
		       (cms_rev1 >> 16) & 0xff,
		       (cms_rev1 >> 8) & 0xff,
		       cms_rev1 & 0xff,
		       cms_rev2);
	}
61
	if (max >= 0x80860006) {
L
Linus Torvalds 已提交
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
		cpuid(0x80860003,
		      (void *)&cpu_info[0],
		      (void *)&cpu_info[4],
		      (void *)&cpu_info[8],
		      (void *)&cpu_info[12]);
		cpuid(0x80860004,
		      (void *)&cpu_info[16],
		      (void *)&cpu_info[20],
		      (void *)&cpu_info[24],
		      (void *)&cpu_info[28]);
		cpuid(0x80860005,
		      (void *)&cpu_info[32],
		      (void *)&cpu_info[36],
		      (void *)&cpu_info[40],
		      (void *)&cpu_info[44]);
		cpuid(0x80860006,
		      (void *)&cpu_info[48],
		      (void *)&cpu_info[52],
		      (void *)&cpu_info[56],
		      (void *)&cpu_info[60]);
		cpu_info[64] = '\0';
83
		pr_info("CPU: %s\n", cpu_info);
L
Linus Torvalds 已提交
84 85 86 87 88
	}

	/* Unhide possibly hidden capability flags */
	rdmsr(0x80860004, cap_mask, uk);
	wrmsr(0x80860004, ~0, uk);
89
	c->x86_capability[CPUID_1_EDX] = cpuid_edx(0x00000001);
L
Linus Torvalds 已提交
90
	wrmsr(0x80860004, cap_mask, uk);
91 92

	/* All Transmeta CPUs have a constant TSC */
93
	set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
94

95
#ifdef CONFIG_SYSCTL
96 97 98 99
	/*
	 * randomize_va_space slows us down enormously;
	 * it probably triggers retranslation of x86->native bytecode
	 */
100
	randomize_va_space = 0;
101
#endif
L
Linus Torvalds 已提交
102 103
}

104
static const struct cpu_dev transmeta_cpu_dev = {
L
Linus Torvalds 已提交
105 106
	.c_vendor	= "Transmeta",
	.c_ident	= { "GenuineTMx86", "TransmetaCPU" },
107
	.c_early_init	= early_init_transmeta,
L
Linus Torvalds 已提交
108
	.c_init		= init_transmeta,
Y
Yinghai Lu 已提交
109
	.c_x86_vendor	= X86_VENDOR_TRANSMETA,
L
Linus Torvalds 已提交
110 111
};

Y
Yinghai Lu 已提交
112
cpu_dev_register(transmeta_cpu_dev);