xref: /wlan-driver/platform/inc/icnss2.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
4  * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
5  */
6 #ifndef _ICNSS_WLAN_H_
7 #define _ICNSS_WLAN_H_
8 
9 #include <linux/interrupt.h>
10 #include <linux/device.h>
11 
12 #define ICNSS_MAX_IRQ_REGISTRATIONS    12
13 #define IWCN_MAX_IRQ_REGISTRATIONS    32
14 #define ICNSS_MAX_TIMESTAMP_LEN        32
15 #define ICNSS_WLFW_MAX_BUILD_ID_LEN    128
16 #define ICNSS_MAX_DEV_MEM_NUM            4
17 
18 #define DEVICE_NAME_MAX		10
19 enum icnss_uevent {
20 	ICNSS_UEVENT_FW_CRASHED,
21 	ICNSS_UEVENT_FW_DOWN,
22 	ICNSS_UEVENT_HANG_DATA,
23 	ICNSS_UEVENT_SMMU_FAULT,
24 };
25 
26 enum icnss_device_config {
27 	ICNSS_IPA_DISABLED,
28 };
29 
30 struct icnss_uevent_hang_data {
31 	void *hang_event_data;
32 	uint16_t hang_event_data_len;
33 };
34 
35 struct icnss_uevent_fw_down_data {
36 	bool crashed;
37 };
38 
39 struct icnss_uevent_data {
40 	enum icnss_uevent uevent;
41 	void *data;
42 };
43 
44 struct icnss_dev_mem_info {
45 	u64 start;
46 	u64 size;
47 };
48 
49 /* Device information like supported device ids, etc*/
50 struct device_info {
51 	char name[DEVICE_NAME_MAX];
52 	uint16_t device_id;
53 };
54 
55 struct icnss_driver_ops {
56 	char *name;
57 	struct device_info *dev_info;
58 	unsigned long drv_state;
59 	struct device_driver driver;
60 	int (*probe)(struct device *dev);
61 	void (*remove)(struct device *dev);
62 	void (*shutdown)(struct device *dev);
63 	int (*reinit)(struct device *dev);
64 	void (*crash_shutdown)(void *pdev);
65 	int (*pm_suspend)(struct device *dev);
66 	int (*pm_resume)(struct device *dev);
67 	int (*suspend_noirq)(struct device *dev);
68 	int (*resume_noirq)(struct device *dev);
69 	int (*runtime_suspend)(struct device *dev);
70 	int (*runtime_resume)(struct device *dev);
71 	int (*uevent)(struct device *dev, struct icnss_uevent_data *uevent);
72 	int (*idle_shutdown)(struct device *dev);
73 	int (*idle_restart)(struct device *dev);
74 	int (*set_therm_cdev_state)(struct device *dev,
75 				    unsigned long thermal_state,
76 				    int tcdev_id);
77 };
78 
79 
80 struct ce_tgt_pipe_cfg {
81 	u32 pipe_num;
82 	u32 pipe_dir;
83 	u32 nentries;
84 	u32 nbytes_max;
85 	u32 flags;
86 	u32 reserved;
87 };
88 
89 struct ce_svc_pipe_cfg {
90 	u32 service_id;
91 	u32 pipe_dir;
92 	u32 pipe_num;
93 };
94 
95 struct icnss_shadow_reg_cfg {
96 	u16 ce_id;
97 	u16 reg_offset;
98 };
99 
100 struct icnss_shadow_reg_v2_cfg {
101 	u32 addr;
102 };
103 
104 struct icnss_shadow_reg_v3_cfg {
105 	u32 addr;
106 };
107 
108 struct icnss_rri_over_ddr_cfg {
109 	u32 base_addr_low;
110 	u32 base_addr_high;
111 };
112 /* CE configuration to target */
113 struct icnss_wlan_enable_cfg {
114 	u32 num_ce_tgt_cfg;
115 	struct ce_tgt_pipe_cfg *ce_tgt_cfg;
116 	u32 num_ce_svc_pipe_cfg;
117 	struct ce_svc_pipe_cfg *ce_svc_cfg;
118 	u32 num_shadow_reg_cfg;
119 	struct icnss_shadow_reg_cfg *shadow_reg_cfg;
120 	u32 num_shadow_reg_v2_cfg;
121 	struct icnss_shadow_reg_v2_cfg *shadow_reg_v2_cfg;
122 	u32 num_shadow_reg_v3_cfg;
123 	struct icnss_shadow_reg_v3_cfg *shadow_reg_v3_cfg;
124 	bool rri_over_ddr_cfg_valid;
125 	struct icnss_rri_over_ddr_cfg rri_over_ddr_cfg;
126 };
127 
128 /* driver modes */
129 enum icnss_driver_mode {
130 	ICNSS_MISSION,
131 	ICNSS_FTM,
132 	ICNSS_EPPING,
133 	ICNSS_WALTEST,
134 	ICNSS_OFF,
135 	ICNSS_CCPM,
136 	ICNSS_QVIT,
137 	ICNSS_CALIBRATION,
138 };
139 
140 enum icnss_rd_card_chain_cap {
141 	ICNSS_RD_CARD_CHAIN_CAP_UNSPECIFIED,
142 	ICNSS_RD_CARD_CHAIN_CAP_1x1,
143 	ICNSS_RD_CARD_CHAIN_CAP_2x2,
144 	ICNSS_RD_CARD_CHAIN_CAP_MAX_VAL,
145 };
146 
147 enum icnss_phy_he_channel_width_cap {
148 	ICNSS_PHY_HE_CHANNEL_WIDTH_CAP_UNSPECIFIED,
149 	ICNSS_PHY_HE_CHANNEL_WIDTH_CAP_80MHZ,
150 	ICNSS_PHY_HE_CHANNEL_WIDTH_CAP_160MHZ,
151 	ICNSS_PHY_HE_CHANNEL_WIDTH_CAP_MAX_VAL,
152 };
153 
154 enum icnss_phy_qam_cap {
155 	ICNSS_PHY_QAM_CAP_UNSPECIFIED,
156 	ICNSS_PHY_QAM_CAP_1K,
157 	ICNSS_PHY_QAM_CAP_4K,
158 	ICNSS_PHY_QAM_CAP_MAX_VAL,
159 };
160 
161 struct icnss_soc_info {
162 	void __iomem *v_addr;
163 	phys_addr_t p_addr;
164 	uint32_t chip_id;
165 	uint32_t chip_family;
166 	uint32_t board_id;
167 	uint32_t soc_id;
168 	uint32_t fw_version;
169 	char fw_build_timestamp[ICNSS_MAX_TIMESTAMP_LEN + 1];
170 	char fw_build_id[ICNSS_WLFW_MAX_BUILD_ID_LEN + 1];
171 	enum icnss_rd_card_chain_cap rd_card_chain_cap;
172 	enum icnss_phy_he_channel_width_cap phy_he_channel_width_cap;
173 	enum icnss_phy_qam_cap phy_qam_cap;
174 	struct icnss_dev_mem_info dev_mem_info[ICNSS_MAX_DEV_MEM_NUM];
175 };
176 
177 #define icnss_register_driver(ops)		\
178 	__icnss_register_driver(ops, THIS_MODULE, KBUILD_MODNAME)
179 extern int __icnss_register_driver(struct icnss_driver_ops *ops,
180 				   struct module *owner, const char *mod_name);
181 
182 extern int icnss_unregister_driver(struct icnss_driver_ops *ops);
183 
184 extern int icnss_wlan_enable(struct device *dev,
185 			     struct icnss_wlan_enable_cfg *config,
186 			     enum icnss_driver_mode mode,
187 			     const char *host_version);
188 extern int icnss_wlan_disable(struct device *dev, enum icnss_driver_mode mode);
189 extern void icnss_enable_irq(struct device *dev, unsigned int ce_id);
190 extern void icnss_disable_irq(struct device *dev, unsigned int ce_id);
191 extern int icnss_get_soc_info(struct device *dev, struct icnss_soc_info *info);
192 extern int icnss_ce_free_irq(struct device *dev, unsigned int ce_id, void *ctx);
193 extern int icnss_ce_request_irq(struct device *dev, unsigned int ce_id,
194 	irqreturn_t (*handler)(int, void *),
195 	unsigned long flags, const char *name, void *ctx);
196 extern int icnss_get_ce_id(struct device *dev, int irq);
197 extern int icnss_set_fw_log_mode(struct device *dev, uint8_t fw_log_mode);
198 extern int icnss_athdiag_read(struct device *dev, uint32_t offset,
199 			      uint32_t mem_type, uint32_t data_len,
200 			      uint8_t *output);
201 extern int icnss_athdiag_write(struct device *dev, uint32_t offset,
202 			       uint32_t mem_type, uint32_t data_len,
203 			       uint8_t *input);
204 extern int icnss_get_irq(struct device *dev, int ce_id);
205 extern int icnss_power_on(struct device *dev);
206 extern int icnss_power_off(struct device *dev);
207 extern struct dma_iommu_mapping *icnss_smmu_get_mapping(struct device *dev);
208 extern struct iommu_domain *icnss_smmu_get_domain(struct device *dev);
209 extern int icnss_smmu_map(struct device *dev, phys_addr_t paddr,
210 			  uint32_t *iova_addr, size_t size);
211 extern int icnss_smmu_unmap(struct device *dev,
212 			    uint32_t iova_addr, size_t size);
213 extern unsigned int icnss_socinfo_get_serial_number(struct device *dev);
214 extern bool icnss_is_qmi_disable(struct device *dev);
215 extern bool icnss_is_fw_ready(void);
216 extern bool icnss_is_fw_down(void);
217 extern bool icnss_is_low_power(void);
218 extern bool icnss_is_rejuvenate(void);
219 extern int icnss_trigger_recovery(struct device *dev);
220 extern void icnss_block_shutdown(bool status);
221 extern bool icnss_is_pdr(void);
222 extern int icnss_idle_restart(struct device *dev);
223 extern int icnss_idle_shutdown(struct device *dev);
224 extern int icnss_get_user_msi_assignment(struct device *dev, char *user_name,
225 				 int *num_vectors, u32 *user_base_data,
226 				 u32 *base_vector);
227 extern int icnss_get_msi_irq(struct device *dev, unsigned int vector);
228 extern void icnss_get_msi_address(struct device *dev, u32 *msi_addr_low,
229 			   u32 *msi_addr_high);
230 extern int icnss_qmi_send(struct device *dev, int type, void *cmd,
231 			  int cmd_len, void *cb_ctx,
232 			  int (*cb)(void *ctx, void *event, int event_len));
233 extern int icnss_force_wake_request(struct device *dev);
234 extern int icnss_force_wake_release(struct device *dev);
235 extern int icnss_is_device_awake(struct device *dev);
236 extern int icnss_thermal_cdev_register(struct device *dev,
237 					unsigned long max_state,
238 					int tcdev_id);
239 extern void icnss_thermal_cdev_unregister(struct device *dev, int tcdev_id);
240 extern int icnss_get_curr_therm_cdev_state(struct device *dev,
241 					    unsigned long *thermal_state,
242 					    int tcdev_id);
243 extern int icnss_exit_power_save(struct device *dev);
244 extern int icnss_prevent_l1(struct device *dev);
245 extern void icnss_allow_l1(struct device *dev);
246 extern int icnss_get_mhi_state(struct device *dev);
247 extern int icnss_is_pci_ep_awake(struct device *dev);
248 extern unsigned long icnss_get_device_config(void);
249 #endif /* _ICNSS_WLAN_H_ */
250