2 * Copyright (c) 2014,2016 Qualcomm Atheros, Inc.
3 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #define WIL_FW_SIGNATURE (0x36323130) /* '0126' */
19 #define WIL_FW_FMT_VERSION (1) /* format version driver supports */
21 enum wil_fw_record_type
{
22 wil_fw_type_comment
= 1,
25 wil_fw_type_action
= 4,
26 wil_fw_type_verify
= 5,
27 wil_fw_type_file_header
= 6,
28 wil_fw_type_direct_write
= 7,
29 wil_fw_type_gateway_data
= 8,
30 wil_fw_type_gateway_data4
= 9,
33 struct wil_fw_record_head
{
34 __le16 type
; /* enum wil_fw_record_type */
35 __le16 flags
; /* to be defined */
36 __le32 size
; /* whole record, bytes after head */
39 /* data block. write starting from @addr
40 * data_size inferred from the @head.size. For this case,
41 * data_size = @head.size - offsetof(struct wil_fw_record_data, data)
43 struct wil_fw_record_data
{ /* type == wil_fw_type_data */
45 __le32 data
[0]; /* [data_size], see above */
48 /* fill with constant @value, @size bytes starting from @addr */
49 struct wil_fw_record_fill
{ /* type == wil_fw_type_fill */
56 * for informational purpose, data_size is @head.size from record header
58 struct wil_fw_record_comment
{ /* type == wil_fw_type_comment */
59 u8 data
[0]; /* free-form data [data_size], see above */
62 /* Comment header - common for all comment record types */
63 struct wil_fw_record_comment_hdr
{
67 /* FW capabilities encoded inside a comment record */
68 #define WIL_FW_CAPABILITIES_MAGIC (0xabcddcba)
69 struct wil_fw_record_capabilities
{ /* type == wil_fw_type_comment */
70 /* identifies capabilities record */
71 struct wil_fw_record_comment_hdr hdr
;
72 /* capabilities (variable size), see enum wmi_fw_capability */
76 /* brd file info encoded inside a comment record */
77 #define WIL_BRD_FILE_MAGIC (0xabcddcbb)
78 struct wil_fw_record_brd_file
{ /* type == wil_fw_type_comment */
79 /* identifies brd file record */
80 struct wil_fw_record_comment_hdr hdr
;
83 __le32 max_size_bytes
;
87 * data_size = @head.size - offsetof(struct wil_fw_record_action, data)
89 struct wil_fw_record_action
{ /* type == wil_fw_type_action */
90 __le32 action
; /* action to perform: reset, wait for fw ready etc. */
91 __le32 data
[0]; /* action specific, [data_size], see above */
94 /* data block for struct wil_fw_record_direct_write */
95 struct wil_fw_data_dwrite
{
101 /* write @value to the @addr,
102 * preserve original bits accordingly to the @mask
103 * data_size is @head.size where @head is record header
105 struct wil_fw_record_direct_write
{ /* type == wil_fw_type_direct_write */
106 struct wil_fw_data_dwrite data
[0];
109 /* verify condition: [@addr] & @mask == @value
110 * if condition not met, firmware download fails
112 struct wil_fw_record_verify
{ /* type == wil_fw_verify */
113 __le32 addr
; /* read from this address */
114 __le32 value
; /* reference value */
115 __le32 mask
; /* mask for verification */
119 * First record of every file
121 /* the FW version prefix in the comment */
122 #define WIL_FW_VERSION_PREFIX "FW version: "
123 #define WIL_FW_VERSION_PREFIX_LEN (sizeof(WIL_FW_VERSION_PREFIX) - 1)
124 struct wil_fw_record_file_header
{
125 __le32 signature
; /* Wilocity signature */
127 __le32 crc
; /* crc32 of the following data */
128 __le32 version
; /* format version */
129 __le32 data_len
; /* total data in file, including this record */
130 u8 comment
[32]; /* short description */
133 /* 1-dword gateway */
134 /* data block for the struct wil_fw_record_gateway_data */
135 struct wil_fw_data_gw
{
140 /* gateway write block.
141 * write starting address and values from the data buffer
142 * through the gateway
143 * data_size inferred from the @head.size. For this case,
144 * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data, data)
146 struct wil_fw_record_gateway_data
{ /* type == wil_fw_type_gateway_data */
147 __le32 gateway_addr_addr
;
148 __le32 gateway_value_addr
;
149 __le32 gateway_cmd_addr
;
150 __le32 gateway_ctrl_address
;
151 #define WIL_FW_GW_CTL_BUSY BIT(29) /* gateway busy performing operation */
152 #define WIL_FW_GW_CTL_RUN BIT(30) /* start gateway operation */
154 struct wil_fw_data_gw data
[0]; /* total size [data_size], see above */
157 /* 4-dword gateway */
158 /* data block for the struct wil_fw_record_gateway_data4 */
159 struct wil_fw_data_gw4
{
164 /* gateway write block.
165 * write starting address and values from the data buffer
166 * through the gateway
167 * data_size inferred from the @head.size. For this case,
168 * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data4, data)
170 struct wil_fw_record_gateway_data4
{ /* type == wil_fw_type_gateway_data4 */
171 __le32 gateway_addr_addr
;
172 __le32 gateway_value_addr
[4];
173 __le32 gateway_cmd_addr
;
174 __le32 gateway_ctrl_address
; /* same logic as for 1-dword gw */
176 struct wil_fw_data_gw4 data
[0]; /* total size [data_size], see above */