btif_dma_pub.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. #ifndef __HAL_BTIFD_DMA_PUB_H_
  2. #define __HAL_BTIFD_DMA_PUB_H_
  3. #include <linux/dma-mapping.h>
  4. #include "plat_common.h"
  5. typedef enum _ENUM_DMA_CTRL_ {
  6. DMA_CTRL_DISABLE = 0,
  7. DMA_CTRL_ENABLE = DMA_CTRL_DISABLE + 1,
  8. DMA_CTRL_BOTH,
  9. } ENUM_DMA_CTRL;
  10. /*****************************************************************************
  11. * FUNCTION
  12. * hal_tx_dma_info_get
  13. * DESCRIPTION
  14. * get btif tx dma channel's information
  15. * PARAMETERS
  16. * dma_dir [IN] DMA's direction
  17. * RETURNS
  18. * pointer to btif dma's information structure
  19. *****************************************************************************/
  20. P_MTK_DMA_INFO_STR hal_btif_dma_info_get(ENUM_DMA_DIR dma_dir);
  21. /*****************************************************************************
  22. * FUNCTION
  23. * hal_btif_dma_hw_init
  24. * DESCRIPTION
  25. * control clock output enable/disable of DMA module
  26. * PARAMETERS
  27. * p_dma_info [IN] pointer to BTIF dma channel's information
  28. * RETURNS
  29. * 0 means success, negative means fail
  30. *****************************************************************************/
  31. int hal_btif_dma_hw_init(P_MTK_DMA_INFO_STR p_dma_info);
  32. /*****************************************************************************
  33. * FUNCTION
  34. * hal_btif_clk_ctrl
  35. * DESCRIPTION
  36. * control clock output enable/disable of DMA module
  37. * PARAMETERS
  38. * p_dma_info [IN] pointer to BTIF dma channel's information
  39. * RETURNS
  40. * 0 means success, negative means fail
  41. *****************************************************************************/
  42. int hal_btif_dma_clk_ctrl(P_MTK_DMA_INFO_STR p_dma_info, ENUM_CLOCK_CTRL flag);
  43. /*****************************************************************************
  44. * FUNCTION
  45. * hal_tx_dma_ctrl
  46. * DESCRIPTION
  47. * enable/disable Tx DMA channel
  48. * PARAMETERS
  49. * p_dma_info [IN] pointer to BTIF dma channel's information
  50. * ctrl_id [IN] enable/disable ID
  51. * dma_dir [IN] DMA's direction
  52. * RETURNS
  53. * 0 means success; negative means fail
  54. *****************************************************************************/
  55. int hal_btif_dma_ctrl(P_MTK_DMA_INFO_STR p_dma_info, ENUM_DMA_CTRL ctrl_id);
  56. /*****************************************************************************
  57. * FUNCTION
  58. * hal_btif_dma_rx_cb_reg
  59. * DESCRIPTION
  60. * register rx callback function to dma module
  61. * PARAMETERS
  62. * p_dma_info [IN] pointer to BTIF dma channel's information
  63. * rx_cb [IN] function pointer to btif
  64. * RETURNS
  65. * 0 means success; negative means fail
  66. *****************************************************************************/
  67. int hal_btif_dma_rx_cb_reg(P_MTK_DMA_INFO_STR p_dma_info,
  68. dma_rx_buf_write rx_cb);
  69. /*****************************************************************************
  70. * FUNCTION
  71. * hal_tx_vfifo_reset
  72. * DESCRIPTION
  73. * reset tx virtual fifo information, except memory information
  74. * PARAMETERS
  75. * p_dma_info [IN] pointer to BTIF dma channel's information
  76. * dma_dir [IN] DMA's direction
  77. * RETURNS
  78. * 0 means success, negative means fail
  79. *****************************************************************************/
  80. int hal_btif_vfifo_reset(P_MTK_DMA_INFO_STR p_dma_info);
  81. /*****************************************************************************
  82. * FUNCTION
  83. * hal_tx_dma_irq_handler
  84. * DESCRIPTION
  85. * lower level tx interrupt handler
  86. * PARAMETERS
  87. * p_dma_info [IN] pointer to BTIF dma channel's information
  88. * RETURNS
  89. * 0 means success, negative means fail
  90. *****************************************************************************/
  91. int hal_tx_dma_irq_handler(P_MTK_DMA_INFO_STR p_dma_info);
  92. /*****************************************************************************
  93. * FUNCTION
  94. * hal_dma_send_data
  95. * DESCRIPTION
  96. * send data through btif in DMA mode
  97. * PARAMETERS
  98. * p_dma_info [IN] pointer to BTIF dma channel's information
  99. * p_buf [IN] pointer to rx data buffer
  100. * max_len [IN] tx buffer length
  101. * RETURNS
  102. * 0 means success, negative means fail
  103. *****************************************************************************/
  104. int hal_dma_send_data(P_MTK_DMA_INFO_STR p_dma_info,
  105. const unsigned char *p_buf, const unsigned int buf_len);
  106. /*****************************************************************************
  107. * FUNCTION
  108. * hal_dma_is_tx_complete
  109. * DESCRIPTION
  110. * get tx complete flag
  111. * PARAMETERS
  112. * p_dma_info [IN] pointer to BTIF dma channel's information
  113. * RETURNS
  114. * true means tx complete, false means tx in process
  115. *****************************************************************************/
  116. bool hal_dma_is_tx_complete(P_MTK_DMA_INFO_STR p_dma_info);
  117. /*****************************************************************************
  118. * FUNCTION
  119. * hal_dma_get_ava_room
  120. * DESCRIPTION
  121. * get tx available room
  122. * PARAMETERS
  123. * p_dma_info [IN] pointer to BTIF dma channel's information
  124. * RETURNS
  125. * available room size
  126. *****************************************************************************/
  127. int hal_dma_get_ava_room(P_MTK_DMA_INFO_STR p_dma_info);
  128. /*****************************************************************************
  129. * FUNCTION
  130. * hal_dma_is_tx_allow
  131. * DESCRIPTION
  132. * is tx operation allowed by DMA
  133. * PARAMETERS
  134. * p_dma_info [IN] pointer to BTIF dma channel's information
  135. * RETURNS
  136. * true if tx operation is allowed; false if tx is not allowed
  137. *****************************************************************************/
  138. bool hal_dma_is_tx_allow(P_MTK_DMA_INFO_STR p_dma_info);
  139. /*****************************************************************************
  140. * FUNCTION
  141. * hal_rx_dma_irq_handler
  142. * DESCRIPTION
  143. * lower level rx interrupt handler
  144. * PARAMETERS
  145. * p_dma_info [IN] pointer to BTIF dma channel's information
  146. * p_buf [IN/OUT] pointer to rx data buffer
  147. * max_len [IN] max length of rx buffer
  148. * RETURNS
  149. * 0 means success, negative means fail
  150. *****************************************************************************/
  151. int hal_rx_dma_irq_handler(P_MTK_DMA_INFO_STR p_dma_info,
  152. unsigned char *p_buf, const unsigned int max_len);
  153. /*****************************************************************************
  154. * FUNCTION
  155. * hal_dma_dump_reg
  156. * DESCRIPTION
  157. * dump BTIF module's information when needed
  158. * PARAMETERS
  159. * p_dma_info [IN] pointer to BTIF dma channel's information
  160. * flag [IN] register id flag
  161. * RETURNS
  162. * 0 means success, negative means fail
  163. *****************************************************************************/
  164. int hal_dma_dump_reg(P_MTK_DMA_INFO_STR p_dma_info, ENUM_BTIF_REG_ID flag);
  165. int hal_dma_pm_ops(P_MTK_DMA_INFO_STR p_dma_info, MTK_BTIF_PM_OPID opid);
  166. #endif /*__HAL_BTIFD_DMA_PUB_H_*/