blob: 42c939827621a56c31d9a60f80d6857d091a8ddf [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002#include <linux/kernel.h>
Peter Zijlstraacb04052017-01-19 14:36:33 +01003#include <linux/sched.h>
Ingo Molnare6017572017-02-01 16:36:40 +01004#include <linux/sched/clock.h>
Andi Kleena62eaf12006-02-16 23:41:58 +01005#include <linux/mm.h>
Borislav Petkovcd4d09e2016-01-26 22:12:04 +01006#include <asm/cpufeature.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07007#include <asm/msr.h>
8#include "cpu.h"
9
Paul Gortmaker148f9bb2013-06-18 18:23:59 -040010static void early_init_transmeta(struct cpuinfo_x86 *c)
Yinghai Luafae8652008-09-14 02:33:16 -070011{
12 u32 xlvl;
13
14 /* Transmeta-defined flags: level 0x80860001 */
15 xlvl = cpuid_eax(0x80860000);
16 if ((xlvl & 0xffff0000) == 0x80860000) {
17 if (xlvl >= 0x80860001)
Borislav Petkov39c06df2015-12-07 10:39:40 +010018 c->x86_capability[CPUID_8086_0001_EDX] = cpuid_edx(0x80860001);
Yinghai Luafae8652008-09-14 02:33:16 -070019 }
20}
21
Paul Gortmaker148f9bb2013-06-18 18:23:59 -040022static void init_transmeta(struct cpuinfo_x86 *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -070023{
24 unsigned int cap_mask, uk, max, dummy;
25 unsigned int cms_rev1, cms_rev2;
Andi Kleen7de6d362007-02-13 13:26:25 +010026 unsigned int cpu_rev, cpu_freq = 0, cpu_flags, new_cpu_rev;
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 char cpu_info[65];
28
Yinghai Luafae8652008-09-14 02:33:16 -070029 early_init_transmeta(c);
30
Borislav Petkov27c13ec2009-11-21 14:01:45 +010031 cpu_detect_cache_sizes(c);
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33 /* Print CMS and CPU revision */
34 max = cpuid_eax(0x80860000);
35 cpu_rev = 0;
Paolo Ciarrocchif9751822008-02-22 23:10:28 +010036 if (max >= 0x80860001) {
37 cpuid(0x80860001, &dummy, &cpu_rev, &cpu_freq, &cpu_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 if (cpu_rev != 0x02000000) {
Chen Yucong1b74dde2016-02-02 11:45:02 +080039 pr_info("CPU: Processor revision %u.%u.%u.%u, %u MHz\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 (cpu_rev >> 24) & 0xff,
41 (cpu_rev >> 16) & 0xff,
42 (cpu_rev >> 8) & 0xff,
43 cpu_rev & 0xff,
44 cpu_freq);
45 }
46 }
Paolo Ciarrocchif9751822008-02-22 23:10:28 +010047 if (max >= 0x80860002) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 cpuid(0x80860002, &new_cpu_rev, &cms_rev1, &cms_rev2, &dummy);
49 if (cpu_rev == 0x02000000) {
Chen Yucong1b74dde2016-02-02 11:45:02 +080050 pr_info("CPU: Processor revision %08X, %u MHz\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 new_cpu_rev, cpu_freq);
52 }
Chen Yucong1b74dde2016-02-02 11:45:02 +080053 pr_info("CPU: Code Morphing Software revision %u.%u.%u-%u-%u\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 (cms_rev1 >> 24) & 0xff,
55 (cms_rev1 >> 16) & 0xff,
56 (cms_rev1 >> 8) & 0xff,
57 cms_rev1 & 0xff,
58 cms_rev2);
59 }
Paolo Ciarrocchif9751822008-02-22 23:10:28 +010060 if (max >= 0x80860006) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070061 cpuid(0x80860003,
62 (void *)&cpu_info[0],
63 (void *)&cpu_info[4],
64 (void *)&cpu_info[8],
65 (void *)&cpu_info[12]);
66 cpuid(0x80860004,
67 (void *)&cpu_info[16],
68 (void *)&cpu_info[20],
69 (void *)&cpu_info[24],
70 (void *)&cpu_info[28]);
71 cpuid(0x80860005,
72 (void *)&cpu_info[32],
73 (void *)&cpu_info[36],
74 (void *)&cpu_info[40],
75 (void *)&cpu_info[44]);
76 cpuid(0x80860006,
77 (void *)&cpu_info[48],
78 (void *)&cpu_info[52],
79 (void *)&cpu_info[56],
80 (void *)&cpu_info[60]);
81 cpu_info[64] = '\0';
Chen Yucong1b74dde2016-02-02 11:45:02 +080082 pr_info("CPU: %s\n", cpu_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -070083 }
84
85 /* Unhide possibly hidden capability flags */
86 rdmsr(0x80860004, cap_mask, uk);
87 wrmsr(0x80860004, ~0, uk);
Borislav Petkov39c06df2015-12-07 10:39:40 +010088 c->x86_capability[CPUID_1_EDX] = cpuid_edx(0x00000001);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 wrmsr(0x80860004, cap_mask, uk);
H. Peter Anvin30b82ea2007-02-13 13:26:24 +010090
91 /* All Transmeta CPUs have a constant TSC */
Ingo Molnar10cd5a12008-02-26 08:52:39 +010092 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
Paolo Ciarrocchif9751822008-02-22 23:10:28 +010093
Andrew Morton39bbb072005-08-01 21:11:44 -070094#ifdef CONFIG_SYSCTL
Paolo Ciarrocchif9751822008-02-22 23:10:28 +010095 /*
96 * randomize_va_space slows us down enormously;
97 * it probably triggers retranslation of x86->native bytecode
98 */
Eric Lammertscdf32ea2005-07-31 22:34:42 -070099 randomize_va_space = 0;
Andrew Morton39bbb072005-08-01 21:11:44 -0700100#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101}
102
Paul Gortmaker148f9bb2013-06-18 18:23:59 -0400103static const struct cpu_dev transmeta_cpu_dev = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104 .c_vendor = "Transmeta",
105 .c_ident = { "GenuineTMx86", "TransmetaCPU" },
Yinghai Luafae8652008-09-14 02:33:16 -0700106 .c_early_init = early_init_transmeta,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 .c_init = init_transmeta,
Yinghai Lu10a434f2008-09-04 21:09:45 +0200108 .c_x86_vendor = X86_VENDOR_TRANSMETA,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109};
110
Yinghai Lu10a434f2008-09-04 21:09:45 +0200111cpu_dev_register(transmeta_cpu_dev);