cpu.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. /* cpu.c: Dinky routines to look for the kind of Sparc cpu
  2. * we are on.
  3. *
  4. * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  5. */
  6. #include <linux/kernel.h>
  7. #include <linux/module.h>
  8. #include <linux/init.h>
  9. #include <linux/smp.h>
  10. #include <linux/threads.h>
  11. #include <asm/spitfire.h>
  12. #include <asm/oplib.h>
  13. #include <asm/page.h>
  14. #include <asm/head.h>
  15. #include <asm/psr.h>
  16. #include <asm/mbus.h>
  17. #include <asm/cpudata.h>
  18. #include "kernel.h"
  19. DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 };
  20. EXPORT_PER_CPU_SYMBOL(__cpu_data);
  21. struct cpu_info {
  22. int psr_vers;
  23. const char *name;
  24. };
  25. struct fpu_info {
  26. int fp_vers;
  27. const char *name;
  28. };
  29. #define NOCPU 8
  30. #define NOFPU 8
  31. struct manufacturer_info {
  32. int psr_impl;
  33. struct cpu_info cpu_info[NOCPU];
  34. struct fpu_info fpu_info[NOFPU];
  35. };
  36. #define CPU(ver, _name) \
  37. { .psr_vers = ver, .name = _name }
  38. #define FPU(ver, _name) \
  39. { .fp_vers = ver, .name = _name }
  40. static const struct manufacturer_info __initconst manufacturer_info[] = {
  41. {
  42. 0,
  43. /* Sun4/100, 4/200, SLC */
  44. .cpu_info = {
  45. CPU(0, "Fujitsu MB86900/1A or LSI L64831 SparcKIT-40"),
  46. /* borned STP1012PGA */
  47. CPU(4, "Fujitsu MB86904"),
  48. CPU(5, "Fujitsu TurboSparc MB86907"),
  49. CPU(-1, NULL)
  50. },
  51. .fpu_info = {
  52. FPU(0, "Fujitsu MB86910 or Weitek WTL1164/5"),
  53. FPU(1, "Fujitsu MB86911 or Weitek WTL1164/5 or LSI L64831"),
  54. FPU(2, "LSI Logic L64802 or Texas Instruments ACT8847"),
  55. /* SparcStation SLC, SparcStation1 */
  56. FPU(3, "Weitek WTL3170/2"),
  57. /* SPARCstation-5 */
  58. FPU(4, "Lsi Logic/Meiko L64804 or compatible"),
  59. FPU(-1, NULL)
  60. }
  61. },{
  62. 1,
  63. .cpu_info = {
  64. /* SparcStation2, SparcServer 490 & 690 */
  65. CPU(0, "LSI Logic Corporation - L64811"),
  66. /* SparcStation2 */
  67. CPU(1, "Cypress/ROSS CY7C601"),
  68. /* Embedded controller */
  69. CPU(3, "Cypress/ROSS CY7C611"),
  70. /* Ross Technologies HyperSparc */
  71. CPU(0xf, "ROSS HyperSparc RT620"),
  72. CPU(0xe, "ROSS HyperSparc RT625 or RT626"),
  73. CPU(-1, NULL)
  74. },
  75. .fpu_info = {
  76. FPU(0, "ROSS HyperSparc combined IU/FPU"),
  77. FPU(1, "Lsi Logic L64814"),
  78. FPU(2, "Texas Instruments TMS390-C602A"),
  79. FPU(3, "Cypress CY7C602 FPU"),
  80. FPU(-1, NULL)
  81. }
  82. },{
  83. 2,
  84. .cpu_info = {
  85. /* ECL Implementation, CRAY S-MP Supercomputer... AIEEE! */
  86. /* Someone please write the code to support this beast! ;) */
  87. CPU(0, "Bipolar Integrated Technology - B5010"),
  88. CPU(-1, NULL)
  89. },
  90. .fpu_info = {
  91. FPU(-1, NULL)
  92. }
  93. },{
  94. 3,
  95. .cpu_info = {
  96. CPU(0, "LSI Logic Corporation - unknown-type"),
  97. CPU(-1, NULL)
  98. },
  99. .fpu_info = {
  100. FPU(-1, NULL)
  101. }
  102. },{
  103. 4,
  104. .cpu_info = {
  105. CPU(0, "Texas Instruments, Inc. - SuperSparc-(II)"),
  106. /* SparcClassic -- borned STP1010TAB-50*/
  107. CPU(1, "Texas Instruments, Inc. - MicroSparc"),
  108. CPU(2, "Texas Instruments, Inc. - MicroSparc II"),
  109. CPU(3, "Texas Instruments, Inc. - SuperSparc 51"),
  110. CPU(4, "Texas Instruments, Inc. - SuperSparc 61"),
  111. CPU(5, "Texas Instruments, Inc. - unknown"),
  112. CPU(-1, NULL)
  113. },
  114. .fpu_info = {
  115. /* SuperSparc 50 module */
  116. FPU(0, "SuperSparc on-chip FPU"),
  117. /* SparcClassic */
  118. FPU(4, "TI MicroSparc on chip FPU"),
  119. FPU(-1, NULL)
  120. }
  121. },{
  122. 5,
  123. .cpu_info = {
  124. CPU(0, "Matsushita - MN10501"),
  125. CPU(-1, NULL)
  126. },
  127. .fpu_info = {
  128. FPU(0, "Matsushita MN10501"),
  129. FPU(-1, NULL)
  130. }
  131. },{
  132. 6,
  133. .cpu_info = {
  134. CPU(0, "Philips Corporation - unknown"),
  135. CPU(-1, NULL)
  136. },
  137. .fpu_info = {
  138. FPU(-1, NULL)
  139. }
  140. },{
  141. 7,
  142. .cpu_info = {
  143. CPU(0, "Harvest VLSI Design Center, Inc. - unknown"),
  144. CPU(-1, NULL)
  145. },
  146. .fpu_info = {
  147. FPU(-1, NULL)
  148. }
  149. },{
  150. 8,
  151. .cpu_info = {
  152. CPU(0, "Systems and Processes Engineering Corporation (SPEC)"),
  153. CPU(-1, NULL)
  154. },
  155. .fpu_info = {
  156. FPU(-1, NULL)
  157. }
  158. },{
  159. 9,
  160. .cpu_info = {
  161. /* Gallium arsenide 200MHz, BOOOOGOOOOMIPS!!! */
  162. CPU(0, "Fujitsu or Weitek Power-UP"),
  163. CPU(1, "Fujitsu or Weitek Power-UP"),
  164. CPU(2, "Fujitsu or Weitek Power-UP"),
  165. CPU(3, "Fujitsu or Weitek Power-UP"),
  166. CPU(-1, NULL)
  167. },
  168. .fpu_info = {
  169. FPU(3, "Fujitsu or Weitek on-chip FPU"),
  170. FPU(-1, NULL)
  171. }
  172. },{
  173. 0x17,
  174. .cpu_info = {
  175. CPU(0x10, "TI UltraSparc I (SpitFire)"),
  176. CPU(0x11, "TI UltraSparc II (BlackBird)"),
  177. CPU(0x12, "TI UltraSparc IIi (Sabre)"),
  178. CPU(0x13, "TI UltraSparc IIe (Hummingbird)"),
  179. CPU(-1, NULL)
  180. },
  181. .fpu_info = {
  182. FPU(0x10, "UltraSparc I integrated FPU"),
  183. FPU(0x11, "UltraSparc II integrated FPU"),
  184. FPU(0x12, "UltraSparc IIi integrated FPU"),
  185. FPU(0x13, "UltraSparc IIe integrated FPU"),
  186. FPU(-1, NULL)
  187. }
  188. },{
  189. 0x22,
  190. .cpu_info = {
  191. CPU(0x10, "TI UltraSparc I (SpitFire)"),
  192. CPU(-1, NULL)
  193. },
  194. .fpu_info = {
  195. FPU(0x10, "UltraSparc I integrated FPU"),
  196. FPU(-1, NULL)
  197. }
  198. },{
  199. 0x3e,
  200. .cpu_info = {
  201. CPU(0x14, "TI UltraSparc III (Cheetah)"),
  202. CPU(0x15, "TI UltraSparc III+ (Cheetah+)"),
  203. CPU(0x16, "TI UltraSparc IIIi (Jalapeno)"),
  204. CPU(0x18, "TI UltraSparc IV (Jaguar)"),
  205. CPU(0x19, "TI UltraSparc IV+ (Panther)"),
  206. CPU(0x22, "TI UltraSparc IIIi+ (Serrano)"),
  207. CPU(-1, NULL)
  208. },
  209. .fpu_info = {
  210. FPU(0x14, "UltraSparc III integrated FPU"),
  211. FPU(0x15, "UltraSparc III+ integrated FPU"),
  212. FPU(0x16, "UltraSparc IIIi integrated FPU"),
  213. FPU(0x18, "UltraSparc IV integrated FPU"),
  214. FPU(0x19, "UltraSparc IV+ integrated FPU"),
  215. FPU(0x22, "UltraSparc IIIi+ integrated FPU"),
  216. FPU(-1, NULL)
  217. }
  218. }};
  219. /* In order to get the fpu type correct, you need to take the IDPROM's
  220. * machine type value into consideration too. I will fix this.
  221. */
  222. const char *sparc_cpu_type;
  223. const char *sparc_fpu_type;
  224. unsigned int fsr_storage;
  225. static void set_cpu_and_fpu(int psr_impl, int psr_vers, int fpu_vers)
  226. {
  227. sparc_cpu_type = NULL;
  228. sparc_fpu_type = NULL;
  229. if (psr_impl < ARRAY_SIZE(manufacturer_info))
  230. {
  231. const struct cpu_info *cpu;
  232. const struct fpu_info *fpu;
  233. cpu = &manufacturer_info[psr_impl].cpu_info[0];
  234. while (cpu->psr_vers != -1)
  235. {
  236. if (cpu->psr_vers == psr_vers) {
  237. sparc_cpu_type = cpu->name;
  238. sparc_fpu_type = "No FPU";
  239. break;
  240. }
  241. cpu++;
  242. }
  243. fpu = &manufacturer_info[psr_impl].fpu_info[0];
  244. while (fpu->fp_vers != -1)
  245. {
  246. if (fpu->fp_vers == fpu_vers) {
  247. sparc_fpu_type = fpu->name;
  248. break;
  249. }
  250. fpu++;
  251. }
  252. }
  253. if (sparc_cpu_type == NULL)
  254. {
  255. printk(KERN_ERR "CPU: Unknown chip, impl[0x%x] vers[0x%x]\n",
  256. psr_impl, psr_vers);
  257. sparc_cpu_type = "Unknown CPU";
  258. }
  259. if (sparc_fpu_type == NULL)
  260. {
  261. printk(KERN_ERR "FPU: Unknown chip, impl[0x%x] vers[0x%x]\n",
  262. psr_impl, fpu_vers);
  263. sparc_fpu_type = "Unknown FPU";
  264. }
  265. }
  266. #ifdef CONFIG_SPARC32
  267. void __cpuinit cpu_probe(void)
  268. {
  269. int psr_impl, psr_vers, fpu_vers;
  270. int psr;
  271. psr_impl = ((get_psr() >> 28) & 0xf);
  272. psr_vers = ((get_psr() >> 24) & 0xf);
  273. psr = get_psr();
  274. put_psr(psr | PSR_EF);
  275. fpu_vers = ((get_fsr() >> 17) & 0x7);
  276. put_psr(psr);
  277. set_cpu_and_fpu(psr_impl, psr_vers, fpu_vers);
  278. }
  279. #else
  280. static void __init sun4v_cpu_probe(void)
  281. {
  282. switch (sun4v_chip_type) {
  283. case SUN4V_CHIP_NIAGARA1:
  284. sparc_cpu_type = "UltraSparc T1 (Niagara)";
  285. sparc_fpu_type = "UltraSparc T1 integrated FPU";
  286. break;
  287. case SUN4V_CHIP_NIAGARA2:
  288. sparc_cpu_type = "UltraSparc T2 (Niagara2)";
  289. sparc_fpu_type = "UltraSparc T2 integrated FPU";
  290. break;
  291. default:
  292. printk(KERN_WARNING "CPU: Unknown sun4v cpu type [%s]\n",
  293. prom_cpu_compatible);
  294. sparc_cpu_type = "Unknown SUN4V CPU";
  295. sparc_fpu_type = "Unknown SUN4V FPU";
  296. break;
  297. }
  298. }
  299. static int __init cpu_type_probe(void)
  300. {
  301. if (tlb_type == hypervisor) {
  302. sun4v_cpu_probe();
  303. } else {
  304. unsigned long ver;
  305. int manuf, impl;
  306. __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
  307. manuf = ((ver >> 48) & 0xffff);
  308. impl = ((ver >> 32) & 0xffff);
  309. set_cpu_and_fpu(manuf, impl, impl);
  310. }
  311. return 0;
  312. }
  313. arch_initcall(cpu_type_probe);
  314. #endif