ar9003_mci.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  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 AR9003_MCI_H
  17. #define AR9003_MCI_H
  18. #define MCI_FLAG_DISABLE_TIMESTAMP 0x00000001 /* Disable time stamp */
  19. /* Default remote BT device MCI COEX version */
  20. #define MCI_GPM_COEX_MAJOR_VERSION_DEFAULT 3
  21. #define MCI_GPM_COEX_MINOR_VERSION_DEFAULT 0
  22. /* Local WLAN MCI COEX version */
  23. #define MCI_GPM_COEX_MAJOR_VERSION_WLAN 3
  24. #define MCI_GPM_COEX_MINOR_VERSION_WLAN 0
  25. enum mci_gpm_coex_query_type {
  26. MCI_GPM_COEX_QUERY_BT_ALL_INFO = BIT(0),
  27. MCI_GPM_COEX_QUERY_BT_TOPOLOGY = BIT(1),
  28. MCI_GPM_COEX_QUERY_BT_DEBUG = BIT(2),
  29. };
  30. enum mci_gpm_coex_halt_bt_gpm {
  31. MCI_GPM_COEX_BT_GPM_UNHALT,
  32. MCI_GPM_COEX_BT_GPM_HALT
  33. };
  34. enum mci_gpm_coex_bt_update_flags_op {
  35. MCI_GPM_COEX_BT_FLAGS_READ,
  36. MCI_GPM_COEX_BT_FLAGS_SET,
  37. MCI_GPM_COEX_BT_FLAGS_CLEAR
  38. };
  39. #define MCI_NUM_BT_CHANNELS 79
  40. #define MCI_BT_MCI_FLAGS_UPDATE_CORR 0x00000002
  41. #define MCI_BT_MCI_FLAGS_UPDATE_HDR 0x00000004
  42. #define MCI_BT_MCI_FLAGS_UPDATE_PLD 0x00000008
  43. #define MCI_BT_MCI_FLAGS_LNA_CTRL 0x00000010
  44. #define MCI_BT_MCI_FLAGS_DEBUG 0x00000020
  45. #define MCI_BT_MCI_FLAGS_SCHED_MSG 0x00000040
  46. #define MCI_BT_MCI_FLAGS_CONT_MSG 0x00000080
  47. #define MCI_BT_MCI_FLAGS_COEX_GPM 0x00000100
  48. #define MCI_BT_MCI_FLAGS_CPU_INT_MSG 0x00000200
  49. #define MCI_BT_MCI_FLAGS_MCI_MODE 0x00000400
  50. #define MCI_BT_MCI_FLAGS_AR9462_MODE 0x00001000
  51. #define MCI_BT_MCI_FLAGS_OTHER 0x00010000
  52. #define MCI_DEFAULT_BT_MCI_FLAGS 0x00011dde
  53. #define MCI_TOGGLE_BT_MCI_FLAGS (MCI_BT_MCI_FLAGS_UPDATE_CORR | \
  54. MCI_BT_MCI_FLAGS_UPDATE_HDR | \
  55. MCI_BT_MCI_FLAGS_UPDATE_PLD | \
  56. MCI_BT_MCI_FLAGS_MCI_MODE)
  57. #define MCI_2G_FLAGS_CLEAR_MASK 0x00000000
  58. #define MCI_2G_FLAGS_SET_MASK MCI_TOGGLE_BT_MCI_FLAGS
  59. #define MCI_2G_FLAGS MCI_DEFAULT_BT_MCI_FLAGS
  60. #define MCI_5G_FLAGS_CLEAR_MASK MCI_TOGGLE_BT_MCI_FLAGS
  61. #define MCI_5G_FLAGS_SET_MASK 0x00000000
  62. #define MCI_5G_FLAGS (MCI_DEFAULT_BT_MCI_FLAGS & \
  63. ~MCI_TOGGLE_BT_MCI_FLAGS)
  64. /*
  65. * Default value for AR9462 is 0x00002201
  66. */
  67. #define ATH_MCI_CONFIG_CONCUR_TX 0x00000003
  68. #define ATH_MCI_CONFIG_MCI_OBS_MCI 0x00000004
  69. #define ATH_MCI_CONFIG_MCI_OBS_TXRX 0x00000008
  70. #define ATH_MCI_CONFIG_MCI_OBS_BT 0x00000010
  71. #define ATH_MCI_CONFIG_DISABLE_MCI_CAL 0x00000020
  72. #define ATH_MCI_CONFIG_DISABLE_OSLA 0x00000040
  73. #define ATH_MCI_CONFIG_DISABLE_FTP_STOMP 0x00000080
  74. #define ATH_MCI_CONFIG_AGGR_THRESH 0x00000700
  75. #define ATH_MCI_CONFIG_AGGR_THRESH_S 8
  76. #define ATH_MCI_CONFIG_DISABLE_AGGR_THRESH 0x00000800
  77. #define ATH_MCI_CONFIG_CLK_DIV 0x00003000
  78. #define ATH_MCI_CONFIG_CLK_DIV_S 12
  79. #define ATH_MCI_CONFIG_DISABLE_TUNING 0x00004000
  80. #define ATH_MCI_CONFIG_MCI_WEIGHT_DBG 0x40000000
  81. #define ATH_MCI_CONFIG_DISABLE_MCI 0x80000000
  82. #define ATH_MCI_CONFIG_MCI_OBS_MASK (ATH_MCI_CONFIG_MCI_OBS_MCI | \
  83. ATH_MCI_CONFIG_MCI_OBS_TXRX | \
  84. ATH_MCI_CONFIG_MCI_OBS_BT)
  85. #define ATH_MCI_CONFIG_MCI_OBS_GPIO 0x0000002F
  86. enum mci_message_header { /* length of payload */
  87. MCI_LNA_CTRL = 0x10, /* len = 0 */
  88. MCI_CONT_NACK = 0x20, /* len = 0 */
  89. MCI_CONT_INFO = 0x30, /* len = 4 */
  90. MCI_CONT_RST = 0x40, /* len = 0 */
  91. MCI_SCHD_INFO = 0x50, /* len = 16 */
  92. MCI_CPU_INT = 0x60, /* len = 4 */
  93. MCI_SYS_WAKING = 0x70, /* len = 0 */
  94. MCI_GPM = 0x80, /* len = 16 */
  95. MCI_LNA_INFO = 0x90, /* len = 1 */
  96. MCI_LNA_STATE = 0x94,
  97. MCI_LNA_TAKE = 0x98,
  98. MCI_LNA_TRANS = 0x9c,
  99. MCI_SYS_SLEEPING = 0xa0, /* len = 0 */
  100. MCI_REQ_WAKE = 0xc0, /* len = 0 */
  101. MCI_DEBUG_16 = 0xfe, /* len = 2 */
  102. MCI_REMOTE_RESET = 0xff /* len = 16 */
  103. };
  104. enum ath_mci_gpm_coex_profile_type {
  105. MCI_GPM_COEX_PROFILE_UNKNOWN,
  106. MCI_GPM_COEX_PROFILE_RFCOMM,
  107. MCI_GPM_COEX_PROFILE_A2DP,
  108. MCI_GPM_COEX_PROFILE_HID,
  109. MCI_GPM_COEX_PROFILE_BNEP,
  110. MCI_GPM_COEX_PROFILE_VOICE,
  111. MCI_GPM_COEX_PROFILE_MAX
  112. };
  113. /* MCI GPM/Coex opcode/type definitions */
  114. enum {
  115. MCI_GPM_COEX_W_GPM_PAYLOAD = 1,
  116. MCI_GPM_COEX_B_GPM_TYPE = 4,
  117. MCI_GPM_COEX_B_GPM_OPCODE = 5,
  118. /* MCI_GPM_WLAN_CAL_REQ, MCI_GPM_WLAN_CAL_DONE */
  119. MCI_GPM_WLAN_CAL_W_SEQUENCE = 2,
  120. /* MCI_GPM_COEX_VERSION_QUERY */
  121. /* MCI_GPM_COEX_VERSION_RESPONSE */
  122. MCI_GPM_COEX_B_MAJOR_VERSION = 6,
  123. MCI_GPM_COEX_B_MINOR_VERSION = 7,
  124. /* MCI_GPM_COEX_STATUS_QUERY */
  125. MCI_GPM_COEX_B_BT_BITMAP = 6,
  126. MCI_GPM_COEX_B_WLAN_BITMAP = 7,
  127. /* MCI_GPM_COEX_HALT_BT_GPM */
  128. MCI_GPM_COEX_B_HALT_STATE = 6,
  129. /* MCI_GPM_COEX_WLAN_CHANNELS */
  130. MCI_GPM_COEX_B_CHANNEL_MAP = 6,
  131. /* MCI_GPM_COEX_BT_PROFILE_INFO */
  132. MCI_GPM_COEX_B_PROFILE_TYPE = 6,
  133. MCI_GPM_COEX_B_PROFILE_LINKID = 7,
  134. MCI_GPM_COEX_B_PROFILE_STATE = 8,
  135. MCI_GPM_COEX_B_PROFILE_ROLE = 9,
  136. MCI_GPM_COEX_B_PROFILE_RATE = 10,
  137. MCI_GPM_COEX_B_PROFILE_VOTYPE = 11,
  138. MCI_GPM_COEX_H_PROFILE_T = 12,
  139. MCI_GPM_COEX_B_PROFILE_W = 14,
  140. MCI_GPM_COEX_B_PROFILE_A = 15,
  141. /* MCI_GPM_COEX_BT_STATUS_UPDATE */
  142. MCI_GPM_COEX_B_STATUS_TYPE = 6,
  143. MCI_GPM_COEX_B_STATUS_LINKID = 7,
  144. MCI_GPM_COEX_B_STATUS_STATE = 8,
  145. /* MCI_GPM_COEX_BT_UPDATE_FLAGS */
  146. MCI_GPM_COEX_W_BT_FLAGS = 6,
  147. MCI_GPM_COEX_B_BT_FLAGS_OP = 10
  148. };
  149. enum mci_gpm_subtype {
  150. MCI_GPM_BT_CAL_REQ = 0,
  151. MCI_GPM_BT_CAL_GRANT = 1,
  152. MCI_GPM_BT_CAL_DONE = 2,
  153. MCI_GPM_WLAN_CAL_REQ = 3,
  154. MCI_GPM_WLAN_CAL_GRANT = 4,
  155. MCI_GPM_WLAN_CAL_DONE = 5,
  156. MCI_GPM_COEX_AGENT = 0x0c,
  157. MCI_GPM_RSVD_PATTERN = 0xfe,
  158. MCI_GPM_RSVD_PATTERN32 = 0xfefefefe,
  159. MCI_GPM_BT_DEBUG = 0xff
  160. };
  161. enum mci_bt_state {
  162. MCI_BT_SLEEP,
  163. MCI_BT_AWAKE,
  164. MCI_BT_CAL_START,
  165. MCI_BT_CAL
  166. };
  167. /* Type of state query */
  168. enum mci_state_type {
  169. MCI_STATE_ENABLE,
  170. MCI_STATE_INIT_GPM_OFFSET,
  171. MCI_STATE_NEXT_GPM_OFFSET,
  172. MCI_STATE_LAST_GPM_OFFSET,
  173. MCI_STATE_BT,
  174. MCI_STATE_SET_BT_SLEEP,
  175. MCI_STATE_SET_BT_AWAKE,
  176. MCI_STATE_SET_BT_CAL_START,
  177. MCI_STATE_SET_BT_CAL,
  178. MCI_STATE_LAST_SCHD_MSG_OFFSET,
  179. MCI_STATE_REMOTE_SLEEP,
  180. MCI_STATE_CONT_RSSI_POWER,
  181. MCI_STATE_CONT_PRIORITY,
  182. MCI_STATE_CONT_TXRX,
  183. MCI_STATE_RESET_REQ_WAKE,
  184. MCI_STATE_SEND_WLAN_COEX_VERSION,
  185. MCI_STATE_SET_BT_COEX_VERSION,
  186. MCI_STATE_SEND_WLAN_CHANNELS,
  187. MCI_STATE_SEND_VERSION_QUERY,
  188. MCI_STATE_SEND_STATUS_QUERY,
  189. MCI_STATE_NEED_FLUSH_BT_INFO,
  190. MCI_STATE_SET_CONCUR_TX_PRI,
  191. MCI_STATE_RECOVER_RX,
  192. MCI_STATE_NEED_FTP_STOMP,
  193. MCI_STATE_NEED_TUNING,
  194. MCI_STATE_DEBUG,
  195. MCI_STATE_MAX
  196. };
  197. enum mci_gpm_coex_opcode {
  198. MCI_GPM_COEX_VERSION_QUERY,
  199. MCI_GPM_COEX_VERSION_RESPONSE,
  200. MCI_GPM_COEX_STATUS_QUERY,
  201. MCI_GPM_COEX_HALT_BT_GPM,
  202. MCI_GPM_COEX_WLAN_CHANNELS,
  203. MCI_GPM_COEX_BT_PROFILE_INFO,
  204. MCI_GPM_COEX_BT_STATUS_UPDATE,
  205. MCI_GPM_COEX_BT_UPDATE_FLAGS
  206. };
  207. #define MCI_GPM_NOMORE 0
  208. #define MCI_GPM_MORE 1
  209. #define MCI_GPM_INVALID 0xffffffff
  210. #define MCI_GPM_RECYCLE(_p_gpm) do { \
  211. *(((u32 *)_p_gpm) + MCI_GPM_COEX_W_GPM_PAYLOAD) = \
  212. MCI_GPM_RSVD_PATTERN32; \
  213. } while (0)
  214. #define MCI_GPM_TYPE(_p_gpm) \
  215. (*(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_TYPE) & 0xff)
  216. #define MCI_GPM_OPCODE(_p_gpm) \
  217. (*(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_OPCODE) & 0xff)
  218. #define MCI_GPM_SET_CAL_TYPE(_p_gpm, _cal_type) do { \
  219. *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_TYPE) = (_cal_type) & 0xff;\
  220. } while (0)
  221. #define MCI_GPM_SET_TYPE_OPCODE(_p_gpm, _type, _opcode) do { \
  222. *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_TYPE) = (_type) & 0xff; \
  223. *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_OPCODE) = (_opcode) & 0xff;\
  224. } while (0)
  225. #define MCI_GPM_IS_CAL_TYPE(_type) ((_type) <= MCI_GPM_WLAN_CAL_DONE)
  226. /*
  227. * Functions that are available to the MCI driver core.
  228. */
  229. bool ar9003_mci_send_message(struct ath_hw *ah, u8 header, u32 flag,
  230. u32 *payload, u8 len, bool wait_done,
  231. bool check_bt);
  232. u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data);
  233. void ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf,
  234. u16 len, u32 sched_addr);
  235. void ar9003_mci_cleanup(struct ath_hw *ah);
  236. void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr,
  237. u32 *rx_msg_intr);
  238. /*
  239. * These functions are used by ath9k_hw.
  240. */
  241. #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
  242. static inline bool ar9003_mci_is_ready(struct ath_hw *ah)
  243. {
  244. return ah->btcoex_hw.mci.ready;
  245. }
  246. void ar9003_mci_stop_bt(struct ath_hw *ah, bool save_fullsleep);
  247. void ar9003_mci_init_cal_req(struct ath_hw *ah, bool *is_reusable);
  248. void ar9003_mci_init_cal_done(struct ath_hw *ah);
  249. void ar9003_mci_set_full_sleep(struct ath_hw *ah);
  250. void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool wait_done);
  251. void ar9003_mci_check_bt(struct ath_hw *ah);
  252. bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan);
  253. int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan,
  254. struct ath9k_hw_cal_data *caldata);
  255. void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g,
  256. bool is_full_sleep);
  257. void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked);
  258. #else
  259. static inline bool ar9003_mci_is_ready(struct ath_hw *ah)
  260. {
  261. return false;
  262. }
  263. static inline void ar9003_mci_stop_bt(struct ath_hw *ah, bool save_fullsleep)
  264. {
  265. }
  266. static inline void ar9003_mci_init_cal_req(struct ath_hw *ah, bool *is_reusable)
  267. {
  268. }
  269. static inline void ar9003_mci_init_cal_done(struct ath_hw *ah)
  270. {
  271. }
  272. static inline void ar9003_mci_set_full_sleep(struct ath_hw *ah)
  273. {
  274. }
  275. static inline void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool wait_done)
  276. {
  277. }
  278. static inline void ar9003_mci_check_bt(struct ath_hw *ah)
  279. {
  280. }
  281. static inline bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan)
  282. {
  283. return false;
  284. }
  285. static inline int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan,
  286. struct ath9k_hw_cal_data *caldata)
  287. {
  288. return 0;
  289. }
  290. static inline void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g,
  291. bool is_full_sleep)
  292. {
  293. }
  294. static inline void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked)
  295. {
  296. }
  297. #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */
  298. #endif