1 // SPDX-License-Identifier: BSD-3-Clause-Clear
3 * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
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
,
27 .elem_size
= sizeof(u8
),
28 .array_type
= NO_ARRAY
,
30 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
34 .data_type
= QMI_UNSIGNED_4_BYTE
,
36 .elem_size
= sizeof(u32
),
37 .array_type
= NO_ARRAY
,
39 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
43 .data_type
= QMI_OPT_FLAG
,
45 .elem_size
= sizeof(u8
),
46 .array_type
= NO_ARRAY
,
48 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
52 .data_type
= QMI_UNSIGNED_4_BYTE
,
54 .elem_size
= sizeof(u32
),
55 .array_type
= NO_ARRAY
,
57 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
61 .data_type
= QMI_OPT_FLAG
,
63 .elem_size
= sizeof(u8
),
64 .array_type
= NO_ARRAY
,
66 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
70 .data_type
= QMI_DATA_LEN
,
72 .elem_size
= sizeof(u8
),
73 .array_type
= NO_ARRAY
,
75 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
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
,
84 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
88 .data_type
= QMI_OPT_FLAG
,
90 .elem_size
= sizeof(u8
),
91 .array_type
= NO_ARRAY
,
93 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
97 .data_type
= QMI_UNSIGNED_1_BYTE
,
99 .elem_size
= sizeof(u8
),
100 .array_type
= NO_ARRAY
,
102 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
106 .data_type
= QMI_OPT_FLAG
,
108 .elem_size
= sizeof(u8
),
109 .array_type
= NO_ARRAY
,
111 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
115 .data_type
= QMI_UNSIGNED_1_BYTE
,
117 .elem_size
= sizeof(u8
),
118 .array_type
= NO_ARRAY
,
120 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
124 .data_type
= QMI_OPT_FLAG
,
126 .elem_size
= sizeof(u8
),
127 .array_type
= NO_ARRAY
,
129 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
130 bdf_cache_support_valid
),
133 .data_type
= QMI_UNSIGNED_1_BYTE
,
135 .elem_size
= sizeof(u8
),
136 .array_type
= NO_ARRAY
,
138 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
142 .data_type
= QMI_OPT_FLAG
,
144 .elem_size
= sizeof(u8
),
145 .array_type
= NO_ARRAY
,
147 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
151 .data_type
= QMI_UNSIGNED_1_BYTE
,
153 .elem_size
= sizeof(u8
),
154 .array_type
= NO_ARRAY
,
156 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
160 .data_type
= QMI_OPT_FLAG
,
162 .elem_size
= sizeof(u8
),
163 .array_type
= NO_ARRAY
,
165 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
166 m3_cache_support_valid
),
169 .data_type
= QMI_UNSIGNED_1_BYTE
,
171 .elem_size
= sizeof(u8
),
172 .array_type
= NO_ARRAY
,
174 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
178 .data_type
= QMI_OPT_FLAG
,
180 .elem_size
= sizeof(u8
),
181 .array_type
= NO_ARRAY
,
183 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
184 cal_filesys_support_valid
),
187 .data_type
= QMI_UNSIGNED_1_BYTE
,
189 .elem_size
= sizeof(u8
),
190 .array_type
= NO_ARRAY
,
192 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
193 cal_filesys_support
),
196 .data_type
= QMI_OPT_FLAG
,
198 .elem_size
= sizeof(u8
),
199 .array_type
= NO_ARRAY
,
201 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
202 cal_cache_support_valid
),
205 .data_type
= QMI_UNSIGNED_1_BYTE
,
207 .elem_size
= sizeof(u8
),
208 .array_type
= NO_ARRAY
,
210 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
214 .data_type
= QMI_OPT_FLAG
,
216 .elem_size
= sizeof(u8
),
217 .array_type
= NO_ARRAY
,
219 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
223 .data_type
= QMI_UNSIGNED_1_BYTE
,
225 .elem_size
= sizeof(u8
),
226 .array_type
= NO_ARRAY
,
228 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
232 .data_type
= QMI_OPT_FLAG
,
234 .elem_size
= sizeof(u8
),
235 .array_type
= NO_ARRAY
,
237 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
241 .data_type
= QMI_UNSIGNED_4_BYTE
,
243 .elem_size
= sizeof(u32
),
244 .array_type
= NO_ARRAY
,
246 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
250 .data_type
= QMI_OPT_FLAG
,
252 .elem_size
= sizeof(u8
),
253 .array_type
= NO_ARRAY
,
255 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
259 .data_type
= QMI_UNSIGNED_1_BYTE
,
261 .elem_size
= sizeof(u8
),
262 .array_type
= NO_ARRAY
,
264 .offset
= offsetof(struct qmi_wlanfw_host_cap_req_msg_v01
,
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
,
278 .elem_size
= sizeof(struct qmi_response_type_v01
),
279 .array_type
= NO_ARRAY
,
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
,
295 .elem_size
= sizeof(u8
),
296 .array_type
= NO_ARRAY
,
298 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
299 fw_ready_enable_valid
),
302 .data_type
= QMI_UNSIGNED_1_BYTE
,
304 .elem_size
= sizeof(u8
),
305 .array_type
= NO_ARRAY
,
307 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
311 .data_type
= QMI_OPT_FLAG
,
313 .elem_size
= sizeof(u8
),
314 .array_type
= NO_ARRAY
,
316 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
317 initiate_cal_download_enable_valid
),
320 .data_type
= QMI_UNSIGNED_1_BYTE
,
322 .elem_size
= sizeof(u8
),
323 .array_type
= NO_ARRAY
,
325 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
326 initiate_cal_download_enable
),
329 .data_type
= QMI_OPT_FLAG
,
331 .elem_size
= sizeof(u8
),
332 .array_type
= NO_ARRAY
,
334 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
335 initiate_cal_update_enable_valid
),
338 .data_type
= QMI_UNSIGNED_1_BYTE
,
340 .elem_size
= sizeof(u8
),
341 .array_type
= NO_ARRAY
,
343 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
344 initiate_cal_update_enable
),
347 .data_type
= QMI_OPT_FLAG
,
349 .elem_size
= sizeof(u8
),
350 .array_type
= NO_ARRAY
,
352 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
353 msa_ready_enable_valid
),
356 .data_type
= QMI_UNSIGNED_1_BYTE
,
358 .elem_size
= sizeof(u8
),
359 .array_type
= NO_ARRAY
,
361 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
365 .data_type
= QMI_OPT_FLAG
,
367 .elem_size
= sizeof(u8
),
368 .array_type
= NO_ARRAY
,
370 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
371 pin_connect_result_enable_valid
),
374 .data_type
= QMI_UNSIGNED_1_BYTE
,
376 .elem_size
= sizeof(u8
),
377 .array_type
= NO_ARRAY
,
379 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
380 pin_connect_result_enable
),
383 .data_type
= QMI_OPT_FLAG
,
385 .elem_size
= sizeof(u8
),
386 .array_type
= NO_ARRAY
,
388 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
392 .data_type
= QMI_UNSIGNED_4_BYTE
,
394 .elem_size
= sizeof(u32
),
395 .array_type
= NO_ARRAY
,
397 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
401 .data_type
= QMI_OPT_FLAG
,
403 .elem_size
= sizeof(u8
),
404 .array_type
= NO_ARRAY
,
406 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
407 request_mem_enable_valid
),
410 .data_type
= QMI_UNSIGNED_1_BYTE
,
412 .elem_size
= sizeof(u8
),
413 .array_type
= NO_ARRAY
,
415 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
419 .data_type
= QMI_OPT_FLAG
,
421 .elem_size
= sizeof(u8
),
422 .array_type
= NO_ARRAY
,
424 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
425 fw_mem_ready_enable_valid
),
428 .data_type
= QMI_UNSIGNED_1_BYTE
,
430 .elem_size
= sizeof(u8
),
431 .array_type
= NO_ARRAY
,
433 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
434 fw_mem_ready_enable
),
437 .data_type
= QMI_OPT_FLAG
,
439 .elem_size
= sizeof(u8
),
440 .array_type
= NO_ARRAY
,
442 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
443 fw_init_done_enable_valid
),
446 .data_type
= QMI_UNSIGNED_1_BYTE
,
448 .elem_size
= sizeof(u8
),
449 .array_type
= NO_ARRAY
,
451 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
452 fw_init_done_enable
),
456 .data_type
= QMI_OPT_FLAG
,
458 .elem_size
= sizeof(u8
),
459 .array_type
= NO_ARRAY
,
461 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
462 rejuvenate_enable_valid
),
465 .data_type
= QMI_UNSIGNED_1_BYTE
,
467 .elem_size
= sizeof(u8
),
468 .array_type
= NO_ARRAY
,
470 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
474 .data_type
= QMI_OPT_FLAG
,
476 .elem_size
= sizeof(u8
),
477 .array_type
= NO_ARRAY
,
479 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
480 xo_cal_enable_valid
),
483 .data_type
= QMI_UNSIGNED_1_BYTE
,
485 .elem_size
= sizeof(u8
),
486 .array_type
= NO_ARRAY
,
488 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
492 .data_type
= QMI_OPT_FLAG
,
494 .elem_size
= sizeof(u8
),
495 .array_type
= NO_ARRAY
,
497 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
498 cal_done_enable_valid
),
501 .data_type
= QMI_UNSIGNED_1_BYTE
,
503 .elem_size
= sizeof(u8
),
504 .array_type
= NO_ARRAY
,
506 .offset
= offsetof(struct qmi_wlanfw_ind_register_req_msg_v01
,
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
,
520 .elem_size
= sizeof(struct qmi_response_type_v01
),
521 .array_type
= NO_ARRAY
,
523 .offset
= offsetof(struct qmi_wlanfw_ind_register_resp_msg_v01
,
525 .ei_array
= qmi_response_type_v01_ei
,
528 .data_type
= QMI_OPT_FLAG
,
530 .elem_size
= sizeof(u8
),
531 .array_type
= NO_ARRAY
,
533 .offset
= offsetof(struct qmi_wlanfw_ind_register_resp_msg_v01
,
537 .data_type
= QMI_UNSIGNED_8_BYTE
,
539 .elem_size
= sizeof(u64
),
540 .array_type
= NO_ARRAY
,
542 .offset
= offsetof(struct qmi_wlanfw_ind_register_resp_msg_v01
,
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
,
556 .elem_size
= sizeof(u64
),
557 .array_type
= NO_ARRAY
,
559 .offset
= offsetof(struct qmi_wlanfw_mem_cfg_s_v01
, offset
),
562 .data_type
= QMI_UNSIGNED_4_BYTE
,
564 .elem_size
= sizeof(u32
),
565 .array_type
= NO_ARRAY
,
567 .offset
= offsetof(struct qmi_wlanfw_mem_cfg_s_v01
, size
),
570 .data_type
= QMI_UNSIGNED_1_BYTE
,
572 .elem_size
= sizeof(u8
),
573 .array_type
= NO_ARRAY
,
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
,
588 .elem_size
= sizeof(u32
),
589 .array_type
= NO_ARRAY
,
591 .offset
= offsetof(struct qmi_wlanfw_mem_seg_s_v01
,
595 .data_type
= QMI_SIGNED_4_BYTE_ENUM
,
597 .elem_size
= sizeof(enum qmi_wlanfw_mem_type_enum_v01
),
598 .array_type
= NO_ARRAY
,
600 .offset
= offsetof(struct qmi_wlanfw_mem_seg_s_v01
, type
),
603 .data_type
= QMI_DATA_LEN
,
605 .elem_size
= sizeof(u8
),
606 .array_type
= NO_ARRAY
,
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
,
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
,
630 .elem_size
= sizeof(u8
),
631 .array_type
= NO_ARRAY
,
633 .offset
= offsetof(struct qmi_wlanfw_request_mem_ind_msg_v01
,
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
,
642 .offset
= offsetof(struct qmi_wlanfw_request_mem_ind_msg_v01
,
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
,
657 .elem_size
= sizeof(u64
),
658 .array_type
= NO_ARRAY
,
660 .offset
= offsetof(struct qmi_wlanfw_mem_seg_resp_s_v01
, addr
),
663 .data_type
= QMI_UNSIGNED_4_BYTE
,
665 .elem_size
= sizeof(u32
),
666 .array_type
= NO_ARRAY
,
668 .offset
= offsetof(struct qmi_wlanfw_mem_seg_resp_s_v01
, size
),
671 .data_type
= QMI_SIGNED_4_BYTE_ENUM
,
673 .elem_size
= sizeof(enum qmi_wlanfw_mem_type_enum_v01
),
674 .array_type
= NO_ARRAY
,
676 .offset
= offsetof(struct qmi_wlanfw_mem_seg_resp_s_v01
, type
),
679 .data_type
= QMI_UNSIGNED_1_BYTE
,
681 .elem_size
= sizeof(u8
),
682 .array_type
= NO_ARRAY
,
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
,
697 .elem_size
= sizeof(u8
),
698 .array_type
= NO_ARRAY
,
700 .offset
= offsetof(struct qmi_wlanfw_respond_mem_req_msg_v01
,
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
,
709 .offset
= offsetof(struct qmi_wlanfw_respond_mem_req_msg_v01
,
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
,
724 .elem_size
= sizeof(struct qmi_response_type_v01
),
725 .array_type
= NO_ARRAY
,
727 .offset
= offsetof(struct qmi_wlanfw_respond_mem_resp_msg_v01
,
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
,
750 .elem_size
= sizeof(u32
),
751 .array_type
= NO_ARRAY
,
753 .offset
= offsetof(struct qmi_wlanfw_rf_chip_info_s_v01
,
757 .data_type
= QMI_UNSIGNED_4_BYTE
,
759 .elem_size
= sizeof(u32
),
760 .array_type
= NO_ARRAY
,
762 .offset
= offsetof(struct qmi_wlanfw_rf_chip_info_s_v01
,
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
,
776 .elem_size
= sizeof(u32
),
777 .array_type
= NO_ARRAY
,
779 .offset
= offsetof(struct qmi_wlanfw_rf_board_info_s_v01
,
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
,
793 .elem_size
= sizeof(u32
),
794 .array_type
= NO_ARRAY
,
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
,
809 .elem_size
= sizeof(u32
),
810 .array_type
= NO_ARRAY
,
812 .offset
= offsetof(struct qmi_wlanfw_fw_version_info_s_v01
,
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
,
821 .offset
= offsetof(struct qmi_wlanfw_fw_version_info_s_v01
,
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
,
835 .elem_size
= sizeof(struct qmi_response_type_v01
),
836 .array_type
= NO_ARRAY
,
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
,
844 .elem_size
= sizeof(u8
),
845 .array_type
= NO_ARRAY
,
847 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
851 .data_type
= QMI_STRUCT
,
853 .elem_size
= sizeof(struct qmi_wlanfw_rf_chip_info_s_v01
),
854 .array_type
= NO_ARRAY
,
856 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
858 .ei_array
= qmi_wlanfw_rf_chip_info_s_v01_ei
,
861 .data_type
= QMI_OPT_FLAG
,
863 .elem_size
= sizeof(u8
),
864 .array_type
= NO_ARRAY
,
866 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
870 .data_type
= QMI_STRUCT
,
872 .elem_size
= sizeof(struct qmi_wlanfw_rf_board_info_s_v01
),
873 .array_type
= NO_ARRAY
,
875 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
877 .ei_array
= qmi_wlanfw_rf_board_info_s_v01_ei
,
880 .data_type
= QMI_OPT_FLAG
,
882 .elem_size
= sizeof(u8
),
883 .array_type
= NO_ARRAY
,
885 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
889 .data_type
= QMI_STRUCT
,
891 .elem_size
= sizeof(struct qmi_wlanfw_soc_info_s_v01
),
892 .array_type
= NO_ARRAY
,
894 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
896 .ei_array
= qmi_wlanfw_soc_info_s_v01_ei
,
899 .data_type
= QMI_OPT_FLAG
,
901 .elem_size
= sizeof(u8
),
902 .array_type
= NO_ARRAY
,
904 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
905 fw_version_info_valid
),
908 .data_type
= QMI_STRUCT
,
910 .elem_size
= sizeof(struct qmi_wlanfw_fw_version_info_s_v01
),
911 .array_type
= NO_ARRAY
,
913 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
915 .ei_array
= qmi_wlanfw_fw_version_info_s_v01_ei
,
918 .data_type
= QMI_OPT_FLAG
,
920 .elem_size
= sizeof(u8
),
921 .array_type
= NO_ARRAY
,
923 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
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
,
932 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
936 .data_type
= QMI_OPT_FLAG
,
938 .elem_size
= sizeof(u8
),
939 .array_type
= NO_ARRAY
,
941 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
945 .data_type
= QMI_UNSIGNED_1_BYTE
,
947 .elem_size
= sizeof(u8
),
948 .array_type
= NO_ARRAY
,
950 .offset
= offsetof(struct qmi_wlanfw_cap_resp_msg_v01
,
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
,
964 .elem_size
= sizeof(u8
),
965 .array_type
= NO_ARRAY
,
967 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
971 .data_type
= QMI_OPT_FLAG
,
973 .elem_size
= sizeof(u8
),
974 .array_type
= NO_ARRAY
,
976 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
980 .data_type
= QMI_SIGNED_4_BYTE_ENUM
,
982 .elem_size
= sizeof(enum qmi_wlanfw_cal_temp_id_enum_v01
),
983 .array_type
= NO_ARRAY
,
985 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
989 .data_type
= QMI_OPT_FLAG
,
991 .elem_size
= sizeof(u8
),
992 .array_type
= NO_ARRAY
,
994 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
998 .data_type
= QMI_UNSIGNED_4_BYTE
,
1000 .elem_size
= sizeof(u32
),
1001 .array_type
= NO_ARRAY
,
1003 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
1007 .data_type
= QMI_OPT_FLAG
,
1009 .elem_size
= sizeof(u8
),
1010 .array_type
= NO_ARRAY
,
1012 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
1016 .data_type
= QMI_UNSIGNED_4_BYTE
,
1018 .elem_size
= sizeof(u32
),
1019 .array_type
= NO_ARRAY
,
1021 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
1025 .data_type
= QMI_OPT_FLAG
,
1027 .elem_size
= sizeof(u8
),
1028 .array_type
= NO_ARRAY
,
1030 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
1034 .data_type
= QMI_DATA_LEN
,
1036 .elem_size
= sizeof(u16
),
1037 .array_type
= NO_ARRAY
,
1039 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
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
,
1048 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
1052 .data_type
= QMI_OPT_FLAG
,
1054 .elem_size
= sizeof(u8
),
1055 .array_type
= NO_ARRAY
,
1057 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
1061 .data_type
= QMI_UNSIGNED_1_BYTE
,
1063 .elem_size
= sizeof(u8
),
1064 .array_type
= NO_ARRAY
,
1066 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
1070 .data_type
= QMI_OPT_FLAG
,
1072 .elem_size
= sizeof(u8
),
1073 .array_type
= NO_ARRAY
,
1075 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
1079 .data_type
= QMI_UNSIGNED_1_BYTE
,
1081 .elem_size
= sizeof(u8
),
1082 .array_type
= NO_ARRAY
,
1084 .offset
= offsetof(struct qmi_wlanfw_bdf_download_req_msg_v01
,
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
,
1099 .elem_size
= sizeof(struct qmi_response_type_v01
),
1100 .array_type
= NO_ARRAY
,
1102 .offset
= offsetof(struct qmi_wlanfw_bdf_download_resp_msg_v01
,
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
,
1117 .elem_size
= sizeof(u64
),
1118 .array_type
= NO_ARRAY
,
1120 .offset
= offsetof(struct qmi_wlanfw_m3_info_req_msg_v01
, addr
),
1123 .data_type
= QMI_UNSIGNED_4_BYTE
,
1125 .elem_size
= sizeof(u32
),
1126 .array_type
= NO_ARRAY
,
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
,
1141 .elem_size
= sizeof(struct qmi_response_type_v01
),
1142 .array_type
= NO_ARRAY
,
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
,
1158 .elem_size
= sizeof(u32
),
1159 .array_type
= NO_ARRAY
,
1161 .offset
= offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01
,
1165 .data_type
= QMI_SIGNED_4_BYTE_ENUM
,
1167 .elem_size
= sizeof(enum qmi_wlanfw_pipedir_enum_v01
),
1168 .array_type
= NO_ARRAY
,
1170 .offset
= offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01
,
1174 .data_type
= QMI_UNSIGNED_4_BYTE
,
1176 .elem_size
= sizeof(u32
),
1177 .array_type
= NO_ARRAY
,
1179 .offset
= offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01
,
1183 .data_type
= QMI_UNSIGNED_4_BYTE
,
1185 .elem_size
= sizeof(u32
),
1186 .array_type
= NO_ARRAY
,
1188 .offset
= offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01
,
1192 .data_type
= QMI_UNSIGNED_4_BYTE
,
1194 .elem_size
= sizeof(u32
),
1195 .array_type
= NO_ARRAY
,
1197 .offset
= offsetof(struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01
,
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
,
1211 .elem_size
= sizeof(u32
),
1212 .array_type
= NO_ARRAY
,
1214 .offset
= offsetof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01
,
1218 .data_type
= QMI_SIGNED_4_BYTE_ENUM
,
1220 .elem_size
= sizeof(enum qmi_wlanfw_pipedir_enum_v01
),
1221 .array_type
= NO_ARRAY
,
1223 .offset
= offsetof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01
,
1227 .data_type
= QMI_UNSIGNED_4_BYTE
,
1229 .elem_size
= sizeof(u32
),
1230 .array_type
= NO_ARRAY
,
1232 .offset
= offsetof(struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01
,
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
,
1246 .elem_size
= sizeof(u16
),
1247 .array_type
= NO_ARRAY
,
1249 .offset
= offsetof(struct qmi_wlanfw_shadow_reg_cfg_s_v01
, id
),
1252 .data_type
= QMI_UNSIGNED_2_BYTE
,
1254 .elem_size
= sizeof(u16
),
1255 .array_type
= NO_ARRAY
,
1257 .offset
= offsetof(struct qmi_wlanfw_shadow_reg_cfg_s_v01
,
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
,
1270 .elem_size
= sizeof(u32
),
1271 .array_type
= NO_ARRAY
,
1273 .offset
= offsetof(struct qmi_wlanfw_shadow_reg_v2_cfg_s_v01
,
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
,
1287 .elem_size
= sizeof(u32
),
1288 .array_type
= NO_ARRAY
,
1290 .offset
= offsetof(struct qmi_wlanfw_wlan_mode_req_msg_v01
,
1294 .data_type
= QMI_OPT_FLAG
,
1296 .elem_size
= sizeof(u8
),
1297 .array_type
= NO_ARRAY
,
1299 .offset
= offsetof(struct qmi_wlanfw_wlan_mode_req_msg_v01
,
1303 .data_type
= QMI_UNSIGNED_1_BYTE
,
1305 .elem_size
= sizeof(u8
),
1306 .array_type
= NO_ARRAY
,
1308 .offset
= offsetof(struct qmi_wlanfw_wlan_mode_req_msg_v01
,
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
,
1322 .elem_size
= sizeof(struct qmi_response_type_v01
),
1323 .array_type
= NO_ARRAY
,
1325 .offset
= offsetof(struct qmi_wlanfw_wlan_mode_resp_msg_v01
,
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
,
1340 .elem_size
= sizeof(u8
),
1341 .array_type
= NO_ARRAY
,
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
,
1352 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
1356 .data_type
= QMI_OPT_FLAG
,
1358 .elem_size
= sizeof(u8
),
1359 .array_type
= NO_ARRAY
,
1361 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
1365 .data_type
= QMI_DATA_LEN
,
1367 .elem_size
= sizeof(u8
),
1368 .array_type
= NO_ARRAY
,
1370 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
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
,
1380 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
1382 .ei_array
= qmi_wlanfw_ce_tgt_pipe_cfg_s_v01_ei
,
1385 .data_type
= QMI_OPT_FLAG
,
1387 .elem_size
= sizeof(u8
),
1388 .array_type
= NO_ARRAY
,
1390 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
1394 .data_type
= QMI_DATA_LEN
,
1396 .elem_size
= sizeof(u8
),
1397 .array_type
= NO_ARRAY
,
1399 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
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
,
1408 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
1410 .ei_array
= qmi_wlanfw_ce_svc_pipe_cfg_s_v01_ei
,
1413 .data_type
= QMI_OPT_FLAG
,
1415 .elem_size
= sizeof(u8
),
1416 .array_type
= NO_ARRAY
,
1418 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
1422 .data_type
= QMI_DATA_LEN
,
1424 .elem_size
= sizeof(u8
),
1425 .array_type
= NO_ARRAY
,
1427 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
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
,
1436 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
1438 .ei_array
= qmi_wlanfw_shadow_reg_cfg_s_v01_ei
,
1441 .data_type
= QMI_OPT_FLAG
,
1443 .elem_size
= sizeof(u8
),
1444 .array_type
= NO_ARRAY
,
1446 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
1447 shadow_reg_v2_valid
),
1450 .data_type
= QMI_DATA_LEN
,
1452 .elem_size
= sizeof(u8
),
1453 .array_type
= NO_ARRAY
,
1455 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
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
,
1464 .offset
= offsetof(struct qmi_wlanfw_wlan_cfg_req_msg_v01
,
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
,
1479 .elem_size
= sizeof(struct qmi_response_type_v01
),
1480 .array_type
= NO_ARRAY
,
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
= {};
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;
1533 req
.m3_cache_support_valid
= 1;
1534 req
.m3_cache_support
= 1;
1536 req
.m3_support_valid
= 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
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
);
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
);
1569 ath11k_warn(ab
, "Failed to send host capability request,err = %d\n", ret
);
1573 ret
= qmi_txn_wait(&txn
, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS
));
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
);
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
;
1596 req
= kzalloc(sizeof(*req
), GFP_KERNEL
);
1600 resp
= kzalloc(sizeof(*resp
), GFP_KERNEL
);
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
);
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
);
1632 ath11k_warn(ab
, "Failed to send indication register request, err = %d\n",
1637 ret
= qmi_txn_wait(&txn
, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS
));
1639 ath11k_warn(ab
, "failed to register fw indication %d\n", ret
);
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
);
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
= {};
1665 req
= kzalloc(sizeof(*req
), GFP_KERNEL
);
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
) {
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
));
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
);
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
);
1702 ath11k_warn(ab
, "qmi failed to respond memory request, err = %d\n",
1707 ret
= qmi_txn_wait(&txn
, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS
));
1709 ath11k_warn(ab
, "qmi failed memory request, err = %d\n", ret
);
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)
1720 ath11k_warn(ab
, "Respond mem req failed, result: %d, err: %d\n",
1721 resp
.resp
.result
, resp
.resp
.error
);
1730 static void ath11k_qmi_free_target_mem_chunk(struct ath11k_base
*ab
)
1734 if (ab
->bus_params
.fixed_mem_region
)
1737 for (i
= 0; i
< ab
->qmi
.mem_seg_count
; i
++) {
1738 if (!ab
->qmi
.target_mem
[i
].vaddr
)
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
)
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
,
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",
1768 ath11k_qmi_free_target_mem_chunk(ab
);
1769 ab
->qmi
.target_mem_delayed
= true;
1772 ath11k_err(ab
, "failed to alloc memory, size: 0x%x, type: %u\n",
1782 static int ath11k_qmi_assign_target_mem_chunk(struct ath11k_base
*ab
)
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
;
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");
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
;
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
;
1815 ath11k_warn(ab
, "qmi ignore invalid mem req type %d\n",
1816 ab
->qmi
.target_mem
[i
].type
);
1820 ab
->qmi
.mem_seg_count
= idx
;
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
= {};
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
);
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
);
1846 ath11k_warn(ab
, "qmi failed to send target cap request, err = %d\n",
1851 ret
= qmi_txn_wait(&txn
, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS
));
1853 ath11k_warn(ab
, "qmi failed target cap request %d\n", ret
);
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
);
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
;
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
);
1899 ath11k_dbg(ab
, ATH11K_DBG_QMI
, "DT bdf variant name not set.\n");
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
;
1916 case ATH11K_QMI_FILE_TYPE_BDF_GOLDEN
:
1917 memset(&bd
, 0, sizeof(bd
));
1919 ret
= ath11k_core_fetch_bdf(ab
, &bd
);
1921 ath11k_warn(ab
, "qmi failed to load BDF\n");
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
);
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
);
1938 fw_size
= min_t(u32
, ab
->hw_params
.fw
.board_size
,
1941 memcpy_toio(bdf_addr
+ ATH11K_QMI_CALDATA_OFFSET
,
1942 fw_entry
->data
, fw_size
);
1944 release_firmware(fw_entry
);
1950 req
->total_size
= fw_size
;
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
;
1962 req
= kzalloc(sizeof(*req
), GFP_KERNEL
);
1965 memset(&resp
, 0, sizeof(resp
));
1967 bdf_addr
= ioremap(ab
->hw_params
.bdf_addr
, ATH11K_QMI_BDF_MAX_SIZE
);
1969 ath11k_warn(ab
, "qmi ioremap error for BDF\n");
1974 for (type
= 0; type
< ATH11K_QMI_MAX_FILE_TYPE
; type
++) {
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;
1981 req
->data_valid
= 0;
1982 req
->data_len
= ATH11K_QMI_MAX_BDF_FILE_NAME_SIZE
;
1984 req
->bdf_type_valid
= 0;
1988 ret
= ath11k_qmi_prepare_bdf_download(ab
, type
, req
, bdf_addr
);
1992 ret
= qmi_txn_init(&ab
->qmi
.handle
, &txn
,
1993 qmi_wlanfw_bdf_download_resp_msg_v01_ei
,
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
);
2003 qmi_txn_cancel(&txn
);
2007 ret
= qmi_txn_wait(&txn
, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS
));
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
);
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
= {};
2037 req
= kzalloc(sizeof(*req
), GFP_KERNEL
);
2040 memset(&resp
, 0, sizeof(resp
));
2042 memset(&bd
, 0, sizeof(bd
));
2043 ret
= ath11k_core_fetch_bdf(ab
, &bd
);
2045 ath11k_warn(ab
, "qmi failed to load bdf:\n");
2052 if (bd
.len
>= SELFMAG
&& memcmp(bd
.data
, ELFMAG
, SELFMAG
) == 0)
2053 bdf_type
= ATH11K_QMI_BDF_TYPE_ELF
;
2055 bdf_type
= ATH11K_QMI_BDF_TYPE_BIN
;
2057 ath11k_dbg(ab
, ATH11K_DBG_QMI
, "qmi bdf_type %d\n", bdf_type
);
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;
2073 if (remaining
> QMI_WLANFW_MAX_DATA_SIZE_V01
) {
2074 req
->data_len
= QMI_WLANFW_MAX_DATA_SIZE_V01
;
2076 req
->data_len
= remaining
;
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
,
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
);
2093 qmi_txn_cancel(&txn
);
2097 ret
= qmi_txn_wait(&txn
, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS
));
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
;
2107 remaining
-= req
->data_len
;
2108 temp
+= req
->data_len
;
2113 ath11k_core_free_bdf(ab
, &bd
);
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
;
2127 if (m3_mem
->vaddr
|| m3_mem
->size
)
2130 fw
= ath11k_core_firmware_request(ab
, ATH11K_M3_FILE
);
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
);
2139 m3_mem
->vaddr
= dma_alloc_coherent(ab
->dev
,
2140 fw
->size
, &m3_mem
->paddr
,
2142 if (!m3_mem
->vaddr
) {
2143 ath11k_err(ab
, "failed to allocate memory for M3 with size %zu\n",
2145 release_firmware(fw
);
2149 memcpy(m3_mem
->vaddr
, fw
->data
, fw
->size
);
2150 m3_mem
->size
= fw
->size
;
2151 release_firmware(fw
);
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
)
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
= {};
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
);
2182 ath11k_err(ab
, "failed to load m3 firmware: %d", ret
);
2186 req
.addr
= m3_mem
->paddr
;
2187 req
.size
= m3_mem
->size
;
2193 ret
= qmi_txn_init(&ab
->qmi
.handle
, &txn
,
2194 qmi_wlanfw_m3_info_resp_msg_v01_ei
, &resp
);
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
);
2203 ath11k_warn(ab
, "qmi failed to send M3 information request, err = %d\n",
2208 ret
= qmi_txn_wait(&txn
, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS
));
2210 ath11k_warn(ab
, "qmi failed M3 information request %d\n", ret
);
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
);
2224 static int ath11k_qmi_wlanfw_mode_send(struct ath11k_base
*ab
,
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
= {};
2232 memset(&req
, 0, sizeof(req
));
2233 memset(&resp
, 0, sizeof(resp
));
2236 req
.hw_debug_valid
= 1;
2239 ret
= qmi_txn_init(&ab
->qmi
.handle
, &txn
,
2240 qmi_wlanfw_wlan_mode_resp_msg_v01_ei
, &resp
);
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
);
2249 ath11k_warn(ab
, "qmi failed to send mode request, mode: %d, err = %d\n",
2254 ret
= qmi_txn_wait(&txn
, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS
));
2256 if (mode
== ATH11K_FIRMWARE_MODE_OFF
&& ret
== -ENETRESET
) {
2257 ath11k_warn(ab
, "WLFW service is dis-connected\n");
2260 ath11k_warn(ab
, "qmi failed set mode request, mode: %d, err = %d\n",
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
);
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
);
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
);
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
);
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
);
2341 ath11k_warn(ab
, "qmi failed to send wlan config request, err = %d\n",
2346 ret
= qmi_txn_wait(&txn
, msecs_to_jiffies(ATH11K_QMI_WLANFW_TIMEOUT_MS
));
2348 ath11k_warn(ab
, "qmi failed wlan config request, err = %d\n", ret
);
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
);
2364 void ath11k_qmi_firmware_stop(struct ath11k_base
*ab
)
2368 ret
= ath11k_qmi_wlanfw_mode_send(ab
, ATH11K_FIRMWARE_MODE_OFF
);
2370 ath11k_warn(ab
, "qmi failed to send wlan mode off\n");
2375 int ath11k_qmi_firmware_start(struct ath11k_base
*ab
,
2380 ret
= ath11k_qmi_wlanfw_wlan_cfg_send(ab
);
2382 ath11k_warn(ab
, "qmi failed to send wlan cfg:%d\n", ret
);
2386 ret
= ath11k_qmi_wlanfw_mode_send(ab
, mode
);
2388 ath11k_warn(ab
, "qmi failed to send wlan fw mode:%d\n", ret
);
2395 static int ath11k_qmi_process_coldboot_calibration(struct ath11k_base
*ab
)
2400 ret
= ath11k_qmi_wlanfw_mode_send(ab
, ATH11K_FIRMWARE_MODE_COLD_BOOT
);
2402 ath11k_warn(ab
, "qmi failed to send wlan fw mode:%d\n", 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
);
2412 ath11k_warn(ab
, "Coldboot Calibration failed - wait ended\n");
2416 ath11k_dbg(ab
, ATH11K_DBG_QMI
, "Coldboot calibration done\n");
2422 ath11k_qmi_driver_event_post(struct ath11k_qmi
*qmi
,
2423 enum ath11k_qmi_event_type type
,
2426 struct ath11k_qmi_driver_event
*event
;
2428 event
= kzalloc(sizeof(*event
), GFP_ATOMIC
);
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
);
2444 static int ath11k_qmi_event_server_arrive(struct ath11k_qmi
*qmi
)
2446 struct ath11k_base
*ab
= qmi
->ab
;
2449 ret
= ath11k_qmi_fw_ind_register_send(ab
);
2451 ath11k_warn(ab
, "qmi failed to send FW indication QMI:%d\n", ret
);
2455 ret
= ath11k_qmi_host_cap_send(ab
);
2457 ath11k_warn(ab
, "qmi failed to send host cap QMI:%d\n", ret
);
2464 static int ath11k_qmi_event_mem_request(struct ath11k_qmi
*qmi
)
2466 struct ath11k_base
*ab
= qmi
->ab
;
2469 ret
= ath11k_qmi_respond_fw_mem_request(ab
);
2471 ath11k_warn(ab
, "qmi failed to respond fw mem req:%d\n", ret
);
2478 static int ath11k_qmi_event_load_bdf(struct ath11k_qmi
*qmi
)
2480 struct ath11k_base
*ab
= qmi
->ab
;
2483 ret
= ath11k_qmi_request_target_cap(ab
);
2485 ath11k_warn(ab
, "qmi failed to req target capabilities:%d\n", ret
);
2489 if (ab
->bus_params
.fixed_bdf_addr
)
2490 ret
= ath11k_qmi_load_bdf_fixed_addr(ab
);
2492 ret
= ath11k_qmi_load_bdf_qmi(ab
);
2494 ath11k_warn(ab
, "qmi failed to load board data file:%d\n", ret
);
2498 ret
= ath11k_qmi_wlanfw_m3_info_send(ab
);
2500 ath11k_warn(ab
, "qmi failed to send m3 info req:%d\n", 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
,
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
;
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",
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
);
2536 ath11k_warn(ab
, "qmi failed to assign target memory: %d\n",
2541 ret
= ath11k_qmi_alloc_target_mem_chunk(ab
);
2543 ath11k_warn(ab
, "qmi failed to alloc target memory: %d\n",
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
,
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
;
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
,
2637 ath11k_warn(ab
, "qmi failed to connect to remote service %d\n", 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
);
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
,
2666 struct ath11k_qmi_driver_event
*event
;
2667 struct ath11k_base
*ab
= qmi
->ab
;
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
))
2680 switch (event
->type
) {
2681 case ATH11K_QMI_EVENT_SERVER_ARRIVE
:
2682 ret
= ath11k_qmi_event_server_arrive(qmi
);
2684 set_bit(ATH11K_FLAG_QMI_FAIL
, &ab
->dev_flags
);
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
);
2690 case ATH11K_QMI_EVENT_REQUEST_MEM
:
2691 ret
= ath11k_qmi_event_mem_request(qmi
);
2693 set_bit(ATH11K_FLAG_QMI_FAIL
, &ab
->dev_flags
);
2695 case ATH11K_QMI_EVENT_FW_MEM_READY
:
2696 ret
= ath11k_qmi_event_load_bdf(qmi
);
2698 set_bit(ATH11K_FLAG_QMI_FAIL
, &ab
->dev_flags
);
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
);
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
);
2712 clear_bit(ATH11K_FLAG_CRASH_FLUSH
,
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
);
2720 case ATH11K_QMI_EVENT_COLD_BOOT_CAL_DONE
:
2723 ath11k_warn(ab
, "invalid event type: %d", event
->type
);
2727 spin_lock(&qmi
->event_lock
);
2729 spin_unlock(&qmi
->event_lock
);
2732 int ath11k_qmi_init_service(struct ath11k_base
*ab
)
2736 memset(&ab
->qmi
.target
, 0, sizeof(struct target_info
));
2737 memset(&ab
->qmi
.target_mem
, 0, sizeof(struct target_mem_chunk
));
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
);
2744 ath11k_warn(ab
, "failed to initialize qmi handle\n");
2748 ab
->qmi
.event_wq
= alloc_workqueue("ath11k_qmi_driver_event",
2750 if (!ab
->qmi
.event_wq
) {
2751 ath11k_err(ab
, "failed to allocate workqueue\n");
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
);
2763 ath11k_warn(ab
, "failed to add qmi lookup\n");
2764 destroy_workqueue(ab
->qmi
.event_wq
);
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
);