mci.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 MCI_GPM_SET_CHANNEL_BIT(_p_gpm, _bt_chan) \
  34. do { \
  35. if (_bt_chan < ATH_MCI_NUM_BT_CHANNELS) { \
  36. *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_CHANNEL_MAP + \
  37. (_bt_chan / 8)) |= (1 << (_bt_chan & 7)); \
  38. } \
  39. } while (0)
  40. #define MCI_GPM_CLR_CHANNEL_BIT(_p_gpm, _bt_chan) \
  41. do { \
  42. if (_bt_chan < ATH_MCI_NUM_BT_CHANNELS) { \
  43. *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_CHANNEL_MAP + \
  44. (_bt_chan / 8)) &= ~(1 << (_bt_chan & 7));\
  45. } \
  46. } while (0)
  47. #define INC_PROF(_mci, _info) do { \
  48. switch (_info->type) { \
  49. case MCI_GPM_COEX_PROFILE_RFCOMM:\
  50. _mci->num_other_acl++; \
  51. break; \
  52. case MCI_GPM_COEX_PROFILE_A2DP: \
  53. _mci->num_a2dp++; \
  54. if (!_info->edr) \
  55. _mci->num_bdr++; \
  56. break; \
  57. case MCI_GPM_COEX_PROFILE_HID: \
  58. _mci->num_hid++; \
  59. break; \
  60. case MCI_GPM_COEX_PROFILE_BNEP: \
  61. _mci->num_pan++; \
  62. break; \
  63. case MCI_GPM_COEX_PROFILE_VOICE: \
  64. _mci->num_sco++; \
  65. break; \
  66. default: \
  67. break; \
  68. } \
  69. } while (0)
  70. #define DEC_PROF(_mci, _info) do { \
  71. switch (_info->type) { \
  72. case MCI_GPM_COEX_PROFILE_RFCOMM:\
  73. _mci->num_other_acl--; \
  74. break; \
  75. case MCI_GPM_COEX_PROFILE_A2DP: \
  76. _mci->num_a2dp--; \
  77. if (!_info->edr) \
  78. _mci->num_bdr--; \
  79. break; \
  80. case MCI_GPM_COEX_PROFILE_HID: \
  81. _mci->num_hid--; \
  82. break; \
  83. case MCI_GPM_COEX_PROFILE_BNEP: \
  84. _mci->num_pan--; \
  85. break; \
  86. case MCI_GPM_COEX_PROFILE_VOICE: \
  87. _mci->num_sco--; \
  88. break; \
  89. default: \
  90. break; \
  91. } \
  92. } while (0)
  93. #define NUM_PROF(_mci) (_mci->num_other_acl + _mci->num_a2dp + \
  94. _mci->num_hid + _mci->num_pan + _mci->num_sco)
  95. struct ath_mci_profile_info {
  96. u8 type;
  97. u8 conn_handle;
  98. bool start;
  99. bool master;
  100. bool edr;
  101. u8 voice_type;
  102. u16 T; /* Voice: Tvoice, HID: Tsniff, in slots */
  103. u8 W; /* Voice: Wvoice, HID: Sniff timeout, in slots */
  104. u8 A; /* HID: Sniff attempt, in slots */
  105. struct list_head list;
  106. };
  107. struct ath_mci_profile_status {
  108. bool is_critical;
  109. bool is_link;
  110. u8 conn_handle;
  111. };
  112. struct ath_mci_profile {
  113. struct list_head info;
  114. DECLARE_BITMAP(status, ATH_MCI_MAX_PROFILE);
  115. u16 aggr_limit;
  116. u8 num_mgmt;
  117. u8 num_sco;
  118. u8 num_a2dp;
  119. u8 num_hid;
  120. u8 num_pan;
  121. u8 num_other_acl;
  122. u8 num_bdr;
  123. u8 voice_priority;
  124. };
  125. struct ath_mci_buf {
  126. void *bf_addr; /* virtual addr of desc */
  127. dma_addr_t bf_paddr; /* physical addr of buffer */
  128. u32 bf_len; /* len of data */
  129. };
  130. struct ath_mci_coex {
  131. struct ath_mci_buf sched_buf;
  132. struct ath_mci_buf gpm_buf;
  133. };
  134. void ath_mci_flush_profile(struct ath_mci_profile *mci);
  135. int ath_mci_setup(struct ath_softc *sc);
  136. void ath_mci_cleanup(struct ath_softc *sc);
  137. void ath_mci_intr(struct ath_softc *sc);
  138. #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
  139. void ath_mci_enable(struct ath_softc *sc);
  140. void ath9k_mci_update_wlan_channels(struct ath_softc *sc, bool allow_all);
  141. #else
  142. static inline void ath_mci_enable(struct ath_softc *sc)
  143. {
  144. }
  145. static inline void ath9k_mci_update_wlan_channels(struct ath_softc *sc,
  146. bool allow_all)
  147. {
  148. }
  149. #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
  150. #endif /* MCI_H*/