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