New upstream version 18.02
[deb_dpdk.git] / drivers / net / sfc / base / siena_flash.h
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright (c) 2007-2018 Solarflare Communications Inc.
4  * All rights reserved.
5  */
6
7 #ifndef _SYS_SIENA_FLASH_H
8 #define _SYS_SIENA_FLASH_H
9
10 #pragma pack(1)
11
12 /* Fixed locations near the start of flash (which may be in the internal PHY
13  * firmware header) point to the boot header.
14  *
15  * - parsed by MC boot ROM and firmware
16  * - reserved (but not parsed) by PHY firmware
17  * - opaque to driver
18  */
19
20 #define SIENA_MC_BOOT_PHY_FW_HDR_LEN (0x20)
21
22 #define SIENA_MC_BOOT_PTR_LOCATION (0x18)      /* First thing we try to boot */
23 #define SIENA_MC_BOOT_ALT_PTR_LOCATION (0x1c)  /* Alternative if that fails */
24
25 #define SIENA_MC_BOOT_HDR_LEN (0x200)
26
27 #define SIENA_MC_BOOT_MAGIC (0x51E4A001)
28 #define SIENA_MC_BOOT_VERSION (1)
29
30
31 /*Structures supporting an arbitrary number of binary blobs in the flash image
32   intended to house code and tables for the satellite cpus*/
33 /*thanks to random.org for:*/
34 #define BLOBS_HEADER_MAGIC (0xBDA3BBD4)
35 #define BLOB_HEADER_MAGIC  (0xA1478A91)
36
37 typedef struct blobs_hdr_s {                    /* GENERATED BY scripts/genfwdef */
38         efx_dword_t     magic;
39         efx_dword_t     no_of_blobs;
40 } blobs_hdr_t;
41
42 typedef struct blob_hdr_s {                     /* GENERATED BY scripts/genfwdef */
43         efx_dword_t     magic;
44         efx_dword_t     cpu_type;
45         efx_dword_t     build_variant;
46         efx_dword_t     offset;
47         efx_dword_t     length;
48         efx_dword_t     checksum;
49 } blob_hdr_t;
50
51 #define BLOB_CPU_TYPE_TXDI_TEXT (0)
52 #define BLOB_CPU_TYPE_RXDI_TEXT (1)
53 #define BLOB_CPU_TYPE_TXDP_TEXT (2)
54 #define BLOB_CPU_TYPE_RXDP_TEXT (3)
55 #define BLOB_CPU_TYPE_RXHRSL_HR_LUT (4)
56 #define BLOB_CPU_TYPE_RXHRSL_HR_LUT_CFG (5)
57 #define BLOB_CPU_TYPE_TXHRSL_HR_LUT (6)
58 #define BLOB_CPU_TYPE_TXHRSL_HR_LUT_CFG (7)
59 #define BLOB_CPU_TYPE_RXHRSL_HR_PGM  (8)
60 #define BLOB_CPU_TYPE_RXHRSL_SL_PGM  (9)
61 #define BLOB_CPU_TYPE_TXHRSL_HR_PGM  (10)
62 #define BLOB_CPU_TYPE_TXHRSL_SL_PGM  (11)
63 #define BLOB_CPU_TYPE_RXDI_VTBL0 (12)
64 #define BLOB_CPU_TYPE_TXDI_VTBL0 (13)
65 #define BLOB_CPU_TYPE_RXDI_VTBL1 (14)
66 #define BLOB_CPU_TYPE_TXDI_VTBL1 (15)
67 #define BLOB_CPU_TYPE_DUMPSPEC (32)
68 #define BLOB_CPU_TYPE_MC_XIP   (33)
69
70 #define BLOB_CPU_TYPE_INVALID (31)
71
72 /*
73  * The upper four bits of the CPU type field specify the compression
74  * algorithm used for this blob.
75  */
76 #define BLOB_COMPRESSION_MASK (0xf0000000)
77 #define BLOB_CPU_TYPE_MASK    (0x0fffffff)
78
79 #define BLOB_COMPRESSION_NONE (0x00000000) /* Stored as is */
80 #define BLOB_COMPRESSION_LZ   (0x10000000) /* see lib/lzdecoder.c */
81
82 typedef struct siena_mc_boot_hdr_s {            /* GENERATED BY scripts/genfwdef */
83         efx_dword_t     magic;                  /* = SIENA_MC_BOOT_MAGIC */
84         efx_word_t      hdr_version;            /* this structure definition is version 1 */
85         efx_byte_t      board_type;
86         efx_byte_t      firmware_version_a;
87         efx_byte_t      firmware_version_b;
88         efx_byte_t      firmware_version_c;
89         efx_word_t      checksum;               /* of whole header area + firmware image */
90         efx_word_t      firmware_version_d;
91         efx_byte_t      mcfw_subtype;
92         efx_byte_t      generation;             /* MC (Medford and later): MC partition generation when */
93                                                 /* written to NVRAM. */
94                                                 /* MUM & SUC images: subtype. */
95                                                 /* (Otherwise set to 0) */
96         efx_dword_t     firmware_text_offset;   /* offset to firmware .text */
97         efx_dword_t     firmware_text_size;     /* length of firmware .text, in bytes */
98         efx_dword_t     firmware_data_offset;   /* offset to firmware .data */
99         efx_dword_t     firmware_data_size;     /* length of firmware .data, in bytes */
100         efx_byte_t      spi_rate;               /* SPI rate for reading image, 0 is BootROM default */
101         efx_byte_t      spi_phase_adj;          /* SPI SDO/SCL phase adjustment, 0 is default (no adj) */
102         efx_word_t      xpm_sector;             /* XPM (MEDFORD and later): The sector that contains */
103                                                 /* the key, or 0xffff if unsigned. (Otherwise set to 0) */
104         efx_byte_t      mumfw_subtype;          /* MUM & SUC images: subtype. (Otherwise set to 0) */
105         efx_byte_t      reserved_b[3];          /* (set to 0) */
106         efx_dword_t     reserved_c[6];          /* (set to 0) */
107 } siena_mc_boot_hdr_t;
108
109 #define SIENA_MC_BOOT_HDR_PADDING \
110         (SIENA_MC_BOOT_HDR_LEN - sizeof(siena_mc_boot_hdr_t))
111
112 #define SIENA_MC_STATIC_CONFIG_MAGIC (0xBDCF5555)
113 #define SIENA_MC_STATIC_CONFIG_VERSION (0)
114
115 typedef struct siena_mc_static_config_hdr_s {   /* GENERATED BY scripts/genfwdef */
116         efx_dword_t     magic;                  /* = SIENA_MC_STATIC_CONFIG_MAGIC */
117         efx_word_t      length;                 /* of header area (i.e. not including VPD) */
118         efx_byte_t      version;
119         efx_byte_t      csum;                   /* over header area (i.e. not including VPD) */
120         efx_dword_t     static_vpd_offset;
121         efx_dword_t     static_vpd_length;
122         efx_dword_t     capabilities;
123         efx_byte_t      mac_addr_base[6];
124         efx_byte_t      green_mode_cal;         /* Green mode calibration result */
125         efx_byte_t      green_mode_valid;       /* Whether cal holds a valid value */
126         efx_word_t      mac_addr_count;
127         efx_word_t      mac_addr_stride;
128         efx_word_t      calibrated_vref;        /* Vref as measured during production */
129         efx_word_t      adc_vref;               /* Vref as read by ADC */
130         efx_dword_t     reserved2[1];           /* (write as zero) */
131         efx_dword_t     num_dbi_items;
132         struct {
133                 efx_word_t      addr;
134                 efx_word_t      byte_enables;
135                 efx_dword_t     value;
136         } dbi[];
137 } siena_mc_static_config_hdr_t;
138
139 /* This prefixes a valid XIP partition */
140 #define XIP_PARTITION_MAGIC (0x51DEC0DE)
141
142 #define SIENA_MC_DYNAMIC_CONFIG_MAGIC (0xBDCFDDDD)
143 #define SIENA_MC_DYNAMIC_CONFIG_VERSION (0)
144
145 typedef struct siena_mc_fw_version_s {          /* GENERATED BY scripts/genfwdef */
146         efx_dword_t     fw_subtype;
147         efx_word_t      version_w;
148         efx_word_t      version_x;
149         efx_word_t      version_y;
150         efx_word_t      version_z;
151 } siena_mc_fw_version_t;
152
153 typedef struct siena_mc_dynamic_config_hdr_s {  /* GENERATED BY scripts/genfwdef */
154         efx_dword_t     magic;                  /* = SIENA_MC_DYNAMIC_CONFIG_MAGIC */
155         efx_word_t      length;                 /* of header area (i.e. not including VPD) */
156         efx_byte_t      version;
157         efx_byte_t      csum;                   /* over header area (i.e. not including VPD) */
158         efx_dword_t     dynamic_vpd_offset;
159         efx_dword_t     dynamic_vpd_length;
160         efx_dword_t     num_fw_version_items;
161         siena_mc_fw_version_t   fw_version[];
162 } siena_mc_dynamic_config_hdr_t;
163
164 #define SIENA_MC_EXPROM_SINGLE_MAGIC (0xAA55)  /* little-endian uint16_t */
165
166 #define SIENA_MC_EXPROM_COMBO_MAGIC (0xB0070102)  /* little-endian uint32_t */
167 #define SIENA_MC_EXPROM_COMBO_V2_MAGIC (0xB0070103)  /* little-endian uint32_t */
168
169 typedef struct siena_mc_combo_rom_hdr_s {       /* GENERATED BY scripts/genfwdef */
170         efx_dword_t     magic;                  /* = SIENA_MC_EXPROM_COMBO_MAGIC or SIENA_MC_EXPROM_COMBO_V2_MAGIC */
171         union           {
172                 struct {
173                         efx_dword_t     len1;   /* length of first image */
174                         efx_dword_t     len2;   /* length of second image */
175                         efx_dword_t     off1;   /* offset of first byte to edit to combine images */
176                         efx_dword_t     off2;   /* offset of second byte to edit to combine images */
177                         efx_word_t      infoblk0_off;/* infoblk offset */
178                         efx_word_t      infoblk1_off;/* infoblk offset */
179                         efx_byte_t      infoblk_len;/* length of space reserved for one infoblk structure */
180                         efx_byte_t      reserved[7];/* (set to 0) */
181                 } v1;
182                 struct {
183                         efx_dword_t     len1;   /* length of first image */
184                         efx_dword_t     len2;   /* length of second image */
185                         efx_dword_t     off1;   /* offset of first byte to edit to combine images */
186                         efx_dword_t     off2;   /* offset of second byte to edit to combine images */
187                         efx_word_t      infoblk_off;/* infoblk start offset */
188                         efx_word_t      infoblk_count;/* infoblk count  */
189                         efx_byte_t      infoblk_len;/* length of space reserved for one infoblk structure */
190                         efx_byte_t      reserved[7];/* (set to 0) */
191                 } v2;
192         } data;
193 } siena_mc_combo_rom_hdr_t;
194
195 #pragma pack()
196
197 #endif  /* _SYS_SIENA_FLASH_H */