xref: /wlan-dirver/qca-wifi-host-cmn/hif/src/dispatcher/ipci_api.h (revision f28396d060cff5c6519f883cb28ae0116ce479f1)
1 /*
2  * Copyright (c) 2020 The Linux Foundation. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7 
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef _IPCI_API_H_
18 #define _IPCI_API_H_
19 struct hif_exec_context;
20 
21 /**
22  * hif_ipci_open(): hif_bus_open
23  * @hif_ctx: hif context
24  * @bus_type: bus type
25  *
26  * Return: 0 for success or QDF_STATUS_E_NOMEM
27  */
28 QDF_STATUS hif_ipci_open(struct hif_softc *hif_ctx,
29 			 enum qdf_bus_type bus_type);
30 
31 /**
32  * hif_ipci_close(): hif_bus_close
33  * @hif_ctx: hif context
34  *
35  * Return: n/a
36  */
37 void hif_ipci_close(struct hif_softc *hif_ctx);
38 
39 /**
40  * hif_bus_prevent_linkdown(): allow or permit linkdown
41  * @scn: struct hif_softc
42  * @flag: true prevents linkdown, false allows
43  *
44  * Calls into the platform driver to vote against taking down the
45  * pcie link.
46  *
47  * Return: n/a
48  */
49 void hif_ipci_prevent_linkdown(struct hif_softc *scn, bool flag);
50 
51 /**
52  * hif_ipci_bus_suspend(): prepare hif for suspend
53  * @scn: struct hif_softc
54  *
55  * Return: Errno
56  */
57 int hif_ipci_bus_suspend(struct hif_softc *scn);
58 
59 /**
60  * hif_ipci_bus_suspend_noirq() - ensure there are no pending transactions
61  * @scn: hif context
62  *
63  * Ensure that if we received the wakeup message before the irq
64  * was disabled that the message is pocessed before suspending.
65  *
66  * Return: -EBUSY if we fail to flush the tasklets.
67  */
68 int hif_ipci_bus_suspend_noirq(struct hif_softc *scn);
69 
70 /**
71  * hif_ipci_bus_resume(): prepare hif for resume
72  * @scn: struct hif_softc
73  *
74  * Return: Errno
75  */
76 int hif_ipci_bus_resume(struct hif_softc *scn);
77 
78 /**
79  * hif_ipci_bus_resume_noirq() - ensure there are no pending transactions
80  * @scn: hif context
81  *
82  * Ensure that if we received the wakeup message before the irq
83  * was disabled that the message is pocessed before suspending.
84  *
85  * Return: -EBUSY if we fail to flush the tasklets.
86  */
87 int hif_ipci_bus_resume_noirq(struct hif_softc *scn);
88 
89 /**
90  * hif_ipci_disable_isr(): disable interrupt
91  * @scn: struct hif_softc
92  *
93  * Return: n/a
94  */
95 void hif_ipci_disable_isr(struct hif_softc *scn);
96 
97 /**
98  * hif_ipci_nointrs(): disable IRQ
99  * @scn: struct hif_softc
100  *
101  * This function stops interrupt(s)
102  *
103  * Return: none
104  */
105 void hif_ipci_nointrs(struct hif_softc *scn);
106 
107 /**
108  * hif_ipci_dump_registers(): dump bus debug registers
109  * @scn: struct hif_opaque_softc
110  *
111  * This function dumps hif bus debug registers
112  *
113  * Return: 0 for success or error code
114  */
115 int hif_ipci_dump_registers(struct hif_softc *scn);
116 
117 /**
118  * hif_ipci_enable_bus(): enable bus
119  *
120  * This function enables the bus
121  *
122  * @ol_sc: soft_sc struct
123  * @dev: device pointer
124  * @bdev: bus dev pointer
125  * bid: bus id pointer
126  * type: enum hif_enable_type such as HIF_ENABLE_TYPE_PROBE
127  * Return: QDF_STATUS
128  */
129 QDF_STATUS hif_ipci_enable_bus(
130 			struct hif_softc *scn,
131 			struct device *dev, void *bdev,
132 			const struct hif_bus_id *bid,
133 			enum hif_enable_type type);
134 
135 /**
136  * hif_ipci_disable_bus(): hif_disable_bus
137  *
138  * This function disables the bus
139  *
140  * @scn: struct hif_softc
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  * @hif_sc: 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_display_stats() - display stats
186  * @hif_ctx: hif context
187  *
188  * Return: none
189  */
190 void hif_ipci_display_stats(struct hif_softc *hif_ctx);
191 
192 /**
193  * hif_ipci_clear_stats() - clear stats
194  * @hif_ctx: hif context
195  *
196  * Return: none
197  */
198 void hif_ipci_clear_stats(struct hif_softc *hif_ctx);
199 
200 /**
201  * hif_ipci_needs_bmi() - return true if the soc needs bmi through the driver
202  * @scn: hif context
203  *
204  * Return: true if soc needs driver bmi otherwise false
205  */
206 bool hif_ipci_needs_bmi(struct hif_softc *scn);
207 
208 /**
209  * hif_ipci_get_irq_name() - get irqname
210  * This function gives irqnumber to irqname
211  * mapping.
212  *
213  * @irq_no: irq number
214  *
215  * Return: irq name
216  */
217 const char *hif_ipci_get_irq_name(int irq_no);
218 
219 #endif /* _IPCI_API_H_ */
220