qdf_platform.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362
  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_is_driver_state_module_stop_callback() - callback to get driver state is
  116. * module stop or not
  117. *
  118. * Return: true if driver state is module stop else false
  119. */
  120. typedef bool (*qdf_is_driver_state_module_stop_callback)(void);
  121. /**
  122. * qdf_register_is_driver_state_module_stop_callback() - driver state is
  123. * module stop or not
  124. * @callback: driver state module stop callback
  125. *
  126. * Return: None
  127. */
  128. void qdf_register_is_driver_state_module_stop_callback(
  129. qdf_is_driver_state_module_stop_callback callback);
  130. /**
  131. * qdf_register_self_recovery_callback() - register self recovery callback
  132. * @callback: self recovery callback
  133. *
  134. * Return: None
  135. */
  136. void qdf_register_self_recovery_callback(qdf_self_recovery_callback callback);
  137. /**
  138. * qdf_trigger_self_recovery () - trigger self recovery
  139. * @psoc: the psoc at which the recovery is being triggered
  140. * @reason: the reason for the recovery request
  141. *
  142. * Call API only in case of fatal error,
  143. * if self_recovery_cb callback is registered, injcets fw crash and recovers
  144. * else raises QDF_BUG()
  145. *
  146. * Return: None
  147. */
  148. #define qdf_trigger_self_recovery(psoc, reason) \
  149. __qdf_trigger_self_recovery(psoc, reason, __func__, __LINE__)
  150. void __qdf_trigger_self_recovery(void *psoc, enum qdf_hang_reason reason,
  151. const char *func, const uint32_t line);
  152. /**
  153. * qdf_is_recovering_callback() - callback to get driver recovering in
  154. * progress or not
  155. *
  156. * Return: true if driver is doing recovering else false
  157. */
  158. typedef bool (*qdf_is_recovering_callback)(void);
  159. /**
  160. * qdf_register_recovering_state_query_callback() - register recover status
  161. * query callback
  162. *
  163. * Return: none
  164. */
  165. void qdf_register_recovering_state_query_callback(
  166. qdf_is_recovering_callback is_recovering);
  167. /**
  168. * qdf_is_driver_unloading() - get driver unloading in progress status
  169. * or not
  170. *
  171. * Return: true if driver is unloading else false
  172. */
  173. bool qdf_is_driver_unloading(void);
  174. /**
  175. * qdf_is_driver_state_module_stop() - get driver state is module stop or not
  176. *
  177. * Return: true if driver state is module stop else false
  178. */
  179. bool qdf_is_driver_state_module_stop(void);
  180. /**
  181. * qdf_is_recovering() - get driver recovering in progress status
  182. * or not
  183. *
  184. * Return: true if driver is doing recovering else false
  185. */
  186. bool qdf_is_recovering(void);
  187. /**
  188. * struct qdf_op_sync - opaque operation synchronization context handle
  189. */
  190. struct qdf_op_sync;
  191. typedef int (*qdf_op_protect_cb)(void **out_sync, const char *func);
  192. typedef void (*qdf_op_unprotect_cb)(void *sync, const char *func);
  193. /**
  194. * qdf_op_protect() - attempt to protect a driver operation
  195. * @out_sync: output parameter for the synchronization context, populated on
  196. * success
  197. *
  198. * Return: Errno
  199. */
  200. #define qdf_op_protect(out_sync) __qdf_op_protect(out_sync, __func__)
  201. qdf_must_check int
  202. __qdf_op_protect(struct qdf_op_sync **out_sync, const char *func);
  203. /**
  204. * qdf_op_unprotect() - release driver operation protection
  205. * @sync: synchronization context returned from qdf_op_protect()
  206. *
  207. * Return: None
  208. */
  209. #define qdf_op_unprotect(sync) __qdf_op_unprotect(sync, __func__)
  210. void __qdf_op_unprotect(struct qdf_op_sync *sync, const char *func);
  211. /**
  212. * qdf_op_callbacks_register() - register driver operation protection callbacks
  213. *
  214. * Return: None
  215. */
  216. void qdf_op_callbacks_register(qdf_op_protect_cb on_protect,
  217. qdf_op_unprotect_cb on_unprotect);
  218. /**
  219. * qdf_is_drv_connected_callback() - callback to query if drv is connected
  220. *
  221. * Return: true if drv is connected else false
  222. */
  223. typedef bool (*qdf_is_drv_connected_callback)(void);
  224. /**
  225. * qdf_is_drv_connected() - API to check if drv is connected or not
  226. *
  227. * DRV is dynamic request voting using which fw can do page fault and
  228. * bring in page back without apps wake up
  229. *
  230. * Return: true: if drv is connected
  231. * false: if drv is not connected
  232. */
  233. bool qdf_is_drv_connected(void);
  234. /**
  235. * qdf_register_drv_connected_callback() - API to register drv connected cb
  236. * @is_drv_connected: callback to query if drv is connected or not
  237. *
  238. * Return: none
  239. */
  240. void qdf_register_drv_connected_callback(qdf_is_drv_connected_callback
  241. is_drv_connected);
  242. /**
  243. * qdf_check_state_before_panic() - API to check if FW is down
  244. * or driver is in recovery before calling assert
  245. * @func: Caller function pointer used for debug info
  246. * @line: Caller function line number
  247. *
  248. * Return: none
  249. */
  250. void qdf_check_state_before_panic(const char *func, const uint32_t line);
  251. /**
  252. * qdf_is_drv_supported_callback() - callback to query if drv is supported
  253. *
  254. * Return: true if drv is supported else false
  255. */
  256. typedef bool (*qdf_is_drv_supported_callback)(void);
  257. /**
  258. * qdf_is_drv_supported_callback() - API to check if drv is supported or not
  259. *
  260. * DRV is dynamic request voting using which fw can do page fault and
  261. * bring in page back without apps wake up
  262. *
  263. * Return: true: if drv is supported
  264. * false: if drv is not supported
  265. */
  266. bool qdf_is_drv_supported(void);
  267. /**
  268. * qdf_register_drv_supported_callback() - API to register drv supported cb
  269. * @is_drv_supported: callback to query if drv is supported or not
  270. *
  271. * Return: none
  272. */
  273. void qdf_register_drv_supported_callback(qdf_is_drv_supported_callback
  274. is_drv_supported);
  275. typedef void (*qdf_recovery_reason_update_callback)(enum qdf_hang_reason
  276. reason);
  277. /**
  278. * qdf_register_recovery_reason_update() - Register callback to update recovery
  279. * reason
  280. * @qdf_recovery_reason_update_callback: callback to update recovery reason
  281. *
  282. * Return: none
  283. */
  284. void qdf_register_recovery_reason_update(qdf_recovery_reason_update_callback
  285. callback);
  286. /**
  287. * qdf_recovery_reason_update() - update recovery reason
  288. * @reason: recovery reason
  289. *
  290. * Return: none
  291. */
  292. void qdf_recovery_reason_update(enum qdf_hang_reason reason);
  293. /**
  294. * qdf_bus_reg_dump() - callback for getting bus specific register dump
  295. * @dev: Bus specific device
  296. * @buf: Hang event buffer in which the data will be populated
  297. * @len: length of data to be populated in the hang event buffer
  298. *
  299. * Return: none
  300. */
  301. typedef void (*qdf_bus_reg_dump)(struct device *dev, uint8_t *buf,
  302. uint32_t len);
  303. /**
  304. * qdf_register_get_bus_reg_dump() - Register callback to update bus register
  305. * dump
  306. * @qdf_bus_reg_dump: callback to update bus register dump
  307. *
  308. * Return: none
  309. */
  310. void qdf_register_get_bus_reg_dump(qdf_bus_reg_dump callback);
  311. /**
  312. * qdf_get_bus_reg_dump() - Get the register dump for the bus
  313. * @dev: device
  314. * @buffer: buffer for hang data
  315. * @len: len of hang data
  316. *
  317. * Return: none
  318. */
  319. void qdf_get_bus_reg_dump(struct device *dev, uint8_t *buf, uint32_t len);
  320. #endif /*_QDF_PLATFORM_H*/