Back to home page

OSCL-LXR

 
 

    


0001 /***********************license start***************
0002  * Author: Cavium Networks
0003  *
0004  * Contact: support@caviumnetworks.com
0005  * This file is part of the OCTEON SDK
0006  *
0007  * Copyright (c) 2003-2010 Cavium Networks
0008  *
0009  * This file is free software; you can redistribute it and/or modify
0010  * it under the terms of the GNU General Public License, Version 2, as
0011  * published by the Free Software Foundation.
0012  *
0013  * This file is distributed in the hope that it will be useful, but
0014  * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
0015  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
0016  * NONINFRINGEMENT.  See the GNU General Public License for more
0017  * details.
0018  *
0019  * You should have received a copy of the GNU General Public License
0020  * along with this file; if not, write to the Free Software
0021  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
0022  * or visit http://www.gnu.org/licenses/.
0023  *
0024  * This file may also be available under a different license from Cavium.
0025  * Contact Cavium Networks for more information
0026  ***********************license end**************************************/
0027 #ifndef __OCTEON_MODEL_H__
0028 #define __OCTEON_MODEL_H__
0029 
0030 /*
0031  * The defines below should be used with the OCTEON_IS_MODEL() macro
0032  * to determine what model of chip the software is running on.  Models
0033  * ending in 'XX' match multiple models (families), while specific
0034  * models match only that model.  If a pass (revision) is specified,
0035  * then only that revision will be matched.  Care should be taken when
0036  * checking for both specific models and families that the specific
0037  * models are checked for first.  While these defines are similar to
0038  * the processor ID, they are not intended to be used by anything
0039  * other that the OCTEON_IS_MODEL framework, and the values are
0040  * subject to change at anytime without notice.
0041  *
0042  * NOTE: only the OCTEON_IS_MODEL() macro/function and the OCTEON_CN*
0043  * macros should be used outside of this file.  All other macros are
0044  * for internal use only, and may change without notice.
0045  */
0046 
0047 #define OCTEON_FAMILY_MASK  0x00ffff00
0048 #define OCTEON_PRID_MASK    0x00ffffff
0049 
0050 /* Flag bits in top byte */
0051 /* Ignores revision in model checks */
0052 #define OM_IGNORE_REVISION    0x01000000
0053 /* Check submodels */
0054 #define OM_CHECK_SUBMODEL     0x02000000
0055 /* Match all models previous than the one specified */
0056 #define OM_MATCH_PREVIOUS_MODELS  0x04000000
0057 /* Ignores the minor revison on newer parts */
0058 #define OM_IGNORE_MINOR_REVISION  0x08000000
0059 #define OM_FLAG_MASK          0xff000000
0060 
0061 /* Match all cn5XXX Octeon models. */
0062 #define OM_MATCH_5XXX_FAMILY_MODELS 0x20000000
0063 /* Match all cn6XXX Octeon models. */
0064 #define OM_MATCH_6XXX_FAMILY_MODELS 0x40000000
0065 /* Match all cnf7XXX Octeon models. */
0066 #define OM_MATCH_F7XXX_FAMILY_MODELS    0x80000000
0067 /* Match all cn7XXX Octeon models. */
0068 #define OM_MATCH_7XXX_FAMILY_MODELS     0x10000000
0069 #define OM_MATCH_FAMILY_MODELS      (OM_MATCH_5XXX_FAMILY_MODELS |  \
0070                      OM_MATCH_6XXX_FAMILY_MODELS |  \
0071                      OM_MATCH_F7XXX_FAMILY_MODELS | \
0072                      OM_MATCH_7XXX_FAMILY_MODELS)
0073 /*
0074  * CN7XXX models with new revision encoding
0075  */
0076 
0077 #define OCTEON_CNF75XX_PASS1_0  0x000d9800
0078 #define OCTEON_CNF75XX      (OCTEON_CNF75XX_PASS1_0 | OM_IGNORE_REVISION)
0079 #define OCTEON_CNF75XX_PASS1_X  (OCTEON_CNF75XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
0080 
0081 #define OCTEON_CN73XX_PASS1_0   0x000d9700
0082 #define OCTEON_CN73XX_PASS1_1   0x000d9701
0083 #define OCTEON_CN73XX       (OCTEON_CN73XX_PASS1_0 | OM_IGNORE_REVISION)
0084 #define OCTEON_CN73XX_PASS1_X   (OCTEON_CN73XX_PASS1_0 | \
0085                  OM_IGNORE_MINOR_REVISION)
0086 
0087 #define OCTEON_CN70XX_PASS1_0   0x000d9600
0088 #define OCTEON_CN70XX_PASS1_1   0x000d9601
0089 #define OCTEON_CN70XX_PASS1_2   0x000d9602
0090 
0091 #define OCTEON_CN70XX_PASS2_0   0x000d9608
0092 
0093 #define OCTEON_CN70XX       (OCTEON_CN70XX_PASS1_0 | OM_IGNORE_REVISION)
0094 #define OCTEON_CN70XX_PASS1_X   (OCTEON_CN70XX_PASS1_0 | \
0095                  OM_IGNORE_MINOR_REVISION)
0096 #define OCTEON_CN70XX_PASS2_X   (OCTEON_CN70XX_PASS2_0 | \
0097                  OM_IGNORE_MINOR_REVISION)
0098 
0099 #define OCTEON_CN71XX       OCTEON_CN70XX
0100 
0101 #define OCTEON_CN78XX_PASS1_0   0x000d9500
0102 #define OCTEON_CN78XX_PASS1_1   0x000d9501
0103 #define OCTEON_CN78XX_PASS2_0   0x000d9508
0104 
0105 #define OCTEON_CN78XX       (OCTEON_CN78XX_PASS1_0 | OM_IGNORE_REVISION)
0106 #define OCTEON_CN78XX_PASS1_X   (OCTEON_CN78XX_PASS1_0 | \
0107                  OM_IGNORE_MINOR_REVISION)
0108 #define OCTEON_CN78XX_PASS2_X   (OCTEON_CN78XX_PASS2_0 | \
0109                  OM_IGNORE_MINOR_REVISION)
0110 
0111 #define OCTEON_CN76XX       (0x000d9540 | OM_CHECK_SUBMODEL)
0112 
0113 /*
0114  * CNF7XXX models with new revision encoding
0115  */
0116 #define OCTEON_CNF71XX_PASS1_0  0x000d9400
0117 #define OCTEON_CNF71XX_PASS1_1  0x000d9401
0118 
0119 #define OCTEON_CNF71XX      (OCTEON_CNF71XX_PASS1_0 | OM_IGNORE_REVISION)
0120 #define OCTEON_CNF71XX_PASS1_X  (OCTEON_CNF71XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
0121 
0122 /*
0123  * CN6XXX models with new revision encoding
0124  */
0125 #define OCTEON_CN68XX_PASS1_0   0x000d9100
0126 #define OCTEON_CN68XX_PASS1_1   0x000d9101
0127 #define OCTEON_CN68XX_PASS1_2   0x000d9102
0128 #define OCTEON_CN68XX_PASS2_0   0x000d9108
0129 #define OCTEON_CN68XX_PASS2_1   0x000d9109
0130 #define OCTEON_CN68XX_PASS2_2   0x000d910a
0131 
0132 #define OCTEON_CN68XX       (OCTEON_CN68XX_PASS2_0 | OM_IGNORE_REVISION)
0133 #define OCTEON_CN68XX_PASS1_X   (OCTEON_CN68XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
0134 #define OCTEON_CN68XX_PASS2_X   (OCTEON_CN68XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
0135 
0136 #define OCTEON_CN68XX_PASS1 OCTEON_CN68XX_PASS1_X
0137 #define OCTEON_CN68XX_PASS2 OCTEON_CN68XX_PASS2_X
0138 
0139 #define OCTEON_CN66XX_PASS1_0   0x000d9200
0140 #define OCTEON_CN66XX_PASS1_2   0x000d9202
0141 
0142 #define OCTEON_CN66XX       (OCTEON_CN66XX_PASS1_0 | OM_IGNORE_REVISION)
0143 #define OCTEON_CN66XX_PASS1_X   (OCTEON_CN66XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
0144 
0145 #define OCTEON_CN63XX_PASS1_0   0x000d9000
0146 #define OCTEON_CN63XX_PASS1_1   0x000d9001
0147 #define OCTEON_CN63XX_PASS1_2   0x000d9002
0148 #define OCTEON_CN63XX_PASS2_0   0x000d9008
0149 #define OCTEON_CN63XX_PASS2_1   0x000d9009
0150 #define OCTEON_CN63XX_PASS2_2   0x000d900a
0151 
0152 #define OCTEON_CN63XX       (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_REVISION)
0153 #define OCTEON_CN63XX_PASS1_X   (OCTEON_CN63XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
0154 #define OCTEON_CN63XX_PASS2_X   (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
0155 
0156 /* CN62XX is same as CN63XX with 1 MB cache */
0157 #define OCTEON_CN62XX           OCTEON_CN63XX
0158 
0159 #define OCTEON_CN61XX_PASS1_0   0x000d9300
0160 #define OCTEON_CN61XX_PASS1_1   0x000d9301
0161 
0162 #define OCTEON_CN61XX       (OCTEON_CN61XX_PASS1_0 | OM_IGNORE_REVISION)
0163 #define OCTEON_CN61XX_PASS1_X   (OCTEON_CN61XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
0164 
0165 /* CN60XX is same as CN61XX with 512 KB cache */
0166 #define OCTEON_CN60XX           OCTEON_CN61XX
0167 
0168 /*
0169  * CN5XXX models with new revision encoding
0170  */
0171 #define OCTEON_CN58XX_PASS1_0   0x000d0300
0172 #define OCTEON_CN58XX_PASS1_1   0x000d0301
0173 #define OCTEON_CN58XX_PASS1_2   0x000d0303
0174 #define OCTEON_CN58XX_PASS2_0   0x000d0308
0175 #define OCTEON_CN58XX_PASS2_1   0x000d0309
0176 #define OCTEON_CN58XX_PASS2_2   0x000d030a
0177 #define OCTEON_CN58XX_PASS2_3   0x000d030b
0178 
0179 #define OCTEON_CN58XX       (OCTEON_CN58XX_PASS2_0 | OM_IGNORE_REVISION)
0180 #define OCTEON_CN58XX_PASS1_X   (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
0181 #define OCTEON_CN58XX_PASS2_X   (OCTEON_CN58XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
0182 #define OCTEON_CN58XX_PASS1 OCTEON_CN58XX_PASS1_X
0183 #define OCTEON_CN58XX_PASS2 OCTEON_CN58XX_PASS2_X
0184 
0185 #define OCTEON_CN56XX_PASS1_0   0x000d0400
0186 #define OCTEON_CN56XX_PASS1_1   0x000d0401
0187 #define OCTEON_CN56XX_PASS2_0   0x000d0408
0188 #define OCTEON_CN56XX_PASS2_1   0x000d0409
0189 
0190 #define OCTEON_CN56XX       (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_REVISION)
0191 #define OCTEON_CN56XX_PASS1_X   (OCTEON_CN56XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
0192 #define OCTEON_CN56XX_PASS2_X   (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
0193 #define OCTEON_CN56XX_PASS1 OCTEON_CN56XX_PASS1_X
0194 #define OCTEON_CN56XX_PASS2 OCTEON_CN56XX_PASS2_X
0195 
0196 #define OCTEON_CN57XX       OCTEON_CN56XX
0197 #define OCTEON_CN57XX_PASS1 OCTEON_CN56XX_PASS1
0198 #define OCTEON_CN57XX_PASS2 OCTEON_CN56XX_PASS2
0199 
0200 #define OCTEON_CN55XX       OCTEON_CN56XX
0201 #define OCTEON_CN55XX_PASS1 OCTEON_CN56XX_PASS1
0202 #define OCTEON_CN55XX_PASS2 OCTEON_CN56XX_PASS2
0203 
0204 #define OCTEON_CN54XX       OCTEON_CN56XX
0205 #define OCTEON_CN54XX_PASS1 OCTEON_CN56XX_PASS1
0206 #define OCTEON_CN54XX_PASS2 OCTEON_CN56XX_PASS2
0207 
0208 #define OCTEON_CN50XX_PASS1_0   0x000d0600
0209 
0210 #define OCTEON_CN50XX       (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_REVISION)
0211 #define OCTEON_CN50XX_PASS1_X   (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
0212 #define OCTEON_CN50XX_PASS1 OCTEON_CN50XX_PASS1_X
0213 
0214 /*
0215  * NOTE: Octeon CN5000F model is not identifiable using the
0216  * OCTEON_IS_MODEL() functions, but are treated as CN50XX.
0217  */
0218 
0219 #define OCTEON_CN52XX_PASS1_0   0x000d0700
0220 #define OCTEON_CN52XX_PASS2_0   0x000d0708
0221 
0222 #define OCTEON_CN52XX       (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_REVISION)
0223 #define OCTEON_CN52XX_PASS1_X   (OCTEON_CN52XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
0224 #define OCTEON_CN52XX_PASS2_X   (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
0225 #define OCTEON_CN52XX_PASS1 OCTEON_CN52XX_PASS1_X
0226 #define OCTEON_CN52XX_PASS2 OCTEON_CN52XX_PASS2_X
0227 
0228 /*
0229  * CN3XXX models with old revision enconding
0230  */
0231 #define OCTEON_CN38XX_PASS1 0x000d0000
0232 #define OCTEON_CN38XX_PASS2 0x000d0001
0233 #define OCTEON_CN38XX_PASS3 0x000d0003
0234 #define OCTEON_CN38XX       (OCTEON_CN38XX_PASS3 | OM_IGNORE_REVISION)
0235 
0236 #define OCTEON_CN36XX       OCTEON_CN38XX
0237 #define OCTEON_CN36XX_PASS2 OCTEON_CN38XX_PASS2
0238 #define OCTEON_CN36XX_PASS3 OCTEON_CN38XX_PASS3
0239 
0240 /* The OCTEON_CN31XX matches CN31XX models and the CN3020 */
0241 #define OCTEON_CN31XX_PASS1 0x000d0100
0242 #define OCTEON_CN31XX_PASS1_1   0x000d0102
0243 #define OCTEON_CN31XX       (OCTEON_CN31XX_PASS1 | OM_IGNORE_REVISION)
0244 
0245 /*
0246  * This model is only used for internal checks, it is not a valid
0247  * model for the OCTEON_MODEL environment variable.  This matches the
0248  * CN3010 and CN3005 but NOT the CN3020.
0249  */
0250 #define OCTEON_CN30XX_PASS1 0x000d0200
0251 #define OCTEON_CN30XX_PASS1_1   0x000d0202
0252 #define OCTEON_CN30XX       (OCTEON_CN30XX_PASS1 | OM_IGNORE_REVISION)
0253 
0254 #define OCTEON_CN3005_PASS1 (0x000d0210 | OM_CHECK_SUBMODEL)
0255 #define OCTEON_CN3005_PASS1_0   (0x000d0210 | OM_CHECK_SUBMODEL)
0256 #define OCTEON_CN3005_PASS1_1   (0x000d0212 | OM_CHECK_SUBMODEL)
0257 #define OCTEON_CN3005       (OCTEON_CN3005_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
0258 
0259 #define OCTEON_CN3010_PASS1 (0x000d0200 | OM_CHECK_SUBMODEL)
0260 #define OCTEON_CN3010_PASS1_0   (0x000d0200 | OM_CHECK_SUBMODEL)
0261 #define OCTEON_CN3010_PASS1_1   (0x000d0202 | OM_CHECK_SUBMODEL)
0262 #define OCTEON_CN3010       (OCTEON_CN3010_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
0263 
0264 #define OCTEON_CN3020_PASS1 (0x000d0110 | OM_CHECK_SUBMODEL)
0265 #define OCTEON_CN3020_PASS1_0   (0x000d0110 | OM_CHECK_SUBMODEL)
0266 #define OCTEON_CN3020_PASS1_1   (0x000d0112 | OM_CHECK_SUBMODEL)
0267 #define OCTEON_CN3020       (OCTEON_CN3020_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
0268 
0269 /*
0270  * This matches the complete family of CN3xxx CPUs, and not subsequent
0271  * models
0272  */
0273 #define OCTEON_CN3XXX       (OCTEON_CN58XX_PASS1_0 | OM_MATCH_PREVIOUS_MODELS | OM_IGNORE_REVISION)
0274 #define OCTEON_CN5XXX       (OCTEON_CN58XX_PASS1_0 | OM_MATCH_5XXX_FAMILY_MODELS)
0275 #define OCTEON_CN6XXX       (OCTEON_CN63XX_PASS1_0 | OM_MATCH_6XXX_FAMILY_MODELS)
0276 #define OCTEON_CNF7XXX      (OCTEON_CNF71XX_PASS1_0 | \
0277                  OM_MATCH_F7XXX_FAMILY_MODELS)
0278 #define OCTEON_CN7XXX       (OCTEON_CN78XX_PASS1_0 | \
0279                  OM_MATCH_7XXX_FAMILY_MODELS)
0280 
0281 /* The revision byte (low byte) has two different encodings.
0282  * CN3XXX:
0283  *
0284  *     bits
0285  *     <7:5>: reserved (0)
0286  *     <4>:   alternate package
0287  *     <3:0>: revision
0288  *
0289  * CN5XXX and older models:
0290  *
0291  *     bits
0292  *     <7>:   reserved (0)
0293  *     <6>:   alternate package
0294  *     <5:3>: major revision
0295  *     <2:0>: minor revision
0296  *
0297  */
0298 
0299 /* Masks used for the various types of model/family/revision matching */
0300 #define OCTEON_38XX_FAMILY_MASK      0x00ffff00
0301 #define OCTEON_38XX_FAMILY_REV_MASK  0x00ffff0f
0302 #define OCTEON_38XX_MODEL_MASK       0x00ffff10
0303 #define OCTEON_38XX_MODEL_REV_MASK   (OCTEON_38XX_FAMILY_REV_MASK | OCTEON_38XX_MODEL_MASK)
0304 
0305 /* CN5XXX and later use different layout of bits in the revision ID field */
0306 #define OCTEON_58XX_FAMILY_MASK      OCTEON_38XX_FAMILY_MASK
0307 #define OCTEON_58XX_FAMILY_REV_MASK  0x00ffff3f
0308 #define OCTEON_58XX_MODEL_MASK       0x00ffff40
0309 #define OCTEON_58XX_MODEL_REV_MASK   (OCTEON_58XX_FAMILY_REV_MASK | OCTEON_58XX_MODEL_MASK)
0310 #define OCTEON_58XX_MODEL_MINOR_REV_MASK (OCTEON_58XX_MODEL_REV_MASK & 0x00ffff38)
0311 #define OCTEON_5XXX_MODEL_MASK       0x00ff0fc0
0312 
0313 static inline uint32_t cvmx_get_proc_id(void) __attribute__ ((pure));
0314 static inline uint64_t cvmx_read_csr(uint64_t csr_addr);
0315 
0316 #define __OCTEON_MATCH_MASK__(x, y, z) (((x) & (z)) == ((y) & (z)))
0317 
0318 /*
0319  * __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model)
0320  * returns true if chip_model is identical or belong to the OCTEON
0321  * model group specified in arg_model.
0322  */
0323 /* NOTE: This for internal use only! */
0324 #define __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model)      \
0325 ((((arg_model & OCTEON_38XX_FAMILY_MASK) < OCTEON_CN58XX_PASS1_0)  && ( \
0326         ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
0327             && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_MASK)) || \
0328         ((((arg_model) & (OM_FLAG_MASK)) == 0)          \
0329             && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_REV_MASK)) || \
0330         ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
0331             && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_MASK)) || \
0332         ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL)  \
0333             && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_REV_MASK)) || \
0334         ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
0335             && (((chip_model) & OCTEON_38XX_MODEL_MASK) < ((arg_model) & OCTEON_38XX_MODEL_MASK))) \
0336         )) ||                           \
0337     (((arg_model & OCTEON_38XX_FAMILY_MASK) >= OCTEON_CN58XX_PASS1_0)  && ( \
0338         ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
0339             && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
0340         ((((arg_model) & (OM_FLAG_MASK)) == 0)          \
0341             && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_REV_MASK)) || \
0342         ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_MINOR_REVISION) \
0343             && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MINOR_REV_MASK)) || \
0344         ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
0345             && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_MASK)) || \
0346         ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL)  \
0347             && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
0348         ((((arg_model) & (OM_MATCH_5XXX_FAMILY_MODELS)) == OM_MATCH_5XXX_FAMILY_MODELS) \
0349             && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN58XX_PASS1_0) \
0350             && ((chip_model & OCTEON_PRID_MASK) < OCTEON_CN63XX_PASS1_0)) || \
0351         ((((arg_model) & (OM_MATCH_6XXX_FAMILY_MODELS)) == OM_MATCH_6XXX_FAMILY_MODELS) \
0352             && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN63XX_PASS1_0) \
0353             && ((chip_model & OCTEON_PRID_MASK) < OCTEON_CNF71XX_PASS1_0)) || \
0354         ((((arg_model) & (OM_MATCH_F7XXX_FAMILY_MODELS)) == OM_MATCH_F7XXX_FAMILY_MODELS) \
0355             && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CNF71XX_PASS1_0) \
0356             && ((chip_model & OCTEON_PRID_MASK) < OCTEON_CN78XX_PASS1_0)) || \
0357         ((((arg_model) & (OM_MATCH_7XXX_FAMILY_MODELS)) == OM_MATCH_7XXX_FAMILY_MODELS) \
0358             && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN78XX_PASS1_0)) || \
0359         ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
0360             && (((chip_model) & OCTEON_58XX_MODEL_MASK) < ((arg_model) & OCTEON_58XX_MODEL_MASK))) \
0361         )))
0362 
0363 /* NOTE: This for internal use only!!!!! */
0364 static inline int __octeon_is_model_runtime__(uint32_t model)
0365 {
0366     uint32_t cpuid = cvmx_get_proc_id();
0367 
0368     return __OCTEON_IS_MODEL_COMPILE__(model, cpuid);
0369 }
0370 
0371 /*
0372  * The OCTEON_IS_MODEL macro should be used for all Octeon model checking done
0373  * in a program.
0374  * This should be kept runtime if at all possible  and must be conditionalized
0375  * with OCTEON_IS_COMMON_BINARY() if runtime checking support is required.
0376  *
0377  * Use of the macro in preprocessor directives ( #if OCTEON_IS_MODEL(...) )
0378  * is NOT SUPPORTED, and should be replaced with CVMX_COMPILED_FOR()
0379  * I.e.:
0380  *  #if OCTEON_IS_MODEL(OCTEON_CN56XX)  ->  #if CVMX_COMPILED_FOR(OCTEON_CN56XX)
0381  */
0382 #define OCTEON_IS_MODEL(x) __octeon_is_model_runtime__(x)
0383 #define OCTEON_IS_COMMON_BINARY() 1
0384 #undef OCTEON_MODEL
0385 
0386 #define OCTEON_IS_OCTEON1() OCTEON_IS_MODEL(OCTEON_CN3XXX)
0387 #define OCTEON_IS_OCTEONPLUS()  OCTEON_IS_MODEL(OCTEON_CN5XXX)
0388 #define OCTEON_IS_OCTEON2()                     \
0389     (OCTEON_IS_MODEL(OCTEON_CN6XXX) || OCTEON_IS_MODEL(OCTEON_CNF71XX))
0390 
0391 #define OCTEON_IS_OCTEON3() OCTEON_IS_MODEL(OCTEON_CN7XXX)
0392 
0393 #define OCTEON_IS_OCTEON1PLUS() (OCTEON_IS_OCTEON1() || OCTEON_IS_OCTEONPLUS())
0394 
0395 const char *__init octeon_model_get_string(uint32_t chip_id);
0396 
0397 /*
0398  * Return the octeon family, i.e., ProcessorID of the PrID register.
0399  *
0400  * @return the octeon family on success, ((unint32_t)-1) on error.
0401  */
0402 static inline uint32_t cvmx_get_octeon_family(void)
0403 {
0404     return cvmx_get_proc_id() & OCTEON_FAMILY_MASK;
0405 }
0406 
0407 #include <asm/octeon/octeon-feature.h>
0408 
0409 #endif /* __OCTEON_MODEL_H__ */