xref: /wlan-dirver/qca-wifi-host-cmn/qal/inc/qal_vbus_dev.h (revision 8cfe6b10058a04cafb17eed051f2ddf11bee8931)
1 /*
2  * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
3  * Copyright (c) 2023 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 /**
21  * DOC: qal_vbus_dev
22  * QCA abstraction layer (QAL) virtual bus management APIs
23  */
24 
25 #if !defined(__QAL_VBUS_DEV_H)
26 #define __QAL_VBUS_DEV_H
27 
28 /* Include Files */
29 #include <qdf_types.h>
30 #include <i_qal_vbus_dev.h>
31 
32 struct qdf_vbus_resource;
33 struct qdf_vbus_rstctl;
34 struct qdf_dev_clk;
35 struct qdf_pfm_hndl;
36 struct qdf_pfm_drv;
37 
38 #ifdef ENHANCED_OS_ABSTRACTION
39 /**
40  * qal_vbus_get_iorsc() - acquire io resource
41  * @devnum: Device Number
42  * @flag: Property bitmap for the io resource
43  * @devname: Device name string
44  *
45  * This function will allocate the io resource for a device
46  *
47  * Return: QDF_STATUS_SUCCESS on success
48  */
49 QDF_STATUS
50 qal_vbus_get_iorsc(int devnum, uint32_t flag, char *devname);
51 
52 /**
53  * qal_vbus_release_iorsc() - release io resource
54  * @devnum: Device Number
55  *
56  * This function will release the io resource attached to a device
57  *
58  * Return: QDF_STATUS_SUCCESS on success
59  */
60 QDF_STATUS
61 qal_vbus_release_iorsc(int devnum);
62 
63 /**
64  * qal_vbus_enable_devclk() - enable device clock
65  * @clk: Device clock
66  *
67  * This function will enable the clock for a device
68  *
69  * Return: QDF_STATUS_SUCCESS on success
70  */
71 QDF_STATUS
72 qal_vbus_enable_devclk(struct qdf_dev_clk *clk);
73 
74 /**
75  * qal_vbus_disable_devclk() - disable device clock
76  * @clk: Device clock
77  *
78  * This function will disable the clock for a device
79  *
80  * Return: QDF_STATUS_SUCCESS on success
81  */
82 QDF_STATUS
83 qal_vbus_disable_devclk(struct qdf_dev_clk *clk);
84 
85 /**
86  * qal_vbus_get_dev_rstctl() - get device reset control
87  * @pfhndl: Device handle
88  * @state: Device state information
89  * @rstctl: Device reset control handle
90  *
91  * This function will acquire the control to reset the device
92  *
93  * Return: QDF_STATUS_SUCCESS on success
94  */
95 QDF_STATUS
96 qal_vbus_get_dev_rstctl(struct qdf_pfm_hndl *pfhndl, const char *state,
97 			struct qdf_vbus_rstctl **rstctl);
98 
99 /**
100  * qal_vbus_release_dev_rstctl() - release device reset control
101  * @pfhndl: Device handle
102  * @rstctl: Device reset control handle
103  *
104  * This function will release the control to reset the device
105  *
106  * Return: QDF_STATUS_SUCCESS on success
107  */
108 QDF_STATUS
109 qal_vbus_release_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
110 			    struct qdf_vbus_rstctl *rstctl);
111 
112 /**
113  * qal_vbus_activate_dev_rstctl() - activate device reset control
114  * @pfhndl: Device handle
115  * @rstctl: Device reset control handle
116  *
117  * This function will activate the reset control for the device
118  *
119  * Return: QDF_STATUS_SUCCESS on success
120  */
121 QDF_STATUS
122 qal_vbus_activate_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
123 			     struct qdf_vbus_rstctl *rstctl);
124 
125 /**
126  * qal_vbus_deactivate_dev_rstctl() - deactivate device reset control
127  * @pfhndl: Device handle
128  * @rstctl: Device reset control handle
129  *
130  * This function will deactivate the reset control for the device
131  *
132  * Return: QDF_STATUS_SUCCESS on success
133  */
134 QDF_STATUS
135 qal_vbus_deactivate_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
136 			       struct qdf_vbus_rstctl *rstctl);
137 
138 /**
139  * qal_vbus_get_resource() - get resource
140  * @pfhndl: Device handle
141  * @rsc: Resource handle
142  * @restype: Resource type
143  * @residx: Resource index
144  *
145  * This function will acquire a particular resource and attach it to the device
146  *
147  * Return: QDF_STATUS_SUCCESS on success
148  */
149 QDF_STATUS
150 qal_vbus_get_resource(struct qdf_pfm_hndl *pfhndl,
151 		      struct qdf_vbus_resource **rsc, uint32_t restype,
152 		      uint32_t residx);
153 
154 /**
155  * qal_vbus_get_irq() - get irq
156  * @pfhndl: Device handle
157  * @str: Device identifier
158  * @irq: irq number
159  *
160  * This function will acquire an irq for the device
161  *
162  * Return: QDF_STATUS_SUCCESS on success
163  */
164 QDF_STATUS
165 qal_vbus_get_irq(struct qdf_pfm_hndl *pfhndl, const char *str, int *irq);
166 
167 /**
168  * qal_vbus_register_driver() - register driver
169  * @pfdev: Device handle
170  *
171  * This function will initialize a device
172  *
173  * Return: QDF_STATUS_SUCCESS on success
174  */
175 QDF_STATUS
176 qal_vbus_register_driver(struct qdf_pfm_drv *pfdev);
177 
178 /**
179  * qal_vbus_deregister_driver() - deregister driver
180  * @pfdev: Device handle
181  *
182  * This function will deregister the driver for a device
183  *
184  * Return: QDF_STATUS_SUCCESS on success
185  */
186 QDF_STATUS
187 qal_vbus_deregister_driver(struct qdf_pfm_drv *pfdev);
188 
189 /**
190  * qal_vbus_gpio_set_value_cansleep() - assign a gpio's value
191  * @gpio: gpio whose value will be assigned
192  * @value: value to assign
193  *
194  * Return: QDF_STATUS_SUCCESS on success
195  */
196 QDF_STATUS
197 qal_vbus_gpio_set_value_cansleep(unsigned int gpio, int value);
198 
199 /**
200  * qal_vbus_rcu_read_lock() - mark the beginning of an RCU read-side critical
201  *                            section
202  *
203  * Return: QDF_STATUS_SUCCESS on success
204  */
205 QDF_STATUS
206 qal_vbus_rcu_read_lock(void);
207 
208 /**
209  * qal_vbus_rcu_read_unlock() - mark the end of an RCU read-side critical
210  *                              section
211  *
212  * Return: QDF_STATUS_SUCCESS on success
213  */
214 QDF_STATUS
215 qal_vbus_rcu_read_unlock(void);
216 #else
217 static inline QDF_STATUS
218 qal_vbus_get_iorsc(int devnum, uint32_t flag, char *devname)
219 {
220 	return __qal_vbus_get_iorsc(devnum, flag, devname);
221 }
222 
223 static inline QDF_STATUS
224 qal_vbus_release_iorsc(int devnum)
225 {
226 	return __qal_vbus_release_iorsc(devnum);
227 }
228 
229 static inline QDF_STATUS
230 qal_vbus_enable_devclk(struct qdf_dev_clk *clk)
231 {
232 	return __qal_vbus_enable_devclk(clk);
233 }
234 
235 static inline QDF_STATUS
236 qal_vbus_disable_devclk(struct qdf_dev_clk *clk)
237 {
238 	return __qal_vbus_disable_devclk(clk);
239 }
240 
241 static inline QDF_STATUS
242 qal_vbus_get_dev_rstctl(struct qdf_pfm_hndl *pfhndl, const char *state,
243 			struct qdf_vbus_rstctl **rstctl)
244 {
245 	return __qal_vbus_get_dev_rstctl(pfhndl, state, rstctl);
246 }
247 
248 static inline QDF_STATUS
249 qal_vbus_release_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
250 			    struct qdf_vbus_rstctl *rstctl)
251 {
252 	return __qal_vbus_release_dev_rstctl(pfhndl, rstctl);
253 }
254 
255 static inline QDF_STATUS
256 qal_vbus_activate_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
257 			     struct qdf_vbus_rstctl *rstctl)
258 {
259 	return __qal_vbus_activate_dev_rstctl(pfhndl, rstctl);
260 }
261 
262 static inline QDF_STATUS
263 qal_vbus_deactivate_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
264 			       struct qdf_vbus_rstctl *rstctl)
265 {
266 	return __qal_vbus_deactivate_dev_rstctl(pfhndl, rstctl);
267 }
268 
269 static inline QDF_STATUS
270 qal_vbus_get_resource(struct qdf_pfm_hndl *pfhndl,
271 		      struct qdf_vbus_resource **rsc, uint32_t restype,
272 		      uint32_t residx)
273 {
274 	return __qal_vbus_get_resource(pfhndl, rsc, restype, residx);
275 }
276 
277 static inline QDF_STATUS
278 qal_vbus_get_irq(struct qdf_pfm_hndl *pfhndl, const char *str, int *irq)
279 {
280 	return __qal_vbus_get_irq(pfhndl, str, irq);
281 }
282 
283 static inline QDF_STATUS
284 qal_vbus_register_driver(struct qdf_pfm_drv *pfdev)
285 {
286 	return __qal_vbus_register_driver(pfdev);
287 }
288 
289 static inline QDF_STATUS
290 qal_vbus_deregister_driver(struct qdf_pfm_drv *pfdev)
291 {
292 	return __qal_vbus_deregister_driver(pfdev);
293 }
294 
295 static inline QDF_STATUS
296 qal_vbus_gpio_set_value_cansleep(unsigned int gpio, int value)
297 {
298 	return __qal_vbus_gpio_set_value_cansleep(gpio, value);
299 }
300 
301 static inline QDF_STATUS
302 qal_vbus_rcu_read_lock(void)
303 {
304 	return __qal_vbus_rcu_read_lock();
305 }
306 
307 static inline QDF_STATUS
308 qal_vbus_rcu_read_unlock(void)
309 {
310 	return __qal_vbus_rcu_read_unlock();
311 }
312 #endif
313 
314 #endif  /* __QAL_VBUS_DEV_H */
315