Loading...
1/* SPDX-License-Identifier: ISC */
2/*
3 * Copyright (c) 2014,2016 Qualcomm Atheros, Inc.
4 * Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
5 */
6#ifndef __WIL_FW_H__
7#define __WIL_FW_H__
8
9#define WIL_FW_SIGNATURE (0x36323130) /* '0126' */
10#define WIL_FW_FMT_VERSION (1) /* format version driver supports */
11
12enum wil_fw_record_type {
13 wil_fw_type_comment = 1,
14 wil_fw_type_data = 2,
15 wil_fw_type_fill = 3,
16 wil_fw_type_action = 4,
17 wil_fw_type_verify = 5,
18 wil_fw_type_file_header = 6,
19 wil_fw_type_direct_write = 7,
20 wil_fw_type_gateway_data = 8,
21 wil_fw_type_gateway_data4 = 9,
22};
23
24struct wil_fw_record_head {
25 __le16 type; /* enum wil_fw_record_type */
26 __le16 flags; /* to be defined */
27 __le32 size; /* whole record, bytes after head */
28} __packed;
29
30/* data block. write starting from @addr
31 * data_size inferred from the @head.size. For this case,
32 * data_size = @head.size - offsetof(struct wil_fw_record_data, data)
33 */
34struct wil_fw_record_data { /* type == wil_fw_type_data */
35 __le32 addr;
36 __le32 data[]; /* [data_size], see above */
37} __packed;
38
39/* fill with constant @value, @size bytes starting from @addr */
40struct wil_fw_record_fill { /* type == wil_fw_type_fill */
41 __le32 addr;
42 __le32 value;
43 __le32 size;
44} __packed;
45
46/* free-form comment
47 * for informational purpose, data_size is @head.size from record header
48 */
49struct wil_fw_record_comment { /* type == wil_fw_type_comment */
50 DECLARE_FLEX_ARRAY(u8, data); /* free-form data [data_size], see above */
51} __packed;
52
53/* Comment header - common for all comment record types */
54struct wil_fw_record_comment_hdr {
55 __le32 magic;
56};
57
58/* FW capabilities encoded inside a comment record */
59#define WIL_FW_CAPABILITIES_MAGIC (0xabcddcba)
60struct wil_fw_record_capabilities { /* type == wil_fw_type_comment */
61 /* identifies capabilities record */
62 struct wil_fw_record_comment_hdr hdr;
63 /* capabilities (variable size), see enum wmi_fw_capability */
64 u8 capabilities[];
65} __packed;
66
67/* FW VIF concurrency encoded inside a comment record
68 * Format is similar to wiphy->iface_combinations
69 */
70#define WIL_FW_CONCURRENCY_MAGIC (0xfedccdef)
71#define WIL_FW_CONCURRENCY_REC_VER 1
72struct wil_fw_concurrency_limit {
73 __le16 max; /* maximum number of interfaces of these types */
74 __le16 types; /* interface types (bit mask of enum nl80211_iftype) */
75} __packed;
76
77struct wil_fw_concurrency_combo {
78 u8 n_limits; /* number of wil_fw_concurrency_limit entries */
79 u8 max_interfaces; /* max number of concurrent interfaces allowed */
80 u8 n_diff_channels; /* total number of different channels allowed */
81 u8 same_bi; /* for APs, 1 if all APs must have same BI */
82 /* keep last - concurrency limits, variable size by n_limits */
83 struct wil_fw_concurrency_limit limits[];
84} __packed;
85
86struct wil_fw_record_concurrency { /* type == wil_fw_type_comment */
87 /* identifies concurrency record */
88 __le32 magic;
89 /* structure version, currently always 1 */
90 u8 version;
91 /* maximum number of supported MIDs _in addition_ to MID 0 */
92 u8 n_mids;
93 /* number of concurrency combinations that follow */
94 __le16 n_combos;
95 /* keep last - combinations, variable size by n_combos */
96 struct wil_fw_concurrency_combo combos[];
97} __packed;
98
99/* brd file info encoded inside a comment record */
100#define WIL_BRD_FILE_MAGIC (0xabcddcbb)
101
102struct brd_info {
103 __le32 base_addr;
104 __le32 max_size_bytes;
105} __packed;
106
107struct wil_fw_record_brd_file { /* type == wil_fw_type_comment */
108 /* identifies brd file record */
109 struct wil_fw_record_comment_hdr hdr;
110 __le32 version;
111 struct brd_info brd_info[];
112} __packed;
113
114/* perform action
115 * data_size = @head.size - offsetof(struct wil_fw_record_action, data)
116 */
117struct wil_fw_record_action { /* type == wil_fw_type_action */
118 __le32 action; /* action to perform: reset, wait for fw ready etc. */
119 __le32 data[]; /* action specific, [data_size], see above */
120} __packed;
121
122/* data block for struct wil_fw_record_direct_write */
123struct wil_fw_data_dwrite {
124 __le32 addr;
125 __le32 value;
126 __le32 mask;
127} __packed;
128
129/* write @value to the @addr,
130 * preserve original bits accordingly to the @mask
131 * data_size is @head.size where @head is record header
132 */
133struct wil_fw_record_direct_write { /* type == wil_fw_type_direct_write */
134 DECLARE_FLEX_ARRAY(struct wil_fw_data_dwrite, data);
135} __packed;
136
137/* verify condition: [@addr] & @mask == @value
138 * if condition not met, firmware download fails
139 */
140struct wil_fw_record_verify { /* type == wil_fw_verify */
141 __le32 addr; /* read from this address */
142 __le32 value; /* reference value */
143 __le32 mask; /* mask for verification */
144} __packed;
145
146/* file header
147 * First record of every file
148 */
149/* the FW version prefix in the comment */
150#define WIL_FW_VERSION_PREFIX "FW version: "
151#define WIL_FW_VERSION_PREFIX_LEN (sizeof(WIL_FW_VERSION_PREFIX) - 1)
152struct wil_fw_record_file_header {
153 __le32 signature ; /* Wilocity signature */
154 __le32 reserved;
155 __le32 crc; /* crc32 of the following data */
156 __le32 version; /* format version */
157 __le32 data_len; /* total data in file, including this record */
158 u8 comment[32]; /* short description */
159} __packed;
160
161/* 1-dword gateway */
162/* data block for the struct wil_fw_record_gateway_data */
163struct wil_fw_data_gw {
164 __le32 addr;
165 __le32 value;
166} __packed;
167
168/* gateway write block.
169 * write starting address and values from the data buffer
170 * through the gateway
171 * data_size inferred from the @head.size. For this case,
172 * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data, data)
173 */
174struct wil_fw_record_gateway_data { /* type == wil_fw_type_gateway_data */
175 __le32 gateway_addr_addr;
176 __le32 gateway_value_addr;
177 __le32 gateway_cmd_addr;
178 __le32 gateway_ctrl_address;
179#define WIL_FW_GW_CTL_BUSY BIT(29) /* gateway busy performing operation */
180#define WIL_FW_GW_CTL_RUN BIT(30) /* start gateway operation */
181 __le32 command;
182 struct wil_fw_data_gw data[]; /* total size [data_size], see above */
183} __packed;
184
185/* 4-dword gateway */
186/* data block for the struct wil_fw_record_gateway_data4 */
187struct wil_fw_data_gw4 {
188 __le32 addr;
189 __le32 value[4];
190} __packed;
191
192/* gateway write block.
193 * write starting address and values from the data buffer
194 * through the gateway
195 * data_size inferred from the @head.size. For this case,
196 * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data4, data)
197 */
198struct wil_fw_record_gateway_data4 { /* type == wil_fw_type_gateway_data4 */
199 __le32 gateway_addr_addr;
200 __le32 gateway_value_addr[4];
201 __le32 gateway_cmd_addr;
202 __le32 gateway_ctrl_address; /* same logic as for 1-dword gw */
203 __le32 command;
204 struct wil_fw_data_gw4 data[]; /* total size [data_size], see above */
205} __packed;
206
207#endif /* __WIL_FW_H__ */
1/*
2 * Copyright (c) 2014,2016 Qualcomm Atheros, Inc.
3 * Copyright (c) 2018, The Linux Foundation. All rights reserved.
4 *
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.
8 *
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.
16 */
17#ifndef __WIL_FW_H__
18#define __WIL_FW_H__
19
20#define WIL_FW_SIGNATURE (0x36323130) /* '0126' */
21#define WIL_FW_FMT_VERSION (1) /* format version driver supports */
22
23enum wil_fw_record_type {
24 wil_fw_type_comment = 1,
25 wil_fw_type_data = 2,
26 wil_fw_type_fill = 3,
27 wil_fw_type_action = 4,
28 wil_fw_type_verify = 5,
29 wil_fw_type_file_header = 6,
30 wil_fw_type_direct_write = 7,
31 wil_fw_type_gateway_data = 8,
32 wil_fw_type_gateway_data4 = 9,
33};
34
35struct wil_fw_record_head {
36 __le16 type; /* enum wil_fw_record_type */
37 __le16 flags; /* to be defined */
38 __le32 size; /* whole record, bytes after head */
39} __packed;
40
41/* data block. write starting from @addr
42 * data_size inferred from the @head.size. For this case,
43 * data_size = @head.size - offsetof(struct wil_fw_record_data, data)
44 */
45struct wil_fw_record_data { /* type == wil_fw_type_data */
46 __le32 addr;
47 __le32 data[0]; /* [data_size], see above */
48} __packed;
49
50/* fill with constant @value, @size bytes starting from @addr */
51struct wil_fw_record_fill { /* type == wil_fw_type_fill */
52 __le32 addr;
53 __le32 value;
54 __le32 size;
55} __packed;
56
57/* free-form comment
58 * for informational purpose, data_size is @head.size from record header
59 */
60struct wil_fw_record_comment { /* type == wil_fw_type_comment */
61 u8 data[0]; /* free-form data [data_size], see above */
62} __packed;
63
64/* Comment header - common for all comment record types */
65struct wil_fw_record_comment_hdr {
66 __le32 magic;
67};
68
69/* FW capabilities encoded inside a comment record */
70#define WIL_FW_CAPABILITIES_MAGIC (0xabcddcba)
71struct wil_fw_record_capabilities { /* type == wil_fw_type_comment */
72 /* identifies capabilities record */
73 struct wil_fw_record_comment_hdr hdr;
74 /* capabilities (variable size), see enum wmi_fw_capability */
75 u8 capabilities[0];
76} __packed;
77
78/* FW VIF concurrency encoded inside a comment record
79 * Format is similar to wiphy->iface_combinations
80 */
81#define WIL_FW_CONCURRENCY_MAGIC (0xfedccdef)
82#define WIL_FW_CONCURRENCY_REC_VER 1
83struct wil_fw_concurrency_limit {
84 __le16 max; /* maximum number of interfaces of these types */
85 __le16 types; /* interface types (bit mask of enum nl80211_iftype) */
86} __packed;
87
88struct wil_fw_concurrency_combo {
89 u8 n_limits; /* number of wil_fw_concurrency_limit entries */
90 u8 max_interfaces; /* max number of concurrent interfaces allowed */
91 u8 n_diff_channels; /* total number of different channels allowed */
92 u8 same_bi; /* for APs, 1 if all APs must have same BI */
93 /* keep last - concurrency limits, variable size by n_limits */
94 struct wil_fw_concurrency_limit limits[0];
95} __packed;
96
97struct wil_fw_record_concurrency { /* type == wil_fw_type_comment */
98 /* identifies concurrency record */
99 __le32 magic;
100 /* structure version, currently always 1 */
101 u8 version;
102 /* maximum number of supported MIDs _in addition_ to MID 0 */
103 u8 n_mids;
104 /* number of concurrency combinations that follow */
105 __le16 n_combos;
106 /* keep last - combinations, variable size by n_combos */
107 struct wil_fw_concurrency_combo combos[0];
108} __packed;
109
110/* brd file info encoded inside a comment record */
111#define WIL_BRD_FILE_MAGIC (0xabcddcbb)
112struct wil_fw_record_brd_file { /* type == wil_fw_type_comment */
113 /* identifies brd file record */
114 struct wil_fw_record_comment_hdr hdr;
115 __le32 version;
116 __le32 base_addr;
117 __le32 max_size_bytes;
118} __packed;
119
120/* perform action
121 * data_size = @head.size - offsetof(struct wil_fw_record_action, data)
122 */
123struct wil_fw_record_action { /* type == wil_fw_type_action */
124 __le32 action; /* action to perform: reset, wait for fw ready etc. */
125 __le32 data[0]; /* action specific, [data_size], see above */
126} __packed;
127
128/* data block for struct wil_fw_record_direct_write */
129struct wil_fw_data_dwrite {
130 __le32 addr;
131 __le32 value;
132 __le32 mask;
133} __packed;
134
135/* write @value to the @addr,
136 * preserve original bits accordingly to the @mask
137 * data_size is @head.size where @head is record header
138 */
139struct wil_fw_record_direct_write { /* type == wil_fw_type_direct_write */
140 struct wil_fw_data_dwrite data[0];
141} __packed;
142
143/* verify condition: [@addr] & @mask == @value
144 * if condition not met, firmware download fails
145 */
146struct wil_fw_record_verify { /* type == wil_fw_verify */
147 __le32 addr; /* read from this address */
148 __le32 value; /* reference value */
149 __le32 mask; /* mask for verification */
150} __packed;
151
152/* file header
153 * First record of every file
154 */
155/* the FW version prefix in the comment */
156#define WIL_FW_VERSION_PREFIX "FW version: "
157#define WIL_FW_VERSION_PREFIX_LEN (sizeof(WIL_FW_VERSION_PREFIX) - 1)
158struct wil_fw_record_file_header {
159 __le32 signature ; /* Wilocity signature */
160 __le32 reserved;
161 __le32 crc; /* crc32 of the following data */
162 __le32 version; /* format version */
163 __le32 data_len; /* total data in file, including this record */
164 u8 comment[32]; /* short description */
165} __packed;
166
167/* 1-dword gateway */
168/* data block for the struct wil_fw_record_gateway_data */
169struct wil_fw_data_gw {
170 __le32 addr;
171 __le32 value;
172} __packed;
173
174/* gateway write block.
175 * write starting address and values from the data buffer
176 * through the gateway
177 * data_size inferred from the @head.size. For this case,
178 * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data, data)
179 */
180struct wil_fw_record_gateway_data { /* type == wil_fw_type_gateway_data */
181 __le32 gateway_addr_addr;
182 __le32 gateway_value_addr;
183 __le32 gateway_cmd_addr;
184 __le32 gateway_ctrl_address;
185#define WIL_FW_GW_CTL_BUSY BIT(29) /* gateway busy performing operation */
186#define WIL_FW_GW_CTL_RUN BIT(30) /* start gateway operation */
187 __le32 command;
188 struct wil_fw_data_gw data[0]; /* total size [data_size], see above */
189} __packed;
190
191/* 4-dword gateway */
192/* data block for the struct wil_fw_record_gateway_data4 */
193struct wil_fw_data_gw4 {
194 __le32 addr;
195 __le32 value[4];
196} __packed;
197
198/* gateway write block.
199 * write starting address and values from the data buffer
200 * through the gateway
201 * data_size inferred from the @head.size. For this case,
202 * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data4, data)
203 */
204struct wil_fw_record_gateway_data4 { /* type == wil_fw_type_gateway_data4 */
205 __le32 gateway_addr_addr;
206 __le32 gateway_value_addr[4];
207 __le32 gateway_cmd_addr;
208 __le32 gateway_ctrl_address; /* same logic as for 1-dword gw */
209 __le32 command;
210 struct wil_fw_data_gw4 data[0]; /* total size [data_size], see above */
211} __packed;
212
213#endif /* __WIL_FW_H__ */