1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD 3 * 4 * Copyright (c) 2007-2016 Solarflare Communications Inc. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions are met: 9 * 10 * 1. Redistributions of source code must retain the above copyright notice, 11 * this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright notice, 13 * this list of conditions and the following disclaimer in the documentation 14 * and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 18 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 20 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 21 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 23 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 24 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 * 28 * The views and conclusions contained in the software and documentation are 29 * those of the authors and should not be interpreted as representing official 30 * policies, either expressed or implied, of the FreeBSD Project. 31 * 32 * $FreeBSD$ 33 */ 34 35 #ifndef _SYS_SIENA_FLASH_H 36 #define _SYS_SIENA_FLASH_H 37 38 #pragma pack(1) 39 40 /* Fixed locations near the start of flash (which may be in the internal PHY 41 * firmware header) point to the boot header. 42 * 43 * - parsed by MC boot ROM and firmware 44 * - reserved (but not parsed) by PHY firmware 45 * - opaque to driver 46 */ 47 48 #define SIENA_MC_BOOT_PHY_FW_HDR_LEN (0x20) 49 50 #define SIENA_MC_BOOT_PTR_LOCATION (0x18) /* First thing we try to boot */ 51 #define SIENA_MC_BOOT_ALT_PTR_LOCATION (0x1c) /* Alternative if that fails */ 52 53 #define SIENA_MC_BOOT_HDR_LEN (0x200) 54 55 #define SIENA_MC_BOOT_MAGIC (0x51E4A001) 56 #define SIENA_MC_BOOT_VERSION (1) 57 58 59 /*Structures supporting an arbitrary number of binary blobs in the flash image 60 intended to house code and tables for the satellite cpus*/ 61 /*thanks to random.org for:*/ 62 #define BLOBS_HEADER_MAGIC (0xBDA3BBD4) 63 #define BLOB_HEADER_MAGIC (0xA1478A91) 64 65 typedef struct blobs_hdr_s { /* GENERATED BY scripts/genfwdef */ 66 efx_dword_t magic; 67 efx_dword_t no_of_blobs; 68 } blobs_hdr_t; 69 70 typedef struct blob_hdr_s { /* GENERATED BY scripts/genfwdef */ 71 efx_dword_t magic; 72 efx_dword_t cpu_type; 73 efx_dword_t build_variant; 74 efx_dword_t offset; 75 efx_dword_t length; 76 efx_dword_t checksum; 77 } blob_hdr_t; 78 79 #define BLOB_CPU_TYPE_TXDI_TEXT (0) 80 #define BLOB_CPU_TYPE_RXDI_TEXT (1) 81 #define BLOB_CPU_TYPE_TXDP_TEXT (2) 82 #define BLOB_CPU_TYPE_RXDP_TEXT (3) 83 #define BLOB_CPU_TYPE_RXHRSL_HR_LUT (4) 84 #define BLOB_CPU_TYPE_RXHRSL_HR_LUT_CFG (5) 85 #define BLOB_CPU_TYPE_TXHRSL_HR_LUT (6) 86 #define BLOB_CPU_TYPE_TXHRSL_HR_LUT_CFG (7) 87 #define BLOB_CPU_TYPE_RXHRSL_HR_PGM (8) 88 #define BLOB_CPU_TYPE_RXHRSL_SL_PGM (9) 89 #define BLOB_CPU_TYPE_TXHRSL_HR_PGM (10) 90 #define BLOB_CPU_TYPE_TXHRSL_SL_PGM (11) 91 #define BLOB_CPU_TYPE_RXDI_VTBL0 (12) 92 #define BLOB_CPU_TYPE_TXDI_VTBL0 (13) 93 #define BLOB_CPU_TYPE_RXDI_VTBL1 (14) 94 #define BLOB_CPU_TYPE_TXDI_VTBL1 (15) 95 #define BLOB_CPU_TYPE_DUMPSPEC (32) 96 #define BLOB_CPU_TYPE_MC_XIP (33) 97 98 #define BLOB_CPU_TYPE_INVALID (31) 99 100 /* 101 * The upper four bits of the CPU type field specify the compression 102 * algorithm used for this blob. 103 */ 104 #define BLOB_COMPRESSION_MASK (0xf0000000) 105 #define BLOB_CPU_TYPE_MASK (0x0fffffff) 106 107 #define BLOB_COMPRESSION_NONE (0x00000000) /* Stored as is */ 108 #define BLOB_COMPRESSION_LZ (0x10000000) /* see lib/lzdecoder.c */ 109 110 typedef struct siena_mc_boot_hdr_s { /* GENERATED BY scripts/genfwdef */ 111 efx_dword_t magic; /* = SIENA_MC_BOOT_MAGIC */ 112 efx_word_t hdr_version; /* this structure definition is version 1 */ 113 efx_byte_t board_type; 114 efx_byte_t firmware_version_a; 115 efx_byte_t firmware_version_b; 116 efx_byte_t firmware_version_c; 117 efx_word_t checksum; /* of whole header area + firmware image */ 118 efx_word_t firmware_version_d; 119 efx_byte_t mcfw_subtype; 120 efx_byte_t generation; /* MC (Medford and later): MC partition generation when */ 121 /* written to NVRAM. */ 122 /* MUM & SUC images: subtype. */ 123 /* (Otherwise set to 0) */ 124 efx_dword_t firmware_text_offset; /* offset to firmware .text */ 125 efx_dword_t firmware_text_size; /* length of firmware .text, in bytes */ 126 efx_dword_t firmware_data_offset; /* offset to firmware .data */ 127 efx_dword_t firmware_data_size; /* length of firmware .data, in bytes */ 128 efx_byte_t spi_rate; /* SPI rate for reading image, 0 is BootROM default */ 129 efx_byte_t spi_phase_adj; /* SPI SDO/SCL phase adjustment, 0 is default (no adj) */ 130 efx_word_t xpm_sector; /* XPM (MEDFORD and later): The sector that contains */ 131 /* the key, or 0xffff if unsigned. (Otherwise set to 0) */ 132 efx_byte_t mumfw_subtype; /* MUM & SUC images: subtype. (Otherwise set to 0) */ 133 efx_byte_t reserved_b[3]; /* (set to 0) */ 134 efx_dword_t security_level; /* This number increases every time a serious security flaw */ 135 /* is fixed. A secure NIC may not downgrade to any image */ 136 /* with a lower security level than the current image. */ 137 /* Note: The number in this header should only be used for */ 138 /* determining the level of new images, not to determine */ 139 /* the level of the current image as this header is not */ 140 /* protected by a CMAC. */ 141 efx_dword_t reserved_c[5]; /* (set to 0) */ 142 } siena_mc_boot_hdr_t; 143 144 #define SIENA_MC_BOOT_HDR_PADDING \ 145 (SIENA_MC_BOOT_HDR_LEN - sizeof(siena_mc_boot_hdr_t)) 146 147 #define SIENA_MC_STATIC_CONFIG_MAGIC (0xBDCF5555) 148 #define SIENA_MC_STATIC_CONFIG_VERSION (0) 149 150 typedef struct siena_mc_static_config_hdr_s { /* GENERATED BY scripts/genfwdef */ 151 efx_dword_t magic; /* = SIENA_MC_STATIC_CONFIG_MAGIC */ 152 efx_word_t length; /* of header area (i.e. not including VPD) */ 153 efx_byte_t version; 154 efx_byte_t csum; /* over header area (i.e. not including VPD) */ 155 efx_dword_t static_vpd_offset; 156 efx_dword_t static_vpd_length; 157 efx_dword_t capabilities; 158 efx_byte_t mac_addr_base[6]; 159 efx_byte_t green_mode_cal; /* Green mode calibration result */ 160 efx_byte_t green_mode_valid; /* Whether cal holds a valid value */ 161 efx_word_t mac_addr_count; 162 efx_word_t mac_addr_stride; 163 efx_word_t calibrated_vref; /* Vref as measured during production */ 164 efx_word_t adc_vref; /* Vref as read by ADC */ 165 efx_dword_t reserved2[1]; /* (write as zero) */ 166 efx_dword_t num_dbi_items; 167 struct { 168 efx_word_t addr; 169 efx_word_t byte_enables; 170 efx_dword_t value; 171 } dbi[]; 172 } siena_mc_static_config_hdr_t; 173 174 #define SIENA_MC_DYNAMIC_CONFIG_MAGIC (0xBDCFDDDD) 175 #define SIENA_MC_DYNAMIC_CONFIG_VERSION (0) 176 177 typedef struct siena_mc_fw_version_s { /* GENERATED BY scripts/genfwdef */ 178 efx_dword_t fw_subtype; 179 efx_word_t version_w; 180 efx_word_t version_x; 181 efx_word_t version_y; 182 efx_word_t version_z; 183 } siena_mc_fw_version_t; 184 185 typedef struct siena_mc_dynamic_config_hdr_s { /* GENERATED BY scripts/genfwdef */ 186 efx_dword_t magic; /* = SIENA_MC_DYNAMIC_CONFIG_MAGIC */ 187 efx_word_t length; /* of header area (i.e. not including VPD) */ 188 efx_byte_t version; 189 efx_byte_t csum; /* over header area (i.e. not including VPD) */ 190 efx_dword_t dynamic_vpd_offset; 191 efx_dword_t dynamic_vpd_length; 192 efx_dword_t num_fw_version_items; 193 siena_mc_fw_version_t fw_version[]; 194 } siena_mc_dynamic_config_hdr_t; 195 196 #define SIENA_MC_EXPROM_SINGLE_MAGIC (0xAA55) /* little-endian uint16_t */ 197 198 #define SIENA_MC_EXPROM_COMBO_MAGIC (0xB0070102) /* little-endian uint32_t */ 199 #define SIENA_MC_EXPROM_COMBO_V2_MAGIC (0xB0070103) /* little-endian uint32_t */ 200 201 typedef struct siena_mc_combo_rom_hdr_s { /* GENERATED BY scripts/genfwdef */ 202 efx_dword_t magic; /* = SIENA_MC_EXPROM_COMBO_MAGIC or SIENA_MC_EXPROM_COMBO_V2_MAGIC */ 203 union { 204 struct { 205 efx_dword_t len1; /* length of first image */ 206 efx_dword_t len2; /* length of second image */ 207 efx_dword_t off1; /* offset of first byte to edit to combine images */ 208 efx_dword_t off2; /* offset of second byte to edit to combine images */ 209 efx_word_t infoblk0_off;/* infoblk offset */ 210 efx_word_t infoblk1_off;/* infoblk offset */ 211 efx_byte_t infoblk_len;/* length of space reserved for one infoblk structure */ 212 efx_byte_t reserved[7];/* (set to 0) */ 213 } v1; 214 struct { 215 efx_dword_t len1; /* length of first image */ 216 efx_dword_t len2; /* length of second image */ 217 efx_dword_t off1; /* offset of first byte to edit to combine images */ 218 efx_dword_t off2; /* offset of second byte to edit to combine images */ 219 efx_word_t infoblk_off;/* infoblk start offset */ 220 efx_word_t infoblk_count;/* infoblk count */ 221 efx_byte_t infoblk_len;/* length of space reserved for one infoblk structure */ 222 efx_byte_t reserved[7];/* (set to 0) */ 223 } v2; 224 } data; 225 } siena_mc_combo_rom_hdr_t; 226 227 #pragma pack() 228 229 #endif /* _SYS_SIENA_FLASH_H */ 230