xref: /wlan-driver/qcacld-3.0/core/pld/inc/pld_common.h (revision 5113495b16420b49004c444715d2daae2066e7dc)
1 /*
2  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2021-2024 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_COMMON_H__
21 #define __PLD_COMMON_H__
22 
23 #include <linux/device.h>
24 #include <linux/interrupt.h>
25 #include <linux/pm.h>
26 #include <osapi_linux.h>
27 
28 #ifdef CONFIG_CNSS_OUT_OF_TREE
29 #include "cnss2.h"
30 #else
31 #include <net/cnss2.h>
32 #endif
33 
34 #ifdef CNSS_UTILS
35 #ifdef CONFIG_CNSS_OUT_OF_TREE
36 #include "cnss_utils.h"
37 #else
38 #include <net/cnss_utils.h>
39 #endif
40 #endif
41 
42 #define PLD_IMAGE_FILE               "athwlan.bin"
43 #define PLD_UTF_FIRMWARE_FILE        "utf.bin"
44 #define PLD_BOARD_DATA_FILE          "fakeboar.bin"
45 #define PLD_OTP_FILE                 "otp.bin"
46 #define PLD_SETUP_FILE               "athsetup.bin"
47 #define PLD_EPPING_FILE              "epping.bin"
48 #define PLD_EVICTED_FILE             ""
49 #define PLD_MHI_STATE_L0	1
50 
51 #define TOTAL_DUMP_SIZE         0x00200000
52 
53 #ifdef CNSS_MEM_PRE_ALLOC
54 #ifdef CONFIG_CNSS_OUT_OF_TREE
55 #include "cnss_prealloc.h"
56 #else
57 #include <net/cnss_prealloc.h>
58 #endif
59 #endif
60 
61 #define PLD_LIMIT_LOG_FOR_SEC 6
62 /**
63  * __PLD_TRACE_RATE_LIMITED() - rate limited version of PLD_TRACE
64  * @params: parameters to pass through to PLD_TRACE
65  *
66  * This API prevents logging a message more than once in PLD_LIMIT_LOG_FOR_SEC
67  * seconds. This means any subsequent calls to this API from the same location
68  * within PLD_LIMIT_LOG_FOR_SEC seconds will be dropped.
69  *
70  * Return: None
71  */
72 #define __PLD_TRACE_RATE_LIMITED(params...)\
73 	do {\
74 		static ulong __last_ticks;\
75 		ulong __ticks = jiffies;\
76 		if (time_after(__ticks,\
77 			       __last_ticks + (HZ * PLD_LIMIT_LOG_FOR_SEC))) {\
78 			pr_err(params);\
79 			__last_ticks = __ticks;\
80 		} \
81 	} while (0)
82 
83 #define pld_err_rl(params...) __PLD_TRACE_RATE_LIMITED(params)
84 
85 /**
86  * enum pld_bus_type - bus type
87  * @PLD_BUS_TYPE_NONE: invalid bus type, only return in error cases
88  * @PLD_BUS_TYPE_PCIE: PCIE bus
89  * @PLD_BUS_TYPE_SNOC: SNOC bus
90  * @PLD_BUS_TYPE_SDIO: SDIO bus
91  * @PLD_BUS_TYPE_USB : USB bus
92  * @PLD_BUS_TYPE_SNOC_FW_SIM : SNOC FW SIM bus
93  * @PLD_BUS_TYPE_PCIE_FW_SIM : PCIE FW SIM bus
94  * @PLD_BUS_TYPE_IPCI : IPCI bus
95  * @PLD_BUS_TYPE_IPCI_FW_SIM : IPCI FW SIM bus
96  */
97 enum pld_bus_type {
98 	PLD_BUS_TYPE_NONE = -1,
99 	PLD_BUS_TYPE_PCIE = 0,
100 	PLD_BUS_TYPE_SNOC,
101 	PLD_BUS_TYPE_SDIO,
102 	PLD_BUS_TYPE_USB,
103 	PLD_BUS_TYPE_SNOC_FW_SIM,
104 	PLD_BUS_TYPE_PCIE_FW_SIM,
105 	PLD_BUS_TYPE_IPCI,
106 	PLD_BUS_TYPE_IPCI_FW_SIM,
107 };
108 
109 #define PLD_MAX_FIRMWARE_SIZE (1 * 1024 * 1024)
110 
111 /**
112  * enum pld_bus_width_type - bus bandwidth
113  * @PLD_BUS_WIDTH_NONE: don't vote for bus bandwidth
114  * @PLD_BUS_WIDTH_IDLE: vote for idle bandwidth
115  * @PLD_BUS_WIDTH_LOW: vote for low bus bandwidth
116  * @PLD_BUS_WIDTH_MEDIUM: vote for medium bus bandwidth
117  * @PLD_BUS_WIDTH_HIGH: vote for high bus bandwidth
118  * @PLD_BUS_WIDTH_MID_HIGH: vote for mid high bus bandwidth
119  * @PLD_BUS_WIDTH_VERY_HIGH: vote for very high bus bandwidth
120  * @PLD_BUS_WIDTH_ULTRA_HIGH: vote for ultra high bus bandwidth
121  * @PLD_BUS_WIDTH_LOW_LATENCY: vote for low latency bus bandwidth
122  * @PLD_BUS_WIDTH_MAX:
123  */
124 enum pld_bus_width_type {
125 	PLD_BUS_WIDTH_NONE,
126 	PLD_BUS_WIDTH_IDLE,
127 	PLD_BUS_WIDTH_LOW,
128 	PLD_BUS_WIDTH_MEDIUM,
129 	PLD_BUS_WIDTH_HIGH,
130 	PLD_BUS_WIDTH_VERY_HIGH,
131 	PLD_BUS_WIDTH_ULTRA_HIGH,
132 	PLD_BUS_WIDTH_MAX,
133 	PLD_BUS_WIDTH_LOW_LATENCY,
134 	PLD_BUS_WIDTH_MID_HIGH,
135 };
136 
137 #define PLD_MAX_FILE_NAME NAME_MAX
138 
139 /**
140  * struct pld_fw_files - WLAN FW file names
141  * @image_file: WLAN FW image file
142  * @board_data: WLAN FW board data file
143  * @otp_data: WLAN FW OTP file
144  * @utf_file: WLAN FW UTF file
145  * @utf_board_data: WLAN FW UTF board data file
146  * @epping_file: WLAN FW EPPING mode file
147  * @evicted_data: WLAN FW evicted file
148  * @setup_file: WLAN FW setup file
149  * @ibss_image_file: WLAN FW IBSS mode file
150  *
151  * pld_fw_files is used to store WLAN FW file names
152  */
153 struct pld_fw_files {
154 	char image_file[PLD_MAX_FILE_NAME];
155 	char board_data[PLD_MAX_FILE_NAME];
156 	char otp_data[PLD_MAX_FILE_NAME];
157 	char utf_file[PLD_MAX_FILE_NAME];
158 	char utf_board_data[PLD_MAX_FILE_NAME];
159 	char epping_file[PLD_MAX_FILE_NAME];
160 	char evicted_data[PLD_MAX_FILE_NAME];
161 	char setup_file[PLD_MAX_FILE_NAME];
162 	char ibss_image_file[PLD_MAX_FILE_NAME];
163 };
164 
165 /**
166  * enum pld_platform_cap_flag - platform capability flag
167  * @PLD_HAS_EXTERNAL_SWREG: has external regulator
168  * @PLD_HAS_UART_ACCESS: has UART access
169  * @PLD_HAS_DRV_SUPPORT: has PCIe DRV support
170  */
171 enum pld_platform_cap_flag {
172 	PLD_HAS_EXTERNAL_SWREG = 0x01,
173 	PLD_HAS_UART_ACCESS = 0x02,
174 	PLD_HAS_DRV_SUPPORT = 0x04,
175 };
176 
177 /**
178  * enum pld_wfc_mode - WFC Mode
179  * @PLD_WFC_MODE_OFF: WFC Inactive
180  * @PLD_WFC_MODE_ON: WFC Active
181  */
182 enum pld_wfc_mode {
183 	PLD_WFC_MODE_OFF,
184 	PLD_WFC_MODE_ON,
185 };
186 
187 /**
188  * struct pld_platform_cap - platform capabilities
189  * @cap_flag: capabilities flag
190  *
191  * pld_platform_cap provides platform capabilities which are
192  * extracted from DTS.
193  */
194 struct pld_platform_cap {
195 	u32 cap_flag;
196 };
197 
198 /**
199  * enum pld_uevent - PLD uevent event types
200  * @PLD_FW_DOWN: firmware is down
201  * @PLD_FW_CRASHED: firmware has crashed
202  * @PLD_FW_RECOVERY_START: firmware is starting recovery
203  * @PLD_FW_HANG_EVENT: firmware update hang event
204  * @PLD_BUS_EVENT: update bus/link event
205  * @PLD_SMMU_FAULT: SMMU fault
206  * @PLD_SYS_REBOOT: system is rebooting
207  */
208 enum pld_uevent {
209 	PLD_FW_DOWN,
210 	PLD_FW_CRASHED,
211 	PLD_FW_RECOVERY_START,
212 	PLD_FW_HANG_EVENT,
213 	PLD_BUS_EVENT,
214 	PLD_SMMU_FAULT,
215 	PLD_SYS_REBOOT,
216 };
217 
218 /**
219  * enum pld_bus_event - PLD bus event types
220  * @PLD_BUS_EVENT_PCIE_LINK_DOWN: PCIe link is down
221  * @PLD_BUS_EVENT_INVALID: invalid event type
222  */
223 
224 enum pld_bus_event {
225 	PLD_BUS_EVENT_PCIE_LINK_DOWN = 0,
226 
227 	PLD_BUS_EVENT_INVALID = 0xFFFF,
228 };
229 
230 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
231 /**
232  * enum pld_device_config - Get PLD device config
233  * @PLD_IPA_DISABLED: IPA is disabled
234  */
235 enum pld_device_config {
236 	PLD_IPA_DISABLED,
237 };
238 #endif
239 
240 /**
241  * struct pld_uevent_data - uevent status received from platform driver
242  * @uevent: uevent type
243  * @fw_down: FW down info
244  * @hang_data: FW hang data
245  * @bus_data: bus related data
246  */
247 struct pld_uevent_data {
248 	enum pld_uevent uevent;
249 	union {
250 		struct {
251 			bool crashed;
252 		} fw_down;
253 		struct {
254 			void *hang_event_data;
255 			u16 hang_event_data_len;
256 		} hang_data;
257 		struct {
258 			enum pld_bus_event etype;
259 			void *event_data;
260 		} bus_data;
261 	};
262 };
263 
264 /**
265  * struct pld_ce_tgt_pipe_cfg - copy engine target pipe configuration
266  * @pipe_num: pipe number
267  * @pipe_dir: pipe direction
268  * @nentries: number of entries
269  * @nbytes_max: max number of bytes
270  * @flags: flags
271  * @reserved: reserved
272  *
273  * pld_ce_tgt_pipe_cfg is used to store copy engine target pipe
274  * configuration.
275  */
276 struct pld_ce_tgt_pipe_cfg {
277 	u32 pipe_num;
278 	u32 pipe_dir;
279 	u32 nentries;
280 	u32 nbytes_max;
281 	u32 flags;
282 	u32 reserved;
283 };
284 
285 /**
286  * struct pld_ce_svc_pipe_cfg - copy engine service pipe configuration
287  * @service_id: service ID
288  * @pipe_dir: pipe direction
289  * @pipe_num: pipe number
290  *
291  * pld_ce_svc_pipe_cfg is used to store copy engine service pipe
292  * configuration.
293  */
294 struct pld_ce_svc_pipe_cfg {
295 	u32 service_id;
296 	u32 pipe_dir;
297 	u32 pipe_num;
298 };
299 
300 /**
301  * struct pld_shadow_reg_cfg - shadow register configuration
302  * @ce_id: copy engine ID
303  * @reg_offset: register offset
304  *
305  * pld_shadow_reg_cfg is used to store shadow register configuration.
306  */
307 struct pld_shadow_reg_cfg {
308 	u16 ce_id;
309 	u16 reg_offset;
310 };
311 
312 /**
313  * struct pld_shadow_reg_v2_cfg - shadow register version 2 configuration
314  * @addr: shadow register physical address
315  *
316  * pld_shadow_reg_v2_cfg is used to store shadow register version 2
317  * configuration.
318  */
319 struct pld_shadow_reg_v2_cfg {
320 	u32 addr;
321 };
322 
323 #ifdef CONFIG_SHADOW_V3
324 struct pld_shadow_reg_v3_cfg {
325 	u32 addr;
326 };
327 #endif
328 
329 /**
330  * struct pld_rri_over_ddr_cfg - rri_over_ddr configuration
331  * @base_addr_low: lower 32bit
332  * @base_addr_high: higher 32bit
333  *
334  * pld_rri_over_ddr_cfg_s is used in Genoa to pass rri_over_ddr configuration
335  * to firmware to update ring/write index in host DDR.
336  */
337 struct pld_rri_over_ddr_cfg {
338 	u32 base_addr_low;
339 	u32 base_addr_high;
340 };
341 
342 /**
343  * struct pld_wlan_enable_cfg - WLAN FW configuration
344  * @num_ce_tgt_cfg: number of CE target configuration
345  * @ce_tgt_cfg: CE target configuration
346  * @num_ce_svc_pipe_cfg: number of CE service configuration
347  * @ce_svc_cfg: CE service configuration
348  * @num_shadow_reg_cfg: number of shadow register configuration
349  * @shadow_reg_cfg: shadow register configuration
350  * @num_shadow_reg_v2_cfg: number of shadow register version 2 configuration
351  * @shadow_reg_v2_cfg: shadow register version 2 configuration
352  * @rri_over_ddr_cfg_valid: valid flag for rri_over_ddr config
353  * @rri_over_ddr_cfg: rri over ddr config
354  * @num_shadow_reg_v3_cfg: number of shadow register version 3 configuration
355  * @shadow_reg_v3_cfg: shadow register version 3 configuration
356  *
357  * pld_wlan_enable_cfg stores WLAN FW configurations. It will be
358  * passed to WLAN FW when WLAN host driver calls wlan_enable.
359  */
360 struct pld_wlan_enable_cfg {
361 	u32 num_ce_tgt_cfg;
362 	struct pld_ce_tgt_pipe_cfg *ce_tgt_cfg;
363 	u32 num_ce_svc_pipe_cfg;
364 	struct pld_ce_svc_pipe_cfg *ce_svc_cfg;
365 	u32 num_shadow_reg_cfg;
366 	struct pld_shadow_reg_cfg *shadow_reg_cfg;
367 	u32 num_shadow_reg_v2_cfg;
368 	struct pld_shadow_reg_v2_cfg *shadow_reg_v2_cfg;
369 	bool rri_over_ddr_cfg_valid;
370 	struct pld_rri_over_ddr_cfg rri_over_ddr_cfg;
371 #ifdef CONFIG_SHADOW_V3
372 	u32 num_shadow_reg_v3_cfg;
373 	struct pld_shadow_reg_v3_cfg *shadow_reg_v3_cfg;
374 #endif
375 };
376 
377 /**
378  * enum pld_driver_mode - WLAN host driver mode
379  * @PLD_MISSION: mission mode
380  * @PLD_FTM: FTM mode
381  * @PLD_EPPING: EPPING mode
382  * @PLD_WALTEST: WAL test mode, FW standalone test mode
383  * @PLD_OFF: OFF mode
384  * @PLD_COLDBOOT_CALIBRATION: Cold Boot Calibration Mode
385  * @PLD_FTM_COLDBOOT_CALIBRATION: Cold Boot Calibration for FTM Mode
386  */
387 enum pld_driver_mode {
388 	PLD_MISSION,
389 	PLD_FTM,
390 	PLD_EPPING,
391 	PLD_WALTEST,
392 	PLD_OFF,
393 	PLD_COLDBOOT_CALIBRATION = 7,
394 	PLD_FTM_COLDBOOT_CALIBRATION = 10
395 };
396 
397 /**
398  * struct pld_device_version - WLAN device version info
399  * @family_number: family number of WLAN SOC HW
400  * @device_number: device number of WLAN SOC HW
401  * @major_version: major version of WLAN SOC HW
402  * @minor_version: minor version of WLAN SOC HW
403  *
404  * pld_device_version is used to store WLAN device version info
405  */
406 
407 struct pld_device_version {
408 	u32 family_number;
409 	u32 device_number;
410 	u32 major_version;
411 	u32 minor_version;
412 };
413 
414 /**
415  * struct pld_dev_mem_info - WLAN device memory info
416  * @start: start address of the memory block
417  * @size: size of the memory block
418  *
419  * pld_dev_mem_info is used to store WLAN device memory info
420  */
421 struct pld_dev_mem_info {
422 	u64 start;
423 	u64 size;
424 };
425 
426 /**
427  * enum pld_wlan_hw_nss_info - WLAN HW nss info
428  * @PLD_WLAN_HW_CAP_NSS_UNSPECIFIED: nss info not specified
429  * @PLD_WLAN_HW_CAP_NSS_1x1: supported nss link 1x1
430  * @PLD_WLAN_HW_CAP_NSS_2x2: supported nss link 2x2
431  */
432 enum pld_wlan_hw_nss_info {
433 	PLD_WLAN_HW_CAP_NSS_UNSPECIFIED,
434 	PLD_WLAN_HW_CAP_NSS_1x1,
435 	PLD_WLAN_HW_CAP_NSS_2x2
436 };
437 
438 /**
439  * enum pld_wlan_hw_channel_bw_info - WLAN HW channel bw info
440  * @PLD_WLAN_HW_CHANNEL_BW_UNSPECIFIED: bw info not specified
441  * @PLD_WLAN_HW_CHANNEL_BW_80MHZ: supported bw 80MHZ
442  * @PLD_WLAN_HW_CHANNEL_BW_160MHZ: supported bw 160MHZ
443  */
444 enum pld_wlan_hw_channel_bw_info  {
445 	PLD_WLAN_HW_CHANNEL_BW_UNSPECIFIED,
446 	PLD_WLAN_HW_CHANNEL_BW_80MHZ,
447 	PLD_WLAN_HW_CHANNEL_BW_160MHZ
448 };
449 
450 /**
451  * enum pld_wlan_hw_qam_info - WLAN HW qam info
452  * @PLD_WLAN_HW_QAM_UNSPECIFIED: QAM info not specified
453  * @PLD_WLAN_HW_QAM_1K: 1K QAM supported
454  * @PLD_WLAN_HW_QAM_4K: 4K QAM supported
455  */
456 enum pld_wlan_hw_qam_info  {
457 	PLD_WLAN_HW_QAM_UNSPECIFIED,
458 	PLD_WLAN_HW_QAM_1K,
459 	PLD_WLAN_HW_QAM_4K
460 };
461 
462 /**
463  * struct pld_wlan_hw_cap_info - WLAN HW cap info
464  * @nss: nss info
465  * @bw: bw info
466  * @qam: qam info
467  */
468 struct pld_wlan_hw_cap_info {
469 	enum pld_wlan_hw_nss_info nss;
470 	enum pld_wlan_hw_channel_bw_info bw;
471 	enum pld_wlan_hw_qam_info qam;
472 };
473 
474 #define PLD_MAX_TIMESTAMP_LEN 32
475 #define PLD_WLFW_MAX_BUILD_ID_LEN 128
476 #define PLD_MAX_DEV_MEM_NUM 4
477 
478 /**
479  * struct pld_soc_info - SOC information
480  * @v_addr: virtual address of preallocated memory
481  * @p_addr: physical address of preallcoated memory
482  * @chip_id: chip ID
483  * @chip_family: chip family
484  * @board_id: board ID
485  * @soc_id: SOC ID
486  * @fw_version: FW version
487  * @fw_build_timestamp: FW build timestamp
488  * @device_version: WLAN device version info
489  * @dev_mem_info: WLAN device memory info
490  * @fw_build_id: Firmware build identifier
491  * @hw_cap_info: WLAN HW capabilities info
492  *
493  * pld_soc_info is used to store WLAN SOC information.
494  */
495 struct pld_soc_info {
496 	void __iomem *v_addr;
497 	phys_addr_t p_addr;
498 	u32 chip_id;
499 	u32 chip_family;
500 	u32 board_id;
501 	u32 soc_id;
502 	u32 fw_version;
503 	char fw_build_timestamp[PLD_MAX_TIMESTAMP_LEN + 1];
504 	struct pld_device_version device_version;
505 	struct pld_dev_mem_info dev_mem_info[PLD_MAX_DEV_MEM_NUM];
506 	char fw_build_id[PLD_WLFW_MAX_BUILD_ID_LEN + 1];
507 	struct pld_wlan_hw_cap_info hw_cap_info;
508 };
509 
510 /**
511  * enum pld_recovery_reason - WLAN host driver recovery reason
512  * @PLD_REASON_DEFAULT: default
513  * @PLD_REASON_LINK_DOWN: PCIe link down
514  */
515 enum pld_recovery_reason {
516 	PLD_REASON_DEFAULT,
517 	PLD_REASON_LINK_DOWN
518 };
519 
520 #ifdef FEATURE_WLAN_TIME_SYNC_FTM
521 /**
522  * enum pld_wlan_time_sync_trigger_type - WLAN time sync trigger type
523  * @PLD_TRIGGER_POSITIVE_EDGE: Positive edge trigger
524  * @PLD_TRIGGER_NEGATIVE_EDGE: Negative edge trigger
525  */
526 enum pld_wlan_time_sync_trigger_type {
527 	PLD_TRIGGER_POSITIVE_EDGE,
528 	PLD_TRIGGER_NEGATIVE_EDGE
529 };
530 #endif /* FEATURE_WLAN_TIME_SYNC_FTM */
531 
532 /* MAX channel avoid ranges supported in PLD */
533 #define PLD_CH_AVOID_MAX_RANGE   4
534 
535 /**
536  * struct pld_ch_avoid_freq_type
537  * @start_freq: start freq (MHz)
538  * @end_freq: end freq (Mhz)
539  */
540 struct pld_ch_avoid_freq_type {
541 	uint32_t start_freq;
542 	uint32_t end_freq;
543 };
544 
545 /**
546  * struct pld_ch_avoid_ind_type
547  * @ch_avoid_range_cnt: count
548  * @avoid_freq_range: avoid freq range array
549  */
550 struct pld_ch_avoid_ind_type {
551 	uint32_t ch_avoid_range_cnt;
552 	struct pld_ch_avoid_freq_type
553 		avoid_freq_range[PLD_CH_AVOID_MAX_RANGE];
554 };
555 
556 /**
557  * struct pld_driver_ops - driver callback functions
558  * @probe: required operation, will be called when device is detected
559  * @remove: required operation, will be called when device is removed
560  * @idle_shutdown: required operation, will be called when device is doing
561  *                 idle shutdown after interface inactivity timer has fired
562  * @idle_restart: required operation, will be called when device is doing
563  *                idle restart after idle shutdown
564  * @shutdown: optional operation, will be called during SSR
565  * @reinit: optional operation, will be called during SSR
566  * @crash_shutdown: optional operation, will be called when a crash is
567  *                  detected
568  * @suspend: required operation, will be called for power management
569  *           is enabled
570  * @resume: required operation, will be called for power management
571  *          is enabled
572  * @reset_resume: required operation, will be called for power management
573  *                is enabled
574  * @modem_status: optional operation, will be called when platform driver
575  *                sending modem power status to WLAN FW
576  * @uevent: optional operation, will be called when platform driver
577  *                 updating driver status
578  * @collect_driver_dump: optional operation, will be called during SSR to
579  *                       collect driver memory dump
580  * @runtime_suspend: optional operation, prepare the device for a condition
581  *                   in which it won't be able to communicate with the CPU(s)
582  *                   and RAM due to power management.
583  * @runtime_resume: optional operation, put the device into the fully
584  *                  active state in response to a wakeup event generated by
585  *                  hardware or at the request of software.
586  * @suspend_noirq: optional operation, complete the actions started by suspend()
587  * @resume_noirq: optional operation, prepare for the execution of resume()
588  * @set_curr_therm_cdev_state: optional operation, will be called when there is
589  *                        change in the thermal level triggered by the thermal
590  *                        subsystem thus requiring mitigation actions. This will
591  *                        be called every time there is a change in the state
592  *                        and after driver load.
593  */
594 struct pld_driver_ops {
595 	int (*probe)(struct device *dev,
596 		     enum pld_bus_type bus_type,
597 		     void *bdev, void *id);
598 	void (*remove)(struct device *dev,
599 		       enum pld_bus_type bus_type);
600 	int (*idle_shutdown)(struct device *dev,
601 			      enum pld_bus_type bus_type);
602 	int (*idle_restart)(struct device *dev,
603 			     enum pld_bus_type bus_type);
604 	void (*shutdown)(struct device *dev,
605 			 enum pld_bus_type bus_type);
606 	int (*reinit)(struct device *dev,
607 		      enum pld_bus_type bus_type,
608 		      void *bdev, void *id);
609 	void (*crash_shutdown)(struct device *dev,
610 			       enum pld_bus_type bus_type);
611 	int (*suspend)(struct device *dev,
612 		       enum pld_bus_type bus_type,
613 		       pm_message_t state);
614 	int (*resume)(struct device *dev,
615 		      enum pld_bus_type bus_type);
616 	int (*reset_resume)(struct device *dev,
617 		      enum pld_bus_type bus_type);
618 	void (*modem_status)(struct device *dev,
619 			     enum pld_bus_type bus_type,
620 			     int state);
621 	void (*uevent)(struct device *dev, struct pld_uevent_data *uevent);
622 #ifdef WLAN_FEATURE_SSR_DRIVER_DUMP
623 	int (*collect_driver_dump)(struct device *dev,
624 				   enum pld_bus_type bus_type,
625 				   struct cnss_ssr_driver_dump_entry
626 				   *input_array,
627 				   size_t *num_entries_loaded);
628 #endif
629 	int (*runtime_suspend)(struct device *dev,
630 			       enum pld_bus_type bus_type);
631 	int (*runtime_resume)(struct device *dev,
632 			      enum pld_bus_type bus_type);
633 	int (*suspend_noirq)(struct device *dev,
634 			     enum pld_bus_type bus_type);
635 	int (*resume_noirq)(struct device *dev,
636 			    enum pld_bus_type bus_type);
637 	int (*set_curr_therm_cdev_state)(struct device *dev,
638 					 unsigned long state,
639 					 int mon_id);
640 };
641 
642 /**
643  * pld_init() - Initialize PLD module
644  *
645  * Return: 0 for success
646  *         Non zero failure code for errors
647  */
648 int pld_init(void);
649 
650 /**
651  * pld_deinit() - Uninitialize PLD module
652  *
653  * Return: void
654  */
655 void pld_deinit(void);
656 
657 /**
658  * pld_set_mode() - set driver mode in PLD module
659  * @mode: driver mode
660  *
661  * Return: 0 for success
662  *         Non zero failure code for errors
663  */
664 int pld_set_mode(u8 mode);
665 
666 /**
667  * pld_register_driver() - Register driver to kernel
668  * @ops: Callback functions that will be registered to kernel
669  *
670  * This function should be called when other modules want to
671  * register platform driver callback functions to kernel. The
672  * probe() is expected to be called after registration if the
673  * device is online.
674  *
675  * Return: 0 for success
676  *         Non zero failure code for errors
677  */
678 int pld_register_driver(struct pld_driver_ops *ops);
679 
680 /**
681  * pld_unregister_driver() - Unregister driver to kernel
682  *
683  * This function should be called when other modules want to
684  * unregister callback functions from kernel. The remove() is
685  * expected to be called after registration.
686  *
687  * Return: void
688  */
689 void pld_unregister_driver(void);
690 
691 /**
692  * pld_wlan_enable() - Enable WLAN
693  * @dev: device
694  * @config: WLAN configuration data
695  * @mode: WLAN mode
696  *
697  * This function enables WLAN FW. It passed WLAN configuration data,
698  * WLAN mode and host software version to FW.
699  *
700  * Return: 0 for success
701  *         Non zero failure code for errors
702  */
703 int pld_wlan_enable(struct device *dev, struct pld_wlan_enable_cfg *config,
704 		    enum pld_driver_mode mode);
705 
706 /**
707  * pld_wlan_disable() - Disable WLAN
708  * @dev: device
709  * @mode: WLAN mode
710  *
711  * This function disables WLAN FW. It passes WLAN mode to FW.
712  *
713  * Return: 0 for success
714  *         Non zero failure code for errors
715  */
716 int pld_wlan_disable(struct device *dev, enum pld_driver_mode mode);
717 
718 /**
719  * pld_set_fw_log_mode() - Set FW debug log mode
720  * @dev: device
721  * @fw_log_mode: 0 for No log, 1 for WMI, 2 for DIAG
722  *
723  * Switch Fw debug log mode between DIAG logging and WMI logging.
724  *
725  * Return: 0 for success
726  *         Non zero failure code for errors
727  */
728 int pld_set_fw_log_mode(struct device *dev, u8 fw_log_mode);
729 
730 /**
731  * pld_get_default_fw_files() - Get default FW file names
732  * @pfw_files: buffer for FW file names
733  *
734  * Return default FW file names to the buffer.
735  *
736  * Return: void
737  */
738 void pld_get_default_fw_files(struct pld_fw_files *pfw_files);
739 
740 /**
741  * pld_get_fw_files_for_target() - Get FW file names
742  * @dev: device
743  * @pfw_files: buffer for FW file names
744  * @target_type: target type
745  * @target_version: target version
746  *
747  * Return target specific FW file names to the buffer.
748  *
749  * Return: 0 for success
750  *         Non zero failure code for errors
751  */
752 int pld_get_fw_files_for_target(struct device *dev,
753 				struct pld_fw_files *pfw_files,
754 				u32 target_type, u32 target_version);
755 
756 /**
757  * pld_prevent_l1() - Prevent PCIe enter L1 state
758  * @dev: device
759  *
760  * Prevent PCIe enter L1 and L1ss states
761  *
762  * Return: 0 for success
763  *         Non zero failure code for errors
764  */
765 int pld_prevent_l1(struct device *dev);
766 
767 /**
768  * pld_allow_l1() - Allow PCIe enter L1 state
769  * @dev: device
770  *
771  * Allow PCIe enter L1 and L1ss states
772  *
773  * Return: void
774  */
775 void pld_allow_l1(struct device *dev);
776 
777 /**
778  * pld_set_pcie_gen_speed() - Set PCIE gen speed
779  * @dev: device
780  * @pcie_gen_speed: Required PCIE gen speed
781  *
782  * Send required PCIE Gen speed to platform driver
783  *
784  * Return: 0 for success. Negative error codes.
785  */
786 int pld_set_pcie_gen_speed(struct device *dev, u8 pcie_gen_speed);
787 
788 /**
789  * pld_is_pci_link_down() - Notification for pci link down event
790  * @dev: device
791  *
792  * Notify platform that pci link is down.
793  *
794  * Return: void
795  */
796 void pld_is_pci_link_down(struct device *dev);
797 
798 /**
799  * pld_get_bus_reg_dump() - Get bus reg dump
800  * @dev: device
801  * @buf: buffer for hang data
802  * @len: len of hang data
803  *
804  * Get pci reg dump for hang data.
805  *
806  * Return: void
807  */
808 void pld_get_bus_reg_dump(struct device *dev, uint8_t *buf, uint32_t len);
809 
810 int pld_shadow_control(struct device *dev, bool enable);
811 
812 /**
813  * pld_schedule_recovery_work() - Schedule recovery work
814  * @dev: device
815  * @reason: recovery reason
816  *
817  * Schedule a system self recovery work.
818  *
819  * Return: void
820  */
821 void pld_schedule_recovery_work(struct device *dev,
822 				enum pld_recovery_reason reason);
823 
824 /**
825  * pld_wlan_hw_enable() - Enable WLAN HW
826  *
827  * This function enables WLAN HW. If WLAN is secured disabled at boot all wlan
828  * boot time activities are deferred. This is used to run deferred activities
829  * after wlan is enabled.
830  *
831  * Return: 0 for success
832  *         Non zero failure code for errors
833  */
834 int pld_wlan_hw_enable(void);
835 
836 #ifdef FEATURE_WLAN_TIME_SYNC_FTM
837 /**
838  * pld_get_audio_wlan_timestamp() - Get audio timestamp
839  * @dev: device pointer
840  * @type: trigger type
841  * @ts: audio timestamp
842  *
843  * This API can be used to get audio timestamp.
844  *
845  * Return: 0 if trigger to get audio timestamp is successful
846  *         Non zero failure code for errors
847  */
848 int pld_get_audio_wlan_timestamp(struct device *dev,
849 				 enum pld_wlan_time_sync_trigger_type type,
850 				 uint64_t *ts);
851 #endif /* FEATURE_WLAN_TIME_SYNC_FTM */
852 
853 #ifdef CNSS_UTILS
854 #ifdef CNSS_UTILS_VENDOR_UNSAFE_CHAN_API_SUPPORT
855 /**
856  * pld_get_wlan_unsafe_channel_sap() - Get vendor unsafe ch freq ranges
857  * @dev: device
858  * @ch_avoid_ranges: unsafe freq channel ranges
859  *
860  * Get vendor specific unsafe channel frequency ranges
861  *
862  * Return: 0 for success
863  *         Non zero failure code for errors
864  */
865 int pld_get_wlan_unsafe_channel_sap(
866 	struct device *dev, struct pld_ch_avoid_ind_type *ch_avoid_ranges);
867 #else
868 static inline
pld_get_wlan_unsafe_channel_sap(struct device * dev,struct pld_ch_avoid_ind_type * ch_avoid_ranges)869 int pld_get_wlan_unsafe_channel_sap(
870 	struct device *dev, struct pld_ch_avoid_ind_type *ch_avoid_ranges)
871 {
872 	return 0;
873 }
874 #endif
875 
876 /**
877  * pld_set_wlan_unsafe_channel() - Set unsafe channel
878  * @dev: device
879  * @unsafe_ch_list: unsafe channel list
880  * @ch_count: number of channel
881  *
882  * Return: 0 for success
883  *         Non zero failure code for errors
884  */
pld_set_wlan_unsafe_channel(struct device * dev,u16 * unsafe_ch_list,u16 ch_count)885 static inline int pld_set_wlan_unsafe_channel(struct device *dev,
886 					      u16 *unsafe_ch_list,
887 					      u16 ch_count)
888 {
889 	return cnss_utils_set_wlan_unsafe_channel(dev, unsafe_ch_list,
890 						  ch_count);
891 }
892 /**
893  * pld_get_wlan_unsafe_channel() - Get unsafe channel
894  * @dev: device
895  * @unsafe_ch_list: buffer to unsafe channel list
896  * @ch_count: number of channel
897  * @buf_len: buffer length
898  *
899  * Return WLAN unsafe channel to the buffer.
900  *
901  * Return: 0 for success
902  *         Non zero failure code for errors
903  */
pld_get_wlan_unsafe_channel(struct device * dev,u16 * unsafe_ch_list,u16 * ch_count,u16 buf_len)904 static inline int pld_get_wlan_unsafe_channel(struct device *dev,
905 					      u16 *unsafe_ch_list,
906 					      u16 *ch_count, u16 buf_len)
907 {
908 	return cnss_utils_get_wlan_unsafe_channel(dev, unsafe_ch_list,
909 						  ch_count, buf_len);
910 }
911 /**
912  * pld_wlan_set_dfs_nol() - Set DFS info
913  * @dev: device
914  * @info: DFS info
915  * @info_len: info length
916  *
917  * Return: 0 for success
918  *         Non zero failure code for errors
919  */
pld_wlan_set_dfs_nol(struct device * dev,void * info,u16 info_len)920 static inline int pld_wlan_set_dfs_nol(struct device *dev, void *info,
921 				       u16 info_len)
922 {
923 	return cnss_utils_wlan_set_dfs_nol(dev, info, info_len);
924 }
925 /**
926  * pld_wlan_get_dfs_nol() - Get DFS info
927  * @dev: device
928  * @info: buffer to DFS info
929  * @info_len: info length
930  *
931  * Return DFS info to the buffer.
932  *
933  * Return: 0 for success
934  *         Non zero failure code for errors
935  */
pld_wlan_get_dfs_nol(struct device * dev,void * info,u16 info_len)936 static inline int pld_wlan_get_dfs_nol(struct device *dev,
937 				       void *info, u16 info_len)
938 {
939 	return cnss_utils_wlan_get_dfs_nol(dev, info, info_len);
940 }
941 /**
942  * pld_get_wlan_mac_address() - API to query MAC address from Platform
943  * Driver
944  * @dev: Device Structure
945  * @num: Pointer to number of MAC address supported
946  *
947  * Platform Driver can have MAC address stored. This API needs to be used
948  * to get those MAC address
949  *
950  * Return: Pointer to the list of MAC address
951  */
pld_get_wlan_mac_address(struct device * dev,uint32_t * num)952 static inline uint8_t *pld_get_wlan_mac_address(struct device *dev,
953 						uint32_t *num)
954 {
955 	return cnss_utils_get_wlan_mac_address(dev, num);
956 }
957 
958 /**
959  * pld_get_wlan_derived_mac_address() - API to query derived MAC address
960  * from platform Driver
961  * @dev: Device Structure
962  * @num: Pointer to number of MAC address supported
963  *
964  * Platform Driver can have MAC address stored. This API needs to be used
965  * to get those MAC address
966  *
967  * Return: Pointer to the list of MAC address
968  */
pld_get_wlan_derived_mac_address(struct device * dev,uint32_t * num)969 static inline uint8_t *pld_get_wlan_derived_mac_address(struct device *dev,
970 							uint32_t *num)
971 {
972 	return cnss_utils_get_wlan_derived_mac_address(dev, num);
973 }
974 
975 /**
976  * pld_increment_driver_load_cnt() - Maintain driver load count
977  * @dev: device
978  *
979  * This function maintain a count which get increase whenever wiphy
980  * is registered
981  *
982  * Return: void
983  */
pld_increment_driver_load_cnt(struct device * dev)984 static inline void pld_increment_driver_load_cnt(struct device *dev)
985 {
986 	cnss_utils_increment_driver_load_cnt(dev);
987 }
988 /**
989  * pld_get_driver_load_cnt() - get driver load count
990  * @dev: device
991  *
992  * This function provide total wiphy registration count from starting
993  *
994  * Return: driver load count
995  */
pld_get_driver_load_cnt(struct device * dev)996 static inline int pld_get_driver_load_cnt(struct device *dev)
997 {
998 	return cnss_utils_get_driver_load_cnt(dev);
999 }
1000 #else
pld_get_wlan_unsafe_channel_sap(struct device * dev,struct pld_ch_avoid_ind_type * ch_avoid_ranges)1001 static inline int pld_get_wlan_unsafe_channel_sap(
1002 	struct device *dev, struct pld_ch_avoid_ind_type *ch_avoid_ranges)
1003 {
1004 	return 0;
1005 }
1006 
pld_set_wlan_unsafe_channel(struct device * dev,u16 * unsafe_ch_list,u16 ch_count)1007 static inline int pld_set_wlan_unsafe_channel(struct device *dev,
1008 					      u16 *unsafe_ch_list,
1009 					      u16 ch_count)
1010 {
1011 	return 0;
1012 }
pld_get_wlan_unsafe_channel(struct device * dev,u16 * unsafe_ch_list,u16 * ch_count,u16 buf_len)1013 static inline int pld_get_wlan_unsafe_channel(struct device *dev,
1014 					      u16 *unsafe_ch_list,
1015 					      u16 *ch_count, u16 buf_len)
1016 {
1017 	*ch_count = 0;
1018 
1019 	return 0;
1020 }
pld_wlan_set_dfs_nol(struct device * dev,void * info,u16 info_len)1021 static inline int pld_wlan_set_dfs_nol(struct device *dev,
1022 				       void *info, u16 info_len)
1023 {
1024 	return -EINVAL;
1025 }
pld_wlan_get_dfs_nol(struct device * dev,void * info,u16 info_len)1026 static inline int pld_wlan_get_dfs_nol(struct device *dev,
1027 				       void *info, u16 info_len)
1028 {
1029 	return -EINVAL;
1030 }
pld_get_wlan_mac_address(struct device * dev,uint32_t * num)1031 static inline uint8_t *pld_get_wlan_mac_address(struct device *dev,
1032 						uint32_t *num)
1033 {
1034 	*num = 0;
1035 	return NULL;
1036 }
1037 
pld_get_wlan_derived_mac_address(struct device * dev,uint32_t * num)1038 static inline uint8_t *pld_get_wlan_derived_mac_address(struct device *dev,
1039 							uint32_t *num)
1040 {
1041 	*num = 0;
1042 	return NULL;
1043 }
1044 
pld_increment_driver_load_cnt(struct device * dev)1045 static inline void pld_increment_driver_load_cnt(struct device *dev) {}
pld_get_driver_load_cnt(struct device * dev)1046 static inline int pld_get_driver_load_cnt(struct device *dev)
1047 {
1048 	return -EINVAL;
1049 }
1050 #endif
1051 
1052 /**
1053  * pld_wlan_pm_control() - WLAN PM control on PCIE
1054  * @dev: device
1055  * @vote: 0 for enable PCIE PC, 1 for disable PCIE PC
1056  *
1057  * This is for PCIE power collapse control during suspend/resume.
1058  * When PCIE power collapse is disabled, WLAN FW can access memory
1059  * through PCIE when system is suspended.
1060  *
1061  * Return: 0 for success
1062  *         Non zero failure code for errors
1063  */
1064 int pld_wlan_pm_control(struct device *dev, bool vote);
1065 
1066 /**
1067  * pld_get_virt_ramdump_mem() - Get virtual ramdump memory
1068  * @dev: device
1069  * @size: buffer to virtual memory size
1070  *
1071  * Return: virtual ramdump memory address
1072  */
1073 void *pld_get_virt_ramdump_mem(struct device *dev, unsigned long *size);
1074 
1075 /**
1076  * pld_release_virt_ramdump_mem() - Release virtual ramdump memory
1077  * @dev: device
1078  * @address: buffer to virtual memory address
1079  *
1080  * Return: void
1081  */
1082 void pld_release_virt_ramdump_mem(struct device *dev, void *address);
1083 
1084 /**
1085  * pld_device_crashed() - Notification for device crash event
1086  * @dev: device
1087  *
1088  * Notify subsystem a device crashed event. A subsystem restart
1089  * is expected to happen after calling this function.
1090  *
1091  * Return: void
1092  */
1093 void pld_device_crashed(struct device *dev);
1094 
1095 /**
1096  * pld_device_self_recovery() - Device self recovery
1097  * @dev: device
1098  * @reason: recovery reason
1099  *
1100  * Return: void
1101  */
1102 void pld_device_self_recovery(struct device *dev,
1103 			      enum pld_recovery_reason reason);
1104 
1105 /**
1106  * pld_intr_notify_q6() - Notify Q6 FW interrupts
1107  * @dev: device
1108  *
1109  * Notify Q6 that a FW interrupt is triggered.
1110  *
1111  * Return: void
1112  */
1113 void pld_intr_notify_q6(struct device *dev);
1114 
1115 /**
1116  * pld_request_pm_qos() - Request system PM
1117  * @dev: device
1118  * @qos_val: request value
1119  *
1120  * It votes for the value of aggregate QoS expectations.
1121  *
1122  * Return: void
1123  */
1124 void pld_request_pm_qos(struct device *dev, u32 qos_val);
1125 
1126 /**
1127  * pld_remove_pm_qos() - Remove system PM
1128  * @dev: device
1129  *
1130  * Remove the vote request for Qos expectations.
1131  *
1132  * Return: void
1133  */
1134 void pld_remove_pm_qos(struct device *dev);
1135 
1136 /**
1137  * pld_request_bus_bandwidth() - Request bus bandwidth
1138  * @dev: device
1139  * @bandwidth: bus bandwidth
1140  *
1141  * Votes for HIGH/MEDIUM/LOW bus bandwidth.
1142  *
1143  * Return: 0 for success
1144  *         Non zero failure code for errors
1145  */
1146 int pld_request_bus_bandwidth(struct device *dev, int bandwidth);
1147 
1148 /**
1149  * pld_get_platform_cap() - Get platform capabilities
1150  * @dev: device
1151  * @cap: buffer to the capabilities
1152  *
1153  * Return capabilities to the buffer.
1154  *
1155  * Return: 0 for success
1156  *         Non zero failure code for errors
1157  */
1158 int pld_get_platform_cap(struct device *dev, struct pld_platform_cap *cap);
1159 
1160 /**
1161  * pld_get_sha_hash() - Get sha hash number
1162  * @dev: device
1163  * @data: input data
1164  * @data_len: data length
1165  * @hash_idx: hash index
1166  * @out:  output buffer
1167  *
1168  * Return computed hash to the out buffer.
1169  *
1170  * Return: 0 for success
1171  *         Non zero failure code for errors
1172  */
1173 int pld_get_sha_hash(struct device *dev, const u8 *data,
1174 		     u32 data_len, u8 *hash_idx, u8 *out);
1175 
1176 /**
1177  * pld_get_fw_ptr() - Get secure FW memory address
1178  * @dev: device
1179  *
1180  * Return: secure memory address
1181  */
1182 void *pld_get_fw_ptr(struct device *dev);
1183 
1184 /**
1185  * pld_auto_suspend() - Auto suspend
1186  * @dev: device
1187  *
1188  * Return: 0 for success
1189  *         Non zero failure code for errors
1190  */
1191 int pld_auto_suspend(struct device *dev);
1192 
1193 /**
1194  * pld_auto_resume() - Auto resume
1195  * @dev: device
1196  *
1197  * Return: 0 for success
1198  *         Non zero failure code for errors
1199  */
1200 int pld_auto_resume(struct device *dev);
1201 
1202 /**
1203  * pld_force_wake_request() - Request vote to assert WAKE register
1204  * @dev: device
1205  *
1206  * Return: 0 for success
1207  *         Non zero failure code for errors
1208  */
1209 int pld_force_wake_request(struct device *dev);
1210 
1211 /**
1212  * pld_is_direct_link_supported() - Get whether direct_link is supported
1213  *                                  by FW or not
1214  * @dev: device
1215  *
1216  * Return: true if supported
1217  *         false on failure or if not supported
1218  */
1219 bool pld_is_direct_link_supported(struct device *dev);
1220 
1221 /**
1222  * pld_force_wake_request_sync() - Request to awake MHI synchronously
1223  * @dev: device
1224  * @timeout_us: timeout in micro-sec request to wake
1225  *
1226  * Return: 0 for success
1227  *         Non zero failure code for errors
1228  */
1229 int pld_force_wake_request_sync(struct device *dev, int timeout_us);
1230 
1231 /**
1232  * pld_exit_power_save() - Send EXIT_POWER_SAVE QMI to FW
1233  * @dev: device
1234  *
1235  * Return: 0 for success
1236  *         Non zero failure code for errors
1237  */
1238 int pld_exit_power_save(struct device *dev);
1239 
1240 /**
1241  * pld_is_device_awake() - Check if it's ready to access MMIO registers
1242  * @dev: device
1243  *
1244  * Return: True for device awake
1245  *         False for device not awake
1246  *         Negative failure code for errors
1247  */
1248 int pld_is_device_awake(struct device *dev);
1249 
1250 /**
1251  * pld_force_wake_release() - Release vote to assert WAKE register
1252  * @dev: device
1253  *
1254  * Return: 0 for success
1255  *         Non zero failure code for errors
1256  */
1257 int pld_force_wake_release(struct device *dev);
1258 
1259 /**
1260  * pld_ce_request_irq() - Register IRQ for CE
1261  * @dev: device
1262  * @ce_id: CE number
1263  * @handler: IRQ callback function
1264  * @flags: IRQ flags
1265  * @name: IRQ name
1266  * @ctx: IRQ context
1267  *
1268  * Return: 0 for success
1269  *         Non zero failure code for errors
1270  */
1271 int pld_ce_request_irq(struct device *dev, unsigned int ce_id,
1272 		       irqreturn_t (*handler)(int, void *),
1273 		       unsigned long flags, const char *name, void *ctx);
1274 
1275 /**
1276  * pld_ce_free_irq() - Free IRQ for CE
1277  * @dev: device
1278  * @ce_id: CE number
1279  * @ctx: IRQ context
1280  *
1281  * Return: 0 for success
1282  *         Non zero failure code for errors
1283  */
1284 int pld_ce_free_irq(struct device *dev, unsigned int ce_id, void *ctx);
1285 
1286 /**
1287  * pld_enable_irq() - Enable IRQ for CE
1288  * @dev: device
1289  * @ce_id: CE number
1290  *
1291  * Return: void
1292  */
1293 void pld_enable_irq(struct device *dev, unsigned int ce_id);
1294 
1295 /**
1296  * pld_disable_irq() - Disable IRQ for CE
1297  * @dev: device
1298  * @ce_id: CE number
1299  *
1300  * Return: void
1301  */
1302 void pld_disable_irq(struct device *dev, unsigned int ce_id);
1303 
1304 /**
1305  * pld_get_soc_info() - Get SOC information
1306  * @dev: device
1307  * @info: buffer to SOC information
1308  *
1309  * Return SOC info to the buffer.
1310  *
1311  * Return: 0 for success
1312  *         Non zero failure code for errors
1313  */
1314 int pld_get_soc_info(struct device *dev, struct pld_soc_info *info);
1315 
1316 /**
1317  * pld_get_mhi_state() - Get MHI state Info
1318  * @dev: device
1319  *
1320  * MHI state can be determined by reading this address.
1321  *
1322  * Return: MHI state
1323  */
1324 int pld_get_mhi_state(struct device *dev);
1325 
1326 /**
1327  * pld_is_pci_ep_awake() - Check if PCI EP is L0 state
1328  * @dev: device
1329  *
1330  * Return: True for PCI EP awake
1331  *         False for PCI EP not awake
1332  *         Negative failure code for errors
1333  */
1334 int pld_is_pci_ep_awake(struct device *dev);
1335 
1336 /**
1337  * pld_get_ce_id() - Get CE number for the provided IRQ
1338  * @dev: device
1339  * @irq: IRQ number
1340  *
1341  * Return: CE number
1342  */
1343 int pld_get_ce_id(struct device *dev, int irq);
1344 
1345 /**
1346  * pld_get_irq() - Get IRQ number for given CE ID
1347  * @dev: device
1348  * @ce_id: CE ID
1349  *
1350  * Return: IRQ number
1351  */
1352 int pld_get_irq(struct device *dev, int ce_id);
1353 
1354 /**
1355  * pld_lock_reg_window() - Lock register window spinlock
1356  * @dev: device pointer
1357  * @flags: variable pointer to save CPU states
1358  *
1359  * It uses spinlock_bh so avoid calling in top half context.
1360  *
1361  * Return: void
1362  */
1363 void pld_lock_reg_window(struct device *dev, unsigned long *flags);
1364 
1365 /**
1366  * pld_unlock_reg_window() - Unlock register window spinlock
1367  * @dev: device pointer
1368  * @flags: variable pointer to save CPU states
1369  *
1370  * It uses spinlock_bh so avoid calling in top half context.
1371  *
1372  * Return: void
1373  */
1374 void pld_unlock_reg_window(struct device *dev, unsigned long *flags);
1375 
1376 /**
1377  * pld_get_pci_slot() - Get PCI slot of attached device
1378  * @dev: device
1379  *
1380  * Return: pci slot
1381  */
1382 int pld_get_pci_slot(struct device *dev);
1383 
1384 /**
1385  * pld_power_on() - Power on WLAN hardware
1386  * @dev: device
1387  *
1388  * Return: 0 for success
1389  *         Non zero failure code for errors
1390  */
1391 int pld_power_on(struct device *dev);
1392 
1393 /**
1394  * pld_power_off() - Power off WLAN hardware
1395  * @dev: device
1396  *
1397  * Return: 0 for success
1398  *         Non zero failure code for errors
1399  */
1400 int pld_power_off(struct device *dev);
1401 
1402 /**
1403  * pld_athdiag_read() - Read data from WLAN FW
1404  * @dev: device
1405  * @offset: address offset
1406  * @memtype: memory type
1407  * @datalen: data length
1408  * @output: output buffer
1409  *
1410  * Return: 0 for success
1411  *         Non zero failure code for errors
1412  */
1413 int pld_athdiag_read(struct device *dev, uint32_t offset, uint32_t memtype,
1414 		     uint32_t datalen, uint8_t *output);
1415 
1416 /**
1417  * pld_athdiag_write() - Write data to WLAN FW
1418  * @dev: device
1419  * @offset: address offset
1420  * @memtype: memory type
1421  * @datalen: data length
1422  * @input: input buffer
1423  *
1424  * Return: 0 for success
1425  *         Non zero failure code for errors
1426  */
1427 int pld_athdiag_write(struct device *dev, uint32_t offset, uint32_t memtype,
1428 		      uint32_t datalen, uint8_t *input);
1429 
1430 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
1431 /**
1432  * pld_smmu_get_domain() - Get SMMU domain
1433  * @dev: device
1434  *
1435  * Return: Pointer to the domain
1436  */
1437 void *pld_smmu_get_domain(struct device *dev);
1438 #else
1439 /**
1440  * pld_smmu_get_mapping() - Get SMMU mapping context
1441  * @dev: device
1442  *
1443  * Return: Pointer to the mapping context
1444  */
1445 void *pld_smmu_get_mapping(struct device *dev);
1446 #endif
1447 
1448 /**
1449  * pld_smmu_map() - Map SMMU
1450  * @dev: device
1451  * @paddr: physical address that needs to map to
1452  * @iova_addr: IOVA address
1453  * @size: size to be mapped
1454  *
1455  * Return: 0 for success
1456  *         Non zero failure code for errors
1457  */
1458 int pld_smmu_map(struct device *dev, phys_addr_t paddr,
1459 		 uint32_t *iova_addr, size_t size);
1460 
1461 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0))
1462 struct kobject *pld_get_wifi_kobj(struct device *dev);
1463 #else
pld_get_wifi_kobj(struct device * dev)1464 static inline struct kobject *pld_get_wifi_kobj(struct device *dev)
1465 {
1466 	return NULL;
1467 }
1468 #endif
1469 
1470 /**
1471  * pld_smmu_unmap() - Unmap SMMU
1472  * @dev: device
1473  * @iova_addr: IOVA address to be unmapped
1474  * @size: size to be unmapped
1475  *
1476  * Return: 0 for success
1477  *         Non zero failure code for errors
1478  */
1479 #ifdef CONFIG_SMMU_S1_UNMAP
1480 int pld_smmu_unmap(struct device *dev,
1481 		   uint32_t iova_addr, size_t size);
1482 #else
pld_smmu_unmap(struct device * dev,uint32_t iova_addr,size_t size)1483 static inline int pld_smmu_unmap(struct device *dev,
1484 				 uint32_t iova_addr, size_t size)
1485 {
1486 	return 0;
1487 }
1488 #endif
1489 
1490 /**
1491  * pld_get_user_msi_assignment() - Get MSI assignment information
1492  * @dev: device structure
1493  * @user_name: name of the user who requests the MSI assignment
1494  * @num_vectors: number of the MSI vectors assigned for the user
1495  * @user_base_data: MSI base data assigned for the user, this equals to
1496  *                  endpoint base data from config space plus base vector
1497  * @base_vector: base MSI vector (offset) number assigned for the user
1498  *
1499  * Return: 0 for success
1500  *         Negative failure code for errors
1501  */
1502 int pld_get_user_msi_assignment(struct device *dev, char *user_name,
1503 				int *num_vectors, uint32_t *user_base_data,
1504 				uint32_t *base_vector);
1505 
1506 /**
1507  * pld_get_msi_irq() - Get MSI IRQ number used for request_irq()
1508  * @dev: device structure
1509  * @vector: MSI vector (offset) number
1510  *
1511  * Return: Positive IRQ number for success
1512  *         Negative failure code for errors
1513  */
1514 int pld_get_msi_irq(struct device *dev, unsigned int vector);
1515 
1516 /**
1517  * pld_get_msi_address() - Get the MSI address
1518  * @dev: device structure
1519  * @msi_addr_low: lower 32-bit of the address
1520  * @msi_addr_high: higher 32-bit of the address
1521  *
1522  * Return: Void
1523  */
1524 void pld_get_msi_address(struct device *dev, uint32_t *msi_addr_low,
1525 			 uint32_t *msi_addr_high);
1526 
1527 /**
1528  * pld_is_drv_connected() - Check if DRV subsystem is connected
1529  * @dev: device structure
1530  *
1531  *  Return: 1 DRV is connected
1532  *          0 DRV is not connected
1533  *          Non zero failure code for errors
1534  */
1535 int pld_is_drv_connected(struct device *dev);
1536 
1537 /**
1538  * pld_socinfo_get_serial_number() - Get SOC serial number
1539  * @dev: device
1540  *
1541  * Return: SOC serial number
1542  */
1543 unsigned int pld_socinfo_get_serial_number(struct device *dev);
1544 
1545 /**
1546  * pld_is_qmi_disable() - Check QMI support is present or not
1547  * @dev: device
1548  *
1549  *  Return: 1 QMI is not supported
1550  *          0 QMI is supported
1551  *          Non zero failure code for errors
1552  */
1553 int pld_is_qmi_disable(struct device *dev);
1554 
1555 /**
1556  * pld_is_fw_down() - Check WLAN fw is down or not
1557  *
1558  * @dev: device
1559  *
1560  * This API will be called to check if WLAN FW is down or not.
1561  *
1562  *  Return: 0 FW is not down
1563  *          Otherwise FW is down
1564  *          Always return 0 for unsupported bus type
1565  */
1566 int pld_is_fw_down(struct device *dev);
1567 
1568 /**
1569  * pld_force_assert_target() - Send a force assert request to FW.
1570  * @dev: device pointer
1571  *
1572  * This can use various sideband requests available at platform driver to
1573  * initiate a FW assert.
1574  *
1575  * Context: Any context
1576  * Return:
1577  * 0 - force assert of FW is triggered successfully.
1578  * -EOPNOTSUPP - force assert is not supported.
1579  * Other non-zero codes - other failures or errors
1580  */
1581 int pld_force_assert_target(struct device *dev);
1582 
1583 /**
1584  * pld_force_collect_target_dump() - Collect FW dump after asserting FW.
1585  * @dev: device pointer
1586  *
1587  * This API will send force assert request to FW and wait till FW dump has
1588  * been collected.
1589  *
1590  * Context: Process context only since this is a blocking call.
1591  * Return:
1592  * 0 - FW dump is collected successfully.
1593  * -EOPNOTSUPP - forcing assert and collecting FW dump is not supported.
1594  * -ETIMEDOUT - FW dump collection is timed out for any reason.
1595  * Other non-zero codes - other failures or errors
1596  */
1597 int pld_force_collect_target_dump(struct device *dev);
1598 
1599 /**
1600  * pld_qmi_send_get() - Indicate certain data to be sent over QMI
1601  * @dev: device pointer
1602  *
1603  * This API can be used to indicate certain data to be sent over QMI.
1604  * pld_qmi_send() is expected to be called later.
1605  *
1606  * Return: 0 for success
1607  *         Non zero failure code for errors
1608  */
1609 int pld_qmi_send_get(struct device *dev);
1610 
1611 /**
1612  * pld_qmi_send_put() - Indicate response sent over QMI has been processed
1613  * @dev: device pointer
1614  *
1615  * This API can be used to indicate response of the data sent over QMI has
1616  * been processed.
1617  *
1618  * Return: 0 for success
1619  *         Non zero failure code for errors
1620  */
1621 int pld_qmi_send_put(struct device *dev);
1622 
1623 /**
1624  * pld_qmi_send() - Send data request over QMI
1625  * @dev: device pointer
1626  * @type: type of the send data operation
1627  * @cmd: buffer pointer of send data request command
1628  * @cmd_len: size of the command buffer
1629  * @cb_ctx: context pointer if any to pass back in callback
1630  * @cb: callback pointer to pass response back
1631  *
1632  * This API can be used to send data request over QMI.
1633  *
1634  * Return: 0 if data request sends successfully
1635  *         Non zero failure code for errors
1636  */
1637 int pld_qmi_send(struct device *dev, int type, void *cmd,
1638 		 int cmd_len, void *cb_ctx,
1639 		 int (*cb)(void *ctx, void *event, int event_len));
1640 
1641 /**
1642  * pld_qmi_indication() - Send data request over QMI
1643  * @dev: device pointer
1644  * @cb_ctx: context pointer if any to pass back in callback
1645  * @cb: callback pointer to pass response back
1646  *
1647  * This API can be used to register for QMI events.
1648  *
1649  * Return: 0 if registration is successful
1650  *         Non zero failure code for errors
1651  */
1652 int pld_qmi_indication(struct device *dev, void *cb_ctx,
1653 		       int (*cb)(void *ctx, uint16_t type,
1654 				 void *event, int event_len));
1655 
1656 /**
1657  * pld_is_fw_dump_skipped() - get fw dump skipped status.
1658  * @dev: device
1659  *
1660  * The subsys ssr status help the driver to decide whether to skip
1661  * the FW memory dump when FW assert.
1662  * For SDIO case, the memory dump progress takes 1 minutes to
1663  * complete, which is not acceptable in SSR enabled.
1664  *
1665  * Return: true if need to skip FW dump.
1666  */
1667 bool pld_is_fw_dump_skipped(struct device *dev);
1668 
1669 /**
1670  * pld_is_low_power_mode() - Check WLAN fw is in low power
1671  * @dev: device
1672  *
1673  * This API will be called to check if WLAN FW is in low power or not.
1674  * Low power means either Deep Sleep or Hibernate state.
1675  *
1676  * Return: 0 FW is not in low power mode
1677  *         Otherwise FW is low power mode
1678  *         Always return 0 for unsupported bus type
1679  */
1680 #ifdef CONFIG_ENABLE_LOW_POWER_MODE
1681 int pld_is_low_power_mode(struct device *dev);
1682 #else
pld_is_low_power_mode(struct device * dev)1683 static inline int pld_is_low_power_mode(struct device *dev)
1684 {
1685 	return 0;
1686 }
1687 #endif
1688 
1689 /**
1690  * pld_is_pdr() - Check WLAN PD is Restarted
1691  * @dev: device
1692  *
1693  * Help the driver decide whether FW down is due to
1694  * WLAN PD Restart.
1695  *
1696  * Return: 1 WLAN PD is Restarted
1697  *         0 WLAN PD is not Restarted
1698  */
1699 int pld_is_pdr(struct device *dev);
1700 
1701 /**
1702  * pld_is_fw_rejuvenate() - Check WLAN fw is rejuvenating
1703  * @dev: device
1704  *
1705  * Help the driver decide whether FW down is due to
1706  * SSR or FW rejuvenate.
1707  *
1708  * Return: 1 FW is rejuvenating
1709  *         0 FW is not rejuvenating
1710  */
1711 int pld_is_fw_rejuvenate(struct device *dev);
1712 
1713 /**
1714  * pld_have_platform_driver_support() - check if platform driver support
1715  * @dev: device
1716  *
1717  * Return: true if platform driver support.
1718  */
1719 bool pld_have_platform_driver_support(struct device *dev);
1720 
1721 /**
1722  * pld_idle_shutdown - request idle shutdown callback from platform driver
1723  * @dev: pointer to struct dev
1724  * @shutdown_cb: pointer to hdd psoc idle shutdown callback handler
1725  *
1726  * Return: 0 for success and non-zero negative error code for failure
1727  */
1728 int pld_idle_shutdown(struct device *dev,
1729 		      int (*shutdown_cb)(struct device *dev));
1730 
1731 /**
1732  * pld_idle_restart - request idle restart callback from platform driver
1733  * @dev: pointer to struct dev
1734  * @restart_cb: pointer to hdd psoc idle restart callback handler
1735  *
1736  * Return: 0 for success and non-zero negative error code for failure
1737  */
1738 int pld_idle_restart(struct device *dev,
1739 		     int (*restart_cb)(struct device *dev));
1740 
1741 /**
1742  * pld_srng_devm_request_irq() - Register IRQ for SRNG
1743  * @dev: device
1744  * @irq: IRQ number
1745  * @handler: IRQ callback function
1746  * @irqflags: IRQ flags
1747  * @name: IRQ name
1748  * @ctx: IRQ context
1749  *
1750  * Return: 0 for success
1751  *         Non zero failure code for errors
1752  */
1753 int pld_srng_devm_request_irq(struct device *dev, int irq,
1754 			      irq_handler_t handler,
1755 			      unsigned long irqflags,
1756 			      const char *name,
1757 			      void *ctx);
1758 
1759 /**
1760  * pld_srng_request_irq() - Register IRQ for SRNG
1761  * @dev: device
1762  * @irq: IRQ number
1763  * @handler: IRQ callback function
1764  * @irqflags: IRQ flags
1765  * @name: IRQ name
1766  * @ctx: IRQ context
1767  *
1768  * Return: 0 for success
1769  *         Non zero failure code for errors
1770  */
1771 int pld_srng_request_irq(struct device *dev, int irq, irq_handler_t handler,
1772 			 unsigned long irqflags,
1773 			 const char *name,
1774 			 void *ctx);
1775 
1776 /**
1777  * pld_srng_free_irq() - Free IRQ for SRNG
1778  * @dev: device
1779  * @irq: IRQ number
1780  * @ctx: IRQ context
1781  *
1782  * Return: 0 for success
1783  *         Non zero failure code for errors
1784  */
1785 int pld_srng_free_irq(struct device *dev, int irq, void *ctx);
1786 
1787 /**
1788  * pld_srng_enable_irq() - Enable IRQ for SRNG
1789  * @dev: device
1790  * @irq: IRQ number
1791  *
1792  * Return: void
1793  */
1794 void pld_srng_enable_irq(struct device *dev, int irq);
1795 
1796 /**
1797  * pld_srng_disable_irq() - Disable IRQ for SRNG
1798  * @dev: device
1799  * @irq: IRQ number
1800  *
1801  * Return: void
1802  */
1803 void pld_srng_disable_irq(struct device *dev, int irq);
1804 
1805 /**
1806  * pld_srng_disable_irq_sync() - Synchronouus disable IRQ for SRNG
1807  * @dev: device
1808  * @irq: IRQ number
1809  *
1810  * Return: void
1811  */
1812 void pld_srng_disable_irq_sync(struct device *dev, int irq);
1813 
1814 /**
1815  * pld_pci_read_config_word() - Read PCI config
1816  * @pdev: pci device
1817  * @offset: Config space offset
1818  * @val : Value
1819  *
1820  * Return: 0 for success
1821  *         Non zero failure code for errors
1822  */
1823 int pld_pci_read_config_word(struct pci_dev *pdev, int offset, uint16_t *val);
1824 
1825 /**
1826  * pld_pci_write_config_word() - Write PCI config
1827  * @pdev: pci device
1828  * @offset: Config space offset
1829  * @val : Value
1830  *
1831  * Return: 0 for success
1832  *         Non zero failure code for errors
1833  */
1834 int pld_pci_write_config_word(struct pci_dev *pdev, int offset, uint16_t val);
1835 
1836 /**
1837  * pld_pci_read_config_dword() - Read PCI config
1838  * @pdev: pci device
1839  * @offset: Config space offset
1840  * @val : Value
1841  *
1842  * Return: 0 for success
1843  *         Non zero failure code for errors
1844  */
1845 int pld_pci_read_config_dword(struct pci_dev *pdev, int offset, uint32_t *val);
1846 
1847 /**
1848  * pld_pci_write_config_dword() - Write PCI config
1849  * @pdev: pci device
1850  * @offset: Config space offset
1851  * @val : Value
1852  *
1853  * Return: 0 for success
1854  *         Non zero failure code for errors
1855  */
1856 int pld_pci_write_config_dword(struct pci_dev *pdev, int offset, uint32_t val);
1857 
1858 /**
1859  * pld_thermal_register() - Register the thermal device with the thermal system
1860  * @dev: The device structure
1861  * @state: The max state to be configured on registration
1862  * @mon_id: Thermal cooling device ID
1863  *
1864  * Return: Error code on error
1865  */
1866 int pld_thermal_register(struct device *dev, unsigned long state, int mon_id);
1867 
1868 /**
1869  * pld_thermal_unregister() - Unregister the device with the thermal system
1870  * @dev: The device structure
1871  * @mon_id: Thermal cooling device ID
1872  *
1873  * Return: None
1874  */
1875 void pld_thermal_unregister(struct device *dev, int mon_id);
1876 
1877 /**
1878  * pld_set_wfc_mode() - Sent WFC mode to FW via platform driver
1879  * @dev: The device structure
1880  * @wfc_mode: WFC Modes (0 => Inactive, 1 => Active)
1881  *
1882  * Return: Error code on error
1883  */
1884 int pld_set_wfc_mode(struct device *dev, enum pld_wfc_mode wfc_mode);
1885 
1886 /**
1887  * pld_bus_width_type_to_str() - Helper function to convert PLD bandwidth level
1888  *				 to string
1889  * @level: PLD bus width level
1890  *
1891  * Return: String corresponding to input "level"
1892  */
1893 const char *pld_bus_width_type_to_str(enum pld_bus_width_type level);
1894 
1895 /**
1896  * pld_get_thermal_state() - Get the current thermal state from the PLD
1897  * @dev: The device structure
1898  * @thermal_state: param to store the current thermal state
1899  * @mon_id: Thermal cooling device ID
1900  *
1901  * Return: Non-zero code for error; zero for success
1902  */
1903 int pld_get_thermal_state(struct device *dev, unsigned long *thermal_state,
1904 			  int mon_id);
1905 
1906 /**
1907  * pld_set_tsf_sync_period() - Set TSF sync period
1908  * @dev: device
1909  * @val: TSF sync time value
1910  *
1911  * Return: void
1912  */
1913 void pld_set_tsf_sync_period(struct device *dev, u32 val);
1914 
1915 /**
1916  * pld_reset_tsf_sync_period() - Reset TSF sync period
1917  * @dev: device
1918  *
1919  * Return: void
1920  */
1921 void pld_reset_tsf_sync_period(struct device *dev);
1922 
1923 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0))
1924 /**
1925  * pld_is_ipa_offload_disabled() - Check if IPA offload is enabled or not
1926  * @dev: The device structure
1927  *
1928  * Return: Non-zero code for IPA offload disable; zero for IPA offload enable
1929  */
1930 int pld_is_ipa_offload_disabled(struct device *dev);
1931 #else
1932 static inline
pld_is_ipa_offload_disabled(struct device * dev)1933 int pld_is_ipa_offload_disabled(struct device *dev)
1934 {
1935 	return 0;
1936 }
1937 #endif
1938 
1939 #if defined(CNSS_MEM_PRE_ALLOC) && defined(FEATURE_SKB_PRE_ALLOC)
1940 
1941 /**
1942  * pld_nbuf_pre_alloc() - get allocated nbuf from platform driver.
1943  * @size: Netbuf requested size
1944  *
1945  * Return: nbuf or NULL if no memory
1946  */
pld_nbuf_pre_alloc(size_t size)1947 static inline struct sk_buff *pld_nbuf_pre_alloc(size_t size)
1948 {
1949 	struct sk_buff *skb = NULL;
1950 
1951 	if (size >= WCNSS_PRE_SKB_ALLOC_GET_THRESHOLD)
1952 		skb = wcnss_skb_prealloc_get(size);
1953 
1954 	return skb;
1955 }
1956 
1957 /**
1958  * pld_nbuf_pre_alloc_free() - free the nbuf allocated in platform driver.
1959  * @skb: Pointer to network buffer
1960  *
1961  * Return: TRUE if the nbuf is freed
1962  */
pld_nbuf_pre_alloc_free(struct sk_buff * skb)1963 static inline int pld_nbuf_pre_alloc_free(struct sk_buff *skb)
1964 {
1965 	return wcnss_skb_prealloc_put(skb);
1966 }
1967 #else
pld_nbuf_pre_alloc(size_t size)1968 static inline struct sk_buff *pld_nbuf_pre_alloc(size_t size)
1969 {
1970 	return NULL;
1971 }
pld_nbuf_pre_alloc_free(struct sk_buff * skb)1972 static inline int pld_nbuf_pre_alloc_free(struct sk_buff *skb)
1973 {
1974 	return 0;
1975 }
1976 #endif
1977 
1978 #ifdef CONFIG_AFC_SUPPORT
1979 /**
1980  * pld_send_buffer_to_afcmem() - Send afc data to afc memory
1981  * @dev: The device structure
1982  * @afcdb: Pointer to afc data buffer
1983  * @len: Length of afc data
1984  * @slotid: Slot id of afc memory
1985  *
1986  * Return: Non-zero code for error; zero for success
1987  */
1988 int pld_send_buffer_to_afcmem(struct device *dev, const uint8_t *afcdb,
1989 			      uint32_t len, uint8_t slotid);
1990 
1991 /**
1992  * pld_reset_afcmem() - Reset afc data in afc memory
1993  * @dev: The device structure
1994  * @slotid: Slot id of afc memory
1995  *
1996  * Return: Non-zero code for error; zero for success
1997  */
1998 int pld_reset_afcmem(struct device *dev, uint8_t slotid);
1999 #else
2000 static inline
pld_send_buffer_to_afcmem(struct device * dev,const uint8_t * afcdb,uint32_t len,uint8_t slotid)2001 int pld_send_buffer_to_afcmem(struct device *dev, const uint8_t *afcdb,
2002 			      uint32_t len, uint8_t slotid)
2003 {
2004 	return -EINVAL;
2005 }
2006 
2007 static inline
pld_reset_afcmem(struct device * dev,uint8_t slotid)2008 int pld_reset_afcmem(struct device *dev, uint8_t slotid)
2009 {
2010 	return -EINVAL;
2011 }
2012 #endif
2013 
2014 /**
2015  * pld_get_bus_type() - Bus type of the device
2016  * @dev: device
2017  *
2018  * Return: PLD bus type
2019  */
2020 enum pld_bus_type pld_get_bus_type(struct device *dev);
2021 
pfrm_devm_request_irq(struct device * dev,unsigned int ce_id,irqreturn_t (* handler)(int,void *),unsigned long flags,const char * name,void * ctx)2022 static inline int pfrm_devm_request_irq(struct device *dev, unsigned int ce_id,
2023 					irqreturn_t (*handler)(int, void *),
2024 					unsigned long flags, const char *name,
2025 					void *ctx)
2026 {
2027 	return pld_srng_devm_request_irq(dev, ce_id, handler, flags, name, ctx);
2028 }
2029 
pfrm_request_irq(struct device * dev,unsigned int ce_id,irqreturn_t (* handler)(int,void *),unsigned long flags,const char * name,void * ctx)2030 static inline int pfrm_request_irq(struct device *dev, unsigned int ce_id,
2031 				   irqreturn_t (*handler)(int, void *),
2032 				   unsigned long flags, const char *name,
2033 				   void *ctx)
2034 {
2035 	return pld_srng_request_irq(dev, ce_id, handler, flags, name, ctx);
2036 }
2037 
pfrm_free_irq(struct device * dev,int irq,void * ctx)2038 static inline int pfrm_free_irq(struct device *dev, int irq, void *ctx)
2039 {
2040 	return pld_srng_free_irq(dev, irq, ctx);
2041 }
2042 
pfrm_enable_irq(struct device * dev,int irq)2043 static inline void pfrm_enable_irq(struct device *dev, int irq)
2044 {
2045 	pld_srng_enable_irq(dev, irq);
2046 }
2047 
pfrm_disable_irq_nosync(struct device * dev,int irq)2048 static inline void pfrm_disable_irq_nosync(struct device *dev, int irq)
2049 {
2050 	pld_srng_disable_irq(dev, irq);
2051 }
2052 
pfrm_disable_irq(struct device * dev,int irq)2053 static inline void pfrm_disable_irq(struct device *dev, int irq)
2054 {
2055 	pld_srng_disable_irq_sync(dev, irq);
2056 }
2057 
pfrm_read_config_word(struct pci_dev * pdev,int offset,uint16_t * val)2058 static inline int pfrm_read_config_word(struct pci_dev *pdev, int offset,
2059 					uint16_t *val)
2060 {
2061 	return pld_pci_read_config_word(pdev, offset, val);
2062 }
2063 
pfrm_write_config_word(struct pci_dev * pdev,int offset,uint16_t val)2064 static inline int pfrm_write_config_word(struct pci_dev *pdev, int offset,
2065 					 uint16_t val)
2066 {
2067 	return pld_pci_write_config_word(pdev, offset, val);
2068 }
2069 
pfrm_read_config_dword(struct pci_dev * pdev,int offset,uint32_t * val)2070 static inline int pfrm_read_config_dword(struct pci_dev *pdev, int offset,
2071 					 uint32_t *val)
2072 {
2073 	return pld_pci_read_config_dword(pdev, offset, val);
2074 }
2075 
pfrm_write_config_dword(struct pci_dev * pdev,int offset,uint32_t val)2076 static inline int pfrm_write_config_dword(struct pci_dev *pdev, int offset,
2077 					  uint32_t val)
2078 {
2079 	return pld_pci_write_config_dword(pdev, offset, val);
2080 }
2081 
pld_get_enable_intx(struct device * dev)2082 static inline bool pld_get_enable_intx(struct device *dev)
2083 {
2084 	return false;
2085 }
2086 
2087 /**
2088  * pld_is_one_msi()- whether one MSI is used or not
2089  * @dev: device structure
2090  *
2091  * Return: true if it is one MSI
2092  */
2093 bool pld_is_one_msi(struct device *dev);
2094 
2095 #ifdef FEATURE_DIRECT_LINK
2096 /**
2097  * pld_audio_smmu_map()- Map memory region into Audio SMMU CB
2098  * @dev: pointer to device structure
2099  * @paddr: physical address
2100  * @iova: DMA address
2101  * @size: memory region size
2102  *
2103  * Return: 0 on success else failure code
2104  */
2105 int pld_audio_smmu_map(struct device *dev, phys_addr_t paddr, dma_addr_t iova,
2106 		       size_t size);
2107 
2108 /**
2109  * pld_audio_smmu_unmap()- Remove memory region mapping from Audio SMMU CB
2110  * @dev: pointer to device structure
2111  * @iova: DMA address
2112  * @size: memory region size
2113  *
2114  * Return: None
2115  */
2116 void pld_audio_smmu_unmap(struct device *dev, dma_addr_t iova, size_t size);
2117 #else
2118 static inline
pld_audio_smmu_map(struct device * dev,phys_addr_t paddr,dma_addr_t iova,size_t size)2119 int pld_audio_smmu_map(struct device *dev, phys_addr_t paddr, dma_addr_t iova,
2120 		       size_t size)
2121 {
2122 	return 0;
2123 }
2124 
2125 static inline
pld_audio_smmu_unmap(struct device * dev,dma_addr_t iova,size_t size)2126 void pld_audio_smmu_unmap(struct device *dev, dma_addr_t iova, size_t size)
2127 {
2128 }
2129 #endif
2130 #endif
2131