qdf_platform.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. * DOC: qdf_platform.h
  20. * This file defines platform API abstractions.
  21. */
  22. #ifndef _QDF_PLATFORM_H
  23. #define _QDF_PLATFORM_H
  24. #include "qdf_types.h"
  25. /**
  26. * qdf_self_recovery_callback() - callback for self recovery
  27. * @psoc: pointer to the posc object
  28. * @reason: the reason for the recovery request
  29. * @func: the caller's function name
  30. * @line: the line number of the callsite
  31. *
  32. * Return: none
  33. */
  34. typedef void (*qdf_self_recovery_callback)(void *psoc,
  35. enum qdf_hang_reason reason,
  36. const char *func,
  37. const uint32_t line);
  38. /**
  39. * qdf_is_fw_down_callback() - callback to query if fw is down
  40. *
  41. * Return: true if fw is down and false if fw is not down
  42. */
  43. typedef bool (*qdf_is_fw_down_callback)(void);
  44. /**
  45. * qdf_register_fw_down_callback() - API to register fw down callback
  46. * @is_fw_down: callback to query if fw is down or not
  47. *
  48. * Return: none
  49. */
  50. void qdf_register_fw_down_callback(qdf_is_fw_down_callback is_fw_down);
  51. /**
  52. * qdf_is_fw_down() - API to check if fw is down or not
  53. *
  54. * Return: true: if fw is down
  55. * false: if fw is not down
  56. */
  57. bool qdf_is_fw_down(void);
  58. /**
  59. * qdf_wmi_recv_qmi_cb() - callback to receive WMI over QMI
  60. * @cb_ctx: WMI event recv callback context(wmi_handle)
  61. * @buf: WMI buffer
  62. * @len: WMI buffer len
  63. *
  64. * Return: 0 if success otherwise -EINVAL
  65. */
  66. typedef int (*qdf_wmi_recv_qmi_cb)(void *cb_ctx, void *buf, int len);
  67. /**
  68. * qdf_wmi_send_over_qmi_callback() - callback to send WMI over QMI
  69. * @buf: WMI buffer
  70. * @len: WMI buffer len
  71. * @cb_ctx: WMI event recv callback context(wmi_handle)
  72. * @wmi_rx_cb: WMI event receive call back
  73. *
  74. * Return: QDF_STATUS_SUCCESS if success otherwise QDF error code
  75. */
  76. typedef QDF_STATUS (*qdf_wmi_send_over_qmi_callback)(void *buf, uint32_t len,
  77. void *cb_ctx,
  78. qdf_wmi_recv_qmi_cb
  79. wmi_rx_cb);
  80. /**
  81. * qdf_register_wmi_send_recv_qmi_callback() - Register WMI over QMI callback
  82. * @qdf_wmi_send_over_qmi_callback: callback to send recv WMI data over QMI
  83. *
  84. * Return: none
  85. */
  86. void qdf_register_wmi_send_recv_qmi_callback(qdf_wmi_send_over_qmi_callback
  87. wmi_send_recv_qmi_cb);
  88. /**
  89. * qdf_wmi_send_recv_qmi() - API to send receive WMI data over QMI
  90. * @buf: WMI buffer
  91. * @len: WMI buffer len
  92. * @cb_ctx: WMI event recv callback context(wmi_handle)
  93. * @wmi_rx_cb: WMI event receive call back
  94. *
  95. * Return: QDF STATUS of operation
  96. */
  97. QDF_STATUS qdf_wmi_send_recv_qmi(void *buf, uint32_t len, void *cb_ctx,
  98. qdf_wmi_recv_qmi_cb wmi_rx_cb);
  99. /**
  100. * qdf_is_driver_unloading_callback() - callback to get driver unloading in progress
  101. * or not
  102. *
  103. * Return: true if driver is unloading else false
  104. */
  105. typedef bool (*qdf_is_driver_unloading_callback)(void);
  106. /**
  107. * qdf_register_is_driver_unloading_callback() - driver unloading callback
  108. * @callback: driver unloading callback
  109. *
  110. * Return: None
  111. */
  112. void qdf_register_is_driver_unloading_callback(
  113. qdf_is_driver_unloading_callback callback);
  114. /**
  115. * qdf_register_self_recovery_callback() - register self recovery callback
  116. * @callback: self recovery callback
  117. *
  118. * Return: None
  119. */
  120. void qdf_register_self_recovery_callback(qdf_self_recovery_callback callback);
  121. /**
  122. * qdf_trigger_self_recovery () - trigger self recovery
  123. * @psoc: the psoc at which the recovery is being triggered
  124. * @reason: the reason for the recovery request
  125. *
  126. * Call API only in case of fatal error,
  127. * if self_recovery_cb callback is registered, injcets fw crash and recovers
  128. * else raises QDF_BUG()
  129. *
  130. * Return: None
  131. */
  132. #define qdf_trigger_self_recovery(psoc, reason) \
  133. __qdf_trigger_self_recovery(psoc, reason, __func__, __LINE__)
  134. void __qdf_trigger_self_recovery(void *psoc, enum qdf_hang_reason reason,
  135. const char *func, const uint32_t line);
  136. /**
  137. * qdf_is_recovering_callback() - callback to get driver recovering in
  138. * progress or not
  139. *
  140. * Return: true if driver is doing recovering else false
  141. */
  142. typedef bool (*qdf_is_recovering_callback)(void);
  143. /**
  144. * qdf_register_recovering_state_query_callback() - register recover status
  145. * query callback
  146. *
  147. * Return: none
  148. */
  149. void qdf_register_recovering_state_query_callback(
  150. qdf_is_recovering_callback is_recovering);
  151. /**
  152. * qdf_is_driver_unloading() - get driver unloading in progress status
  153. * or not
  154. *
  155. * Return: true if driver is unloading else false
  156. */
  157. bool qdf_is_driver_unloading(void);
  158. /**
  159. * qdf_is_recovering() - get driver recovering in progress status
  160. * or not
  161. *
  162. * Return: true if driver is doing recovering else false
  163. */
  164. bool qdf_is_recovering(void);
  165. /**
  166. * struct qdf_op_sync - opaque operation synchronization context handle
  167. */
  168. struct qdf_op_sync;
  169. typedef int (*qdf_op_protect_cb)(void **out_sync, const char *func);
  170. typedef void (*qdf_op_unprotect_cb)(void *sync, const char *func);
  171. /**
  172. * qdf_op_protect() - attempt to protect a driver operation
  173. * @out_sync: output parameter for the synchronization context, populated on
  174. * success
  175. *
  176. * Return: Errno
  177. */
  178. #define qdf_op_protect(out_sync) __qdf_op_protect(out_sync, __func__)
  179. qdf_must_check int
  180. __qdf_op_protect(struct qdf_op_sync **out_sync, const char *func);
  181. /**
  182. * qdf_op_unprotect() - release driver operation protection
  183. * @sync: synchronization context returned from qdf_op_protect()
  184. *
  185. * Return: None
  186. */
  187. #define qdf_op_unprotect(sync) __qdf_op_unprotect(sync, __func__)
  188. void __qdf_op_unprotect(struct qdf_op_sync *sync, const char *func);
  189. /**
  190. * qdf_op_callbacks_register() - register driver operation protection callbacks
  191. *
  192. * Return: None
  193. */
  194. void qdf_op_callbacks_register(qdf_op_protect_cb on_protect,
  195. qdf_op_unprotect_cb on_unprotect);
  196. /**
  197. * qdf_is_drv_connected_callback() - callback to query if drv is connected
  198. *
  199. * Return: true if drv is connected else false
  200. */
  201. typedef bool (*qdf_is_drv_connected_callback)(void);
  202. /**
  203. * qdf_is_drv_connected() - API to check if drv is connected or not
  204. *
  205. * DRV is dynamic request voting using which fw can do page fault and
  206. * bring in page back without apps wake up
  207. *
  208. * Return: true: if drv is connected
  209. * false: if drv is not connected
  210. */
  211. bool qdf_is_drv_connected(void);
  212. /**
  213. * qdf_register_drv_connected_callback() - API to register drv connected cb
  214. * @is_drv_connected: callback to query if drv is connected or not
  215. *
  216. * Return: none
  217. */
  218. void qdf_register_drv_connected_callback(qdf_is_drv_connected_callback
  219. is_drv_connected);
  220. /**
  221. * qdf_check_state_before_panic() - API to check if FW is down
  222. * or driver is in recovery before calling assert
  223. * @func: Caller function pointer used for debug info
  224. * @line: Caller function line number
  225. *
  226. * Return: none
  227. */
  228. void qdf_check_state_before_panic(const char *func, const uint32_t line);
  229. /**
  230. * qdf_is_drv_supported_callback() - callback to query if drv is supported
  231. *
  232. * Return: true if drv is supported else false
  233. */
  234. typedef bool (*qdf_is_drv_supported_callback)(void);
  235. /**
  236. * qdf_is_drv_supported_callback() - API to check if drv is supported or not
  237. *
  238. * DRV is dynamic request voting using which fw can do page fault and
  239. * bring in page back without apps wake up
  240. *
  241. * Return: true: if drv is supported
  242. * false: if drv is not supported
  243. */
  244. bool qdf_is_drv_supported(void);
  245. /**
  246. * qdf_register_drv_supported_callback() - API to register drv supported cb
  247. * @is_drv_supported: callback to query if drv is supported or not
  248. *
  249. * Return: none
  250. */
  251. void qdf_register_drv_supported_callback(qdf_is_drv_supported_callback
  252. is_drv_supported);
  253. typedef void (*qdf_recovery_reason_update_callback)(enum qdf_hang_reason
  254. reason);
  255. /**
  256. * qdf_register_recovery_reason_update() - Register callback to update recovery
  257. * reason
  258. * @qdf_recovery_reason_update_callback: callback to update recovery reason
  259. *
  260. * Return: none
  261. */
  262. void qdf_register_recovery_reason_update(qdf_recovery_reason_update_callback
  263. callback);
  264. /**
  265. * qdf_recovery_reason_update() - update recovery reason
  266. * @reason: recovery reason
  267. *
  268. * Return: none
  269. */
  270. void qdf_recovery_reason_update(enum qdf_hang_reason reason);
  271. /**
  272. * qdf_bus_reg_dump() - callback for getting bus specific register dump
  273. * @dev: Bus specific device
  274. * @buf: Hang event buffer in which the data will be populated
  275. * @len: length of data to be populated in the hang event buffer
  276. *
  277. * Return: none
  278. */
  279. typedef void (*qdf_bus_reg_dump)(struct device *dev, uint8_t *buf,
  280. uint32_t len);
  281. /**
  282. * qdf_register_get_bus_reg_dump() - Register callback to update bus register
  283. * dump
  284. * @qdf_bus_reg_dump: callback to update bus register dump
  285. *
  286. * Return: none
  287. */
  288. void qdf_register_get_bus_reg_dump(qdf_bus_reg_dump callback);
  289. /**
  290. * qdf_get_bus_reg_dump() - Get the register dump for the bus
  291. * @dev: device
  292. * @buffer: buffer for hang data
  293. * @len: len of hang data
  294. *
  295. * Return: none
  296. */
  297. void qdf_get_bus_reg_dump(struct device *dev, uint8_t *buf, uint32_t len);
  298. #endif /*_QDF_PLATFORM_H*/