xref: /linux/drivers/net/wireless/ath/wil6210/fw.h (revision e5c86679d5e864947a52fb31e45a425dea3e7fa9)
1 /*
2  * Copyright (c) 2014,2016 Qualcomm Atheros, Inc.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #define WIL_FW_SIGNATURE (0x36323130) /* '0126' */
18 #define WIL_FW_FMT_VERSION (1) /* format version driver supports */
19 
20 enum wil_fw_record_type {
21 	wil_fw_type_comment = 1,
22 	wil_fw_type_data = 2,
23 	wil_fw_type_fill = 3,
24 	wil_fw_type_action = 4,
25 	wil_fw_type_verify = 5,
26 	wil_fw_type_file_header = 6,
27 	wil_fw_type_direct_write = 7,
28 	wil_fw_type_gateway_data = 8,
29 	wil_fw_type_gateway_data4 = 9,
30 };
31 
32 struct wil_fw_record_head {
33 	__le16 type; /* enum wil_fw_record_type */
34 	__le16 flags; /* to be defined */
35 	__le32 size; /* whole record, bytes after head */
36 } __packed;
37 
38 /* data block. write starting from @addr
39  * data_size inferred from the @head.size. For this case,
40  * data_size = @head.size - offsetof(struct wil_fw_record_data, data)
41  */
42 struct wil_fw_record_data { /* type == wil_fw_type_data */
43 	__le32 addr;
44 	__le32 data[0]; /* [data_size], see above */
45 } __packed;
46 
47 /* fill with constant @value, @size bytes starting from @addr */
48 struct wil_fw_record_fill { /* type == wil_fw_type_fill */
49 	__le32 addr;
50 	__le32 value;
51 	__le32 size;
52 } __packed;
53 
54 /* free-form comment
55  * for informational purpose, data_size is @head.size from record header
56  */
57 struct wil_fw_record_comment { /* type == wil_fw_type_comment */
58 	u8 data[0]; /* free-form data [data_size], see above */
59 } __packed;
60 
61 /* FW capabilities encoded inside a comment record */
62 #define WIL_FW_CAPABILITIES_MAGIC (0xabcddcba)
63 struct wil_fw_record_capabilities { /* type == wil_fw_type_comment */
64 	/* identifies capabilities record */
65 	__le32 magic;
66 	/* capabilities (variable size), see enum wmi_fw_capability */
67 	u8 capabilities[0];
68 };
69 
70 /* perform action
71  * data_size = @head.size - offsetof(struct wil_fw_record_action, data)
72  */
73 struct wil_fw_record_action { /* type == wil_fw_type_action */
74 	__le32 action; /* action to perform: reset, wait for fw ready etc. */
75 	__le32 data[0]; /* action specific, [data_size], see above */
76 } __packed;
77 
78 /* data block for struct wil_fw_record_direct_write */
79 struct wil_fw_data_dwrite {
80 	__le32 addr;
81 	__le32 value;
82 	__le32 mask;
83 } __packed;
84 
85 /* write @value to the @addr,
86  * preserve original bits accordingly to the @mask
87  * data_size is @head.size where @head is record header
88  */
89 struct wil_fw_record_direct_write { /* type == wil_fw_type_direct_write */
90 	struct wil_fw_data_dwrite data[0];
91 } __packed;
92 
93 /* verify condition: [@addr] & @mask == @value
94  * if condition not met, firmware download fails
95  */
96 struct wil_fw_record_verify { /* type == wil_fw_verify */
97 	__le32 addr; /* read from this address */
98 	__le32 value; /* reference value */
99 	__le32 mask; /* mask for verification */
100 } __packed;
101 
102 /* file header
103  * First record of every file
104  */
105 /* the FW version prefix in the comment */
106 #define WIL_FW_VERSION_PREFIX "FW version: "
107 #define WIL_FW_VERSION_PREFIX_LEN (sizeof(WIL_FW_VERSION_PREFIX) - 1)
108 struct wil_fw_record_file_header {
109 	__le32 signature ; /* Wilocity signature */
110 	__le32 reserved;
111 	__le32 crc; /* crc32 of the following data  */
112 	__le32 version; /* format version */
113 	__le32 data_len; /* total data in file, including this record */
114 	u8 comment[32]; /* short description */
115 } __packed;
116 
117 /* 1-dword gateway */
118 /* data block for the struct wil_fw_record_gateway_data */
119 struct wil_fw_data_gw {
120 	__le32 addr;
121 	__le32 value;
122 } __packed;
123 
124 /* gateway write block.
125  * write starting address and values from the data buffer
126  * through the gateway
127  * data_size inferred from the @head.size. For this case,
128  * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data, data)
129  */
130 struct wil_fw_record_gateway_data { /* type == wil_fw_type_gateway_data */
131 	__le32 gateway_addr_addr;
132 	__le32 gateway_value_addr;
133 	__le32 gateway_cmd_addr;
134 	__le32 gateway_ctrl_address;
135 #define WIL_FW_GW_CTL_BUSY	BIT(29) /* gateway busy performing operation */
136 #define WIL_FW_GW_CTL_RUN	BIT(30) /* start gateway operation */
137 	__le32 command;
138 	struct wil_fw_data_gw data[0]; /* total size [data_size], see above */
139 } __packed;
140 
141 /* 4-dword gateway */
142 /* data block for the struct wil_fw_record_gateway_data4 */
143 struct wil_fw_data_gw4 {
144 	__le32 addr;
145 	__le32 value[4];
146 } __packed;
147 
148 /* gateway write block.
149  * write starting address and values from the data buffer
150  * through the gateway
151  * data_size inferred from the @head.size. For this case,
152  * data_size = @head.size - offsetof(struct wil_fw_record_gateway_data4, data)
153  */
154 struct wil_fw_record_gateway_data4 { /* type == wil_fw_type_gateway_data4 */
155 	__le32 gateway_addr_addr;
156 	__le32 gateway_value_addr[4];
157 	__le32 gateway_cmd_addr;
158 	__le32 gateway_ctrl_address; /* same logic as for 1-dword gw */
159 	__le32 command;
160 	struct wil_fw_data_gw4 data[0]; /* total size [data_size], see above */
161 } __packed;
162