cpuinfo-static.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. /*
  2. * Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
  3. * Copyright (C) 2007-2009 PetaLogix
  4. * Copyright (C) 2007 John Williams <john.williams@petalogix.com>
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/init.h>
  12. #include <linux/string.h>
  13. #include <asm/cpuinfo.h>
  14. #include <asm/pvr.h>
  15. static const char family_string[] = CONFIG_XILINX_MICROBLAZE0_FAMILY;
  16. static const char cpu_ver_string[] = CONFIG_XILINX_MICROBLAZE0_HW_VER;
  17. #define err_printk(x) \
  18. early_printk("ERROR: Microblaze " x "-different for kernel and DTS\n");
  19. void __init set_cpuinfo_static(struct cpuinfo *ci, struct device_node *cpu)
  20. {
  21. u32 i = 0;
  22. ci->use_instr =
  23. (fcpu(cpu, "xlnx,use-barrel") ? PVR0_USE_BARREL_MASK : 0) |
  24. (fcpu(cpu, "xlnx,use-msr-instr") ? PVR2_USE_MSR_INSTR : 0) |
  25. (fcpu(cpu, "xlnx,use-pcmp-instr") ? PVR2_USE_PCMP_INSTR : 0) |
  26. (fcpu(cpu, "xlnx,use-div") ? PVR0_USE_DIV_MASK : 0);
  27. if (CONFIG_XILINX_MICROBLAZE0_USE_BARREL)
  28. i |= PVR0_USE_BARREL_MASK;
  29. if (CONFIG_XILINX_MICROBLAZE0_USE_MSR_INSTR)
  30. i |= PVR2_USE_MSR_INSTR;
  31. if (CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR)
  32. i |= PVR2_USE_PCMP_INSTR;
  33. if (CONFIG_XILINX_MICROBLAZE0_USE_DIV)
  34. i |= PVR0_USE_DIV_MASK;
  35. if (ci->use_instr != i)
  36. err_printk("BARREL, MSR, PCMP or DIV");
  37. ci->use_mult = fcpu(cpu, "xlnx,use-hw-mul");
  38. if (ci->use_mult != CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL)
  39. err_printk("HW_MUL");
  40. ci->use_mult =
  41. (ci->use_mult > 1 ?
  42. (PVR2_USE_MUL64_MASK | PVR0_USE_HW_MUL_MASK) :
  43. (ci->use_mult == 1 ? PVR0_USE_HW_MUL_MASK : 0));
  44. ci->use_fpu = fcpu(cpu, "xlnx,use-fpu");
  45. if (ci->use_fpu != CONFIG_XILINX_MICROBLAZE0_USE_FPU)
  46. err_printk("HW_FPU");
  47. ci->use_fpu = (ci->use_fpu > 1 ?
  48. (PVR2_USE_FPU2_MASK | PVR0_USE_FPU_MASK) :
  49. (ci->use_fpu == 1 ? PVR0_USE_FPU_MASK : 0));
  50. ci->use_exc =
  51. (fcpu(cpu, "xlnx,unaligned-exceptions") ?
  52. PVR2_UNALIGNED_EXC_MASK : 0) |
  53. (fcpu(cpu, "xlnx,ill-opcode-exception") ?
  54. PVR2_ILL_OPCODE_EXC_MASK : 0) |
  55. (fcpu(cpu, "xlnx,iopb-bus-exception") ?
  56. PVR2_IOPB_BUS_EXC_MASK : 0) |
  57. (fcpu(cpu, "xlnx,dopb-bus-exception") ?
  58. PVR2_DOPB_BUS_EXC_MASK : 0) |
  59. (fcpu(cpu, "xlnx,div-zero-exception") ?
  60. PVR2_DIV_ZERO_EXC_MASK : 0) |
  61. (fcpu(cpu, "xlnx,fpu-exception") ? PVR2_FPU_EXC_MASK : 0) |
  62. (fcpu(cpu, "xlnx,fsl-exception") ? PVR2_USE_EXTEND_FSL : 0);
  63. ci->use_icache = fcpu(cpu, "xlnx,use-icache");
  64. ci->icache_tagbits = fcpu(cpu, "xlnx,addr-tag-bits");
  65. ci->icache_write = fcpu(cpu, "xlnx,allow-icache-wr");
  66. ci->icache_line_length = fcpu(cpu, "xlnx,icache-line-len") << 2;
  67. if (!ci->icache_line_length) {
  68. if (fcpu(cpu, "xlnx,icache-use-fsl"))
  69. ci->icache_line_length = 4 << 2;
  70. else
  71. ci->icache_line_length = 1 << 2;
  72. }
  73. ci->icache_size = fcpu(cpu, "i-cache-size");
  74. ci->icache_base = fcpu(cpu, "i-cache-baseaddr");
  75. ci->icache_high = fcpu(cpu, "i-cache-highaddr");
  76. ci->use_dcache = fcpu(cpu, "xlnx,use-dcache");
  77. ci->dcache_tagbits = fcpu(cpu, "xlnx,dcache-addr-tag");
  78. ci->dcache_write = fcpu(cpu, "xlnx,allow-dcache-wr");
  79. ci->dcache_line_length = fcpu(cpu, "xlnx,dcache-line-len") << 2;
  80. if (!ci->dcache_line_length) {
  81. if (fcpu(cpu, "xlnx,dcache-use-fsl"))
  82. ci->dcache_line_length = 4 << 2;
  83. else
  84. ci->dcache_line_length = 1 << 2;
  85. }
  86. ci->dcache_size = fcpu(cpu, "d-cache-size");
  87. ci->dcache_base = fcpu(cpu, "d-cache-baseaddr");
  88. ci->dcache_high = fcpu(cpu, "d-cache-highaddr");
  89. ci->dcache_wb = fcpu(cpu, "xlnx,dcache-use-writeback");
  90. ci->use_dopb = fcpu(cpu, "xlnx,d-opb");
  91. ci->use_iopb = fcpu(cpu, "xlnx,i-opb");
  92. ci->use_dlmb = fcpu(cpu, "xlnx,d-lmb");
  93. ci->use_ilmb = fcpu(cpu, "xlnx,i-lmb");
  94. ci->num_fsl = fcpu(cpu, "xlnx,fsl-links");
  95. ci->irq_edge = fcpu(cpu, "xlnx,interrupt-is-edge");
  96. ci->irq_positive = fcpu(cpu, "xlnx,edge-is-positive");
  97. ci->area_optimised = 0;
  98. ci->hw_debug = fcpu(cpu, "xlnx,debug-enabled");
  99. ci->num_pc_brk = fcpu(cpu, "xlnx,number-of-pc-brk");
  100. ci->num_rd_brk = fcpu(cpu, "xlnx,number-of-rd-addr-brk");
  101. ci->num_wr_brk = fcpu(cpu, "xlnx,number-of-wr-addr-brk");
  102. ci->pvr_user1 = fcpu(cpu, "xlnx,pvr-user1");
  103. ci->pvr_user2 = fcpu(cpu, "xlnx,pvr-user2");
  104. ci->mmu = fcpu(cpu, "xlnx,use-mmu");
  105. ci->mmu_privins = fcpu(cpu, "xlnx,mmu-privileged-instr");
  106. ci->endian = fcpu(cpu, "xlnx,endianness");
  107. ci->ver_code = 0;
  108. ci->fpga_family_code = 0;
  109. /* Do various fixups based on CPU version and FPGA family strings */
  110. /* Resolved the CPU version code */
  111. for (i = 0; cpu_ver_lookup[i].s != NULL; i++) {
  112. if (strcmp(cpu_ver_lookup[i].s, cpu_ver_string) == 0)
  113. ci->ver_code = cpu_ver_lookup[i].k;
  114. }
  115. /* Resolved the fpga family code */
  116. for (i = 0; family_string_lookup[i].s != NULL; i++) {
  117. if (strcmp(family_string_lookup[i].s, family_string) == 0)
  118. ci->fpga_family_code = family_string_lookup[i].k;
  119. }
  120. /* FIXME - mb3 and spartan2 do not exist in PVR */
  121. /* This is mb3 and on a non Spartan2 */
  122. if (ci->ver_code == 0x20 && ci->fpga_family_code != 0xf0)
  123. /* Hardware Multiplier in use */
  124. ci->use_mult = 1;
  125. }