cpu.c 8.1 KB

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