162306a36Sopenharmony_ci/***********************license start***************
262306a36Sopenharmony_ci * Author: Cavium Networks
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Contact: support@caviumnetworks.com
562306a36Sopenharmony_ci * This file is part of the OCTEON SDK
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci * Copyright (c) 2003-2010 Cavium Networks
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * This file is free software; you can redistribute it and/or modify
1062306a36Sopenharmony_ci * it under the terms of the GNU General Public License, Version 2, as
1162306a36Sopenharmony_ci * published by the Free Software Foundation.
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * This file is distributed in the hope that it will be useful, but
1462306a36Sopenharmony_ci * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
1562306a36Sopenharmony_ci * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
1662306a36Sopenharmony_ci * NONINFRINGEMENT.  See the GNU General Public License for more
1762306a36Sopenharmony_ci * details.
1862306a36Sopenharmony_ci *
1962306a36Sopenharmony_ci * You should have received a copy of the GNU General Public License
2062306a36Sopenharmony_ci * along with this file; if not, write to the Free Software
2162306a36Sopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2262306a36Sopenharmony_ci * or visit http://www.gnu.org/licenses/.
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci * This file may also be available under a different license from Cavium.
2562306a36Sopenharmony_ci * Contact Cavium Networks for more information
2662306a36Sopenharmony_ci ***********************license end**************************************/
2762306a36Sopenharmony_ci#ifndef __OCTEON_MODEL_H__
2862306a36Sopenharmony_ci#define __OCTEON_MODEL_H__
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_ci/*
3162306a36Sopenharmony_ci * The defines below should be used with the OCTEON_IS_MODEL() macro
3262306a36Sopenharmony_ci * to determine what model of chip the software is running on.	Models
3362306a36Sopenharmony_ci * ending in 'XX' match multiple models (families), while specific
3462306a36Sopenharmony_ci * models match only that model.  If a pass (revision) is specified,
3562306a36Sopenharmony_ci * then only that revision will be matched.  Care should be taken when
3662306a36Sopenharmony_ci * checking for both specific models and families that the specific
3762306a36Sopenharmony_ci * models are checked for first.  While these defines are similar to
3862306a36Sopenharmony_ci * the processor ID, they are not intended to be used by anything
3962306a36Sopenharmony_ci * other that the OCTEON_IS_MODEL framework, and the values are
4062306a36Sopenharmony_ci * subject to change at anytime without notice.
4162306a36Sopenharmony_ci *
4262306a36Sopenharmony_ci * NOTE: only the OCTEON_IS_MODEL() macro/function and the OCTEON_CN*
4362306a36Sopenharmony_ci * macros should be used outside of this file.	All other macros are
4462306a36Sopenharmony_ci * for internal use only, and may change without notice.
4562306a36Sopenharmony_ci */
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci#define OCTEON_FAMILY_MASK	0x00ffff00
4862306a36Sopenharmony_ci#define OCTEON_PRID_MASK	0x00ffffff
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci/* Flag bits in top byte */
5162306a36Sopenharmony_ci/* Ignores revision in model checks */
5262306a36Sopenharmony_ci#define OM_IGNORE_REVISION	  0x01000000
5362306a36Sopenharmony_ci/* Check submodels */
5462306a36Sopenharmony_ci#define OM_CHECK_SUBMODEL	  0x02000000
5562306a36Sopenharmony_ci/* Match all models previous than the one specified */
5662306a36Sopenharmony_ci#define OM_MATCH_PREVIOUS_MODELS  0x04000000
5762306a36Sopenharmony_ci/* Ignores the minor revison on newer parts */
5862306a36Sopenharmony_ci#define OM_IGNORE_MINOR_REVISION  0x08000000
5962306a36Sopenharmony_ci#define OM_FLAG_MASK		  0xff000000
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci/* Match all cn5XXX Octeon models. */
6262306a36Sopenharmony_ci#define OM_MATCH_5XXX_FAMILY_MODELS	0x20000000
6362306a36Sopenharmony_ci/* Match all cn6XXX Octeon models. */
6462306a36Sopenharmony_ci#define OM_MATCH_6XXX_FAMILY_MODELS	0x40000000
6562306a36Sopenharmony_ci/* Match all cnf7XXX Octeon models. */
6662306a36Sopenharmony_ci#define OM_MATCH_F7XXX_FAMILY_MODELS	0x80000000
6762306a36Sopenharmony_ci/* Match all cn7XXX Octeon models. */
6862306a36Sopenharmony_ci#define OM_MATCH_7XXX_FAMILY_MODELS     0x10000000
6962306a36Sopenharmony_ci#define OM_MATCH_FAMILY_MODELS		(OM_MATCH_5XXX_FAMILY_MODELS |	\
7062306a36Sopenharmony_ci					 OM_MATCH_6XXX_FAMILY_MODELS |	\
7162306a36Sopenharmony_ci					 OM_MATCH_F7XXX_FAMILY_MODELS | \
7262306a36Sopenharmony_ci					 OM_MATCH_7XXX_FAMILY_MODELS)
7362306a36Sopenharmony_ci/*
7462306a36Sopenharmony_ci * CN7XXX models with new revision encoding
7562306a36Sopenharmony_ci */
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci#define OCTEON_CNF75XX_PASS1_0	0x000d9800
7862306a36Sopenharmony_ci#define OCTEON_CNF75XX		(OCTEON_CNF75XX_PASS1_0 | OM_IGNORE_REVISION)
7962306a36Sopenharmony_ci#define OCTEON_CNF75XX_PASS1_X	(OCTEON_CNF75XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci#define OCTEON_CN73XX_PASS1_0	0x000d9700
8262306a36Sopenharmony_ci#define OCTEON_CN73XX_PASS1_1	0x000d9701
8362306a36Sopenharmony_ci#define OCTEON_CN73XX		(OCTEON_CN73XX_PASS1_0 | OM_IGNORE_REVISION)
8462306a36Sopenharmony_ci#define OCTEON_CN73XX_PASS1_X	(OCTEON_CN73XX_PASS1_0 | \
8562306a36Sopenharmony_ci				 OM_IGNORE_MINOR_REVISION)
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define OCTEON_CN70XX_PASS1_0	0x000d9600
8862306a36Sopenharmony_ci#define OCTEON_CN70XX_PASS1_1	0x000d9601
8962306a36Sopenharmony_ci#define OCTEON_CN70XX_PASS1_2	0x000d9602
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci#define OCTEON_CN70XX_PASS2_0	0x000d9608
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci#define OCTEON_CN70XX		(OCTEON_CN70XX_PASS1_0 | OM_IGNORE_REVISION)
9462306a36Sopenharmony_ci#define OCTEON_CN70XX_PASS1_X	(OCTEON_CN70XX_PASS1_0 | \
9562306a36Sopenharmony_ci				 OM_IGNORE_MINOR_REVISION)
9662306a36Sopenharmony_ci#define OCTEON_CN70XX_PASS2_X	(OCTEON_CN70XX_PASS2_0 | \
9762306a36Sopenharmony_ci				 OM_IGNORE_MINOR_REVISION)
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#define OCTEON_CN71XX		OCTEON_CN70XX
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci#define OCTEON_CN78XX_PASS1_0	0x000d9500
10262306a36Sopenharmony_ci#define OCTEON_CN78XX_PASS1_1	0x000d9501
10362306a36Sopenharmony_ci#define OCTEON_CN78XX_PASS2_0	0x000d9508
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci#define OCTEON_CN78XX		(OCTEON_CN78XX_PASS1_0 | OM_IGNORE_REVISION)
10662306a36Sopenharmony_ci#define OCTEON_CN78XX_PASS1_X	(OCTEON_CN78XX_PASS1_0 | \
10762306a36Sopenharmony_ci				 OM_IGNORE_MINOR_REVISION)
10862306a36Sopenharmony_ci#define OCTEON_CN78XX_PASS2_X	(OCTEON_CN78XX_PASS2_0 | \
10962306a36Sopenharmony_ci				 OM_IGNORE_MINOR_REVISION)
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci#define OCTEON_CN76XX		(0x000d9540 | OM_CHECK_SUBMODEL)
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci/*
11462306a36Sopenharmony_ci * CNF7XXX models with new revision encoding
11562306a36Sopenharmony_ci */
11662306a36Sopenharmony_ci#define OCTEON_CNF71XX_PASS1_0	0x000d9400
11762306a36Sopenharmony_ci#define OCTEON_CNF71XX_PASS1_1  0x000d9401
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci#define OCTEON_CNF71XX		(OCTEON_CNF71XX_PASS1_0 | OM_IGNORE_REVISION)
12062306a36Sopenharmony_ci#define OCTEON_CNF71XX_PASS1_X	(OCTEON_CNF71XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
12162306a36Sopenharmony_ci
12262306a36Sopenharmony_ci/*
12362306a36Sopenharmony_ci * CN6XXX models with new revision encoding
12462306a36Sopenharmony_ci */
12562306a36Sopenharmony_ci#define OCTEON_CN68XX_PASS1_0	0x000d9100
12662306a36Sopenharmony_ci#define OCTEON_CN68XX_PASS1_1	0x000d9101
12762306a36Sopenharmony_ci#define OCTEON_CN68XX_PASS1_2	0x000d9102
12862306a36Sopenharmony_ci#define OCTEON_CN68XX_PASS2_0	0x000d9108
12962306a36Sopenharmony_ci#define OCTEON_CN68XX_PASS2_1   0x000d9109
13062306a36Sopenharmony_ci#define OCTEON_CN68XX_PASS2_2   0x000d910a
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci#define OCTEON_CN68XX		(OCTEON_CN68XX_PASS2_0 | OM_IGNORE_REVISION)
13362306a36Sopenharmony_ci#define OCTEON_CN68XX_PASS1_X	(OCTEON_CN68XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
13462306a36Sopenharmony_ci#define OCTEON_CN68XX_PASS2_X	(OCTEON_CN68XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
13562306a36Sopenharmony_ci
13662306a36Sopenharmony_ci#define OCTEON_CN68XX_PASS1	OCTEON_CN68XX_PASS1_X
13762306a36Sopenharmony_ci#define OCTEON_CN68XX_PASS2	OCTEON_CN68XX_PASS2_X
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci#define OCTEON_CN66XX_PASS1_0	0x000d9200
14062306a36Sopenharmony_ci#define OCTEON_CN66XX_PASS1_2	0x000d9202
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#define OCTEON_CN66XX		(OCTEON_CN66XX_PASS1_0 | OM_IGNORE_REVISION)
14362306a36Sopenharmony_ci#define OCTEON_CN66XX_PASS1_X	(OCTEON_CN66XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci#define OCTEON_CN63XX_PASS1_0	0x000d9000
14662306a36Sopenharmony_ci#define OCTEON_CN63XX_PASS1_1	0x000d9001
14762306a36Sopenharmony_ci#define OCTEON_CN63XX_PASS1_2	0x000d9002
14862306a36Sopenharmony_ci#define OCTEON_CN63XX_PASS2_0	0x000d9008
14962306a36Sopenharmony_ci#define OCTEON_CN63XX_PASS2_1	0x000d9009
15062306a36Sopenharmony_ci#define OCTEON_CN63XX_PASS2_2	0x000d900a
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci#define OCTEON_CN63XX		(OCTEON_CN63XX_PASS2_0 | OM_IGNORE_REVISION)
15362306a36Sopenharmony_ci#define OCTEON_CN63XX_PASS1_X	(OCTEON_CN63XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
15462306a36Sopenharmony_ci#define OCTEON_CN63XX_PASS2_X	(OCTEON_CN63XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci/* CN62XX is same as CN63XX with 1 MB cache */
15762306a36Sopenharmony_ci#define OCTEON_CN62XX           OCTEON_CN63XX
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci#define OCTEON_CN61XX_PASS1_0	0x000d9300
16062306a36Sopenharmony_ci#define OCTEON_CN61XX_PASS1_1   0x000d9301
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci#define OCTEON_CN61XX		(OCTEON_CN61XX_PASS1_0 | OM_IGNORE_REVISION)
16362306a36Sopenharmony_ci#define OCTEON_CN61XX_PASS1_X	(OCTEON_CN61XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci/* CN60XX is same as CN61XX with 512 KB cache */
16662306a36Sopenharmony_ci#define OCTEON_CN60XX           OCTEON_CN61XX
16762306a36Sopenharmony_ci
16862306a36Sopenharmony_ci/*
16962306a36Sopenharmony_ci * CN5XXX models with new revision encoding
17062306a36Sopenharmony_ci */
17162306a36Sopenharmony_ci#define OCTEON_CN58XX_PASS1_0	0x000d0300
17262306a36Sopenharmony_ci#define OCTEON_CN58XX_PASS1_1	0x000d0301
17362306a36Sopenharmony_ci#define OCTEON_CN58XX_PASS1_2	0x000d0303
17462306a36Sopenharmony_ci#define OCTEON_CN58XX_PASS2_0	0x000d0308
17562306a36Sopenharmony_ci#define OCTEON_CN58XX_PASS2_1	0x000d0309
17662306a36Sopenharmony_ci#define OCTEON_CN58XX_PASS2_2	0x000d030a
17762306a36Sopenharmony_ci#define OCTEON_CN58XX_PASS2_3	0x000d030b
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci#define OCTEON_CN58XX		(OCTEON_CN58XX_PASS2_0 | OM_IGNORE_REVISION)
18062306a36Sopenharmony_ci#define OCTEON_CN58XX_PASS1_X	(OCTEON_CN58XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
18162306a36Sopenharmony_ci#define OCTEON_CN58XX_PASS2_X	(OCTEON_CN58XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
18262306a36Sopenharmony_ci#define OCTEON_CN58XX_PASS1	OCTEON_CN58XX_PASS1_X
18362306a36Sopenharmony_ci#define OCTEON_CN58XX_PASS2	OCTEON_CN58XX_PASS2_X
18462306a36Sopenharmony_ci
18562306a36Sopenharmony_ci#define OCTEON_CN56XX_PASS1_0	0x000d0400
18662306a36Sopenharmony_ci#define OCTEON_CN56XX_PASS1_1	0x000d0401
18762306a36Sopenharmony_ci#define OCTEON_CN56XX_PASS2_0	0x000d0408
18862306a36Sopenharmony_ci#define OCTEON_CN56XX_PASS2_1	0x000d0409
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ci#define OCTEON_CN56XX		(OCTEON_CN56XX_PASS2_0 | OM_IGNORE_REVISION)
19162306a36Sopenharmony_ci#define OCTEON_CN56XX_PASS1_X	(OCTEON_CN56XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
19262306a36Sopenharmony_ci#define OCTEON_CN56XX_PASS2_X	(OCTEON_CN56XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
19362306a36Sopenharmony_ci#define OCTEON_CN56XX_PASS1	OCTEON_CN56XX_PASS1_X
19462306a36Sopenharmony_ci#define OCTEON_CN56XX_PASS2	OCTEON_CN56XX_PASS2_X
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci#define OCTEON_CN57XX		OCTEON_CN56XX
19762306a36Sopenharmony_ci#define OCTEON_CN57XX_PASS1	OCTEON_CN56XX_PASS1
19862306a36Sopenharmony_ci#define OCTEON_CN57XX_PASS2	OCTEON_CN56XX_PASS2
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci#define OCTEON_CN55XX		OCTEON_CN56XX
20162306a36Sopenharmony_ci#define OCTEON_CN55XX_PASS1	OCTEON_CN56XX_PASS1
20262306a36Sopenharmony_ci#define OCTEON_CN55XX_PASS2	OCTEON_CN56XX_PASS2
20362306a36Sopenharmony_ci
20462306a36Sopenharmony_ci#define OCTEON_CN54XX		OCTEON_CN56XX
20562306a36Sopenharmony_ci#define OCTEON_CN54XX_PASS1	OCTEON_CN56XX_PASS1
20662306a36Sopenharmony_ci#define OCTEON_CN54XX_PASS2	OCTEON_CN56XX_PASS2
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci#define OCTEON_CN50XX_PASS1_0	0x000d0600
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci#define OCTEON_CN50XX		(OCTEON_CN50XX_PASS1_0 | OM_IGNORE_REVISION)
21162306a36Sopenharmony_ci#define OCTEON_CN50XX_PASS1_X	(OCTEON_CN50XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
21262306a36Sopenharmony_ci#define OCTEON_CN50XX_PASS1	OCTEON_CN50XX_PASS1_X
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_ci/*
21562306a36Sopenharmony_ci * NOTE: Octeon CN5000F model is not identifiable using the
21662306a36Sopenharmony_ci * OCTEON_IS_MODEL() functions, but are treated as CN50XX.
21762306a36Sopenharmony_ci */
21862306a36Sopenharmony_ci
21962306a36Sopenharmony_ci#define OCTEON_CN52XX_PASS1_0	0x000d0700
22062306a36Sopenharmony_ci#define OCTEON_CN52XX_PASS2_0	0x000d0708
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci#define OCTEON_CN52XX		(OCTEON_CN52XX_PASS2_0 | OM_IGNORE_REVISION)
22362306a36Sopenharmony_ci#define OCTEON_CN52XX_PASS1_X	(OCTEON_CN52XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
22462306a36Sopenharmony_ci#define OCTEON_CN52XX_PASS2_X	(OCTEON_CN52XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
22562306a36Sopenharmony_ci#define OCTEON_CN52XX_PASS1	OCTEON_CN52XX_PASS1_X
22662306a36Sopenharmony_ci#define OCTEON_CN52XX_PASS2	OCTEON_CN52XX_PASS2_X
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_ci/*
22962306a36Sopenharmony_ci * CN3XXX models with old revision enconding
23062306a36Sopenharmony_ci */
23162306a36Sopenharmony_ci#define OCTEON_CN38XX_PASS1	0x000d0000
23262306a36Sopenharmony_ci#define OCTEON_CN38XX_PASS2	0x000d0001
23362306a36Sopenharmony_ci#define OCTEON_CN38XX_PASS3	0x000d0003
23462306a36Sopenharmony_ci#define OCTEON_CN38XX		(OCTEON_CN38XX_PASS3 | OM_IGNORE_REVISION)
23562306a36Sopenharmony_ci
23662306a36Sopenharmony_ci#define OCTEON_CN36XX		OCTEON_CN38XX
23762306a36Sopenharmony_ci#define OCTEON_CN36XX_PASS2	OCTEON_CN38XX_PASS2
23862306a36Sopenharmony_ci#define OCTEON_CN36XX_PASS3	OCTEON_CN38XX_PASS3
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci/* The OCTEON_CN31XX matches CN31XX models and the CN3020 */
24162306a36Sopenharmony_ci#define OCTEON_CN31XX_PASS1	0x000d0100
24262306a36Sopenharmony_ci#define OCTEON_CN31XX_PASS1_1	0x000d0102
24362306a36Sopenharmony_ci#define OCTEON_CN31XX		(OCTEON_CN31XX_PASS1 | OM_IGNORE_REVISION)
24462306a36Sopenharmony_ci
24562306a36Sopenharmony_ci/*
24662306a36Sopenharmony_ci * This model is only used for internal checks, it is not a valid
24762306a36Sopenharmony_ci * model for the OCTEON_MODEL environment variable.  This matches the
24862306a36Sopenharmony_ci * CN3010 and CN3005 but NOT the CN3020.
24962306a36Sopenharmony_ci */
25062306a36Sopenharmony_ci#define OCTEON_CN30XX_PASS1	0x000d0200
25162306a36Sopenharmony_ci#define OCTEON_CN30XX_PASS1_1	0x000d0202
25262306a36Sopenharmony_ci#define OCTEON_CN30XX		(OCTEON_CN30XX_PASS1 | OM_IGNORE_REVISION)
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci#define OCTEON_CN3005_PASS1	(0x000d0210 | OM_CHECK_SUBMODEL)
25562306a36Sopenharmony_ci#define OCTEON_CN3005_PASS1_0	(0x000d0210 | OM_CHECK_SUBMODEL)
25662306a36Sopenharmony_ci#define OCTEON_CN3005_PASS1_1	(0x000d0212 | OM_CHECK_SUBMODEL)
25762306a36Sopenharmony_ci#define OCTEON_CN3005		(OCTEON_CN3005_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_ci#define OCTEON_CN3010_PASS1	(0x000d0200 | OM_CHECK_SUBMODEL)
26062306a36Sopenharmony_ci#define OCTEON_CN3010_PASS1_0	(0x000d0200 | OM_CHECK_SUBMODEL)
26162306a36Sopenharmony_ci#define OCTEON_CN3010_PASS1_1	(0x000d0202 | OM_CHECK_SUBMODEL)
26262306a36Sopenharmony_ci#define OCTEON_CN3010		(OCTEON_CN3010_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_ci#define OCTEON_CN3020_PASS1	(0x000d0110 | OM_CHECK_SUBMODEL)
26562306a36Sopenharmony_ci#define OCTEON_CN3020_PASS1_0	(0x000d0110 | OM_CHECK_SUBMODEL)
26662306a36Sopenharmony_ci#define OCTEON_CN3020_PASS1_1	(0x000d0112 | OM_CHECK_SUBMODEL)
26762306a36Sopenharmony_ci#define OCTEON_CN3020		(OCTEON_CN3020_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
26862306a36Sopenharmony_ci
26962306a36Sopenharmony_ci/*
27062306a36Sopenharmony_ci * This matches the complete family of CN3xxx CPUs, and not subsequent
27162306a36Sopenharmony_ci * models
27262306a36Sopenharmony_ci */
27362306a36Sopenharmony_ci#define OCTEON_CN3XXX		(OCTEON_CN58XX_PASS1_0 | OM_MATCH_PREVIOUS_MODELS | OM_IGNORE_REVISION)
27462306a36Sopenharmony_ci#define OCTEON_CN5XXX		(OCTEON_CN58XX_PASS1_0 | OM_MATCH_5XXX_FAMILY_MODELS)
27562306a36Sopenharmony_ci#define OCTEON_CN6XXX		(OCTEON_CN63XX_PASS1_0 | OM_MATCH_6XXX_FAMILY_MODELS)
27662306a36Sopenharmony_ci#define OCTEON_CNF7XXX		(OCTEON_CNF71XX_PASS1_0 | \
27762306a36Sopenharmony_ci				 OM_MATCH_F7XXX_FAMILY_MODELS)
27862306a36Sopenharmony_ci#define OCTEON_CN7XXX		(OCTEON_CN78XX_PASS1_0 | \
27962306a36Sopenharmony_ci				 OM_MATCH_7XXX_FAMILY_MODELS)
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_ci/* The revision byte (low byte) has two different encodings.
28262306a36Sopenharmony_ci * CN3XXX:
28362306a36Sopenharmony_ci *
28462306a36Sopenharmony_ci *     bits
28562306a36Sopenharmony_ci *     <7:5>: reserved (0)
28662306a36Sopenharmony_ci *     <4>:   alternate package
28762306a36Sopenharmony_ci *     <3:0>: revision
28862306a36Sopenharmony_ci *
28962306a36Sopenharmony_ci * CN5XXX and older models:
29062306a36Sopenharmony_ci *
29162306a36Sopenharmony_ci *     bits
29262306a36Sopenharmony_ci *     <7>:   reserved (0)
29362306a36Sopenharmony_ci *     <6>:   alternate package
29462306a36Sopenharmony_ci *     <5:3>: major revision
29562306a36Sopenharmony_ci *     <2:0>: minor revision
29662306a36Sopenharmony_ci *
29762306a36Sopenharmony_ci */
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_ci/* Masks used for the various types of model/family/revision matching */
30062306a36Sopenharmony_ci#define OCTEON_38XX_FAMILY_MASK	     0x00ffff00
30162306a36Sopenharmony_ci#define OCTEON_38XX_FAMILY_REV_MASK  0x00ffff0f
30262306a36Sopenharmony_ci#define OCTEON_38XX_MODEL_MASK	     0x00ffff10
30362306a36Sopenharmony_ci#define OCTEON_38XX_MODEL_REV_MASK   (OCTEON_38XX_FAMILY_REV_MASK | OCTEON_38XX_MODEL_MASK)
30462306a36Sopenharmony_ci
30562306a36Sopenharmony_ci/* CN5XXX and later use different layout of bits in the revision ID field */
30662306a36Sopenharmony_ci#define OCTEON_58XX_FAMILY_MASK	     OCTEON_38XX_FAMILY_MASK
30762306a36Sopenharmony_ci#define OCTEON_58XX_FAMILY_REV_MASK  0x00ffff3f
30862306a36Sopenharmony_ci#define OCTEON_58XX_MODEL_MASK	     0x00ffff40
30962306a36Sopenharmony_ci#define OCTEON_58XX_MODEL_REV_MASK   (OCTEON_58XX_FAMILY_REV_MASK | OCTEON_58XX_MODEL_MASK)
31062306a36Sopenharmony_ci#define OCTEON_58XX_MODEL_MINOR_REV_MASK (OCTEON_58XX_MODEL_REV_MASK & 0x00ffff38)
31162306a36Sopenharmony_ci#define OCTEON_5XXX_MODEL_MASK	     0x00ff0fc0
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_cistatic inline uint32_t cvmx_get_proc_id(void) __attribute__ ((pure));
31462306a36Sopenharmony_cistatic inline uint64_t cvmx_read_csr(uint64_t csr_addr);
31562306a36Sopenharmony_ci
31662306a36Sopenharmony_ci#define __OCTEON_MATCH_MASK__(x, y, z) (((x) & (z)) == ((y) & (z)))
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_ci/*
31962306a36Sopenharmony_ci * __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model)
32062306a36Sopenharmony_ci * returns true if chip_model is identical or belong to the OCTEON
32162306a36Sopenharmony_ci * model group specified in arg_model.
32262306a36Sopenharmony_ci */
32362306a36Sopenharmony_ci/* NOTE: This for internal use only! */
32462306a36Sopenharmony_ci#define __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model)		\
32562306a36Sopenharmony_ci((((arg_model & OCTEON_38XX_FAMILY_MASK) < OCTEON_CN58XX_PASS1_0)  && ( \
32662306a36Sopenharmony_ci		((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
32762306a36Sopenharmony_ci			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_MASK)) || \
32862306a36Sopenharmony_ci		((((arg_model) & (OM_FLAG_MASK)) == 0)			\
32962306a36Sopenharmony_ci			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_REV_MASK)) || \
33062306a36Sopenharmony_ci		((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
33162306a36Sopenharmony_ci			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_MASK)) || \
33262306a36Sopenharmony_ci		((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL)	\
33362306a36Sopenharmony_ci			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_REV_MASK)) || \
33462306a36Sopenharmony_ci		((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
33562306a36Sopenharmony_ci			&& (((chip_model) & OCTEON_38XX_MODEL_MASK) < ((arg_model) & OCTEON_38XX_MODEL_MASK))) \
33662306a36Sopenharmony_ci		)) ||							\
33762306a36Sopenharmony_ci	(((arg_model & OCTEON_38XX_FAMILY_MASK) >= OCTEON_CN58XX_PASS1_0)  && ( \
33862306a36Sopenharmony_ci		((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
33962306a36Sopenharmony_ci			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
34062306a36Sopenharmony_ci		((((arg_model) & (OM_FLAG_MASK)) == 0)			\
34162306a36Sopenharmony_ci			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_REV_MASK)) || \
34262306a36Sopenharmony_ci		((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_MINOR_REVISION) \
34362306a36Sopenharmony_ci			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MINOR_REV_MASK)) || \
34462306a36Sopenharmony_ci		((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
34562306a36Sopenharmony_ci			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_MASK)) || \
34662306a36Sopenharmony_ci		((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL)	\
34762306a36Sopenharmony_ci			&& __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
34862306a36Sopenharmony_ci		((((arg_model) & (OM_MATCH_5XXX_FAMILY_MODELS)) == OM_MATCH_5XXX_FAMILY_MODELS) \
34962306a36Sopenharmony_ci			&& ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN58XX_PASS1_0) \
35062306a36Sopenharmony_ci			&& ((chip_model & OCTEON_PRID_MASK) < OCTEON_CN63XX_PASS1_0)) || \
35162306a36Sopenharmony_ci		((((arg_model) & (OM_MATCH_6XXX_FAMILY_MODELS)) == OM_MATCH_6XXX_FAMILY_MODELS) \
35262306a36Sopenharmony_ci			&& ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN63XX_PASS1_0) \
35362306a36Sopenharmony_ci			&& ((chip_model & OCTEON_PRID_MASK) < OCTEON_CNF71XX_PASS1_0)) || \
35462306a36Sopenharmony_ci		((((arg_model) & (OM_MATCH_F7XXX_FAMILY_MODELS)) == OM_MATCH_F7XXX_FAMILY_MODELS) \
35562306a36Sopenharmony_ci			&& ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CNF71XX_PASS1_0) \
35662306a36Sopenharmony_ci			&& ((chip_model & OCTEON_PRID_MASK) < OCTEON_CN78XX_PASS1_0)) || \
35762306a36Sopenharmony_ci		((((arg_model) & (OM_MATCH_7XXX_FAMILY_MODELS)) == OM_MATCH_7XXX_FAMILY_MODELS) \
35862306a36Sopenharmony_ci			&& ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN78XX_PASS1_0)) || \
35962306a36Sopenharmony_ci		((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
36062306a36Sopenharmony_ci			&& (((chip_model) & OCTEON_58XX_MODEL_MASK) < ((arg_model) & OCTEON_58XX_MODEL_MASK))) \
36162306a36Sopenharmony_ci		)))
36262306a36Sopenharmony_ci
36362306a36Sopenharmony_ci/* NOTE: This for internal use only!!!!! */
36462306a36Sopenharmony_cistatic inline int __octeon_is_model_runtime__(uint32_t model)
36562306a36Sopenharmony_ci{
36662306a36Sopenharmony_ci	uint32_t cpuid = cvmx_get_proc_id();
36762306a36Sopenharmony_ci
36862306a36Sopenharmony_ci	return __OCTEON_IS_MODEL_COMPILE__(model, cpuid);
36962306a36Sopenharmony_ci}
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ci/*
37262306a36Sopenharmony_ci * The OCTEON_IS_MODEL macro should be used for all Octeon model checking done
37362306a36Sopenharmony_ci * in a program.
37462306a36Sopenharmony_ci * This should be kept runtime if at all possible  and must be conditionalized
37562306a36Sopenharmony_ci * with OCTEON_IS_COMMON_BINARY() if runtime checking support is required.
37662306a36Sopenharmony_ci *
37762306a36Sopenharmony_ci * Use of the macro in preprocessor directives ( #if OCTEON_IS_MODEL(...) )
37862306a36Sopenharmony_ci * is NOT SUPPORTED, and should be replaced with CVMX_COMPILED_FOR()
37962306a36Sopenharmony_ci * I.e.:
38062306a36Sopenharmony_ci *  #if OCTEON_IS_MODEL(OCTEON_CN56XX)	->  #if CVMX_COMPILED_FOR(OCTEON_CN56XX)
38162306a36Sopenharmony_ci */
38262306a36Sopenharmony_ci#define OCTEON_IS_MODEL(x) __octeon_is_model_runtime__(x)
38362306a36Sopenharmony_ci#define OCTEON_IS_COMMON_BINARY() 1
38462306a36Sopenharmony_ci#undef OCTEON_MODEL
38562306a36Sopenharmony_ci
38662306a36Sopenharmony_ci#define OCTEON_IS_OCTEON1()	OCTEON_IS_MODEL(OCTEON_CN3XXX)
38762306a36Sopenharmony_ci#define OCTEON_IS_OCTEONPLUS()	OCTEON_IS_MODEL(OCTEON_CN5XXX)
38862306a36Sopenharmony_ci#define OCTEON_IS_OCTEON2()						\
38962306a36Sopenharmony_ci	(OCTEON_IS_MODEL(OCTEON_CN6XXX) || OCTEON_IS_MODEL(OCTEON_CNF71XX))
39062306a36Sopenharmony_ci
39162306a36Sopenharmony_ci#define OCTEON_IS_OCTEON3()	OCTEON_IS_MODEL(OCTEON_CN7XXX)
39262306a36Sopenharmony_ci
39362306a36Sopenharmony_ci#define OCTEON_IS_OCTEON1PLUS()	(OCTEON_IS_OCTEON1() || OCTEON_IS_OCTEONPLUS())
39462306a36Sopenharmony_ci
39562306a36Sopenharmony_ciconst char *__init octeon_model_get_string(uint32_t chip_id);
39662306a36Sopenharmony_ci
39762306a36Sopenharmony_ci/*
39862306a36Sopenharmony_ci * Return the octeon family, i.e., ProcessorID of the PrID register.
39962306a36Sopenharmony_ci *
40062306a36Sopenharmony_ci * @return the octeon family on success, ((unint32_t)-1) on error.
40162306a36Sopenharmony_ci */
40262306a36Sopenharmony_cistatic inline uint32_t cvmx_get_octeon_family(void)
40362306a36Sopenharmony_ci{
40462306a36Sopenharmony_ci	return cvmx_get_proc_id() & OCTEON_FAMILY_MASK;
40562306a36Sopenharmony_ci}
40662306a36Sopenharmony_ci
40762306a36Sopenharmony_ci#include <asm/octeon/octeon-feature.h>
40862306a36Sopenharmony_ci
40962306a36Sopenharmony_ci#endif /* __OCTEON_MODEL_H__ */
410