1*b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
2f7627e25SThomas Gleixner #include <linux/kernel.h>
3acb04058SPeter Zijlstra #include <linux/sched.h>
4e6017571SIngo Molnar #include <linux/sched/clock.h>
5f7627e25SThomas Gleixner #include <linux/mm.h>
6cd4d09ecSBorislav Petkov #include <asm/cpufeature.h>
7f7627e25SThomas Gleixner #include <asm/msr.h>
8f7627e25SThomas Gleixner #include "cpu.h"
9f7627e25SThomas Gleixner
early_init_transmeta(struct cpuinfo_x86 * c)10148f9bb8SPaul Gortmaker static void early_init_transmeta(struct cpuinfo_x86 *c)
11afae8656SYinghai Lu {
12afae8656SYinghai Lu u32 xlvl;
13afae8656SYinghai Lu
14afae8656SYinghai Lu /* Transmeta-defined flags: level 0x80860001 */
15afae8656SYinghai Lu xlvl = cpuid_eax(0x80860000);
16afae8656SYinghai Lu if ((xlvl & 0xffff0000) == 0x80860000) {
17afae8656SYinghai Lu if (xlvl >= 0x80860001)
1839c06df4SBorislav Petkov c->x86_capability[CPUID_8086_0001_EDX] = cpuid_edx(0x80860001);
19afae8656SYinghai Lu }
20afae8656SYinghai Lu }
21afae8656SYinghai Lu
init_transmeta(struct cpuinfo_x86 * c)22148f9bb8SPaul Gortmaker static void init_transmeta(struct cpuinfo_x86 *c)
23f7627e25SThomas Gleixner {
24f7627e25SThomas Gleixner unsigned int cap_mask, uk, max, dummy;
25f7627e25SThomas Gleixner unsigned int cms_rev1, cms_rev2;
26f7627e25SThomas Gleixner unsigned int cpu_rev, cpu_freq = 0, cpu_flags, new_cpu_rev;
27f7627e25SThomas Gleixner char cpu_info[65];
28f7627e25SThomas Gleixner
29afae8656SYinghai Lu early_init_transmeta(c);
30afae8656SYinghai Lu
3127c13eceSBorislav Petkov cpu_detect_cache_sizes(c);
32f7627e25SThomas Gleixner
33f7627e25SThomas Gleixner /* Print CMS and CPU revision */
34f7627e25SThomas Gleixner max = cpuid_eax(0x80860000);
35f7627e25SThomas Gleixner cpu_rev = 0;
36f7627e25SThomas Gleixner if (max >= 0x80860001) {
37f7627e25SThomas Gleixner cpuid(0x80860001, &dummy, &cpu_rev, &cpu_freq, &cpu_flags);
38f7627e25SThomas Gleixner if (cpu_rev != 0x02000000) {
391b74dde7SChen Yucong pr_info("CPU: Processor revision %u.%u.%u.%u, %u MHz\n",
40f7627e25SThomas Gleixner (cpu_rev >> 24) & 0xff,
41f7627e25SThomas Gleixner (cpu_rev >> 16) & 0xff,
42f7627e25SThomas Gleixner (cpu_rev >> 8) & 0xff,
43f7627e25SThomas Gleixner cpu_rev & 0xff,
44f7627e25SThomas Gleixner cpu_freq);
45f7627e25SThomas Gleixner }
46f7627e25SThomas Gleixner }
47f7627e25SThomas Gleixner if (max >= 0x80860002) {
48f7627e25SThomas Gleixner cpuid(0x80860002, &new_cpu_rev, &cms_rev1, &cms_rev2, &dummy);
49f7627e25SThomas Gleixner if (cpu_rev == 0x02000000) {
501b74dde7SChen Yucong pr_info("CPU: Processor revision %08X, %u MHz\n",
51f7627e25SThomas Gleixner new_cpu_rev, cpu_freq);
52f7627e25SThomas Gleixner }
531b74dde7SChen Yucong pr_info("CPU: Code Morphing Software revision %u.%u.%u-%u-%u\n",
54f7627e25SThomas Gleixner (cms_rev1 >> 24) & 0xff,
55f7627e25SThomas Gleixner (cms_rev1 >> 16) & 0xff,
56f7627e25SThomas Gleixner (cms_rev1 >> 8) & 0xff,
57f7627e25SThomas Gleixner cms_rev1 & 0xff,
58f7627e25SThomas Gleixner cms_rev2);
59f7627e25SThomas Gleixner }
60f7627e25SThomas Gleixner if (max >= 0x80860006) {
61f7627e25SThomas Gleixner cpuid(0x80860003,
62f7627e25SThomas Gleixner (void *)&cpu_info[0],
63f7627e25SThomas Gleixner (void *)&cpu_info[4],
64f7627e25SThomas Gleixner (void *)&cpu_info[8],
65f7627e25SThomas Gleixner (void *)&cpu_info[12]);
66f7627e25SThomas Gleixner cpuid(0x80860004,
67f7627e25SThomas Gleixner (void *)&cpu_info[16],
68f7627e25SThomas Gleixner (void *)&cpu_info[20],
69f7627e25SThomas Gleixner (void *)&cpu_info[24],
70f7627e25SThomas Gleixner (void *)&cpu_info[28]);
71f7627e25SThomas Gleixner cpuid(0x80860005,
72f7627e25SThomas Gleixner (void *)&cpu_info[32],
73f7627e25SThomas Gleixner (void *)&cpu_info[36],
74f7627e25SThomas Gleixner (void *)&cpu_info[40],
75f7627e25SThomas Gleixner (void *)&cpu_info[44]);
76f7627e25SThomas Gleixner cpuid(0x80860006,
77f7627e25SThomas Gleixner (void *)&cpu_info[48],
78f7627e25SThomas Gleixner (void *)&cpu_info[52],
79f7627e25SThomas Gleixner (void *)&cpu_info[56],
80f7627e25SThomas Gleixner (void *)&cpu_info[60]);
81f7627e25SThomas Gleixner cpu_info[64] = '\0';
821b74dde7SChen Yucong pr_info("CPU: %s\n", cpu_info);
83f7627e25SThomas Gleixner }
84f7627e25SThomas Gleixner
85f7627e25SThomas Gleixner /* Unhide possibly hidden capability flags */
86f7627e25SThomas Gleixner rdmsr(0x80860004, cap_mask, uk);
87f7627e25SThomas Gleixner wrmsr(0x80860004, ~0, uk);
8839c06df4SBorislav Petkov c->x86_capability[CPUID_1_EDX] = cpuid_edx(0x00000001);
89f7627e25SThomas Gleixner wrmsr(0x80860004, cap_mask, uk);
90f7627e25SThomas Gleixner
91f7627e25SThomas Gleixner /* All Transmeta CPUs have a constant TSC */
9210cd5a1eSIngo Molnar set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
93f7627e25SThomas Gleixner
94f7627e25SThomas Gleixner #ifdef CONFIG_SYSCTL
95f9751827SPaolo Ciarrocchi /*
96f9751827SPaolo Ciarrocchi * randomize_va_space slows us down enormously;
97f9751827SPaolo Ciarrocchi * it probably triggers retranslation of x86->native bytecode
98f9751827SPaolo Ciarrocchi */
99f7627e25SThomas Gleixner randomize_va_space = 0;
100f7627e25SThomas Gleixner #endif
101f7627e25SThomas Gleixner }
102f7627e25SThomas Gleixner
103148f9bb8SPaul Gortmaker static const struct cpu_dev transmeta_cpu_dev = {
104f7627e25SThomas Gleixner .c_vendor = "Transmeta",
105f7627e25SThomas Gleixner .c_ident = { "GenuineTMx86", "TransmetaCPU" },
106afae8656SYinghai Lu .c_early_init = early_init_transmeta,
107f7627e25SThomas Gleixner .c_init = init_transmeta,
10810a434fcSYinghai Lu .c_x86_vendor = X86_VENDOR_TRANSMETA,
109f7627e25SThomas Gleixner };
110f7627e25SThomas Gleixner
11110a434fcSYinghai Lu cpu_dev_register(transmeta_cpu_dev);
112