cpu-features.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 2003, 2004 Ralf Baechle
  7. * Copyright (C) 2004 Maciej W. Rozycki
  8. */
  9. #ifndef __ASM_CPU_FEATURES_H
  10. #define __ASM_CPU_FEATURES_H
  11. #include <linux/config.h>
  12. #include <asm/cpu.h>
  13. #include <asm/cpu-info.h>
  14. #include <cpu-feature-overrides.h>
  15. /*
  16. * SMP assumption: Options of CPU 0 are a superset of all processors.
  17. * This is true for all known MIPS systems.
  18. */
  19. #ifndef cpu_has_tlb
  20. #define cpu_has_tlb (cpu_data[0].options & MIPS_CPU_TLB)
  21. #endif
  22. #ifndef cpu_has_4kex
  23. #define cpu_has_4kex (cpu_data[0].options & MIPS_CPU_4KEX)
  24. #endif
  25. #ifndef cpu_has_3k_cache
  26. #define cpu_has_3k_cache (cpu_data[0].options & MIPS_CPU_3K_CACHE)
  27. #endif
  28. #define cpu_has_6k_cache 0
  29. #define cpu_has_8k_cache 0
  30. #ifndef cpu_has_4k_cache
  31. #define cpu_has_4k_cache (cpu_data[0].options & MIPS_CPU_4K_CACHE)
  32. #endif
  33. #ifndef cpu_has_tx39_cache
  34. #define cpu_has_tx39_cache (cpu_data[0].options & MIPS_CPU_TX39_CACHE)
  35. #endif
  36. #ifndef cpu_has_sb1_cache
  37. #define cpu_has_sb1_cache (cpu_data[0].options & MIPS_CPU_SB1_CACHE)
  38. #endif
  39. #ifndef cpu_has_fpu
  40. #define cpu_has_fpu (cpu_data[0].options & MIPS_CPU_FPU)
  41. #endif
  42. #ifndef cpu_has_32fpr
  43. #define cpu_has_32fpr (cpu_data[0].options & MIPS_CPU_32FPR)
  44. #endif
  45. #ifndef cpu_has_counter
  46. #define cpu_has_counter (cpu_data[0].options & MIPS_CPU_COUNTER)
  47. #endif
  48. #ifndef cpu_has_watch
  49. #define cpu_has_watch (cpu_data[0].options & MIPS_CPU_WATCH)
  50. #endif
  51. #ifndef cpu_has_divec
  52. #define cpu_has_divec (cpu_data[0].options & MIPS_CPU_DIVEC)
  53. #endif
  54. #ifndef cpu_has_vce
  55. #define cpu_has_vce (cpu_data[0].options & MIPS_CPU_VCE)
  56. #endif
  57. #ifndef cpu_has_cache_cdex_p
  58. #define cpu_has_cache_cdex_p (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_P)
  59. #endif
  60. #ifndef cpu_has_cache_cdex_s
  61. #define cpu_has_cache_cdex_s (cpu_data[0].options & MIPS_CPU_CACHE_CDEX_S)
  62. #endif
  63. #ifndef cpu_has_prefetch
  64. #define cpu_has_prefetch (cpu_data[0].options & MIPS_CPU_PREFETCH)
  65. #endif
  66. #ifndef cpu_has_mcheck
  67. #define cpu_has_mcheck (cpu_data[0].options & MIPS_CPU_MCHECK)
  68. #endif
  69. #ifndef cpu_has_ejtag
  70. #define cpu_has_ejtag (cpu_data[0].options & MIPS_CPU_EJTAG)
  71. #endif
  72. #ifndef cpu_has_llsc
  73. #define cpu_has_llsc (cpu_data[0].options & MIPS_CPU_LLSC)
  74. #endif
  75. #ifndef cpu_has_mips16
  76. #define cpu_has_mips16 (cpu_data[0].ases & MIPS_ASE_MIPS16)
  77. #endif
  78. #ifndef cpu_has_mdmx
  79. #define cpu_has_mdmx (cpu_data[0].ases & MIPS_ASE_MDMX)
  80. #endif
  81. #ifndef cpu_has_mips3d
  82. #define cpu_has_mips3d (cpu_data[0].ases & MIPS_ASE_MIPS3D)
  83. #endif
  84. #ifndef cpu_has_smartmips
  85. #define cpu_has_smartmips (cpu_data[0].ases & MIPS_ASE_SMARTMIPS)
  86. #endif
  87. #ifndef cpu_has_vtag_icache
  88. #define cpu_has_vtag_icache (cpu_data[0].icache.flags & MIPS_CACHE_VTAG)
  89. #endif
  90. #ifndef cpu_has_dc_aliases
  91. #define cpu_has_dc_aliases (cpu_data[0].dcache.flags & MIPS_CACHE_ALIASES)
  92. #endif
  93. #ifndef cpu_has_ic_fills_f_dc
  94. #define cpu_has_ic_fills_f_dc (cpu_data[0].icache.flags & MIPS_CACHE_IC_F_DC)
  95. #endif
  96. /*
  97. * I-Cache snoops remote store. This only matters on SMP. Some multiprocessors
  98. * such as the R10000 have I-Caches that snoop local stores; the embedded ones
  99. * don't. For maintaining I-cache coherency this means we need to flush the
  100. * D-cache all the way back to whever the I-cache does refills from, so the
  101. * I-cache has a chance to see the new data at all. Then we have to flush the
  102. * I-cache also.
  103. * Note we may have been rescheduled and may no longer be running on the CPU
  104. * that did the store so we can't optimize this into only doing the flush on
  105. * the local CPU.
  106. */
  107. #ifndef cpu_icache_snoops_remote_store
  108. #ifdef CONFIG_SMP
  109. #define cpu_icache_snoops_remote_store (cpu_data[0].icache.flags & MIPS_IC_SNOOPS_REMOTE)
  110. #else
  111. #define cpu_icache_snoops_remote_store 1
  112. #endif
  113. #endif
  114. # ifndef cpu_has_mips32r1
  115. # define cpu_has_mips32r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R1)
  116. # endif
  117. # ifndef cpu_has_mips32r2
  118. # define cpu_has_mips32r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M32R2)
  119. # endif
  120. # ifndef cpu_has_mips64r1
  121. # define cpu_has_mips64r1 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R1)
  122. # endif
  123. # ifndef cpu_has_mips64r2
  124. # define cpu_has_mips64r2 (cpu_data[0].isa_level & MIPS_CPU_ISA_M64R2)
  125. # endif
  126. /*
  127. * Shortcuts ...
  128. */
  129. #define cpu_has_mips32 (cpu_has_mips32r1 | cpu_has_mips32r2)
  130. #define cpu_has_mips64 (cpu_has_mips64r1 | cpu_has_mips64r2)
  131. #define cpu_has_mips_r1 (cpu_has_mips32r1 | cpu_has_mips64r1)
  132. #define cpu_has_mips_r2 (cpu_has_mips32r2 | cpu_has_mips64r2)
  133. #ifndef cpu_has_dsp
  134. #define cpu_has_dsp (cpu_data[0].ases & MIPS_ASE_DSP)
  135. #endif
  136. #ifdef CONFIG_MIPS_MT
  137. #ifndef cpu_has_mipsmt
  138. # define cpu_has_mipsmt (cpu_data[0].ases & MIPS_ASE_MIPSMT)
  139. #endif
  140. #else
  141. # define cpu_has_mipsmt 0
  142. #endif
  143. #ifdef CONFIG_32BIT
  144. # ifndef cpu_has_nofpuex
  145. # define cpu_has_nofpuex (cpu_data[0].options & MIPS_CPU_NOFPUEX)
  146. # endif
  147. # ifndef cpu_has_64bits
  148. # define cpu_has_64bits (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
  149. # endif
  150. # ifndef cpu_has_64bit_zero_reg
  151. # define cpu_has_64bit_zero_reg (cpu_data[0].isa_level & MIPS_CPU_ISA_64BIT)
  152. # endif
  153. # ifndef cpu_has_64bit_gp_regs
  154. # define cpu_has_64bit_gp_regs 0
  155. # endif
  156. # ifndef cpu_has_64bit_addresses
  157. # define cpu_has_64bit_addresses 0
  158. # endif
  159. #endif
  160. #ifdef CONFIG_64BIT
  161. # ifndef cpu_has_nofpuex
  162. # define cpu_has_nofpuex 0
  163. # endif
  164. # ifndef cpu_has_64bits
  165. # define cpu_has_64bits 1
  166. # endif
  167. # ifndef cpu_has_64bit_zero_reg
  168. # define cpu_has_64bit_zero_reg 1
  169. # endif
  170. # ifndef cpu_has_64bit_gp_regs
  171. # define cpu_has_64bit_gp_regs 1
  172. # endif
  173. # ifndef cpu_has_64bit_addresses
  174. # define cpu_has_64bit_addresses 1
  175. # endif
  176. #endif
  177. #ifdef CONFIG_CPU_MIPSR2
  178. # if defined(CONFIG_CPU_MIPSR2_IRQ_VI) && !defined(cpu_has_vint)
  179. # define cpu_has_vint (cpu_data[0].options & MIPS_CPU_VINT)
  180. # else
  181. # define cpu_has_vint 0
  182. # endif
  183. # if defined(CONFIG_CPU_MIPSR2_IRQ_EI) && !defined(cpu_has_veic)
  184. # define cpu_has_veic (cpu_data[0].options & MIPS_CPU_VEIC)
  185. # else
  186. # define cpu_has_veic 0
  187. # endif
  188. #else
  189. # define cpu_has_vint 0
  190. # define cpu_has_veic 0
  191. #endif
  192. #ifndef cpu_has_subset_pcaches
  193. #define cpu_has_subset_pcaches (cpu_data[0].options & MIPS_CPU_SUBSET_CACHES)
  194. #endif
  195. #ifndef cpu_dcache_line_size
  196. #define cpu_dcache_line_size() current_cpu_data.dcache.linesz
  197. #endif
  198. #ifndef cpu_icache_line_size
  199. #define cpu_icache_line_size() current_cpu_data.icache.linesz
  200. #endif
  201. #ifndef cpu_scache_line_size
  202. #define cpu_scache_line_size() current_cpu_data.scache.linesz
  203. #endif
  204. #endif /* __ASM_CPU_FEATURES_H */