1 /***********************license start***************
2 * Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above
14 * copyright notice, this list of conditions and the following
15 * disclaimer in the documentation and/or other materials provided
16 * with the distribution.
18 * * Neither the name of Cavium Networks nor the names of
19 * its contributors may be used to endorse or promote products
20 * derived from this software without specific prior written
23 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
24 * AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
25 * OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
26 * RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
27 * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
28 * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
29 * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
30 * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
31 * POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT
32 * OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
35 * For any questions regarding licensing please contact marketing@caviumnetworks.com
37 ***********************license end**************************************/
46 * File defining different Octeon model IDs and macros to
49 * <hr>$Revision: 41586 $<hr>
52 #ifndef __OCTEON_MODEL_H__
53 #define __OCTEON_MODEL_H__
60 /* NOTE: These must match what is checked in common-config.mk */
61 /* Defines to represent the different versions of Octeon. */
64 /* IMPORTANT: When the default pass is updated for an Octeon Model,
65 ** the corresponding change must also be made in the oct-sim script. */
68 /* The defines below should be used with the OCTEON_IS_MODEL() macro to
69 ** determine what model of chip the software is running on. Models ending
70 ** in 'XX' match multiple models (families), while specific models match only
71 ** that model. If a pass (revision) is specified, then only that revision
72 ** will be matched. Care should be taken when checking for both specific
73 ** models and families that the specific models are checked for first.
74 ** While these defines are similar to the processor ID, they are not intended
75 ** to be used by anything other that the OCTEON_IS_MODEL framework, and
76 ** the values are subject to change at anytime without notice.
78 ** NOTE: only the OCTEON_IS_MODEL() macro/function and the OCTEON_CN* macros
79 ** should be used outside of this file. All other macros are for internal
80 ** use only, and may change without notice.
84 /* Flag bits in top byte */
85 #define OM_IGNORE_REVISION 0x01000000 /* Ignores revision in model checks */
86 #define OM_CHECK_SUBMODEL 0x02000000 /* Check submodels */
87 #define OM_MATCH_PREVIOUS_MODELS 0x04000000 /* Match all models previous than the one specified */
88 #define OM_IGNORE_MINOR_REVISION 0x08000000 /* Ignores the minor revison on newer parts */
89 #define OM_FLAG_MASK 0xff000000
92 * CN5XXX models with new revision encoding
94 #define OCTEON_CN58XX_PASS1_0 0x000d0300
95 #define OCTEON_CN58XX_PASS1_1 0x000d0301
96 #define OCTEON_CN58XX_PASS1_2 0x000d0303
97 #define OCTEON_CN58XX_PASS2_0 0x000d0308
98 #define OCTEON_CN58XX_PASS2_1 0x000d0309
99 #define OCTEON_CN58XX_PASS2_2 0x000d030a
100 #define OCTEON_CN58XX_PASS2_3 0x000d030b
102 #define OCTEON_CN58XX (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_REVISION)
103 #define OCTEON_CN58XX_PASS1_X (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
104 #define OCTEON_CN58XX_PASS2_X (OCTEON_CN58XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
105 #define OCTEON_CN58XX_PASS1 OCTEON_CN58XX_PASS1_X
106 #define OCTEON_CN58XX_PASS2 OCTEON_CN58XX_PASS2_X
108 #define OCTEON_CN56XX_PASS1_0 0x000d0400
109 #define OCTEON_CN56XX_PASS1_1 0x000d0401
110 #define OCTEON_CN56XX_PASS2_0 0x000d0408
111 #define OCTEON_CN56XX_PASS2_1 0x000d0409
113 #define OCTEON_CN56XX (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_REVISION)
114 #define OCTEON_CN56XX_PASS1_X (OCTEON_CN56XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
115 #define OCTEON_CN56XX_PASS2_X (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
116 #define OCTEON_CN56XX_PASS1 OCTEON_CN56XX_PASS1_X
117 #define OCTEON_CN56XX_PASS2 OCTEON_CN56XX_PASS2_X
119 #define OCTEON_CN57XX OCTEON_CN56XX
120 #define OCTEON_CN57XX_PASS1 OCTEON_CN56XX_PASS1
121 #define OCTEON_CN57XX_PASS2 OCTEON_CN56XX_PASS2
123 #define OCTEON_CN55XX OCTEON_CN56XX
124 #define OCTEON_CN55XX_PASS1 OCTEON_CN56XX_PASS1
125 #define OCTEON_CN55XX_PASS2 OCTEON_CN56XX_PASS2
127 #define OCTEON_CN54XX OCTEON_CN56XX
128 #define OCTEON_CN54XX_PASS1 OCTEON_CN56XX_PASS1
129 #define OCTEON_CN54XX_PASS2 OCTEON_CN56XX_PASS2
131 #define OCTEON_CN50XX_PASS1_0 0x000d0600
133 #define OCTEON_CN50XX (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_REVISION)
134 #define OCTEON_CN50XX_PASS1_X (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
135 #define OCTEON_CN50XX_PASS1 OCTEON_CN50XX_PASS1_X
137 /* NOTE: Octeon CN5000F model is not identifiable using the OCTEON_IS_MODEL()
138 functions, but are treated as CN50XX */
140 #define OCTEON_CN52XX_PASS1_0 0x000d0700
141 #define OCTEON_CN52XX_PASS2_0 0x000d0708
143 #define OCTEON_CN52XX (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_REVISION)
144 #define OCTEON_CN52XX_PASS1_X (OCTEON_CN52XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
145 #define OCTEON_CN52XX_PASS2_X (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
146 #define OCTEON_CN52XX_PASS1 OCTEON_CN52XX_PASS1_X
147 #define OCTEON_CN52XX_PASS2 OCTEON_CN52XX_PASS2_X
150 * CN3XXX models with old revision enconding
152 #define OCTEON_CN38XX_PASS1 0x000d0000
153 #define OCTEON_CN38XX_PASS2 0x000d0001
154 #define OCTEON_CN38XX_PASS3 0x000d0003
155 #define OCTEON_CN38XX (OCTEON_CN38XX_PASS3 | OM_IGNORE_REVISION)
157 #define OCTEON_CN36XX OCTEON_CN38XX
158 #define OCTEON_CN36XX_PASS2 OCTEON_CN38XX_PASS2
159 #define OCTEON_CN36XX_PASS3 OCTEON_CN38XX_PASS3
161 /* The OCTEON_CN31XX matches CN31XX models and the CN3020 */
162 #define OCTEON_CN31XX_PASS1 0x000d0100
163 #define OCTEON_CN31XX_PASS1_1 0x000d0102
164 #define OCTEON_CN31XX (OCTEON_CN31XX_PASS1 | OM_IGNORE_REVISION)
166 /* This model is only used for internal checks, it
167 ** is not a valid model for the OCTEON_MODEL environment variable.
168 ** This matches the CN3010 and CN3005 but NOT the CN3020*/
169 #define OCTEON_CN30XX_PASS1 0x000d0200
170 #define OCTEON_CN30XX_PASS1_1 0x000d0202
171 #define OCTEON_CN30XX (OCTEON_CN30XX_PASS1 | OM_IGNORE_REVISION)
173 #define OCTEON_CN3005_PASS1 (0x000d0210 | OM_CHECK_SUBMODEL)
174 #define OCTEON_CN3005_PASS1_0 (0x000d0210 | OM_CHECK_SUBMODEL)
175 #define OCTEON_CN3005_PASS1_1 (0x000d0212 | OM_CHECK_SUBMODEL)
176 #define OCTEON_CN3005 (OCTEON_CN3005_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
178 #define OCTEON_CN3010_PASS1 (0x000d0200 | OM_CHECK_SUBMODEL)
179 #define OCTEON_CN3010_PASS1_0 (0x000d0200 | OM_CHECK_SUBMODEL)
180 #define OCTEON_CN3010_PASS1_1 (0x000d0202 | OM_CHECK_SUBMODEL)
181 #define OCTEON_CN3010 (OCTEON_CN3010_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
183 #define OCTEON_CN3020_PASS1 (0x000d0110 | OM_CHECK_SUBMODEL)
184 #define OCTEON_CN3020_PASS1_0 (0x000d0110 | OM_CHECK_SUBMODEL)
185 #define OCTEON_CN3020_PASS1_1 (0x000d0112 | OM_CHECK_SUBMODEL)
186 #define OCTEON_CN3020 (OCTEON_CN3020_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
190 /* This matches the complete family of CN3xxx CPUs, and not subsequent models */
191 #define OCTEON_CN3XXX (OCTEON_CN58XX_PASS1_0 | OM_MATCH_PREVIOUS_MODELS | OM_IGNORE_REVISION)
193 /* The revision byte (low byte) has two different encodings.
197 ** <7:5>: reserved (0)
198 ** <4>: alternate package
205 ** <6>: alternate package
206 ** <5:3>: major revision
207 ** <2:0>: minor revision
211 /* Masks used for the various types of model/family/revision matching */
212 #define OCTEON_38XX_FAMILY_MASK 0x00ffff00
213 #define OCTEON_38XX_FAMILY_REV_MASK 0x00ffff0f
214 #define OCTEON_38XX_MODEL_MASK 0x00ffff10
215 #define OCTEON_38XX_MODEL_REV_MASK (OCTEON_38XX_FAMILY_REV_MASK | OCTEON_38XX_MODEL_MASK)
217 /* CN5XXX and later use different layout of bits in the revision ID field */
218 #define OCTEON_58XX_FAMILY_MASK OCTEON_38XX_FAMILY_MASK
219 #define OCTEON_58XX_FAMILY_REV_MASK 0x00ffff3f
220 #define OCTEON_58XX_MODEL_MASK 0x00ffffc0
221 #define OCTEON_58XX_MODEL_REV_MASK (OCTEON_58XX_FAMILY_REV_MASK | OCTEON_58XX_MODEL_MASK)
222 #define OCTEON_58XX_MODEL_MINOR_REV_MASK (OCTEON_58XX_MODEL_REV_MASK & 0x00fffff8)
225 #define __OCTEON_MATCH_MASK__(x,y,z) (((x) & (z)) == ((y) & (z)))
228 /* NOTE: This for internal use only!!!!! */
229 #define __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model) \
230 ((((arg_model & OCTEON_38XX_FAMILY_MASK) < OCTEON_CN58XX_PASS1_0) && (\
231 ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
232 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_MASK)) || \
233 ((((arg_model) & (OM_FLAG_MASK)) == 0) \
234 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_REV_MASK)) || \
235 ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
236 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_MASK)) || \
237 ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL) \
238 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_REV_MASK)) || \
239 ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
240 && (((chip_model) & OCTEON_38XX_MODEL_MASK) < ((arg_model) & OCTEON_38XX_MODEL_MASK))) \
242 (((arg_model & OCTEON_38XX_FAMILY_MASK) >= OCTEON_CN58XX_PASS1_0) && (\
243 ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
244 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
245 ((((arg_model) & (OM_FLAG_MASK)) == 0) \
246 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_REV_MASK)) || \
247 ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_MINOR_REVISION) \
248 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MINOR_REV_MASK)) || \
249 ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
250 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_MASK)) || \
251 ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL) \
252 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_REV_MASK)) || \
253 ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
254 && (((chip_model) & OCTEON_58XX_MODEL_MASK) < ((arg_model) & OCTEON_58XX_MODEL_MASK))) \
257 #if defined(USE_RUNTIME_MODEL_CHECKS) || defined(__U_BOOT__) || (defined(__linux__) && defined(__KERNEL__)) || (defined(__FreeBSD__) && defined(_KERNEL))
259 /* NOTE: This for internal use only!!!!! */
260 static inline int __octeon_is_model_runtime__(uint32_t model)
262 uint32_t cpuid = cvmx_get_proc_id();
264 /* Check for special case of mismarked 3005 samples. We only need to check
265 if the sub model isn't being ignored */
266 if ((model & OM_CHECK_SUBMODEL) == OM_CHECK_SUBMODEL)
268 if (cpuid == OCTEON_CN3010_PASS1 && (cvmx_read_csr(0x80011800800007B8ull) & (1ull << 34)))
271 return(__OCTEON_IS_MODEL_COMPILE__(model, cpuid));
274 /* The OCTEON_IS_MODEL macro should be used for all Octeon model checking done
276 ** This should be kept runtime if at all possible and must be conditionalized
277 ** with OCTEON_IS_COMMON_BINARY() if runtime checking support is required.
279 ** Use of the macro in preprocessor directives ( #if OCTEON_IS_MODEL(...) )
280 ** is NOT SUPPORTED, and should be replaced with CVMX_COMPILED_FOR()
282 ** #if OCTEON_IS_MODEL(OCTEON_CN56XX) -> #if CVMX_COMPILED_FOR(OCTEON_CN56XX)
284 #define OCTEON_IS_MODEL(x) __octeon_is_model_runtime__(x)
285 #define OCTEON_IS_COMMON_BINARY() 1
288 #define CVMX_COMPILED_FOR(x) __OCTEON_IS_MODEL_COMPILE__(x, OCTEON_MODEL)
290 #define OCTEON_IS_MODEL(x) \
291 (((x & (OM_IGNORE_REVISION | OM_IGNORE_MINOR_REVISION)) != 0) \
292 ? __OCTEON_IS_MODEL_COMPILE__(x, OCTEON_MODEL) \
293 : __OCTEON_IS_MODEL_COMPILE__(x, cvmx_get_proc_id()))
295 #define OCTEON_IS_COMMON_BINARY() 0
298 const char *octeon_model_get_string(uint32_t chip_id);
299 const char *octeon_model_get_string_buffer(uint32_t chip_id, char * buffer);
301 #include "octeon-feature.h"
307 #endif /* __OCTEON_MODEL_H__ */