blob: 28000743bbb06984b0b7182caca09833fed756b9 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/kernel.h>
Andi Kleena62eaf12006-02-16 23:41:58 +01002#include <linux/mm.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07003#include <linux/init.h>
4#include <asm/processor.h>
5#include <asm/msr.h>
6#include "cpu.h"
7
Yinghai Luafae8652008-09-14 02:33:16 -07008static void __cpuinit early_init_transmeta(struct cpuinfo_x86 *c)
9{
10 u32 xlvl;
11
12 /* Transmeta-defined flags: level 0x80860001 */
13 xlvl = cpuid_eax(0x80860000);
14 if ((xlvl & 0xffff0000) == 0x80860000) {
15 if (xlvl >= 0x80860001)
16 c->x86_capability[2] = cpuid_edx(0x80860001);
17 }
18}
19
Magnus Dammb4af3f72006-09-26 10:52:36 +020020static void __cpuinit init_transmeta(struct cpuinfo_x86 *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -070021{
22 unsigned int cap_mask, uk, max, dummy;
23 unsigned int cms_rev1, cms_rev2;
Andi Kleen7de6d362007-02-13 13:26:25 +010024 unsigned int cpu_rev, cpu_freq = 0, cpu_flags, new_cpu_rev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 char cpu_info[65];
26
Yinghai Luafae8652008-09-14 02:33:16 -070027 early_init_transmeta(c);
28
Borislav Petkov27c13ec2009-11-21 14:01:45 +010029 cpu_detect_cache_sizes(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -070030
31 /* Print CMS and CPU revision */
32 max = cpuid_eax(0x80860000);
33 cpu_rev = 0;
Paolo Ciarrocchif9751822008-02-22 23:10:28 +010034 if (max >= 0x80860001) {
35 cpuid(0x80860001, &dummy, &cpu_rev, &cpu_freq, &cpu_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070036 if (cpu_rev != 0x02000000) {
37 printk(KERN_INFO "CPU: Processor revision %u.%u.%u.%u, %u MHz\n",
38 (cpu_rev >> 24) & 0xff,
39 (cpu_rev >> 16) & 0xff,
40 (cpu_rev >> 8) & 0xff,
41 cpu_rev & 0xff,
42 cpu_freq);
43 }
44 }
Paolo Ciarrocchif9751822008-02-22 23:10:28 +010045 if (max >= 0x80860002) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 cpuid(0x80860002, &new_cpu_rev, &cms_rev1, &cms_rev2, &dummy);
47 if (cpu_rev == 0x02000000) {
48 printk(KERN_INFO "CPU: Processor revision %08X, %u MHz\n",
49 new_cpu_rev, cpu_freq);
50 }
51 printk(KERN_INFO "CPU: Code Morphing Software revision %u.%u.%u-%u-%u\n",
52 (cms_rev1 >> 24) & 0xff,
53 (cms_rev1 >> 16) & 0xff,
54 (cms_rev1 >> 8) & 0xff,
55 cms_rev1 & 0xff,
56 cms_rev2);
57 }
Paolo Ciarrocchif9751822008-02-22 23:10:28 +010058 if (max >= 0x80860006) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 cpuid(0x80860003,
60 (void *)&cpu_info[0],
61 (void *)&cpu_info[4],
62 (void *)&cpu_info[8],
63 (void *)&cpu_info[12]);
64 cpuid(0x80860004,
65 (void *)&cpu_info[16],
66 (void *)&cpu_info[20],
67 (void *)&cpu_info[24],
68 (void *)&cpu_info[28]);
69 cpuid(0x80860005,
70 (void *)&cpu_info[32],
71 (void *)&cpu_info[36],
72 (void *)&cpu_info[40],
73 (void *)&cpu_info[44]);
74 cpuid(0x80860006,
75 (void *)&cpu_info[48],
76 (void *)&cpu_info[52],
77 (void *)&cpu_info[56],
78 (void *)&cpu_info[60]);
79 cpu_info[64] = '\0';
80 printk(KERN_INFO "CPU: %s\n", cpu_info);
81 }
82
83 /* Unhide possibly hidden capability flags */
84 rdmsr(0x80860004, cap_mask, uk);
85 wrmsr(0x80860004, ~0, uk);
86 c->x86_capability[0] = cpuid_edx(0x00000001);
87 wrmsr(0x80860004, cap_mask, uk);
H. Peter Anvin30b82ea2007-02-13 13:26:24 +010088
89 /* All Transmeta CPUs have a constant TSC */
Ingo Molnar10cd5a12008-02-26 08:52:39 +010090 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
Paolo Ciarrocchif9751822008-02-22 23:10:28 +010091
Andrew Morton39bbb072005-08-01 21:11:44 -070092#ifdef CONFIG_SYSCTL
Paolo Ciarrocchif9751822008-02-22 23:10:28 +010093 /*
94 * randomize_va_space slows us down enormously;
95 * it probably triggers retranslation of x86->native bytecode
96 */
Eric Lammertscdf32ea2005-07-31 22:34:42 -070097 randomize_va_space = 0;
Andrew Morton39bbb072005-08-01 21:11:44 -070098#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070099}
100
Jan Beulich02dde8b2009-03-12 12:08:49 +0000101static const struct cpu_dev __cpuinitconst transmeta_cpu_dev = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 .c_vendor = "Transmeta",
103 .c_ident = { "GenuineTMx86", "TransmetaCPU" },
Yinghai Luafae8652008-09-14 02:33:16 -0700104 .c_early_init = early_init_transmeta,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700105 .c_init = init_transmeta,
Yinghai Lu10a434f2008-09-04 21:09:45 +0200106 .c_x86_vendor = X86_VENDOR_TRANSMETA,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107};
108
Yinghai Lu10a434f2008-09-04 21:09:45 +0200109cpu_dev_register(transmeta_cpu_dev);