qal_vbus_dev.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  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_allocate_iorsc() - allocate io resource
  58. * @pinnum: pin Number
  59. * @label: pin name string
  60. *
  61. * This function will allocate the io resource for a device
  62. *
  63. * Return: QDF_STATUS_SUCCESS on success
  64. */
  65. QDF_STATUS
  66. qal_vbus_allocate_iorsc(unsigned int pinnum, const char *label);
  67. /**
  68. * qal_vbus_iorsc_dir_output() - set pin dirction to output
  69. * @pin: pin Number
  70. * @val: value
  71. *
  72. * This function set the gpio pin direction to output
  73. *
  74. * Return: 0 on success, error no on failure
  75. */
  76. QDF_STATUS
  77. qal_vbus_iorsc_dir_output(unsigned int pin, int val);
  78. /**
  79. * qal_vbus_iorsc_set_value() - set pin direction
  80. * @pin: pin Number
  81. * @val: value
  82. *
  83. * This function set the gpio pin direction based on value
  84. *
  85. * Return: QDF_STATUS_SUCCESS on success
  86. */
  87. QDF_STATUS
  88. qal_vbus_iorsc_set_value(unsigned int pin, int val);
  89. /**
  90. * qal_vbus_iorsc_toirq() - set irq number to gpio
  91. * @pin: pin Number
  92. *
  93. * This function set the irq number to gpio pin
  94. *
  95. * Return: QDF_STATUS_SUCCESS on success
  96. */
  97. QDF_STATUS
  98. qal_vbus_iorsc_toirq(unsigned int pin);
  99. /**
  100. * qal_vbus_request_irq() - set interrupt handler
  101. * @irqnum: irq Number
  102. * @handler: function handler to be called
  103. * @flags: irq flags
  104. * @dev_name: device name
  105. * @ctx: pointer to device context
  106. * This function set up the handling of the interrupt
  107. *
  108. * Return: QDF_STATUS_SUCCESS on success, Error code on failure
  109. */
  110. QDF_STATUS
  111. qal_vbus_request_irq(unsigned int irqnum,
  112. irqreturn_t (*handler)(int irq, void *arg),
  113. unsigned long flags, const char *dev_name,
  114. void *ctx);
  115. /**
  116. * __qal_vbus_free_irq() - free irq
  117. * @irqnum: irq Number
  118. * @ctx: pointer to device context
  119. *
  120. * This function free the irq number set to gpio pin
  121. *
  122. * Return: QDF_STATUS_SUCCESS on success
  123. */
  124. static inline QDF_STATUS
  125. __qal_vbus_free_irq(unsigned int irqnum, void *ctx);
  126. /**
  127. * qal_vbus_enable_devclk() - enable device clock
  128. * @clk: Device clock
  129. *
  130. * This function will enable the clock for a device
  131. *
  132. * Return: QDF_STATUS_SUCCESS on success
  133. */
  134. QDF_STATUS
  135. qal_vbus_enable_devclk(struct qdf_dev_clk *clk);
  136. /**
  137. * qal_vbus_disable_devclk() - disable device clock
  138. * @clk: Device clock
  139. *
  140. * This function will disable the clock for a device
  141. *
  142. * Return: QDF_STATUS_SUCCESS on success
  143. */
  144. QDF_STATUS
  145. qal_vbus_disable_devclk(struct qdf_dev_clk *clk);
  146. /**
  147. * qal_vbus_get_dev_rstctl() - get device reset control
  148. * @pfhndl: Device handle
  149. * @state: Device state information
  150. * @rstctl: Device reset control handle
  151. *
  152. * This function will acquire the control to reset the device
  153. *
  154. * Return: QDF_STATUS_SUCCESS on success
  155. */
  156. QDF_STATUS
  157. qal_vbus_get_dev_rstctl(struct qdf_pfm_hndl *pfhndl, const char *state,
  158. struct qdf_vbus_rstctl **rstctl);
  159. /**
  160. * qal_vbus_release_dev_rstctl() - release device reset control
  161. * @pfhndl: Device handle
  162. * @rstctl: Device reset control handle
  163. *
  164. * This function will release the control to reset the device
  165. *
  166. * Return: QDF_STATUS_SUCCESS on success
  167. */
  168. QDF_STATUS
  169. qal_vbus_release_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
  170. struct qdf_vbus_rstctl *rstctl);
  171. /**
  172. * qal_vbus_activate_dev_rstctl() - activate device reset control
  173. * @pfhndl: Device handle
  174. * @rstctl: Device reset control handle
  175. *
  176. * This function will activate the reset control for the device
  177. *
  178. * Return: QDF_STATUS_SUCCESS on success
  179. */
  180. QDF_STATUS
  181. qal_vbus_activate_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
  182. struct qdf_vbus_rstctl *rstctl);
  183. /**
  184. * qal_vbus_deactivate_dev_rstctl() - deactivate device reset control
  185. * @pfhndl: Device handle
  186. * @rstctl: Device reset control handle
  187. *
  188. * This function will deactivate the reset control for the device
  189. *
  190. * Return: QDF_STATUS_SUCCESS on success
  191. */
  192. QDF_STATUS
  193. qal_vbus_deactivate_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
  194. struct qdf_vbus_rstctl *rstctl);
  195. /**
  196. * qal_vbus_get_resource() - get resource
  197. * @pfhndl: Device handle
  198. * @rsc: Resource handle
  199. * @restype: Resource type
  200. * @residx: Resource index
  201. *
  202. * This function will acquire a particular resource and attach it to the device
  203. *
  204. * Return: QDF_STATUS_SUCCESS on success
  205. */
  206. QDF_STATUS
  207. qal_vbus_get_resource(struct qdf_pfm_hndl *pfhndl,
  208. struct qdf_vbus_resource **rsc, uint32_t restype,
  209. uint32_t residx);
  210. /**
  211. * qal_vbus_get_irq() - get irq
  212. * @pfhndl: Device handle
  213. * @str: Device identifier
  214. * @irq: irq number
  215. *
  216. * This function will acquire an irq for the device
  217. *
  218. * Return: QDF_STATUS_SUCCESS on success
  219. */
  220. QDF_STATUS
  221. qal_vbus_get_irq(struct qdf_pfm_hndl *pfhndl, const char *str, int *irq);
  222. /**
  223. * qal_vbus_register_driver() - register driver
  224. * @pfdev: Device handle
  225. *
  226. * This function will initialize a device
  227. *
  228. * Return: QDF_STATUS_SUCCESS on success
  229. */
  230. QDF_STATUS
  231. qal_vbus_register_driver(struct qdf_pfm_drv *pfdev);
  232. /**
  233. * qal_vbus_deregister_driver() - deregister driver
  234. * @pfdev: Device handle
  235. *
  236. * This function will deregister the driver for a device
  237. *
  238. * Return: QDF_STATUS_SUCCESS on success
  239. */
  240. QDF_STATUS
  241. qal_vbus_deregister_driver(struct qdf_pfm_drv *pfdev);
  242. /**
  243. * qal_vbus_gpio_set_value_cansleep() - assign a gpio's value
  244. * @gpio: gpio whose value will be assigned
  245. * @value: value to assign
  246. *
  247. * Return: QDF_STATUS_SUCCESS on success
  248. */
  249. QDF_STATUS
  250. qal_vbus_gpio_set_value_cansleep(unsigned int gpio, int value);
  251. /**
  252. * qal_vbus_rcu_read_lock() - mark the beginning of an RCU read-side critical
  253. * section
  254. *
  255. * Return: QDF_STATUS_SUCCESS on success
  256. */
  257. QDF_STATUS
  258. qal_vbus_rcu_read_lock(void);
  259. /**
  260. * qal_vbus_rcu_read_unlock() - mark the end of an RCU read-side critical
  261. * section
  262. *
  263. * Return: QDF_STATUS_SUCCESS on success
  264. */
  265. QDF_STATUS
  266. qal_vbus_rcu_read_unlock(void);
  267. #else
  268. static inline QDF_STATUS
  269. qal_vbus_get_iorsc(int devnum, uint32_t flag, char *devname)
  270. {
  271. return __qal_vbus_get_iorsc(devnum, flag, devname);
  272. }
  273. static inline QDF_STATUS
  274. qal_vbus_allocate_iorsc(unsigned int pinnum, const char *label)
  275. {
  276. return __qal_vbus_allocate_iorsc(pinnum, label);
  277. }
  278. static inline QDF_STATUS
  279. qal_vbus_iorsc_dir_output(unsigned int pin, int val)
  280. {
  281. return __qal_vbus_iorsc_dir_output(pin, val);
  282. }
  283. static inline QDF_STATUS
  284. qal_vbus_iorsc_set_value(unsigned int pin, int val)
  285. {
  286. return __qal_vbus_iorsc_set_value(pin, val);
  287. }
  288. static inline QDF_STATUS
  289. qal_vbus_release_iorsc(int devnum)
  290. {
  291. return __qal_vbus_release_iorsc(devnum);
  292. }
  293. static inline QDF_STATUS
  294. qal_vbus_iorsc_toirq(unsigned int pin)
  295. {
  296. return __qal_vbus_iorsc_toirq(pin);
  297. }
  298. static inline QDF_STATUS
  299. qal_vbus_request_irq(unsigned int irqnum,
  300. irqreturn_t (*handler)(int irq, void *arg),
  301. unsigned long flags, const char *dev_name, void *ctx)
  302. {
  303. return __qal_vbus_request_irq(irqnum, handler, flags, dev_name, ctx);
  304. }
  305. static inline QDF_STATUS
  306. qal_vbus_free_irq(unsigned int irqnum, void *ctx)
  307. {
  308. return __qal_vbus_free_irq(irqnum, ctx);
  309. }
  310. static inline QDF_STATUS
  311. qal_vbus_enable_devclk(struct qdf_dev_clk *clk)
  312. {
  313. return __qal_vbus_enable_devclk(clk);
  314. }
  315. static inline QDF_STATUS
  316. qal_vbus_disable_devclk(struct qdf_dev_clk *clk)
  317. {
  318. return __qal_vbus_disable_devclk(clk);
  319. }
  320. static inline QDF_STATUS
  321. qal_vbus_get_dev_rstctl(struct qdf_pfm_hndl *pfhndl, const char *state,
  322. struct qdf_vbus_rstctl **rstctl)
  323. {
  324. return __qal_vbus_get_dev_rstctl(pfhndl, state, rstctl);
  325. }
  326. static inline QDF_STATUS
  327. qal_vbus_release_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
  328. struct qdf_vbus_rstctl *rstctl)
  329. {
  330. return __qal_vbus_release_dev_rstctl(pfhndl, rstctl);
  331. }
  332. static inline QDF_STATUS
  333. qal_vbus_activate_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
  334. struct qdf_vbus_rstctl *rstctl)
  335. {
  336. return __qal_vbus_activate_dev_rstctl(pfhndl, rstctl);
  337. }
  338. static inline QDF_STATUS
  339. qal_vbus_deactivate_dev_rstctl(struct qdf_pfm_hndl *pfhndl,
  340. struct qdf_vbus_rstctl *rstctl)
  341. {
  342. return __qal_vbus_deactivate_dev_rstctl(pfhndl, rstctl);
  343. }
  344. static inline QDF_STATUS
  345. qal_vbus_get_resource(struct qdf_pfm_hndl *pfhndl,
  346. struct qdf_vbus_resource **rsc, uint32_t restype,
  347. uint32_t residx)
  348. {
  349. return __qal_vbus_get_resource(pfhndl, rsc, restype, residx);
  350. }
  351. static inline QDF_STATUS
  352. qal_vbus_get_irq(struct qdf_pfm_hndl *pfhndl, const char *str, int *irq)
  353. {
  354. return __qal_vbus_get_irq(pfhndl, str, irq);
  355. }
  356. static inline QDF_STATUS
  357. qal_vbus_register_driver(struct qdf_pfm_drv *pfdev)
  358. {
  359. return __qal_vbus_register_driver(pfdev);
  360. }
  361. static inline QDF_STATUS
  362. qal_vbus_deregister_driver(struct qdf_pfm_drv *pfdev)
  363. {
  364. return __qal_vbus_deregister_driver(pfdev);
  365. }
  366. static inline QDF_STATUS
  367. qal_vbus_gpio_set_value_cansleep(unsigned int gpio, int value)
  368. {
  369. return __qal_vbus_gpio_set_value_cansleep(gpio, value);
  370. }
  371. static inline QDF_STATUS
  372. qal_vbus_rcu_read_lock(void)
  373. {
  374. return __qal_vbus_rcu_read_lock();
  375. }
  376. static inline QDF_STATUS
  377. qal_vbus_rcu_read_unlock(void)
  378. {
  379. return __qal_vbus_rcu_read_unlock();
  380. }
  381. #endif
  382. #endif /* __QAL_VBUS_DEV_H */