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-2010 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**************************************/
28 #include <asm/octeon/octeon.h>
31 * Read a byte of fuse data
32 * @byte_addr: address to read
34 * Returns fuse value: 0 or 1
36 static uint8_t __init cvmx_fuse_read_byte(int byte_addr)
38 union cvmx_mio_fus_rcmd read_cmd;
41 read_cmd.s.addr = byte_addr;
43 cvmx_write_csr(CVMX_MIO_FUS_RCMD, read_cmd.u64);
44 while ((read_cmd.u64 = cvmx_read_csr(CVMX_MIO_FUS_RCMD))
47 return read_cmd.s.dat;
51 * Version of octeon_model_get_string() that takes buffer as argument,
52 * as running early in u-boot static/global variables don't work when
55 static const char *__init octeon_model_get_string_buffer(uint32_t chip_id,
59 const char *core_model;
63 union cvmx_l2d_fus3 fus3;
65 union cvmx_mio_fus_dat2 fus_dat2;
66 union cvmx_mio_fus_dat3 fus_dat3;
68 uint32_t fuse_data = 0;
71 if (!OCTEON_IS_MODEL(OCTEON_CN6XXX))
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);
75 num_cores = cvmx_pop(cvmx_read_csr(CVMX_CIU_FUSE));
77 /* Make sure the non existent devices look disabled */
78 switch ((chip_id >> 8) & 0xff) {
81 fus_dat3.s.nodfa_dte = 1;
84 case 4: /* CN57XX or CN56XX */
85 fus_dat3.s.nodfa_dte = 1;
91 /* Make a guess at the suffix */
92 /* NSP = everything */
94 /* SCP = No DFA, No zip */
95 /* CP = No DFA, No crypto, No zip */
96 if (fus_dat3.s.nodfa_dte) {
97 if (fus_dat2.s.nocrypto)
101 } else if (fus_dat2.s.nocrypto)
107 * Assume pass number is encoded using <5:3><2:0>. Exceptions
108 * will be fixed later.
110 sprintf(pass, "%d.%d", (int)((chip_id >> 3) & 7) + 1, (int)chip_id & 7);
113 * Use the number of cores to determine the last 2 digits of
114 * the model number. There are some exceptions that are fixed
177 /* Now figure out the family, the first two digits */
178 switch ((chip_id >> 8) & 0xff) {
179 case 0: /* CN38XX, CN37XX or CN36XX */
180 if (fus3.cn38xx.crip_512k) {
182 * For some unknown reason, the 16 core one is
183 * called 37 instead of 36.
192 * This series of chips didn't follow the standard
195 switch (chip_id & 0xf) {
210 case 1: /* CN31XX or CN3020 */
211 if ((chip_id & 0x10) || fus3.cn31xx.crip_128k)
216 * This series of chips didn't follow the standard
219 switch (chip_id & 0xf) {
231 case 2: /* CN3010 or CN3005 */
233 /* A chip with half cache is an 05 */
234 if (fus3.cn30xx.crip_64k)
237 * This series of chips didn't follow the standard
240 switch (chip_id & 0xf) {
254 /* Special case. 4 core, half cache (CP with half cache) */
255 if ((num_cores == 4) && fus3.cn58xx.crip_1024k && !strncmp(suffix, "CP", 2))
258 /* Pass 1 uses different encodings for pass numbers */
259 if ((chip_id & 0xFF) < 0x8) {
260 switch (chip_id & 0x3) {
276 case 4: /* CN57XX, CN56XX, CN55XX, CN54XX */
277 if (fus_dat2.cn56xx.raid_en) {
278 if (fus3.cn56xx.crip_1024k)
282 if (fus_dat2.cn56xx.nocrypto)
287 if (fus_dat2.cn56xx.nocrypto)
291 if (fus_dat3.s.nozip)
294 if (fus_dat3.s.bar2_en)
297 if (fus3.cn56xx.crip_1024k)
307 if (fus3.cn52xx.crip_256k)
312 case 0x93: /* CN61XX */
314 if (fus_dat2.cn61xx.nocrypto && fus_dat2.cn61xx.dorm_crypto)
316 if (fus_dat2.cn61xx.nocrypto)
318 else if (fus_dat2.cn61xx.dorm_crypto)
320 else if (fus_dat3.cn61xx.nozip)
323 case 0x90: /* CN63XX */
325 if (fus_dat3.s.l2c_crip == 2)
327 if (num_cores == 6) /* Other core counts match generic */
329 if (fus_dat2.cn63xx.nocrypto)
331 else if (fus_dat2.cn63xx.dorm_crypto)
333 else if (fus_dat3.cn63xx.nozip)
338 case 0x92: /* CN66XX */
340 if (num_cores == 6) /* Other core counts match generic */
342 if (fus_dat2.cn66xx.nocrypto && fus_dat2.cn66xx.dorm_crypto)
344 if (fus_dat2.cn66xx.nocrypto)
346 else if (fus_dat2.cn66xx.dorm_crypto)
348 else if (fus_dat3.cn66xx.nozip)
353 case 0x91: /* CN68XX */
355 if (fus_dat2.cn68xx.nocrypto && fus_dat3.cn68xx.nozip)
357 else if (fus_dat2.cn68xx.dorm_crypto)
359 else if (fus_dat3.cn68xx.nozip)
361 else if (fus_dat2.cn68xx.nocrypto)
374 clock_mhz = octeon_get_clock_rate() / 1000000;
375 if (family[0] != '3') {
376 int fuse_base = 384 / 8;
377 if (family[0] == '6')
380 /* Check for model in fuses, overrides normal decode */
381 /* This is _not_ valid for Octeon CN3XXX models */
382 fuse_data |= cvmx_fuse_read_byte(fuse_base + 3);
383 fuse_data = fuse_data << 8;
384 fuse_data |= cvmx_fuse_read_byte(fuse_base + 2);
385 fuse_data = fuse_data << 8;
386 fuse_data |= cvmx_fuse_read_byte(fuse_base + 1);
387 fuse_data = fuse_data << 8;
388 fuse_data |= cvmx_fuse_read_byte(fuse_base);
389 if (fuse_data & 0x7ffff) {
390 int model = fuse_data & 0x3fff;
391 int suffix = (fuse_data >> 14) & 0x1f;
392 if (suffix && model) {
393 /* Have both number and suffix in fuses, so both */
394 sprintf(fuse_model, "%d%c", model, 'A' + suffix - 1);
397 } else if (suffix && !model) {
398 /* Only have suffix, so add suffix to 'normal' model number */
399 sprintf(fuse_model, "%s%c", core_model, 'A' + suffix - 1);
400 core_model = fuse_model;
402 /* Don't have suffix, so just use model from fuses */
403 sprintf(fuse_model, "%d", model);
409 sprintf(buffer, "CN%s%sp%s-%d-%s", family, core_model, pass, clock_mhz, suffix);
414 * Given the chip processor ID from COP0, this function returns a
415 * string representing the chip model number. The string is of the
416 * form CNXXXXpX.X-FREQ-SUFFIX.
417 * - XXXX = The chip model number
418 * - X.X = Chip pass number
419 * - FREQ = Current frequency in Mhz
420 * - SUFFIX = NSP, EXP, SCP, SSP, or CP
424 * Returns Model string
426 const char *__init octeon_model_get_string(uint32_t chip_id)
428 static char buffer[32];
429 return octeon_model_get_string_buffer(chip_id, buffer);