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>
35 * Given the chip processor ID from COP0, this function returns a
36 * string representing the chip model number. The string is of the
37 * form CNXXXXpX.X-FREQ-SUFFIX.
38 * - XXXX = The chip model number
39 * - X.X = Chip pass number
40 * - FREQ = Current frequency in Mhz
41 * - SUFFIX = NSP, EXP, SCP, SSP, or CP
45 * Returns Model string
47 const char *octeon_model_get_string(uint32_t chip_id
)
49 static char buffer
[32];
50 return octeon_model_get_string_buffer(chip_id
, buffer
);
54 * Version of octeon_model_get_string() that takes buffer as argument,
55 * as running early in u-boot static/global variables don't work when
58 const char *octeon_model_get_string_buffer(uint32_t chip_id
, char *buffer
)
61 const char *core_model
;
65 union cvmx_l2d_fus3 fus3
;
67 union cvmx_mio_fus_dat2 fus_dat2
;
68 union cvmx_mio_fus_dat3 fus_dat3
;
70 uint32_t fuse_data
= 0;
72 fus3
.u64
= cvmx_read_csr(CVMX_L2D_FUS3
);
73 fus_dat2
.u64
= cvmx_read_csr(CVMX_MIO_FUS_DAT2
);
74 fus_dat3
.u64
= cvmx_read_csr(CVMX_MIO_FUS_DAT3
);
76 num_cores
= cvmx_octeon_num_cores();
78 /* Make sure the non existant devices look disabled */
79 switch ((chip_id
>> 8) & 0xff) {
82 fus_dat3
.s
.nodfa_dte
= 1;
85 case 4: /* CN57XX or CN56XX */
86 fus_dat3
.s
.nodfa_dte
= 1;
92 /* Make a guess at the suffix */
93 /* NSP = everything */
95 /* SCP = No DFA, No zip */
96 /* CP = No DFA, No crypto, No zip */
97 if (fus_dat3
.s
.nodfa_dte
) {
98 if (fus_dat2
.s
.nocrypto
)
102 } else if (fus_dat2
.s
.nocrypto
)
108 * Assume pass number is encoded using <5:3><2:0>. Exceptions
109 * will be fixed later.
111 sprintf(pass
, "%u.%u", ((chip_id
>> 3) & 7) + 1, chip_id
& 7);
114 * Use the number of cores to determine the last 2 digits of
115 * the model number. There are some exceptions that are fixed
172 /* Now figure out the family, the first two digits */
173 switch ((chip_id
>> 8) & 0xff) {
174 case 0: /* CN38XX, CN37XX or CN36XX */
175 if (fus3
.cn38xx
.crip_512k
) {
177 * For some unknown reason, the 16 core one is
178 * called 37 instead of 36.
187 * This series of chips didn't follow the standard
190 switch (chip_id
& 0xf) {
205 case 1: /* CN31XX or CN3020 */
206 if ((chip_id
& 0x10) || fus3
.cn31xx
.crip_128k
)
211 * This series of chips didn't follow the standard
214 switch (chip_id
& 0xf) {
226 case 2: /* CN3010 or CN3005 */
228 /* A chip with half cache is an 05 */
229 if (fus3
.cn30xx
.crip_64k
)
232 * This series of chips didn't follow the standard
235 switch (chip_id
& 0xf) {
249 /* Special case. 4 core, no crypto */
250 if ((num_cores
== 4) && fus_dat2
.cn38xx
.nocrypto
)
253 /* Pass 1 uses different encodings for pass numbers */
254 if ((chip_id
& 0xFF) < 0x8) {
255 switch (chip_id
& 0x3) {
271 case 4: /* CN57XX, CN56XX, CN55XX, CN54XX */
272 if (fus_dat2
.cn56xx
.raid_en
) {
273 if (fus3
.cn56xx
.crip_1024k
)
277 if (fus_dat2
.cn56xx
.nocrypto
)
282 if (fus_dat2
.cn56xx
.nocrypto
)
286 if (fus_dat3
.s
.nozip
)
289 if (fus3
.cn56xx
.crip_1024k
)
299 if (fus3
.cn52xx
.crip_256k
)
312 clock_mhz
= octeon_get_clock_rate() / 1000000;
314 if (family
[0] != '3') {
315 /* Check for model in fuses, overrides normal decode */
316 /* This is _not_ valid for Octeon CN3XXX models */
317 fuse_data
|= cvmx_fuse_read_byte(51);
318 fuse_data
= fuse_data
<< 8;
319 fuse_data
|= cvmx_fuse_read_byte(50);
320 fuse_data
= fuse_data
<< 8;
321 fuse_data
|= cvmx_fuse_read_byte(49);
322 fuse_data
= fuse_data
<< 8;
323 fuse_data
|= cvmx_fuse_read_byte(48);
324 if (fuse_data
& 0x7ffff) {
325 int model
= fuse_data
& 0x3fff;
326 int suffix
= (fuse_data
>> 14) & 0x1f;
327 if (suffix
&& model
) {
329 * Have both number and suffix in
332 sprintf(fuse_model
, "%d%c",
333 model
, 'A' + suffix
- 1);
336 } else if (suffix
&& !model
) {
338 * Only have suffix, so add suffix to
339 * 'normal' model number.
341 sprintf(fuse_model
, "%s%c", core_model
,
343 core_model
= fuse_model
;
346 * Don't have suffix, so just use
349 sprintf(fuse_model
, "%d", model
);
355 sprintf(buffer
, "CN%s%sp%s-%d-%s",
356 family
, core_model
, pass
, clock_mhz
, suffix
);