xref: /wlan-dirver/qca-wifi-host-cmn/qal/inc/qal_vbus_dev.h (revision dd4dc88b837a295134aa9869114a2efee0f4894b)
1 /*
2  * Copyright (c) 2018-2019 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 #else
188 static inline QDF_STATUS
189 qal_vbus_get_iorsc(int devnum, uint32_t flag, char *devname)
190 {
191 	return __qal_vbus_get_iorsc(devnum, flag, devname);
192 }
193 
194 static inline QDF_STATUS
195 qal_vbus_release_iorsc(int devnum)
196 {
197 	return __qal_vbus_release_iorsc(devnum);
198 }
199 
200 static inline QDF_STATUS
201 qal_vbus_enable_devclk(struct qdf_dev_clk *clk)
202 {
203 	return __qal_vbus_enable_devclk(clk);
204 }
205 
206 static inline QDF_STATUS
207 qal_vbus_disable_devclk(struct qdf_dev_clk *clk)
208 {
209 	return __qal_vbus_disable_devclk(clk);
210 }
211 
212 static inline QDF_STATUS
213 qal_vbus_get_dev_rstctl(struct qdf_pfm_hndl *pfhndl, const char *state,
214 			struct qdf_vbus_rstctl **rstctl)
215 {
216 	return __qal_vbus_get_dev_rstctl(pfhndl, state, rstctl);
217 }
218 
219 static inline QDF_STATUS
220 qal_vbus_release_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
221 			    struct qdf_vbus_rstctl *rstctl)
222 {
223 	return __qal_vbus_release_dev_rstctl(pfhndl, rstctl);
224 }
225 
226 static inline QDF_STATUS
227 qal_vbus_activate_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
228 			     struct qdf_vbus_rstctl *rstctl)
229 {
230 	return __qal_vbus_activate_dev_rstctl(pfhndl, rstctl);
231 }
232 
233 static inline QDF_STATUS
234 qal_vbus_deactivate_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
235 			       struct qdf_vbus_rstctl *rstctl)
236 {
237 	return __qal_vbus_deactivate_dev_rstctl(pfhndl, rstctl);
238 }
239 
240 static inline QDF_STATUS
241 qal_vbus_get_resource(struct qdf_pfm_hndl *pfhndl,
242 		      struct qdf_vbus_resource **rsc, uint32_t restype,
243 		      uint32_t residx)
244 {
245 	return __qal_vbus_get_resource(pfhndl, rsc, restype, residx);
246 }
247 
248 static inline QDF_STATUS
249 qal_vbus_get_irq(struct qdf_pfm_hndl *pfhndl, const char *str, int *irq)
250 {
251 	return __qal_vbus_get_irq(pfhndl, str, irq);
252 }
253 
254 static inline QDF_STATUS
255 qal_vbus_register_driver(struct qdf_pfm_drv *pfdev)
256 {
257 	return __qal_vbus_register_driver(pfdev);
258 }
259 
260 static inline QDF_STATUS
261 qal_vbus_deregister_driver(struct qdf_pfm_drv *pfdev)
262 {
263 	return __qal_vbus_deregister_driver(pfdev);
264 }
265 #endif
266 #endif  /* __QAL_VBUS_DEV_H */
267