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