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