Linux Audio

Check our new training course

Loading...
v3.1
  1/***********************license start***************
  2 * Author: Cavium Networks
  3 *
  4 * Contact: support@caviumnetworks.com
  5 * This file is part of the OCTEON SDK
  6 *
  7 * Copyright (c) 2003-2008 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
 28/*
 29 *
 30 * File defining different Octeon model IDs and macros to
 31 * compare them.
 32 *
 33 */
 34
 35#ifndef __OCTEON_MODEL_H__
 36#define __OCTEON_MODEL_H__
 37
 38/*
 39 * The defines below should be used with the OCTEON_IS_MODEL() macro
 40 * to determine what model of chip the software is running on.  Models
 41 * ending in 'XX' match multiple models (families), while specific
 42 * models match only that model.  If a pass (revision) is specified,
 43 * then only that revision will be matched.  Care should be taken when
 44 * checking for both specific models and families that the specific
 45 * models are checked for first.  While these defines are similar to
 46 * the processor ID, they are not intended to be used by anything
 47 * other that the OCTEON_IS_MODEL framework, and the values are
 48 * subject to change at anytime without notice.
 49 *
 50 * NOTE: only the OCTEON_IS_MODEL() macro/function and the OCTEON_CN*
 51 * macros should be used outside of this file.  All other macros are
 52 * for internal use only, and may change without notice.
 53 */
 54
 
 
 55/* Flag bits in top byte */
 56/* Ignores revision in model checks */
 57#define OM_IGNORE_REVISION        0x01000000
 58/* Check submodels */
 59#define OM_CHECK_SUBMODEL         0x02000000
 60/* Match all models previous than the one specified */
 61#define OM_MATCH_PREVIOUS_MODELS  0x04000000
 62/* Ignores the minor revison on newer parts */
 63#define OM_IGNORE_MINOR_REVISION  0x08000000
 64#define OM_FLAG_MASK              0xff000000
 65
 66#define OM_MATCH_5XXX_FAMILY_MODELS     0x20000000 /* Match all cn5XXX Octeon models. */
 67#define OM_MATCH_6XXX_FAMILY_MODELS     0x40000000 /* Match all cn6XXX Octeon models. */
 
 
 68
 69/*
 70 * CN6XXX models with new revision encoding
 71 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 72#define OCTEON_CN63XX_PASS1_0   0x000d9000
 73#define OCTEON_CN63XX_PASS1_1   0x000d9001
 74#define OCTEON_CN63XX_PASS1_2   0x000d9002
 75#define OCTEON_CN63XX_PASS2_0   0x000d9008
 
 
 76
 77#define OCTEON_CN63XX           (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_REVISION)
 78#define OCTEON_CN63XX_PASS1_X   (OCTEON_CN63XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
 79#define OCTEON_CN63XX_PASS2_X   (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
 80
 
 
 
 
 
 81/*
 82 * CN5XXX models with new revision encoding
 83 */
 84#define OCTEON_CN58XX_PASS1_0   0x000d0300
 85#define OCTEON_CN58XX_PASS1_1   0x000d0301
 86#define OCTEON_CN58XX_PASS1_2   0x000d0303
 87#define OCTEON_CN58XX_PASS2_0   0x000d0308
 88#define OCTEON_CN58XX_PASS2_1   0x000d0309
 89#define OCTEON_CN58XX_PASS2_2   0x000d030a
 90#define OCTEON_CN58XX_PASS2_3   0x000d030b
 91
 92#define OCTEON_CN58XX           (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_REVISION)
 93#define OCTEON_CN58XX_PASS1_X   (OCTEON_CN58XX_PASS1_0 \
 94				 | OM_IGNORE_MINOR_REVISION)
 95#define OCTEON_CN58XX_PASS2_X   (OCTEON_CN58XX_PASS2_0 \
 96				 | OM_IGNORE_MINOR_REVISION)
 97#define OCTEON_CN58XX_PASS1     OCTEON_CN58XX_PASS1_X
 98#define OCTEON_CN58XX_PASS2     OCTEON_CN58XX_PASS2_X
 99
100#define OCTEON_CN56XX_PASS1_0   0x000d0400
101#define OCTEON_CN56XX_PASS1_1   0x000d0401
102#define OCTEON_CN56XX_PASS2_0   0x000d0408
103#define OCTEON_CN56XX_PASS2_1   0x000d0409
104
105#define OCTEON_CN56XX           (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_REVISION)
106#define OCTEON_CN56XX_PASS1_X   (OCTEON_CN56XX_PASS1_0 \
107				 | OM_IGNORE_MINOR_REVISION)
108#define OCTEON_CN56XX_PASS2_X   (OCTEON_CN56XX_PASS2_0 \
109				 | OM_IGNORE_MINOR_REVISION)
110#define OCTEON_CN56XX_PASS1     OCTEON_CN56XX_PASS1_X
111#define OCTEON_CN56XX_PASS2     OCTEON_CN56XX_PASS2_X
112
113#define OCTEON_CN57XX           OCTEON_CN56XX
114#define OCTEON_CN57XX_PASS1     OCTEON_CN56XX_PASS1
115#define OCTEON_CN57XX_PASS2     OCTEON_CN56XX_PASS2
116
117#define OCTEON_CN55XX           OCTEON_CN56XX
118#define OCTEON_CN55XX_PASS1     OCTEON_CN56XX_PASS1
119#define OCTEON_CN55XX_PASS2     OCTEON_CN56XX_PASS2
120
121#define OCTEON_CN54XX           OCTEON_CN56XX
122#define OCTEON_CN54XX_PASS1     OCTEON_CN56XX_PASS1
123#define OCTEON_CN54XX_PASS2     OCTEON_CN56XX_PASS2
124
125#define OCTEON_CN50XX_PASS1_0   0x000d0600
126
127#define OCTEON_CN50XX           (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_REVISION)
128#define OCTEON_CN50XX_PASS1_X   (OCTEON_CN50XX_PASS1_0 \
129				 | OM_IGNORE_MINOR_REVISION)
130#define OCTEON_CN50XX_PASS1     OCTEON_CN50XX_PASS1_X
131
132/*
133 * NOTE: Octeon CN5000F model is not identifiable using the
134 * OCTEON_IS_MODEL() functions, but are treated as CN50XX.
135 */
136
137#define OCTEON_CN52XX_PASS1_0   0x000d0700
138#define OCTEON_CN52XX_PASS2_0   0x000d0708
139
140#define OCTEON_CN52XX           (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_REVISION)
141#define OCTEON_CN52XX_PASS1_X   (OCTEON_CN52XX_PASS1_0 \
142				 | OM_IGNORE_MINOR_REVISION)
143#define OCTEON_CN52XX_PASS2_X   (OCTEON_CN52XX_PASS2_0 \
144				 | OM_IGNORE_MINOR_REVISION)
145#define OCTEON_CN52XX_PASS1     OCTEON_CN52XX_PASS1_X
146#define OCTEON_CN52XX_PASS2     OCTEON_CN52XX_PASS2_X
147
148/*
149 * CN3XXX models with old revision enconding
150 */
151#define OCTEON_CN38XX_PASS1     0x000d0000
152#define OCTEON_CN38XX_PASS2     0x000d0001
153#define OCTEON_CN38XX_PASS3     0x000d0003
154#define OCTEON_CN38XX           (OCTEON_CN38XX_PASS3 | OM_IGNORE_REVISION)
155
156#define OCTEON_CN36XX           OCTEON_CN38XX
157#define OCTEON_CN36XX_PASS2     OCTEON_CN38XX_PASS2
158#define OCTEON_CN36XX_PASS3     OCTEON_CN38XX_PASS3
159
160/* The OCTEON_CN31XX matches CN31XX models and the CN3020 */
161#define OCTEON_CN31XX_PASS1     0x000d0100
162#define OCTEON_CN31XX_PASS1_1   0x000d0102
163#define OCTEON_CN31XX           (OCTEON_CN31XX_PASS1 | OM_IGNORE_REVISION)
164
165/*
166 * This model is only used for internal checks, it is not a valid
167 * model for the OCTEON_MODEL environment variable.  This matches the
168 * CN3010 and CN3005 but NOT the CN3020.
169 */
170#define OCTEON_CN30XX_PASS1     0x000d0200
171#define OCTEON_CN30XX_PASS1_1   0x000d0202
172#define OCTEON_CN30XX           (OCTEON_CN30XX_PASS1 | OM_IGNORE_REVISION)
173
174#define OCTEON_CN3005_PASS1     (0x000d0210 | OM_CHECK_SUBMODEL)
175#define OCTEON_CN3005_PASS1_0   (0x000d0210 | OM_CHECK_SUBMODEL)
176#define OCTEON_CN3005_PASS1_1   (0x000d0212 | OM_CHECK_SUBMODEL)
177#define OCTEON_CN3005           (OCTEON_CN3005_PASS1 | OM_IGNORE_REVISION \
178				 | OM_CHECK_SUBMODEL)
179
180#define OCTEON_CN3010_PASS1     (0x000d0200 | OM_CHECK_SUBMODEL)
181#define OCTEON_CN3010_PASS1_0   (0x000d0200 | OM_CHECK_SUBMODEL)
182#define OCTEON_CN3010_PASS1_1   (0x000d0202 | OM_CHECK_SUBMODEL)
183#define OCTEON_CN3010           (OCTEON_CN3010_PASS1 | OM_IGNORE_REVISION \
184				 | OM_CHECK_SUBMODEL)
185
186#define OCTEON_CN3020_PASS1     (0x000d0110 | OM_CHECK_SUBMODEL)
187#define OCTEON_CN3020_PASS1_0   (0x000d0110 | OM_CHECK_SUBMODEL)
188#define OCTEON_CN3020_PASS1_1   (0x000d0112 | OM_CHECK_SUBMODEL)
189#define OCTEON_CN3020           (OCTEON_CN3020_PASS1 | OM_IGNORE_REVISION \
190				 | OM_CHECK_SUBMODEL)
191
192
193
194/* This matches the complete family of CN3xxx CPUs, and not subsequent models */
195#define OCTEON_CN3XXX           (OCTEON_CN58XX_PASS1_0 \
196				 | OM_MATCH_PREVIOUS_MODELS \
197				 | OM_IGNORE_REVISION)
198
 
 
 
 
 
199#define OCTEON_CN5XXX           (OCTEON_CN58XX_PASS1_0 | OM_MATCH_5XXX_FAMILY_MODELS)
200#define OCTEON_CN6XXX           (OCTEON_CN63XX_PASS1_0 | OM_MATCH_6XXX_FAMILY_MODELS)
201
202/* The revision byte (low byte) has two different encodings.
203 * CN3XXX:
204 *
205 *     bits
206 *     <7:5>: reserved (0)
207 *     <4>:   alternate package
208 *     <3:0>: revision
209 *
210 * CN5XXX:
211 *
212 *     bits
213 *     <7>:   reserved (0)
214 *     <6>:   alternate package
215 *     <5:3>: major revision
216 *     <2:0>: minor revision
217 *
218 */
219
220/* Masks used for the various types of model/family/revision matching */
221#define OCTEON_38XX_FAMILY_MASK      0x00ffff00
222#define OCTEON_38XX_FAMILY_REV_MASK  0x00ffff0f
223#define OCTEON_38XX_MODEL_MASK       0x00ffff10
224#define OCTEON_38XX_MODEL_REV_MASK   (OCTEON_38XX_FAMILY_REV_MASK \
225				      | OCTEON_38XX_MODEL_MASK)
226
227/* CN5XXX and later use different layout of bits in the revision ID field */
228#define OCTEON_58XX_FAMILY_MASK      OCTEON_38XX_FAMILY_MASK
229#define OCTEON_58XX_FAMILY_REV_MASK  0x00ffff3f
230#define OCTEON_58XX_MODEL_MASK       0x00ffffc0
231#define OCTEON_58XX_MODEL_REV_MASK   (OCTEON_58XX_FAMILY_REV_MASK \
232				      | OCTEON_58XX_MODEL_MASK)
233#define OCTEON_58XX_MODEL_MINOR_REV_MASK (OCTEON_58XX_MODEL_REV_MASK \
234					  & 0x00fffff8)
235#define OCTEON_5XXX_MODEL_MASK       0x00ff0fc0
236
237#define __OCTEON_MATCH_MASK__(x, y, z) (((x) & (z)) == ((y) & (z)))
238
239/* NOTE: This is for internal (to this file) use only. */
240static inline int __OCTEON_IS_MODEL_COMPILE__(uint32_t arg_model,
241					      uint32_t chip_model)
242{
243	uint32_t rev_and_sub = OM_IGNORE_REVISION | OM_CHECK_SUBMODEL;
244
245	if ((arg_model & OCTEON_38XX_FAMILY_MASK) < OCTEON_CN58XX_PASS1_0) {
246		if (((arg_model & OM_FLAG_MASK) == rev_and_sub) &&
247		    __OCTEON_MATCH_MASK__(chip_model, arg_model,
248					  OCTEON_38XX_MODEL_MASK))
249			return 1;
250		if (((arg_model & OM_FLAG_MASK) == 0) &&
251		    __OCTEON_MATCH_MASK__(chip_model, arg_model,
252					  OCTEON_38XX_FAMILY_REV_MASK))
253			return 1;
254		if (((arg_model & OM_FLAG_MASK) == OM_IGNORE_REVISION) &&
255		    __OCTEON_MATCH_MASK__(chip_model, arg_model,
256					  OCTEON_38XX_FAMILY_MASK))
257			return 1;
258		if (((arg_model & OM_FLAG_MASK) == OM_CHECK_SUBMODEL) &&
259		    __OCTEON_MATCH_MASK__((chip_model), (arg_model),
260					  OCTEON_38XX_MODEL_REV_MASK))
261			return 1;
262		if ((arg_model & OM_MATCH_PREVIOUS_MODELS) &&
263		    ((chip_model & OCTEON_38XX_MODEL_MASK) <
264			    (arg_model & OCTEON_38XX_MODEL_MASK)))
265			return 1;
266	} else {
267		if (((arg_model & OM_FLAG_MASK) == rev_and_sub) &&
268		    __OCTEON_MATCH_MASK__((chip_model), (arg_model),
269					  OCTEON_58XX_MODEL_MASK))
270			return 1;
271		if (((arg_model & OM_FLAG_MASK) == 0) &&
272		    __OCTEON_MATCH_MASK__((chip_model), (arg_model),
273					  OCTEON_58XX_FAMILY_REV_MASK))
274			return 1;
275		if (((arg_model & OM_FLAG_MASK) == OM_IGNORE_MINOR_REVISION) &&
276		    __OCTEON_MATCH_MASK__((chip_model), (arg_model),
277					  OCTEON_58XX_MODEL_MINOR_REV_MASK))
278			return 1;
279		if (((arg_model & OM_FLAG_MASK) == OM_IGNORE_REVISION) &&
280		    __OCTEON_MATCH_MASK__((chip_model), (arg_model),
281					  OCTEON_58XX_FAMILY_MASK))
282			return 1;
283		if (((arg_model & OM_FLAG_MASK) == OM_CHECK_SUBMODEL) &&
284		    __OCTEON_MATCH_MASK__((chip_model), (arg_model),
285					  OCTEON_58XX_MODEL_REV_MASK))
286			return 1;
287
288		if (((arg_model & OM_MATCH_5XXX_FAMILY_MODELS) == OM_MATCH_5XXX_FAMILY_MODELS) &&
289		    ((chip_model) >= OCTEON_CN58XX_PASS1_0) && ((chip_model) < OCTEON_CN63XX_PASS1_0))
290			return 1;
291
292		if (((arg_model & OM_MATCH_6XXX_FAMILY_MODELS) == OM_MATCH_6XXX_FAMILY_MODELS) &&
293		    ((chip_model) >= OCTEON_CN63XX_PASS1_0))
294			return 1;
295
296		if ((arg_model & OM_MATCH_PREVIOUS_MODELS) &&
297		    ((chip_model & OCTEON_58XX_MODEL_MASK) <
298			    (arg_model & OCTEON_58XX_MODEL_MASK)))
299			return 1;
300	}
301	return 0;
302}
303
304/* forward declarations */
305static inline uint32_t cvmx_get_proc_id(void) __attribute__ ((pure));
306static inline uint64_t cvmx_read_csr(uint64_t csr_addr);
307
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
308/* NOTE: This for internal use only!!!!! */
309static inline int __octeon_is_model_runtime__(uint32_t model)
310{
311	uint32_t cpuid = cvmx_get_proc_id();
312
313	/*
314	 * Check for special case of mismarked 3005 samples. We only
315	 * need to check if the sub model isn't being ignored.
316	 */
317	if ((model & OM_CHECK_SUBMODEL) == OM_CHECK_SUBMODEL) {
318		if (cpuid == OCTEON_CN3010_PASS1 \
319		    && (cvmx_read_csr(0x80011800800007B8ull) & (1ull << 34)))
320			cpuid |= 0x10;
321	}
322	return __OCTEON_IS_MODEL_COMPILE__(model, cpuid);
323}
324
325/*
326 * The OCTEON_IS_MODEL macro should be used for all Octeon model
327 * checking done in a program.  This should be kept runtime if at all
328 * possible.  Any compile time (#if OCTEON_IS_MODEL) usage must be
329 * condtionalized with OCTEON_IS_COMMON_BINARY() if runtime checking
330 * support is required.
 
 
 
 
331 */
332#define OCTEON_IS_MODEL(x) __octeon_is_model_runtime__(x)
333#define OCTEON_IS_COMMON_BINARY() 1
334#undef OCTEON_MODEL
335
336const char *octeon_model_get_string(uint32_t chip_id);
337const char *octeon_model_get_string_buffer(uint32_t chip_id, char *buffer);
338
339#include "octeon-feature.h"
340
341#endif /* __OCTEON_MODEL_H__ */
v3.5.6
  1/***********************license start***************
  2 * Author: Cavium Networks
  3 *
  4 * Contact: support@caviumnetworks.com
  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/*
 31 * The defines below should be used with the OCTEON_IS_MODEL() macro
 32 * to determine what model of chip the software is running on.  Models
 33 * ending in 'XX' match multiple models (families), while specific
 34 * models match only that model.  If a pass (revision) is specified,
 35 * then only that revision will be matched.  Care should be taken when
 36 * checking for both specific models and families that the specific
 37 * models are checked for first.  While these defines are similar to
 38 * the processor ID, they are not intended to be used by anything
 39 * other that the OCTEON_IS_MODEL framework, and the values are
 40 * subject to change at anytime without notice.
 41 *
 42 * NOTE: only the OCTEON_IS_MODEL() macro/function and the OCTEON_CN*
 43 * macros should be used outside of this file.  All other macros are
 44 * for internal use only, and may change without notice.
 45 */
 46
 47#define OCTEON_FAMILY_MASK      0x00ffff00
 48
 49/* Flag bits in top byte */
 50/* Ignores revision in model checks */
 51#define OM_IGNORE_REVISION        0x01000000
 52/* Check submodels */
 53#define OM_CHECK_SUBMODEL         0x02000000
 54/* Match all models previous than the one specified */
 55#define OM_MATCH_PREVIOUS_MODELS  0x04000000
 56/* Ignores the minor revison on newer parts */
 57#define OM_IGNORE_MINOR_REVISION  0x08000000
 58#define OM_FLAG_MASK              0xff000000
 59
 60/* Match all cn5XXX Octeon models. */
 61#define OM_MATCH_5XXX_FAMILY_MODELS     0x20000000
 62/* Match all cn6XXX Octeon models. */
 63#define OM_MATCH_6XXX_FAMILY_MODELS     0x40000000
 64
 65/*
 66 * CN6XXX models with new revision encoding
 67 */
 68#define OCTEON_CN68XX_PASS1_0   0x000d9100
 69#define OCTEON_CN68XX_PASS1_1   0x000d9101
 70#define OCTEON_CN68XX_PASS1_2   0x000d9102
 71#define OCTEON_CN68XX_PASS2_0   0x000d9108
 72
 73#define OCTEON_CN68XX           (OCTEON_CN68XX_PASS2_0 | OM_IGNORE_REVISION)
 74#define OCTEON_CN68XX_PASS1_X   (OCTEON_CN68XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
 75#define OCTEON_CN68XX_PASS2_X   (OCTEON_CN68XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
 76
 77#define OCTEON_CN68XX_PASS1	OCTEON_CN68XX_PASS1_X
 78#define OCTEON_CN68XX_PASS2	OCTEON_CN68XX_PASS2_X
 79
 80#define OCTEON_CN66XX_PASS1_0   0x000d9200
 81#define OCTEON_CN66XX_PASS1_2   0x000d9202
 82
 83#define OCTEON_CN66XX           (OCTEON_CN66XX_PASS1_0 | OM_IGNORE_REVISION)
 84#define OCTEON_CN66XX_PASS1_X   (OCTEON_CN66XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
 85
 86#define OCTEON_CN63XX_PASS1_0   0x000d9000
 87#define OCTEON_CN63XX_PASS1_1   0x000d9001
 88#define OCTEON_CN63XX_PASS1_2   0x000d9002
 89#define OCTEON_CN63XX_PASS2_0   0x000d9008
 90#define OCTEON_CN63XX_PASS2_1   0x000d9009
 91#define OCTEON_CN63XX_PASS2_2   0x000d900a
 92
 93#define OCTEON_CN63XX           (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_REVISION)
 94#define OCTEON_CN63XX_PASS1_X   (OCTEON_CN63XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
 95#define OCTEON_CN63XX_PASS2_X   (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
 96
 97#define OCTEON_CN61XX_PASS1_0   0x000d9300
 98
 99#define OCTEON_CN61XX           (OCTEON_CN61XX_PASS1_0 | OM_IGNORE_REVISION)
100#define OCTEON_CN61XX_PASS1_X   (OCTEON_CN61XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
101
102/*
103 * CN5XXX models with new revision encoding
104 */
105#define OCTEON_CN58XX_PASS1_0   0x000d0300
106#define OCTEON_CN58XX_PASS1_1   0x000d0301
107#define OCTEON_CN58XX_PASS1_2   0x000d0303
108#define OCTEON_CN58XX_PASS2_0   0x000d0308
109#define OCTEON_CN58XX_PASS2_1   0x000d0309
110#define OCTEON_CN58XX_PASS2_2   0x000d030a
111#define OCTEON_CN58XX_PASS2_3   0x000d030b
112
113#define OCTEON_CN58XX           (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_REVISION)
114#define OCTEON_CN58XX_PASS1_X   (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
115#define OCTEON_CN58XX_PASS2_X   (OCTEON_CN58XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
 
 
116#define OCTEON_CN58XX_PASS1     OCTEON_CN58XX_PASS1_X
117#define OCTEON_CN58XX_PASS2     OCTEON_CN58XX_PASS2_X
118
119#define OCTEON_CN56XX_PASS1_0   0x000d0400
120#define OCTEON_CN56XX_PASS1_1   0x000d0401
121#define OCTEON_CN56XX_PASS2_0   0x000d0408
122#define OCTEON_CN56XX_PASS2_1   0x000d0409
123
124#define OCTEON_CN56XX           (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_REVISION)
125#define OCTEON_CN56XX_PASS1_X   (OCTEON_CN56XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
126#define OCTEON_CN56XX_PASS2_X   (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
 
 
127#define OCTEON_CN56XX_PASS1     OCTEON_CN56XX_PASS1_X
128#define OCTEON_CN56XX_PASS2     OCTEON_CN56XX_PASS2_X
129
130#define OCTEON_CN57XX           OCTEON_CN56XX
131#define OCTEON_CN57XX_PASS1     OCTEON_CN56XX_PASS1
132#define OCTEON_CN57XX_PASS2     OCTEON_CN56XX_PASS2
133
134#define OCTEON_CN55XX           OCTEON_CN56XX
135#define OCTEON_CN55XX_PASS1     OCTEON_CN56XX_PASS1
136#define OCTEON_CN55XX_PASS2     OCTEON_CN56XX_PASS2
137
138#define OCTEON_CN54XX           OCTEON_CN56XX
139#define OCTEON_CN54XX_PASS1     OCTEON_CN56XX_PASS1
140#define OCTEON_CN54XX_PASS2     OCTEON_CN56XX_PASS2
141
142#define OCTEON_CN50XX_PASS1_0   0x000d0600
143
144#define OCTEON_CN50XX           (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_REVISION)
145#define OCTEON_CN50XX_PASS1_X   (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
 
146#define OCTEON_CN50XX_PASS1     OCTEON_CN50XX_PASS1_X
147
148/*
149 * NOTE: Octeon CN5000F model is not identifiable using the
150 * OCTEON_IS_MODEL() functions, but are treated as CN50XX.
151 */
152
153#define OCTEON_CN52XX_PASS1_0   0x000d0700
154#define OCTEON_CN52XX_PASS2_0   0x000d0708
155
156#define OCTEON_CN52XX           (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_REVISION)
157#define OCTEON_CN52XX_PASS1_X   (OCTEON_CN52XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
158#define OCTEON_CN52XX_PASS2_X   (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
 
 
159#define OCTEON_CN52XX_PASS1     OCTEON_CN52XX_PASS1_X
160#define OCTEON_CN52XX_PASS2     OCTEON_CN52XX_PASS2_X
161
162/*
163 * CN3XXX models with old revision enconding
164 */
165#define OCTEON_CN38XX_PASS1     0x000d0000
166#define OCTEON_CN38XX_PASS2     0x000d0001
167#define OCTEON_CN38XX_PASS3     0x000d0003
168#define OCTEON_CN38XX           (OCTEON_CN38XX_PASS3 | OM_IGNORE_REVISION)
169
170#define OCTEON_CN36XX           OCTEON_CN38XX
171#define OCTEON_CN36XX_PASS2     OCTEON_CN38XX_PASS2
172#define OCTEON_CN36XX_PASS3     OCTEON_CN38XX_PASS3
173
174/* The OCTEON_CN31XX matches CN31XX models and the CN3020 */
175#define OCTEON_CN31XX_PASS1     0x000d0100
176#define OCTEON_CN31XX_PASS1_1   0x000d0102
177#define OCTEON_CN31XX           (OCTEON_CN31XX_PASS1 | OM_IGNORE_REVISION)
178
179/*
180 * This model is only used for internal checks, it is not a valid
181 * model for the OCTEON_MODEL environment variable.  This matches the
182 * CN3010 and CN3005 but NOT the CN3020.
183 */
184#define OCTEON_CN30XX_PASS1     0x000d0200
185#define OCTEON_CN30XX_PASS1_1   0x000d0202
186#define OCTEON_CN30XX           (OCTEON_CN30XX_PASS1 | OM_IGNORE_REVISION)
187
188#define OCTEON_CN3005_PASS1     (0x000d0210 | OM_CHECK_SUBMODEL)
189#define OCTEON_CN3005_PASS1_0   (0x000d0210 | OM_CHECK_SUBMODEL)
190#define OCTEON_CN3005_PASS1_1   (0x000d0212 | OM_CHECK_SUBMODEL)
191#define OCTEON_CN3005           (OCTEON_CN3005_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
 
192
193#define OCTEON_CN3010_PASS1     (0x000d0200 | OM_CHECK_SUBMODEL)
194#define OCTEON_CN3010_PASS1_0   (0x000d0200 | OM_CHECK_SUBMODEL)
195#define OCTEON_CN3010_PASS1_1   (0x000d0202 | OM_CHECK_SUBMODEL)
196#define OCTEON_CN3010           (OCTEON_CN3010_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
 
197
198#define OCTEON_CN3020_PASS1     (0x000d0110 | OM_CHECK_SUBMODEL)
199#define OCTEON_CN3020_PASS1_0   (0x000d0110 | OM_CHECK_SUBMODEL)
200#define OCTEON_CN3020_PASS1_1   (0x000d0112 | OM_CHECK_SUBMODEL)
201#define OCTEON_CN3020           (OCTEON_CN3020_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
 
 
 
 
 
 
 
 
202
203/*
204 * This matches the complete family of CN3xxx CPUs, and not subsequent
205 * models
206 */
207#define OCTEON_CN3XXX           (OCTEON_CN58XX_PASS1_0 | OM_MATCH_PREVIOUS_MODELS | OM_IGNORE_REVISION)
208#define OCTEON_CN5XXX           (OCTEON_CN58XX_PASS1_0 | OM_MATCH_5XXX_FAMILY_MODELS)
209#define OCTEON_CN6XXX           (OCTEON_CN63XX_PASS1_0 | OM_MATCH_6XXX_FAMILY_MODELS)
210
211/* The revision byte (low byte) has two different encodings.
212 * CN3XXX:
213 *
214 *     bits
215 *     <7:5>: reserved (0)
216 *     <4>:   alternate package
217 *     <3:0>: revision
218 *
219 * CN5XXX:
220 *
221 *     bits
222 *     <7>:   reserved (0)
223 *     <6>:   alternate package
224 *     <5:3>: major revision
225 *     <2:0>: minor revision
226 *
227 */
228
229/* Masks used for the various types of model/family/revision matching */
230#define OCTEON_38XX_FAMILY_MASK      0x00ffff00
231#define OCTEON_38XX_FAMILY_REV_MASK  0x00ffff0f
232#define OCTEON_38XX_MODEL_MASK       0x00ffff10
233#define OCTEON_38XX_MODEL_REV_MASK   (OCTEON_38XX_FAMILY_REV_MASK | OCTEON_38XX_MODEL_MASK)
 
234
235/* CN5XXX and later use different layout of bits in the revision ID field */
236#define OCTEON_58XX_FAMILY_MASK      OCTEON_38XX_FAMILY_MASK
237#define OCTEON_58XX_FAMILY_REV_MASK  0x00ffff3f
238#define OCTEON_58XX_MODEL_MASK       0x00ffffc0
239#define OCTEON_58XX_MODEL_REV_MASK   (OCTEON_58XX_FAMILY_REV_MASK | OCTEON_58XX_MODEL_MASK)
240#define OCTEON_58XX_MODEL_MINOR_REV_MASK (OCTEON_58XX_MODEL_REV_MASK & 0x00fffff8)
 
 
241#define OCTEON_5XXX_MODEL_MASK       0x00ff0fc0
242
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243/* forward declarations */
244static inline uint32_t cvmx_get_proc_id(void) __attribute__ ((pure));
245static inline uint64_t cvmx_read_csr(uint64_t csr_addr);
246
247#define __OCTEON_MATCH_MASK__(x, y, z) (((x) & (z)) == ((y) & (z)))
248
249/* NOTE: This for internal use only! */
250#define __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model)		\
251((((arg_model & OCTEON_38XX_FAMILY_MASK) < OCTEON_CN58XX_PASS1_0)  && (	\
252		((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
253			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_MASK)) || \
254		((((arg_model) & (OM_FLAG_MASK)) == 0)			\
255			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_REV_MASK)) || \
256		((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
257			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_MASK)) || \
258		((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL)	\
259			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_REV_MASK)) || \
260		((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
261			&& (((chip_model) & OCTEON_38XX_MODEL_MASK) < ((arg_model) & OCTEON_38XX_MODEL_MASK))) \
262		)) ||							\
263	(((arg_model & OCTEON_38XX_FAMILY_MASK) >= OCTEON_CN58XX_PASS1_0)  && (	\
264		((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
265			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
266		((((arg_model) & (OM_FLAG_MASK)) == 0)			\
267			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_REV_MASK)) || \
268		((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_MINOR_REVISION) \
269			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MINOR_REV_MASK)) || \
270		((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
271			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_MASK)) || \
272		((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL)	\
273			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_REV_MASK)) || \
274		((((arg_model) & (OM_MATCH_5XXX_FAMILY_MODELS)) == OM_MATCH_5XXX_FAMILY_MODELS) \
275			&& ((chip_model) >= OCTEON_CN58XX_PASS1_0) && ((chip_model) < OCTEON_CN63XX_PASS1_0)) || \
276		((((arg_model) & (OM_MATCH_6XXX_FAMILY_MODELS)) == OM_MATCH_6XXX_FAMILY_MODELS) \
277			&& ((chip_model) >= OCTEON_CN63XX_PASS1_0)) ||	\
278		((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
279			&& (((chip_model) & OCTEON_58XX_MODEL_MASK) < ((arg_model) & OCTEON_58XX_MODEL_MASK))) \
280		)))
281
282/* NOTE: This for internal use only!!!!! */
283static inline int __octeon_is_model_runtime__(uint32_t model)
284{
285	uint32_t cpuid = cvmx_get_proc_id();
286
287	/*
288	 * Check for special case of mismarked 3005 samples. We only
289	 * need to check if the sub model isn't being ignored
290	 */
291	if ((model & OM_CHECK_SUBMODEL) == OM_CHECK_SUBMODEL) {
292		if (cpuid == OCTEON_CN3010_PASS1 && (cvmx_read_csr(0x80011800800007B8ull) & (1ull << 34)))
 
293			cpuid |= 0x10;
294	}
295	return __OCTEON_IS_MODEL_COMPILE__(model, cpuid);
296}
297
298/*
299 * The OCTEON_IS_MODEL macro should be used for all Octeon model checking done
300 * in a program.
301 * This should be kept runtime if at all possible  and must be conditionalized
302 * with OCTEON_IS_COMMON_BINARY() if runtime checking support is required.
303 *
304 * Use of the macro in preprocessor directives ( #if OCTEON_IS_MODEL(...) )
305 * is NOT SUPPORTED, and should be replaced with CVMX_COMPILED_FOR()
306 * I.e.:
307 *  #if OCTEON_IS_MODEL(OCTEON_CN56XX)  ->  #if CVMX_COMPILED_FOR(OCTEON_CN56XX)
308 */
309#define OCTEON_IS_MODEL(x) __octeon_is_model_runtime__(x)
310#define OCTEON_IS_COMMON_BINARY() 1
311#undef OCTEON_MODEL
312
313const char *octeon_model_get_string(uint32_t chip_id);
314const char *octeon_model_get_string_buffer(uint32_t chip_id, char *buffer);
315
316#include "octeon-feature.h"
317
318#endif /* __OCTEON_MODEL_H__ */