cpu.c 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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. 0xF, /* Aeroflex Gaisler */
  177. .cpu_info = {
  178. CPU(3, "LEON"),
  179. CPU(-1, NULL)
  180. },
  181. .fpu_info = {
  182. FPU(2, "GRFPU"),
  183. FPU(3, "GRFPU-Lite"),
  184. FPU(-1, NULL)
  185. }
  186. },{
  187. 0x17,
  188. .cpu_info = {
  189. CPU_PMU(0x10, "TI UltraSparc I (SpitFire)", "ultra12"),
  190. CPU_PMU(0x11, "TI UltraSparc II (BlackBird)", "ultra12"),
  191. CPU_PMU(0x12, "TI UltraSparc IIi (Sabre)", "ultra12"),
  192. CPU_PMU(0x13, "TI UltraSparc IIe (Hummingbird)", "ultra12"),
  193. CPU(-1, NULL)
  194. },
  195. .fpu_info = {
  196. FPU(0x10, "UltraSparc I integrated FPU"),
  197. FPU(0x11, "UltraSparc II integrated FPU"),
  198. FPU(0x12, "UltraSparc IIi integrated FPU"),
  199. FPU(0x13, "UltraSparc IIe integrated FPU"),
  200. FPU(-1, NULL)
  201. }
  202. },{
  203. 0x22,
  204. .cpu_info = {
  205. CPU_PMU(0x10, "TI UltraSparc I (SpitFire)", "ultra12"),
  206. CPU(-1, NULL)
  207. },
  208. .fpu_info = {
  209. FPU(0x10, "UltraSparc I integrated FPU"),
  210. FPU(-1, NULL)
  211. }
  212. },{
  213. 0x3e,
  214. .cpu_info = {
  215. CPU_PMU(0x14, "TI UltraSparc III (Cheetah)", "ultra3"),
  216. CPU_PMU(0x15, "TI UltraSparc III+ (Cheetah+)", "ultra3+"),
  217. CPU_PMU(0x16, "TI UltraSparc IIIi (Jalapeno)", "ultra3i"),
  218. CPU_PMU(0x18, "TI UltraSparc IV (Jaguar)", "ultra3+"),
  219. CPU_PMU(0x19, "TI UltraSparc IV+ (Panther)", "ultra4+"),
  220. CPU_PMU(0x22, "TI UltraSparc IIIi+ (Serrano)", "ultra3i"),
  221. CPU(-1, NULL)
  222. },
  223. .fpu_info = {
  224. FPU(0x14, "UltraSparc III integrated FPU"),
  225. FPU(0x15, "UltraSparc III+ integrated FPU"),
  226. FPU(0x16, "UltraSparc IIIi integrated FPU"),
  227. FPU(0x18, "UltraSparc IV integrated FPU"),
  228. FPU(0x19, "UltraSparc IV+ integrated FPU"),
  229. FPU(0x22, "UltraSparc IIIi+ integrated FPU"),
  230. FPU(-1, NULL)
  231. }
  232. }};
  233. /* In order to get the fpu type correct, you need to take the IDPROM's
  234. * machine type value into consideration too. I will fix this.
  235. */
  236. const char *sparc_cpu_type;
  237. const char *sparc_fpu_type;
  238. const char *sparc_pmu_type;
  239. unsigned int fsr_storage;
  240. static void set_cpu_and_fpu(int psr_impl, int psr_vers, int fpu_vers)
  241. {
  242. const struct manufacturer_info *manuf;
  243. int i;
  244. sparc_cpu_type = NULL;
  245. sparc_fpu_type = NULL;
  246. sparc_pmu_type = NULL;
  247. manuf = NULL;
  248. for (i = 0; i < ARRAY_SIZE(manufacturer_info); i++)
  249. {
  250. if (psr_impl == manufacturer_info[i].psr_impl) {
  251. manuf = &manufacturer_info[i];
  252. break;
  253. }
  254. }
  255. if (manuf != NULL)
  256. {
  257. const struct cpu_info *cpu;
  258. const struct fpu_info *fpu;
  259. cpu = &manuf->cpu_info[0];
  260. while (cpu->psr_vers != -1)
  261. {
  262. if (cpu->psr_vers == psr_vers) {
  263. sparc_cpu_type = cpu->name;
  264. sparc_pmu_type = cpu->pmu_name;
  265. sparc_fpu_type = "No FPU";
  266. break;
  267. }
  268. cpu++;
  269. }
  270. fpu = &manuf->fpu_info[0];
  271. while (fpu->fp_vers != -1)
  272. {
  273. if (fpu->fp_vers == fpu_vers) {
  274. sparc_fpu_type = fpu->name;
  275. break;
  276. }
  277. fpu++;
  278. }
  279. }
  280. if (sparc_cpu_type == NULL)
  281. {
  282. printk(KERN_ERR "CPU: Unknown chip, impl[0x%x] vers[0x%x]\n",
  283. psr_impl, psr_vers);
  284. sparc_cpu_type = "Unknown CPU";
  285. }
  286. if (sparc_fpu_type == NULL)
  287. {
  288. printk(KERN_ERR "FPU: Unknown chip, impl[0x%x] vers[0x%x]\n",
  289. psr_impl, fpu_vers);
  290. sparc_fpu_type = "Unknown FPU";
  291. }
  292. if (sparc_pmu_type == NULL)
  293. sparc_pmu_type = "Unknown PMU";
  294. }
  295. #ifdef CONFIG_SPARC32
  296. void __cpuinit cpu_probe(void)
  297. {
  298. int psr_impl, psr_vers, fpu_vers;
  299. int psr;
  300. psr_impl = ((get_psr() >> 28) & 0xf);
  301. psr_vers = ((get_psr() >> 24) & 0xf);
  302. psr = get_psr();
  303. put_psr(psr | PSR_EF);
  304. #ifdef CONFIG_SPARC_LEON
  305. fpu_vers = 7;
  306. #else
  307. fpu_vers = ((get_fsr() >> 17) & 0x7);
  308. #endif
  309. put_psr(psr);
  310. set_cpu_and_fpu(psr_impl, psr_vers, fpu_vers);
  311. }
  312. #else
  313. static void __init sun4v_cpu_probe(void)
  314. {
  315. switch (sun4v_chip_type) {
  316. case SUN4V_CHIP_NIAGARA1:
  317. sparc_cpu_type = "UltraSparc T1 (Niagara)";
  318. sparc_fpu_type = "UltraSparc T1 integrated FPU";
  319. sparc_pmu_type = "niagara";
  320. break;
  321. case SUN4V_CHIP_NIAGARA2:
  322. sparc_cpu_type = "UltraSparc T2 (Niagara2)";
  323. sparc_fpu_type = "UltraSparc T2 integrated FPU";
  324. sparc_pmu_type = "niagara2";
  325. break;
  326. default:
  327. printk(KERN_WARNING "CPU: Unknown sun4v cpu type [%s]\n",
  328. prom_cpu_compatible);
  329. sparc_cpu_type = "Unknown SUN4V CPU";
  330. sparc_fpu_type = "Unknown SUN4V FPU";
  331. break;
  332. }
  333. }
  334. static int __init cpu_type_probe(void)
  335. {
  336. if (tlb_type == hypervisor) {
  337. sun4v_cpu_probe();
  338. } else {
  339. unsigned long ver;
  340. int manuf, impl;
  341. __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
  342. manuf = ((ver >> 48) & 0xffff);
  343. impl = ((ver >> 32) & 0xffff);
  344. set_cpu_and_fpu(manuf, impl, impl);
  345. }
  346. return 0;
  347. }
  348. early_initcall(cpu_type_probe);
  349. #endif