1 /***********************license start***************
2 * Copyright (c) 2003-2010 Cavium Inc. (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 Inc. 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 * This Software, including technical data, may be subject to U.S. export control
24 * laws, including the U.S. Export Administration Act and its associated
25 * regulations, and may be subject to export or import regulations in other
28 * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
29 * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR
30 * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO
31 * THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY REPRESENTATION OR
32 * DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT DEFECTS, AND CAVIUM
33 * SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES OF TITLE,
34 * MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF
35 * VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
36 * CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT OF USE OR
37 * PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
38 ***********************license end**************************************/
48 * File defining different Octeon model IDs and macros to
51 * <hr>$Revision: 70338 $<hr>
54 #ifndef __OCTEON_MODEL_H__
55 #define __OCTEON_MODEL_H__
62 /* NOTE: These must match what is checked in common-config.mk */
63 /* Defines to represent the different versions of Octeon. */
66 /* IMPORTANT: When the default pass is updated for an Octeon Model,
67 ** the corresponding change must also be made in the oct-sim script. */
70 /* The defines below should be used with the OCTEON_IS_MODEL() macro to
71 ** determine what model of chip the software is running on. Models ending
72 ** in 'XX' match multiple models (families), while specific models match only
73 ** that model. If a pass (revision) is specified, then only that revision
74 ** will be matched. Care should be taken when checking for both specific
75 ** models and families that the specific models are checked for first.
76 ** While these defines are similar to the processor ID, they are not intended
77 ** to be used by anything other that the OCTEON_IS_MODEL framework, and
78 ** the values are subject to change at anytime without notice.
80 ** NOTE: only the OCTEON_IS_MODEL() macro/function and the OCTEON_CN* macros
81 ** should be used outside of this file. All other macros are for internal
82 ** use only, and may change without notice.
85 #define OCTEON_FAMILY_MASK 0x00ffff00
87 /* Flag bits in top byte */
88 #define OM_IGNORE_REVISION 0x01000000 /* Ignores revision in model checks */
89 #define OM_CHECK_SUBMODEL 0x02000000 /* Check submodels */
90 #define OM_MATCH_PREVIOUS_MODELS 0x04000000 /* Match all models previous than the one specified */
91 #define OM_IGNORE_MINOR_REVISION 0x08000000 /* Ignores the minor revison on newer parts */
92 #define OM_FLAG_MASK 0xff000000
94 #define OM_MATCH_5XXX_FAMILY_MODELS 0x20000000 /* Match all cn5XXX Octeon models. */
95 #define OM_MATCH_6XXX_FAMILY_MODELS 0x40000000 /* Match all cn6XXX Octeon models. */
96 #define OM_MATCH_F7XXX_FAMILY_MODELS 0x80000000 /* Match all cnf7XXX Octeon models. */
99 * CNF7XXX models with new revision encoding
101 #define OCTEON_CNF71XX_PASS1_0 0x000d9400
103 #define OCTEON_CNF71XX (OCTEON_CNF71XX_PASS1_0 | OM_IGNORE_REVISION)
104 #define OCTEON_CNF71XX_PASS1_X (OCTEON_CNF71XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
107 * CN6XXX models with new revision encoding
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
114 #define OCTEON_CN68XX (OCTEON_CN68XX_PASS2_0 | OM_IGNORE_REVISION)
115 #define OCTEON_CN68XX_PASS1_X (OCTEON_CN68XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
116 #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
121 #define OCTEON_CN66XX_PASS1_0 0x000d9200
122 #define OCTEON_CN66XX_PASS1_2 0x000d9202
124 #define OCTEON_CN66XX (OCTEON_CN66XX_PASS1_0 | OM_IGNORE_REVISION)
125 #define OCTEON_CN66XX_PASS1_X (OCTEON_CN66XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
127 #define OCTEON_CN63XX_PASS1_0 0x000d9000
128 #define OCTEON_CN63XX_PASS1_1 0x000d9001
129 #define OCTEON_CN63XX_PASS1_2 0x000d9002
130 #define OCTEON_CN63XX_PASS2_0 0x000d9008
131 #define OCTEON_CN63XX_PASS2_1 0x000d9009
132 #define OCTEON_CN63XX_PASS2_2 0x000d900a
134 #define OCTEON_CN63XX (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_REVISION)
135 #define OCTEON_CN63XX_PASS1_X (OCTEON_CN63XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
136 #define OCTEON_CN63XX_PASS2_X (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
138 #define OCTEON_CN61XX_PASS1_0 0x000d9300
140 #define OCTEON_CN61XX (OCTEON_CN61XX_PASS1_0 | OM_IGNORE_REVISION)
141 #define OCTEON_CN61XX_PASS1_X (OCTEON_CN61XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
144 * CN5XXX models with new revision encoding
146 #define OCTEON_CN58XX_PASS1_0 0x000d0300
147 #define OCTEON_CN58XX_PASS1_1 0x000d0301
148 #define OCTEON_CN58XX_PASS1_2 0x000d0303
149 #define OCTEON_CN58XX_PASS2_0 0x000d0308
150 #define OCTEON_CN58XX_PASS2_1 0x000d0309
151 #define OCTEON_CN58XX_PASS2_2 0x000d030a
152 #define OCTEON_CN58XX_PASS2_3 0x000d030b
154 #define OCTEON_CN58XX (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_REVISION)
155 #define OCTEON_CN58XX_PASS1_X (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
156 #define OCTEON_CN58XX_PASS2_X (OCTEON_CN58XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
157 #define OCTEON_CN58XX_PASS1 OCTEON_CN58XX_PASS1_X
158 #define OCTEON_CN58XX_PASS2 OCTEON_CN58XX_PASS2_X
160 #define OCTEON_CN56XX_PASS1_0 0x000d0400
161 #define OCTEON_CN56XX_PASS1_1 0x000d0401
162 #define OCTEON_CN56XX_PASS2_0 0x000d0408
163 #define OCTEON_CN56XX_PASS2_1 0x000d0409
165 #define OCTEON_CN56XX (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_REVISION)
166 #define OCTEON_CN56XX_PASS1_X (OCTEON_CN56XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
167 #define OCTEON_CN56XX_PASS2_X (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
168 #define OCTEON_CN56XX_PASS1 OCTEON_CN56XX_PASS1_X
169 #define OCTEON_CN56XX_PASS2 OCTEON_CN56XX_PASS2_X
171 #define OCTEON_CN57XX OCTEON_CN56XX
172 #define OCTEON_CN57XX_PASS1 OCTEON_CN56XX_PASS1
173 #define OCTEON_CN57XX_PASS2 OCTEON_CN56XX_PASS2
175 #define OCTEON_CN55XX OCTEON_CN56XX
176 #define OCTEON_CN55XX_PASS1 OCTEON_CN56XX_PASS1
177 #define OCTEON_CN55XX_PASS2 OCTEON_CN56XX_PASS2
179 #define OCTEON_CN54XX OCTEON_CN56XX
180 #define OCTEON_CN54XX_PASS1 OCTEON_CN56XX_PASS1
181 #define OCTEON_CN54XX_PASS2 OCTEON_CN56XX_PASS2
183 #define OCTEON_CN50XX_PASS1_0 0x000d0600
185 #define OCTEON_CN50XX (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_REVISION)
186 #define OCTEON_CN50XX_PASS1_X (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
187 #define OCTEON_CN50XX_PASS1 OCTEON_CN50XX_PASS1_X
189 /* NOTE: Octeon CN5000F model is not identifiable using the OCTEON_IS_MODEL()
190 functions, but are treated as CN50XX */
192 #define OCTEON_CN52XX_PASS1_0 0x000d0700
193 #define OCTEON_CN52XX_PASS2_0 0x000d0708
195 #define OCTEON_CN52XX (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_REVISION)
196 #define OCTEON_CN52XX_PASS1_X (OCTEON_CN52XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
197 #define OCTEON_CN52XX_PASS2_X (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
198 #define OCTEON_CN52XX_PASS1 OCTEON_CN52XX_PASS1_X
199 #define OCTEON_CN52XX_PASS2 OCTEON_CN52XX_PASS2_X
202 * CN3XXX models with old revision enconding
204 //#define OCTEON_CN38XX_PASS1 0x000d0000 // is not supported
205 #define OCTEON_CN38XX_PASS2 0x000d0001
206 #define OCTEON_CN38XX_PASS3 0x000d0003
207 #define OCTEON_CN38XX (OCTEON_CN38XX_PASS3 | OM_IGNORE_REVISION)
209 #define OCTEON_CN36XX OCTEON_CN38XX
210 #define OCTEON_CN36XX_PASS2 OCTEON_CN38XX_PASS2
211 #define OCTEON_CN36XX_PASS3 OCTEON_CN38XX_PASS3
213 /* The OCTEON_CN31XX matches CN31XX models and the CN3020 */
214 #define OCTEON_CN31XX_PASS1 0x000d0100
215 #define OCTEON_CN31XX_PASS1_1 0x000d0102
216 #define OCTEON_CN31XX (OCTEON_CN31XX_PASS1 | OM_IGNORE_REVISION)
218 /* This model is only used for internal checks, it
219 ** is not a valid model for the OCTEON_MODEL environment variable.
220 ** This matches the CN3010 and CN3005 but NOT the CN3020*/
221 #define OCTEON_CN30XX_PASS1 0x000d0200
222 #define OCTEON_CN30XX_PASS1_1 0x000d0202
223 #define OCTEON_CN30XX (OCTEON_CN30XX_PASS1 | OM_IGNORE_REVISION)
225 #define OCTEON_CN3005_PASS1 (0x000d0210 | OM_CHECK_SUBMODEL)
226 #define OCTEON_CN3005_PASS1_0 (0x000d0210 | OM_CHECK_SUBMODEL)
227 #define OCTEON_CN3005_PASS1_1 (0x000d0212 | OM_CHECK_SUBMODEL)
228 #define OCTEON_CN3005 (OCTEON_CN3005_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
230 #define OCTEON_CN3010_PASS1 (0x000d0200 | OM_CHECK_SUBMODEL)
231 #define OCTEON_CN3010_PASS1_0 (0x000d0200 | OM_CHECK_SUBMODEL)
232 #define OCTEON_CN3010_PASS1_1 (0x000d0202 | OM_CHECK_SUBMODEL)
233 #define OCTEON_CN3010 (OCTEON_CN3010_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
235 #define OCTEON_CN3020_PASS1 (0x000d0110 | OM_CHECK_SUBMODEL)
236 #define OCTEON_CN3020_PASS1_0 (0x000d0110 | OM_CHECK_SUBMODEL)
237 #define OCTEON_CN3020_PASS1_1 (0x000d0112 | OM_CHECK_SUBMODEL)
238 #define OCTEON_CN3020 (OCTEON_CN3020_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
242 /* This matches the complete family of CN3xxx CPUs, and not subsequent models */
243 #define OCTEON_CN3XXX (OCTEON_CN58XX_PASS1_0 | OM_MATCH_PREVIOUS_MODELS | OM_IGNORE_REVISION)
244 #define OCTEON_CN5XXX (OCTEON_CN58XX_PASS1_0 | OM_MATCH_5XXX_FAMILY_MODELS)
245 #define OCTEON_CN6XXX (OCTEON_CN63XX_PASS1_0 | OM_MATCH_6XXX_FAMILY_MODELS)
246 #define OCTEON_CNF7XXX (OCTEON_CNF71XX_PASS1_0 | OM_MATCH_F7XXX_FAMILY_MODELS)
248 /* The revision byte (low byte) has two different encodings.
252 ** <7:5>: reserved (0)
253 ** <4>: alternate package
260 ** <6>: alternate package
261 ** <5:3>: major revision
262 ** <2:0>: minor revision
266 /* Masks used for the various types of model/family/revision matching */
267 #define OCTEON_38XX_FAMILY_MASK 0x00ffff00
268 #define OCTEON_38XX_FAMILY_REV_MASK 0x00ffff0f
269 #define OCTEON_38XX_MODEL_MASK 0x00ffff10
270 #define OCTEON_38XX_MODEL_REV_MASK (OCTEON_38XX_FAMILY_REV_MASK | OCTEON_38XX_MODEL_MASK)
272 /* CN5XXX and later use different layout of bits in the revision ID field */
273 #define OCTEON_58XX_FAMILY_MASK OCTEON_38XX_FAMILY_MASK
274 #define OCTEON_58XX_FAMILY_REV_MASK 0x00ffff3f
275 #define OCTEON_58XX_MODEL_MASK 0x00ffffc0
276 #define OCTEON_58XX_MODEL_REV_MASK (OCTEON_58XX_FAMILY_REV_MASK | OCTEON_58XX_MODEL_MASK)
277 #define OCTEON_58XX_MODEL_MINOR_REV_MASK (OCTEON_58XX_MODEL_REV_MASK & 0x00fffff8)
278 #define OCTEON_5XXX_MODEL_MASK 0x00ff0fc0
281 #define __OCTEON_MATCH_MASK__(x,y,z) (((x) & (z)) == ((y) & (z)))
284 /* NOTE: This for internal use only!!!!! */
285 #define __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model) \
286 ((((arg_model & OCTEON_38XX_FAMILY_MASK) < OCTEON_CN58XX_PASS1_0) && (\
287 ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
288 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_MASK)) || \
289 ((((arg_model) & (OM_FLAG_MASK)) == 0) \
290 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_REV_MASK)) || \
291 ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
292 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_MASK)) || \
293 ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL) \
294 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_REV_MASK)) || \
295 ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
296 && (((chip_model) & OCTEON_38XX_MODEL_MASK) < ((arg_model) & OCTEON_38XX_MODEL_MASK))) \
298 (((arg_model & OCTEON_38XX_FAMILY_MASK) >= OCTEON_CN58XX_PASS1_0) && (\
299 ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
300 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
301 ((((arg_model) & (OM_FLAG_MASK)) == 0) \
302 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_REV_MASK)) || \
303 ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_MINOR_REVISION) \
304 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MINOR_REV_MASK)) || \
305 ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
306 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_MASK)) || \
307 ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL) \
308 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_REV_MASK)) || \
309 ((((arg_model) & (OM_MATCH_5XXX_FAMILY_MODELS)) == OM_MATCH_5XXX_FAMILY_MODELS) \
310 && ((chip_model) >= OCTEON_CN58XX_PASS1_0) && ((chip_model) < OCTEON_CN63XX_PASS1_0)) || \
311 ((((arg_model) & (OM_MATCH_6XXX_FAMILY_MODELS)) == OM_MATCH_6XXX_FAMILY_MODELS) \
312 && ((chip_model) >= OCTEON_CN63XX_PASS1_0) && ((chip_model) < OCTEON_CNF71XX_PASS1_0)) || \
313 ((((arg_model) & (OM_MATCH_F7XXX_FAMILY_MODELS)) == OM_MATCH_F7XXX_FAMILY_MODELS) \
314 && ((chip_model) >= OCTEON_CNF71XX_PASS1_0)) || \
315 ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
316 && (((chip_model) & OCTEON_58XX_MODEL_MASK) < ((arg_model) & OCTEON_58XX_MODEL_MASK))) \
319 #ifndef OCTEON_IS_MODEL
320 #if defined(USE_RUNTIME_MODEL_CHECKS) || defined(__U_BOOT__) || (defined(__linux__) && defined(__KERNEL__)) || defined(CVMX_BUILD_FOR_TOOLCHAIN) || (defined(__FreeBSD__) && defined(_KERNEL) && !defined(OCTEON_MODEL))
322 /* NOTE: This for internal use only!!!!! */
323 static inline int __octeon_is_model_runtime__(uint32_t model)
325 uint32_t cpuid = cvmx_get_proc_id();
327 /* Check for special case of mismarked 3005 samples. We only need to check
328 if the sub model isn't being ignored */
329 if ((model & OM_CHECK_SUBMODEL) == OM_CHECK_SUBMODEL)
331 if (cpuid == OCTEON_CN3010_PASS1 && (cvmx_read_csr(0x80011800800007B8ull) & (1ull << 34)))
334 return(__OCTEON_IS_MODEL_COMPILE__(model, cpuid));
337 /* The OCTEON_IS_MODEL macro should be used for all Octeon model checking done
339 ** This should be kept runtime if at all possible and must be conditionalized
340 ** with OCTEON_IS_COMMON_BINARY() if runtime checking support is required.
342 ** Use of the macro in preprocessor directives ( #if OCTEON_IS_MODEL(...) )
343 ** is NOT SUPPORTED, and should be replaced with CVMX_COMPILED_FOR()
345 ** #if OCTEON_IS_MODEL(OCTEON_CN56XX) -> #if CVMX_COMPILED_FOR(OCTEON_CN56XX)
347 #define OCTEON_IS_MODEL(x) __octeon_is_model_runtime__(x)
348 #define OCTEON_IS_COMMON_BINARY() 1
351 #define CVMX_COMPILED_FOR(x) __OCTEON_IS_MODEL_COMPILE__(x, OCTEON_MODEL)
353 #define OCTEON_IS_MODEL(x) \
354 (((x & (OM_IGNORE_REVISION | OM_IGNORE_MINOR_REVISION)) != 0) \
355 ? __OCTEON_IS_MODEL_COMPILE__(x, OCTEON_MODEL) \
356 : __OCTEON_IS_MODEL_COMPILE__(x, cvmx_get_proc_id()))
358 #define OCTEON_IS_COMMON_BINARY() 0
362 int octeon_model_version_check(uint32_t chip_id);
363 const char *octeon_model_get_string(uint32_t chip_id);
364 const char *octeon_model_get_string_buffer(uint32_t chip_id, char * buffer);
367 * Return the octeon family, i.e., ProcessorID of the PrID register.
369 * @return the octeon family on success, ((unint32_t)-1) on error.
371 static inline uint32_t cvmx_get_octeon_family(void)
373 #if defined(USE_RUNTIME_MODEL_CHECKS) || defined(__U_BOOT__) || (defined(__linux__) && defined(__KERNEL__)) || defined(CVMX_BUILD_FOR_TOOLCHAIN) || (defined(__FreeBSD__) && defined(_KERNEL))
374 return (cvmx_get_proc_id() & OCTEON_FAMILY_MASK);
376 return (OCTEON_MODEL & OCTEON_FAMILY_MASK);
384 #endif /* __OCTEON_MODEL_H__ */