btif_pub.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. #ifndef __HAL_BTIF_PUB_H_
  2. #define __HAL_BTIF_PUB_H_
  3. #include "plat_common.h"
  4. /*Enum Defination*/
  5. /*BTIF Mode Enum */
  6. typedef enum _ENUM_BTIF_MODE_ {
  7. BTIF_MODE_PIO = 0,
  8. BTIF_MODE_DMA = BTIF_MODE_PIO + 1,
  9. BTIF_MODE_MAX,
  10. } ENUM_BTIF_MODE;
  11. /*****************************************************************************
  12. * FUNCTION
  13. * hal_btif_info_get
  14. * DESCRIPTION
  15. * get btif's information included base address , irq related information
  16. * PARAMETERS
  17. * RETURNS
  18. * BTIF's information
  19. *****************************************************************************/
  20. P_MTK_BTIF_INFO_STR hal_btif_info_get(void);
  21. #if 0 /*included in hal_btif_info_get */
  22. /*****************************************************************************
  23. * FUNCTION
  24. * hal_btif_get_irq
  25. * DESCRIPTION
  26. * get BTIF module's IRQ information
  27. * PARAMETERS
  28. * RETURNS
  29. * pointer to BTIF's irq structure
  30. *****************************************************************************/
  31. P_MTK_BTIF_IRQ_STR hal_btif_get_irq(void);
  32. #endif
  33. #if !defined(CONFIG_MTK_CLKMGR)
  34. /*****************************************************************************
  35. * FUNCTION
  36. * hal_btif_clk_get_and_prepare
  37. * DESCRIPTION
  38. * get clock from device tree and prepare for enable/disable control
  39. * PARAMETERS
  40. * pdev device pointer
  41. * RETURNS
  42. * 0 means success, negative means fail
  43. *****************************************************************************/
  44. int hal_btif_clk_get_and_prepare(struct platform_device *pdev);
  45. /*****************************************************************************
  46. * FUNCTION
  47. * hal_btif_clk_unprepare
  48. * DESCRIPTION
  49. * unprepare btif clock and apdma clock
  50. * PARAMETERS
  51. * none
  52. * RETURNS
  53. * 0 means success, negative means fail
  54. *****************************************************************************/
  55. int hal_btif_clk_unprepare(void);
  56. #endif
  57. /*****************************************************************************
  58. * FUNCTION
  59. * hal_btif_clk_ctrl
  60. * DESCRIPTION
  61. * control clock output enable/disable of BTIF module
  62. * PARAMETERS
  63. * p_base [IN] BTIF module's base address
  64. * RETURNS
  65. * 0 means success, negative means fail
  66. *****************************************************************************/
  67. int hal_btif_clk_ctrl(P_MTK_BTIF_INFO_STR p_btif, ENUM_CLOCK_CTRL flag);
  68. /*****************************************************************************
  69. * FUNCTION
  70. * hal_btif_hw_init
  71. * DESCRIPTION
  72. * BTIF module init, after this step, BTIF should enable to do tx/rx with PIO
  73. * mode
  74. * PARAMETERS
  75. * p_base [IN] BTIF module's base address
  76. * RETURNS
  77. * 0 means success, negative means fail
  78. *****************************************************************************/
  79. int hal_btif_hw_init(P_MTK_BTIF_INFO_STR p_btif);
  80. /*****************************************************************************
  81. * FUNCTION
  82. * hal_btif_rx_cb_reg
  83. * DESCRIPTION
  84. * BTIF rx callback register API
  85. * PARAMETERS
  86. * p_btif_info [IN] pointer to BTIF's information
  87. * rx_cb [IN] rx callback function
  88. * RETURNS
  89. * 0 means success, negative means fail
  90. *****************************************************************************/
  91. int hal_btif_rx_cb_reg(P_MTK_BTIF_INFO_STR p_btif_info,
  92. btif_rx_buf_write rx_cb);
  93. /*****************************************************************************
  94. * FUNCTION
  95. * hal_btif_loopback_ctrl
  96. * DESCRIPTION
  97. * BTIF Tx/Rx loopback mode set, this operation can only be done
  98. * after set BTIF to normal mode
  99. * PARAMETERS
  100. * RETURNS
  101. * 0 means success, negative means fail
  102. *****************************************************************************/
  103. int hal_btif_loopback_ctrl(P_MTK_BTIF_INFO_STR p_btif, bool en);
  104. /*****************************************************************************
  105. * FUNCTION
  106. * hal_btif_rx_handler
  107. * DESCRIPTION
  108. * lower level interrupt handler
  109. * PARAMETERS
  110. * p_base [IN] BTIF module's base address
  111. * p_buf [IN/OUT] pointer to rx data buffer
  112. * max_len [IN] max length of rx buffer
  113. * RETURNS
  114. * 0 means success; negative means fail; positive means rx data length
  115. *****************************************************************************/
  116. int hal_btif_irq_handler(P_MTK_BTIF_INFO_STR p_btif,
  117. unsigned char *p_buf, const unsigned int max_len);
  118. /*****************************************************************************
  119. * FUNCTION
  120. * hal_btif_tx_mode_ctrl
  121. * DESCRIPTION
  122. * set BTIF tx to corresponding mode (PIO/DMA)
  123. * PARAMETERS
  124. * p_base [IN] BTIF module's base address
  125. * mode [IN] rx mode <PIO/DMA>
  126. * RETURNS
  127. * 0 means success, negative means fail
  128. *****************************************************************************/
  129. int hal_btif_tx_mode_ctrl(P_MTK_BTIF_INFO_STR p_btif, ENUM_BTIF_MODE mode);
  130. /*****************************************************************************
  131. * FUNCTION
  132. * hal_btif_rx_mode_ctrl
  133. * DESCRIPTION
  134. * set BTIF rx to corresponding mode (PIO/DMA)
  135. * PARAMETERS
  136. * p_base [IN] BTIF module's base address
  137. * mode [IN] rx mode <PIO/DMA>
  138. * RETURNS
  139. * 0 means success, negative means fail
  140. *****************************************************************************/
  141. int hal_btif_rx_mode_ctrl(P_MTK_BTIF_INFO_STR p_btif, ENUM_BTIF_MODE mode);
  142. /*****************************************************************************
  143. * FUNCTION
  144. * hal_btif_send_data
  145. * DESCRIPTION
  146. * send data through btif in FIFO mode
  147. * PARAMETERS
  148. * p_base [IN] BTIF module's base address
  149. * p_buf [IN] pointer to rx data buffer
  150. * max_len [IN] tx buffer length
  151. * RETURNS
  152. * positive means number of data sent;
  153. * 0 means no data put to FIFO;
  154. * negative means error happens
  155. *****************************************************************************/
  156. int hal_btif_send_data(P_MTK_BTIF_INFO_STR p_btif,
  157. const unsigned char *p_buf, const unsigned int buf_len);
  158. /*****************************************************************************
  159. * FUNCTION
  160. * hal_btif_raise_wak_sig
  161. * DESCRIPTION
  162. * raise wakeup signal to counterpart
  163. * PARAMETERS
  164. * p_base [IN] BTIF module's base address
  165. * RETURNS
  166. * 0 means success, negative means fail
  167. *****************************************************************************/
  168. int hal_btif_raise_wak_sig(P_MTK_BTIF_INFO_STR p_btif);
  169. /*****************************************************************************
  170. * FUNCTION
  171. * hal_btif_dump_reg
  172. * DESCRIPTION
  173. * dump BTIF module's information when needed
  174. * PARAMETERS
  175. * p_base [IN] BTIF module's base address
  176. * flag [IN] register id flag
  177. * RETURNS
  178. * 0 means success, negative means fail
  179. *****************************************************************************/
  180. int hal_btif_dump_reg(P_MTK_BTIF_INFO_STR p_btif, ENUM_BTIF_REG_ID flag);
  181. /*****************************************************************************
  182. * FUNCTION
  183. * hal_btif_is_tx_complete
  184. * DESCRIPTION
  185. * get tx complete flag
  186. * PARAMETERS
  187. * p_base [IN] BTIF module's base address
  188. * RETURNS
  189. * true means tx complete, false means tx in process
  190. *****************************************************************************/
  191. bool hal_btif_is_tx_complete(P_MTK_BTIF_INFO_STR p_btif);
  192. /*****************************************************************************
  193. * FUNCTION
  194. * hal_btif_is_tx_allow
  195. * DESCRIPTION
  196. * whether tx is allowed
  197. * PARAMETERS
  198. * p_base [IN] BTIF module's base address
  199. * RETURNS
  200. * true if tx operation is allowed; false if tx is not allowed
  201. *****************************************************************************/
  202. bool hal_btif_is_tx_allow(P_MTK_BTIF_INFO_STR p_btif);
  203. int hal_btif_pm_ops(P_MTK_BTIF_INFO_STR p_btif, MTK_BTIF_PM_OPID opid);
  204. #endif /*__HAL_BTIF_PUB_H_*/