cpu.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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/config.h>
  7. #include <linux/kernel.h>
  8. #include <linux/init.h>
  9. #include <linux/sched.h>
  10. #include <linux/smp.h>
  11. #include <asm/asi.h>
  12. #include <asm/system.h>
  13. #include <asm/fpumacro.h>
  14. #include <asm/cpudata.h>
  15. DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 };
  16. struct cpu_iu_info {
  17. short manuf;
  18. short impl;
  19. char* cpu_name; /* should be enough I hope... */
  20. };
  21. struct cpu_fp_info {
  22. short manuf;
  23. short impl;
  24. char fpu_vers;
  25. char* fp_name;
  26. };
  27. struct cpu_fp_info linux_sparc_fpu[] = {
  28. { 0x17, 0x10, 0, "UltraSparc I integrated FPU"},
  29. { 0x22, 0x10, 0, "UltraSparc I integrated FPU"},
  30. { 0x17, 0x11, 0, "UltraSparc II integrated FPU"},
  31. { 0x17, 0x12, 0, "UltraSparc IIi integrated FPU"},
  32. { 0x17, 0x13, 0, "UltraSparc IIe integrated FPU"},
  33. { 0x3e, 0x14, 0, "UltraSparc III integrated FPU"},
  34. { 0x3e, 0x15, 0, "UltraSparc III+ integrated FPU"},
  35. { 0x3e, 0x16, 0, "UltraSparc IIIi integrated FPU"},
  36. { 0x3e, 0x18, 0, "UltraSparc IV integrated FPU"},
  37. };
  38. #define NSPARCFPU (sizeof(linux_sparc_fpu)/sizeof(struct cpu_fp_info))
  39. struct cpu_iu_info linux_sparc_chips[] = {
  40. { 0x17, 0x10, "TI UltraSparc I (SpitFire)"},
  41. { 0x22, 0x10, "TI UltraSparc I (SpitFire)"},
  42. { 0x17, 0x11, "TI UltraSparc II (BlackBird)"},
  43. { 0x17, 0x12, "TI UltraSparc IIi (Sabre)"},
  44. { 0x17, 0x13, "TI UltraSparc IIe (Hummingbird)"},
  45. { 0x3e, 0x14, "TI UltraSparc III (Cheetah)"},
  46. { 0x3e, 0x15, "TI UltraSparc III+ (Cheetah+)"},
  47. { 0x3e, 0x16, "TI UltraSparc IIIi (Jalapeno)"},
  48. { 0x3e, 0x18, "TI UltraSparc IV (Jaguar)"},
  49. };
  50. #define NSPARCCHIPS (sizeof(linux_sparc_chips)/sizeof(struct cpu_iu_info))
  51. char *sparc_cpu_type = "cpu-oops";
  52. char *sparc_fpu_type = "fpu-oops";
  53. unsigned int fsr_storage;
  54. void __init cpu_probe(void)
  55. {
  56. unsigned long ver, fpu_vers, manuf, impl, fprs;
  57. int i;
  58. fprs = fprs_read();
  59. fprs_write(FPRS_FEF);
  60. __asm__ __volatile__ ("rdpr %%ver, %0; stx %%fsr, [%1]"
  61. : "=&r" (ver)
  62. : "r" (&fpu_vers));
  63. fprs_write(fprs);
  64. manuf = ((ver >> 48) & 0xffff);
  65. impl = ((ver >> 32) & 0xffff);
  66. fpu_vers = ((fpu_vers >> 17) & 0x7);
  67. retry:
  68. for (i = 0; i < NSPARCCHIPS; i++) {
  69. if (linux_sparc_chips[i].manuf == manuf) {
  70. if (linux_sparc_chips[i].impl == impl) {
  71. sparc_cpu_type =
  72. linux_sparc_chips[i].cpu_name;
  73. break;
  74. }
  75. }
  76. }
  77. if (i == NSPARCCHIPS) {
  78. /* Maybe it is a cheetah+ derivative, report it as cheetah+
  79. * in that case until we learn the real names.
  80. */
  81. if (manuf == 0x3e &&
  82. impl > 0x15) {
  83. impl = 0x15;
  84. goto retry;
  85. } else {
  86. printk("DEBUG: manuf[%lx] impl[%lx]\n",
  87. manuf, impl);
  88. }
  89. sparc_cpu_type = "Unknown CPU";
  90. }
  91. for (i = 0; i < NSPARCFPU; i++) {
  92. if (linux_sparc_fpu[i].manuf == manuf &&
  93. linux_sparc_fpu[i].impl == impl) {
  94. if (linux_sparc_fpu[i].fpu_vers == fpu_vers) {
  95. sparc_fpu_type =
  96. linux_sparc_fpu[i].fp_name;
  97. break;
  98. }
  99. }
  100. }
  101. if (i == NSPARCFPU) {
  102. printk("DEBUG: manuf[%lx] impl[%lx] fsr.vers[%lx]\n",
  103. manuf, impl, fpu_vers);
  104. sparc_fpu_type = "Unknown FPU";
  105. }
  106. }