octeon-model.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409
  1. /***********************license start***************
  2. * Author: Cavium Networks
  3. *
  4. * Contact: [email protected]
  5. * This file is part of the OCTEON SDK
  6. *
  7. * Copyright (c) 2003-2010 Cavium Networks
  8. *
  9. * This file is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License, Version 2, as
  11. * published by the Free Software Foundation.
  12. *
  13. * This file is distributed in the hope that it will be useful, but
  14. * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
  16. * NONINFRINGEMENT. See the GNU General Public License for more
  17. * details.
  18. *
  19. * You should have received a copy of the GNU General Public License
  20. * along with this file; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  22. * or visit http://www.gnu.org/licenses/.
  23. *
  24. * This file may also be available under a different license from Cavium.
  25. * Contact Cavium Networks for more information
  26. ***********************license end**************************************/
  27. #ifndef __OCTEON_MODEL_H__
  28. #define __OCTEON_MODEL_H__
  29. /*
  30. * The defines below should be used with the OCTEON_IS_MODEL() macro
  31. * to determine what model of chip the software is running on. Models
  32. * ending in 'XX' match multiple models (families), while specific
  33. * models match only that model. If a pass (revision) is specified,
  34. * then only that revision will be matched. Care should be taken when
  35. * checking for both specific models and families that the specific
  36. * models are checked for first. While these defines are similar to
  37. * the processor ID, they are not intended to be used by anything
  38. * other that the OCTEON_IS_MODEL framework, and the values are
  39. * subject to change at anytime without notice.
  40. *
  41. * NOTE: only the OCTEON_IS_MODEL() macro/function and the OCTEON_CN*
  42. * macros should be used outside of this file. All other macros are
  43. * for internal use only, and may change without notice.
  44. */
  45. #define OCTEON_FAMILY_MASK 0x00ffff00
  46. #define OCTEON_PRID_MASK 0x00ffffff
  47. /* Flag bits in top byte */
  48. /* Ignores revision in model checks */
  49. #define OM_IGNORE_REVISION 0x01000000
  50. /* Check submodels */
  51. #define OM_CHECK_SUBMODEL 0x02000000
  52. /* Match all models previous than the one specified */
  53. #define OM_MATCH_PREVIOUS_MODELS 0x04000000
  54. /* Ignores the minor revison on newer parts */
  55. #define OM_IGNORE_MINOR_REVISION 0x08000000
  56. #define OM_FLAG_MASK 0xff000000
  57. /* Match all cn5XXX Octeon models. */
  58. #define OM_MATCH_5XXX_FAMILY_MODELS 0x20000000
  59. /* Match all cn6XXX Octeon models. */
  60. #define OM_MATCH_6XXX_FAMILY_MODELS 0x40000000
  61. /* Match all cnf7XXX Octeon models. */
  62. #define OM_MATCH_F7XXX_FAMILY_MODELS 0x80000000
  63. /* Match all cn7XXX Octeon models. */
  64. #define OM_MATCH_7XXX_FAMILY_MODELS 0x10000000
  65. #define OM_MATCH_FAMILY_MODELS (OM_MATCH_5XXX_FAMILY_MODELS | \
  66. OM_MATCH_6XXX_FAMILY_MODELS | \
  67. OM_MATCH_F7XXX_FAMILY_MODELS | \
  68. OM_MATCH_7XXX_FAMILY_MODELS)
  69. /*
  70. * CN7XXX models with new revision encoding
  71. */
  72. #define OCTEON_CNF75XX_PASS1_0 0x000d9800
  73. #define OCTEON_CNF75XX (OCTEON_CNF75XX_PASS1_0 | OM_IGNORE_REVISION)
  74. #define OCTEON_CNF75XX_PASS1_X (OCTEON_CNF75XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
  75. #define OCTEON_CN73XX_PASS1_0 0x000d9700
  76. #define OCTEON_CN73XX_PASS1_1 0x000d9701
  77. #define OCTEON_CN73XX (OCTEON_CN73XX_PASS1_0 | OM_IGNORE_REVISION)
  78. #define OCTEON_CN73XX_PASS1_X (OCTEON_CN73XX_PASS1_0 | \
  79. OM_IGNORE_MINOR_REVISION)
  80. #define OCTEON_CN70XX_PASS1_0 0x000d9600
  81. #define OCTEON_CN70XX_PASS1_1 0x000d9601
  82. #define OCTEON_CN70XX_PASS1_2 0x000d9602
  83. #define OCTEON_CN70XX_PASS2_0 0x000d9608
  84. #define OCTEON_CN70XX (OCTEON_CN70XX_PASS1_0 | OM_IGNORE_REVISION)
  85. #define OCTEON_CN70XX_PASS1_X (OCTEON_CN70XX_PASS1_0 | \
  86. OM_IGNORE_MINOR_REVISION)
  87. #define OCTEON_CN70XX_PASS2_X (OCTEON_CN70XX_PASS2_0 | \
  88. OM_IGNORE_MINOR_REVISION)
  89. #define OCTEON_CN71XX OCTEON_CN70XX
  90. #define OCTEON_CN78XX_PASS1_0 0x000d9500
  91. #define OCTEON_CN78XX_PASS1_1 0x000d9501
  92. #define OCTEON_CN78XX_PASS2_0 0x000d9508
  93. #define OCTEON_CN78XX (OCTEON_CN78XX_PASS1_0 | OM_IGNORE_REVISION)
  94. #define OCTEON_CN78XX_PASS1_X (OCTEON_CN78XX_PASS1_0 | \
  95. OM_IGNORE_MINOR_REVISION)
  96. #define OCTEON_CN78XX_PASS2_X (OCTEON_CN78XX_PASS2_0 | \
  97. OM_IGNORE_MINOR_REVISION)
  98. #define OCTEON_CN76XX (0x000d9540 | OM_CHECK_SUBMODEL)
  99. /*
  100. * CNF7XXX models with new revision encoding
  101. */
  102. #define OCTEON_CNF71XX_PASS1_0 0x000d9400
  103. #define OCTEON_CNF71XX_PASS1_1 0x000d9401
  104. #define OCTEON_CNF71XX (OCTEON_CNF71XX_PASS1_0 | OM_IGNORE_REVISION)
  105. #define OCTEON_CNF71XX_PASS1_X (OCTEON_CNF71XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
  106. /*
  107. * CN6XXX models with new revision encoding
  108. */
  109. #define OCTEON_CN68XX_PASS1_0 0x000d9100
  110. #define OCTEON_CN68XX_PASS1_1 0x000d9101
  111. #define OCTEON_CN68XX_PASS1_2 0x000d9102
  112. #define OCTEON_CN68XX_PASS2_0 0x000d9108
  113. #define OCTEON_CN68XX_PASS2_1 0x000d9109
  114. #define OCTEON_CN68XX_PASS2_2 0x000d910a
  115. #define OCTEON_CN68XX (OCTEON_CN68XX_PASS2_0 | OM_IGNORE_REVISION)
  116. #define OCTEON_CN68XX_PASS1_X (OCTEON_CN68XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
  117. #define OCTEON_CN68XX_PASS2_X (OCTEON_CN68XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
  118. #define OCTEON_CN68XX_PASS1 OCTEON_CN68XX_PASS1_X
  119. #define OCTEON_CN68XX_PASS2 OCTEON_CN68XX_PASS2_X
  120. #define OCTEON_CN66XX_PASS1_0 0x000d9200
  121. #define OCTEON_CN66XX_PASS1_2 0x000d9202
  122. #define OCTEON_CN66XX (OCTEON_CN66XX_PASS1_0 | OM_IGNORE_REVISION)
  123. #define OCTEON_CN66XX_PASS1_X (OCTEON_CN66XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
  124. #define OCTEON_CN63XX_PASS1_0 0x000d9000
  125. #define OCTEON_CN63XX_PASS1_1 0x000d9001
  126. #define OCTEON_CN63XX_PASS1_2 0x000d9002
  127. #define OCTEON_CN63XX_PASS2_0 0x000d9008
  128. #define OCTEON_CN63XX_PASS2_1 0x000d9009
  129. #define OCTEON_CN63XX_PASS2_2 0x000d900a
  130. #define OCTEON_CN63XX (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_REVISION)
  131. #define OCTEON_CN63XX_PASS1_X (OCTEON_CN63XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
  132. #define OCTEON_CN63XX_PASS2_X (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
  133. /* CN62XX is same as CN63XX with 1 MB cache */
  134. #define OCTEON_CN62XX OCTEON_CN63XX
  135. #define OCTEON_CN61XX_PASS1_0 0x000d9300
  136. #define OCTEON_CN61XX_PASS1_1 0x000d9301
  137. #define OCTEON_CN61XX (OCTEON_CN61XX_PASS1_0 | OM_IGNORE_REVISION)
  138. #define OCTEON_CN61XX_PASS1_X (OCTEON_CN61XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
  139. /* CN60XX is same as CN61XX with 512 KB cache */
  140. #define OCTEON_CN60XX OCTEON_CN61XX
  141. /*
  142. * CN5XXX models with new revision encoding
  143. */
  144. #define OCTEON_CN58XX_PASS1_0 0x000d0300
  145. #define OCTEON_CN58XX_PASS1_1 0x000d0301
  146. #define OCTEON_CN58XX_PASS1_2 0x000d0303
  147. #define OCTEON_CN58XX_PASS2_0 0x000d0308
  148. #define OCTEON_CN58XX_PASS2_1 0x000d0309
  149. #define OCTEON_CN58XX_PASS2_2 0x000d030a
  150. #define OCTEON_CN58XX_PASS2_3 0x000d030b
  151. #define OCTEON_CN58XX (OCTEON_CN58XX_PASS2_0 | OM_IGNORE_REVISION)
  152. #define OCTEON_CN58XX_PASS1_X (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
  153. #define OCTEON_CN58XX_PASS2_X (OCTEON_CN58XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
  154. #define OCTEON_CN58XX_PASS1 OCTEON_CN58XX_PASS1_X
  155. #define OCTEON_CN58XX_PASS2 OCTEON_CN58XX_PASS2_X
  156. #define OCTEON_CN56XX_PASS1_0 0x000d0400
  157. #define OCTEON_CN56XX_PASS1_1 0x000d0401
  158. #define OCTEON_CN56XX_PASS2_0 0x000d0408
  159. #define OCTEON_CN56XX_PASS2_1 0x000d0409
  160. #define OCTEON_CN56XX (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_REVISION)
  161. #define OCTEON_CN56XX_PASS1_X (OCTEON_CN56XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
  162. #define OCTEON_CN56XX_PASS2_X (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
  163. #define OCTEON_CN56XX_PASS1 OCTEON_CN56XX_PASS1_X
  164. #define OCTEON_CN56XX_PASS2 OCTEON_CN56XX_PASS2_X
  165. #define OCTEON_CN57XX OCTEON_CN56XX
  166. #define OCTEON_CN57XX_PASS1 OCTEON_CN56XX_PASS1
  167. #define OCTEON_CN57XX_PASS2 OCTEON_CN56XX_PASS2
  168. #define OCTEON_CN55XX OCTEON_CN56XX
  169. #define OCTEON_CN55XX_PASS1 OCTEON_CN56XX_PASS1
  170. #define OCTEON_CN55XX_PASS2 OCTEON_CN56XX_PASS2
  171. #define OCTEON_CN54XX OCTEON_CN56XX
  172. #define OCTEON_CN54XX_PASS1 OCTEON_CN56XX_PASS1
  173. #define OCTEON_CN54XX_PASS2 OCTEON_CN56XX_PASS2
  174. #define OCTEON_CN50XX_PASS1_0 0x000d0600
  175. #define OCTEON_CN50XX (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_REVISION)
  176. #define OCTEON_CN50XX_PASS1_X (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
  177. #define OCTEON_CN50XX_PASS1 OCTEON_CN50XX_PASS1_X
  178. /*
  179. * NOTE: Octeon CN5000F model is not identifiable using the
  180. * OCTEON_IS_MODEL() functions, but are treated as CN50XX.
  181. */
  182. #define OCTEON_CN52XX_PASS1_0 0x000d0700
  183. #define OCTEON_CN52XX_PASS2_0 0x000d0708
  184. #define OCTEON_CN52XX (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_REVISION)
  185. #define OCTEON_CN52XX_PASS1_X (OCTEON_CN52XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
  186. #define OCTEON_CN52XX_PASS2_X (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
  187. #define OCTEON_CN52XX_PASS1 OCTEON_CN52XX_PASS1_X
  188. #define OCTEON_CN52XX_PASS2 OCTEON_CN52XX_PASS2_X
  189. /*
  190. * CN3XXX models with old revision enconding
  191. */
  192. #define OCTEON_CN38XX_PASS1 0x000d0000
  193. #define OCTEON_CN38XX_PASS2 0x000d0001
  194. #define OCTEON_CN38XX_PASS3 0x000d0003
  195. #define OCTEON_CN38XX (OCTEON_CN38XX_PASS3 | OM_IGNORE_REVISION)
  196. #define OCTEON_CN36XX OCTEON_CN38XX
  197. #define OCTEON_CN36XX_PASS2 OCTEON_CN38XX_PASS2
  198. #define OCTEON_CN36XX_PASS3 OCTEON_CN38XX_PASS3
  199. /* The OCTEON_CN31XX matches CN31XX models and the CN3020 */
  200. #define OCTEON_CN31XX_PASS1 0x000d0100
  201. #define OCTEON_CN31XX_PASS1_1 0x000d0102
  202. #define OCTEON_CN31XX (OCTEON_CN31XX_PASS1 | OM_IGNORE_REVISION)
  203. /*
  204. * This model is only used for internal checks, it is not a valid
  205. * model for the OCTEON_MODEL environment variable. This matches the
  206. * CN3010 and CN3005 but NOT the CN3020.
  207. */
  208. #define OCTEON_CN30XX_PASS1 0x000d0200
  209. #define OCTEON_CN30XX_PASS1_1 0x000d0202
  210. #define OCTEON_CN30XX (OCTEON_CN30XX_PASS1 | OM_IGNORE_REVISION)
  211. #define OCTEON_CN3005_PASS1 (0x000d0210 | OM_CHECK_SUBMODEL)
  212. #define OCTEON_CN3005_PASS1_0 (0x000d0210 | OM_CHECK_SUBMODEL)
  213. #define OCTEON_CN3005_PASS1_1 (0x000d0212 | OM_CHECK_SUBMODEL)
  214. #define OCTEON_CN3005 (OCTEON_CN3005_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
  215. #define OCTEON_CN3010_PASS1 (0x000d0200 | OM_CHECK_SUBMODEL)
  216. #define OCTEON_CN3010_PASS1_0 (0x000d0200 | OM_CHECK_SUBMODEL)
  217. #define OCTEON_CN3010_PASS1_1 (0x000d0202 | OM_CHECK_SUBMODEL)
  218. #define OCTEON_CN3010 (OCTEON_CN3010_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
  219. #define OCTEON_CN3020_PASS1 (0x000d0110 | OM_CHECK_SUBMODEL)
  220. #define OCTEON_CN3020_PASS1_0 (0x000d0110 | OM_CHECK_SUBMODEL)
  221. #define OCTEON_CN3020_PASS1_1 (0x000d0112 | OM_CHECK_SUBMODEL)
  222. #define OCTEON_CN3020 (OCTEON_CN3020_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
  223. /*
  224. * This matches the complete family of CN3xxx CPUs, and not subsequent
  225. * models
  226. */
  227. #define OCTEON_CN3XXX (OCTEON_CN58XX_PASS1_0 | OM_MATCH_PREVIOUS_MODELS | OM_IGNORE_REVISION)
  228. #define OCTEON_CN5XXX (OCTEON_CN58XX_PASS1_0 | OM_MATCH_5XXX_FAMILY_MODELS)
  229. #define OCTEON_CN6XXX (OCTEON_CN63XX_PASS1_0 | OM_MATCH_6XXX_FAMILY_MODELS)
  230. #define OCTEON_CNF7XXX (OCTEON_CNF71XX_PASS1_0 | \
  231. OM_MATCH_F7XXX_FAMILY_MODELS)
  232. #define OCTEON_CN7XXX (OCTEON_CN78XX_PASS1_0 | \
  233. OM_MATCH_7XXX_FAMILY_MODELS)
  234. /* The revision byte (low byte) has two different encodings.
  235. * CN3XXX:
  236. *
  237. * bits
  238. * <7:5>: reserved (0)
  239. * <4>: alternate package
  240. * <3:0>: revision
  241. *
  242. * CN5XXX and older models:
  243. *
  244. * bits
  245. * <7>: reserved (0)
  246. * <6>: alternate package
  247. * <5:3>: major revision
  248. * <2:0>: minor revision
  249. *
  250. */
  251. /* Masks used for the various types of model/family/revision matching */
  252. #define OCTEON_38XX_FAMILY_MASK 0x00ffff00
  253. #define OCTEON_38XX_FAMILY_REV_MASK 0x00ffff0f
  254. #define OCTEON_38XX_MODEL_MASK 0x00ffff10
  255. #define OCTEON_38XX_MODEL_REV_MASK (OCTEON_38XX_FAMILY_REV_MASK | OCTEON_38XX_MODEL_MASK)
  256. /* CN5XXX and later use different layout of bits in the revision ID field */
  257. #define OCTEON_58XX_FAMILY_MASK OCTEON_38XX_FAMILY_MASK
  258. #define OCTEON_58XX_FAMILY_REV_MASK 0x00ffff3f
  259. #define OCTEON_58XX_MODEL_MASK 0x00ffff40
  260. #define OCTEON_58XX_MODEL_REV_MASK (OCTEON_58XX_FAMILY_REV_MASK | OCTEON_58XX_MODEL_MASK)
  261. #define OCTEON_58XX_MODEL_MINOR_REV_MASK (OCTEON_58XX_MODEL_REV_MASK & 0x00ffff38)
  262. #define OCTEON_5XXX_MODEL_MASK 0x00ff0fc0
  263. static inline uint32_t cvmx_get_proc_id(void) __attribute__ ((pure));
  264. static inline uint64_t cvmx_read_csr(uint64_t csr_addr);
  265. #define __OCTEON_MATCH_MASK__(x, y, z) (((x) & (z)) == ((y) & (z)))
  266. /*
  267. * __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model)
  268. * returns true if chip_model is identical or belong to the OCTEON
  269. * model group specified in arg_model.
  270. */
  271. /* NOTE: This for internal use only! */
  272. #define __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model) \
  273. ((((arg_model & OCTEON_38XX_FAMILY_MASK) < OCTEON_CN58XX_PASS1_0) && ( \
  274. ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
  275. && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_MASK)) || \
  276. ((((arg_model) & (OM_FLAG_MASK)) == 0) \
  277. && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_REV_MASK)) || \
  278. ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
  279. && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_MASK)) || \
  280. ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL) \
  281. && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_REV_MASK)) || \
  282. ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
  283. && (((chip_model) & OCTEON_38XX_MODEL_MASK) < ((arg_model) & OCTEON_38XX_MODEL_MASK))) \
  284. )) || \
  285. (((arg_model & OCTEON_38XX_FAMILY_MASK) >= OCTEON_CN58XX_PASS1_0) && ( \
  286. ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
  287. && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
  288. ((((arg_model) & (OM_FLAG_MASK)) == 0) \
  289. && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_REV_MASK)) || \
  290. ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_MINOR_REVISION) \
  291. && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MINOR_REV_MASK)) || \
  292. ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
  293. && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_MASK)) || \
  294. ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL) \
  295. && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
  296. ((((arg_model) & (OM_MATCH_5XXX_FAMILY_MODELS)) == OM_MATCH_5XXX_FAMILY_MODELS) \
  297. && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN58XX_PASS1_0) \
  298. && ((chip_model & OCTEON_PRID_MASK) < OCTEON_CN63XX_PASS1_0)) || \
  299. ((((arg_model) & (OM_MATCH_6XXX_FAMILY_MODELS)) == OM_MATCH_6XXX_FAMILY_MODELS) \
  300. && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN63XX_PASS1_0) \
  301. && ((chip_model & OCTEON_PRID_MASK) < OCTEON_CNF71XX_PASS1_0)) || \
  302. ((((arg_model) & (OM_MATCH_F7XXX_FAMILY_MODELS)) == OM_MATCH_F7XXX_FAMILY_MODELS) \
  303. && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CNF71XX_PASS1_0) \
  304. && ((chip_model & OCTEON_PRID_MASK) < OCTEON_CN78XX_PASS1_0)) || \
  305. ((((arg_model) & (OM_MATCH_7XXX_FAMILY_MODELS)) == OM_MATCH_7XXX_FAMILY_MODELS) \
  306. && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN78XX_PASS1_0)) || \
  307. ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
  308. && (((chip_model) & OCTEON_58XX_MODEL_MASK) < ((arg_model) & OCTEON_58XX_MODEL_MASK))) \
  309. )))
  310. /* NOTE: This for internal use only!!!!! */
  311. static inline int __octeon_is_model_runtime__(uint32_t model)
  312. {
  313. uint32_t cpuid = cvmx_get_proc_id();
  314. return __OCTEON_IS_MODEL_COMPILE__(model, cpuid);
  315. }
  316. /*
  317. * The OCTEON_IS_MODEL macro should be used for all Octeon model checking done
  318. * in a program.
  319. * This should be kept runtime if at all possible and must be conditionalized
  320. * with OCTEON_IS_COMMON_BINARY() if runtime checking support is required.
  321. *
  322. * Use of the macro in preprocessor directives ( #if OCTEON_IS_MODEL(...) )
  323. * is NOT SUPPORTED, and should be replaced with CVMX_COMPILED_FOR()
  324. * I.e.:
  325. * #if OCTEON_IS_MODEL(OCTEON_CN56XX) -> #if CVMX_COMPILED_FOR(OCTEON_CN56XX)
  326. */
  327. #define OCTEON_IS_MODEL(x) __octeon_is_model_runtime__(x)
  328. #define OCTEON_IS_COMMON_BINARY() 1
  329. #undef OCTEON_MODEL
  330. #define OCTEON_IS_OCTEON1() OCTEON_IS_MODEL(OCTEON_CN3XXX)
  331. #define OCTEON_IS_OCTEONPLUS() OCTEON_IS_MODEL(OCTEON_CN5XXX)
  332. #define OCTEON_IS_OCTEON2() \
  333. (OCTEON_IS_MODEL(OCTEON_CN6XXX) || OCTEON_IS_MODEL(OCTEON_CNF71XX))
  334. #define OCTEON_IS_OCTEON3() OCTEON_IS_MODEL(OCTEON_CN7XXX)
  335. #define OCTEON_IS_OCTEON1PLUS() (OCTEON_IS_OCTEON1() || OCTEON_IS_OCTEONPLUS())
  336. const char *__init octeon_model_get_string(uint32_t chip_id);
  337. /*
  338. * Return the octeon family, i.e., ProcessorID of the PrID register.
  339. *
  340. * @return the octeon family on success, ((unint32_t)-1) on error.
  341. */
  342. static inline uint32_t cvmx_get_octeon_family(void)
  343. {
  344. return cvmx_get_proc_id() & OCTEON_FAMILY_MASK;
  345. }
  346. #include <asm/octeon/octeon-feature.h>
  347. #endif /* __OCTEON_MODEL_H__ */