1 /***********************license start***************
2 * Copyright (c) 2003-2010 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 * 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 NETWORKS 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: 52119 $<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.
86 /* Flag bits in top byte */
87 #define OM_IGNORE_REVISION 0x01000000 /* Ignores revision in model checks */
88 #define OM_CHECK_SUBMODEL 0x02000000 /* Check submodels */
89 #define OM_MATCH_PREVIOUS_MODELS 0x04000000 /* Match all models previous than the one specified */
90 #define OM_IGNORE_MINOR_REVISION 0x08000000 /* Ignores the minor revison on newer parts */
91 #define OM_FLAG_MASK 0xff000000
93 #define OM_MATCH_5XXX_FAMILY_MODELS 0x20000000 /* Match all cn5XXX Octeon models. */
94 #define OM_MATCH_6XXX_FAMILY_MODELS 0x40000000 /* Match all cn6XXX Octeon models. */
97 * CN6XXX models with new revision encoding
99 #define OCTEON_CN63XX_PASS1_0 0x000d9000
100 #define OCTEON_CN63XX_PASS1_1 0x000d9001
101 #define OCTEON_CN63XX_PASS1_2 0x000d9002
102 #define OCTEON_CN63XX_PASS2_0 0x000d9008
104 #define OCTEON_CN63XX (OCTEON_CN63XX_PASS1_0 | OM_IGNORE_REVISION)
105 #define OCTEON_CN63XX_PASS1_X (OCTEON_CN63XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
106 #define OCTEON_CN63XX_PASS2_X (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
109 * CN5XXX models with new revision encoding
111 #define OCTEON_CN58XX_PASS1_0 0x000d0300
112 #define OCTEON_CN58XX_PASS1_1 0x000d0301
113 #define OCTEON_CN58XX_PASS1_2 0x000d0303
114 #define OCTEON_CN58XX_PASS2_0 0x000d0308
115 #define OCTEON_CN58XX_PASS2_1 0x000d0309
116 #define OCTEON_CN58XX_PASS2_2 0x000d030a
117 #define OCTEON_CN58XX_PASS2_3 0x000d030b
119 #define OCTEON_CN58XX (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_REVISION)
120 #define OCTEON_CN58XX_PASS1_X (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
121 #define OCTEON_CN58XX_PASS2_X (OCTEON_CN58XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
122 #define OCTEON_CN58XX_PASS1 OCTEON_CN58XX_PASS1_X
123 #define OCTEON_CN58XX_PASS2 OCTEON_CN58XX_PASS2_X
125 #define OCTEON_CN56XX_PASS1_0 0x000d0400
126 #define OCTEON_CN56XX_PASS1_1 0x000d0401
127 #define OCTEON_CN56XX_PASS2_0 0x000d0408
128 #define OCTEON_CN56XX_PASS2_1 0x000d0409
130 #define OCTEON_CN56XX (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_REVISION)
131 #define OCTEON_CN56XX_PASS1_X (OCTEON_CN56XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
132 #define OCTEON_CN56XX_PASS2_X (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
133 #define OCTEON_CN56XX_PASS1 OCTEON_CN56XX_PASS1_X
134 #define OCTEON_CN56XX_PASS2 OCTEON_CN56XX_PASS2_X
136 #define OCTEON_CN57XX OCTEON_CN56XX
137 #define OCTEON_CN57XX_PASS1 OCTEON_CN56XX_PASS1
138 #define OCTEON_CN57XX_PASS2 OCTEON_CN56XX_PASS2
140 #define OCTEON_CN55XX OCTEON_CN56XX
141 #define OCTEON_CN55XX_PASS1 OCTEON_CN56XX_PASS1
142 #define OCTEON_CN55XX_PASS2 OCTEON_CN56XX_PASS2
144 #define OCTEON_CN54XX OCTEON_CN56XX
145 #define OCTEON_CN54XX_PASS1 OCTEON_CN56XX_PASS1
146 #define OCTEON_CN54XX_PASS2 OCTEON_CN56XX_PASS2
148 #define OCTEON_CN50XX_PASS1_0 0x000d0600
150 #define OCTEON_CN50XX (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_REVISION)
151 #define OCTEON_CN50XX_PASS1_X (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
152 #define OCTEON_CN50XX_PASS1 OCTEON_CN50XX_PASS1_X
154 /* NOTE: Octeon CN5000F model is not identifiable using the OCTEON_IS_MODEL()
155 functions, but are treated as CN50XX */
157 #define OCTEON_CN52XX_PASS1_0 0x000d0700
158 #define OCTEON_CN52XX_PASS2_0 0x000d0708
160 #define OCTEON_CN52XX (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_REVISION)
161 #define OCTEON_CN52XX_PASS1_X (OCTEON_CN52XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
162 #define OCTEON_CN52XX_PASS2_X (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
163 #define OCTEON_CN52XX_PASS1 OCTEON_CN52XX_PASS1_X
164 #define OCTEON_CN52XX_PASS2 OCTEON_CN52XX_PASS2_X
167 * CN3XXX models with old revision enconding
169 //#define OCTEON_CN38XX_PASS1 0x000d0000 // is not supported
170 #define OCTEON_CN38XX_PASS2 0x000d0001
171 #define OCTEON_CN38XX_PASS3 0x000d0003
172 #define OCTEON_CN38XX (OCTEON_CN38XX_PASS3 | OM_IGNORE_REVISION)
174 #define OCTEON_CN36XX OCTEON_CN38XX
175 #define OCTEON_CN36XX_PASS2 OCTEON_CN38XX_PASS2
176 #define OCTEON_CN36XX_PASS3 OCTEON_CN38XX_PASS3
178 /* The OCTEON_CN31XX matches CN31XX models and the CN3020 */
179 #define OCTEON_CN31XX_PASS1 0x000d0100
180 #define OCTEON_CN31XX_PASS1_1 0x000d0102
181 #define OCTEON_CN31XX (OCTEON_CN31XX_PASS1 | OM_IGNORE_REVISION)
183 /* This model is only used for internal checks, it
184 ** is not a valid model for the OCTEON_MODEL environment variable.
185 ** This matches the CN3010 and CN3005 but NOT the CN3020*/
186 #define OCTEON_CN30XX_PASS1 0x000d0200
187 #define OCTEON_CN30XX_PASS1_1 0x000d0202
188 #define OCTEON_CN30XX (OCTEON_CN30XX_PASS1 | OM_IGNORE_REVISION)
190 #define OCTEON_CN3005_PASS1 (0x000d0210 | OM_CHECK_SUBMODEL)
191 #define OCTEON_CN3005_PASS1_0 (0x000d0210 | OM_CHECK_SUBMODEL)
192 #define OCTEON_CN3005_PASS1_1 (0x000d0212 | OM_CHECK_SUBMODEL)
193 #define OCTEON_CN3005 (OCTEON_CN3005_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
195 #define OCTEON_CN3010_PASS1 (0x000d0200 | OM_CHECK_SUBMODEL)
196 #define OCTEON_CN3010_PASS1_0 (0x000d0200 | OM_CHECK_SUBMODEL)
197 #define OCTEON_CN3010_PASS1_1 (0x000d0202 | OM_CHECK_SUBMODEL)
198 #define OCTEON_CN3010 (OCTEON_CN3010_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
200 #define OCTEON_CN3020_PASS1 (0x000d0110 | OM_CHECK_SUBMODEL)
201 #define OCTEON_CN3020_PASS1_0 (0x000d0110 | OM_CHECK_SUBMODEL)
202 #define OCTEON_CN3020_PASS1_1 (0x000d0112 | OM_CHECK_SUBMODEL)
203 #define OCTEON_CN3020 (OCTEON_CN3020_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
207 /* This matches the complete family of CN3xxx CPUs, and not subsequent models */
208 #define OCTEON_CN3XXX (OCTEON_CN58XX_PASS1_0 | OM_MATCH_PREVIOUS_MODELS | OM_IGNORE_REVISION)
209 #define OCTEON_CN5XXX (OCTEON_CN58XX_PASS1_0 | OM_MATCH_5XXX_FAMILY_MODELS)
210 #define OCTEON_CN6XXX (OCTEON_CN63XX_PASS1_0 | OM_MATCH_6XXX_FAMILY_MODELS)
212 /* The revision byte (low byte) has two different encodings.
216 ** <7:5>: reserved (0)
217 ** <4>: alternate package
224 ** <6>: alternate package
225 ** <5:3>: major revision
226 ** <2:0>: minor revision
230 /* Masks used for the various types of model/family/revision matching */
231 #define OCTEON_38XX_FAMILY_MASK 0x00ffff00
232 #define OCTEON_38XX_FAMILY_REV_MASK 0x00ffff0f
233 #define OCTEON_38XX_MODEL_MASK 0x00ffff10
234 #define OCTEON_38XX_MODEL_REV_MASK (OCTEON_38XX_FAMILY_REV_MASK | OCTEON_38XX_MODEL_MASK)
236 /* CN5XXX and later use different layout of bits in the revision ID field */
237 #define OCTEON_58XX_FAMILY_MASK OCTEON_38XX_FAMILY_MASK
238 #define OCTEON_58XX_FAMILY_REV_MASK 0x00ffff3f
239 #define OCTEON_58XX_MODEL_MASK 0x00ffffc0
240 #define OCTEON_58XX_MODEL_REV_MASK (OCTEON_58XX_FAMILY_REV_MASK | OCTEON_58XX_MODEL_MASK)
241 #define OCTEON_58XX_MODEL_MINOR_REV_MASK (OCTEON_58XX_MODEL_REV_MASK & 0x00fffff8)
242 #define OCTEON_5XXX_MODEL_MASK 0x00ff0fc0
245 #define __OCTEON_MATCH_MASK__(x,y,z) (((x) & (z)) == ((y) & (z)))
248 /* NOTE: This for internal use only!!!!! */
249 #define __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model) \
250 ((((arg_model & OCTEON_38XX_FAMILY_MASK) < OCTEON_CN58XX_PASS1_0) && (\
251 ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
252 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_MASK)) || \
253 ((((arg_model) & (OM_FLAG_MASK)) == 0) \
254 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_REV_MASK)) || \
255 ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
256 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_MASK)) || \
257 ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL) \
258 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_REV_MASK)) || \
259 ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
260 && (((chip_model) & OCTEON_38XX_MODEL_MASK) < ((arg_model) & OCTEON_38XX_MODEL_MASK))) \
262 (((arg_model & OCTEON_38XX_FAMILY_MASK) >= OCTEON_CN58XX_PASS1_0) && (\
263 ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
264 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
265 ((((arg_model) & (OM_FLAG_MASK)) == 0) \
266 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_REV_MASK)) || \
267 ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_MINOR_REVISION) \
268 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MINOR_REV_MASK)) || \
269 ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
270 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_MASK)) || \
271 ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL) \
272 && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_REV_MASK)) || \
273 ((((arg_model) & (OM_MATCH_5XXX_FAMILY_MODELS)) == OM_MATCH_5XXX_FAMILY_MODELS) \
274 && ((chip_model) >= OCTEON_CN58XX_PASS1_0) && ((chip_model) < OCTEON_CN63XX_PASS1_0)) || \
275 ((((arg_model) & (OM_MATCH_6XXX_FAMILY_MODELS)) == OM_MATCH_6XXX_FAMILY_MODELS) \
276 && ((chip_model) >= OCTEON_CN63XX_PASS1_0)) || \
277 ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
278 && (((chip_model) & OCTEON_58XX_MODEL_MASK) < ((arg_model) & OCTEON_58XX_MODEL_MASK))) \
281 #if defined(USE_RUNTIME_MODEL_CHECKS) || defined(__U_BOOT__) || (defined(__linux__) && defined(__KERNEL__)) || defined(__OCTEON_NEWLIB__) || (defined(__FreeBSD__) && defined(_KERNEL))
283 /* NOTE: This for internal use only!!!!! */
284 static inline int __octeon_is_model_runtime__(uint32_t model)
286 uint32_t cpuid = cvmx_get_proc_id();
288 /* Check for special case of mismarked 3005 samples. We only need to check
289 if the sub model isn't being ignored */
290 if ((model & OM_CHECK_SUBMODEL) == OM_CHECK_SUBMODEL)
292 if (cpuid == OCTEON_CN3010_PASS1 && (cvmx_read_csr(0x80011800800007B8ull) & (1ull << 34)))
295 return(__OCTEON_IS_MODEL_COMPILE__(model, cpuid));
298 /* The OCTEON_IS_MODEL macro should be used for all Octeon model checking done
300 ** This should be kept runtime if at all possible and must be conditionalized
301 ** with OCTEON_IS_COMMON_BINARY() if runtime checking support is required.
303 ** Use of the macro in preprocessor directives ( #if OCTEON_IS_MODEL(...) )
304 ** is NOT SUPPORTED, and should be replaced with CVMX_COMPILED_FOR()
306 ** #if OCTEON_IS_MODEL(OCTEON_CN56XX) -> #if CVMX_COMPILED_FOR(OCTEON_CN56XX)
308 #define OCTEON_IS_MODEL(x) __octeon_is_model_runtime__(x)
309 #define OCTEON_IS_COMMON_BINARY() 1
312 #define CVMX_COMPILED_FOR(x) __OCTEON_IS_MODEL_COMPILE__(x, OCTEON_MODEL)
314 #define OCTEON_IS_MODEL(x) \
315 (((x & (OM_IGNORE_REVISION | OM_IGNORE_MINOR_REVISION)) != 0) \
316 ? __OCTEON_IS_MODEL_COMPILE__(x, OCTEON_MODEL) \
317 : __OCTEON_IS_MODEL_COMPILE__(x, cvmx_get_proc_id()))
319 #define OCTEON_IS_COMMON_BINARY() 0
322 const char *octeon_model_get_string(uint32_t chip_id);
323 const char *octeon_model_get_string_buffer(uint32_t chip_id, char * buffer);
329 #endif /* __OCTEON_MODEL_H__ */