qal_vbus_dev.h 7.8 KB

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