Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4) #include <linux/sched/clock.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) #include <asm/cpufeature.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <asm/msr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include "cpu.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) static void early_init_transmeta(struct cpuinfo_x86 *c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 	u32 xlvl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 	/* Transmeta-defined flags: level 0x80860001 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	xlvl = cpuid_eax(0x80860000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	if ((xlvl & 0xffff0000) == 0x80860000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 		if (xlvl >= 0x80860001)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 			c->x86_capability[CPUID_8086_0001_EDX] = cpuid_edx(0x80860001);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) static void init_transmeta(struct cpuinfo_x86 *c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	unsigned int cap_mask, uk, max, dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	unsigned int cms_rev1, cms_rev2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	unsigned int cpu_rev, cpu_freq = 0, cpu_flags, new_cpu_rev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	char cpu_info[65];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	early_init_transmeta(c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	cpu_detect_cache_sizes(c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	/* Print CMS and CPU revision */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	max = cpuid_eax(0x80860000);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	cpu_rev = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	if (max >= 0x80860001) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		cpuid(0x80860001, &dummy, &cpu_rev, &cpu_freq, &cpu_flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		if (cpu_rev != 0x02000000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 			pr_info("CPU: Processor revision %u.%u.%u.%u, %u MHz\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 				(cpu_rev >> 24) & 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 				(cpu_rev >> 16) & 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 				(cpu_rev >> 8) & 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 				cpu_rev & 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 				cpu_freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	if (max >= 0x80860002) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 		cpuid(0x80860002, &new_cpu_rev, &cms_rev1, &cms_rev2, &dummy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 		if (cpu_rev == 0x02000000) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 			pr_info("CPU: Processor revision %08X, %u MHz\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 				new_cpu_rev, cpu_freq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		pr_info("CPU: Code Morphing Software revision %u.%u.%u-%u-%u\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		       (cms_rev1 >> 24) & 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 		       (cms_rev1 >> 16) & 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		       (cms_rev1 >> 8) & 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 		       cms_rev1 & 0xff,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 		       cms_rev2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	if (max >= 0x80860006) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 		cpuid(0x80860003,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		      (void *)&cpu_info[0],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		      (void *)&cpu_info[4],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 		      (void *)&cpu_info[8],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		      (void *)&cpu_info[12]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 		cpuid(0x80860004,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		      (void *)&cpu_info[16],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		      (void *)&cpu_info[20],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		      (void *)&cpu_info[24],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		      (void *)&cpu_info[28]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 		cpuid(0x80860005,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		      (void *)&cpu_info[32],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		      (void *)&cpu_info[36],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		      (void *)&cpu_info[40],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		      (void *)&cpu_info[44]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		cpuid(0x80860006,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		      (void *)&cpu_info[48],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		      (void *)&cpu_info[52],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 		      (void *)&cpu_info[56],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		      (void *)&cpu_info[60]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		cpu_info[64] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		pr_info("CPU: %s\n", cpu_info);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	/* Unhide possibly hidden capability flags */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	rdmsr(0x80860004, cap_mask, uk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	wrmsr(0x80860004, ~0, uk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	c->x86_capability[CPUID_1_EDX] = cpuid_edx(0x00000001);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	wrmsr(0x80860004, cap_mask, uk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	/* All Transmeta CPUs have a constant TSC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) #ifdef CONFIG_SYSCTL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	 * randomize_va_space slows us down enormously;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	 * it probably triggers retranslation of x86->native bytecode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	randomize_va_space = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) static const struct cpu_dev transmeta_cpu_dev = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	.c_vendor	= "Transmeta",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	.c_ident	= { "GenuineTMx86", "TransmetaCPU" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	.c_early_init	= early_init_transmeta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	.c_init		= init_transmeta,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	.c_x86_vendor	= X86_VENDOR_TRANSMETA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) cpu_dev_register(transmeta_cpu_dev);