xref: /wlan-driver/qcacld-3.0/core/pld/src/pld_ipci.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4  *
5  * Permission to use, copy, modify, and/or distribute this software for
6  * any purpose with or without fee is hereby granted, provided that the
7  * above copyright notice and this permission notice appear in all
8  * copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17  * PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef __PLD_IPCI_H__
21 #define __PLD_IPCI_H__
22 
23 #ifdef CONFIG_PLD_IPCI_ICNSS
24 #ifdef CONFIG_CNSS_OUT_OF_TREE
25 #include "icnss2.h"
26 #else
27 #include <soc/qcom/icnss2.h>
28 #endif
29 #endif
30 #include "pld_internal.h"
31 
32 #ifndef CONFIG_PLD_IPCI_ICNSS
pld_ipci_register_driver(void)33 static inline int pld_ipci_register_driver(void)
34 {
35 	return 0;
36 }
37 
pld_ipci_unregister_driver(void)38 static inline void pld_ipci_unregister_driver(void)
39 {
40 }
41 
pld_ipci_wlan_enable(struct device * dev,struct pld_wlan_enable_cfg * config,enum pld_driver_mode mode,const char * host_version)42 static inline int pld_ipci_wlan_enable(struct device *dev,
43 				       struct pld_wlan_enable_cfg *config,
44 				       enum pld_driver_mode mode,
45 				       const char *host_version)
46 {
47 	return 0;
48 }
49 
pld_ipci_wlan_disable(struct device * dev,enum pld_driver_mode mode)50 static inline int pld_ipci_wlan_disable(struct device *dev,
51 					enum pld_driver_mode mode)
52 {
53 	return 0;
54 }
55 
pld_ipci_get_soc_info(struct device * dev,struct pld_soc_info * info)56 static inline int pld_ipci_get_soc_info(struct device *dev,
57 					struct pld_soc_info *info)
58 {
59 	return 0;
60 }
61 
pld_ipci_power_on(struct device * dev)62 static inline int pld_ipci_power_on(struct device *dev)
63 {
64 	return 0;
65 }
66 
pld_ipci_power_off(struct device * dev)67 static inline int pld_ipci_power_off(struct device *dev)
68 {
69 	return 0;
70 }
71 
pld_ipci_idle_restart(struct device * dev)72 static inline int pld_ipci_idle_restart(struct device *dev)
73 {
74 	return 0;
75 }
76 
pld_ipci_idle_shutdown(struct device * dev)77 static inline int pld_ipci_idle_shutdown(struct device *dev)
78 {
79 	return 0;
80 }
81 
pld_ipci_force_assert_target(struct device * dev)82 static inline int pld_ipci_force_assert_target(struct device *dev)
83 {
84 	return -EINVAL;
85 }
86 
pld_ipci_get_user_msi_assignment(struct device * dev,char * user_name,int * num_vectors,uint32_t * user_base_data,uint32_t * base_vector)87 static inline int pld_ipci_get_user_msi_assignment(struct device *dev,
88 						   char *user_name,
89 						   int *num_vectors,
90 						   uint32_t *user_base_data,
91 						   uint32_t *base_vector)
92 {
93 	return 0;
94 }
95 
pld_ipci_get_msi_irq(struct device * dev,unsigned int vector)96 static inline int pld_ipci_get_msi_irq(struct device *dev, unsigned int vector)
97 {
98 	return 0;
99 }
100 
pld_ipci_get_msi_address(struct device * dev,uint32_t * msi_addr_low,uint32_t * msi_addr_high)101 static inline void pld_ipci_get_msi_address(struct device *dev,
102 					    uint32_t *msi_addr_low,
103 					    uint32_t *msi_addr_high)
104 {
105 }
106 
pld_ipci_is_fw_down(struct device * dev)107 static inline int pld_ipci_is_fw_down(struct device *dev)
108 {
109 	return 0;
110 }
111 
pld_ipci_set_fw_log_mode(struct device * dev,u8 fw_log_mode)112 static inline int pld_ipci_set_fw_log_mode(struct device *dev, u8 fw_log_mode)
113 {
114 	return 0;
115 }
116 
pld_ipci_smmu_get_domain(struct device * dev)117 static inline void *pld_ipci_smmu_get_domain(struct device *dev)
118 {
119 	return NULL;
120 }
121 
pld_ipci_smmu_map(struct device * dev,phys_addr_t paddr,uint32_t * iova_addr,size_t size)122 static inline int pld_ipci_smmu_map(struct device *dev, phys_addr_t paddr,
123 				    uint32_t *iova_addr, size_t size)
124 {
125 	return 0;
126 }
127 
pld_ipci_smmu_unmap(struct device * dev,uint32_t iova_addr,size_t size)128 static inline int pld_ipci_smmu_unmap(struct device *dev,
129 				      uint32_t iova_addr, size_t size)
130 {
131 	return 0;
132 }
133 
pld_ipci_force_wake_request(struct device * dev)134 static inline int pld_ipci_force_wake_request(struct device *dev)
135 {
136 	return 0;
137 }
138 
pld_ipci_force_wake_release(struct device * dev)139 static inline int pld_ipci_force_wake_release(struct device *dev)
140 {
141 	return 0;
142 }
143 
pld_ipci_is_device_awake(struct device * dev)144 static inline int pld_ipci_is_device_awake(struct device *dev)
145 {
146 	return 0;
147 }
148 
pld_ipci_athdiag_read(struct device * dev,uint32_t offset,uint32_t memtype,uint32_t datalen,uint8_t * output)149 static inline int pld_ipci_athdiag_read(struct device *dev, uint32_t offset,
150 					uint32_t memtype, uint32_t datalen,
151 					uint8_t *output)
152 {
153 	return 0;
154 }
155 
pld_ipci_athdiag_write(struct device * dev,uint32_t offset,uint32_t memtype,uint32_t datalen,uint8_t * input)156 static inline int pld_ipci_athdiag_write(struct device *dev, uint32_t offset,
157 					 uint32_t memtype, uint32_t datalen,
158 					 uint8_t *input)
159 {
160 	return 0;
161 }
162 
163 static inline int
pld_ipci_qmi_send(struct device * dev,int type,void * cmd,int cmd_len,void * cb_ctx,int (* cb)(void * ctx,void * event,int event_len))164 pld_ipci_qmi_send(struct device *dev, int type, void *cmd,
165 		  int cmd_len, void *cb_ctx,
166 		  int (*cb)(void *ctx, void *event, int event_len))
167 {
168 	return 0;
169 }
170 
pld_ipci_thermal_register(struct device * dev,unsigned long max_state,int mon_id)171 static inline int pld_ipci_thermal_register(struct device *dev,
172 					    unsigned long max_state,
173 					    int mon_id)
174 {
175 	return 0;
176 }
177 
pld_ipci_thermal_unregister(struct device * dev,int mon_id)178 static inline void pld_ipci_thermal_unregister(struct device *dev,
179 					       int mon_id)
180 {
181 }
182 
pld_ipci_get_thermal_state(struct device * dev,unsigned long * thermal_state,int mon_id)183 static inline int pld_ipci_get_thermal_state(struct device *dev,
184 					     unsigned long *thermal_state,
185 					     int mon_id)
186 {
187 	return 0;
188 }
189 
pld_ipci_exit_power_save(struct device * dev)190 static inline int pld_ipci_exit_power_save(struct device *dev)
191 {
192 	return 0;
193 }
194 
pld_ipci_prevent_l1(struct device * dev)195 static inline int pld_ipci_prevent_l1(struct device *dev)
196 {
197 	return 0;
198 }
199 
pld_ipci_allow_l1(struct device * dev)200 static inline void pld_ipci_allow_l1(struct device *dev)
201 {
202 }
203 
pld_ipci_mhi_state(struct device * dev)204 static inline int pld_ipci_mhi_state(struct device *dev)
205 {
206 	return 0;
207 }
208 
pld_ipci_is_pci_ep_awake(struct device * dev)209 static inline int pld_ipci_is_pci_ep_awake(struct device *dev)
210 {
211 	return 0;
212 }
213 
pld_ipci_get_irq(struct device * dev,int ce_id)214 static inline int pld_ipci_get_irq(struct device *dev, int ce_id)
215 {
216 	return 0;
217 }
218 #else
219 /**
220  * pld_ipci_register_driver() - Register platform device callback functions
221  *
222  * Return: int
223  */
224 int pld_ipci_register_driver(void);
225 
226 /**
227  * pld_ipci_unregister_driver() - Unregister platform device callback functions
228  *
229  * Return: void
230  */
231 void pld_ipci_unregister_driver(void);
232 
233 /**
234  * pld_ipci_wlan_enable() - Enable WLAN
235  * @dev: device
236  * @config: WLAN configuration data
237  * @mode: WLAN mode
238  * @host_version: host software version
239  *
240  * This function enables WLAN FW. It passed WLAN configuration data,
241  * WLAN mode and host software version to FW.
242  *
243  * Return: 0 for success
244  *         Non zero failure code for errors
245  */
246 int pld_ipci_wlan_enable(struct device *dev,
247 			 struct pld_wlan_enable_cfg *config,
248 			 enum pld_driver_mode mode, const char *host_version);
249 
250 /**
251  * pld_ipci_wlan_disable() - Disable WLAN
252  * @dev: device
253  * @mode: WLAN mode
254  *
255  * This function disables WLAN FW. It passes WLAN mode to FW.
256  *
257  * Return: 0 for success
258  *         Non zero failure code for errors
259  */
260 int pld_ipci_wlan_disable(struct device *dev, enum pld_driver_mode mode);
261 
262 /**
263  * pld_ipci_get_soc_info() - Get SOC information
264  * @dev: device
265  * @info: buffer to SOC information
266  *
267  * Return SOC info to the buffer.
268  *
269  * Return: 0 for success
270  *         Non zero failure code for errors
271  */
272 int pld_ipci_get_soc_info(struct device *dev, struct pld_soc_info *info);
273 int pld_ipci_get_irq(struct device *dev, int ce_id);
274 
pld_ipci_power_on(struct device * dev)275 static inline int pld_ipci_power_on(struct device *dev)
276 {
277 	return icnss_power_on(dev);
278 }
279 
pld_ipci_power_off(struct device * dev)280 static inline int pld_ipci_power_off(struct device *dev)
281 {
282 	return icnss_power_off(dev);
283 }
284 
pld_ipci_idle_restart(struct device * dev)285 static inline int pld_ipci_idle_restart(struct device *dev)
286 {
287 	return icnss_idle_restart(dev);
288 }
289 
pld_ipci_idle_shutdown(struct device * dev)290 static inline int pld_ipci_idle_shutdown(struct device *dev)
291 {
292 	return icnss_idle_shutdown(dev);
293 }
294 
pld_ipci_force_assert_target(struct device * dev)295 static inline int pld_ipci_force_assert_target(struct device *dev)
296 {
297 	return icnss_trigger_recovery(dev);
298 }
299 
pld_ipci_get_user_msi_assignment(struct device * dev,char * user_name,int * num_vectors,uint32_t * user_base_data,uint32_t * base_vector)300 static inline int pld_ipci_get_user_msi_assignment(struct device *dev,
301 						   char *user_name,
302 						   int *num_vectors,
303 						   uint32_t *user_base_data,
304 						   uint32_t *base_vector)
305 {
306 	return icnss_get_user_msi_assignment(dev, user_name, num_vectors,
307 					    user_base_data, base_vector);
308 }
309 
pld_ipci_get_msi_irq(struct device * dev,unsigned int vector)310 static inline int pld_ipci_get_msi_irq(struct device *dev, unsigned int vector)
311 {
312 	return icnss_get_msi_irq(dev, vector);
313 }
314 
pld_ipci_get_msi_address(struct device * dev,uint32_t * msi_addr_low,uint32_t * msi_addr_high)315 static inline void pld_ipci_get_msi_address(struct device *dev,
316 					    uint32_t *msi_addr_low,
317 					    uint32_t *msi_addr_high)
318 {
319 	icnss_get_msi_address(dev, msi_addr_low, msi_addr_high);
320 }
321 
pld_ipci_is_fw_down(struct device * dev)322 static inline int pld_ipci_is_fw_down(struct device *dev)
323 {
324 	return icnss_is_fw_down();
325 }
326 
pld_ipci_set_fw_log_mode(struct device * dev,u8 fw_log_mode)327 static inline int pld_ipci_set_fw_log_mode(struct device *dev, u8 fw_log_mode)
328 {
329 	return icnss_set_fw_log_mode(dev, fw_log_mode);
330 }
331 
pld_ipci_smmu_get_domain(struct device * dev)332 static inline void *pld_ipci_smmu_get_domain(struct device *dev)
333 {
334 	return icnss_smmu_get_domain(dev);
335 }
336 
pld_ipci_smmu_map(struct device * dev,phys_addr_t paddr,uint32_t * iova_addr,size_t size)337 static inline int pld_ipci_smmu_map(struct device *dev, phys_addr_t paddr,
338 				    uint32_t *iova_addr, size_t size)
339 {
340 	return icnss_smmu_map(dev, paddr, iova_addr, size);
341 }
342 
343 #ifdef CONFIG_SMMU_S1_UNMAP
pld_ipci_smmu_unmap(struct device * dev,uint32_t iova_addr,size_t size)344 static inline int pld_ipci_smmu_unmap(struct device *dev,
345 				      uint32_t iova_addr, size_t size)
346 {
347 	return icnss_smmu_unmap(dev, iova_addr, size);
348 }
349 
350 #else
pld_ipci_smmu_unmap(struct device * dev,uint32_t iova_addr,size_t size)351 static inline int pld_ipci_smmu_unmap(struct device *dev,
352 				      uint32_t iova_addr, size_t size)
353 {
354 	return 0;
355 }
356 #endif
357 
pld_ipci_force_wake_request(struct device * dev)358 static inline int pld_ipci_force_wake_request(struct device *dev)
359 {
360 	return icnss_force_wake_request(dev);
361 }
362 
pld_ipci_force_wake_release(struct device * dev)363 static inline int pld_ipci_force_wake_release(struct device *dev)
364 {
365 	return icnss_force_wake_release(dev);
366 }
367 
pld_ipci_is_device_awake(struct device * dev)368 static inline int pld_ipci_is_device_awake(struct device *dev)
369 {
370 	return icnss_is_device_awake(dev);
371 }
372 
pld_ipci_athdiag_read(struct device * dev,uint32_t offset,uint32_t memtype,uint32_t datalen,uint8_t * output)373 static inline int pld_ipci_athdiag_read(struct device *dev, uint32_t offset,
374 					uint32_t memtype, uint32_t datalen,
375 					uint8_t *output)
376 {
377 	return icnss_athdiag_read(dev, offset, memtype, datalen, output);
378 }
379 
pld_ipci_athdiag_write(struct device * dev,uint32_t offset,uint32_t memtype,uint32_t datalen,uint8_t * input)380 static inline int pld_ipci_athdiag_write(struct device *dev, uint32_t offset,
381 					 uint32_t memtype, uint32_t datalen,
382 					 uint8_t *input)
383 {
384 	return icnss_athdiag_write(dev, offset, memtype, datalen, input);
385 }
386 
387 static inline int
pld_ipci_qmi_send(struct device * dev,int type,void * cmd,int cmd_len,void * cb_ctx,int (* cb)(void * ctx,void * event,int event_len))388 pld_ipci_qmi_send(struct device *dev, int type, void *cmd,
389 		  int cmd_len, void *cb_ctx,
390 		  int (*cb)(void *ctx, void *event, int event_len))
391 {
392 	return icnss_qmi_send(dev, type, cmd, cmd_len, cb_ctx, cb);
393 }
394 
pld_ipci_thermal_register(struct device * dev,unsigned long max_state,int mon_id)395 static inline int pld_ipci_thermal_register(struct device *dev,
396 					    unsigned long max_state,
397 					    int mon_id)
398 {
399 	return icnss_thermal_cdev_register(dev, max_state, mon_id);
400 }
401 
pld_ipci_thermal_unregister(struct device * dev,int mon_id)402 static inline void pld_ipci_thermal_unregister(struct device *dev,
403 					       int mon_id)
404 {
405 	icnss_thermal_cdev_unregister(dev, mon_id);
406 }
407 
pld_ipci_get_thermal_state(struct device * dev,unsigned long * thermal_state,int mon_id)408 static inline int pld_ipci_get_thermal_state(struct device *dev,
409 					     unsigned long *thermal_state,
410 					     int mon_id)
411 {
412 	return icnss_get_curr_therm_cdev_state(dev, thermal_state, mon_id);
413 }
414 
pld_ipci_exit_power_save(struct device * dev)415 static inline int pld_ipci_exit_power_save(struct device *dev)
416 {
417 	return icnss_exit_power_save(dev);
418 }
419 
pld_ipci_prevent_l1(struct device * dev)420 static inline int pld_ipci_prevent_l1(struct device *dev)
421 {
422 	return icnss_prevent_l1(dev);
423 }
424 
pld_ipci_allow_l1(struct device * dev)425 static inline void pld_ipci_allow_l1(struct device *dev)
426 {
427 	icnss_allow_l1(dev);
428 }
429 
pld_ipci_is_pci_ep_awake(struct device * dev)430 static inline int pld_ipci_is_pci_ep_awake(struct device *dev)
431 {
432 	return icnss_is_pci_ep_awake(dev);
433 }
434 
pld_ipci_mhi_state(struct device * dev)435 static inline int pld_ipci_mhi_state(struct device *dev)
436 {
437 	return icnss_get_mhi_state(dev);
438 }
439 #endif
440 #endif
441