xref: /linux/drivers/net/wireless/ath/ath12k/qmi.h (revision d889913205cf7ebda905b1e62c5867ed4e39f6c2)
1*d8899132SKalle Valo /* SPDX-License-Identifier: BSD-3-Clause-Clear */
2*d8899132SKalle Valo /*
3*d8899132SKalle Valo  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4*d8899132SKalle Valo  * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
5*d8899132SKalle Valo  */
6*d8899132SKalle Valo 
7*d8899132SKalle Valo #ifndef ATH12K_QMI_H
8*d8899132SKalle Valo #define ATH12K_QMI_H
9*d8899132SKalle Valo 
10*d8899132SKalle Valo #include <linux/mutex.h>
11*d8899132SKalle Valo #include <linux/soc/qcom/qmi.h>
12*d8899132SKalle Valo 
13*d8899132SKalle Valo #define ATH12K_HOST_VERSION_STRING		"WIN"
14*d8899132SKalle Valo #define ATH12K_QMI_WLANFW_TIMEOUT_MS		10000
15*d8899132SKalle Valo #define ATH12K_QMI_MAX_BDF_FILE_NAME_SIZE	64
16*d8899132SKalle Valo #define ATH12K_QMI_CALDB_ADDRESS		0x4BA00000
17*d8899132SKalle Valo #define ATH12K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01	128
18*d8899132SKalle Valo #define ATH12K_QMI_WLFW_NODE_ID_BASE		0x07
19*d8899132SKalle Valo #define ATH12K_QMI_WLFW_SERVICE_ID_V01		0x45
20*d8899132SKalle Valo #define ATH12K_QMI_WLFW_SERVICE_VERS_V01	0x01
21*d8899132SKalle Valo #define ATH12K_QMI_WLFW_SERVICE_INS_ID_V01	0x02
22*d8899132SKalle Valo #define ATH12K_QMI_WLFW_SERVICE_INS_ID_V01_WCN7850 0x1
23*d8899132SKalle Valo 
24*d8899132SKalle Valo #define ATH12K_QMI_WLFW_SERVICE_INS_ID_V01_QCN9274	0x07
25*d8899132SKalle Valo #define ATH12K_QMI_WLANFW_MAX_TIMESTAMP_LEN_V01	32
26*d8899132SKalle Valo #define ATH12K_QMI_RESP_LEN_MAX			8192
27*d8899132SKalle Valo #define ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01	52
28*d8899132SKalle Valo #define ATH12K_QMI_CALDB_SIZE			0x480000
29*d8899132SKalle Valo #define ATH12K_QMI_BDF_EXT_STR_LENGTH		0x20
30*d8899132SKalle Valo #define ATH12K_QMI_FW_MEM_REQ_SEGMENT_CNT	3
31*d8899132SKalle Valo #define ATH12K_QMI_WLFW_MAX_DEV_MEM_NUM_V01 4
32*d8899132SKalle Valo #define ATH12K_QMI_DEVMEM_CMEM_INDEX	0
33*d8899132SKalle Valo 
34*d8899132SKalle Valo #define QMI_WLFW_REQUEST_MEM_IND_V01		0x0035
35*d8899132SKalle Valo #define QMI_WLFW_FW_MEM_READY_IND_V01		0x0037
36*d8899132SKalle Valo #define QMI_WLFW_FW_READY_IND_V01		0x0038
37*d8899132SKalle Valo 
38*d8899132SKalle Valo #define QMI_WLANFW_MAX_DATA_SIZE_V01		6144
39*d8899132SKalle Valo #define ATH12K_FIRMWARE_MODE_OFF		4
40*d8899132SKalle Valo #define ATH12K_QMI_TARGET_MEM_MODE_DEFAULT	0
41*d8899132SKalle Valo 
42*d8899132SKalle Valo #define ATH12K_BOARD_ID_DEFAULT	0xFF
43*d8899132SKalle Valo 
44*d8899132SKalle Valo struct ath12k_base;
45*d8899132SKalle Valo 
46*d8899132SKalle Valo enum ath12k_qmi_file_type {
47*d8899132SKalle Valo 	ATH12K_QMI_FILE_TYPE_BDF_GOLDEN,
48*d8899132SKalle Valo 	ATH12K_QMI_FILE_TYPE_CALDATA,
49*d8899132SKalle Valo 	ATH12K_QMI_FILE_TYPE_EEPROM,
50*d8899132SKalle Valo 	ATH12K_QMI_MAX_FILE_TYPE,
51*d8899132SKalle Valo };
52*d8899132SKalle Valo 
53*d8899132SKalle Valo enum ath12k_qmi_bdf_type {
54*d8899132SKalle Valo 	ATH12K_QMI_BDF_TYPE_BIN			= 0,
55*d8899132SKalle Valo 	ATH12K_QMI_BDF_TYPE_ELF			= 1,
56*d8899132SKalle Valo 	ATH12K_QMI_BDF_TYPE_REGDB		= 4,
57*d8899132SKalle Valo };
58*d8899132SKalle Valo 
59*d8899132SKalle Valo enum ath12k_qmi_event_type {
60*d8899132SKalle Valo 	ATH12K_QMI_EVENT_SERVER_ARRIVE,
61*d8899132SKalle Valo 	ATH12K_QMI_EVENT_SERVER_EXIT,
62*d8899132SKalle Valo 	ATH12K_QMI_EVENT_REQUEST_MEM,
63*d8899132SKalle Valo 	ATH12K_QMI_EVENT_FW_MEM_READY,
64*d8899132SKalle Valo 	ATH12K_QMI_EVENT_FW_READY,
65*d8899132SKalle Valo 	ATH12K_QMI_EVENT_REGISTER_DRIVER,
66*d8899132SKalle Valo 	ATH12K_QMI_EVENT_UNREGISTER_DRIVER,
67*d8899132SKalle Valo 	ATH12K_QMI_EVENT_RECOVERY,
68*d8899132SKalle Valo 	ATH12K_QMI_EVENT_FORCE_FW_ASSERT,
69*d8899132SKalle Valo 	ATH12K_QMI_EVENT_POWER_UP,
70*d8899132SKalle Valo 	ATH12K_QMI_EVENT_POWER_DOWN,
71*d8899132SKalle Valo 	ATH12K_QMI_EVENT_MAX,
72*d8899132SKalle Valo };
73*d8899132SKalle Valo 
74*d8899132SKalle Valo struct ath12k_qmi_driver_event {
75*d8899132SKalle Valo 	struct list_head list;
76*d8899132SKalle Valo 	enum ath12k_qmi_event_type type;
77*d8899132SKalle Valo 	void *data;
78*d8899132SKalle Valo };
79*d8899132SKalle Valo 
80*d8899132SKalle Valo struct ath12k_qmi_ce_cfg {
81*d8899132SKalle Valo 	const struct ce_pipe_config *tgt_ce;
82*d8899132SKalle Valo 	int tgt_ce_len;
83*d8899132SKalle Valo 	const struct service_to_pipe *svc_to_ce_map;
84*d8899132SKalle Valo 	int svc_to_ce_map_len;
85*d8899132SKalle Valo 	const u8 *shadow_reg;
86*d8899132SKalle Valo 	int shadow_reg_len;
87*d8899132SKalle Valo 	u32 *shadow_reg_v3;
88*d8899132SKalle Valo 	int shadow_reg_v3_len;
89*d8899132SKalle Valo };
90*d8899132SKalle Valo 
91*d8899132SKalle Valo struct ath12k_qmi_event_msg {
92*d8899132SKalle Valo 	struct list_head list;
93*d8899132SKalle Valo 	enum ath12k_qmi_event_type type;
94*d8899132SKalle Valo };
95*d8899132SKalle Valo 
96*d8899132SKalle Valo struct target_mem_chunk {
97*d8899132SKalle Valo 	u32 size;
98*d8899132SKalle Valo 	u32 type;
99*d8899132SKalle Valo 	dma_addr_t paddr;
100*d8899132SKalle Valo 	union {
101*d8899132SKalle Valo 		void __iomem *ioaddr;
102*d8899132SKalle Valo 		void *addr;
103*d8899132SKalle Valo 	} v;
104*d8899132SKalle Valo };
105*d8899132SKalle Valo 
106*d8899132SKalle Valo struct target_info {
107*d8899132SKalle Valo 	u32 chip_id;
108*d8899132SKalle Valo 	u32 chip_family;
109*d8899132SKalle Valo 	u32 board_id;
110*d8899132SKalle Valo 	u32 soc_id;
111*d8899132SKalle Valo 	u32 fw_version;
112*d8899132SKalle Valo 	u32 eeprom_caldata;
113*d8899132SKalle Valo 	char fw_build_timestamp[ATH12K_QMI_WLANFW_MAX_TIMESTAMP_LEN_V01 + 1];
114*d8899132SKalle Valo 	char fw_build_id[ATH12K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 + 1];
115*d8899132SKalle Valo 	char bdf_ext[ATH12K_QMI_BDF_EXT_STR_LENGTH];
116*d8899132SKalle Valo };
117*d8899132SKalle Valo 
118*d8899132SKalle Valo struct m3_mem_region {
119*d8899132SKalle Valo 	u32 size;
120*d8899132SKalle Valo 	dma_addr_t paddr;
121*d8899132SKalle Valo 	void *vaddr;
122*d8899132SKalle Valo };
123*d8899132SKalle Valo 
124*d8899132SKalle Valo struct dev_mem_info {
125*d8899132SKalle Valo 	u64 start;
126*d8899132SKalle Valo 	u64 size;
127*d8899132SKalle Valo };
128*d8899132SKalle Valo 
129*d8899132SKalle Valo struct ath12k_qmi {
130*d8899132SKalle Valo 	struct ath12k_base *ab;
131*d8899132SKalle Valo 	struct qmi_handle handle;
132*d8899132SKalle Valo 	struct sockaddr_qrtr sq;
133*d8899132SKalle Valo 	struct work_struct event_work;
134*d8899132SKalle Valo 	struct workqueue_struct *event_wq;
135*d8899132SKalle Valo 	struct list_head event_list;
136*d8899132SKalle Valo 	spinlock_t event_lock; /* spinlock for qmi event list */
137*d8899132SKalle Valo 	struct ath12k_qmi_ce_cfg ce_cfg;
138*d8899132SKalle Valo 	struct target_mem_chunk target_mem[ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01];
139*d8899132SKalle Valo 	u32 mem_seg_count;
140*d8899132SKalle Valo 	u32 target_mem_mode;
141*d8899132SKalle Valo 	bool target_mem_delayed;
142*d8899132SKalle Valo 	u8 cal_done;
143*d8899132SKalle Valo 	struct target_info target;
144*d8899132SKalle Valo 	struct m3_mem_region m3_mem;
145*d8899132SKalle Valo 	unsigned int service_ins_id;
146*d8899132SKalle Valo 	struct dev_mem_info dev_mem[ATH12K_QMI_WLFW_MAX_DEV_MEM_NUM_V01];
147*d8899132SKalle Valo };
148*d8899132SKalle Valo 
149*d8899132SKalle Valo #define QMI_WLANFW_HOST_CAP_REQ_MSG_V01_MAX_LEN		261
150*d8899132SKalle Valo #define QMI_WLANFW_HOST_CAP_REQ_V01			0x0034
151*d8899132SKalle Valo #define QMI_WLANFW_HOST_CAP_RESP_MSG_V01_MAX_LEN	7
152*d8899132SKalle Valo #define QMI_WLFW_HOST_CAP_RESP_V01			0x0034
153*d8899132SKalle Valo #define QMI_WLFW_MAX_NUM_GPIO_V01			32
154*d8899132SKalle Valo #define QMI_WLANFW_MAX_PLATFORM_NAME_LEN_V01		64
155*d8899132SKalle Valo #define QMI_WLANFW_MAX_HOST_DDR_RANGE_SIZE_V01		3
156*d8899132SKalle Valo 
157*d8899132SKalle Valo struct qmi_wlanfw_host_ddr_range {
158*d8899132SKalle Valo 	u64 start;
159*d8899132SKalle Valo 	u64 size;
160*d8899132SKalle Valo };
161*d8899132SKalle Valo 
162*d8899132SKalle Valo enum ath12k_qmi_target_mem {
163*d8899132SKalle Valo 	HOST_DDR_REGION_TYPE = 0x1,
164*d8899132SKalle Valo 	BDF_MEM_REGION_TYPE = 0x2,
165*d8899132SKalle Valo 	M3_DUMP_REGION_TYPE = 0x3,
166*d8899132SKalle Valo 	CALDB_MEM_REGION_TYPE = 0x4,
167*d8899132SKalle Valo 	PAGEABLE_MEM_REGION_TYPE = 0x9,
168*d8899132SKalle Valo };
169*d8899132SKalle Valo 
170*d8899132SKalle Valo enum qmi_wlanfw_host_build_type {
171*d8899132SKalle Valo 	WLANFW_HOST_BUILD_TYPE_ENUM_MIN_VAL_V01 = INT_MIN,
172*d8899132SKalle Valo 	QMI_WLANFW_HOST_BUILD_TYPE_UNSPECIFIED_V01 = 0,
173*d8899132SKalle Valo 	QMI_WLANFW_HOST_BUILD_TYPE_PRIMARY_V01 = 1,
174*d8899132SKalle Valo 	QMI_WLANFW_HOST_BUILD_TYPE_SECONDARY_V01 = 2,
175*d8899132SKalle Valo 	WLANFW_HOST_BUILD_TYPE_ENUM_MAX_VAL_V01 = INT_MAX,
176*d8899132SKalle Valo };
177*d8899132SKalle Valo 
178*d8899132SKalle Valo #define QMI_WLFW_MAX_NUM_MLO_CHIPS_V01 3
179*d8899132SKalle Valo #define QMI_WLFW_MAX_NUM_MLO_LINKS_PER_CHIP_V01 2
180*d8899132SKalle Valo 
181*d8899132SKalle Valo struct wlfw_host_mlo_chip_info_s_v01 {
182*d8899132SKalle Valo 	u8 chip_id;
183*d8899132SKalle Valo 	u8 num_local_links;
184*d8899132SKalle Valo 	u8 hw_link_id[QMI_WLFW_MAX_NUM_MLO_LINKS_PER_CHIP_V01];
185*d8899132SKalle Valo 	u8 valid_mlo_link_id[QMI_WLFW_MAX_NUM_MLO_LINKS_PER_CHIP_V01];
186*d8899132SKalle Valo };
187*d8899132SKalle Valo 
188*d8899132SKalle Valo enum ath12k_qmi_cnss_feature {
189*d8899132SKalle Valo 	CNSS_FEATURE_MIN_ENUM_VAL_V01 = INT_MIN,
190*d8899132SKalle Valo 	CNSS_QDSS_CFG_MISS_V01 = 3,
191*d8899132SKalle Valo 	CNSS_MAX_FEATURE_V01 = 64,
192*d8899132SKalle Valo 	CNSS_FEATURE_MAX_ENUM_VAL_V01 = INT_MAX,
193*d8899132SKalle Valo };
194*d8899132SKalle Valo 
195*d8899132SKalle Valo struct qmi_wlanfw_host_cap_req_msg_v01 {
196*d8899132SKalle Valo 	u8 num_clients_valid;
197*d8899132SKalle Valo 	u32 num_clients;
198*d8899132SKalle Valo 	u8 wake_msi_valid;
199*d8899132SKalle Valo 	u32 wake_msi;
200*d8899132SKalle Valo 	u8 gpios_valid;
201*d8899132SKalle Valo 	u32 gpios_len;
202*d8899132SKalle Valo 	u32 gpios[QMI_WLFW_MAX_NUM_GPIO_V01];
203*d8899132SKalle Valo 	u8 nm_modem_valid;
204*d8899132SKalle Valo 	u8 nm_modem;
205*d8899132SKalle Valo 	u8 bdf_support_valid;
206*d8899132SKalle Valo 	u8 bdf_support;
207*d8899132SKalle Valo 	u8 bdf_cache_support_valid;
208*d8899132SKalle Valo 	u8 bdf_cache_support;
209*d8899132SKalle Valo 	u8 m3_support_valid;
210*d8899132SKalle Valo 	u8 m3_support;
211*d8899132SKalle Valo 	u8 m3_cache_support_valid;
212*d8899132SKalle Valo 	u8 m3_cache_support;
213*d8899132SKalle Valo 	u8 cal_filesys_support_valid;
214*d8899132SKalle Valo 	u8 cal_filesys_support;
215*d8899132SKalle Valo 	u8 cal_cache_support_valid;
216*d8899132SKalle Valo 	u8 cal_cache_support;
217*d8899132SKalle Valo 	u8 cal_done_valid;
218*d8899132SKalle Valo 	u8 cal_done;
219*d8899132SKalle Valo 	u8 mem_bucket_valid;
220*d8899132SKalle Valo 	u32 mem_bucket;
221*d8899132SKalle Valo 	u8 mem_cfg_mode_valid;
222*d8899132SKalle Valo 	u8 mem_cfg_mode;
223*d8899132SKalle Valo 	u8 cal_duration_valid;
224*d8899132SKalle Valo 	u16 cal_duraiton;
225*d8899132SKalle Valo 	u8 platform_name_valid;
226*d8899132SKalle Valo 	char platform_name[QMI_WLANFW_MAX_PLATFORM_NAME_LEN_V01 + 1];
227*d8899132SKalle Valo 	u8 ddr_range_valid;
228*d8899132SKalle Valo 	struct qmi_wlanfw_host_ddr_range ddr_range[QMI_WLANFW_MAX_HOST_DDR_RANGE_SIZE_V01];
229*d8899132SKalle Valo 	u8 host_build_type_valid;
230*d8899132SKalle Valo 	enum qmi_wlanfw_host_build_type host_build_type;
231*d8899132SKalle Valo 	u8 mlo_capable_valid;
232*d8899132SKalle Valo 	u8 mlo_capable;
233*d8899132SKalle Valo 	u8 mlo_chip_id_valid;
234*d8899132SKalle Valo 	u16 mlo_chip_id;
235*d8899132SKalle Valo 	u8 mlo_group_id_valid;
236*d8899132SKalle Valo 	u8 mlo_group_id;
237*d8899132SKalle Valo 	u8 max_mlo_peer_valid;
238*d8899132SKalle Valo 	u16 max_mlo_peer;
239*d8899132SKalle Valo 	u8 mlo_num_chips_valid;
240*d8899132SKalle Valo 	u8 mlo_num_chips;
241*d8899132SKalle Valo 	u8 mlo_chip_info_valid;
242*d8899132SKalle Valo 	struct wlfw_host_mlo_chip_info_s_v01 mlo_chip_info[QMI_WLFW_MAX_NUM_MLO_CHIPS_V01];
243*d8899132SKalle Valo 	u8 feature_list_valid;
244*d8899132SKalle Valo 	u64 feature_list;
245*d8899132SKalle Valo 
246*d8899132SKalle Valo };
247*d8899132SKalle Valo 
248*d8899132SKalle Valo struct qmi_wlanfw_host_cap_resp_msg_v01 {
249*d8899132SKalle Valo 	struct qmi_response_type_v01 resp;
250*d8899132SKalle Valo };
251*d8899132SKalle Valo 
252*d8899132SKalle Valo #define QMI_WLANFW_IND_REGISTER_REQ_MSG_V01_MAX_LEN		54
253*d8899132SKalle Valo #define QMI_WLANFW_IND_REGISTER_REQ_V01				0x0020
254*d8899132SKalle Valo #define QMI_WLANFW_IND_REGISTER_RESP_MSG_V01_MAX_LEN		18
255*d8899132SKalle Valo #define QMI_WLANFW_IND_REGISTER_RESP_V01			0x0020
256*d8899132SKalle Valo #define QMI_WLANFW_CLIENT_ID					0x4b4e454c
257*d8899132SKalle Valo 
258*d8899132SKalle Valo struct qmi_wlanfw_ind_register_req_msg_v01 {
259*d8899132SKalle Valo 	u8 fw_ready_enable_valid;
260*d8899132SKalle Valo 	u8 fw_ready_enable;
261*d8899132SKalle Valo 	u8 initiate_cal_download_enable_valid;
262*d8899132SKalle Valo 	u8 initiate_cal_download_enable;
263*d8899132SKalle Valo 	u8 initiate_cal_update_enable_valid;
264*d8899132SKalle Valo 	u8 initiate_cal_update_enable;
265*d8899132SKalle Valo 	u8 msa_ready_enable_valid;
266*d8899132SKalle Valo 	u8 msa_ready_enable;
267*d8899132SKalle Valo 	u8 pin_connect_result_enable_valid;
268*d8899132SKalle Valo 	u8 pin_connect_result_enable;
269*d8899132SKalle Valo 	u8 client_id_valid;
270*d8899132SKalle Valo 	u32 client_id;
271*d8899132SKalle Valo 	u8 request_mem_enable_valid;
272*d8899132SKalle Valo 	u8 request_mem_enable;
273*d8899132SKalle Valo 	u8 fw_mem_ready_enable_valid;
274*d8899132SKalle Valo 	u8 fw_mem_ready_enable;
275*d8899132SKalle Valo 	u8 fw_init_done_enable_valid;
276*d8899132SKalle Valo 	u8 fw_init_done_enable;
277*d8899132SKalle Valo 	u8 rejuvenate_enable_valid;
278*d8899132SKalle Valo 	u32 rejuvenate_enable;
279*d8899132SKalle Valo 	u8 xo_cal_enable_valid;
280*d8899132SKalle Valo 	u8 xo_cal_enable;
281*d8899132SKalle Valo 	u8 cal_done_enable_valid;
282*d8899132SKalle Valo 	u8 cal_done_enable;
283*d8899132SKalle Valo };
284*d8899132SKalle Valo 
285*d8899132SKalle Valo struct qmi_wlanfw_ind_register_resp_msg_v01 {
286*d8899132SKalle Valo 	struct qmi_response_type_v01 resp;
287*d8899132SKalle Valo 	u8 fw_status_valid;
288*d8899132SKalle Valo 	u64 fw_status;
289*d8899132SKalle Valo };
290*d8899132SKalle Valo 
291*d8899132SKalle Valo #define QMI_WLANFW_REQUEST_MEM_IND_MSG_V01_MAX_LEN	1824
292*d8899132SKalle Valo #define QMI_WLANFW_RESPOND_MEM_REQ_MSG_V01_MAX_LEN	888
293*d8899132SKalle Valo #define QMI_WLANFW_RESPOND_MEM_RESP_MSG_V01_MAX_LEN	7
294*d8899132SKalle Valo #define QMI_WLANFW_REQUEST_MEM_IND_V01			0x0035
295*d8899132SKalle Valo #define QMI_WLANFW_RESPOND_MEM_REQ_V01			0x0036
296*d8899132SKalle Valo #define QMI_WLANFW_RESPOND_MEM_RESP_V01			0x0036
297*d8899132SKalle Valo #define QMI_WLANFW_MAX_NUM_MEM_CFG_V01			2
298*d8899132SKalle Valo #define QMI_WLANFW_MAX_STR_LEN_V01                      16
299*d8899132SKalle Valo 
300*d8899132SKalle Valo struct qmi_wlanfw_mem_cfg_s_v01 {
301*d8899132SKalle Valo 	u64 offset;
302*d8899132SKalle Valo 	u32 size;
303*d8899132SKalle Valo 	u8 secure_flag;
304*d8899132SKalle Valo };
305*d8899132SKalle Valo 
306*d8899132SKalle Valo enum qmi_wlanfw_mem_type_enum_v01 {
307*d8899132SKalle Valo 	WLANFW_MEM_TYPE_ENUM_MIN_VAL_V01 = INT_MIN,
308*d8899132SKalle Valo 	QMI_WLANFW_MEM_TYPE_MSA_V01 = 0,
309*d8899132SKalle Valo 	QMI_WLANFW_MEM_TYPE_DDR_V01 = 1,
310*d8899132SKalle Valo 	QMI_WLANFW_MEM_BDF_V01 = 2,
311*d8899132SKalle Valo 	QMI_WLANFW_MEM_M3_V01 = 3,
312*d8899132SKalle Valo 	QMI_WLANFW_MEM_CAL_V01 = 4,
313*d8899132SKalle Valo 	QMI_WLANFW_MEM_DPD_V01 = 5,
314*d8899132SKalle Valo 	WLANFW_MEM_TYPE_ENUM_MAX_VAL_V01 = INT_MAX,
315*d8899132SKalle Valo };
316*d8899132SKalle Valo 
317*d8899132SKalle Valo struct qmi_wlanfw_mem_seg_s_v01 {
318*d8899132SKalle Valo 	u32 size;
319*d8899132SKalle Valo 	enum qmi_wlanfw_mem_type_enum_v01 type;
320*d8899132SKalle Valo 	u32 mem_cfg_len;
321*d8899132SKalle Valo 	struct qmi_wlanfw_mem_cfg_s_v01 mem_cfg[QMI_WLANFW_MAX_NUM_MEM_CFG_V01];
322*d8899132SKalle Valo };
323*d8899132SKalle Valo 
324*d8899132SKalle Valo struct qmi_wlanfw_request_mem_ind_msg_v01 {
325*d8899132SKalle Valo 	u32 mem_seg_len;
326*d8899132SKalle Valo 	struct qmi_wlanfw_mem_seg_s_v01 mem_seg[ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01];
327*d8899132SKalle Valo };
328*d8899132SKalle Valo 
329*d8899132SKalle Valo struct qmi_wlanfw_mem_seg_resp_s_v01 {
330*d8899132SKalle Valo 	u64 addr;
331*d8899132SKalle Valo 	u32 size;
332*d8899132SKalle Valo 	enum qmi_wlanfw_mem_type_enum_v01 type;
333*d8899132SKalle Valo 	u8 restore;
334*d8899132SKalle Valo };
335*d8899132SKalle Valo 
336*d8899132SKalle Valo struct qmi_wlanfw_respond_mem_req_msg_v01 {
337*d8899132SKalle Valo 	u32 mem_seg_len;
338*d8899132SKalle Valo 	struct qmi_wlanfw_mem_seg_resp_s_v01 mem_seg[ATH12K_QMI_WLANFW_MAX_NUM_MEM_SEG_V01];
339*d8899132SKalle Valo };
340*d8899132SKalle Valo 
341*d8899132SKalle Valo struct qmi_wlanfw_respond_mem_resp_msg_v01 {
342*d8899132SKalle Valo 	struct qmi_response_type_v01 resp;
343*d8899132SKalle Valo };
344*d8899132SKalle Valo 
345*d8899132SKalle Valo struct qmi_wlanfw_fw_mem_ready_ind_msg_v01 {
346*d8899132SKalle Valo 	char placeholder;
347*d8899132SKalle Valo };
348*d8899132SKalle Valo 
349*d8899132SKalle Valo struct qmi_wlanfw_fw_ready_ind_msg_v01 {
350*d8899132SKalle Valo 	char placeholder;
351*d8899132SKalle Valo };
352*d8899132SKalle Valo 
353*d8899132SKalle Valo #define QMI_WLANFW_CAP_REQ_MSG_V01_MAX_LEN	0
354*d8899132SKalle Valo #define QMI_WLANFW_CAP_RESP_MSG_V01_MAX_LEN	207
355*d8899132SKalle Valo #define QMI_WLANFW_CAP_REQ_V01			0x0024
356*d8899132SKalle Valo #define QMI_WLANFW_CAP_RESP_V01			0x0024
357*d8899132SKalle Valo 
358*d8899132SKalle Valo enum qmi_wlanfw_pipedir_enum_v01 {
359*d8899132SKalle Valo 	QMI_WLFW_PIPEDIR_NONE_V01 = 0,
360*d8899132SKalle Valo 	QMI_WLFW_PIPEDIR_IN_V01 = 1,
361*d8899132SKalle Valo 	QMI_WLFW_PIPEDIR_OUT_V01 = 2,
362*d8899132SKalle Valo 	QMI_WLFW_PIPEDIR_INOUT_V01 = 3,
363*d8899132SKalle Valo };
364*d8899132SKalle Valo 
365*d8899132SKalle Valo struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01 {
366*d8899132SKalle Valo 	__le32 pipe_num;
367*d8899132SKalle Valo 	__le32 pipe_dir;
368*d8899132SKalle Valo 	__le32 nentries;
369*d8899132SKalle Valo 	__le32 nbytes_max;
370*d8899132SKalle Valo 	__le32 flags;
371*d8899132SKalle Valo };
372*d8899132SKalle Valo 
373*d8899132SKalle Valo struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01 {
374*d8899132SKalle Valo 	__le32 service_id;
375*d8899132SKalle Valo 	__le32 pipe_dir;
376*d8899132SKalle Valo 	__le32 pipe_num;
377*d8899132SKalle Valo };
378*d8899132SKalle Valo 
379*d8899132SKalle Valo struct qmi_wlanfw_shadow_reg_cfg_s_v01 {
380*d8899132SKalle Valo 	u16 id;
381*d8899132SKalle Valo 	u16 offset;
382*d8899132SKalle Valo };
383*d8899132SKalle Valo 
384*d8899132SKalle Valo struct qmi_wlanfw_shadow_reg_v3_cfg_s_v01 {
385*d8899132SKalle Valo 	u32 addr;
386*d8899132SKalle Valo };
387*d8899132SKalle Valo 
388*d8899132SKalle Valo struct qmi_wlanfw_memory_region_info_s_v01 {
389*d8899132SKalle Valo 	u64 region_addr;
390*d8899132SKalle Valo 	u32 size;
391*d8899132SKalle Valo 	u8 secure_flag;
392*d8899132SKalle Valo };
393*d8899132SKalle Valo 
394*d8899132SKalle Valo struct qmi_wlanfw_rf_chip_info_s_v01 {
395*d8899132SKalle Valo 	u32 chip_id;
396*d8899132SKalle Valo 	u32 chip_family;
397*d8899132SKalle Valo };
398*d8899132SKalle Valo 
399*d8899132SKalle Valo struct qmi_wlanfw_rf_board_info_s_v01 {
400*d8899132SKalle Valo 	u32 board_id;
401*d8899132SKalle Valo };
402*d8899132SKalle Valo 
403*d8899132SKalle Valo struct qmi_wlanfw_soc_info_s_v01 {
404*d8899132SKalle Valo 	u32 soc_id;
405*d8899132SKalle Valo };
406*d8899132SKalle Valo 
407*d8899132SKalle Valo struct qmi_wlanfw_fw_version_info_s_v01 {
408*d8899132SKalle Valo 	u32 fw_version;
409*d8899132SKalle Valo 	char fw_build_timestamp[ATH12K_QMI_WLANFW_MAX_TIMESTAMP_LEN_V01 + 1];
410*d8899132SKalle Valo };
411*d8899132SKalle Valo 
412*d8899132SKalle Valo struct qmi_wlanfw_dev_mem_info_s_v01 {
413*d8899132SKalle Valo 	u64 start;
414*d8899132SKalle Valo 	u64 size;
415*d8899132SKalle Valo };
416*d8899132SKalle Valo 
417*d8899132SKalle Valo enum qmi_wlanfw_cal_temp_id_enum_v01 {
418*d8899132SKalle Valo 	QMI_WLANFW_CAL_TEMP_IDX_0_V01 = 0,
419*d8899132SKalle Valo 	QMI_WLANFW_CAL_TEMP_IDX_1_V01 = 1,
420*d8899132SKalle Valo 	QMI_WLANFW_CAL_TEMP_IDX_2_V01 = 2,
421*d8899132SKalle Valo 	QMI_WLANFW_CAL_TEMP_IDX_3_V01 = 3,
422*d8899132SKalle Valo 	QMI_WLANFW_CAL_TEMP_IDX_4_V01 = 4,
423*d8899132SKalle Valo 	QMI_WLANFW_CAL_TEMP_ID_MAX_V01 = 0xFF,
424*d8899132SKalle Valo };
425*d8899132SKalle Valo 
426*d8899132SKalle Valo enum qmi_wlanfw_rd_card_chain_cap_v01 {
427*d8899132SKalle Valo 	WLFW_RD_CARD_CHAIN_CAP_MIN_VAL_V01 = INT_MIN,
428*d8899132SKalle Valo 	WLFW_RD_CARD_CHAIN_CAP_UNSPECIFIED_V01 = 0,
429*d8899132SKalle Valo 	WLFW_RD_CARD_CHAIN_CAP_1x1_V01 = 1,
430*d8899132SKalle Valo 	WLFW_RD_CARD_CHAIN_CAP_2x2_V01 = 2,
431*d8899132SKalle Valo 	WLFW_RD_CARD_CHAIN_CAP_MAX_VAL_V01 = INT_MAX,
432*d8899132SKalle Valo };
433*d8899132SKalle Valo 
434*d8899132SKalle Valo struct qmi_wlanfw_cap_resp_msg_v01 {
435*d8899132SKalle Valo 	struct qmi_response_type_v01 resp;
436*d8899132SKalle Valo 	u8 chip_info_valid;
437*d8899132SKalle Valo 	struct qmi_wlanfw_rf_chip_info_s_v01 chip_info;
438*d8899132SKalle Valo 	u8 board_info_valid;
439*d8899132SKalle Valo 	struct qmi_wlanfw_rf_board_info_s_v01 board_info;
440*d8899132SKalle Valo 	u8 soc_info_valid;
441*d8899132SKalle Valo 	struct qmi_wlanfw_soc_info_s_v01 soc_info;
442*d8899132SKalle Valo 	u8 fw_version_info_valid;
443*d8899132SKalle Valo 	struct qmi_wlanfw_fw_version_info_s_v01 fw_version_info;
444*d8899132SKalle Valo 	u8 fw_build_id_valid;
445*d8899132SKalle Valo 	char fw_build_id[ATH12K_QMI_WLANFW_MAX_BUILD_ID_LEN_V01 + 1];
446*d8899132SKalle Valo 	u8 num_macs_valid;
447*d8899132SKalle Valo 	u8 num_macs;
448*d8899132SKalle Valo 	u8 voltage_mv_valid;
449*d8899132SKalle Valo 	u32 voltage_mv;
450*d8899132SKalle Valo 	u8 time_freq_hz_valid;
451*d8899132SKalle Valo 	u32 time_freq_hz;
452*d8899132SKalle Valo 	u8 otp_version_valid;
453*d8899132SKalle Valo 	u32 otp_version;
454*d8899132SKalle Valo 	u8 eeprom_caldata_read_timeout_valid;
455*d8899132SKalle Valo 	u32 eeprom_caldata_read_timeout;
456*d8899132SKalle Valo 	u8 fw_caps_valid;
457*d8899132SKalle Valo 	u64 fw_caps;
458*d8899132SKalle Valo 	u8 rd_card_chain_cap_valid;
459*d8899132SKalle Valo 	enum qmi_wlanfw_rd_card_chain_cap_v01 rd_card_chain_cap;
460*d8899132SKalle Valo 	u8 dev_mem_info_valid;
461*d8899132SKalle Valo 	struct qmi_wlanfw_dev_mem_info_s_v01 dev_mem[ATH12K_QMI_WLFW_MAX_DEV_MEM_NUM_V01];
462*d8899132SKalle Valo };
463*d8899132SKalle Valo 
464*d8899132SKalle Valo struct qmi_wlanfw_cap_req_msg_v01 {
465*d8899132SKalle Valo 	char placeholder;
466*d8899132SKalle Valo };
467*d8899132SKalle Valo 
468*d8899132SKalle Valo #define QMI_WLANFW_BDF_DOWNLOAD_REQ_MSG_V01_MAX_LEN	6182
469*d8899132SKalle Valo #define QMI_WLANFW_BDF_DOWNLOAD_RESP_MSG_V01_MAX_LEN	7
470*d8899132SKalle Valo #define QMI_WLANFW_BDF_DOWNLOAD_RESP_V01		0x0025
471*d8899132SKalle Valo #define QMI_WLANFW_BDF_DOWNLOAD_REQ_V01			0x0025
472*d8899132SKalle Valo /* TODO: Need to check with MCL and FW team that data can be pointer and
473*d8899132SKalle Valo  * can be last element in structure
474*d8899132SKalle Valo  */
475*d8899132SKalle Valo struct qmi_wlanfw_bdf_download_req_msg_v01 {
476*d8899132SKalle Valo 	u8 valid;
477*d8899132SKalle Valo 	u8 file_id_valid;
478*d8899132SKalle Valo 	enum qmi_wlanfw_cal_temp_id_enum_v01 file_id;
479*d8899132SKalle Valo 	u8 total_size_valid;
480*d8899132SKalle Valo 	u32 total_size;
481*d8899132SKalle Valo 	u8 seg_id_valid;
482*d8899132SKalle Valo 	u32 seg_id;
483*d8899132SKalle Valo 	u8 data_valid;
484*d8899132SKalle Valo 	u32 data_len;
485*d8899132SKalle Valo 	u8 data[QMI_WLANFW_MAX_DATA_SIZE_V01];
486*d8899132SKalle Valo 	u8 end_valid;
487*d8899132SKalle Valo 	u8 end;
488*d8899132SKalle Valo 	u8 bdf_type_valid;
489*d8899132SKalle Valo 	u8 bdf_type;
490*d8899132SKalle Valo 
491*d8899132SKalle Valo };
492*d8899132SKalle Valo 
493*d8899132SKalle Valo struct qmi_wlanfw_bdf_download_resp_msg_v01 {
494*d8899132SKalle Valo 	struct qmi_response_type_v01 resp;
495*d8899132SKalle Valo };
496*d8899132SKalle Valo 
497*d8899132SKalle Valo #define QMI_WLANFW_M3_INFO_REQ_MSG_V01_MAX_MSG_LEN	18
498*d8899132SKalle Valo #define QMI_WLANFW_M3_INFO_RESP_MSG_V01_MAX_MSG_LEN	7
499*d8899132SKalle Valo #define QMI_WLANFW_M3_INFO_RESP_V01		0x003C
500*d8899132SKalle Valo #define QMI_WLANFW_M3_INFO_REQ_V01		0x003C
501*d8899132SKalle Valo 
502*d8899132SKalle Valo struct qmi_wlanfw_m3_info_req_msg_v01 {
503*d8899132SKalle Valo 	u64 addr;
504*d8899132SKalle Valo 	u32 size;
505*d8899132SKalle Valo };
506*d8899132SKalle Valo 
507*d8899132SKalle Valo struct qmi_wlanfw_m3_info_resp_msg_v01 {
508*d8899132SKalle Valo 	struct qmi_response_type_v01 resp;
509*d8899132SKalle Valo };
510*d8899132SKalle Valo 
511*d8899132SKalle Valo #define QMI_WLANFW_WLAN_MODE_REQ_MSG_V01_MAX_LEN	11
512*d8899132SKalle Valo #define QMI_WLANFW_WLAN_MODE_RESP_MSG_V01_MAX_LEN	7
513*d8899132SKalle Valo #define QMI_WLANFW_WLAN_CFG_REQ_MSG_V01_MAX_LEN		803
514*d8899132SKalle Valo #define QMI_WLANFW_WLAN_CFG_RESP_MSG_V01_MAX_LEN	7
515*d8899132SKalle Valo #define QMI_WLANFW_WLAN_MODE_REQ_V01			0x0022
516*d8899132SKalle Valo #define QMI_WLANFW_WLAN_MODE_RESP_V01			0x0022
517*d8899132SKalle Valo #define QMI_WLANFW_WLAN_CFG_REQ_V01			0x0023
518*d8899132SKalle Valo #define QMI_WLANFW_WLAN_CFG_RESP_V01			0x0023
519*d8899132SKalle Valo #define QMI_WLANFW_MAX_STR_LEN_V01			16
520*d8899132SKalle Valo #define QMI_WLANFW_MAX_NUM_CE_V01			12
521*d8899132SKalle Valo #define QMI_WLANFW_MAX_NUM_SVC_V01			24
522*d8899132SKalle Valo #define QMI_WLANFW_MAX_NUM_SHADOW_REG_V01		24
523*d8899132SKalle Valo #define QMI_WLANFW_MAX_NUM_SHADOW_REG_V3_V01		60
524*d8899132SKalle Valo 
525*d8899132SKalle Valo struct qmi_wlanfw_wlan_mode_req_msg_v01 {
526*d8899132SKalle Valo 	u32 mode;
527*d8899132SKalle Valo 	u8 hw_debug_valid;
528*d8899132SKalle Valo 	u8 hw_debug;
529*d8899132SKalle Valo };
530*d8899132SKalle Valo 
531*d8899132SKalle Valo struct qmi_wlanfw_wlan_mode_resp_msg_v01 {
532*d8899132SKalle Valo 	struct qmi_response_type_v01 resp;
533*d8899132SKalle Valo };
534*d8899132SKalle Valo 
535*d8899132SKalle Valo struct qmi_wlanfw_wlan_cfg_req_msg_v01 {
536*d8899132SKalle Valo 	u8 host_version_valid;
537*d8899132SKalle Valo 	char host_version[QMI_WLANFW_MAX_STR_LEN_V01 + 1];
538*d8899132SKalle Valo 	u8  tgt_cfg_valid;
539*d8899132SKalle Valo 	u32  tgt_cfg_len;
540*d8899132SKalle Valo 	struct qmi_wlanfw_ce_tgt_pipe_cfg_s_v01
541*d8899132SKalle Valo 			tgt_cfg[QMI_WLANFW_MAX_NUM_CE_V01];
542*d8899132SKalle Valo 	u8  svc_cfg_valid;
543*d8899132SKalle Valo 	u32 svc_cfg_len;
544*d8899132SKalle Valo 	struct qmi_wlanfw_ce_svc_pipe_cfg_s_v01
545*d8899132SKalle Valo 			svc_cfg[QMI_WLANFW_MAX_NUM_SVC_V01];
546*d8899132SKalle Valo 	u8 shadow_reg_valid;
547*d8899132SKalle Valo 	u32 shadow_reg_len;
548*d8899132SKalle Valo 	struct qmi_wlanfw_shadow_reg_cfg_s_v01
549*d8899132SKalle Valo 		shadow_reg[QMI_WLANFW_MAX_NUM_SHADOW_REG_V01];
550*d8899132SKalle Valo 	u8 shadow_reg_v3_valid;
551*d8899132SKalle Valo 	u32 shadow_reg_v3_len;
552*d8899132SKalle Valo 	struct qmi_wlanfw_shadow_reg_v3_cfg_s_v01
553*d8899132SKalle Valo 		shadow_reg_v3[QMI_WLANFW_MAX_NUM_SHADOW_REG_V3_V01];
554*d8899132SKalle Valo };
555*d8899132SKalle Valo 
556*d8899132SKalle Valo struct qmi_wlanfw_wlan_cfg_resp_msg_v01 {
557*d8899132SKalle Valo 	struct qmi_response_type_v01 resp;
558*d8899132SKalle Valo };
559*d8899132SKalle Valo 
560*d8899132SKalle Valo int ath12k_qmi_firmware_start(struct ath12k_base *ab,
561*d8899132SKalle Valo 			      u32 mode);
562*d8899132SKalle Valo void ath12k_qmi_firmware_stop(struct ath12k_base *ab);
563*d8899132SKalle Valo void ath12k_qmi_event_work(struct work_struct *work);
564*d8899132SKalle Valo void ath12k_qmi_msg_recv_work(struct work_struct *work);
565*d8899132SKalle Valo void ath12k_qmi_deinit_service(struct ath12k_base *ab);
566*d8899132SKalle Valo int ath12k_qmi_init_service(struct ath12k_base *ab);
567*d8899132SKalle Valo 
568*d8899132SKalle Valo #endif
569