mci.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * Copyright (c) 2010-2011 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #ifndef MCI_H
  17. #define MCI_H
  18. #include "ar9003_mci.h"
  19. #define ATH_MCI_SCHED_BUF_SIZE (16 * 16) /* 16 entries, 4 dword each */
  20. #define ATH_MCI_GPM_MAX_ENTRY 16
  21. #define ATH_MCI_GPM_BUF_SIZE (ATH_MCI_GPM_MAX_ENTRY * 16)
  22. #define ATH_MCI_DEF_BT_PERIOD 40
  23. #define ATH_MCI_BDR_DUTY_CYCLE 20
  24. #define ATH_MCI_MAX_DUTY_CYCLE 90
  25. #define ATH_MCI_DEF_AGGR_LIMIT 6 /* in 0.24 ms */
  26. #define ATH_MCI_MAX_ACL_PROFILE 7
  27. #define ATH_MCI_MAX_SCO_PROFILE 1
  28. #define ATH_MCI_MAX_PROFILE (ATH_MCI_MAX_ACL_PROFILE +\
  29. ATH_MCI_MAX_SCO_PROFILE)
  30. #define ATH_MCI_INQUIRY_PRIO 62
  31. #define ATH_MCI_HI_PRIO 60
  32. #define ATH_MCI_NUM_BT_CHANNELS 79
  33. #define ATH_MCI_CONCUR_TX_SWITCH 5
  34. #define MCI_GPM_SET_CHANNEL_BIT(_p_gpm, _bt_chan) \
  35. do { \
  36. if (_bt_chan < ATH_MCI_NUM_BT_CHANNELS) { \
  37. *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_CHANNEL_MAP + \
  38. (_bt_chan / 8)) |= (1 << (_bt_chan & 7)); \
  39. } \
  40. } while (0)
  41. #define MCI_GPM_CLR_CHANNEL_BIT(_p_gpm, _bt_chan) \
  42. do { \
  43. if (_bt_chan < ATH_MCI_NUM_BT_CHANNELS) { \
  44. *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_CHANNEL_MAP + \
  45. (_bt_chan / 8)) &= ~(1 << (_bt_chan & 7));\
  46. } \
  47. } while (0)
  48. #define INC_PROF(_mci, _info) do { \
  49. switch (_info->type) { \
  50. case MCI_GPM_COEX_PROFILE_RFCOMM:\
  51. _mci->num_other_acl++; \
  52. break; \
  53. case MCI_GPM_COEX_PROFILE_A2DP: \
  54. _mci->num_a2dp++; \
  55. if (!_info->edr) \
  56. _mci->num_bdr++; \
  57. break; \
  58. case MCI_GPM_COEX_PROFILE_HID: \
  59. _mci->num_hid++; \
  60. break; \
  61. case MCI_GPM_COEX_PROFILE_BNEP: \
  62. _mci->num_pan++; \
  63. break; \
  64. case MCI_GPM_COEX_PROFILE_VOICE: \
  65. case MCI_GPM_COEX_PROFILE_A2DPVO:\
  66. _mci->num_sco++; \
  67. break; \
  68. default: \
  69. break; \
  70. } \
  71. } while (0)
  72. #define DEC_PROF(_mci, _info) do { \
  73. switch (_info->type) { \
  74. case MCI_GPM_COEX_PROFILE_RFCOMM:\
  75. _mci->num_other_acl--; \
  76. break; \
  77. case MCI_GPM_COEX_PROFILE_A2DP: \
  78. _mci->num_a2dp--; \
  79. if (!_info->edr) \
  80. _mci->num_bdr--; \
  81. break; \
  82. case MCI_GPM_COEX_PROFILE_HID: \
  83. _mci->num_hid--; \
  84. break; \
  85. case MCI_GPM_COEX_PROFILE_BNEP: \
  86. _mci->num_pan--; \
  87. break; \
  88. case MCI_GPM_COEX_PROFILE_VOICE: \
  89. case MCI_GPM_COEX_PROFILE_A2DPVO:\
  90. _mci->num_sco--; \
  91. break; \
  92. default: \
  93. break; \
  94. } \
  95. } while (0)
  96. #define NUM_PROF(_mci) (_mci->num_other_acl + _mci->num_a2dp + \
  97. _mci->num_hid + _mci->num_pan + _mci->num_sco)
  98. struct ath_mci_profile_info {
  99. u8 type;
  100. u8 conn_handle;
  101. bool start;
  102. bool master;
  103. bool edr;
  104. u8 voice_type;
  105. u16 T; /* Voice: Tvoice, HID: Tsniff, in slots */
  106. u8 W; /* Voice: Wvoice, HID: Sniff timeout, in slots */
  107. u8 A; /* HID: Sniff attempt, in slots */
  108. struct list_head list;
  109. };
  110. struct ath_mci_profile_status {
  111. bool is_critical;
  112. bool is_link;
  113. u8 conn_handle;
  114. };
  115. struct ath_mci_profile {
  116. struct list_head info;
  117. DECLARE_BITMAP(status, ATH_MCI_MAX_PROFILE);
  118. u16 aggr_limit;
  119. u8 num_mgmt;
  120. u8 num_sco;
  121. u8 num_a2dp;
  122. u8 num_hid;
  123. u8 num_pan;
  124. u8 num_other_acl;
  125. u8 num_bdr;
  126. u8 voice_priority;
  127. };
  128. struct ath_mci_buf {
  129. void *bf_addr; /* virtual addr of desc */
  130. dma_addr_t bf_paddr; /* physical addr of buffer */
  131. u32 bf_len; /* len of data */
  132. };
  133. struct ath_mci_coex {
  134. struct ath_mci_buf sched_buf;
  135. struct ath_mci_buf gpm_buf;
  136. };
  137. void ath_mci_flush_profile(struct ath_mci_profile *mci);
  138. int ath_mci_setup(struct ath_softc *sc);
  139. void ath_mci_cleanup(struct ath_softc *sc);
  140. void ath_mci_intr(struct ath_softc *sc);
  141. void ath9k_mci_update_rssi(struct ath_softc *sc);
  142. #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
  143. void ath_mci_enable(struct ath_softc *sc);
  144. void ath9k_mci_update_wlan_channels(struct ath_softc *sc, bool allow_all);
  145. void ath9k_mci_set_txpower(struct ath_softc *sc, bool setchannel,
  146. bool concur_tx);
  147. #else
  148. static inline void ath_mci_enable(struct ath_softc *sc)
  149. {
  150. }
  151. static inline void ath9k_mci_update_wlan_channels(struct ath_softc *sc,
  152. bool allow_all)
  153. {
  154. }
  155. static inline void ath9k_mci_set_txpower(struct ath_softc *sc, bool setchannel,
  156. bool concur_tx)
  157. {
  158. }
  159. #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
  160. #endif /* MCI_H*/