xref: /linux/drivers/net/wireless/ath/wil6210/fw.h (revision 4b132aacb0768ac1e652cf517097ea6f237214b9)
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 
12 enum 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 
24 struct 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  */
34 struct 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 */
40 struct 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  */
49 struct 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 */
54 struct 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)
60 struct 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
72 struct 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 
77 struct 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 
86 struct 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 } __packed;
97 
98 /* brd file info encoded inside a comment record */
99 #define WIL_BRD_FILE_MAGIC (0xabcddcbb)
100 
101 struct brd_info {
102 	__le32 base_addr;
103 	__le32 max_size_bytes;
104 } __packed;
105 
106 struct wil_fw_record_brd_file { /* type == wil_fw_type_comment */
107 	/* identifies brd file record */
108 	struct wil_fw_record_comment_hdr hdr;
109 	__le32 version;
110 	struct brd_info brd_info[];
111 } __packed;
112 
113 /* perform action
114  * data_size = @head.size - offsetof(struct wil_fw_record_action, data)
115  */
116 struct wil_fw_record_action { /* type == wil_fw_type_action */
117 	__le32 action; /* action to perform: reset, wait for fw ready etc. */
118 	__le32 data[]; /* action specific, [data_size], see above */
119 } __packed;
120 
121 /* data block for struct wil_fw_record_direct_write */
122 struct wil_fw_data_dwrite {
123 	__le32 addr;
124 	__le32 value;
125 	__le32 mask;
126 } __packed;
127 
128 /* write @value to the @addr,
129  * preserve original bits accordingly to the @mask
130  * data_size is @head.size where @head is record header
131  */
132 struct wil_fw_record_direct_write { /* type == wil_fw_type_direct_write */
133 	DECLARE_FLEX_ARRAY(struct wil_fw_data_dwrite, data);
134 } __packed;
135 
136 /* verify condition: [@addr] & @mask == @value
137  * if condition not met, firmware download fails
138  */
139 struct wil_fw_record_verify { /* type == wil_fw_verify */
140 	__le32 addr; /* read from this address */
141 	__le32 value; /* reference value */
142 	__le32 mask; /* mask for verification */
143 } __packed;
144 
145 /* file header
146  * First record of every file
147  */
148 /* the FW version prefix in the comment */
149 #define WIL_FW_VERSION_PREFIX "FW version: "
150 #define WIL_FW_VERSION_PREFIX_LEN (sizeof(WIL_FW_VERSION_PREFIX) - 1)
151 struct wil_fw_record_file_header {
152 	__le32 signature ; /* Wilocity signature */
153 	__le32 reserved;
154 	__le32 crc; /* crc32 of the following data  */
155 	__le32 version; /* format version */
156 	__le32 data_len; /* total data in file, including this record */
157 	u8 comment[32]; /* short description */
158 } __packed;
159 
160 /* 1-dword gateway */
161 /* data block for the struct wil_fw_record_gateway_data */
162 struct wil_fw_data_gw {
163 	__le32 addr;
164 	__le32 value;
165 } __packed;
166 
167 /* gateway write block.
168  * write starting address and values from the data buffer
169  * through the gateway
170  * data_size inferred from the @head.size. For this case,
171  * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data, data)
172  */
173 struct wil_fw_record_gateway_data { /* type == wil_fw_type_gateway_data */
174 	__le32 gateway_addr_addr;
175 	__le32 gateway_value_addr;
176 	__le32 gateway_cmd_addr;
177 	__le32 gateway_ctrl_address;
178 #define WIL_FW_GW_CTL_BUSY	BIT(29) /* gateway busy performing operation */
179 #define WIL_FW_GW_CTL_RUN	BIT(30) /* start gateway operation */
180 	__le32 command;
181 	struct wil_fw_data_gw data[]; /* total size [data_size], see above */
182 } __packed;
183 
184 /* 4-dword gateway */
185 /* data block for the struct wil_fw_record_gateway_data4 */
186 struct wil_fw_data_gw4 {
187 	__le32 addr;
188 	__le32 value[4];
189 } __packed;
190 
191 /* gateway write block.
192  * write starting address and values from the data buffer
193  * through the gateway
194  * data_size inferred from the @head.size. For this case,
195  * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data4, data)
196  */
197 struct wil_fw_record_gateway_data4 { /* type == wil_fw_type_gateway_data4 */
198 	__le32 gateway_addr_addr;
199 	__le32 gateway_value_addr[4];
200 	__le32 gateway_cmd_addr;
201 	__le32 gateway_ctrl_address; /* same logic as for 1-dword gw */
202 	__le32 command;
203 	struct wil_fw_data_gw4 data[]; /* total size [data_size], see above */
204 } __packed;
205 
206 #endif /* __WIL_FW_H__ */
207