1 /*
2 * Copyright (c) 2015-2017, 2019, 2021 The Linux Foundation.
3 * All rights reserved.
4 * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
5 *
6 * Permission to use, copy, modify, and/or distribute this software for
7 * any purpose with or without fee is hereby granted, provided that the
8 * above copyright notice and this permission notice appear in all
9 * copies.
10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
12 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
13 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
14 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
15 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
16 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
17 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
18 * PERFORMANCE OF THIS SOFTWARE.
19 */
20
21 #ifndef __WLAN_HDD_DRIVER_OPS_H__
22 #define __WLAN_HDD_DRIVER_OPS_H__
23
24 #include "hif.h"
25 #include <qdf_types.h>
26
27 struct hdd_context;
28
29 #define wlan_hdd_trigger_cds_recovery(reason) \
30 __wlan_hdd_trigger_cds_recovery(reason, __func__, __LINE__)
31
32 void __wlan_hdd_trigger_cds_recovery(enum qdf_hang_reason reason,
33 const char *func, const uint32_t line);
34 /**
35 * DOC: wlan_hdd_driver_ops.h
36 *
37 * Functions to register the wlan driver.
38 */
39
40 /**
41 * wlan_hdd_register_driver() - Register with platform layer
42 *
43 * This function is used to register HDD callbacks with the platform
44 * layer.
45 *
46 * Return: 0 if registration is successful, negative errno if
47 * registration fails
48 */
49 int wlan_hdd_register_driver(void);
50
51 /**
52 * wlan_hdd_unregister_driver() - Unregister from platform layer
53 *
54 * This function is used to unregister HDD callbacks from the platform
55 * layer.
56 *
57 * Return: void
58 */
59
60 void wlan_hdd_unregister_driver(void);
61
62 /**
63 * wlan_hdd_bus_suspend() - suspend the wlan bus
64 *
65 * This function is called by the platform driver to suspend the
66 * wlan bus
67 *
68 * Return: 0 on success, negative errno on error
69 */
70 int wlan_hdd_bus_suspend(void);
71
72 /**
73 * wlan_hdd_bus_suspend_noirq() - handle .suspend_noirq callback
74 *
75 * This function is called by the platform driver to complete the
76 * bus suspend callback when device interrupts are disabled by kernel.
77 * Call HIF and WMA suspend_noirq callbacks to make sure there is no
78 * wake up pending from FW before allowing suspend.
79 *
80 * Return: 0 for success and -EBUSY if FW is requesting wake up
81 */
82 int wlan_hdd_bus_suspend_noirq(void);
83
84 /**
85 * wlan_hdd_bus_resume() - wake up the bus
86 *
87 * @type: WoW suspend type
88 *
89 * This function is called by the platform driver to resume wlan
90 * bus
91 *
92 * Return: 0 for success and negative errno if failure
93 */
94 int wlan_hdd_bus_resume(enum qdf_suspend_type type);
95
96 /**
97 * wlan_hdd_bus_resume_noirq() - handle bus resume no irq
98 *
99 * This function is called by the platform driver to do bus
100 * resume no IRQ before calling resume callback. Call WMA and HIF
101 * layers to complete the resume_noirq.
102 *
103 * Return: 0 for success and negative error code for failure
104 */
105 int wlan_hdd_bus_resume_noirq(void);
106
107 /**
108 * hdd_hif_close() - HIF close helper
109 * @hdd_ctx: HDD context
110 * @hif_ctx: HIF context
111 *
112 * Helper function to close HIF
113 */
114 void hdd_hif_close(struct hdd_context *hdd_ctx, void *hif_ctx);
115
116 /**
117 * hdd_hif_open() - HIF open helper
118 * @dev: wlan device structure
119 * @bdev: bus device structure
120 * @bid: bus identifier for shared busses
121 * @bus_type: underlying bus type
122 * @reinit: true if we are reinitializing the driver during recovery phase
123 *
124 * This function brings-up HIF layer during load/recovery phase.
125 *
126 * Return: 0 on success and errno on failure.
127 */
128 int hdd_hif_open(struct device *dev, void *bdev, const struct hif_bus_id *bid,
129 enum qdf_bus_type bus_type, bool reinit);
130
131 /**
132 * hdd_soc_idle_restart_lock() - Takes wakelock for idle restart
133 * @dev: wlan device structure
134 *
135 * This function takes wakelock to prevent suspend during idle restart
136 *
137 * Return: 0 for success and non zero for error
138 */
139 int hdd_soc_idle_restart_lock(struct device *dev);
140
141 /**
142 * hdd_soc_idle_restart_unlock() - Releases wakelock for idle restart
143 *
144 * This function releases wakelock to allow suspend after idle restart
145 *
146 * Return: none
147 */
148 void hdd_soc_idle_restart_unlock(void);
149
150 #ifdef FORCE_WAKE
151 /**
152 * hdd_set_hif_init_phase() - Enable/disable the
153 * init_phase flag
154 * @hif_ctx: hif opaque handle
155 * @init_phase: init phase flag
156 *
157 * Return: None
158 */
159 void hdd_set_hif_init_phase(struct hif_opaque_softc *hif_ctx,
160 bool init_phase);
161 #else
162 static inline
hdd_set_hif_init_phase(struct hif_opaque_softc * hif_ctx,bool init_phase)163 void hdd_set_hif_init_phase(struct hif_opaque_softc *hif_ctx,
164 bool init_phase)
165 {
166 }
167 #endif /* FORCE_WAKE */
168
169 #ifdef HIF_DETECTION_LATENCY_ENABLE
170 /**
171 * hdd_hif_set_enable_detection() - enable detection
172 * @hif_ctx: hif opaque handle
173 * @value: enable/disable
174 *
175 * Return: None
176 */
177 void hdd_hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value);
178 #else
179 static inline
hdd_hif_set_enable_detection(struct hif_opaque_softc * hif_ctx,bool value)180 void hdd_hif_set_enable_detection(struct hif_opaque_softc *hif_ctx, bool value)
181 {
182 }
183 #endif /* HIF_DETECTION_LATENCY_ENABLE */
184
185 /**
186 * hdd_deinit_qdf_ctx() - API to Deinitialize global QDF Device structure
187 * @domain: Debug domain
188 *
189 * Return: 0 - success, < 0 - failure
190 */
191 int hdd_deinit_qdf_ctx(uint8_t domain);
192 #endif /* __WLAN_HDD_DRIVER_OPS_H__ */
193