| 1 | /***********************license start*********************************** |
| 2 | * Copyright (c) 2003-2017 Cavium Inc. ([email protected]). All rights |
| 3 | * reserved. |
| 4 | * |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * |
| 13 | * * Redistributions in binary form must reproduce the above |
| 14 | * copyright notice, this list of conditions and the following |
| 15 | * disclaimer in the documentation and/or other materials provided |
| 16 | * with the distribution. |
| 17 | * |
| 18 | * * Neither the name of Cavium Inc. nor the names of |
| 19 | * its contributors may be used to endorse or promote products |
| 20 | * derived from this software without specific prior written |
| 21 | * permission. |
| 22 | * |
| 23 | * This Software, including technical data, may be subject to U.S. export |
| 24 | * control laws, including the U.S. Export Administration Act and its |
| 25 | * associated regulations, and may be subject to export or import |
| 26 | * regulations in other countries. |
| 27 | * |
| 28 | * TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
| 29 | * AND WITH ALL FAULTS AND CAVIUM INC. MAKES NO PROMISES, REPRESENTATIONS OR |
| 30 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT |
| 31 | * TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY |
| 32 | * REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT |
| 33 | * DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES |
| 34 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR |
| 35 | * PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, |
| 36 | * QUIET POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK |
| 37 | * ARISING OUT OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU. |
| 38 | ***********************license end**************************************/ |
| 39 | #include <bdk.h> |
| 40 | #include "libbdk-arch/bdk-csrs-ap.h" |
| 41 | #include "libbdk-arch/bdk-csrs-mio_fus.h" |
| 42 | #include "libbdk-arch/bdk-csrs-fus.h" |
| 43 | #include "libbdk-arch/bdk-csrs-fusf.h" |
| 44 | #include <libbdk-hal/bdk-clock.h> |
| 45 | #include <libbdk-hal/bdk-utils.h> |
| 46 | |
| 47 | /* |
| 48 | Format of a SKU |
| 49 | CN8890-2000BG2601-AAP-G |
| 50 | CN8890-2000BG2601-AAP-PR-Y-G |
| 51 | CN XX XX X - XXX BG XXX - XX (- XX) (- X) - G |
| 52 | | | | | | | | | | | ^ RoHS Option, G=RoHS 6/6 |
| 53 | | | | | | | | | | ^ Product Revision, blank for pass 1, Y=pass 2, W=pass 3, V=pass 4 |
| 54 | | | | | | | | | ^ Product Phase, blank=production, PR=Prototype, ES=Engineering Sample |
| 55 | | | | | | | | ^ Marketing Segment Option (SC, SNT, etc) |
| 56 | | | | | | | ^ Number of balls on the package |
| 57 | | | | | | ^ Ball Grid Array |
| 58 | | | | | ^ Frequency in Mhz, 3 or 4 digits (300 - 2000) |
| 59 | | | | ^ Optional Customer Code, blank or A-Z |
| 60 | | | ^ Number of cores, see table below |
| 61 | | ^ Processor family, plus or minus for L2 sizes and such (88, 86, 83, 81, 80) |
| 62 | ^ Cavium Prefix, sometimes changed for customer specific parts |
| 63 | |
| 64 | Table of Core to Model encoding |
| 65 | >= 48 shows xx90 |
| 66 | >= 44 shows xx88 |
| 67 | >= 42 shows xx85 |
| 68 | >= 32 shows xx80 |
| 69 | >= 24 shows xx70 |
| 70 | >= 20 shows xx65 |
| 71 | >= 16 shows xx60 |
| 72 | = 15 shows xx58 |
| 73 | = 14 shows xx55 |
| 74 | = 13 shows xx52 |
| 75 | = 12 shows xx50 |
| 76 | = 11 shows xx48 |
| 77 | = 10 shows xx45 |
| 78 | = 9 shows xx42 |
| 79 | = 8 shows xx40 |
| 80 | = 7 shows xx38 |
| 81 | = 6 shows xx34 |
| 82 | = 5 shows xx32 |
| 83 | = 4 shows xx30 |
| 84 | = 3 shows xx25 |
| 85 | = 2 shows xx20 |
| 86 | = 1 shows xx10 |
| 87 | */ |
| 88 | |
| 89 | /* Definition of each SKU table entry for the different dies */ |
| 90 | typedef struct |
| 91 | { |
| 92 | uint8_t fuse_index; /* Index programmed into PNAME fuses to match this entry. Must never change once fused parts ship */ |
| 93 | const char prefix[4]; /* Prefix before model number, usually "CN". Third letter is customer code shown after the model */ |
| 94 | uint8_t model_base; /* First two digits of the model number */ |
| 95 | uint16_t num_balls; /* Number of balls on package, included in SKU */ |
| 96 | const char segment[4]; /* Market segment SKU is for, 2-3 character string */ |
| 97 | uint16_t fuses[12]; /* List of fuses required for operation of this SKU */ |
| 98 | } model_sku_info_t; |
| 99 | |
| 100 | /* In the model_sku_info_t.fuses[] array, we use a special value |
| 101 | FUSES_CHECK_FUSF to represent that we need to check FUSF_CTL bit |
| 102 | 6, checking for trusted boot */ |
| 103 | #define FUSES_CHECK_FUSF 0xffff |
| 104 | |
| 105 | /** |
| 106 | * Return non-zero if the die is in an alternate package. The |
| 107 | * normal is_model() checks will treat alternate package parts |
| 108 | * as all the same, where this function can be used to detect |
| 109 | * them. The return value is the upper two bits of |
| 110 | * MIO_FUS_DAT2[chip_id]. Most alternate packages use bit 6, |
| 111 | * which will return 1 here. Parts with a second alternative |
| 112 | * will use bit 7, which will return 2. |
| 113 | * |
| 114 | * @param arg_model One of the CAVIUM_* constants for chip models and passes |
| 115 | * |
| 116 | * @return Non-zero if an alternate package |
| 117 | * 0 = Normal package |
| 118 | * 1 = Alternate package 1 (CN86XX, CN80XX with 555 balls) |
| 119 | * 2 = Alternate package 2 (CN80XX with 676 balls) |
| 120 | * 3 = Alternate package 3 (Currently unused) |
| 121 | */ |
| 122 | int cavium_is_altpkg(uint32_t arg_model) |
| 123 | { |
| 124 | if (CAVIUM_IS_MODEL(arg_model)) |
| 125 | { |
| 126 | BDK_CSR_INIT(mio_fus_dat2, bdk_numa_local(), BDK_MIO_FUS_DAT2); |
| 127 | /* Bits 7:6 are used for alternate packages. Return the exact |
| 128 | number so multiple alternate packages can be detected |
| 129 | (CN80XX is an example) */ |
| 130 | int altpkg = mio_fus_dat2.s.chip_id >> 6; |
| 131 | if (altpkg) |
| 132 | return altpkg; |
| 133 | /* Due to a documentation mixup, some CN80XX parts do not have chip_id |
| 134 | bit 7 set. As a backup, use lmc_mode32 to find these parts. Both |
| 135 | bits are suppose to be fused, but some parts only have lmc_mode32 */ |
| 136 | if (CAVIUM_IS_MODEL(CAVIUM_CN81XX) && mio_fus_dat2.s.lmc_mode32) |
| 137 | return 2; |
| 138 | return 0; |
| 139 | } |
| 140 | else |
| 141 | return 0; |
| 142 | } |