xref: /freebsd/sys/dev/sfxge/common/siena_flash.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1e948693eSPhilip Paeps /*-
2*4d846d26SWarner Losh  * SPDX-License-Identifier: BSD-2-Clause
3718cf2ccSPedro F. Giffuni  *
4929c7febSAndrew Rybchenko  * Copyright (c) 2007-2016 Solarflare Communications Inc.
53c838a9fSAndrew Rybchenko  * All rights reserved.
6e948693eSPhilip Paeps  *
7e948693eSPhilip Paeps  * Redistribution and use in source and binary forms, with or without
83c838a9fSAndrew Rybchenko  * modification, are permitted provided that the following conditions are met:
9e948693eSPhilip Paeps  *
103c838a9fSAndrew Rybchenko  * 1. Redistributions of source code must retain the above copyright notice,
113c838a9fSAndrew Rybchenko  *    this list of conditions and the following disclaimer.
123c838a9fSAndrew Rybchenko  * 2. Redistributions in binary form must reproduce the above copyright notice,
133c838a9fSAndrew Rybchenko  *    this list of conditions and the following disclaimer in the documentation
143c838a9fSAndrew Rybchenko  *    and/or other materials provided with the distribution.
153c838a9fSAndrew Rybchenko  *
163c838a9fSAndrew Rybchenko  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
173c838a9fSAndrew Rybchenko  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
183c838a9fSAndrew Rybchenko  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
193c838a9fSAndrew Rybchenko  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
203c838a9fSAndrew Rybchenko  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
213c838a9fSAndrew Rybchenko  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
223c838a9fSAndrew Rybchenko  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
233c838a9fSAndrew Rybchenko  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
243c838a9fSAndrew Rybchenko  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
253c838a9fSAndrew Rybchenko  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
263c838a9fSAndrew Rybchenko  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
273c838a9fSAndrew Rybchenko  *
283c838a9fSAndrew Rybchenko  * The views and conclusions contained in the software and documentation are
293c838a9fSAndrew Rybchenko  * those of the authors and should not be interpreted as representing official
303c838a9fSAndrew Rybchenko  * policies, either expressed or implied, of the FreeBSD Project.
31e948693eSPhilip Paeps  */
32e948693eSPhilip Paeps 
33e948693eSPhilip Paeps #ifndef	_SYS_SIENA_FLASH_H
34e948693eSPhilip Paeps #define	_SYS_SIENA_FLASH_H
35e948693eSPhilip Paeps 
36e948693eSPhilip Paeps #pragma pack(1)
37e948693eSPhilip Paeps 
38e948693eSPhilip Paeps /* Fixed locations near the start of flash (which may be in the internal PHY
39e948693eSPhilip Paeps  * firmware header) point to the boot header.
40e948693eSPhilip Paeps  *
41e948693eSPhilip Paeps  * - parsed by MC boot ROM and firmware
42e948693eSPhilip Paeps  * - reserved (but not parsed) by PHY firmware
43e948693eSPhilip Paeps  * - opaque to driver
44e948693eSPhilip Paeps  */
45e948693eSPhilip Paeps 
46e948693eSPhilip Paeps #define	SIENA_MC_BOOT_PHY_FW_HDR_LEN (0x20)
47e948693eSPhilip Paeps 
48e948693eSPhilip Paeps #define	SIENA_MC_BOOT_PTR_LOCATION (0x18)      /* First thing we try to boot */
49e948693eSPhilip Paeps #define	SIENA_MC_BOOT_ALT_PTR_LOCATION (0x1c)  /* Alternative if that fails */
50e948693eSPhilip Paeps 
51e948693eSPhilip Paeps #define	SIENA_MC_BOOT_HDR_LEN (0x200)
52e948693eSPhilip Paeps 
53e948693eSPhilip Paeps #define	SIENA_MC_BOOT_MAGIC (0x51E4A001)
54e948693eSPhilip Paeps #define	SIENA_MC_BOOT_VERSION (1)
55e948693eSPhilip Paeps 
563c838a9fSAndrew Rybchenko /*Structures supporting an arbitrary number of binary blobs in the flash image
573c838a9fSAndrew Rybchenko   intended to house code and tables for the satellite cpus*/
583c838a9fSAndrew Rybchenko /*thanks to random.org for:*/
593c838a9fSAndrew Rybchenko #define	BLOBS_HEADER_MAGIC (0xBDA3BBD4)
603c838a9fSAndrew Rybchenko #define	BLOB_HEADER_MAGIC  (0xA1478A91)
613c838a9fSAndrew Rybchenko 
623c838a9fSAndrew Rybchenko typedef struct blobs_hdr_s {			/* GENERATED BY scripts/genfwdef */
633c838a9fSAndrew Rybchenko 	efx_dword_t	magic;
643c838a9fSAndrew Rybchenko 	efx_dword_t	no_of_blobs;
653c838a9fSAndrew Rybchenko } blobs_hdr_t;
663c838a9fSAndrew Rybchenko 
673c838a9fSAndrew Rybchenko typedef struct blob_hdr_s {			/* GENERATED BY scripts/genfwdef */
683c838a9fSAndrew Rybchenko 	efx_dword_t	magic;
693c838a9fSAndrew Rybchenko 	efx_dword_t	cpu_type;
703c838a9fSAndrew Rybchenko 	efx_dword_t	build_variant;
713c838a9fSAndrew Rybchenko 	efx_dword_t	offset;
723c838a9fSAndrew Rybchenko 	efx_dword_t	length;
733c838a9fSAndrew Rybchenko 	efx_dword_t	checksum;
743c838a9fSAndrew Rybchenko } blob_hdr_t;
753c838a9fSAndrew Rybchenko 
763c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_TXDI_TEXT (0)
773c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_RXDI_TEXT (1)
783c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_TXDP_TEXT (2)
793c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_RXDP_TEXT (3)
803c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_RXHRSL_HR_LUT (4)
813c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_RXHRSL_HR_LUT_CFG (5)
823c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_TXHRSL_HR_LUT (6)
833c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_TXHRSL_HR_LUT_CFG (7)
843c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_RXHRSL_HR_PGM  (8)
853c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_RXHRSL_SL_PGM  (9)
863c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_TXHRSL_HR_PGM  (10)
873c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_TXHRSL_SL_PGM  (11)
883c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_RXDI_VTBL0 (12)
893c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_TXDI_VTBL0 (13)
903c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_RXDI_VTBL1 (14)
913c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_TXDI_VTBL1 (15)
923c838a9fSAndrew Rybchenko #define	BLOB_CPU_TYPE_DUMPSPEC (32)
931fa702a2SAndrew Rybchenko #define	BLOB_CPU_TYPE_MC_XIP   (33)
941fa702a2SAndrew Rybchenko 
951fa702a2SAndrew Rybchenko #define	BLOB_CPU_TYPE_INVALID (31)
961fa702a2SAndrew Rybchenko 
971fa702a2SAndrew Rybchenko /*
981fa702a2SAndrew Rybchenko  * The upper four bits of the CPU type field specify the compression
991fa702a2SAndrew Rybchenko  * algorithm used for this blob.
1001fa702a2SAndrew Rybchenko  */
1011fa702a2SAndrew Rybchenko #define	BLOB_COMPRESSION_MASK (0xf0000000)
1021fa702a2SAndrew Rybchenko #define	BLOB_CPU_TYPE_MASK    (0x0fffffff)
1031fa702a2SAndrew Rybchenko 
1041fa702a2SAndrew Rybchenko #define	BLOB_COMPRESSION_NONE (0x00000000) /* Stored as is */
1051fa702a2SAndrew Rybchenko #define	BLOB_COMPRESSION_LZ   (0x10000000) /* see lib/lzdecoder.c */
1063c838a9fSAndrew Rybchenko 
107e948693eSPhilip Paeps typedef struct siena_mc_boot_hdr_s {		/* GENERATED BY scripts/genfwdef */
108e948693eSPhilip Paeps 	efx_dword_t	magic;			/* = SIENA_MC_BOOT_MAGIC */
109e948693eSPhilip Paeps 	efx_word_t	hdr_version;		/* this structure definition is version 1 */
110e948693eSPhilip Paeps 	efx_byte_t	board_type;
111e948693eSPhilip Paeps 	efx_byte_t	firmware_version_a;
112e948693eSPhilip Paeps 	efx_byte_t	firmware_version_b;
113e948693eSPhilip Paeps 	efx_byte_t	firmware_version_c;
114e948693eSPhilip Paeps 	efx_word_t	checksum;		/* of whole header area + firmware image */
115e948693eSPhilip Paeps 	efx_word_t	firmware_version_d;
1163c838a9fSAndrew Rybchenko 	efx_byte_t	mcfw_subtype;
1174fe33ae8SAndrew Rybchenko 	efx_byte_t	generation;		/* MC (Medford and later): MC partition generation when */
1184fe33ae8SAndrew Rybchenko 						/* written to NVRAM. */
1194fe33ae8SAndrew Rybchenko 						/* MUM & SUC images: subtype. */
1204fe33ae8SAndrew Rybchenko 						/* (Otherwise set to 0) */
121e948693eSPhilip Paeps 	efx_dword_t	firmware_text_offset;	/* offset to firmware .text */
122e948693eSPhilip Paeps 	efx_dword_t	firmware_text_size;	/* length of firmware .text, in bytes */
123e948693eSPhilip Paeps 	efx_dword_t	firmware_data_offset;	/* offset to firmware .data */
124e948693eSPhilip Paeps 	efx_dword_t	firmware_data_size;	/* length of firmware .data, in bytes */
1253c838a9fSAndrew Rybchenko 	efx_byte_t	spi_rate;		/* SPI rate for reading image, 0 is BootROM default */
1263c838a9fSAndrew Rybchenko 	efx_byte_t	spi_phase_adj;		/* SPI SDO/SCL phase adjustment, 0 is default (no adj) */
1274fe33ae8SAndrew Rybchenko 	efx_word_t	xpm_sector;		/* XPM (MEDFORD and later): The sector that contains */
1284fe33ae8SAndrew Rybchenko 						/* the key, or 0xffff if unsigned. (Otherwise set to 0) */
1294fe33ae8SAndrew Rybchenko 	efx_byte_t	mumfw_subtype;		/* MUM & SUC images: subtype. (Otherwise set to 0) */
1304fe33ae8SAndrew Rybchenko 	efx_byte_t	reserved_b[3];		/* (set to 0) */
131208539a4SAndrew Rybchenko 	efx_dword_t	security_level;		/* This number increases every time a serious security flaw */
132208539a4SAndrew Rybchenko 						/* is fixed. A secure NIC may not downgrade to any image */
133208539a4SAndrew Rybchenko 						/* with a lower security level than the current image. */
134208539a4SAndrew Rybchenko 						/* Note: The number in this header should only be used for */
135208539a4SAndrew Rybchenko 						/* determining the level of new images, not to determine */
136208539a4SAndrew Rybchenko 						/* the level of the current image as this header is not */
137208539a4SAndrew Rybchenko 						/* protected by a CMAC. */
138208539a4SAndrew Rybchenko 	efx_dword_t	reserved_c[5];		/* (set to 0) */
139e948693eSPhilip Paeps } siena_mc_boot_hdr_t;
140e948693eSPhilip Paeps 
1413c838a9fSAndrew Rybchenko #define	SIENA_MC_BOOT_HDR_PADDING \
1423c838a9fSAndrew Rybchenko 	(SIENA_MC_BOOT_HDR_LEN - sizeof(siena_mc_boot_hdr_t))
1433c838a9fSAndrew Rybchenko 
144e948693eSPhilip Paeps #define	SIENA_MC_STATIC_CONFIG_MAGIC (0xBDCF5555)
145e948693eSPhilip Paeps #define	SIENA_MC_STATIC_CONFIG_VERSION (0)
146e948693eSPhilip Paeps 
147e948693eSPhilip Paeps typedef struct siena_mc_static_config_hdr_s {	/* GENERATED BY scripts/genfwdef */
148e948693eSPhilip Paeps 	efx_dword_t	magic;			/* = SIENA_MC_STATIC_CONFIG_MAGIC */
149e948693eSPhilip Paeps 	efx_word_t	length;			/* of header area (i.e. not including VPD) */
150e948693eSPhilip Paeps 	efx_byte_t	version;
151e948693eSPhilip Paeps 	efx_byte_t	csum;			/* over header area (i.e. not including VPD) */
152e948693eSPhilip Paeps 	efx_dword_t	static_vpd_offset;
153e948693eSPhilip Paeps 	efx_dword_t	static_vpd_length;
154e948693eSPhilip Paeps 	efx_dword_t	capabilities;
155e948693eSPhilip Paeps 	efx_byte_t	mac_addr_base[6];
156e948693eSPhilip Paeps 	efx_byte_t	green_mode_cal;		/* Green mode calibration result */
157e948693eSPhilip Paeps 	efx_byte_t	green_mode_valid;	/* Whether cal holds a valid value */
158e948693eSPhilip Paeps 	efx_word_t	mac_addr_count;
159e948693eSPhilip Paeps 	efx_word_t	mac_addr_stride;
1603c838a9fSAndrew Rybchenko 	efx_word_t	calibrated_vref;	/* Vref as measured during production */
1613c838a9fSAndrew Rybchenko 	efx_word_t	adc_vref;		/* Vref as read by ADC */
162d880a0b3SAndrew Rybchenko 	efx_dword_t	reserved2[1];		/* (write as zero) */
163e948693eSPhilip Paeps 	efx_dword_t	num_dbi_items;
164e948693eSPhilip Paeps 	struct {
165e948693eSPhilip Paeps 		efx_word_t	addr;
166e948693eSPhilip Paeps 		efx_word_t	byte_enables;
167e948693eSPhilip Paeps 		efx_dword_t	value;
168e948693eSPhilip Paeps 	} dbi[];
169e948693eSPhilip Paeps } siena_mc_static_config_hdr_t;
170e948693eSPhilip Paeps 
171e948693eSPhilip Paeps #define	SIENA_MC_DYNAMIC_CONFIG_MAGIC (0xBDCFDDDD)
172e948693eSPhilip Paeps #define	SIENA_MC_DYNAMIC_CONFIG_VERSION (0)
173e948693eSPhilip Paeps 
174e948693eSPhilip Paeps typedef struct siena_mc_fw_version_s {		/* GENERATED BY scripts/genfwdef */
175e948693eSPhilip Paeps 	efx_dword_t	fw_subtype;
176e948693eSPhilip Paeps 	efx_word_t	version_w;
177e948693eSPhilip Paeps 	efx_word_t	version_x;
178e948693eSPhilip Paeps 	efx_word_t	version_y;
179e948693eSPhilip Paeps 	efx_word_t	version_z;
180e948693eSPhilip Paeps } siena_mc_fw_version_t;
181e948693eSPhilip Paeps 
182e948693eSPhilip Paeps typedef struct siena_mc_dynamic_config_hdr_s {	/* GENERATED BY scripts/genfwdef */
183e948693eSPhilip Paeps 	efx_dword_t	magic;			/* = SIENA_MC_DYNAMIC_CONFIG_MAGIC */
184e948693eSPhilip Paeps 	efx_word_t	length;			/* of header area (i.e. not including VPD) */
185e948693eSPhilip Paeps 	efx_byte_t	version;
186e948693eSPhilip Paeps 	efx_byte_t	csum;			/* over header area (i.e. not including VPD) */
187e948693eSPhilip Paeps 	efx_dword_t	dynamic_vpd_offset;
188e948693eSPhilip Paeps 	efx_dword_t	dynamic_vpd_length;
189e948693eSPhilip Paeps 	efx_dword_t	num_fw_version_items;
190e948693eSPhilip Paeps 	siena_mc_fw_version_t	fw_version[];
191e948693eSPhilip Paeps } siena_mc_dynamic_config_hdr_t;
192e948693eSPhilip Paeps 
193e948693eSPhilip Paeps #define	SIENA_MC_EXPROM_SINGLE_MAGIC (0xAA55)  /* little-endian uint16_t */
194e948693eSPhilip Paeps 
195e948693eSPhilip Paeps #define	SIENA_MC_EXPROM_COMBO_MAGIC (0xB0070102)  /* little-endian uint32_t */
1963c838a9fSAndrew Rybchenko #define	SIENA_MC_EXPROM_COMBO_V2_MAGIC (0xB0070103)  /* little-endian uint32_t */
197e948693eSPhilip Paeps 
198e948693eSPhilip Paeps typedef struct siena_mc_combo_rom_hdr_s {	/* GENERATED BY scripts/genfwdef */
1993c838a9fSAndrew Rybchenko 	efx_dword_t	magic;			/* = SIENA_MC_EXPROM_COMBO_MAGIC or SIENA_MC_EXPROM_COMBO_V2_MAGIC */
2003c838a9fSAndrew Rybchenko 	union		{
2013c838a9fSAndrew Rybchenko 		struct {
202e948693eSPhilip Paeps 			efx_dword_t	len1;	/* length of first image */
203e948693eSPhilip Paeps 			efx_dword_t	len2;	/* length of second image */
204e948693eSPhilip Paeps 			efx_dword_t	off1;	/* offset of first byte to edit to combine images */
205e948693eSPhilip Paeps 			efx_dword_t	off2;	/* offset of second byte to edit to combine images */
206e948693eSPhilip Paeps 			efx_word_t	infoblk0_off;/* infoblk offset */
207e948693eSPhilip Paeps 			efx_word_t	infoblk1_off;/* infoblk offset */
2083c838a9fSAndrew Rybchenko 			efx_byte_t	infoblk_len;/* length of space reserved for one infoblk structure */
209e948693eSPhilip Paeps 			efx_byte_t	reserved[7];/* (set to 0) */
2103c838a9fSAndrew Rybchenko 		} v1;
2113c838a9fSAndrew Rybchenko 		struct {
2123c838a9fSAndrew Rybchenko 			efx_dword_t	len1;	/* length of first image */
2133c838a9fSAndrew Rybchenko 			efx_dword_t	len2;	/* length of second image */
2143c838a9fSAndrew Rybchenko 			efx_dword_t	off1;	/* offset of first byte to edit to combine images */
2153c838a9fSAndrew Rybchenko 			efx_dword_t	off2;	/* offset of second byte to edit to combine images */
2163c838a9fSAndrew Rybchenko 			efx_word_t	infoblk_off;/* infoblk start offset */
2173c838a9fSAndrew Rybchenko 			efx_word_t	infoblk_count;/* infoblk count  */
2183c838a9fSAndrew Rybchenko 			efx_byte_t	infoblk_len;/* length of space reserved for one infoblk structure */
2193c838a9fSAndrew Rybchenko 			efx_byte_t	reserved[7];/* (set to 0) */
2203c838a9fSAndrew Rybchenko 		} v2;
2213519e25dSAndrew Rybchenko 	} data;
222e948693eSPhilip Paeps } siena_mc_combo_rom_hdr_t;
223e948693eSPhilip Paeps 
224e948693eSPhilip Paeps #pragma pack()
225e948693eSPhilip Paeps 
226e948693eSPhilip Paeps #endif	/* _SYS_SIENA_FLASH_H */
227