cpu.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /* cpu.c: Dinky routines to look for the kind of Sparc cpu
  2. * we are on.
  3. *
  4. * Copyright (C) 1996, 2007, 2008 David S. Miller (davem@davemloft.net)
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/init.h>
  8. #include <linux/sched.h>
  9. #include <linux/smp.h>
  10. #include <asm/asi.h>
  11. #include <asm/system.h>
  12. #include <asm/fpumacro.h>
  13. #include <asm/cpudata.h>
  14. #include <asm/spitfire.h>
  15. #include <asm/oplib.h>
  16. #include "entry.h"
  17. DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 };
  18. struct cpu_chip_info {
  19. unsigned short manuf;
  20. unsigned short impl;
  21. const char *cpu_name;
  22. const char *fp_name;
  23. };
  24. static const struct cpu_chip_info cpu_chips[] = {
  25. {
  26. .manuf = 0x17,
  27. .impl = 0x10,
  28. .cpu_name = "TI UltraSparc I (SpitFire)",
  29. .fp_name = "UltraSparc I integrated FPU",
  30. },
  31. {
  32. .manuf = 0x22,
  33. .impl = 0x10,
  34. .cpu_name = "TI UltraSparc I (SpitFire)",
  35. .fp_name = "UltraSparc I integrated FPU",
  36. },
  37. {
  38. .manuf = 0x17,
  39. .impl = 0x11,
  40. .cpu_name = "TI UltraSparc II (BlackBird)",
  41. .fp_name = "UltraSparc II integrated FPU",
  42. },
  43. {
  44. .manuf = 0x17,
  45. .impl = 0x12,
  46. .cpu_name = "TI UltraSparc IIi (Sabre)",
  47. .fp_name = "UltraSparc IIi integrated FPU",
  48. },
  49. {
  50. .manuf = 0x17,
  51. .impl = 0x13,
  52. .cpu_name = "TI UltraSparc IIe (Hummingbird)",
  53. .fp_name = "UltraSparc IIe integrated FPU",
  54. },
  55. {
  56. .manuf = 0x3e,
  57. .impl = 0x14,
  58. .cpu_name = "TI UltraSparc III (Cheetah)",
  59. .fp_name = "UltraSparc III integrated FPU",
  60. },
  61. {
  62. .manuf = 0x3e,
  63. .impl = 0x15,
  64. .cpu_name = "TI UltraSparc III+ (Cheetah+)",
  65. .fp_name = "UltraSparc III+ integrated FPU",
  66. },
  67. {
  68. .manuf = 0x3e,
  69. .impl = 0x16,
  70. .cpu_name = "TI UltraSparc IIIi (Jalapeno)",
  71. .fp_name = "UltraSparc IIIi integrated FPU",
  72. },
  73. {
  74. .manuf = 0x3e,
  75. .impl = 0x18,
  76. .cpu_name = "TI UltraSparc IV (Jaguar)",
  77. .fp_name = "UltraSparc IV integrated FPU",
  78. },
  79. {
  80. .manuf = 0x3e,
  81. .impl = 0x19,
  82. .cpu_name = "TI UltraSparc IV+ (Panther)",
  83. .fp_name = "UltraSparc IV+ integrated FPU",
  84. },
  85. {
  86. .manuf = 0x3e,
  87. .impl = 0x22,
  88. .cpu_name = "TI UltraSparc IIIi+ (Serrano)",
  89. .fp_name = "UltraSparc IIIi+ integrated FPU",
  90. },
  91. };
  92. #define NSPARCCHIPS ARRAY_SIZE(linux_sparc_chips)
  93. const char *sparc_cpu_type;
  94. const char *sparc_fpu_type;
  95. static void __init sun4v_cpu_probe(void)
  96. {
  97. switch (sun4v_chip_type) {
  98. case SUN4V_CHIP_NIAGARA1:
  99. sparc_cpu_type = "UltraSparc T1 (Niagara)";
  100. sparc_fpu_type = "UltraSparc T1 integrated FPU";
  101. break;
  102. case SUN4V_CHIP_NIAGARA2:
  103. sparc_cpu_type = "UltraSparc T2 (Niagara2)";
  104. sparc_fpu_type = "UltraSparc T2 integrated FPU";
  105. break;
  106. default:
  107. printk(KERN_WARNING "CPU: Unknown sun4v cpu type [%s]\n",
  108. prom_cpu_compatible);
  109. sparc_cpu_type = "Unknown SUN4V CPU";
  110. sparc_fpu_type = "Unknown SUN4V FPU";
  111. break;
  112. }
  113. }
  114. static const struct cpu_chip_info * __init find_cpu_chip(unsigned short manuf,
  115. unsigned short impl)
  116. {
  117. int i;
  118. for (i = 0; i < ARRAY_SIZE(cpu_chips); i++) {
  119. const struct cpu_chip_info *p = &cpu_chips[i];
  120. if (p->manuf == manuf && p->impl == impl)
  121. return p;
  122. }
  123. return NULL;
  124. }
  125. static int __init cpu_type_probe(void)
  126. {
  127. if (tlb_type == hypervisor) {
  128. sun4v_cpu_probe();
  129. } else {
  130. unsigned long ver, manuf, impl;
  131. const struct cpu_chip_info *p;
  132. __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
  133. manuf = ((ver >> 48) & 0xffff);
  134. impl = ((ver >> 32) & 0xffff);
  135. p = find_cpu_chip(manuf, impl);
  136. if (p) {
  137. sparc_cpu_type = p->cpu_name;
  138. sparc_fpu_type = p->fp_name;
  139. } else {
  140. printk(KERN_ERR "CPU: Unknown chip, manuf[%lx] impl[%lx]\n",
  141. manuf, impl);
  142. sparc_cpu_type = "Unknown CPU";
  143. sparc_fpu_type = "Unknown FPU";
  144. }
  145. }
  146. return 0;
  147. }
  148. arch_initcall(cpu_type_probe);