cpu.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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/seq_file.h>
  7. #include <linux/kernel.h>
  8. #include <linux/module.h>
  9. #include <linux/init.h>
  10. #include <linux/smp.h>
  11. #include <linux/threads.h>
  12. #include <asm/spitfire.h>
  13. #include <asm/pgtable.h>
  14. #include <asm/oplib.h>
  15. #include <asm/setup.h>
  16. #include <asm/page.h>
  17. #include <asm/head.h>
  18. #include <asm/psr.h>
  19. #include <asm/mbus.h>
  20. #include <asm/cpudata.h>
  21. #include "kernel.h"
  22. DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 };
  23. EXPORT_PER_CPU_SYMBOL(__cpu_data);
  24. int ncpus_probed;
  25. unsigned int fsr_storage;
  26. struct cpu_info {
  27. int psr_vers;
  28. const char *name;
  29. const char *pmu_name;
  30. };
  31. struct fpu_info {
  32. int fp_vers;
  33. const char *name;
  34. };
  35. #define NOCPU 8
  36. #define NOFPU 8
  37. struct manufacturer_info {
  38. int psr_impl;
  39. struct cpu_info cpu_info[NOCPU];
  40. struct fpu_info fpu_info[NOFPU];
  41. };
  42. #define CPU(ver, _name) \
  43. { .psr_vers = ver, .name = _name }
  44. #define CPU_PMU(ver, _name, _pmu_name) \
  45. { .psr_vers = ver, .name = _name, .pmu_name = _pmu_name }
  46. #define FPU(ver, _name) \
  47. { .fp_vers = ver, .name = _name }
  48. static const struct manufacturer_info __initconst manufacturer_info[] = {
  49. {
  50. 0,
  51. /* Sun4/100, 4/200, SLC */
  52. .cpu_info = {
  53. CPU(0, "Fujitsu MB86900/1A or LSI L64831 SparcKIT-40"),
  54. /* borned STP1012PGA */
  55. CPU(4, "Fujitsu MB86904"),
  56. CPU(5, "Fujitsu TurboSparc MB86907"),
  57. CPU(-1, NULL)
  58. },
  59. .fpu_info = {
  60. FPU(0, "Fujitsu MB86910 or Weitek WTL1164/5"),
  61. FPU(1, "Fujitsu MB86911 or Weitek WTL1164/5 or LSI L64831"),
  62. FPU(2, "LSI Logic L64802 or Texas Instruments ACT8847"),
  63. /* SparcStation SLC, SparcStation1 */
  64. FPU(3, "Weitek WTL3170/2"),
  65. /* SPARCstation-5 */
  66. FPU(4, "Lsi Logic/Meiko L64804 or compatible"),
  67. FPU(-1, NULL)
  68. }
  69. },{
  70. 1,
  71. .cpu_info = {
  72. /* SparcStation2, SparcServer 490 & 690 */
  73. CPU(0, "LSI Logic Corporation - L64811"),
  74. /* SparcStation2 */
  75. CPU(1, "Cypress/ROSS CY7C601"),
  76. /* Embedded controller */
  77. CPU(3, "Cypress/ROSS CY7C611"),
  78. /* Ross Technologies HyperSparc */
  79. CPU(0xf, "ROSS HyperSparc RT620"),
  80. CPU(0xe, "ROSS HyperSparc RT625 or RT626"),
  81. CPU(-1, NULL)
  82. },
  83. .fpu_info = {
  84. FPU(0, "ROSS HyperSparc combined IU/FPU"),
  85. FPU(1, "Lsi Logic L64814"),
  86. FPU(2, "Texas Instruments TMS390-C602A"),
  87. FPU(3, "Cypress CY7C602 FPU"),
  88. FPU(-1, NULL)
  89. }
  90. },{
  91. 2,
  92. .cpu_info = {
  93. /* ECL Implementation, CRAY S-MP Supercomputer... AIEEE! */
  94. /* Someone please write the code to support this beast! ;) */
  95. CPU(0, "Bipolar Integrated Technology - B5010"),
  96. CPU(-1, NULL)
  97. },
  98. .fpu_info = {
  99. FPU(-1, NULL)
  100. }
  101. },{
  102. 3,
  103. .cpu_info = {
  104. CPU(0, "LSI Logic Corporation - unknown-type"),
  105. CPU(-1, NULL)
  106. },
  107. .fpu_info = {
  108. FPU(-1, NULL)
  109. }
  110. },{
  111. 4,
  112. .cpu_info = {
  113. CPU(0, "Texas Instruments, Inc. - SuperSparc-(II)"),
  114. /* SparcClassic -- borned STP1010TAB-50*/
  115. CPU(1, "Texas Instruments, Inc. - MicroSparc"),
  116. CPU(2, "Texas Instruments, Inc. - MicroSparc II"),
  117. CPU(3, "Texas Instruments, Inc. - SuperSparc 51"),
  118. CPU(4, "Texas Instruments, Inc. - SuperSparc 61"),
  119. CPU(5, "Texas Instruments, Inc. - unknown"),
  120. CPU(-1, NULL)
  121. },
  122. .fpu_info = {
  123. /* SuperSparc 50 module */
  124. FPU(0, "SuperSparc on-chip FPU"),
  125. /* SparcClassic */
  126. FPU(4, "TI MicroSparc on chip FPU"),
  127. FPU(-1, NULL)
  128. }
  129. },{
  130. 5,
  131. .cpu_info = {
  132. CPU(0, "Matsushita - MN10501"),
  133. CPU(-1, NULL)
  134. },
  135. .fpu_info = {
  136. FPU(0, "Matsushita MN10501"),
  137. FPU(-1, NULL)
  138. }
  139. },{
  140. 6,
  141. .cpu_info = {
  142. CPU(0, "Philips Corporation - unknown"),
  143. CPU(-1, NULL)
  144. },
  145. .fpu_info = {
  146. FPU(-1, NULL)
  147. }
  148. },{
  149. 7,
  150. .cpu_info = {
  151. CPU(0, "Harvest VLSI Design Center, Inc. - unknown"),
  152. CPU(-1, NULL)
  153. },
  154. .fpu_info = {
  155. FPU(-1, NULL)
  156. }
  157. },{
  158. 8,
  159. .cpu_info = {
  160. CPU(0, "Systems and Processes Engineering Corporation (SPEC)"),
  161. CPU(-1, NULL)
  162. },
  163. .fpu_info = {
  164. FPU(-1, NULL)
  165. }
  166. },{
  167. 9,
  168. .cpu_info = {
  169. /* Gallium arsenide 200MHz, BOOOOGOOOOMIPS!!! */
  170. CPU(0, "Fujitsu or Weitek Power-UP"),
  171. CPU(1, "Fujitsu or Weitek Power-UP"),
  172. CPU(2, "Fujitsu or Weitek Power-UP"),
  173. CPU(3, "Fujitsu or Weitek Power-UP"),
  174. CPU(-1, NULL)
  175. },
  176. .fpu_info = {
  177. FPU(3, "Fujitsu or Weitek on-chip FPU"),
  178. FPU(-1, NULL)
  179. }
  180. },{
  181. 0xF, /* Aeroflex Gaisler */
  182. .cpu_info = {
  183. CPU(3, "LEON"),
  184. CPU(-1, NULL)
  185. },
  186. .fpu_info = {
  187. FPU(2, "GRFPU"),
  188. FPU(3, "GRFPU-Lite"),
  189. FPU(-1, NULL)
  190. }
  191. },{
  192. 0x17,
  193. .cpu_info = {
  194. CPU_PMU(0x10, "TI UltraSparc I (SpitFire)", "ultra12"),
  195. CPU_PMU(0x11, "TI UltraSparc II (BlackBird)", "ultra12"),
  196. CPU_PMU(0x12, "TI UltraSparc IIi (Sabre)", "ultra12"),
  197. CPU_PMU(0x13, "TI UltraSparc IIe (Hummingbird)", "ultra12"),
  198. CPU(-1, NULL)
  199. },
  200. .fpu_info = {
  201. FPU(0x10, "UltraSparc I integrated FPU"),
  202. FPU(0x11, "UltraSparc II integrated FPU"),
  203. FPU(0x12, "UltraSparc IIi integrated FPU"),
  204. FPU(0x13, "UltraSparc IIe integrated FPU"),
  205. FPU(-1, NULL)
  206. }
  207. },{
  208. 0x22,
  209. .cpu_info = {
  210. CPU_PMU(0x10, "TI UltraSparc I (SpitFire)", "ultra12"),
  211. CPU(-1, NULL)
  212. },
  213. .fpu_info = {
  214. FPU(0x10, "UltraSparc I integrated FPU"),
  215. FPU(-1, NULL)
  216. }
  217. },{
  218. 0x3e,
  219. .cpu_info = {
  220. CPU_PMU(0x14, "TI UltraSparc III (Cheetah)", "ultra3"),
  221. CPU_PMU(0x15, "TI UltraSparc III+ (Cheetah+)", "ultra3+"),
  222. CPU_PMU(0x16, "TI UltraSparc IIIi (Jalapeno)", "ultra3i"),
  223. CPU_PMU(0x18, "TI UltraSparc IV (Jaguar)", "ultra3+"),
  224. CPU_PMU(0x19, "TI UltraSparc IV+ (Panther)", "ultra4+"),
  225. CPU_PMU(0x22, "TI UltraSparc IIIi+ (Serrano)", "ultra3i"),
  226. CPU(-1, NULL)
  227. },
  228. .fpu_info = {
  229. FPU(0x14, "UltraSparc III integrated FPU"),
  230. FPU(0x15, "UltraSparc III+ integrated FPU"),
  231. FPU(0x16, "UltraSparc IIIi integrated FPU"),
  232. FPU(0x18, "UltraSparc IV integrated FPU"),
  233. FPU(0x19, "UltraSparc IV+ integrated FPU"),
  234. FPU(0x22, "UltraSparc IIIi+ integrated FPU"),
  235. FPU(-1, NULL)
  236. }
  237. }};
  238. /* In order to get the fpu type correct, you need to take the IDPROM's
  239. * machine type value into consideration too. I will fix this.
  240. */
  241. static const char *sparc_cpu_type;
  242. static const char *sparc_fpu_type;
  243. const char *sparc_pmu_type;
  244. static void __init set_cpu_and_fpu(int psr_impl, int psr_vers, int fpu_vers)
  245. {
  246. const struct manufacturer_info *manuf;
  247. int i;
  248. sparc_cpu_type = NULL;
  249. sparc_fpu_type = NULL;
  250. sparc_pmu_type = NULL;
  251. manuf = NULL;
  252. for (i = 0; i < ARRAY_SIZE(manufacturer_info); i++)
  253. {
  254. if (psr_impl == manufacturer_info[i].psr_impl) {
  255. manuf = &manufacturer_info[i];
  256. break;
  257. }
  258. }
  259. if (manuf != NULL)
  260. {
  261. const struct cpu_info *cpu;
  262. const struct fpu_info *fpu;
  263. cpu = &manuf->cpu_info[0];
  264. while (cpu->psr_vers != -1)
  265. {
  266. if (cpu->psr_vers == psr_vers) {
  267. sparc_cpu_type = cpu->name;
  268. sparc_pmu_type = cpu->pmu_name;
  269. sparc_fpu_type = "No FPU";
  270. break;
  271. }
  272. cpu++;
  273. }
  274. fpu = &manuf->fpu_info[0];
  275. while (fpu->fp_vers != -1)
  276. {
  277. if (fpu->fp_vers == fpu_vers) {
  278. sparc_fpu_type = fpu->name;
  279. break;
  280. }
  281. fpu++;
  282. }
  283. }
  284. if (sparc_cpu_type == NULL)
  285. {
  286. printk(KERN_ERR "CPU: Unknown chip, impl[0x%x] vers[0x%x]\n",
  287. psr_impl, psr_vers);
  288. sparc_cpu_type = "Unknown CPU";
  289. }
  290. if (sparc_fpu_type == NULL)
  291. {
  292. printk(KERN_ERR "FPU: Unknown chip, impl[0x%x] vers[0x%x]\n",
  293. psr_impl, fpu_vers);
  294. sparc_fpu_type = "Unknown FPU";
  295. }
  296. if (sparc_pmu_type == NULL)
  297. sparc_pmu_type = "Unknown PMU";
  298. }
  299. #ifdef CONFIG_SPARC32
  300. static int show_cpuinfo(struct seq_file *m, void *__unused)
  301. {
  302. seq_printf(m,
  303. "cpu\t\t: %s\n"
  304. "fpu\t\t: %s\n"
  305. "promlib\t\t: Version %d Revision %d\n"
  306. "prom\t\t: %d.%d\n"
  307. "type\t\t: %s\n"
  308. "ncpus probed\t: %d\n"
  309. "ncpus active\t: %d\n"
  310. #ifndef CONFIG_SMP
  311. "CPU0Bogo\t: %lu.%02lu\n"
  312. "CPU0ClkTck\t: %ld\n"
  313. #endif
  314. ,
  315. sparc_cpu_type,
  316. sparc_fpu_type ,
  317. romvec->pv_romvers,
  318. prom_rev,
  319. romvec->pv_printrev >> 16,
  320. romvec->pv_printrev & 0xffff,
  321. &cputypval[0],
  322. ncpus_probed,
  323. num_online_cpus()
  324. #ifndef CONFIG_SMP
  325. , cpu_data(0).udelay_val/(500000/HZ),
  326. (cpu_data(0).udelay_val/(5000/HZ)) % 100,
  327. cpu_data(0).clock_tick
  328. #endif
  329. );
  330. #ifdef CONFIG_SMP
  331. smp_bogo(m);
  332. #endif
  333. mmu_info(m);
  334. #ifdef CONFIG_SMP
  335. smp_info(m);
  336. #endif
  337. return 0;
  338. }
  339. #endif /* CONFIG_SPARC32 */
  340. #ifdef CONFIG_SPARC64
  341. unsigned int dcache_parity_tl1_occurred;
  342. unsigned int icache_parity_tl1_occurred;
  343. static int show_cpuinfo(struct seq_file *m, void *__unused)
  344. {
  345. seq_printf(m,
  346. "cpu\t\t: %s\n"
  347. "fpu\t\t: %s\n"
  348. "pmu\t\t: %s\n"
  349. "prom\t\t: %s\n"
  350. "type\t\t: %s\n"
  351. "ncpus probed\t: %d\n"
  352. "ncpus active\t: %d\n"
  353. "D$ parity tl1\t: %u\n"
  354. "I$ parity tl1\t: %u\n"
  355. #ifndef CONFIG_SMP
  356. "Cpu0ClkTck\t: %016lx\n"
  357. #endif
  358. ,
  359. sparc_cpu_type,
  360. sparc_fpu_type,
  361. sparc_pmu_type,
  362. prom_version,
  363. ((tlb_type == hypervisor) ?
  364. "sun4v" :
  365. "sun4u"),
  366. ncpus_probed,
  367. num_online_cpus(),
  368. dcache_parity_tl1_occurred,
  369. icache_parity_tl1_occurred
  370. #ifndef CONFIG_SMP
  371. , cpu_data(0).clock_tick
  372. #endif
  373. );
  374. cpucap_info(m);
  375. #ifdef CONFIG_SMP
  376. smp_bogo(m);
  377. #endif
  378. mmu_info(m);
  379. #ifdef CONFIG_SMP
  380. smp_info(m);
  381. #endif
  382. return 0;
  383. }
  384. #endif /* CONFIG_SPARC64 */
  385. static void *c_start(struct seq_file *m, loff_t *pos)
  386. {
  387. /* The pointer we are returning is arbitrary,
  388. * it just has to be non-NULL and not IS_ERR
  389. * in the success case.
  390. */
  391. return *pos == 0 ? &c_start : NULL;
  392. }
  393. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  394. {
  395. ++*pos;
  396. return c_start(m, pos);
  397. }
  398. static void c_stop(struct seq_file *m, void *v)
  399. {
  400. }
  401. const struct seq_operations cpuinfo_op = {
  402. .start =c_start,
  403. .next = c_next,
  404. .stop = c_stop,
  405. .show = show_cpuinfo,
  406. };
  407. #ifdef CONFIG_SPARC32
  408. static int __init cpu_type_probe(void)
  409. {
  410. int psr_impl, psr_vers, fpu_vers;
  411. int psr;
  412. psr_impl = ((get_psr() >> 28) & 0xf);
  413. psr_vers = ((get_psr() >> 24) & 0xf);
  414. psr = get_psr();
  415. put_psr(psr | PSR_EF);
  416. #ifdef CONFIG_SPARC_LEON
  417. fpu_vers = get_psr() & PSR_EF ? ((get_fsr() >> 17) & 0x7) : 7;
  418. #else
  419. fpu_vers = ((get_fsr() >> 17) & 0x7);
  420. #endif
  421. put_psr(psr);
  422. set_cpu_and_fpu(psr_impl, psr_vers, fpu_vers);
  423. return 0;
  424. }
  425. #endif /* CONFIG_SPARC32 */
  426. #ifdef CONFIG_SPARC64
  427. static void __init sun4v_cpu_probe(void)
  428. {
  429. switch (sun4v_chip_type) {
  430. case SUN4V_CHIP_NIAGARA1:
  431. sparc_cpu_type = "UltraSparc T1 (Niagara)";
  432. sparc_fpu_type = "UltraSparc T1 integrated FPU";
  433. sparc_pmu_type = "niagara";
  434. break;
  435. case SUN4V_CHIP_NIAGARA2:
  436. sparc_cpu_type = "UltraSparc T2 (Niagara2)";
  437. sparc_fpu_type = "UltraSparc T2 integrated FPU";
  438. sparc_pmu_type = "niagara2";
  439. break;
  440. case SUN4V_CHIP_NIAGARA3:
  441. sparc_cpu_type = "UltraSparc T3 (Niagara3)";
  442. sparc_fpu_type = "UltraSparc T3 integrated FPU";
  443. sparc_pmu_type = "niagara3";
  444. break;
  445. default:
  446. printk(KERN_WARNING "CPU: Unknown sun4v cpu type [%s]\n",
  447. prom_cpu_compatible);
  448. sparc_cpu_type = "Unknown SUN4V CPU";
  449. sparc_fpu_type = "Unknown SUN4V FPU";
  450. sparc_pmu_type = "Unknown SUN4V PMU";
  451. break;
  452. }
  453. }
  454. static int __init cpu_type_probe(void)
  455. {
  456. if (tlb_type == hypervisor) {
  457. sun4v_cpu_probe();
  458. } else {
  459. unsigned long ver;
  460. int manuf, impl;
  461. __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver));
  462. manuf = ((ver >> 48) & 0xffff);
  463. impl = ((ver >> 32) & 0xffff);
  464. set_cpu_and_fpu(manuf, impl, impl);
  465. }
  466. return 0;
  467. }
  468. #endif /* CONFIG_SPARC64 */
  469. early_initcall(cpu_type_probe);