Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / net / wireless / ath / ath11k / qmi.c
blob0db623ff4bb9b33991df8620cb18fb4689e32906
1 // SPDX-License-Identifier: BSD-3-Clause-Clear
2 /*
3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
4 */
6 #include <linux/elf.h>
8 #include "qmi.h"
9 #include "core.h"
10 #include "debug.h"
11 #include <linux/of.h>
12 #include <linux/firmware.h>
14 #define SLEEP_CLOCK_SELECT_INTERNAL_BIT 0x02
15 #define HOST_CSTATE_BIT 0x04
17 bool ath11k_cold_boot_cal = 1;
18 EXPORT_SYMBOL(ath11k_cold_boot_cal);
19 module_param_named(cold_boot_cal, ath11k_cold_boot_cal, bool, 0644);
20 MODULE_PARM_DESC(cold_boot_cal,
21 "Decrease the channel switch time but increase the driver load time (Default: true)");
23 static struct qmi_elem_info qmi_wlanfw_host_cap_req_msg_v01_ei[] = {
25 .data_type = QMI_OPT_FLAG,
26 .elem_len = 1,
27 .elem_size = sizeof(u8),
28 .array_type = NO_ARRAY,
29 .tlv_type = 0x10,
30 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
31 num_clients_valid),
34 .data_type = QMI_UNSIGNED_4_BYTE,
35 .elem_len = 1,
36 .elem_size = sizeof(u32),
37 .array_type = NO_ARRAY,
38 .tlv_type = 0x10,
39 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
40 num_clients),
43 .data_type = QMI_OPT_FLAG,
44 .elem_len = 1,
45 .elem_size = sizeof(u8),
46 .array_type = NO_ARRAY,
47 .tlv_type = 0x11,
48 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
49 wake_msi_valid),
52 .data_type = QMI_UNSIGNED_4_BYTE,
53 .elem_len = 1,
54 .elem_size = sizeof(u32),
55 .array_type = NO_ARRAY,
56 .tlv_type = 0x11,
57 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
58 wake_msi),
61 .data_type = QMI_OPT_FLAG,
62 .elem_len = 1,
63 .elem_size = sizeof(u8),
64 .array_type = NO_ARRAY,
65 .tlv_type = 0x12,
66 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
67 gpios_valid),
70 .data_type = QMI_DATA_LEN,
71 .elem_len = 1,
72 .elem_size = sizeof(u8),
73 .array_type = NO_ARRAY,
74 .tlv_type = 0x12,
75 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
76 gpios_len),
79 .data_type = QMI_UNSIGNED_4_BYTE,
80 .elem_len = QMI_WLFW_MAX_NUM_GPIO_V01,
81 .elem_size = sizeof(u32),
82 .array_type = VAR_LEN_ARRAY,
83 .tlv_type = 0x12,
84 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
85 gpios),
88 .data_type = QMI_OPT_FLAG,
89 .elem_len = 1,
90 .elem_size = sizeof(u8),
91 .array_type = NO_ARRAY,
92 .tlv_type = 0x13,
93 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
94 nm_modem_valid),
97 .data_type = QMI_UNSIGNED_1_BYTE,
98 .elem_len = 1,
99 .elem_size = sizeof(u8),
100 .array_type = NO_ARRAY,
101 .tlv_type = 0x13,
102 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
103 nm_modem),
106 .data_type = QMI_OPT_FLAG,
107 .elem_len = 1,
108 .elem_size = sizeof(u8),
109 .array_type = NO_ARRAY,
110 .tlv_type = 0x14,
111 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
112 bdf_support_valid),
115 .data_type = QMI_UNSIGNED_1_BYTE,
116 .elem_len = 1,
117 .elem_size = sizeof(u8),
118 .array_type = NO_ARRAY,
119 .tlv_type = 0x14,
120 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
121 bdf_support),
124 .data_type = QMI_OPT_FLAG,
125 .elem_len = 1,
126 .elem_size = sizeof(u8),
127 .array_type = NO_ARRAY,
128 .tlv_type = 0x15,
129 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
130 bdf_cache_support_valid),
133 .data_type = QMI_UNSIGNED_1_BYTE,
134 .elem_len = 1,
135 .elem_size = sizeof(u8),
136 .array_type = NO_ARRAY,
137 .tlv_type = 0x15,
138 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
139 bdf_cache_support),
142 .data_type = QMI_OPT_FLAG,
143 .elem_len = 1,
144 .elem_size = sizeof(u8),
145 .array_type = NO_ARRAY,
146 .tlv_type = 0x16,
147 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
148 m3_support_valid),
151 .data_type = QMI_UNSIGNED_1_BYTE,
152 .elem_len = 1,
153 .elem_size = sizeof(u8),
154 .array_type = NO_ARRAY,
155 .tlv_type = 0x16,
156 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
157 m3_support),
160 .data_type = QMI_OPT_FLAG,
161 .elem_len = 1,
162 .elem_size = sizeof(u8),
163 .array_type = NO_ARRAY,
164 .tlv_type = 0x17,
165 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
166 m3_cache_support_valid),
169 .data_type = QMI_UNSIGNED_1_BYTE,
170 .elem_len = 1,
171 .elem_size = sizeof(u8),
172 .array_type = NO_ARRAY,
173 .tlv_type = 0x17,
174 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
175 m3_cache_support),
178 .data_type = QMI_OPT_FLAG,
179 .elem_len = 1,
180 .elem_size = sizeof(u8),
181 .array_type = NO_ARRAY,
182 .tlv_type = 0x18,
183 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
184 cal_filesys_support_valid),
187 .data_type = QMI_UNSIGNED_1_BYTE,
188 .elem_len = 1,
189 .elem_size = sizeof(u8),
190 .array_type = NO_ARRAY,
191 .tlv_type = 0x18,
192 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
193 cal_filesys_support),
196 .data_type = QMI_OPT_FLAG,
197 .elem_len = 1,
198 .elem_size = sizeof(u8),
199 .array_type = NO_ARRAY,
200 .tlv_type = 0x19,
201 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
202 cal_cache_support_valid),
205 .data_type = QMI_UNSIGNED_1_BYTE,
206 .elem_len = 1,
207 .elem_size = sizeof(u8),
208 .array_type = NO_ARRAY,
209 .tlv_type = 0x19,
210 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
211 cal_cache_support),
214 .data_type = QMI_OPT_FLAG,
215 .elem_len = 1,
216 .elem_size = sizeof(u8),
217 .array_type = NO_ARRAY,
218 .tlv_type = 0x1A,
219 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
220 cal_done_valid),
223 .data_type = QMI_UNSIGNED_1_BYTE,
224 .elem_len = 1,
225 .elem_size = sizeof(u8),
226 .array_type = NO_ARRAY,
227 .tlv_type = 0x1A,
228 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
229 cal_done),
232 .data_type = QMI_OPT_FLAG,
233 .elem_len = 1,
234 .elem_size = sizeof(u8),
235 .array_type = NO_ARRAY,
236 .tlv_type = 0x1B,
237 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
238 mem_bucket_valid),
241 .data_type = QMI_UNSIGNED_4_BYTE,
242 .elem_len = 1,
243 .elem_size = sizeof(u32),
244 .array_type = NO_ARRAY,
245 .tlv_type = 0x1B,
246 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
247 mem_bucket),
250 .data_type = QMI_OPT_FLAG,
251 .elem_len = 1,
252 .elem_size = sizeof(u8),
253 .array_type = NO_ARRAY,
254 .tlv_type = 0x1C,
255 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
256 mem_cfg_mode_valid),
259 .data_type = QMI_UNSIGNED_1_BYTE,
260 .elem_len = 1,
261 .elem_size = sizeof(u8),
262 .array_type = NO_ARRAY,
263 .tlv_type = 0x1C,
264 .offset = offsetof(struct qmi_wlanfw_host_cap_req_msg_v01,
265 mem_cfg_mode),
268 .data_type = QMI_EOTI,
269 .array_type = NO_ARRAY,
270 .tlv_type = QMI_COMMON_TLV_TYPE,
274 static struct qmi_elem_info qmi_wlanfw_host_cap_resp_msg_v01_ei[] = {
276 .data_type = QMI_STRUCT,
277 .elem_len = 1,
278 .elem_size = sizeof(struct qmi_response_type_v01),
279 .array_type = NO_ARRAY,
280 .tlv_type = 0x02,
281 .offset = offsetof(struct qmi_wlanfw_host_cap_resp_msg_v01, resp),
282 .ei_array = qmi_response_type_v01_ei,
285 .data_type = QMI_EOTI,
286 .array_type = NO_ARRAY,
287 .tlv_type = QMI_COMMON_TLV_TYPE,
291 static struct qmi_elem_info qmi_wlanfw_ind_register_req_msg_v01_ei[] = {
293 .data_type = QMI_OPT_FLAG,
294 .elem_len = 1,
295 .elem_size = sizeof(u8),
296 .array_type = NO_ARRAY,
297 .tlv_type = 0x10,
298 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
299 fw_ready_enable_valid),
302 .data_type = QMI_UNSIGNED_1_BYTE,
303 .elem_len = 1,
304 .elem_size = sizeof(u8),
305 .array_type = NO_ARRAY,
306 .tlv_type = 0x10,
307 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
308 fw_ready_enable),
311 .data_type = QMI_OPT_FLAG,
312 .elem_len = 1,
313 .elem_size = sizeof(u8),
314 .array_type = NO_ARRAY,
315 .tlv_type = 0x11,
316 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
317 initiate_cal_download_enable_valid),
320 .data_type = QMI_UNSIGNED_1_BYTE,
321 .elem_len = 1,
322 .elem_size = sizeof(u8),
323 .array_type = NO_ARRAY,
324 .tlv_type = 0x11,
325 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
326 initiate_cal_download_enable),
329 .data_type = QMI_OPT_FLAG,
330 .elem_len = 1,
331 .elem_size = sizeof(u8),
332 .array_type = NO_ARRAY,
333 .tlv_type = 0x12,
334 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
335 initiate_cal_update_enable_valid),
338 .data_type = QMI_UNSIGNED_1_BYTE,
339 .elem_len = 1,
340 .elem_size = sizeof(u8),
341 .array_type = NO_ARRAY,
342 .tlv_type = 0x12,
343 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
344 initiate_cal_update_enable),
347 .data_type = QMI_OPT_FLAG,
348 .elem_len = 1,
349 .elem_size = sizeof(u8),
350 .array_type = NO_ARRAY,
351 .tlv_type = 0x13,
352 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
353 msa_ready_enable_valid),
356 .data_type = QMI_UNSIGNED_1_BYTE,
357 .elem_len = 1,
358 .elem_size = sizeof(u8),
359 .array_type = NO_ARRAY,
360 .tlv_type = 0x13,
361 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
362 msa_ready_enable),
365 .data_type = QMI_OPT_FLAG,
366 .elem_len = 1,
367 .elem_size = sizeof(u8),
368 .array_type = NO_ARRAY,
369 .tlv_type = 0x14,
370 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
371 pin_connect_result_enable_valid),
374 .data_type = QMI_UNSIGNED_1_BYTE,
375 .elem_len = 1,
376 .elem_size = sizeof(u8),
377 .array_type = NO_ARRAY,
378 .tlv_type = 0x14,
379 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
380 pin_connect_result_enable),
383 .data_type = QMI_OPT_FLAG,
384 .elem_len = 1,
385 .elem_size = sizeof(u8),
386 .array_type = NO_ARRAY,
387 .tlv_type = 0x15,
388 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
389 client_id_valid),
392 .data_type = QMI_UNSIGNED_4_BYTE,
393 .elem_len = 1,
394 .elem_size = sizeof(u32),
395 .array_type = NO_ARRAY,
396 .tlv_type = 0x15,
397 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
398 client_id),
401 .data_type = QMI_OPT_FLAG,
402 .elem_len = 1,
403 .elem_size = sizeof(u8),
404 .array_type = NO_ARRAY,
405 .tlv_type = 0x16,
406 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
407 request_mem_enable_valid),
410 .data_type = QMI_UNSIGNED_1_BYTE,
411 .elem_len = 1,
412 .elem_size = sizeof(u8),
413 .array_type = NO_ARRAY,
414 .tlv_type = 0x16,
415 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
416 request_mem_enable),
419 .data_type = QMI_OPT_FLAG,
420 .elem_len = 1,
421 .elem_size = sizeof(u8),
422 .array_type = NO_ARRAY,
423 .tlv_type = 0x17,
424 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
425 fw_mem_ready_enable_valid),
428 .data_type = QMI_UNSIGNED_1_BYTE,
429 .elem_len = 1,
430 .elem_size = sizeof(u8),
431 .array_type = NO_ARRAY,
432 .tlv_type = 0x17,
433 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
434 fw_mem_ready_enable),
437 .data_type = QMI_OPT_FLAG,
438 .elem_len = 1,
439 .elem_size = sizeof(u8),
440 .array_type = NO_ARRAY,
441 .tlv_type = 0x18,
442 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
443 fw_init_done_enable_valid),
446 .data_type = QMI_UNSIGNED_1_BYTE,
447 .elem_len = 1,
448 .elem_size = sizeof(u8),
449 .array_type = NO_ARRAY,
450 .tlv_type = 0x18,
451 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
452 fw_init_done_enable),
456 .data_type = QMI_OPT_FLAG,
457 .elem_len = 1,
458 .elem_size = sizeof(u8),
459 .array_type = NO_ARRAY,
460 .tlv_type = 0x19,
461 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
462 rejuvenate_enable_valid),
465 .data_type = QMI_UNSIGNED_1_BYTE,
466 .elem_len = 1,
467 .elem_size = sizeof(u8),
468 .array_type = NO_ARRAY,
469 .tlv_type = 0x19,
470 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
471 rejuvenate_enable),
474 .data_type = QMI_OPT_FLAG,
475 .elem_len = 1,
476 .elem_size = sizeof(u8),
477 .array_type = NO_ARRAY,
478 .tlv_type = 0x1A,
479 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
480 xo_cal_enable_valid),
483 .data_type = QMI_UNSIGNED_1_BYTE,
484 .elem_len = 1,
485 .elem_size = sizeof(u8),
486 .array_type = NO_ARRAY,
487 .tlv_type = 0x1A,
488 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
489 xo_cal_enable),
492 .data_type = QMI_OPT_FLAG,
493 .elem_len = 1,
494 .elem_size = sizeof(u8),
495 .array_type = NO_ARRAY,
496 .tlv_type = 0x1B,
497 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
498 cal_done_enable_valid),
501 .data_type = QMI_UNSIGNED_1_BYTE,
502 .elem_len = 1,
503 .elem_size = sizeof(u8),
504 .array_type = NO_ARRAY,
505 .tlv_type = 0x1B,
506 .offset = offsetof(struct qmi_wlanfw_ind_register_req_msg_v01,
507 cal_done_enable),
510 .data_type = QMI_EOTI,
511 .array_type = NO_ARRAY,
512 .tlv_type = QMI_COMMON_TLV_TYPE,
516 static struct qmi_elem_info qmi_wlanfw_ind_register_resp_msg_v01_ei[] = {
518 .data_type = QMI_STRUCT,
519 .elem_len = 1,
520 .elem_size = sizeof(struct qmi_response_type_v01),
521 .array_type = NO_ARRAY,
522 .tlv_type = 0x02,
523 .offset = offsetof(struct qmi_wlanfw_ind_register_resp_msg_v01,
524 resp),
525 .ei_array = qmi_response_type_v01_ei,
528 .data_type = QMI_OPT_FLAG,
529 .elem_len = 1,
530 .elem_size = sizeof(u8),
531 .array_type = NO_ARRAY,
532 .tlv_type = 0x10,
533 .offset = offsetof(struct qmi_wlanfw_ind_register_resp_msg_v01,
534 fw_status_valid),
537 .data_type = QMI_UNSIGNED_8_BYTE,
538 .elem_len = 1,
539 .elem_size = sizeof(u64),
540 .array_type = NO_ARRAY,
541 .tlv_type = 0x10,
542 .offset = offsetof(struct qmi_wlanfw_ind_register_resp_msg_v01,
543 fw_status),
546 .data_type = QMI_EOTI,
547 .array_type = NO_ARRAY,
548 .tlv_type = QMI_COMMON_TLV_TYPE,
552 static struct qmi_elem_info qmi_wlanfw_mem_cfg_s_v01_ei[] = {
554 .data_type = QMI_UNSIGNED_8_BYTE,
555 .elem_len = 1,
556 .elem_size = sizeof(u64),
557 .array_type = NO_ARRAY,
558 .tlv_type = 0,
559 .offset = offsetof(struct qmi_wlanfw_mem_cfg_s_v01, offset),
562 .data_type = QMI_UNSIGNED_4_BYTE,
563 .elem_len = 1,
564 .elem_size = sizeof(u32),
565 .array_type = NO_ARRAY,
566 .tlv_type = 0,
567 .offset = offsetof(struct qmi_wlanfw_mem_cfg_s_v01, size),
570 .data_type = QMI_UNSIGNED_1_BYTE,
571 .elem_len = 1,
572 .elem_size = sizeof(u8),
573 .array_type = NO_ARRAY,
574 .tlv_type = 0,
575 .offset = offsetof(struct qmi_wlanfw_mem_cfg_s_v01, secure_flag),
578 .data_type = QMI_EOTI,
579 .array_type = NO_ARRAY,
580 .tlv_type = QMI_COMMON_TLV_TYPE,
584 static struct qmi_elem_info qmi_wlanfw_mem_seg_s_v01_ei[] = {
586 .data_type = QMI_UNSIGNED_4_BYTE,
587 .elem_len = 1,
588 .elem_size = sizeof(u32),
589 .array_type = NO_ARRAY,
590 .tlv_type = 0,
591 .offset = offsetof(struct qmi_wlanfw_mem_seg_s_v01,
592 size),
595 .data_type = QMI_SIGNED_4_BYTE_ENUM,
596 .elem_len = 1,
597 .elem_size = sizeof(enum qmi_wlanfw_mem_type_enum_v01),
598 .array_type = NO_ARRAY,
599 .tlv_type = 0,
600 .offset = offsetof(struct qmi_wlanfw_mem_seg_s_v01, type),
603 .data_type = QMI_DATA_LEN,
604 .elem_len = 1,
605 .elem_size = sizeof(u8),
606 .array_type = NO_ARRAY,
607 .tlv_type = 0,
608 .offset = offsetof(struct qmi_wlanfw_mem_seg_s_v01, mem_cfg_len),
611 .data_type = QMI_STRUCT,
612 .elem_len = QMI_WLANFW_MAX_NUM_MEM_CFG_V01,
613 .elem_size = sizeof(struct qmi_wlanfw_mem_cfg_s_v01),
614 .array_type = VAR_LEN_ARRAY,
615 .tlv_type = 0,
616 .offset = offsetof(struct qmi_wlanfw_mem_seg_s_v01, mem_cfg),
617 .ei_array = qmi_wlanfw_mem_cfg_s_v01_ei,
620 .data_type = QMI_EOTI,
621 .array_type = NO_ARRAY,
622 .tlv_type = QMI_COMMON_TLV_TYPE,
626 static struct qmi_elem_info qmi_wlanfw_request_mem_ind_msg_v01_ei[] = {
628 .data_type = QMI_DATA_LEN,
629 .elem_len = 1,
630 .elem_size = sizeof(u8),
631 .array_type = NO_ARRAY,
632 .tlv_type = 0x01,
633 .offset = offsetof(struct qmi_wlanfw_request_mem_ind_msg_v01,
634 mem_seg_len),
637 .data_type = QMI_STRUCT,
638 .elem_len = ATH11K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01,
639 .elem_size = sizeof(struct qmi_wlanfw_mem_seg_s_v01),
640 .array_type = VAR_LEN_ARRAY,
641 .tlv_type = 0x01,
642 .offset = offsetof(struct qmi_wlanfw_request_mem_ind_msg_v01,
643 mem_seg),
644 .ei_array = qmi_wlanfw_mem_seg_s_v01_ei,
647 .data_type = QMI_EOTI,
648 .array_type = NO_ARRAY,
649 .tlv_type = QMI_COMMON_TLV_TYPE,
653 static struct qmi_elem_info qmi_wlanfw_mem_seg_resp_s_v01_ei[] = {
655 .data_type = QMI_UNSIGNED_8_BYTE,
656 .elem_len = 1,
657 .elem_size = sizeof(u64),
658 .array_type = NO_ARRAY,
659 .tlv_type = 0,
660 .offset = offsetof(struct qmi_wlanfw_mem_seg_resp_s_v01, addr),
663 .data_type = QMI_UNSIGNED_4_BYTE,
664 .elem_len = 1,
665 .elem_size = sizeof(u32),
666 .array_type = NO_ARRAY,
667 .tlv_type = 0,
668 .offset = offsetof(struct qmi_wlanfw_mem_seg_resp_s_v01, size),
671 .data_type = QMI_SIGNED_4_BYTE_ENUM,
672 .elem_len = 1,
673 .elem_size = sizeof(enum qmi_wlanfw_mem_type_enum_v01),
674 .array_type = NO_ARRAY,
675 .tlv_type = 0,
676 .offset = offsetof(struct qmi_wlanfw_mem_seg_resp_s_v01, type),
679 .data_type = QMI_UNSIGNED_1_BYTE,
680 .elem_len = 1,
681 .elem_size = sizeof(u8),
682 .array_type = NO_ARRAY,
683 .tlv_type = 0,
684 .offset = offsetof(struct qmi_wlanfw_mem_seg_resp_s_v01, restore),
687 .data_type = QMI_EOTI,
688 .array_type = NO_ARRAY,
689 .tlv_type = QMI_COMMON_TLV_TYPE,
693 static struct qmi_elem_info qmi_wlanfw_respond_mem_req_msg_v01_ei[] = {
695 .data_type = QMI_DATA_LEN,
696 .elem_len = 1,
697 .elem_size = sizeof(u8),
698 .array_type = NO_ARRAY,
699 .tlv_type = 0x01,
700 .offset = offsetof(struct qmi_wlanfw_respond_mem_req_msg_v01,
701 mem_seg_len),
704 .data_type = QMI_STRUCT,
705 .elem_len = ATH11K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01,
706 .elem_size = sizeof(struct qmi_wlanfw_mem_seg_resp_s_v01),
707 .array_type = VAR_LEN_ARRAY,
708 .tlv_type = 0x01,
709 .offset = offsetof(struct qmi_wlanfw_respond_mem_req_msg_v01,
710 mem_seg),
711 .ei_array = qmi_wlanfw_mem_seg_resp_s_v01_ei,
714 .data_type = QMI_EOTI,
715 .array_type = NO_ARRAY,
716 .tlv_type = QMI_COMMON_TLV_TYPE,
720 static struct qmi_elem_info qmi_wlanfw_respond_mem_resp_msg_v01_ei[] = {
722 .data_type = QMI_STRUCT,
723 .elem_len = 1,
724 .elem_size = sizeof(struct qmi_response_type_v01),
725 .array_type = NO_ARRAY,
726 .tlv_type = 0x02,
727 .offset = offsetof(struct qmi_wlanfw_respond_mem_resp_msg_v01,
728 resp),
729 .ei_array = qmi_response_type_v01_ei,
732 .data_type = QMI_EOTI,
733 .array_type = NO_ARRAY,
734 .tlv_type = QMI_COMMON_TLV_TYPE,
738 static struct qmi_elem_info qmi_wlanfw_cap_req_msg_v01_ei[] = {
740 .data_type = QMI_EOTI,
741 .array_type = NO_ARRAY,
742 .tlv_type = QMI_COMMON_TLV_TYPE,
746 static struct qmi_elem_info qmi_wlanfw_rf_chip_info_s_v01_ei[] = {
748 .data_type = QMI_UNSIGNED_4_BYTE,
749 .elem_len = 1,
750 .elem_size = sizeof(u32),
751 .array_type = NO_ARRAY,
752 .tlv_type = 0,
753 .offset = offsetof(struct qmi_wlanfw_rf_chip_info_s_v01,
754 chip_id),
757 .data_type = QMI_UNSIGNED_4_BYTE,
758 .elem_len = 1,
759 .elem_size = sizeof(u32),
760 .array_type = NO_ARRAY,
761 .tlv_type = 0,
762 .offset = offsetof(struct qmi_wlanfw_rf_chip_info_s_v01,
763 chip_family),
766 .data_type = QMI_EOTI,
767 .array_type = NO_ARRAY,
768 .tlv_type = QMI_COMMON_TLV_TYPE,
772 static struct qmi_elem_info qmi_wlanfw_rf_board_info_s_v01_ei[] = {
774 .data_type = QMI_UNSIGNED_4_BYTE,
775 .elem_len = 1,
776 .elem_size = sizeof(u32),
777 .array_type = NO_ARRAY,
778 .tlv_type = 0,
779 .offset = offsetof(struct qmi_wlanfw_rf_board_info_s_v01,
780 board_id),
783 .data_type = QMI_EOTI,
784 .array_type = NO_ARRAY,
785 .tlv_type = QMI_COMMON_TLV_TYPE,
789 static struct qmi_elem_info qmi_wlanfw_soc_info_s_v01_ei[] = {
791 .data_type = QMI_UNSIGNED_4_BYTE,
792 .elem_len = 1,
793 .elem_size = sizeof(u32),
794 .array_type = NO_ARRAY,
795 .tlv_type = 0,
796 .offset = offsetof(struct qmi_wlanfw_soc_info_s_v01, soc_id),
799 .data_type = QMI_EOTI,
800 .array_type = NO_ARRAY,
801 .tlv_type = QMI_COMMON_TLV_TYPE,
805 static struct qmi_elem_info qmi_wlanfw_fw_version_info_s_v01_ei[] = {
807 .data_type = QMI_UNSIGNED_4_BYTE,
808 .elem_len = 1,
809 .elem_size = sizeof(u32),
810 .array_type = NO_ARRAY,
811 .tlv_type = 0,
812 .offset = offsetof(struct qmi_wlanfw_fw_version_info_s_v01,
813 fw_version),
816 .data_type = QMI_STRING,
817 .elem_len = ATH11K_QMI_WLANFW_MAX_TIMESTAMP_LEN_V01 + 1,
818 .elem_size = sizeof(char),
819 .array_type = NO_ARRAY,
820 .tlv_type = 0,
821 .offset = offsetof(struct qmi_wlanfw_fw_version_info_s_v01,
822 fw_build_timestamp),
825 .data_type = QMI_EOTI,
826 .array_type = NO_ARRAY,
827 .tlv_type = QMI_COMMON_TLV_TYPE,
831 static struct qmi_elem_info qmi_wlanfw_cap_resp_msg_v01_ei[] = {
833 .data_type = QMI_STRUCT,
834 .elem_len = 1,
835 .elem_size = sizeof(struct qmi_response_type_v01),
836 .array_type = NO_ARRAY,
837 .tlv_type = 0x02,
838 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01, resp),
839 .ei_array = qmi_response_type_v01_ei,
842 .data_type = QMI_OPT_FLAG,
843 .elem_len = 1,
844 .elem_size = sizeof(u8),
845 .array_type = NO_ARRAY,
846 .tlv_type = 0x10,
847 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
848 chip_info_valid),
851 .data_type = QMI_STRUCT,
852 .elem_len = 1,
853 .elem_size = sizeof(struct qmi_wlanfw_rf_chip_info_s_v01),
854 .array_type = NO_ARRAY,
855 .tlv_type = 0x10,
856 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
857 chip_info),
858 .ei_array = qmi_wlanfw_rf_chip_info_s_v01_ei,
861 .data_type = QMI_OPT_FLAG,
862 .elem_len = 1,
863 .elem_size = sizeof(u8),
864 .array_type = NO_ARRAY,
865 .tlv_type = 0x11,
866 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
867 board_info_valid),
870 .data_type = QMI_STRUCT,
871 .elem_len = 1,
872 .elem_size = sizeof(struct qmi_wlanfw_rf_board_info_s_v01),
873 .array_type = NO_ARRAY,
874 .tlv_type = 0x11,
875 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
876 board_info),
877 .ei_array = qmi_wlanfw_rf_board_info_s_v01_ei,
880 .data_type = QMI_OPT_FLAG,
881 .elem_len = 1,
882 .elem_size = sizeof(u8),
883 .array_type = NO_ARRAY,
884 .tlv_type = 0x12,
885 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
886 soc_info_valid),
889 .data_type = QMI_STRUCT,
890 .elem_len = 1,
891 .elem_size = sizeof(struct qmi_wlanfw_soc_info_s_v01),
892 .array_type = NO_ARRAY,
893 .tlv_type = 0x12,
894 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
895 soc_info),
896 .ei_array = qmi_wlanfw_soc_info_s_v01_ei,
899 .data_type = QMI_OPT_FLAG,
900 .elem_len = 1,
901 .elem_size = sizeof(u8),
902 .array_type = NO_ARRAY,
903 .tlv_type = 0x13,
904 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
905 fw_version_info_valid),
908 .data_type = QMI_STRUCT,
909 .elem_len = 1,
910 .elem_size = sizeof(struct qmi_wlanfw_fw_version_info_s_v01),
911 .array_type = NO_ARRAY,
912 .tlv_type = 0x13,
913 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
914 fw_version_info),
915 .ei_array = qmi_wlanfw_fw_version_info_s_v01_ei,
918 .data_type = QMI_OPT_FLAG,
919 .elem_len = 1,
920 .elem_size = sizeof(u8),
921 .array_type = NO_ARRAY,
922 .tlv_type = 0x14,
923 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
924 fw_build_id_valid),
927 .data_type = QMI_STRING,
928 .elem_len = ATH11K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 + 1,
929 .elem_size = sizeof(char),
930 .array_type = NO_ARRAY,
931 .tlv_type = 0x14,
932 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
933 fw_build_id),
936 .data_type = QMI_OPT_FLAG,
937 .elem_len = 1,
938 .elem_size = sizeof(u8),
939 .array_type = NO_ARRAY,
940 .tlv_type = 0x15,
941 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
942 num_macs_valid),
945 .data_type = QMI_UNSIGNED_1_BYTE,
946 .elem_len = 1,
947 .elem_size = sizeof(u8),
948 .array_type = NO_ARRAY,
949 .tlv_type = 0x15,
950 .offset = offsetof(struct qmi_wlanfw_cap_resp_msg_v01,
951 num_macs),
954 .data_type = QMI_EOTI,
955 .array_type = NO_ARRAY,
956 .tlv_type = QMI_COMMON_TLV_TYPE,
960 static struct qmi_elem_info qmi_wlanfw_bdf_download_req_msg_v01_ei[] = {
962 .data_type = QMI_UNSIGNED_1_BYTE,
963 .elem_len = 1,
964 .elem_size = sizeof(u8),
965 .array_type = NO_ARRAY,
966 .tlv_type = 0x01,
967 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
968 valid),
971 .data_type = QMI_OPT_FLAG,
972 .elem_len = 1,
973 .elem_size = sizeof(u8),
974 .array_type = NO_ARRAY,
975 .tlv_type = 0x10,
976 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
977 file_id_valid),
980 .data_type = QMI_SIGNED_4_BYTE_ENUM,
981 .elem_len = 1,
982 .elem_size = sizeof(enum qmi_wlanfw_cal_temp_id_enum_v01),
983 .array_type = NO_ARRAY,
984 .tlv_type = 0x10,
985 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
986 file_id),
989 .data_type = QMI_OPT_FLAG,
990 .elem_len = 1,
991 .elem_size = sizeof(u8),
992 .array_type = NO_ARRAY,
993 .tlv_type = 0x11,
994 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
995 total_size_valid),
998 .data_type = QMI_UNSIGNED_4_BYTE,
999 .elem_len = 1,
1000 .elem_size = sizeof(u32),
1001 .array_type = NO_ARRAY,
1002 .tlv_type = 0x11,
1003 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
1004 total_size),
1007 .data_type = QMI_OPT_FLAG,
1008 .elem_len = 1,
1009 .elem_size = sizeof(u8),
1010 .array_type = NO_ARRAY,
1011 .tlv_type = 0x12,
1012 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
1013 seg_id_valid),
1016 .data_type = QMI_UNSIGNED_4_BYTE,
1017 .elem_len = 1,
1018 .elem_size = sizeof(u32),
1019 .array_type = NO_ARRAY,
1020 .tlv_type = 0x12,
1021 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
1022 seg_id),
1025 .data_type = QMI_OPT_FLAG,
1026 .elem_len = 1,
1027 .elem_size = sizeof(u8),
1028 .array_type = NO_ARRAY,
1029 .tlv_type = 0x13,
1030 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
1031 data_valid),
1034 .data_type = QMI_DATA_LEN,
1035 .elem_len = 1,
1036 .elem_size = sizeof(u16),
1037 .array_type = NO_ARRAY,
1038 .tlv_type = 0x13,
1039 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
1040 data_len),
1043 .data_type = QMI_UNSIGNED_1_BYTE,
1044 .elem_len = QMI_WLANFW_MAX_DATA_SIZE_V01,
1045 .elem_size = sizeof(u8),
1046 .array_type = VAR_LEN_ARRAY,
1047 .tlv_type = 0x13,
1048 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
1049 data),
1052 .data_type = QMI_OPT_FLAG,
1053 .elem_len = 1,
1054 .elem_size = sizeof(u8),
1055 .array_type = NO_ARRAY,
1056 .tlv_type = 0x14,
1057 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
1058 end_valid),
1061 .data_type = QMI_UNSIGNED_1_BYTE,
1062 .elem_len = 1,
1063 .elem_size = sizeof(u8),
1064 .array_type = NO_ARRAY,
1065 .tlv_type = 0x14,
1066 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
1067 end),
1070 .data_type = QMI_OPT_FLAG,
1071 .elem_len = 1,
1072 .elem_size = sizeof(u8),
1073 .array_type = NO_ARRAY,
1074 .tlv_type = 0x15,
1075 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
1076 bdf_type_valid),
1079 .data_type = QMI_UNSIGNED_1_BYTE,
1080 .elem_len = 1,
1081 .elem_size = sizeof(u8),
1082 .array_type = NO_ARRAY,
1083 .tlv_type = 0x15,
1084 .offset = offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01,
1085 bdf_type),
1089 .data_type = QMI_EOTI,
1090 .array_type = NO_ARRAY,
1091 .tlv_type = QMI_COMMON_TLV_TYPE,
1095 static struct qmi_elem_info qmi_wlanfw_bdf_download_resp_msg_v01_ei[] = {
1097 .data_type = QMI_STRUCT,
1098 .elem_len = 1,
1099 .elem_size = sizeof(struct qmi_response_type_v01),
1100 .array_type = NO_ARRAY,
1101 .tlv_type = 0x02,
1102 .offset = offsetof(struct qmi_wlanfw_bdf_download_resp_msg_v01,
1103 resp),
1104 .ei_array = qmi_response_type_v01_ei,
1107 .data_type = QMI_EOTI,
1108 .array_type = NO_ARRAY,
1109 .tlv_type = QMI_COMMON_TLV_TYPE,
1113 static struct qmi_elem_info qmi_wlanfw_m3_info_req_msg_v01_ei[] = {
1115 .data_type = QMI_UNSIGNED_8_BYTE,
1116 .elem_len = 1,
1117 .elem_size = sizeof(u64),
1118 .array_type = NO_ARRAY,
1119 .tlv_type = 0x01,
1120 .offset = offsetof(struct qmi_wlanfw_m3_info_req_msg_v01, addr),
1123 .data_type = QMI_UNSIGNED_4_BYTE,
1124 .elem_len = 1,
1125 .elem_size = sizeof(u32),
1126 .array_type = NO_ARRAY,
1127 .tlv_type = 0x02,
1128 .offset = offsetof(struct qmi_wlanfw_m3_info_req_msg_v01, size),
1131 .data_type = QMI_EOTI,
1132 .array_type = NO_ARRAY,
1133 .tlv_type = QMI_COMMON_TLV_TYPE,
1137 static struct qmi_elem_info qmi_wlanfw_m3_info_resp_msg_v01_ei[] = {
1139 .data_type = QMI_STRUCT,
1140 .elem_len = 1,
1141 .elem_size = sizeof(struct qmi_response_type_v01),
1142 .array_type = NO_ARRAY,
1143 .tlv_type = 0x02,
1144 .offset = offsetof(struct qmi_wlanfw_m3_info_resp_msg_v01, resp),
1145 .ei_array = qmi_response_type_v01_ei,
1148 .data_type = QMI_EOTI,
1149 .array_type = NO_ARRAY,
1150 .tlv_type = QMI_COMMON_TLV_TYPE,
1154 static struct qmi_elem_info qmi_wlanfw_ce_tgt_pipe_cfg_s_v01_ei[] = {
1156 .data_type = QMI_UNSIGNED_4_BYTE,
1157 .elem_len = 1,
1158 .elem_size = sizeof(u32),
1159 .array_type = NO_ARRAY,
1160 .tlv_type = 0,
1161 .offset = offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01,
1162 pipe_num),
1165 .data_type = QMI_SIGNED_4_BYTE_ENUM,
1166 .elem_len = 1,
1167 .elem_size = sizeof(enum qmi_wlanfw_pipedir_enum_v01),
1168 .array_type = NO_ARRAY,
1169 .tlv_type = 0,
1170 .offset = offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01,
1171 pipe_dir),
1174 .data_type = QMI_UNSIGNED_4_BYTE,
1175 .elem_len = 1,
1176 .elem_size = sizeof(u32),
1177 .array_type = NO_ARRAY,
1178 .tlv_type = 0,
1179 .offset = offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01,
1180 nentries),
1183 .data_type = QMI_UNSIGNED_4_BYTE,
1184 .elem_len = 1,
1185 .elem_size = sizeof(u32),
1186 .array_type = NO_ARRAY,
1187 .tlv_type = 0,
1188 .offset = offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01,
1189 nbytes_max),
1192 .data_type = QMI_UNSIGNED_4_BYTE,
1193 .elem_len = 1,
1194 .elem_size = sizeof(u32),
1195 .array_type = NO_ARRAY,
1196 .tlv_type = 0,
1197 .offset = offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01,
1198 flags),
1201 .data_type = QMI_EOTI,
1202 .array_type = NO_ARRAY,
1203 .tlv_type = QMI_COMMON_TLV_TYPE,
1207 static struct qmi_elem_info qmi_wlanfw_ce_svc_pipe_cfg_s_v01_ei[] = {
1209 .data_type = QMI_UNSIGNED_4_BYTE,
1210 .elem_len = 1,
1211 .elem_size = sizeof(u32),
1212 .array_type = NO_ARRAY,
1213 .tlv_type = 0,
1214 .offset = offsetof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01,
1215 service_id),
1218 .data_type = QMI_SIGNED_4_BYTE_ENUM,
1219 .elem_len = 1,
1220 .elem_size = sizeof(enum qmi_wlanfw_pipedir_enum_v01),
1221 .array_type = NO_ARRAY,
1222 .tlv_type = 0,
1223 .offset = offsetof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01,
1224 pipe_dir),
1227 .data_type = QMI_UNSIGNED_4_BYTE,
1228 .elem_len = 1,
1229 .elem_size = sizeof(u32),
1230 .array_type = NO_ARRAY,
1231 .tlv_type = 0,
1232 .offset = offsetof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01,
1233 pipe_num),
1236 .data_type = QMI_EOTI,
1237 .array_type = NO_ARRAY,
1238 .tlv_type = QMI_COMMON_TLV_TYPE,
1242 static struct qmi_elem_info qmi_wlanfw_shadow_reg_cfg_s_v01_ei[] = {
1244 .data_type = QMI_UNSIGNED_2_BYTE,
1245 .elem_len = 1,
1246 .elem_size = sizeof(u16),
1247 .array_type = NO_ARRAY,
1248 .tlv_type = 0,
1249 .offset = offsetof(struct qmi_wlanfw_shadow_reg_cfg_s_v01, id),
1252 .data_type = QMI_UNSIGNED_2_BYTE,
1253 .elem_len = 1,
1254 .elem_size = sizeof(u16),
1255 .array_type = NO_ARRAY,
1256 .tlv_type = 0,
1257 .offset = offsetof(struct qmi_wlanfw_shadow_reg_cfg_s_v01,
1258 offset),
1261 .data_type = QMI_EOTI,
1262 .array_type = QMI_COMMON_TLV_TYPE,
1266 static struct qmi_elem_info qmi_wlanfw_shadow_reg_v2_cfg_s_v01_ei[] = {
1268 .data_type = QMI_UNSIGNED_4_BYTE,
1269 .elem_len = 1,
1270 .elem_size = sizeof(u32),
1271 .array_type = NO_ARRAY,
1272 .tlv_type = 0,
1273 .offset = offsetof(struct qmi_wlanfw_shadow_reg_v2_cfg_s_v01,
1274 addr),
1277 .data_type = QMI_EOTI,
1278 .array_type = NO_ARRAY,
1279 .tlv_type = QMI_COMMON_TLV_TYPE,
1283 static struct qmi_elem_info qmi_wlanfw_wlan_mode_req_msg_v01_ei[] = {
1285 .data_type = QMI_UNSIGNED_4_BYTE,
1286 .elem_len = 1,
1287 .elem_size = sizeof(u32),
1288 .array_type = NO_ARRAY,
1289 .tlv_type = 0x01,
1290 .offset = offsetof(struct qmi_wlanfw_wlan_mode_req_msg_v01,
1291 mode),
1294 .data_type = QMI_OPT_FLAG,
1295 .elem_len = 1,
1296 .elem_size = sizeof(u8),
1297 .array_type = NO_ARRAY,
1298 .tlv_type = 0x10,
1299 .offset = offsetof(struct qmi_wlanfw_wlan_mode_req_msg_v01,
1300 hw_debug_valid),
1303 .data_type = QMI_UNSIGNED_1_BYTE,
1304 .elem_len = 1,
1305 .elem_size = sizeof(u8),
1306 .array_type = NO_ARRAY,
1307 .tlv_type = 0x10,
1308 .offset = offsetof(struct qmi_wlanfw_wlan_mode_req_msg_v01,
1309 hw_debug),
1312 .data_type = QMI_EOTI,
1313 .array_type = NO_ARRAY,
1314 .tlv_type = QMI_COMMON_TLV_TYPE,
1318 static struct qmi_elem_info qmi_wlanfw_wlan_mode_resp_msg_v01_ei[] = {
1320 .data_type = QMI_STRUCT,
1321 .elem_len = 1,
1322 .elem_size = sizeof(struct qmi_response_type_v01),
1323 .array_type = NO_ARRAY,
1324 .tlv_type = 0x02,
1325 .offset = offsetof(struct qmi_wlanfw_wlan_mode_resp_msg_v01,
1326 resp),
1327 .ei_array = qmi_response_type_v01_ei,
1330 .data_type = QMI_EOTI,
1331 .array_type = NO_ARRAY,
1332 .tlv_type = QMI_COMMON_TLV_TYPE,
1336 static struct qmi_elem_info qmi_wlanfw_wlan_cfg_req_msg_v01_ei[] = {
1338 .data_type = QMI_OPT_FLAG,
1339 .elem_len = 1,
1340 .elem_size = sizeof(u8),
1341 .array_type = NO_ARRAY,
1342 .tlv_type = 0x10,
1343 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1344 host_version_valid),
1347 .data_type = QMI_STRING,
1348 .elem_len = QMI_WLANFW_MAX_STR_LEN_V01 + 1,
1349 .elem_size = sizeof(char),
1350 .array_type = NO_ARRAY,
1351 .tlv_type = 0x10,
1352 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1353 host_version),
1356 .data_type = QMI_OPT_FLAG,
1357 .elem_len = 1,
1358 .elem_size = sizeof(u8),
1359 .array_type = NO_ARRAY,
1360 .tlv_type = 0x11,
1361 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1362 tgt_cfg_valid),
1365 .data_type = QMI_DATA_LEN,
1366 .elem_len = 1,
1367 .elem_size = sizeof(u8),
1368 .array_type = NO_ARRAY,
1369 .tlv_type = 0x11,
1370 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1371 tgt_cfg_len),
1374 .data_type = QMI_STRUCT,
1375 .elem_len = QMI_WLANFW_MAX_NUM_CE_V01,
1376 .elem_size = sizeof(
1377 struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01),
1378 .array_type = VAR_LEN_ARRAY,
1379 .tlv_type = 0x11,
1380 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1381 tgt_cfg),
1382 .ei_array = qmi_wlanfw_ce_tgt_pipe_cfg_s_v01_ei,
1385 .data_type = QMI_OPT_FLAG,
1386 .elem_len = 1,
1387 .elem_size = sizeof(u8),
1388 .array_type = NO_ARRAY,
1389 .tlv_type = 0x12,
1390 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1391 svc_cfg_valid),
1394 .data_type = QMI_DATA_LEN,
1395 .elem_len = 1,
1396 .elem_size = sizeof(u8),
1397 .array_type = NO_ARRAY,
1398 .tlv_type = 0x12,
1399 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1400 svc_cfg_len),
1403 .data_type = QMI_STRUCT,
1404 .elem_len = QMI_WLANFW_MAX_NUM_SVC_V01,
1405 .elem_size = sizeof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01),
1406 .array_type = VAR_LEN_ARRAY,
1407 .tlv_type = 0x12,
1408 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1409 svc_cfg),
1410 .ei_array = qmi_wlanfw_ce_svc_pipe_cfg_s_v01_ei,
1413 .data_type = QMI_OPT_FLAG,
1414 .elem_len = 1,
1415 .elem_size = sizeof(u8),
1416 .array_type = NO_ARRAY,
1417 .tlv_type = 0x13,
1418 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1419 shadow_reg_valid),
1422 .data_type = QMI_DATA_LEN,
1423 .elem_len = 1,
1424 .elem_size = sizeof(u8),
1425 .array_type = NO_ARRAY,
1426 .tlv_type = 0x13,
1427 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1428 shadow_reg_len),
1431 .data_type = QMI_STRUCT,
1432 .elem_len = QMI_WLANFW_MAX_NUM_SHADOW_REG_V01,
1433 .elem_size = sizeof(struct qmi_wlanfw_shadow_reg_cfg_s_v01),
1434 .array_type = VAR_LEN_ARRAY,
1435 .tlv_type = 0x13,
1436 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1437 shadow_reg),
1438 .ei_array = qmi_wlanfw_shadow_reg_cfg_s_v01_ei,
1441 .data_type = QMI_OPT_FLAG,
1442 .elem_len = 1,
1443 .elem_size = sizeof(u8),
1444 .array_type = NO_ARRAY,
1445 .tlv_type = 0x14,
1446 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1447 shadow_reg_v2_valid),
1450 .data_type = QMI_DATA_LEN,
1451 .elem_len = 1,
1452 .elem_size = sizeof(u8),
1453 .array_type = NO_ARRAY,
1454 .tlv_type = 0x14,
1455 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1456 shadow_reg_v2_len),
1459 .data_type = QMI_STRUCT,
1460 .elem_len = QMI_WLANFW_MAX_NUM_SHADOW_REG_V2_V01,
1461 .elem_size = sizeof(struct qmi_wlanfw_shadow_reg_v2_cfg_s_v01),
1462 .array_type = VAR_LEN_ARRAY,
1463 .tlv_type = 0x14,
1464 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01,
1465 shadow_reg_v2),
1466 .ei_array = qmi_wlanfw_shadow_reg_v2_cfg_s_v01_ei,
1469 .data_type = QMI_EOTI,
1470 .array_type = NO_ARRAY,
1471 .tlv_type = QMI_COMMON_TLV_TYPE,
1475 static struct qmi_elem_info qmi_wlanfw_wlan_cfg_resp_msg_v01_ei[] = {
1477 .data_type = QMI_STRUCT,
1478 .elem_len = 1,
1479 .elem_size = sizeof(struct qmi_response_type_v01),
1480 .array_type = NO_ARRAY,
1481 .tlv_type = 0x02,
1482 .offset = offsetof(struct qmi_wlanfw_wlan_cfg_resp_msg_v01, resp),
1483 .ei_array = qmi_response_type_v01_ei,
1486 .data_type = QMI_EOTI,
1487 .array_type = NO_ARRAY,
1488 .tlv_type = QMI_COMMON_TLV_TYPE,
1492 static struct qmi_elem_info qmi_wlanfw_mem_ready_ind_msg_v01_ei[] = {
1494 .data_type = QMI_EOTI,
1495 .array_type = NO_ARRAY,
1499 static struct qmi_elem_info qmi_wlanfw_fw_ready_ind_msg_v01_ei[] = {
1501 .data_type = QMI_EOTI,
1502 .array_type = NO_ARRAY,
1506 static struct qmi_elem_info qmi_wlanfw_cold_boot_cal_done_ind_msg_v01_ei[] = {
1508 .data_type = QMI_EOTI,
1509 .array_type = NO_ARRAY,
1513 static int ath11k_qmi_host_cap_send(struct ath11k_base *ab)
1515 struct qmi_wlanfw_host_cap_req_msg_v01 req;
1516 struct qmi_wlanfw_host_cap_resp_msg_v01 resp;
1517 struct qmi_txn txn = {};
1518 int ret = 0;
1520 memset(&req, 0, sizeof(req));
1521 memset(&resp, 0, sizeof(resp));
1523 req.num_clients_valid = 1;
1524 req.num_clients = 1;
1525 req.mem_cfg_mode = ab->qmi.target_mem_mode;
1526 req.mem_cfg_mode_valid = 1;
1527 req.bdf_support_valid = 1;
1528 req.bdf_support = 1;
1530 if (ab->bus_params.m3_fw_support) {
1531 req.m3_support_valid = 1;
1532 req.m3_support = 1;
1533 req.m3_cache_support_valid = 1;
1534 req.m3_cache_support = 1;
1535 } else {
1536 req.m3_support_valid = 0;
1537 req.m3_support = 0;
1538 req.m3_cache_support_valid = 0;
1539 req.m3_cache_support = 0;
1542 req.cal_done_valid = 1;
1543 req.cal_done = ab->qmi.cal_done;
1545 if (ab->hw_params.internal_sleep_clock) {
1546 req.nm_modem_valid = 1;
1548 /* Notify firmware that this is non-qualcomm platform. */
1549 req.nm_modem |= HOST_CSTATE_BIT;
1551 /* Notify firmware about the sleep clock selection,
1552 * nm_modem_bit[1] is used for this purpose. Host driver on
1553 * non-qualcomm platforms should select internal sleep
1554 * clock.
1556 req.nm_modem |= SLEEP_CLOCK_SELECT_INTERNAL_BIT;
1559 ret = qmi_txn_init(&ab->qmi.handle, &txn,
1560 qmi_wlanfw_host_cap_resp_msg_v01_ei, &resp);
1561 if (ret < 0)
1562 goto out;
1564 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
1565 QMI_WLANFW_HOST_CAP_REQ_V01,
1566 QMI_WLANFW_HOST_CAP_REQ_MSG_V01_MAX_LEN,
1567 qmi_wlanfw_host_cap_req_msg_v01_ei, &req);
1568 if (ret < 0) {
1569 ath11k_warn(ab, "Failed to send host capability request,err = %d\n", ret);
1570 goto out;
1573 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS));
1574 if (ret < 0)
1575 goto out;
1577 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
1578 ath11k_warn(ab, "Host capability request failed, result: %d, err: %d\n",
1579 resp.resp.result, resp.resp.error);
1580 ret = -EINVAL;
1581 goto out;
1584 out:
1585 return ret;
1588 static int ath11k_qmi_fw_ind_register_send(struct ath11k_base *ab)
1590 struct qmi_wlanfw_ind_register_req_msg_v01 *req;
1591 struct qmi_wlanfw_ind_register_resp_msg_v01 *resp;
1592 struct qmi_handle *handle = &ab->qmi.handle;
1593 struct qmi_txn txn;
1594 int ret;
1596 req = kzalloc(sizeof(*req), GFP_KERNEL);
1597 if (!req)
1598 return -ENOMEM;
1600 resp = kzalloc(sizeof(*resp), GFP_KERNEL);
1601 if (!resp) {
1602 ret = -ENOMEM;
1603 goto resp_out;
1606 req->client_id_valid = 1;
1607 req->client_id = QMI_WLANFW_CLIENT_ID;
1608 req->fw_ready_enable_valid = 1;
1609 req->fw_ready_enable = 1;
1610 req->request_mem_enable_valid = 1;
1611 req->request_mem_enable = 1;
1612 req->fw_mem_ready_enable_valid = 1;
1613 req->fw_mem_ready_enable = 1;
1614 req->cal_done_enable_valid = 1;
1615 req->cal_done_enable = 1;
1616 req->fw_init_done_enable_valid = 1;
1617 req->fw_init_done_enable = 1;
1619 req->pin_connect_result_enable_valid = 0;
1620 req->pin_connect_result_enable = 0;
1622 ret = qmi_txn_init(handle, &txn,
1623 qmi_wlanfw_ind_register_resp_msg_v01_ei, resp);
1624 if (ret < 0)
1625 goto out;
1627 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
1628 QMI_WLANFW_IND_REGISTER_REQ_V01,
1629 QMI_WLANFW_IND_REGISTER_REQ_MSG_V01_MAX_LEN,
1630 qmi_wlanfw_ind_register_req_msg_v01_ei, req);
1631 if (ret < 0) {
1632 ath11k_warn(ab, "Failed to send indication register request, err = %d\n",
1633 ret);
1634 goto out;
1637 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS));
1638 if (ret < 0) {
1639 ath11k_warn(ab, "failed to register fw indication %d\n", ret);
1640 goto out;
1643 if (resp->resp.result != QMI_RESULT_SUCCESS_V01) {
1644 ath11k_warn(ab, "FW Ind register request failed, result: %d, err: %d\n",
1645 resp->resp.result, resp->resp.error);
1646 ret = -EINVAL;
1647 goto out;
1650 out:
1651 kfree(resp);
1652 resp_out:
1653 kfree(req);
1654 return ret;
1657 static int ath11k_qmi_respond_fw_mem_request(struct ath11k_base *ab)
1659 struct qmi_wlanfw_respond_mem_req_msg_v01 *req;
1660 struct qmi_wlanfw_respond_mem_resp_msg_v01 resp;
1661 struct qmi_txn txn = {};
1662 int ret = 0, i;
1663 bool delayed;
1665 req = kzalloc(sizeof(*req), GFP_KERNEL);
1666 if (!req)
1667 return -ENOMEM;
1669 memset(&resp, 0, sizeof(resp));
1671 /* For QCA6390 by default FW requests a block of ~4M contiguous
1672 * DMA memory, it's hard to allocate from OS. So host returns
1673 * failure to FW and FW will then request mulitple blocks of small
1674 * chunk size memory.
1676 if (!ab->bus_params.fixed_mem_region && ab->qmi.target_mem_delayed) {
1677 delayed = true;
1678 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi delays mem_request %d\n",
1679 ab->qmi.mem_seg_count);
1680 memset(req, 0, sizeof(*req));
1681 } else {
1682 delayed = false;
1683 req->mem_seg_len = ab->qmi.mem_seg_count;
1685 for (i = 0; i < req->mem_seg_len ; i++) {
1686 req->mem_seg[i].addr = ab->qmi.target_mem[i].paddr;
1687 req->mem_seg[i].size = ab->qmi.target_mem[i].size;
1688 req->mem_seg[i].type = ab->qmi.target_mem[i].type;
1692 ret = qmi_txn_init(&ab->qmi.handle, &txn,
1693 qmi_wlanfw_respond_mem_resp_msg_v01_ei, &resp);
1694 if (ret < 0)
1695 goto out;
1697 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
1698 QMI_WLANFW_RESPOND_MEM_REQ_V01,
1699 QMI_WLANFW_RESPOND_MEM_REQ_MSG_V01_MAX_LEN,
1700 qmi_wlanfw_respond_mem_req_msg_v01_ei, req);
1701 if (ret < 0) {
1702 ath11k_warn(ab, "qmi failed to respond memory request, err = %d\n",
1703 ret);
1704 goto out;
1707 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS));
1708 if (ret < 0) {
1709 ath11k_warn(ab, "qmi failed memory request, err = %d\n", ret);
1710 goto out;
1713 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
1714 /* the error response is expected when
1715 * target_mem_delayed is true.
1717 if (delayed && resp.resp.error == 0)
1718 goto out;
1720 ath11k_warn(ab, "Respond mem req failed, result: %d, err: %d\n",
1721 resp.resp.result, resp.resp.error);
1722 ret = -EINVAL;
1723 goto out;
1725 out:
1726 kfree(req);
1727 return ret;
1730 static void ath11k_qmi_free_target_mem_chunk(struct ath11k_base *ab)
1732 int i;
1734 if (ab->bus_params.fixed_mem_region)
1735 return;
1737 for (i = 0; i < ab->qmi.mem_seg_count; i++) {
1738 if (!ab->qmi.target_mem[i].vaddr)
1739 continue;
1741 dma_free_coherent(ab->dev,
1742 ab->qmi.target_mem[i].size,
1743 ab->qmi.target_mem[i].vaddr,
1744 ab->qmi.target_mem[i].paddr);
1745 ab->qmi.target_mem[i].vaddr = NULL;
1749 static int ath11k_qmi_alloc_target_mem_chunk(struct ath11k_base *ab)
1751 int i;
1752 struct target_mem_chunk *chunk;
1754 ab->qmi.target_mem_delayed = false;
1756 for (i = 0; i < ab->qmi.mem_seg_count; i++) {
1757 chunk = &ab->qmi.target_mem[i];
1758 chunk->vaddr = dma_alloc_coherent(ab->dev,
1759 chunk->size,
1760 &chunk->paddr,
1761 GFP_KERNEL);
1762 if (!chunk->vaddr) {
1763 if (ab->qmi.mem_seg_count <= 2) {
1764 ath11k_dbg(ab, ATH11K_DBG_QMI,
1765 "qmi dma allocation failed (%d B type %u), will try later with small size\n",
1766 chunk->size,
1767 chunk->type);
1768 ath11k_qmi_free_target_mem_chunk(ab);
1769 ab->qmi.target_mem_delayed = true;
1770 return 0;
1772 ath11k_err(ab, "failed to alloc memory, size: 0x%x, type: %u\n",
1773 chunk->size,
1774 chunk->type);
1775 return -EINVAL;
1779 return 0;
1782 static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base *ab)
1784 int i, idx;
1786 for (i = 0, idx = 0; i < ab->qmi.mem_seg_count; i++) {
1787 switch (ab->qmi.target_mem[i].type) {
1788 case BDF_MEM_REGION_TYPE:
1789 ab->qmi.target_mem[idx].paddr = ab->hw_params.bdf_addr;
1790 ab->qmi.target_mem[idx].vaddr = NULL;
1791 ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size;
1792 ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type;
1793 idx++;
1794 break;
1795 case CALDB_MEM_REGION_TYPE:
1796 if (ab->qmi.target_mem[i].size > ATH11K_QMI_CALDB_SIZE) {
1797 ath11k_warn(ab, "qmi mem size is low to load caldata\n");
1798 return -EINVAL;
1801 if (ath11k_cold_boot_cal && ab->hw_params.cold_boot_calib) {
1802 ab->qmi.target_mem[idx].paddr =
1803 ATH11K_QMI_CALDB_ADDRESS;
1804 ab->qmi.target_mem[idx].vaddr =
1805 (void *)ATH11K_QMI_CALDB_ADDRESS;
1806 } else {
1807 ab->qmi.target_mem[idx].paddr = 0;
1808 ab->qmi.target_mem[idx].vaddr = NULL;
1810 ab->qmi.target_mem[idx].size = ab->qmi.target_mem[i].size;
1811 ab->qmi.target_mem[idx].type = ab->qmi.target_mem[i].type;
1812 idx++;
1813 break;
1814 default:
1815 ath11k_warn(ab, "qmi ignore invalid mem req type %d\n",
1816 ab->qmi.target_mem[i].type);
1817 break;
1820 ab->qmi.mem_seg_count = idx;
1822 return 0;
1825 static int ath11k_qmi_request_target_cap(struct ath11k_base *ab)
1827 struct qmi_wlanfw_cap_req_msg_v01 req;
1828 struct qmi_wlanfw_cap_resp_msg_v01 resp;
1829 struct qmi_txn txn = {};
1830 int ret = 0;
1831 int r;
1833 memset(&req, 0, sizeof(req));
1834 memset(&resp, 0, sizeof(resp));
1836 ret = qmi_txn_init(&ab->qmi.handle, &txn,
1837 qmi_wlanfw_cap_resp_msg_v01_ei, &resp);
1838 if (ret < 0)
1839 goto out;
1841 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
1842 QMI_WLANFW_CAP_REQ_V01,
1843 QMI_WLANFW_CAP_REQ_MSG_V01_MAX_LEN,
1844 qmi_wlanfw_cap_req_msg_v01_ei, &req);
1845 if (ret < 0) {
1846 ath11k_warn(ab, "qmi failed to send target cap request, err = %d\n",
1847 ret);
1848 goto out;
1851 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS));
1852 if (ret < 0) {
1853 ath11k_warn(ab, "qmi failed target cap request %d\n", ret);
1854 goto out;
1857 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
1858 ath11k_warn(ab, "qmi targetcap req failed, result: %d, err: %d\n",
1859 resp.resp.result, resp.resp.error);
1860 ret = -EINVAL;
1861 goto out;
1864 if (resp.chip_info_valid) {
1865 ab->qmi.target.chip_id = resp.chip_info.chip_id;
1866 ab->qmi.target.chip_family = resp.chip_info.chip_family;
1869 if (resp.board_info_valid)
1870 ab->qmi.target.board_id = resp.board_info.board_id;
1871 else
1872 ab->qmi.target.board_id = 0xFF;
1874 if (resp.soc_info_valid)
1875 ab->qmi.target.soc_id = resp.soc_info.soc_id;
1877 if (resp.fw_version_info_valid) {
1878 ab->qmi.target.fw_version = resp.fw_version_info.fw_version;
1879 strlcpy(ab->qmi.target.fw_build_timestamp,
1880 resp.fw_version_info.fw_build_timestamp,
1881 sizeof(ab->qmi.target.fw_build_timestamp));
1884 if (resp.fw_build_id_valid)
1885 strlcpy(ab->qmi.target.fw_build_id, resp.fw_build_id,
1886 sizeof(ab->qmi.target.fw_build_id));
1888 ath11k_info(ab, "chip_id 0x%x chip_family 0x%x board_id 0x%x soc_id 0x%x\n",
1889 ab->qmi.target.chip_id, ab->qmi.target.chip_family,
1890 ab->qmi.target.board_id, ab->qmi.target.soc_id);
1892 ath11k_info(ab, "fw_version 0x%x fw_build_timestamp %s fw_build_id %s",
1893 ab->qmi.target.fw_version,
1894 ab->qmi.target.fw_build_timestamp,
1895 ab->qmi.target.fw_build_id);
1897 r = ath11k_core_check_dt(ab);
1898 if (r)
1899 ath11k_dbg(ab, ATH11K_DBG_QMI, "DT bdf variant name not set.\n");
1901 out:
1902 return ret;
1905 static int
1906 ath11k_qmi_prepare_bdf_download(struct ath11k_base *ab, int type,
1907 struct qmi_wlanfw_bdf_download_req_msg_v01 *req,
1908 void __iomem *bdf_addr)
1910 const struct firmware *fw_entry;
1911 struct ath11k_board_data bd;
1912 u32 fw_size;
1913 int ret;
1915 switch (type) {
1916 case ATH11K_QMI_FILE_TYPE_BDF_GOLDEN:
1917 memset(&bd, 0, sizeof(bd));
1919 ret = ath11k_core_fetch_bdf(ab, &bd);
1920 if (ret) {
1921 ath11k_warn(ab, "qmi failed to load BDF\n");
1922 return ret;
1925 fw_size = min_t(u32, ab->hw_params.fw.board_size, bd.len);
1926 memcpy_toio(bdf_addr, bd.data, fw_size);
1927 ath11k_core_free_bdf(ab, &bd);
1928 break;
1929 case ATH11K_QMI_FILE_TYPE_CALDATA:
1930 fw_entry = ath11k_core_firmware_request(ab, ATH11K_DEFAULT_CAL_FILE);
1931 if (IS_ERR(fw_entry)) {
1932 ret = PTR_ERR(fw_entry);
1933 ath11k_warn(ab, "failed to load %s: %d\n",
1934 ATH11K_DEFAULT_CAL_FILE, ret);
1935 return ret;
1938 fw_size = min_t(u32, ab->hw_params.fw.board_size,
1939 fw_entry->size);
1941 memcpy_toio(bdf_addr + ATH11K_QMI_CALDATA_OFFSET,
1942 fw_entry->data, fw_size);
1944 release_firmware(fw_entry);
1945 break;
1946 default:
1947 return -EINVAL;
1950 req->total_size = fw_size;
1951 return 0;
1954 static int ath11k_qmi_load_bdf_fixed_addr(struct ath11k_base *ab)
1956 struct qmi_wlanfw_bdf_download_req_msg_v01 *req;
1957 struct qmi_wlanfw_bdf_download_resp_msg_v01 resp;
1958 struct qmi_txn txn = {};
1959 void __iomem *bdf_addr = NULL;
1960 int type, ret;
1962 req = kzalloc(sizeof(*req), GFP_KERNEL);
1963 if (!req)
1964 return -ENOMEM;
1965 memset(&resp, 0, sizeof(resp));
1967 bdf_addr = ioremap(ab->hw_params.bdf_addr, ATH11K_QMI_BDF_MAX_SIZE);
1968 if (!bdf_addr) {
1969 ath11k_warn(ab, "qmi ioremap error for BDF\n");
1970 ret = -EIO;
1971 goto out;
1974 for (type = 0; type < ATH11K_QMI_MAX_FILE_TYPE; type++) {
1975 req->valid = 1;
1976 req->file_id_valid = 1;
1977 req->file_id = ab->qmi.target.board_id;
1978 req->total_size_valid = 1;
1979 req->seg_id_valid = 1;
1980 req->seg_id = type;
1981 req->data_valid = 0;
1982 req->data_len = ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE;
1983 req->bdf_type = 0;
1984 req->bdf_type_valid = 0;
1985 req->end_valid = 1;
1986 req->end = 1;
1988 ret = ath11k_qmi_prepare_bdf_download(ab, type, req, bdf_addr);
1989 if (ret < 0)
1990 goto out_qmi_bdf;
1992 ret = qmi_txn_init(&ab->qmi.handle, &txn,
1993 qmi_wlanfw_bdf_download_resp_msg_v01_ei,
1994 &resp);
1995 if (ret < 0)
1996 goto out_qmi_bdf;
1998 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
1999 QMI_WLANFW_BDF_DOWNLOAD_REQ_V01,
2000 QMI_WLANFW_BDF_DOWNLOAD_REQ_MSG_V01_MAX_LEN,
2001 qmi_wlanfw_bdf_download_req_msg_v01_ei, req);
2002 if (ret < 0) {
2003 qmi_txn_cancel(&txn);
2004 goto out_qmi_bdf;
2007 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS));
2008 if (ret < 0)
2009 goto out_qmi_bdf;
2011 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
2012 ath11k_warn(ab, "qmi BDF download failed, result: %d, err: %d\n",
2013 resp.resp.result, resp.resp.error);
2014 ret = -EINVAL;
2015 goto out_qmi_bdf;
2019 out_qmi_bdf:
2020 iounmap(bdf_addr);
2021 out:
2022 kfree(req);
2023 return ret;
2026 static int ath11k_qmi_load_bdf_qmi(struct ath11k_base *ab)
2028 struct qmi_wlanfw_bdf_download_req_msg_v01 *req;
2029 struct qmi_wlanfw_bdf_download_resp_msg_v01 resp;
2030 struct ath11k_board_data bd;
2031 unsigned int remaining;
2032 struct qmi_txn txn = {};
2033 int ret;
2034 const u8 *temp;
2035 int bdf_type;
2037 req = kzalloc(sizeof(*req), GFP_KERNEL);
2038 if (!req)
2039 return -ENOMEM;
2040 memset(&resp, 0, sizeof(resp));
2042 memset(&bd, 0, sizeof(bd));
2043 ret = ath11k_core_fetch_bdf(ab, &bd);
2044 if (ret) {
2045 ath11k_warn(ab, "qmi failed to load bdf:\n");
2046 goto out;
2049 temp = bd.data;
2050 remaining = bd.len;
2052 if (bd.len >= SELFMAG && memcmp(bd.data, ELFMAG, SELFMAG) == 0)
2053 bdf_type = ATH11K_QMI_BDF_TYPE_ELF;
2054 else
2055 bdf_type = ATH11K_QMI_BDF_TYPE_BIN;
2057 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi bdf_type %d\n", bdf_type);
2059 while (remaining) {
2060 req->valid = 1;
2061 req->file_id_valid = 1;
2062 req->file_id = ab->qmi.target.board_id;
2063 req->total_size_valid = 1;
2064 req->total_size = bd.len;
2065 req->seg_id_valid = 1;
2066 req->data_valid = 1;
2067 req->data_len = ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE;
2068 req->bdf_type = bdf_type;
2069 req->bdf_type_valid = 1;
2070 req->end_valid = 1;
2071 req->end = 0;
2073 if (remaining > QMI_WLANFW_MAX_DATA_SIZE_V01) {
2074 req->data_len = QMI_WLANFW_MAX_DATA_SIZE_V01;
2075 } else {
2076 req->data_len = remaining;
2077 req->end = 1;
2080 memcpy(req->data, temp, req->data_len);
2082 ret = qmi_txn_init(&ab->qmi.handle, &txn,
2083 qmi_wlanfw_bdf_download_resp_msg_v01_ei,
2084 &resp);
2085 if (ret < 0)
2086 goto out_qmi_bdf;
2088 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
2089 QMI_WLANFW_BDF_DOWNLOAD_REQ_V01,
2090 QMI_WLANFW_BDF_DOWNLOAD_REQ_MSG_V01_MAX_LEN,
2091 qmi_wlanfw_bdf_download_req_msg_v01_ei, req);
2092 if (ret < 0) {
2093 qmi_txn_cancel(&txn);
2094 goto out_qmi_bdf;
2097 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS));
2098 if (ret < 0)
2099 goto out_qmi_bdf;
2101 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
2102 ath11k_warn(ab, "qmi BDF download failed, result: %d, err: %d\n",
2103 resp.resp.result, resp.resp.error);
2104 ret = resp.resp.result;
2105 goto out_qmi_bdf;
2107 remaining -= req->data_len;
2108 temp += req->data_len;
2109 req->seg_id++;
2112 out_qmi_bdf:
2113 ath11k_core_free_bdf(ab, &bd);
2115 out:
2116 kfree(req);
2117 return ret;
2120 static int ath11k_qmi_m3_load(struct ath11k_base *ab)
2122 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem;
2123 const struct firmware *fw;
2124 char path[100];
2125 int ret;
2127 if (m3_mem->vaddr || m3_mem->size)
2128 return 0;
2130 fw = ath11k_core_firmware_request(ab, ATH11K_M3_FILE);
2131 if (IS_ERR(fw)) {
2132 ret = PTR_ERR(fw);
2133 ath11k_core_create_firmware_path(ab, ATH11K_M3_FILE,
2134 path, sizeof(path));
2135 ath11k_err(ab, "failed to load %s: %d\n", path, ret);
2136 return ret;
2139 m3_mem->vaddr = dma_alloc_coherent(ab->dev,
2140 fw->size, &m3_mem->paddr,
2141 GFP_KERNEL);
2142 if (!m3_mem->vaddr) {
2143 ath11k_err(ab, "failed to allocate memory for M3 with size %zu\n",
2144 fw->size);
2145 release_firmware(fw);
2146 return -ENOMEM;
2149 memcpy(m3_mem->vaddr, fw->data, fw->size);
2150 m3_mem->size = fw->size;
2151 release_firmware(fw);
2153 return 0;
2156 static void ath11k_qmi_m3_free(struct ath11k_base *ab)
2158 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem;
2160 if (!ab->bus_params.m3_fw_support || !m3_mem->vaddr)
2161 return;
2163 dma_free_coherent(ab->dev, m3_mem->size,
2164 m3_mem->vaddr, m3_mem->paddr);
2165 m3_mem->vaddr = NULL;
2168 static int ath11k_qmi_wlanfw_m3_info_send(struct ath11k_base *ab)
2170 struct m3_mem_region *m3_mem = &ab->qmi.m3_mem;
2171 struct qmi_wlanfw_m3_info_req_msg_v01 req;
2172 struct qmi_wlanfw_m3_info_resp_msg_v01 resp;
2173 struct qmi_txn txn = {};
2174 int ret = 0;
2176 memset(&req, 0, sizeof(req));
2177 memset(&resp, 0, sizeof(resp));
2179 if (ab->bus_params.m3_fw_support) {
2180 ret = ath11k_qmi_m3_load(ab);
2181 if (ret) {
2182 ath11k_err(ab, "failed to load m3 firmware: %d", ret);
2183 return ret;
2186 req.addr = m3_mem->paddr;
2187 req.size = m3_mem->size;
2188 } else {
2189 req.addr = 0;
2190 req.size = 0;
2193 ret = qmi_txn_init(&ab->qmi.handle, &txn,
2194 qmi_wlanfw_m3_info_resp_msg_v01_ei, &resp);
2195 if (ret < 0)
2196 goto out;
2198 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
2199 QMI_WLANFW_M3_INFO_REQ_V01,
2200 QMI_WLANFW_M3_INFO_REQ_MSG_V01_MAX_MSG_LEN,
2201 qmi_wlanfw_m3_info_req_msg_v01_ei, &req);
2202 if (ret < 0) {
2203 ath11k_warn(ab, "qmi failed to send M3 information request, err = %d\n",
2204 ret);
2205 goto out;
2208 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS));
2209 if (ret < 0) {
2210 ath11k_warn(ab, "qmi failed M3 information request %d\n", ret);
2211 goto out;
2214 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
2215 ath11k_warn(ab, "qmi M3 info request failed, result: %d, err: %d\n",
2216 resp.resp.result, resp.resp.error);
2217 ret = -EINVAL;
2218 goto out;
2220 out:
2221 return ret;
2224 static int ath11k_qmi_wlanfw_mode_send(struct ath11k_base *ab,
2225 u32 mode)
2227 struct qmi_wlanfw_wlan_mode_req_msg_v01 req;
2228 struct qmi_wlanfw_wlan_mode_resp_msg_v01 resp;
2229 struct qmi_txn txn = {};
2230 int ret = 0;
2232 memset(&req, 0, sizeof(req));
2233 memset(&resp, 0, sizeof(resp));
2235 req.mode = mode;
2236 req.hw_debug_valid = 1;
2237 req.hw_debug = 0;
2239 ret = qmi_txn_init(&ab->qmi.handle, &txn,
2240 qmi_wlanfw_wlan_mode_resp_msg_v01_ei, &resp);
2241 if (ret < 0)
2242 goto out;
2244 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
2245 QMI_WLANFW_WLAN_MODE_REQ_V01,
2246 QMI_WLANFW_WLAN_MODE_REQ_MSG_V01_MAX_LEN,
2247 qmi_wlanfw_wlan_mode_req_msg_v01_ei, &req);
2248 if (ret < 0) {
2249 ath11k_warn(ab, "qmi failed to send mode request, mode: %d, err = %d\n",
2250 mode, ret);
2251 goto out;
2254 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS));
2255 if (ret < 0) {
2256 if (mode == ATH11K_FIRMWARE_MODE_OFF && ret == -ENETRESET) {
2257 ath11k_warn(ab, "WLFW service is dis-connected\n");
2258 return 0;
2260 ath11k_warn(ab, "qmi failed set mode request, mode: %d, err = %d\n",
2261 mode, ret);
2262 goto out;
2265 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
2266 ath11k_warn(ab, "Mode request failed, mode: %d, result: %d err: %d\n",
2267 mode, resp.resp.result, resp.resp.error);
2268 ret = -EINVAL;
2269 goto out;
2272 out:
2273 return ret;
2276 static int ath11k_qmi_wlanfw_wlan_cfg_send(struct ath11k_base *ab)
2278 struct qmi_wlanfw_wlan_cfg_req_msg_v01 *req;
2279 struct qmi_wlanfw_wlan_cfg_resp_msg_v01 resp;
2280 struct ce_pipe_config *ce_cfg;
2281 struct service_to_pipe *svc_cfg;
2282 struct qmi_txn txn = {};
2283 int ret = 0, pipe_num;
2285 ce_cfg = (struct ce_pipe_config *)ab->qmi.ce_cfg.tgt_ce;
2286 svc_cfg = (struct service_to_pipe *)ab->qmi.ce_cfg.svc_to_ce_map;
2288 req = kzalloc(sizeof(*req), GFP_KERNEL);
2289 if (!req)
2290 return -ENOMEM;
2292 memset(&resp, 0, sizeof(resp));
2294 req->host_version_valid = 1;
2295 strlcpy(req->host_version, ATH11K_HOST_VERSION_STRING,
2296 sizeof(req->host_version));
2298 req->tgt_cfg_valid = 1;
2299 /* This is number of CE configs */
2300 req->tgt_cfg_len = ab->qmi.ce_cfg.tgt_ce_len;
2301 for (pipe_num = 0; pipe_num < req->tgt_cfg_len ; pipe_num++) {
2302 req->tgt_cfg[pipe_num].pipe_num = ce_cfg[pipe_num].pipenum;
2303 req->tgt_cfg[pipe_num].pipe_dir = ce_cfg[pipe_num].pipedir;
2304 req->tgt_cfg[pipe_num].nentries = ce_cfg[pipe_num].nentries;
2305 req->tgt_cfg[pipe_num].nbytes_max = ce_cfg[pipe_num].nbytes_max;
2306 req->tgt_cfg[pipe_num].flags = ce_cfg[pipe_num].flags;
2309 req->svc_cfg_valid = 1;
2310 /* This is number of Service/CE configs */
2311 req->svc_cfg_len = ab->qmi.ce_cfg.svc_to_ce_map_len;
2312 for (pipe_num = 0; pipe_num < req->svc_cfg_len; pipe_num++) {
2313 req->svc_cfg[pipe_num].service_id = svc_cfg[pipe_num].service_id;
2314 req->svc_cfg[pipe_num].pipe_dir = svc_cfg[pipe_num].pipedir;
2315 req->svc_cfg[pipe_num].pipe_num = svc_cfg[pipe_num].pipenum;
2317 req->shadow_reg_valid = 0;
2319 /* set shadow v2 configuration */
2320 if (ab->hw_params.supports_shadow_regs) {
2321 req->shadow_reg_v2_valid = 1;
2322 req->shadow_reg_v2_len = min_t(u32,
2323 ab->qmi.ce_cfg.shadow_reg_v2_len,
2324 QMI_WLANFW_MAX_NUM_SHADOW_REG_V2_V01);
2325 memcpy(&req->shadow_reg_v2, ab->qmi.ce_cfg.shadow_reg_v2,
2326 sizeof(u32) * req->shadow_reg_v2_len);
2327 } else {
2328 req->shadow_reg_v2_valid = 0;
2331 ret = qmi_txn_init(&ab->qmi.handle, &txn,
2332 qmi_wlanfw_wlan_cfg_resp_msg_v01_ei, &resp);
2333 if (ret < 0)
2334 goto out;
2336 ret = qmi_send_request(&ab->qmi.handle, NULL, &txn,
2337 QMI_WLANFW_WLAN_CFG_REQ_V01,
2338 QMI_WLANFW_WLAN_CFG_REQ_MSG_V01_MAX_LEN,
2339 qmi_wlanfw_wlan_cfg_req_msg_v01_ei, req);
2340 if (ret < 0) {
2341 ath11k_warn(ab, "qmi failed to send wlan config request, err = %d\n",
2342 ret);
2343 goto out;
2346 ret = qmi_txn_wait(&txn, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS));
2347 if (ret < 0) {
2348 ath11k_warn(ab, "qmi failed wlan config request, err = %d\n", ret);
2349 goto out;
2352 if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
2353 ath11k_warn(ab, "qmi wlan config request failed, result: %d, err: %d\n",
2354 resp.resp.result, resp.resp.error);
2355 ret = -EINVAL;
2356 goto out;
2359 out:
2360 kfree(req);
2361 return ret;
2364 void ath11k_qmi_firmware_stop(struct ath11k_base *ab)
2366 int ret;
2368 ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_OFF);
2369 if (ret < 0) {
2370 ath11k_warn(ab, "qmi failed to send wlan mode off\n");
2371 return;
2375 int ath11k_qmi_firmware_start(struct ath11k_base *ab,
2376 u32 mode)
2378 int ret;
2380 ret = ath11k_qmi_wlanfw_wlan_cfg_send(ab);
2381 if (ret < 0) {
2382 ath11k_warn(ab, "qmi failed to send wlan cfg:%d\n", ret);
2383 return ret;
2386 ret = ath11k_qmi_wlanfw_mode_send(ab, mode);
2387 if (ret < 0) {
2388 ath11k_warn(ab, "qmi failed to send wlan fw mode:%d\n", ret);
2389 return ret;
2392 return 0;
2395 static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base *ab)
2397 int timeout;
2398 int ret;
2400 ret = ath11k_qmi_wlanfw_mode_send(ab, ATH11K_FIRMWARE_MODE_COLD_BOOT);
2401 if (ret < 0) {
2402 ath11k_warn(ab, "qmi failed to send wlan fw mode:%d\n", ret);
2403 return ret;
2406 ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration wait started\n");
2408 timeout = wait_event_timeout(ab->qmi.cold_boot_waitq,
2409 (ab->qmi.cal_done == 1),
2410 ATH11K_COLD_BOOT_FW_RESET_DELAY);
2411 if (timeout <= 0) {
2412 ath11k_warn(ab, "Coldboot Calibration failed - wait ended\n");
2413 return 0;
2416 ath11k_dbg(ab, ATH11K_DBG_QMI, "Coldboot calibration done\n");
2418 return 0;
2421 static int
2422 ath11k_qmi_driver_event_post(struct ath11k_qmi *qmi,
2423 enum ath11k_qmi_event_type type,
2424 void *data)
2426 struct ath11k_qmi_driver_event *event;
2428 event = kzalloc(sizeof(*event), GFP_ATOMIC);
2429 if (!event)
2430 return -ENOMEM;
2432 event->type = type;
2433 event->data = data;
2435 spin_lock(&qmi->event_lock);
2436 list_add_tail(&event->list, &qmi->event_list);
2437 spin_unlock(&qmi->event_lock);
2439 queue_work(qmi->event_wq, &qmi->event_work);
2441 return 0;
2444 static int ath11k_qmi_event_server_arrive(struct ath11k_qmi *qmi)
2446 struct ath11k_base *ab = qmi->ab;
2447 int ret;
2449 ret = ath11k_qmi_fw_ind_register_send(ab);
2450 if (ret < 0) {
2451 ath11k_warn(ab, "qmi failed to send FW indication QMI:%d\n", ret);
2452 return ret;
2455 ret = ath11k_qmi_host_cap_send(ab);
2456 if (ret < 0) {
2457 ath11k_warn(ab, "qmi failed to send host cap QMI:%d\n", ret);
2458 return ret;
2461 return ret;
2464 static int ath11k_qmi_event_mem_request(struct ath11k_qmi *qmi)
2466 struct ath11k_base *ab = qmi->ab;
2467 int ret;
2469 ret = ath11k_qmi_respond_fw_mem_request(ab);
2470 if (ret < 0) {
2471 ath11k_warn(ab, "qmi failed to respond fw mem req:%d\n", ret);
2472 return ret;
2475 return ret;
2478 static int ath11k_qmi_event_load_bdf(struct ath11k_qmi *qmi)
2480 struct ath11k_base *ab = qmi->ab;
2481 int ret;
2483 ret = ath11k_qmi_request_target_cap(ab);
2484 if (ret < 0) {
2485 ath11k_warn(ab, "qmi failed to req target capabilities:%d\n", ret);
2486 return ret;
2489 if (ab->bus_params.fixed_bdf_addr)
2490 ret = ath11k_qmi_load_bdf_fixed_addr(ab);
2491 else
2492 ret = ath11k_qmi_load_bdf_qmi(ab);
2493 if (ret < 0) {
2494 ath11k_warn(ab, "qmi failed to load board data file:%d\n", ret);
2495 return ret;
2498 ret = ath11k_qmi_wlanfw_m3_info_send(ab);
2499 if (ret < 0) {
2500 ath11k_warn(ab, "qmi failed to send m3 info req:%d\n", ret);
2501 return ret;
2504 return ret;
2507 static void ath11k_qmi_msg_mem_request_cb(struct qmi_handle *qmi_hdl,
2508 struct sockaddr_qrtr *sq,
2509 struct qmi_txn *txn,
2510 const void *data)
2512 struct ath11k_qmi *qmi = container_of(qmi_hdl, struct ath11k_qmi, handle);
2513 struct ath11k_base *ab = qmi->ab;
2514 const struct qmi_wlanfw_request_mem_ind_msg_v01 *msg = data;
2515 int i, ret;
2517 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware request memory request\n");
2519 if (msg->mem_seg_len == 0 ||
2520 msg->mem_seg_len > ATH11K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01)
2521 ath11k_warn(ab, "Invalid memory segment length: %u\n",
2522 msg->mem_seg_len);
2524 ab->qmi.mem_seg_count = msg->mem_seg_len;
2526 for (i = 0; i < qmi->mem_seg_count ; i++) {
2527 ab->qmi.target_mem[i].type = msg->mem_seg[i].type;
2528 ab->qmi.target_mem[i].size = msg->mem_seg[i].size;
2529 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi mem seg type %d size %d\n",
2530 msg->mem_seg[i].type, msg->mem_seg[i].size);
2533 if (ab->bus_params.fixed_mem_region) {
2534 ret = ath11k_qmi_assign_target_mem_chunk(ab);
2535 if (ret) {
2536 ath11k_warn(ab, "qmi failed to assign target memory: %d\n",
2537 ret);
2538 return;
2540 } else {
2541 ret = ath11k_qmi_alloc_target_mem_chunk(ab);
2542 if (ret) {
2543 ath11k_warn(ab, "qmi failed to alloc target memory: %d\n",
2544 ret);
2545 return;
2549 ath11k_qmi_driver_event_post(qmi, ATH11K_QMI_EVENT_REQUEST_MEM, NULL);
2552 static void ath11k_qmi_msg_mem_ready_cb(struct qmi_handle *qmi_hdl,
2553 struct sockaddr_qrtr *sq,
2554 struct qmi_txn *txn,
2555 const void *decoded)
2557 struct ath11k_qmi *qmi = container_of(qmi_hdl, struct ath11k_qmi, handle);
2558 struct ath11k_base *ab = qmi->ab;
2560 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware memory ready indication\n");
2561 ath11k_qmi_driver_event_post(qmi, ATH11K_QMI_EVENT_FW_MEM_READY, NULL);
2564 static void ath11k_qmi_msg_fw_ready_cb(struct qmi_handle *qmi_hdl,
2565 struct sockaddr_qrtr *sq,
2566 struct qmi_txn *txn,
2567 const void *decoded)
2569 struct ath11k_qmi *qmi = container_of(qmi_hdl, struct ath11k_qmi, handle);
2570 struct ath11k_base *ab = qmi->ab;
2572 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi firmware ready\n");
2573 ath11k_qmi_driver_event_post(qmi, ATH11K_QMI_EVENT_FW_READY, NULL);
2576 static void ath11k_qmi_msg_cold_boot_cal_done_cb(struct qmi_handle *qmi_hdl,
2577 struct sockaddr_qrtr *sq,
2578 struct qmi_txn *txn,
2579 const void *decoded)
2581 struct ath11k_qmi *qmi = container_of(qmi_hdl,
2582 struct ath11k_qmi, handle);
2583 struct ath11k_base *ab = qmi->ab;
2585 ab->qmi.cal_done = 1;
2586 wake_up(&ab->qmi.cold_boot_waitq);
2587 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi cold boot calibration done\n");
2590 static const struct qmi_msg_handler ath11k_qmi_msg_handlers[] = {
2592 .type = QMI_INDICATION,
2593 .msg_id = QMI_WLFW_REQUEST_MEM_IND_V01,
2594 .ei = qmi_wlanfw_request_mem_ind_msg_v01_ei,
2595 .decoded_size = sizeof(struct qmi_wlanfw_request_mem_ind_msg_v01),
2596 .fn = ath11k_qmi_msg_mem_request_cb,
2599 .type = QMI_INDICATION,
2600 .msg_id = QMI_WLFW_FW_MEM_READY_IND_V01,
2601 .ei = qmi_wlanfw_mem_ready_ind_msg_v01_ei,
2602 .decoded_size = sizeof(struct qmi_wlanfw_fw_mem_ready_ind_msg_v01),
2603 .fn = ath11k_qmi_msg_mem_ready_cb,
2606 .type = QMI_INDICATION,
2607 .msg_id = QMI_WLFW_FW_READY_IND_V01,
2608 .ei = qmi_wlanfw_fw_ready_ind_msg_v01_ei,
2609 .decoded_size = sizeof(struct qmi_wlanfw_fw_ready_ind_msg_v01),
2610 .fn = ath11k_qmi_msg_fw_ready_cb,
2613 .type = QMI_INDICATION,
2614 .msg_id = QMI_WLFW_COLD_BOOT_CAL_DONE_IND_V01,
2615 .ei = qmi_wlanfw_cold_boot_cal_done_ind_msg_v01_ei,
2616 .decoded_size =
2617 sizeof(struct qmi_wlanfw_fw_cold_cal_done_ind_msg_v01),
2618 .fn = ath11k_qmi_msg_cold_boot_cal_done_cb,
2622 static int ath11k_qmi_ops_new_server(struct qmi_handle *qmi_hdl,
2623 struct qmi_service *service)
2625 struct ath11k_qmi *qmi = container_of(qmi_hdl, struct ath11k_qmi, handle);
2626 struct ath11k_base *ab = qmi->ab;
2627 struct sockaddr_qrtr *sq = &qmi->sq;
2628 int ret;
2630 sq->sq_family = AF_QIPCRTR;
2631 sq->sq_node = service->node;
2632 sq->sq_port = service->port;
2634 ret = kernel_connect(qmi_hdl->sock, (struct sockaddr *)sq,
2635 sizeof(*sq), 0);
2636 if (ret) {
2637 ath11k_warn(ab, "qmi failed to connect to remote service %d\n", ret);
2638 return ret;
2641 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi wifi fw qmi service connected\n");
2642 ath11k_qmi_driver_event_post(qmi, ATH11K_QMI_EVENT_SERVER_ARRIVE, NULL);
2644 return ret;
2647 static void ath11k_qmi_ops_del_server(struct qmi_handle *qmi_hdl,
2648 struct qmi_service *service)
2650 struct ath11k_qmi *qmi = container_of(qmi_hdl, struct ath11k_qmi, handle);
2651 struct ath11k_base *ab = qmi->ab;
2653 ath11k_dbg(ab, ATH11K_DBG_QMI, "qmi wifi fw del server\n");
2654 ath11k_qmi_driver_event_post(qmi, ATH11K_QMI_EVENT_SERVER_EXIT, NULL);
2657 static const struct qmi_ops ath11k_qmi_ops = {
2658 .new_server = ath11k_qmi_ops_new_server,
2659 .del_server = ath11k_qmi_ops_del_server,
2662 static void ath11k_qmi_driver_event_work(struct work_struct *work)
2664 struct ath11k_qmi *qmi = container_of(work, struct ath11k_qmi,
2665 event_work);
2666 struct ath11k_qmi_driver_event *event;
2667 struct ath11k_base *ab = qmi->ab;
2668 int ret;
2670 spin_lock(&qmi->event_lock);
2671 while (!list_empty(&qmi->event_list)) {
2672 event = list_first_entry(&qmi->event_list,
2673 struct ath11k_qmi_driver_event, list);
2674 list_del(&event->list);
2675 spin_unlock(&qmi->event_lock);
2677 if (test_bit(ATH11K_FLAG_UNREGISTERING, &ab->dev_flags))
2678 return;
2680 switch (event->type) {
2681 case ATH11K_QMI_EVENT_SERVER_ARRIVE:
2682 ret = ath11k_qmi_event_server_arrive(qmi);
2683 if (ret < 0)
2684 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags);
2685 break;
2686 case ATH11K_QMI_EVENT_SERVER_EXIT:
2687 set_bit(ATH11K_FLAG_CRASH_FLUSH, &ab->dev_flags);
2688 set_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags);
2689 break;
2690 case ATH11K_QMI_EVENT_REQUEST_MEM:
2691 ret = ath11k_qmi_event_mem_request(qmi);
2692 if (ret < 0)
2693 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags);
2694 break;
2695 case ATH11K_QMI_EVENT_FW_MEM_READY:
2696 ret = ath11k_qmi_event_load_bdf(qmi);
2697 if (ret < 0)
2698 set_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags);
2699 break;
2700 case ATH11K_QMI_EVENT_FW_READY:
2701 clear_bit(ATH11K_FLAG_QMI_FAIL, &ab->dev_flags);
2702 if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags)) {
2703 ath11k_hal_dump_srng_stats(ab);
2704 queue_work(ab->workqueue, &ab->restart_work);
2705 break;
2708 if (ath11k_cold_boot_cal && ab->qmi.cal_done == 0 &&
2709 ab->hw_params.cold_boot_calib) {
2710 ath11k_qmi_process_coldboot_calibration(ab);
2711 } else {
2712 clear_bit(ATH11K_FLAG_CRASH_FLUSH,
2713 &ab->dev_flags);
2714 clear_bit(ATH11K_FLAG_RECOVERY, &ab->dev_flags);
2715 ath11k_core_qmi_firmware_ready(ab);
2716 set_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags);
2719 break;
2720 case ATH11K_QMI_EVENT_COLD_BOOT_CAL_DONE:
2721 break;
2722 default:
2723 ath11k_warn(ab, "invalid event type: %d", event->type);
2724 break;
2726 kfree(event);
2727 spin_lock(&qmi->event_lock);
2729 spin_unlock(&qmi->event_lock);
2732 int ath11k_qmi_init_service(struct ath11k_base *ab)
2734 int ret;
2736 memset(&ab->qmi.target, 0, sizeof(struct target_info));
2737 memset(&ab->qmi.target_mem, 0, sizeof(struct target_mem_chunk));
2738 ab->qmi.ab = ab;
2740 ab->qmi.target_mem_mode = ATH11K_QMI_TARGET_MEM_MODE_DEFAULT;
2741 ret = qmi_handle_init(&ab->qmi.handle, ATH11K_QMI_RESP_LEN_MAX,
2742 &ath11k_qmi_ops, ath11k_qmi_msg_handlers);
2743 if (ret < 0) {
2744 ath11k_warn(ab, "failed to initialize qmi handle\n");
2745 return ret;
2748 ab->qmi.event_wq = alloc_workqueue("ath11k_qmi_driver_event",
2749 WQ_UNBOUND, 1);
2750 if (!ab->qmi.event_wq) {
2751 ath11k_err(ab, "failed to allocate workqueue\n");
2752 return -EFAULT;
2755 INIT_LIST_HEAD(&ab->qmi.event_list);
2756 spin_lock_init(&ab->qmi.event_lock);
2757 INIT_WORK(&ab->qmi.event_work, ath11k_qmi_driver_event_work);
2759 ret = qmi_add_lookup(&ab->qmi.handle, ATH11K_QMI_WLFW_SERVICE_ID_V01,
2760 ATH11K_QMI_WLFW_SERVICE_VERS_V01,
2761 ab->qmi.service_ins_id);
2762 if (ret < 0) {
2763 ath11k_warn(ab, "failed to add qmi lookup\n");
2764 destroy_workqueue(ab->qmi.event_wq);
2765 return ret;
2768 return ret;
2771 void ath11k_qmi_deinit_service(struct ath11k_base *ab)
2773 qmi_handle_release(&ab->qmi.handle);
2774 cancel_work_sync(&ab->qmi.event_work);
2775 destroy_workqueue(ab->qmi.event_wq);
2776 ath11k_qmi_m3_free(ab);
2777 ath11k_qmi_free_target_mem_chunk(ab);
2779 EXPORT_SYMBOL(ath11k_qmi_deinit_service);