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