158f07778SDavid Daney /***********************license start***************
258f07778SDavid Daney * Author: Cavium Networks
358f07778SDavid Daney *
458f07778SDavid Daney * Contact: support@caviumnetworks.com
558f07778SDavid Daney * This file is part of the OCTEON SDK
658f07778SDavid Daney *
7751c9f68SDavid Daney * Copyright (c) 2003-2010 Cavium Networks
858f07778SDavid Daney *
958f07778SDavid Daney * This file is free software; you can redistribute it and/or modify
1058f07778SDavid Daney * it under the terms of the GNU General Public License, Version 2, as
1158f07778SDavid Daney * published by the Free Software Foundation.
1258f07778SDavid Daney *
1358f07778SDavid Daney * This file is distributed in the hope that it will be useful, but
1458f07778SDavid Daney * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
1558f07778SDavid Daney * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
1658f07778SDavid Daney * NONINFRINGEMENT. See the GNU General Public License for more
1758f07778SDavid Daney * details.
1858f07778SDavid Daney *
1958f07778SDavid Daney * You should have received a copy of the GNU General Public License
2058f07778SDavid Daney * along with this file; if not, write to the Free Software
2158f07778SDavid Daney * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2258f07778SDavid Daney * or visit http://www.gnu.org/licenses/.
2358f07778SDavid Daney *
2458f07778SDavid Daney * This file may also be available under a different license from Cavium.
2558f07778SDavid Daney * Contact Cavium Networks for more information
2658f07778SDavid Daney ***********************license end**************************************/
2758f07778SDavid Daney #ifndef __OCTEON_MODEL_H__
2858f07778SDavid Daney #define __OCTEON_MODEL_H__
2958f07778SDavid Daney
3058f07778SDavid Daney /*
3158f07778SDavid Daney * The defines below should be used with the OCTEON_IS_MODEL() macro
3258f07778SDavid Daney * to determine what model of chip the software is running on. Models
3358f07778SDavid Daney * ending in 'XX' match multiple models (families), while specific
3458f07778SDavid Daney * models match only that model. If a pass (revision) is specified,
3558f07778SDavid Daney * then only that revision will be matched. Care should be taken when
3658f07778SDavid Daney * checking for both specific models and families that the specific
3758f07778SDavid Daney * models are checked for first. While these defines are similar to
3858f07778SDavid Daney * the processor ID, they are not intended to be used by anything
3958f07778SDavid Daney * other that the OCTEON_IS_MODEL framework, and the values are
4058f07778SDavid Daney * subject to change at anytime without notice.
4158f07778SDavid Daney *
4258f07778SDavid Daney * NOTE: only the OCTEON_IS_MODEL() macro/function and the OCTEON_CN*
4358f07778SDavid Daney * macros should be used outside of this file. All other macros are
4458f07778SDavid Daney * for internal use only, and may change without notice.
4558f07778SDavid Daney */
4658f07778SDavid Daney
47751c9f68SDavid Daney #define OCTEON_FAMILY_MASK 0x00ffff00
48debe6a62SDavid Daney #define OCTEON_PRID_MASK 0x00ffffff
49751c9f68SDavid Daney
5058f07778SDavid Daney /* Flag bits in top byte */
5158f07778SDavid Daney /* Ignores revision in model checks */
5258f07778SDavid Daney #define OM_IGNORE_REVISION 0x01000000
5358f07778SDavid Daney /* Check submodels */
5458f07778SDavid Daney #define OM_CHECK_SUBMODEL 0x02000000
5558f07778SDavid Daney /* Match all models previous than the one specified */
5658f07778SDavid Daney #define OM_MATCH_PREVIOUS_MODELS 0x04000000
5758f07778SDavid Daney /* Ignores the minor revison on newer parts */
5858f07778SDavid Daney #define OM_IGNORE_MINOR_REVISION 0x08000000
5958f07778SDavid Daney #define OM_FLAG_MASK 0xff000000
6058f07778SDavid Daney
61751c9f68SDavid Daney /* Match all cn5XXX Octeon models. */
62751c9f68SDavid Daney #define OM_MATCH_5XXX_FAMILY_MODELS 0x20000000
63751c9f68SDavid Daney /* Match all cn6XXX Octeon models. */
64751c9f68SDavid Daney #define OM_MATCH_6XXX_FAMILY_MODELS 0x40000000
655cf02e55SDavid Daney /* Match all cnf7XXX Octeon models. */
665cf02e55SDavid Daney #define OM_MATCH_F7XXX_FAMILY_MODELS 0x80000000
67debe6a62SDavid Daney /* Match all cn7XXX Octeon models. */
68debe6a62SDavid Daney #define OM_MATCH_7XXX_FAMILY_MODELS 0x10000000
69debe6a62SDavid Daney #define OM_MATCH_FAMILY_MODELS (OM_MATCH_5XXX_FAMILY_MODELS | \
70debe6a62SDavid Daney OM_MATCH_6XXX_FAMILY_MODELS | \
71debe6a62SDavid Daney OM_MATCH_F7XXX_FAMILY_MODELS | \
72debe6a62SDavid Daney OM_MATCH_7XXX_FAMILY_MODELS)
73debe6a62SDavid Daney /*
74debe6a62SDavid Daney * CN7XXX models with new revision encoding
75debe6a62SDavid Daney */
76debe6a62SDavid Daney
77*182a6d1cSDavid Daney #define OCTEON_CNF75XX_PASS1_0 0x000d9800
78*182a6d1cSDavid Daney #define OCTEON_CNF75XX (OCTEON_CNF75XX_PASS1_0 | OM_IGNORE_REVISION)
79*182a6d1cSDavid Daney #define OCTEON_CNF75XX_PASS1_X (OCTEON_CNF75XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
80*182a6d1cSDavid Daney
81debe6a62SDavid Daney #define OCTEON_CN73XX_PASS1_0 0x000d9700
82*182a6d1cSDavid Daney #define OCTEON_CN73XX_PASS1_1 0x000d9701
83debe6a62SDavid Daney #define OCTEON_CN73XX (OCTEON_CN73XX_PASS1_0 | OM_IGNORE_REVISION)
84debe6a62SDavid Daney #define OCTEON_CN73XX_PASS1_X (OCTEON_CN73XX_PASS1_0 | \
85debe6a62SDavid Daney OM_IGNORE_MINOR_REVISION)
86debe6a62SDavid Daney
87debe6a62SDavid Daney #define OCTEON_CN70XX_PASS1_0 0x000d9600
88debe6a62SDavid Daney #define OCTEON_CN70XX_PASS1_1 0x000d9601
89debe6a62SDavid Daney #define OCTEON_CN70XX_PASS1_2 0x000d9602
90debe6a62SDavid Daney
91debe6a62SDavid Daney #define OCTEON_CN70XX_PASS2_0 0x000d9608
92debe6a62SDavid Daney
93debe6a62SDavid Daney #define OCTEON_CN70XX (OCTEON_CN70XX_PASS1_0 | OM_IGNORE_REVISION)
94debe6a62SDavid Daney #define OCTEON_CN70XX_PASS1_X (OCTEON_CN70XX_PASS1_0 | \
95debe6a62SDavid Daney OM_IGNORE_MINOR_REVISION)
96debe6a62SDavid Daney #define OCTEON_CN70XX_PASS2_X (OCTEON_CN70XX_PASS2_0 | \
97debe6a62SDavid Daney OM_IGNORE_MINOR_REVISION)
98debe6a62SDavid Daney
99debe6a62SDavid Daney #define OCTEON_CN71XX OCTEON_CN70XX
100debe6a62SDavid Daney
101debe6a62SDavid Daney #define OCTEON_CN78XX_PASS1_0 0x000d9500
102debe6a62SDavid Daney #define OCTEON_CN78XX_PASS1_1 0x000d9501
103debe6a62SDavid Daney #define OCTEON_CN78XX_PASS2_0 0x000d9508
104debe6a62SDavid Daney
105debe6a62SDavid Daney #define OCTEON_CN78XX (OCTEON_CN78XX_PASS1_0 | OM_IGNORE_REVISION)
106debe6a62SDavid Daney #define OCTEON_CN78XX_PASS1_X (OCTEON_CN78XX_PASS1_0 | \
107debe6a62SDavid Daney OM_IGNORE_MINOR_REVISION)
108debe6a62SDavid Daney #define OCTEON_CN78XX_PASS2_X (OCTEON_CN78XX_PASS2_0 | \
109debe6a62SDavid Daney OM_IGNORE_MINOR_REVISION)
110debe6a62SDavid Daney
111debe6a62SDavid Daney #define OCTEON_CN76XX (0x000d9540 | OM_CHECK_SUBMODEL)
1125cf02e55SDavid Daney
1135cf02e55SDavid Daney /*
1145cf02e55SDavid Daney * CNF7XXX models with new revision encoding
1155cf02e55SDavid Daney */
1165cf02e55SDavid Daney #define OCTEON_CNF71XX_PASS1_0 0x000d9400
117debe6a62SDavid Daney #define OCTEON_CNF71XX_PASS1_1 0x000d9401
1185cf02e55SDavid Daney
1195cf02e55SDavid Daney #define OCTEON_CNF71XX (OCTEON_CNF71XX_PASS1_0 | OM_IGNORE_REVISION)
1205cf02e55SDavid Daney #define OCTEON_CNF71XX_PASS1_X (OCTEON_CNF71XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
121a70b13a9SDavid Daney
122a70b13a9SDavid Daney /*
123a70b13a9SDavid Daney * CN6XXX models with new revision encoding
124a70b13a9SDavid Daney */
125751c9f68SDavid Daney #define OCTEON_CN68XX_PASS1_0 0x000d9100
126751c9f68SDavid Daney #define OCTEON_CN68XX_PASS1_1 0x000d9101
127751c9f68SDavid Daney #define OCTEON_CN68XX_PASS1_2 0x000d9102
128751c9f68SDavid Daney #define OCTEON_CN68XX_PASS2_0 0x000d9108
129debe6a62SDavid Daney #define OCTEON_CN68XX_PASS2_1 0x000d9109
130debe6a62SDavid Daney #define OCTEON_CN68XX_PASS2_2 0x000d910a
131751c9f68SDavid Daney
132751c9f68SDavid Daney #define OCTEON_CN68XX (OCTEON_CN68XX_PASS2_0 | OM_IGNORE_REVISION)
133751c9f68SDavid Daney #define OCTEON_CN68XX_PASS1_X (OCTEON_CN68XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
134751c9f68SDavid Daney #define OCTEON_CN68XX_PASS2_X (OCTEON_CN68XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
135751c9f68SDavid Daney
136751c9f68SDavid Daney #define OCTEON_CN68XX_PASS1 OCTEON_CN68XX_PASS1_X
137751c9f68SDavid Daney #define OCTEON_CN68XX_PASS2 OCTEON_CN68XX_PASS2_X
138751c9f68SDavid Daney
139751c9f68SDavid Daney #define OCTEON_CN66XX_PASS1_0 0x000d9200
140751c9f68SDavid Daney #define OCTEON_CN66XX_PASS1_2 0x000d9202
141751c9f68SDavid Daney
142751c9f68SDavid Daney #define OCTEON_CN66XX (OCTEON_CN66XX_PASS1_0 | OM_IGNORE_REVISION)
143751c9f68SDavid Daney #define OCTEON_CN66XX_PASS1_X (OCTEON_CN66XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
144751c9f68SDavid Daney
145a70b13a9SDavid Daney #define OCTEON_CN63XX_PASS1_0 0x000d9000
146a70b13a9SDavid Daney #define OCTEON_CN63XX_PASS1_1 0x000d9001
147a70b13a9SDavid Daney #define OCTEON_CN63XX_PASS1_2 0x000d9002
148a70b13a9SDavid Daney #define OCTEON_CN63XX_PASS2_0 0x000d9008
149751c9f68SDavid Daney #define OCTEON_CN63XX_PASS2_1 0x000d9009
150751c9f68SDavid Daney #define OCTEON_CN63XX_PASS2_2 0x000d900a
151a70b13a9SDavid Daney
152a70b13a9SDavid Daney #define OCTEON_CN63XX (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_REVISION)
153a70b13a9SDavid Daney #define OCTEON_CN63XX_PASS1_X (OCTEON_CN63XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
154a70b13a9SDavid Daney #define OCTEON_CN63XX_PASS2_X (OCTEON_CN63XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
155a70b13a9SDavid Daney
156debe6a62SDavid Daney /* CN62XX is same as CN63XX with 1 MB cache */
157debe6a62SDavid Daney #define OCTEON_CN62XX OCTEON_CN63XX
158debe6a62SDavid Daney
159751c9f68SDavid Daney #define OCTEON_CN61XX_PASS1_0 0x000d9300
160debe6a62SDavid Daney #define OCTEON_CN61XX_PASS1_1 0x000d9301
161751c9f68SDavid Daney
162751c9f68SDavid Daney #define OCTEON_CN61XX (OCTEON_CN61XX_PASS1_0 | OM_IGNORE_REVISION)
163751c9f68SDavid Daney #define OCTEON_CN61XX_PASS1_X (OCTEON_CN61XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
164751c9f68SDavid Daney
165debe6a62SDavid Daney /* CN60XX is same as CN61XX with 512 KB cache */
166debe6a62SDavid Daney #define OCTEON_CN60XX OCTEON_CN61XX
167debe6a62SDavid Daney
16858f07778SDavid Daney /*
16958f07778SDavid Daney * CN5XXX models with new revision encoding
17058f07778SDavid Daney */
17158f07778SDavid Daney #define OCTEON_CN58XX_PASS1_0 0x000d0300
17258f07778SDavid Daney #define OCTEON_CN58XX_PASS1_1 0x000d0301
17358f07778SDavid Daney #define OCTEON_CN58XX_PASS1_2 0x000d0303
17458f07778SDavid Daney #define OCTEON_CN58XX_PASS2_0 0x000d0308
17558f07778SDavid Daney #define OCTEON_CN58XX_PASS2_1 0x000d0309
17658f07778SDavid Daney #define OCTEON_CN58XX_PASS2_2 0x000d030a
17758f07778SDavid Daney #define OCTEON_CN58XX_PASS2_3 0x000d030b
17858f07778SDavid Daney
179debe6a62SDavid Daney #define OCTEON_CN58XX (OCTEON_CN58XX_PASS2_0 | OM_IGNORE_REVISION)
180751c9f68SDavid Daney #define OCTEON_CN58XX_PASS1_X (OCTEON_CN58XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
181751c9f68SDavid Daney #define OCTEON_CN58XX_PASS2_X (OCTEON_CN58XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
18258f07778SDavid Daney #define OCTEON_CN58XX_PASS1 OCTEON_CN58XX_PASS1_X
18358f07778SDavid Daney #define OCTEON_CN58XX_PASS2 OCTEON_CN58XX_PASS2_X
18458f07778SDavid Daney
18558f07778SDavid Daney #define OCTEON_CN56XX_PASS1_0 0x000d0400
18658f07778SDavid Daney #define OCTEON_CN56XX_PASS1_1 0x000d0401
18758f07778SDavid Daney #define OCTEON_CN56XX_PASS2_0 0x000d0408
18858f07778SDavid Daney #define OCTEON_CN56XX_PASS2_1 0x000d0409
18958f07778SDavid Daney
19058f07778SDavid Daney #define OCTEON_CN56XX (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_REVISION)
191751c9f68SDavid Daney #define OCTEON_CN56XX_PASS1_X (OCTEON_CN56XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
192751c9f68SDavid Daney #define OCTEON_CN56XX_PASS2_X (OCTEON_CN56XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
19358f07778SDavid Daney #define OCTEON_CN56XX_PASS1 OCTEON_CN56XX_PASS1_X
19458f07778SDavid Daney #define OCTEON_CN56XX_PASS2 OCTEON_CN56XX_PASS2_X
19558f07778SDavid Daney
19658f07778SDavid Daney #define OCTEON_CN57XX OCTEON_CN56XX
19758f07778SDavid Daney #define OCTEON_CN57XX_PASS1 OCTEON_CN56XX_PASS1
19858f07778SDavid Daney #define OCTEON_CN57XX_PASS2 OCTEON_CN56XX_PASS2
19958f07778SDavid Daney
20058f07778SDavid Daney #define OCTEON_CN55XX OCTEON_CN56XX
20158f07778SDavid Daney #define OCTEON_CN55XX_PASS1 OCTEON_CN56XX_PASS1
20258f07778SDavid Daney #define OCTEON_CN55XX_PASS2 OCTEON_CN56XX_PASS2
20358f07778SDavid Daney
20458f07778SDavid Daney #define OCTEON_CN54XX OCTEON_CN56XX
20558f07778SDavid Daney #define OCTEON_CN54XX_PASS1 OCTEON_CN56XX_PASS1
20658f07778SDavid Daney #define OCTEON_CN54XX_PASS2 OCTEON_CN56XX_PASS2
20758f07778SDavid Daney
20858f07778SDavid Daney #define OCTEON_CN50XX_PASS1_0 0x000d0600
20958f07778SDavid Daney
21058f07778SDavid Daney #define OCTEON_CN50XX (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_REVISION)
211751c9f68SDavid Daney #define OCTEON_CN50XX_PASS1_X (OCTEON_CN50XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
21258f07778SDavid Daney #define OCTEON_CN50XX_PASS1 OCTEON_CN50XX_PASS1_X
21358f07778SDavid Daney
21458f07778SDavid Daney /*
21558f07778SDavid Daney * NOTE: Octeon CN5000F model is not identifiable using the
21658f07778SDavid Daney * OCTEON_IS_MODEL() functions, but are treated as CN50XX.
21758f07778SDavid Daney */
21858f07778SDavid Daney
21958f07778SDavid Daney #define OCTEON_CN52XX_PASS1_0 0x000d0700
22058f07778SDavid Daney #define OCTEON_CN52XX_PASS2_0 0x000d0708
22158f07778SDavid Daney
22258f07778SDavid Daney #define OCTEON_CN52XX (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_REVISION)
223751c9f68SDavid Daney #define OCTEON_CN52XX_PASS1_X (OCTEON_CN52XX_PASS1_0 | OM_IGNORE_MINOR_REVISION)
224751c9f68SDavid Daney #define OCTEON_CN52XX_PASS2_X (OCTEON_CN52XX_PASS2_0 | OM_IGNORE_MINOR_REVISION)
22558f07778SDavid Daney #define OCTEON_CN52XX_PASS1 OCTEON_CN52XX_PASS1_X
22658f07778SDavid Daney #define OCTEON_CN52XX_PASS2 OCTEON_CN52XX_PASS2_X
22758f07778SDavid Daney
22858f07778SDavid Daney /*
22958f07778SDavid Daney * CN3XXX models with old revision enconding
23058f07778SDavid Daney */
23158f07778SDavid Daney #define OCTEON_CN38XX_PASS1 0x000d0000
23258f07778SDavid Daney #define OCTEON_CN38XX_PASS2 0x000d0001
23358f07778SDavid Daney #define OCTEON_CN38XX_PASS3 0x000d0003
23458f07778SDavid Daney #define OCTEON_CN38XX (OCTEON_CN38XX_PASS3 | OM_IGNORE_REVISION)
23558f07778SDavid Daney
23658f07778SDavid Daney #define OCTEON_CN36XX OCTEON_CN38XX
23758f07778SDavid Daney #define OCTEON_CN36XX_PASS2 OCTEON_CN38XX_PASS2
23858f07778SDavid Daney #define OCTEON_CN36XX_PASS3 OCTEON_CN38XX_PASS3
23958f07778SDavid Daney
24058f07778SDavid Daney /* The OCTEON_CN31XX matches CN31XX models and the CN3020 */
24158f07778SDavid Daney #define OCTEON_CN31XX_PASS1 0x000d0100
24258f07778SDavid Daney #define OCTEON_CN31XX_PASS1_1 0x000d0102
24358f07778SDavid Daney #define OCTEON_CN31XX (OCTEON_CN31XX_PASS1 | OM_IGNORE_REVISION)
24458f07778SDavid Daney
24558f07778SDavid Daney /*
24658f07778SDavid Daney * This model is only used for internal checks, it is not a valid
24758f07778SDavid Daney * model for the OCTEON_MODEL environment variable. This matches the
24858f07778SDavid Daney * CN3010 and CN3005 but NOT the CN3020.
24958f07778SDavid Daney */
25058f07778SDavid Daney #define OCTEON_CN30XX_PASS1 0x000d0200
25158f07778SDavid Daney #define OCTEON_CN30XX_PASS1_1 0x000d0202
25258f07778SDavid Daney #define OCTEON_CN30XX (OCTEON_CN30XX_PASS1 | OM_IGNORE_REVISION)
25358f07778SDavid Daney
25458f07778SDavid Daney #define OCTEON_CN3005_PASS1 (0x000d0210 | OM_CHECK_SUBMODEL)
25558f07778SDavid Daney #define OCTEON_CN3005_PASS1_0 (0x000d0210 | OM_CHECK_SUBMODEL)
25658f07778SDavid Daney #define OCTEON_CN3005_PASS1_1 (0x000d0212 | OM_CHECK_SUBMODEL)
257751c9f68SDavid Daney #define OCTEON_CN3005 (OCTEON_CN3005_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
25858f07778SDavid Daney
25958f07778SDavid Daney #define OCTEON_CN3010_PASS1 (0x000d0200 | OM_CHECK_SUBMODEL)
26058f07778SDavid Daney #define OCTEON_CN3010_PASS1_0 (0x000d0200 | OM_CHECK_SUBMODEL)
26158f07778SDavid Daney #define OCTEON_CN3010_PASS1_1 (0x000d0202 | OM_CHECK_SUBMODEL)
262751c9f68SDavid Daney #define OCTEON_CN3010 (OCTEON_CN3010_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
26358f07778SDavid Daney
26458f07778SDavid Daney #define OCTEON_CN3020_PASS1 (0x000d0110 | OM_CHECK_SUBMODEL)
26558f07778SDavid Daney #define OCTEON_CN3020_PASS1_0 (0x000d0110 | OM_CHECK_SUBMODEL)
26658f07778SDavid Daney #define OCTEON_CN3020_PASS1_1 (0x000d0112 | OM_CHECK_SUBMODEL)
267751c9f68SDavid Daney #define OCTEON_CN3020 (OCTEON_CN3020_PASS1 | OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)
26858f07778SDavid Daney
269751c9f68SDavid Daney /*
270751c9f68SDavid Daney * This matches the complete family of CN3xxx CPUs, and not subsequent
271751c9f68SDavid Daney * models
272751c9f68SDavid Daney */
273751c9f68SDavid Daney #define OCTEON_CN3XXX (OCTEON_CN58XX_PASS1_0 | OM_MATCH_PREVIOUS_MODELS | OM_IGNORE_REVISION)
274a70b13a9SDavid Daney #define OCTEON_CN5XXX (OCTEON_CN58XX_PASS1_0 | OM_MATCH_5XXX_FAMILY_MODELS)
275a70b13a9SDavid Daney #define OCTEON_CN6XXX (OCTEON_CN63XX_PASS1_0 | OM_MATCH_6XXX_FAMILY_MODELS)
276debe6a62SDavid Daney #define OCTEON_CNF7XXX (OCTEON_CNF71XX_PASS1_0 | \
277debe6a62SDavid Daney OM_MATCH_F7XXX_FAMILY_MODELS)
278debe6a62SDavid Daney #define OCTEON_CN7XXX (OCTEON_CN78XX_PASS1_0 | \
279debe6a62SDavid Daney OM_MATCH_7XXX_FAMILY_MODELS)
2806bbf6a6dSDavid Daney
28158f07778SDavid Daney /* The revision byte (low byte) has two different encodings.
28258f07778SDavid Daney * CN3XXX:
28358f07778SDavid Daney *
28458f07778SDavid Daney * bits
28558f07778SDavid Daney * <7:5>: reserved (0)
28658f07778SDavid Daney * <4>: alternate package
28758f07778SDavid Daney * <3:0>: revision
28858f07778SDavid Daney *
289debe6a62SDavid Daney * CN5XXX and older models:
29058f07778SDavid Daney *
29158f07778SDavid Daney * bits
29258f07778SDavid Daney * <7>: reserved (0)
29358f07778SDavid Daney * <6>: alternate package
29458f07778SDavid Daney * <5:3>: major revision
29558f07778SDavid Daney * <2:0>: minor revision
29658f07778SDavid Daney *
29758f07778SDavid Daney */
29858f07778SDavid Daney
29958f07778SDavid Daney /* Masks used for the various types of model/family/revision matching */
30058f07778SDavid Daney #define OCTEON_38XX_FAMILY_MASK 0x00ffff00
30158f07778SDavid Daney #define OCTEON_38XX_FAMILY_REV_MASK 0x00ffff0f
30258f07778SDavid Daney #define OCTEON_38XX_MODEL_MASK 0x00ffff10
303751c9f68SDavid Daney #define OCTEON_38XX_MODEL_REV_MASK (OCTEON_38XX_FAMILY_REV_MASK | OCTEON_38XX_MODEL_MASK)
30458f07778SDavid Daney
30558f07778SDavid Daney /* CN5XXX and later use different layout of bits in the revision ID field */
30658f07778SDavid Daney #define OCTEON_58XX_FAMILY_MASK OCTEON_38XX_FAMILY_MASK
30758f07778SDavid Daney #define OCTEON_58XX_FAMILY_REV_MASK 0x00ffff3f
308debe6a62SDavid Daney #define OCTEON_58XX_MODEL_MASK 0x00ffff40
309751c9f68SDavid Daney #define OCTEON_58XX_MODEL_REV_MASK (OCTEON_58XX_FAMILY_REV_MASK | OCTEON_58XX_MODEL_MASK)
310debe6a62SDavid Daney #define OCTEON_58XX_MODEL_MINOR_REV_MASK (OCTEON_58XX_MODEL_REV_MASK & 0x00ffff38)
311a70b13a9SDavid Daney #define OCTEON_5XXX_MODEL_MASK 0x00ff0fc0
31258f07778SDavid Daney
31358f07778SDavid Daney static inline uint32_t cvmx_get_proc_id(void) __attribute__ ((pure));
31458f07778SDavid Daney static inline uint64_t cvmx_read_csr(uint64_t csr_addr);
31558f07778SDavid Daney
316751c9f68SDavid Daney #define __OCTEON_MATCH_MASK__(x, y, z) (((x) & (z)) == ((y) & (z)))
317751c9f68SDavid Daney
318debe6a62SDavid Daney /*
319debe6a62SDavid Daney * __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model)
320debe6a62SDavid Daney * returns true if chip_model is identical or belong to the OCTEON
321debe6a62SDavid Daney * model group specified in arg_model.
322debe6a62SDavid Daney */
323751c9f68SDavid Daney /* NOTE: This for internal use only! */
324751c9f68SDavid Daney #define __OCTEON_IS_MODEL_COMPILE__(arg_model, chip_model) \
325751c9f68SDavid Daney ((((arg_model & OCTEON_38XX_FAMILY_MASK) < OCTEON_CN58XX_PASS1_0) && ( \
326751c9f68SDavid Daney ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
327751c9f68SDavid Daney && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_MASK)) || \
328751c9f68SDavid Daney ((((arg_model) & (OM_FLAG_MASK)) == 0) \
329751c9f68SDavid Daney && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_REV_MASK)) || \
330751c9f68SDavid Daney ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
331751c9f68SDavid Daney && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_FAMILY_MASK)) || \
332751c9f68SDavid Daney ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL) \
333751c9f68SDavid Daney && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_38XX_MODEL_REV_MASK)) || \
334751c9f68SDavid Daney ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
335751c9f68SDavid Daney && (((chip_model) & OCTEON_38XX_MODEL_MASK) < ((arg_model) & OCTEON_38XX_MODEL_MASK))) \
336751c9f68SDavid Daney )) || \
337751c9f68SDavid Daney (((arg_model & OCTEON_38XX_FAMILY_MASK) >= OCTEON_CN58XX_PASS1_0) && ( \
338751c9f68SDavid Daney ((((arg_model) & (OM_FLAG_MASK)) == (OM_IGNORE_REVISION | OM_CHECK_SUBMODEL)) \
339751c9f68SDavid Daney && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
340751c9f68SDavid Daney ((((arg_model) & (OM_FLAG_MASK)) == 0) \
341751c9f68SDavid Daney && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_REV_MASK)) || \
342751c9f68SDavid Daney ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_MINOR_REVISION) \
343751c9f68SDavid Daney && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MINOR_REV_MASK)) || \
344751c9f68SDavid Daney ((((arg_model) & (OM_FLAG_MASK)) == OM_IGNORE_REVISION) \
345751c9f68SDavid Daney && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_FAMILY_MASK)) || \
346751c9f68SDavid Daney ((((arg_model) & (OM_FLAG_MASK)) == OM_CHECK_SUBMODEL) \
347debe6a62SDavid Daney && __OCTEON_MATCH_MASK__((chip_model), (arg_model), OCTEON_58XX_MODEL_MASK)) || \
348751c9f68SDavid Daney ((((arg_model) & (OM_MATCH_5XXX_FAMILY_MODELS)) == OM_MATCH_5XXX_FAMILY_MODELS) \
349debe6a62SDavid Daney && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN58XX_PASS1_0) \
350debe6a62SDavid Daney && ((chip_model & OCTEON_PRID_MASK) < OCTEON_CN63XX_PASS1_0)) || \
351751c9f68SDavid Daney ((((arg_model) & (OM_MATCH_6XXX_FAMILY_MODELS)) == OM_MATCH_6XXX_FAMILY_MODELS) \
352debe6a62SDavid Daney && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN63XX_PASS1_0) \
353debe6a62SDavid Daney && ((chip_model & OCTEON_PRID_MASK) < OCTEON_CNF71XX_PASS1_0)) || \
354debe6a62SDavid Daney ((((arg_model) & (OM_MATCH_F7XXX_FAMILY_MODELS)) == OM_MATCH_F7XXX_FAMILY_MODELS) \
355debe6a62SDavid Daney && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CNF71XX_PASS1_0) \
356debe6a62SDavid Daney && ((chip_model & OCTEON_PRID_MASK) < OCTEON_CN78XX_PASS1_0)) || \
357debe6a62SDavid Daney ((((arg_model) & (OM_MATCH_7XXX_FAMILY_MODELS)) == OM_MATCH_7XXX_FAMILY_MODELS) \
358debe6a62SDavid Daney && ((chip_model & OCTEON_PRID_MASK) >= OCTEON_CN78XX_PASS1_0)) || \
359751c9f68SDavid Daney ((((arg_model) & (OM_MATCH_PREVIOUS_MODELS)) == OM_MATCH_PREVIOUS_MODELS) \
360751c9f68SDavid Daney && (((chip_model) & OCTEON_58XX_MODEL_MASK) < ((arg_model) & OCTEON_58XX_MODEL_MASK))) \
361751c9f68SDavid Daney )))
362751c9f68SDavid Daney
36358f07778SDavid Daney /* NOTE: This for internal use only!!!!! */
__octeon_is_model_runtime__(uint32_t model)36458f07778SDavid Daney static inline int __octeon_is_model_runtime__(uint32_t model)
36558f07778SDavid Daney {
36658f07778SDavid Daney uint32_t cpuid = cvmx_get_proc_id();
36758f07778SDavid Daney
36858f07778SDavid Daney return __OCTEON_IS_MODEL_COMPILE__(model, cpuid);
36958f07778SDavid Daney }
37058f07778SDavid Daney
37158f07778SDavid Daney /*
372751c9f68SDavid Daney * The OCTEON_IS_MODEL macro should be used for all Octeon model checking done
373751c9f68SDavid Daney * in a program.
374751c9f68SDavid Daney * This should be kept runtime if at all possible and must be conditionalized
375751c9f68SDavid Daney * with OCTEON_IS_COMMON_BINARY() if runtime checking support is required.
376751c9f68SDavid Daney *
377751c9f68SDavid Daney * Use of the macro in preprocessor directives ( #if OCTEON_IS_MODEL(...) )
378751c9f68SDavid Daney * is NOT SUPPORTED, and should be replaced with CVMX_COMPILED_FOR()
379751c9f68SDavid Daney * I.e.:
380751c9f68SDavid Daney * #if OCTEON_IS_MODEL(OCTEON_CN56XX) -> #if CVMX_COMPILED_FOR(OCTEON_CN56XX)
38158f07778SDavid Daney */
38258f07778SDavid Daney #define OCTEON_IS_MODEL(x) __octeon_is_model_runtime__(x)
38358f07778SDavid Daney #define OCTEON_IS_COMMON_BINARY() 1
38458f07778SDavid Daney #undef OCTEON_MODEL
38558f07778SDavid Daney
386debe6a62SDavid Daney #define OCTEON_IS_OCTEON1() OCTEON_IS_MODEL(OCTEON_CN3XXX)
387debe6a62SDavid Daney #define OCTEON_IS_OCTEONPLUS() OCTEON_IS_MODEL(OCTEON_CN5XXX)
388debe6a62SDavid Daney #define OCTEON_IS_OCTEON2() \
389debe6a62SDavid Daney (OCTEON_IS_MODEL(OCTEON_CN6XXX) || OCTEON_IS_MODEL(OCTEON_CNF71XX))
390debe6a62SDavid Daney
391debe6a62SDavid Daney #define OCTEON_IS_OCTEON3() OCTEON_IS_MODEL(OCTEON_CN7XXX)
392debe6a62SDavid Daney
393debe6a62SDavid Daney #define OCTEON_IS_OCTEON1PLUS() (OCTEON_IS_OCTEON1() || OCTEON_IS_OCTEONPLUS())
394debe6a62SDavid Daney
395da85e364SAaro Koskinen const char *__init octeon_model_get_string(uint32_t chip_id);
39658f07778SDavid Daney
3975cf02e55SDavid Daney /*
3985cf02e55SDavid Daney * Return the octeon family, i.e., ProcessorID of the PrID register.
399debe6a62SDavid Daney *
400debe6a62SDavid Daney * @return the octeon family on success, ((unint32_t)-1) on error.
4015cf02e55SDavid Daney */
cvmx_get_octeon_family(void)4025cf02e55SDavid Daney static inline uint32_t cvmx_get_octeon_family(void)
4035cf02e55SDavid Daney {
4045cf02e55SDavid Daney return cvmx_get_proc_id() & OCTEON_FAMILY_MASK;
4055cf02e55SDavid Daney }
4065cf02e55SDavid Daney
407a1ce3928SDavid Howells #include <asm/octeon/octeon-feature.h>
40858f07778SDavid Daney
40958f07778SDavid Daney #endif /* __OCTEON_MODEL_H__ */
410