transmeta.c 2.9 KB

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