siena_flash.h revision 331722
1119801Sbmah/*-
2119801Sbmah * Copyright (c) 2007-2016 Solarflare Communications Inc.
3119801Sbmah * All rights reserved.
4119801Sbmah *
5119801Sbmah * Redistribution and use in source and binary forms, with or without
6119801Sbmah * modification, are permitted provided that the following conditions are met:
7119801Sbmah *
8119801Sbmah * 1. Redistributions of source code must retain the above copyright notice,
9119801Sbmah *    this list of conditions and the following disclaimer.
10119801Sbmah * 2. Redistributions in binary form must reproduce the above copyright notice,
11119801Sbmah *    this list of conditions and the following disclaimer in the documentation
12119801Sbmah *    and/or other materials provided with the distribution.
13119801Sbmah *
14119801Sbmah * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15119801Sbmah * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16119801Sbmah * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17119801Sbmah * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18119801Sbmah * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19119801Sbmah * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20119801Sbmah * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21119801Sbmah * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22119801Sbmah * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23119801Sbmah * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
24119801Sbmah * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25119801Sbmah *
26133338Ssimon * The views and conclusions contained in the software and documentation are
27123058Sru * those of the authors and should not be interpreted as representing official
28119801Sbmah * policies, either expressed or implied, of the FreeBSD Project.
29119801Sbmah *
30119801Sbmah * $FreeBSD: stable/11/sys/dev/sfxge/common/siena_flash.h 331722 2018-03-29 02:50:57Z eadler $
31119801Sbmah */
32119801Sbmah
33159719Sbrueffer#ifndef	_SYS_SIENA_FLASH_H
34159719Sbrueffer#define	_SYS_SIENA_FLASH_H
35159719Sbrueffer
36159719Sbrueffer#pragma pack(1)
37159719Sbrueffer
38119801Sbmah/* Fixed locations near the start of flash (which may be in the internal PHY
39119801Sbmah * firmware header) point to the boot header.
40159719Sbrueffer *
41159719Sbrueffer * - parsed by MC boot ROM and firmware
42159719Sbrueffer * - reserved (but not parsed) by PHY firmware
43119801Sbmah * - opaque to driver
44159719Sbrueffer */
45119801Sbmah
46159719Sbrueffer#define	SIENA_MC_BOOT_PHY_FW_HDR_LEN (0x20)
47159719Sbrueffer
48159719Sbrueffer#define	SIENA_MC_BOOT_PTR_LOCATION (0x18)      /* First thing we try to boot */
49159719Sbrueffer#define	SIENA_MC_BOOT_ALT_PTR_LOCATION (0x1c)  /* Alternative if that fails */
50159719Sbrueffer
51159719Sbrueffer#define	SIENA_MC_BOOT_HDR_LEN (0x200)
52159719Sbrueffer
53159719Sbrueffer#define	SIENA_MC_BOOT_MAGIC (0x51E4A001)
54159719Sbrueffer#define	SIENA_MC_BOOT_VERSION (1)
55159719Sbrueffer
56159719Sbrueffer
57119801Sbmah/*Structures supporting an arbitrary number of binary blobs in the flash image
58119801Sbmah  intended to house code and tables for the satellite cpus*/
59119801Sbmah/*thanks to random.org for:*/
60119801Sbmah#define	BLOBS_HEADER_MAGIC (0xBDA3BBD4)
61119801Sbmah#define	BLOB_HEADER_MAGIC  (0xA1478A91)
62133336Ssimon
63133336Ssimontypedef struct blobs_hdr_s {			/* GENERATED BY scripts/genfwdef */
64133336Ssimon	efx_dword_t	magic;
65133336Ssimon	efx_dword_t	no_of_blobs;
66131802Sru} blobs_hdr_t;
67131802Sru
68119801Sbmahtypedef struct blob_hdr_s {			/* GENERATED BY scripts/genfwdef */
69119801Sbmah	efx_dword_t	magic;
70119801Sbmah	efx_dword_t	cpu_type;
71119801Sbmah	efx_dword_t	build_variant;
72119801Sbmah	efx_dword_t	offset;
73119801Sbmah	efx_dword_t	length;
74119801Sbmah	efx_dword_t	checksum;
75119801Sbmah} blob_hdr_t;
76119801Sbmah
77119801Sbmah#define	BLOB_CPU_TYPE_TXDI_TEXT (0)
78119801Sbmah#define	BLOB_CPU_TYPE_RXDI_TEXT (1)
79119801Sbmah#define	BLOB_CPU_TYPE_TXDP_TEXT (2)
80119801Sbmah#define	BLOB_CPU_TYPE_RXDP_TEXT (3)
81119801Sbmah#define	BLOB_CPU_TYPE_RXHRSL_HR_LUT (4)
82119801Sbmah#define	BLOB_CPU_TYPE_RXHRSL_HR_LUT_CFG (5)
83119801Sbmah#define	BLOB_CPU_TYPE_TXHRSL_HR_LUT (6)
84131472Sru#define	BLOB_CPU_TYPE_TXHRSL_HR_LUT_CFG (7)
85131802Sru#define	BLOB_CPU_TYPE_RXHRSL_HR_PGM  (8)
86119801Sbmah#define	BLOB_CPU_TYPE_RXHRSL_SL_PGM  (9)
87119801Sbmah#define	BLOB_CPU_TYPE_TXHRSL_HR_PGM  (10)
88131802Sru#define	BLOB_CPU_TYPE_TXHRSL_SL_PGM  (11)
89119801Sbmah#define	BLOB_CPU_TYPE_RXDI_VTBL0 (12)
90119801Sbmah#define	BLOB_CPU_TYPE_TXDI_VTBL0 (13)
91119801Sbmah#define	BLOB_CPU_TYPE_RXDI_VTBL1 (14)
92119801Sbmah#define	BLOB_CPU_TYPE_TXDI_VTBL1 (15)
93122979Snon#define	BLOB_CPU_TYPE_DUMPSPEC (32)
94122979Snon#define	BLOB_CPU_TYPE_MC_XIP   (33)
95122979Snon
96122979Snon#define	BLOB_CPU_TYPE_INVALID (31)
97122979Snon
98131802Sru/*
99131802Sru * The upper four bits of the CPU type field specify the compression
100131802Sru * algorithm used for this blob.
101122979Snon */
102122979Snon#define	BLOB_COMPRESSION_MASK (0xf0000000)
103122979Snon#define	BLOB_CPU_TYPE_MASK    (0x0fffffff)
104122979Snon
105122979Snon#define	BLOB_COMPRESSION_NONE (0x00000000) /* Stored as is */
106122979Snon#define	BLOB_COMPRESSION_LZ   (0x10000000) /* see lib/lzdecoder.c */
107122979Snon
108122979Snontypedef struct siena_mc_boot_hdr_s {		/* GENERATED BY scripts/genfwdef */
109122979Snon	efx_dword_t	magic;			/* = SIENA_MC_BOOT_MAGIC */
110122979Snon	efx_word_t	hdr_version;		/* this structure definition is version 1 */
111	efx_byte_t	board_type;
112	efx_byte_t	firmware_version_a;
113	efx_byte_t	firmware_version_b;
114	efx_byte_t	firmware_version_c;
115	efx_word_t	checksum;		/* of whole header area + firmware image */
116	efx_word_t	firmware_version_d;
117	efx_byte_t	mcfw_subtype;
118	efx_byte_t	generation;		/* Valid for medford, SBZ for earlier chips */
119	efx_dword_t	firmware_text_offset;	/* offset to firmware .text */
120	efx_dword_t	firmware_text_size;	/* length of firmware .text, in bytes */
121	efx_dword_t	firmware_data_offset;	/* offset to firmware .data */
122	efx_dword_t	firmware_data_size;	/* length of firmware .data, in bytes */
123	efx_byte_t	spi_rate;		/* SPI rate for reading image, 0 is BootROM default */
124	efx_byte_t	spi_phase_adj;		/* SPI SDO/SCL phase adjustment, 0 is default (no adj) */
125	efx_word_t	xpm_sector;		/* The sector that contains the key, or 0xffff if unsigned (medford) SBZ (earlier) */
126	efx_dword_t	reserved_c[7];		/* (set to 0) */
127} siena_mc_boot_hdr_t;
128
129#define	SIENA_MC_BOOT_HDR_PADDING \
130	(SIENA_MC_BOOT_HDR_LEN - sizeof(siena_mc_boot_hdr_t))
131
132#define	SIENA_MC_STATIC_CONFIG_MAGIC (0xBDCF5555)
133#define	SIENA_MC_STATIC_CONFIG_VERSION (0)
134
135typedef struct siena_mc_static_config_hdr_s {	/* GENERATED BY scripts/genfwdef */
136	efx_dword_t	magic;			/* = SIENA_MC_STATIC_CONFIG_MAGIC */
137	efx_word_t	length;			/* of header area (i.e. not including VPD) */
138	efx_byte_t	version;
139	efx_byte_t	csum;			/* over header area (i.e. not including VPD) */
140	efx_dword_t	static_vpd_offset;
141	efx_dword_t	static_vpd_length;
142	efx_dword_t	capabilities;
143	efx_byte_t	mac_addr_base[6];
144	efx_byte_t	green_mode_cal;		/* Green mode calibration result */
145	efx_byte_t	green_mode_valid;	/* Whether cal holds a valid value */
146	efx_word_t	mac_addr_count;
147	efx_word_t	mac_addr_stride;
148	efx_word_t	calibrated_vref;	/* Vref as measured during production */
149	efx_word_t	adc_vref;		/* Vref as read by ADC */
150	efx_dword_t	reserved2[1];		/* (write as zero) */
151	efx_dword_t	num_dbi_items;
152	struct {
153		efx_word_t	addr;
154		efx_word_t	byte_enables;
155		efx_dword_t	value;
156	} dbi[];
157} siena_mc_static_config_hdr_t;
158
159#define	SIENA_MC_DYNAMIC_CONFIG_MAGIC (0xBDCFDDDD)
160#define	SIENA_MC_DYNAMIC_CONFIG_VERSION (0)
161
162typedef struct siena_mc_fw_version_s {		/* GENERATED BY scripts/genfwdef */
163	efx_dword_t	fw_subtype;
164	efx_word_t	version_w;
165	efx_word_t	version_x;
166	efx_word_t	version_y;
167	efx_word_t	version_z;
168} siena_mc_fw_version_t;
169
170typedef struct siena_mc_dynamic_config_hdr_s {	/* GENERATED BY scripts/genfwdef */
171	efx_dword_t	magic;			/* = SIENA_MC_DYNAMIC_CONFIG_MAGIC */
172	efx_word_t	length;			/* of header area (i.e. not including VPD) */
173	efx_byte_t	version;
174	efx_byte_t	csum;			/* over header area (i.e. not including VPD) */
175	efx_dword_t	dynamic_vpd_offset;
176	efx_dword_t	dynamic_vpd_length;
177	efx_dword_t	num_fw_version_items;
178	siena_mc_fw_version_t	fw_version[];
179} siena_mc_dynamic_config_hdr_t;
180
181#define	SIENA_MC_EXPROM_SINGLE_MAGIC (0xAA55)  /* little-endian uint16_t */
182
183#define	SIENA_MC_EXPROM_COMBO_MAGIC (0xB0070102)  /* little-endian uint32_t */
184#define	SIENA_MC_EXPROM_COMBO_V2_MAGIC (0xB0070103)  /* little-endian uint32_t */
185
186typedef struct siena_mc_combo_rom_hdr_s {	/* GENERATED BY scripts/genfwdef */
187	efx_dword_t	magic;			/* = SIENA_MC_EXPROM_COMBO_MAGIC or SIENA_MC_EXPROM_COMBO_V2_MAGIC */
188	union		{
189		struct {
190			efx_dword_t	len1;	/* length of first image */
191			efx_dword_t	len2;	/* length of second image */
192			efx_dword_t	off1;	/* offset of first byte to edit to combine images */
193			efx_dword_t	off2;	/* offset of second byte to edit to combine images */
194			efx_word_t	infoblk0_off;/* infoblk offset */
195			efx_word_t	infoblk1_off;/* infoblk offset */
196			efx_byte_t	infoblk_len;/* length of space reserved for one infoblk structure */
197			efx_byte_t	reserved[7];/* (set to 0) */
198		} v1;
199		struct {
200			efx_dword_t	len1;	/* length of first image */
201			efx_dword_t	len2;	/* length of second image */
202			efx_dword_t	off1;	/* offset of first byte to edit to combine images */
203			efx_dword_t	off2;	/* offset of second byte to edit to combine images */
204			efx_word_t	infoblk_off;/* infoblk start offset */
205			efx_word_t	infoblk_count;/* infoblk count  */
206			efx_byte_t	infoblk_len;/* length of space reserved for one infoblk structure */
207			efx_byte_t	reserved[7];/* (set to 0) */
208		} v2;
209	} data;
210} siena_mc_combo_rom_hdr_t;
211
212#pragma pack()
213
214#endif	/* _SYS_SIENA_FLASH_H */
215