mb.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /*
  2. * CPU-version specific code
  3. *
  4. * Copyright (C) 2007-2009 Michal Simek <[email protected]>
  5. * Copyright (C) 2006-2009 PetaLogix
  6. *
  7. * This file is subject to the terms and conditions of the GNU General Public
  8. * License. See the file "COPYING" in the main directory of this archive
  9. * for more details.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/string.h>
  13. #include <linux/seq_file.h>
  14. #include <linux/cpu.h>
  15. #include <linux/initrd.h>
  16. #include <linux/bug.h>
  17. #include <asm/cpuinfo.h>
  18. #include <linux/delay.h>
  19. #include <linux/io.h>
  20. #include <asm/page.h>
  21. #include <linux/param.h>
  22. #include <asm/pvr.h>
  23. #include <asm/sections.h>
  24. #include <asm/setup.h>
  25. static int show_cpuinfo(struct seq_file *m, void *v)
  26. {
  27. char *fpga_family = "Unknown";
  28. char *cpu_ver = "Unknown";
  29. int i;
  30. /* Denormalised to get the fpga family string */
  31. for (i = 0; family_string_lookup[i].s != NULL; i++) {
  32. if (cpuinfo.fpga_family_code == family_string_lookup[i].k) {
  33. fpga_family = (char *)family_string_lookup[i].s;
  34. break;
  35. }
  36. }
  37. /* Denormalised to get the hw version string */
  38. for (i = 0; cpu_ver_lookup[i].s != NULL; i++) {
  39. if (cpuinfo.ver_code == cpu_ver_lookup[i].k) {
  40. cpu_ver = (char *)cpu_ver_lookup[i].s;
  41. break;
  42. }
  43. }
  44. seq_printf(m,
  45. "CPU-Family: MicroBlaze\n"
  46. "FPGA-Arch: %s\n"
  47. "CPU-Ver: %s, %s endian\n"
  48. "CPU-MHz: %d.%02d\n"
  49. "BogoMips: %lu.%02lu\n",
  50. fpga_family,
  51. cpu_ver,
  52. cpuinfo.endian ? "little" : "big",
  53. cpuinfo.cpu_clock_freq / 1000000,
  54. cpuinfo.cpu_clock_freq % 1000000,
  55. loops_per_jiffy / (500000 / HZ),
  56. (loops_per_jiffy / (5000 / HZ)) % 100);
  57. seq_printf(m,
  58. "HW:\n Shift:\t\t%s\n"
  59. " MSR:\t\t%s\n"
  60. " PCMP:\t\t%s\n"
  61. " DIV:\t\t%s\n",
  62. (cpuinfo.use_instr & PVR0_USE_BARREL_MASK) ? "yes" : "no",
  63. (cpuinfo.use_instr & PVR2_USE_MSR_INSTR) ? "yes" : "no",
  64. (cpuinfo.use_instr & PVR2_USE_PCMP_INSTR) ? "yes" : "no",
  65. (cpuinfo.use_instr & PVR0_USE_DIV_MASK) ? "yes" : "no");
  66. seq_printf(m, " MMU:\t\t%x\n", cpuinfo.mmu);
  67. seq_printf(m,
  68. " MUL:\t\t%s\n"
  69. " FPU:\t\t%s\n",
  70. (cpuinfo.use_mult & PVR2_USE_MUL64_MASK) ? "v2" :
  71. (cpuinfo.use_mult & PVR0_USE_HW_MUL_MASK) ? "v1" : "no",
  72. (cpuinfo.use_fpu & PVR2_USE_FPU2_MASK) ? "v2" :
  73. (cpuinfo.use_fpu & PVR0_USE_FPU_MASK) ? "v1" : "no");
  74. seq_printf(m,
  75. " Exc:\t\t%s%s%s%s%s%s%s%s\n",
  76. (cpuinfo.use_exc & PVR2_OPCODE_0x0_ILL_MASK) ? "op0x0 " : "",
  77. (cpuinfo.use_exc & PVR2_UNALIGNED_EXC_MASK) ? "unal " : "",
  78. (cpuinfo.use_exc & PVR2_ILL_OPCODE_EXC_MASK) ? "ill " : "",
  79. (cpuinfo.use_exc & PVR2_IOPB_BUS_EXC_MASK) ? "iopb " : "",
  80. (cpuinfo.use_exc & PVR2_DOPB_BUS_EXC_MASK) ? "dopb " : "",
  81. (cpuinfo.use_exc & PVR2_DIV_ZERO_EXC_MASK) ? "zero " : "",
  82. (cpuinfo.use_exc & PVR2_FPU_EXC_MASK) ? "fpu " : "",
  83. (cpuinfo.use_exc & PVR2_USE_FSL_EXC) ? "fsl " : "");
  84. seq_printf(m,
  85. "Stream-insns:\t%sprivileged\n",
  86. cpuinfo.mmu_privins ? "un" : "");
  87. if (cpuinfo.use_icache)
  88. seq_printf(m,
  89. "Icache:\t\t%ukB\tline length:\t%dB\n",
  90. cpuinfo.icache_size >> 10,
  91. cpuinfo.icache_line_length);
  92. else
  93. seq_puts(m, "Icache:\t\tno\n");
  94. if (cpuinfo.use_dcache) {
  95. seq_printf(m,
  96. "Dcache:\t\t%ukB\tline length:\t%dB\n",
  97. cpuinfo.dcache_size >> 10,
  98. cpuinfo.dcache_line_length);
  99. seq_puts(m, "Dcache-Policy:\t");
  100. if (cpuinfo.dcache_wb)
  101. seq_puts(m, "write-back\n");
  102. else
  103. seq_puts(m, "write-through\n");
  104. } else {
  105. seq_puts(m, "Dcache:\t\tno\n");
  106. }
  107. seq_printf(m,
  108. "HW-Debug:\t%s\n",
  109. cpuinfo.hw_debug ? "yes" : "no");
  110. seq_printf(m,
  111. "PVR-USR1:\t%02x\n"
  112. "PVR-USR2:\t%08x\n",
  113. cpuinfo.pvr_user1,
  114. cpuinfo.pvr_user2);
  115. seq_printf(m, "Page size:\t%lu\n", PAGE_SIZE);
  116. return 0;
  117. }
  118. static void *c_start(struct seq_file *m, loff_t *pos)
  119. {
  120. int i = *pos;
  121. return i < NR_CPUS ? (void *) (i + 1) : NULL;
  122. }
  123. static void *c_next(struct seq_file *m, void *v, loff_t *pos)
  124. {
  125. ++*pos;
  126. return c_start(m, pos);
  127. }
  128. static void c_stop(struct seq_file *m, void *v)
  129. {
  130. }
  131. const struct seq_operations cpuinfo_op = {
  132. .start = c_start,
  133. .next = c_next,
  134. .stop = c_stop,
  135. .show = show_cpuinfo,
  136. };