ar9003_mci.h 13 KB

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