1 /***********************license start***************
2 * Author: Cavium Networks
4 * Contact: support@caviumnetworks.com
5 * This file is part of the OCTEON SDK
7 * Copyright (c) 2003-2008 Cavium Networks
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.
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
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/.
24 * This file may also be available under a different license from Cavium.
25 * Contact Cavium Networks for more information
26 ***********************license end**************************************/
29 * File defining functions for working with different Octeon
32 #include <asm/octeon/octeon.h>
34 const char *octeon_model_get_string(uint32_t chip_id
)
36 static char buffer
[32];
37 return octeon_model_get_string_buffer(chip_id
, buffer
);
41 * Version of octeon_model_get_string() that takes buffer as argument,
42 * as running early in u-boot static/global variables don't work when
45 const char *octeon_model_get_string_buffer(uint32_t chip_id
, char *buffer
)
48 const char *core_model
;
52 union cvmx_l2d_fus3 fus3
;
54 union cvmx_mio_fus_dat2 fus_dat2
;
55 union cvmx_mio_fus_dat3 fus_dat3
;
57 uint32_t fuse_data
= 0;
59 fus3
.u64
= cvmx_read_csr(CVMX_L2D_FUS3
);
60 fus_dat2
.u64
= cvmx_read_csr(CVMX_MIO_FUS_DAT2
);
61 fus_dat3
.u64
= cvmx_read_csr(CVMX_MIO_FUS_DAT3
);
63 num_cores
= cvmx_octeon_num_cores();
65 /* Make sure the non existant devices look disabled */
66 switch ((chip_id
>> 8) & 0xff) {
69 fus_dat3
.s
.nodfa_dte
= 1;
72 case 4: /* CN57XX or CN56XX */
73 fus_dat3
.s
.nodfa_dte
= 1;
79 /* Make a guess at the suffix */
80 /* NSP = everything */
82 /* SCP = No DFA, No zip */
83 /* CP = No DFA, No crypto, No zip */
84 if (fus_dat3
.s
.nodfa_dte
) {
85 if (fus_dat2
.s
.nocrypto
)
89 } else if (fus_dat2
.s
.nocrypto
)
95 * Assume pass number is encoded using <5:3><2:0>. Exceptions
96 * will be fixed later.
98 sprintf(pass
, "%u.%u", ((chip_id
>> 3) & 7) + 1, chip_id
& 7);
101 * Use the number of cores to determine the last 2 digits of
102 * the model number. There are some exceptions that are fixed
159 /* Now figure out the family, the first two digits */
160 switch ((chip_id
>> 8) & 0xff) {
161 case 0: /* CN38XX, CN37XX or CN36XX */
162 if (fus3
.cn38xx
.crip_512k
) {
164 * For some unknown reason, the 16 core one is
165 * called 37 instead of 36.
174 * This series of chips didn't follow the standard
177 switch (chip_id
& 0xf) {
192 case 1: /* CN31XX or CN3020 */
193 if ((chip_id
& 0x10) || fus3
.cn31xx
.crip_128k
)
198 * This series of chips didn't follow the standard
201 switch (chip_id
& 0xf) {
213 case 2: /* CN3010 or CN3005 */
215 /* A chip with half cache is an 05 */
216 if (fus3
.cn30xx
.crip_64k
)
219 * This series of chips didn't follow the standard
222 switch (chip_id
& 0xf) {
236 /* Special case. 4 core, no crypto */
237 if ((num_cores
== 4) && fus_dat2
.cn38xx
.nocrypto
)
240 /* Pass 1 uses different encodings for pass numbers */
241 if ((chip_id
& 0xFF) < 0x8) {
242 switch (chip_id
& 0x3) {
258 case 4: /* CN57XX, CN56XX, CN55XX, CN54XX */
259 if (fus_dat2
.cn56xx
.raid_en
) {
260 if (fus3
.cn56xx
.crip_1024k
)
264 if (fus_dat2
.cn56xx
.nocrypto
)
269 if (fus_dat2
.cn56xx
.nocrypto
)
273 if (fus_dat3
.s
.nozip
)
276 if (fus3
.cn56xx
.crip_1024k
)
286 if (fus3
.cn52xx
.crip_256k
)
299 clock_mhz
= octeon_get_clock_rate() / 1000000;
301 if (family
[0] != '3') {
302 /* Check for model in fuses, overrides normal decode */
303 /* This is _not_ valid for Octeon CN3XXX models */
304 fuse_data
|= cvmx_fuse_read_byte(51);
305 fuse_data
= fuse_data
<< 8;
306 fuse_data
|= cvmx_fuse_read_byte(50);
307 fuse_data
= fuse_data
<< 8;
308 fuse_data
|= cvmx_fuse_read_byte(49);
309 fuse_data
= fuse_data
<< 8;
310 fuse_data
|= cvmx_fuse_read_byte(48);
311 if (fuse_data
& 0x7ffff) {
312 int model
= fuse_data
& 0x3fff;
313 int suffix
= (fuse_data
>> 14) & 0x1f;
314 if (suffix
&& model
) {
316 * Have both number and suffix in
319 sprintf(fuse_model
, "%d%c",
320 model
, 'A' + suffix
- 1);
323 } else if (suffix
&& !model
) {
325 * Only have suffix, so add suffix to
326 * 'normal' model number.
328 sprintf(fuse_model
, "%s%c", core_model
,
330 core_model
= fuse_model
;
333 * Don't have suffix, so just use
336 sprintf(fuse_model
, "%d", model
);
342 sprintf(buffer
, "CN%s%sp%s-%d-%s",
343 family
, core_model
, pass
, clock_mhz
, suffix
);