1 /*
2 * Copyright (c) 2020-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 any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18 #ifndef _IPCI_API_H_
19 #define _IPCI_API_H_
20 struct hif_exec_context;
21
22 /**
23 * hif_ipci_open() - hif_bus_open
24 * @hif_ctx: hif context
25 * @bus_type: bus type
26 *
27 * Return: 0 for success or QDF_STATUS_E_NOMEM
28 */
29 QDF_STATUS hif_ipci_open(struct hif_softc *hif_ctx,
30 enum qdf_bus_type bus_type);
31
32 /**
33 * hif_ipci_close() - hif_bus_close
34 * @hif_ctx: hif context
35 *
36 * Return: n/a
37 */
38 void hif_ipci_close(struct hif_softc *hif_ctx);
39
40 /**
41 * hif_ipci_prevent_linkdown() - allow or permit linkdown
42 * @scn: struct hif_softc
43 * @flag: true prevents linkdown, false allows
44 *
45 * Calls into the platform driver to vote against taking down the
46 * pcie link.
47 *
48 * Return: n/a
49 */
50 void hif_ipci_prevent_linkdown(struct hif_softc *scn, bool flag);
51
52 /**
53 * hif_ipci_bus_suspend() - prepare hif for suspend
54 * @scn: struct hif_softc
55 *
56 * Return: Errno
57 */
58 int hif_ipci_bus_suspend(struct hif_softc *scn);
59
60 /**
61 * hif_ipci_bus_suspend_noirq() - ensure there are no pending transactions
62 * @scn: hif context
63 *
64 * Ensure that if we received the wakeup message before the irq
65 * was disabled that the message is processed before suspending.
66 *
67 * Return: -EBUSY if we fail to flush the tasklets.
68 */
69 int hif_ipci_bus_suspend_noirq(struct hif_softc *scn);
70
71 /**
72 * hif_ipci_bus_resume() - prepare hif for resume
73 * @scn: struct hif_softc
74 *
75 * Return: Errno
76 */
77 int hif_ipci_bus_resume(struct hif_softc *scn);
78
79 /**
80 * hif_ipci_bus_resume_noirq() - ensure there are no pending transactions
81 * @scn: hif context
82 *
83 * Ensure that if we received the wakeup message before the irq
84 * was disabled that the message is processed before suspending.
85 *
86 * Return: -EBUSY if we fail to flush the tasklets.
87 */
88 int hif_ipci_bus_resume_noirq(struct hif_softc *scn);
89
90 /**
91 * hif_ipci_disable_isr() - disable interrupt
92 * @scn: struct hif_softc
93 *
94 * Return: n/a
95 */
96 void hif_ipci_disable_isr(struct hif_softc *scn);
97
98 /**
99 * hif_ipci_nointrs() - disable IRQ
100 * @scn: struct hif_softc
101 *
102 * This function stops interrupt(s)
103 *
104 * Return: none
105 */
106 void hif_ipci_nointrs(struct hif_softc *scn);
107
108 /**
109 * hif_ipci_dump_registers() - dump bus debug registers
110 * @scn: struct hif_opaque_softc
111 *
112 * This function dumps hif bus debug registers
113 *
114 * Return: 0 for success or error code
115 */
116 int hif_ipci_dump_registers(struct hif_softc *scn);
117
118 /**
119 * hif_ipci_enable_bus() - enable bus
120 * @scn: soft_sc struct
121 * @dev: device pointer
122 * @bdev: bus dev pointer
123 * @bid: bus id pointer
124 * @type: enum hif_enable_type such as HIF_ENABLE_TYPE_PROBE
125 *
126 * This function enables the bus
127 *
128 * Return: QDF_STATUS
129 */
130 QDF_STATUS hif_ipci_enable_bus(
131 struct hif_softc *scn,
132 struct device *dev, void *bdev,
133 const struct hif_bus_id *bid,
134 enum hif_enable_type type);
135
136 /**
137 * hif_ipci_disable_bus() - hif_disable_bus
138 * @scn: struct hif_softc
139 *
140 * This function disables the bus
141 *
142 * Return: none
143 */
144 void hif_ipci_disable_bus(struct hif_softc *scn);
145
146 /**
147 * hif_ipci_bus_configure() - configure the pcie bus
148 * @scn: pointer to the hif context.
149 *
150 * return: 0 for success. nonzero for failure.
151 */
152 int hif_ipci_bus_configure(struct hif_softc *scn);
153
154 /**
155 * hif_ipci_enable_power_management() - enable power management
156 * @hif_ctx: hif context
157 * @is_packet_log_enabled: pktlog enabled or disabled
158 *
159 * Return: none
160 */
161 void hif_ipci_enable_power_management(
162 struct hif_softc *hif_ctx,
163 bool is_packet_log_enabled);
164
165 /**
166 * hif_ipci_disable_power_management() - disable power management
167 * @hif_ctx: hif context
168 *
169 * Return: none
170 */
171 void hif_ipci_disable_power_management(struct hif_softc *hif_ctx);
172
173 /**
174 * hif_ipci_configure_grp_irq() - configure HW block irq
175 * @scn: hif context
176 * @exec: hif exec context
177 *
178 * Return:Errno
179 */
180 int hif_ipci_configure_grp_irq(
181 struct hif_softc *scn,
182 struct hif_exec_context *exec);
183
184 /**
185 * hif_ipci_deconfigure_grp_irq() - deconfigure HW block irq
186 * @scn: hif context
187 *
188 * Return: None
189 */
190 void hif_ipci_deconfigure_grp_irq(struct hif_softc *scn);
191
192 /**
193 * hif_ipci_display_stats() - display stats
194 * @hif_ctx: hif context
195 *
196 * Return: none
197 */
198 void hif_ipci_display_stats(struct hif_softc *hif_ctx);
199
200 /**
201 * hif_ipci_clear_stats() - clear stats
202 * @hif_ctx: hif context
203 *
204 * Return: none
205 */
206 void hif_ipci_clear_stats(struct hif_softc *hif_ctx);
207
208 /**
209 * hif_ipci_needs_bmi() - return true if the soc needs bmi through the driver
210 * @scn: hif context
211 *
212 * Return: true if soc needs driver bmi otherwise false
213 */
214 bool hif_ipci_needs_bmi(struct hif_softc *scn);
215
216 /**
217 * hif_ipci_get_irq_name() - get irqname
218 * This function gives irqnumber to irqname
219 * mapping.
220 *
221 * @irq_no: irq number
222 *
223 * Return: irq name
224 */
225 const char *hif_ipci_get_irq_name(int irq_no);
226
227 /**
228 * hif_ipci_enable_grp_irqs() - enable grp IRQs
229 * @scn: struct hif_softc
230 *
231 * This function enables grp irqs
232 *
233 * Return: 0 if success, error code if failure
234 */
235 int hif_ipci_enable_grp_irqs(struct hif_softc *scn);
236
237 #ifdef HIF_CPU_PERF_AFFINE_MASK
238 /**
239 * hif_ipci_config_irq_affinity() - set the irq affinity
240 * @scn: hif context
241 *
242 * set irq affinity hint for wlan irqs to gold cores only for
243 * defconfig builds.
244 *
245 * Return: none
246 */
247 void hif_ipci_config_irq_affinity(struct hif_softc *scn);
248 #endif
249
250 #ifdef HIF_CPU_CLEAR_AFFINITY
251 /**
252 * hif_ipci_config_irq_clear_cpu_affinity() - Remove cpu affinity of IRQ
253 * @scn: HIF handle
254 * @intr_ctxt_id: interrupt group index
255 * @cpu: CPU core to clear
256 *
257 * Return: None
258 */
259 void hif_ipci_config_irq_clear_cpu_affinity(struct hif_softc *scn,
260 int intr_ctxt_id, int cpu);
261 #else
262 static inline
hif_ipci_config_irq_clear_cpu_affinity(struct hif_softc * scn,int intr_ctxt_id,int cpu)263 void hif_ipci_config_irq_clear_cpu_affinity(struct hif_softc *scn,
264 int intr_ctxt_id, int cpu)
265 {
266 }
267 #endif
268
269 /**
270 * hif_ipci_disable_grp_irqs() - disable grp IRQs
271 * @scn: struct hif_softc
272 *
273 * This function disables grp irqs
274 *
275 * Return: 0 if success, error code if failure
276 */
277 int hif_ipci_disable_grp_irqs(struct hif_softc *scn);
278
279 #ifdef FEATURE_IRQ_AFFINITY
280 /**
281 * hif_ipci_set_grp_intr_affinity() - Set irq affinity hint for grp
282 * intrs based on bitmask
283 * @scn: hif context
284 * @grp_intr_bitmask: group intr bitmask
285 * @perf: affine to perf or non-perf cluster
286 *
287 * Return: None
288 */
289 void hif_ipci_set_grp_intr_affinity(struct hif_softc *scn,
290 uint32_t grp_intr_bitmask, bool perf);
291 #endif
292 #endif /* _IPCI_API_H_ */
293