ar9003_mci.c 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486
  1. /*
  2. * Copyright (c) 2008-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. #include <linux/export.h>
  17. #include "hw.h"
  18. #include "hw-ops.h"
  19. #include "ar9003_phy.h"
  20. #include "ar9003_mci.h"
  21. static void ar9003_mci_reset_req_wakeup(struct ath_hw *ah)
  22. {
  23. REG_RMW_FIELD(ah, AR_MCI_COMMAND2,
  24. AR_MCI_COMMAND2_RESET_REQ_WAKEUP, 1);
  25. udelay(1);
  26. REG_RMW_FIELD(ah, AR_MCI_COMMAND2,
  27. AR_MCI_COMMAND2_RESET_REQ_WAKEUP, 0);
  28. }
  29. static int ar9003_mci_wait_for_interrupt(struct ath_hw *ah, u32 address,
  30. u32 bit_position, int time_out)
  31. {
  32. struct ath_common *common = ath9k_hw_common(ah);
  33. while (time_out) {
  34. if (!(REG_READ(ah, address) & bit_position)) {
  35. udelay(10);
  36. time_out -= 10;
  37. if (time_out < 0)
  38. break;
  39. else
  40. continue;
  41. }
  42. REG_WRITE(ah, address, bit_position);
  43. if (address != AR_MCI_INTERRUPT_RX_MSG_RAW)
  44. break;
  45. if (bit_position & AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE)
  46. ar9003_mci_reset_req_wakeup(ah);
  47. if (bit_position & (AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING |
  48. AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING))
  49. REG_WRITE(ah, AR_MCI_INTERRUPT_RAW,
  50. AR_MCI_INTERRUPT_REMOTE_SLEEP_UPDATE);
  51. REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, AR_MCI_INTERRUPT_RX_MSG);
  52. break;
  53. }
  54. if (time_out <= 0) {
  55. ath_dbg(common, MCI,
  56. "MCI Wait for Reg 0x%08x = 0x%08x timeout\n",
  57. address, bit_position);
  58. ath_dbg(common, MCI,
  59. "MCI INT_RAW = 0x%08x, RX_MSG_RAW = 0x%08x\n",
  60. REG_READ(ah, AR_MCI_INTERRUPT_RAW),
  61. REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW));
  62. time_out = 0;
  63. }
  64. return time_out;
  65. }
  66. static void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done)
  67. {
  68. u32 payload[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffff00};
  69. ar9003_mci_send_message(ah, MCI_REMOTE_RESET, 0, payload, 16,
  70. wait_done, false);
  71. udelay(5);
  72. }
  73. static void ar9003_mci_send_lna_transfer(struct ath_hw *ah, bool wait_done)
  74. {
  75. u32 payload = 0x00000000;
  76. ar9003_mci_send_message(ah, MCI_LNA_TRANS, 0, &payload, 1,
  77. wait_done, false);
  78. }
  79. static void ar9003_mci_send_req_wake(struct ath_hw *ah, bool wait_done)
  80. {
  81. ar9003_mci_send_message(ah, MCI_REQ_WAKE, MCI_FLAG_DISABLE_TIMESTAMP,
  82. NULL, 0, wait_done, false);
  83. udelay(5);
  84. }
  85. static void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done)
  86. {
  87. ar9003_mci_send_message(ah, MCI_SYS_WAKING, MCI_FLAG_DISABLE_TIMESTAMP,
  88. NULL, 0, wait_done, false);
  89. }
  90. static void ar9003_mci_send_lna_take(struct ath_hw *ah, bool wait_done)
  91. {
  92. u32 payload = 0x70000000;
  93. ar9003_mci_send_message(ah, MCI_LNA_TAKE, 0, &payload, 1,
  94. wait_done, false);
  95. }
  96. static void ar9003_mci_send_sys_sleeping(struct ath_hw *ah, bool wait_done)
  97. {
  98. ar9003_mci_send_message(ah, MCI_SYS_SLEEPING,
  99. MCI_FLAG_DISABLE_TIMESTAMP,
  100. NULL, 0, wait_done, false);
  101. }
  102. static void ar9003_mci_send_coex_version_query(struct ath_hw *ah,
  103. bool wait_done)
  104. {
  105. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  106. u32 payload[4] = {0, 0, 0, 0};
  107. if (mci->bt_version_known ||
  108. (mci->bt_state == MCI_BT_SLEEP))
  109. return;
  110. MCI_GPM_SET_TYPE_OPCODE(payload, MCI_GPM_COEX_AGENT,
  111. MCI_GPM_COEX_VERSION_QUERY);
  112. ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, wait_done, true);
  113. }
  114. static void ar9003_mci_send_coex_version_response(struct ath_hw *ah,
  115. bool wait_done)
  116. {
  117. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  118. u32 payload[4] = {0, 0, 0, 0};
  119. MCI_GPM_SET_TYPE_OPCODE(payload, MCI_GPM_COEX_AGENT,
  120. MCI_GPM_COEX_VERSION_RESPONSE);
  121. *(((u8 *)payload) + MCI_GPM_COEX_B_MAJOR_VERSION) =
  122. mci->wlan_ver_major;
  123. *(((u8 *)payload) + MCI_GPM_COEX_B_MINOR_VERSION) =
  124. mci->wlan_ver_minor;
  125. ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, wait_done, true);
  126. }
  127. static void ar9003_mci_send_coex_wlan_channels(struct ath_hw *ah,
  128. bool wait_done)
  129. {
  130. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  131. u32 *payload = &mci->wlan_channels[0];
  132. if (!mci->wlan_channels_update ||
  133. (mci->bt_state == MCI_BT_SLEEP))
  134. return;
  135. MCI_GPM_SET_TYPE_OPCODE(payload, MCI_GPM_COEX_AGENT,
  136. MCI_GPM_COEX_WLAN_CHANNELS);
  137. ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, wait_done, true);
  138. MCI_GPM_SET_TYPE_OPCODE(payload, 0xff, 0xff);
  139. }
  140. static void ar9003_mci_send_coex_bt_status_query(struct ath_hw *ah,
  141. bool wait_done, u8 query_type)
  142. {
  143. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  144. u32 payload[4] = {0, 0, 0, 0};
  145. bool query_btinfo;
  146. if (mci->bt_state == MCI_BT_SLEEP)
  147. return;
  148. query_btinfo = !!(query_type & (MCI_GPM_COEX_QUERY_BT_ALL_INFO |
  149. MCI_GPM_COEX_QUERY_BT_TOPOLOGY));
  150. MCI_GPM_SET_TYPE_OPCODE(payload, MCI_GPM_COEX_AGENT,
  151. MCI_GPM_COEX_STATUS_QUERY);
  152. *(((u8 *)payload) + MCI_GPM_COEX_B_BT_BITMAP) = query_type;
  153. /*
  154. * If bt_status_query message is not sent successfully,
  155. * then need_flush_btinfo should be set again.
  156. */
  157. if (!ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16,
  158. wait_done, true)) {
  159. if (query_btinfo)
  160. mci->need_flush_btinfo = true;
  161. }
  162. if (query_btinfo)
  163. mci->query_bt = false;
  164. }
  165. static void ar9003_mci_send_coex_halt_bt_gpm(struct ath_hw *ah, bool halt,
  166. bool wait_done)
  167. {
  168. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  169. u32 payload[4] = {0, 0, 0, 0};
  170. MCI_GPM_SET_TYPE_OPCODE(payload, MCI_GPM_COEX_AGENT,
  171. MCI_GPM_COEX_HALT_BT_GPM);
  172. if (halt) {
  173. mci->query_bt = true;
  174. /* Send next unhalt no matter halt sent or not */
  175. mci->unhalt_bt_gpm = true;
  176. mci->need_flush_btinfo = true;
  177. *(((u8 *)payload) + MCI_GPM_COEX_B_HALT_STATE) =
  178. MCI_GPM_COEX_BT_GPM_HALT;
  179. } else
  180. *(((u8 *)payload) + MCI_GPM_COEX_B_HALT_STATE) =
  181. MCI_GPM_COEX_BT_GPM_UNHALT;
  182. ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16, wait_done, true);
  183. }
  184. static void ar9003_mci_prep_interface(struct ath_hw *ah)
  185. {
  186. struct ath_common *common = ath9k_hw_common(ah);
  187. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  188. u32 saved_mci_int_en;
  189. u32 mci_timeout = 150;
  190. mci->bt_state = MCI_BT_SLEEP;
  191. saved_mci_int_en = REG_READ(ah, AR_MCI_INTERRUPT_EN);
  192. REG_WRITE(ah, AR_MCI_INTERRUPT_EN, 0);
  193. REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW,
  194. REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW));
  195. REG_WRITE(ah, AR_MCI_INTERRUPT_RAW,
  196. REG_READ(ah, AR_MCI_INTERRUPT_RAW));
  197. ar9003_mci_remote_reset(ah, true);
  198. ar9003_mci_send_req_wake(ah, true);
  199. if (!ar9003_mci_wait_for_interrupt(ah, AR_MCI_INTERRUPT_RX_MSG_RAW,
  200. AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING, 500))
  201. goto clear_redunt;
  202. mci->bt_state = MCI_BT_AWAKE;
  203. /*
  204. * we don't need to send more remote_reset at this moment.
  205. * If BT receive first remote_reset, then BT HW will
  206. * be cleaned up and will be able to receive req_wake
  207. * and BT HW will respond sys_waking.
  208. * In this case, WLAN will receive BT's HW sys_waking.
  209. * Otherwise, if BT SW missed initial remote_reset,
  210. * that remote_reset will still clean up BT MCI RX,
  211. * and the req_wake will wake BT up,
  212. * and BT SW will respond this req_wake with a remote_reset and
  213. * sys_waking. In this case, WLAN will receive BT's SW
  214. * sys_waking. In either case, BT's RX is cleaned up. So we
  215. * don't need to reply BT's remote_reset now, if any.
  216. * Similarly, if in any case, WLAN can receive BT's sys_waking,
  217. * that means WLAN's RX is also fine.
  218. */
  219. ar9003_mci_send_sys_waking(ah, true);
  220. udelay(10);
  221. /*
  222. * Set BT priority interrupt value to be 0xff to
  223. * avoid having too many BT PRIORITY interrupts.
  224. */
  225. REG_WRITE(ah, AR_MCI_BT_PRI0, 0xFFFFFFFF);
  226. REG_WRITE(ah, AR_MCI_BT_PRI1, 0xFFFFFFFF);
  227. REG_WRITE(ah, AR_MCI_BT_PRI2, 0xFFFFFFFF);
  228. REG_WRITE(ah, AR_MCI_BT_PRI3, 0xFFFFFFFF);
  229. REG_WRITE(ah, AR_MCI_BT_PRI, 0X000000FF);
  230. /*
  231. * A contention reset will be received after send out
  232. * sys_waking. Also BT priority interrupt bits will be set.
  233. * Clear those bits before the next step.
  234. */
  235. REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW,
  236. AR_MCI_INTERRUPT_RX_MSG_CONT_RST);
  237. REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, AR_MCI_INTERRUPT_BT_PRI);
  238. if (mci->is_2g) {
  239. ar9003_mci_send_lna_transfer(ah, true);
  240. udelay(5);
  241. }
  242. if ((mci->is_2g && !mci->update_2g5g)) {
  243. if (ar9003_mci_wait_for_interrupt(ah,
  244. AR_MCI_INTERRUPT_RX_MSG_RAW,
  245. AR_MCI_INTERRUPT_RX_MSG_LNA_INFO,
  246. mci_timeout))
  247. ath_dbg(common, MCI,
  248. "MCI WLAN has control over the LNA & BT obeys it\n");
  249. else
  250. ath_dbg(common, MCI,
  251. "MCI BT didn't respond to LNA_TRANS\n");
  252. }
  253. clear_redunt:
  254. /* Clear the extra redundant SYS_WAKING from BT */
  255. if ((mci->bt_state == MCI_BT_AWAKE) &&
  256. (REG_READ_FIELD(ah, AR_MCI_INTERRUPT_RX_MSG_RAW,
  257. AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING)) &&
  258. (REG_READ_FIELD(ah, AR_MCI_INTERRUPT_RX_MSG_RAW,
  259. AR_MCI_INTERRUPT_RX_MSG_SYS_SLEEPING) == 0)) {
  260. REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW,
  261. AR_MCI_INTERRUPT_RX_MSG_SYS_WAKING);
  262. REG_WRITE(ah, AR_MCI_INTERRUPT_RAW,
  263. AR_MCI_INTERRUPT_REMOTE_SLEEP_UPDATE);
  264. }
  265. REG_WRITE(ah, AR_MCI_INTERRUPT_EN, saved_mci_int_en);
  266. }
  267. void ar9003_mci_set_full_sleep(struct ath_hw *ah)
  268. {
  269. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  270. if (ar9003_mci_state(ah, MCI_STATE_ENABLE) &&
  271. (mci->bt_state != MCI_BT_SLEEP) &&
  272. !mci->halted_bt_gpm) {
  273. ar9003_mci_send_coex_halt_bt_gpm(ah, true, true);
  274. }
  275. mci->ready = false;
  276. }
  277. static void ar9003_mci_disable_interrupt(struct ath_hw *ah)
  278. {
  279. REG_WRITE(ah, AR_MCI_INTERRUPT_EN, 0);
  280. REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN, 0);
  281. }
  282. static void ar9003_mci_enable_interrupt(struct ath_hw *ah)
  283. {
  284. REG_WRITE(ah, AR_MCI_INTERRUPT_EN, AR_MCI_INTERRUPT_DEFAULT);
  285. REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN,
  286. AR_MCI_INTERRUPT_RX_MSG_DEFAULT);
  287. }
  288. static bool ar9003_mci_check_int(struct ath_hw *ah, u32 ints)
  289. {
  290. u32 intr;
  291. intr = REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW);
  292. return ((intr & ints) == ints);
  293. }
  294. void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr,
  295. u32 *rx_msg_intr)
  296. {
  297. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  298. *raw_intr = mci->raw_intr;
  299. *rx_msg_intr = mci->rx_msg_intr;
  300. /* Clean int bits after the values are read. */
  301. mci->raw_intr = 0;
  302. mci->rx_msg_intr = 0;
  303. }
  304. EXPORT_SYMBOL(ar9003_mci_get_interrupt);
  305. void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked)
  306. {
  307. struct ath_common *common = ath9k_hw_common(ah);
  308. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  309. u32 raw_intr, rx_msg_intr;
  310. rx_msg_intr = REG_READ(ah, AR_MCI_INTERRUPT_RX_MSG_RAW);
  311. raw_intr = REG_READ(ah, AR_MCI_INTERRUPT_RAW);
  312. if ((raw_intr == 0xdeadbeef) || (rx_msg_intr == 0xdeadbeef)) {
  313. ath_dbg(common, MCI,
  314. "MCI gets 0xdeadbeef during int processing\n");
  315. } else {
  316. mci->rx_msg_intr |= rx_msg_intr;
  317. mci->raw_intr |= raw_intr;
  318. *masked |= ATH9K_INT_MCI;
  319. if (rx_msg_intr & AR_MCI_INTERRUPT_RX_MSG_CONT_INFO)
  320. mci->cont_status = REG_READ(ah, AR_MCI_CONT_STATUS);
  321. REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW, rx_msg_intr);
  322. REG_WRITE(ah, AR_MCI_INTERRUPT_RAW, raw_intr);
  323. }
  324. }
  325. static void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool is_2g)
  326. {
  327. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  328. if (!mci->update_2g5g &&
  329. (mci->is_2g != is_2g))
  330. mci->update_2g5g = true;
  331. mci->is_2g = is_2g;
  332. }
  333. static bool ar9003_mci_is_gpm_valid(struct ath_hw *ah, u32 msg_index)
  334. {
  335. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  336. u32 *payload;
  337. u32 recv_type, offset;
  338. if (msg_index == MCI_GPM_INVALID)
  339. return false;
  340. offset = msg_index << 4;
  341. payload = (u32 *)(mci->gpm_buf + offset);
  342. recv_type = MCI_GPM_TYPE(payload);
  343. if (recv_type == MCI_GPM_RSVD_PATTERN)
  344. return false;
  345. return true;
  346. }
  347. static void ar9003_mci_observation_set_up(struct ath_hw *ah)
  348. {
  349. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  350. if (mci->config & ATH_MCI_CONFIG_MCI_OBS_MCI) {
  351. ath9k_hw_cfg_output(ah, 3, AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_DATA);
  352. ath9k_hw_cfg_output(ah, 2, AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_CLK);
  353. ath9k_hw_cfg_output(ah, 1, AR_GPIO_OUTPUT_MUX_AS_MCI_BT_DATA);
  354. ath9k_hw_cfg_output(ah, 0, AR_GPIO_OUTPUT_MUX_AS_MCI_BT_CLK);
  355. } else if (mci->config & ATH_MCI_CONFIG_MCI_OBS_TXRX) {
  356. ath9k_hw_cfg_output(ah, 3, AR_GPIO_OUTPUT_MUX_AS_WL_IN_TX);
  357. ath9k_hw_cfg_output(ah, 2, AR_GPIO_OUTPUT_MUX_AS_WL_IN_RX);
  358. ath9k_hw_cfg_output(ah, 1, AR_GPIO_OUTPUT_MUX_AS_BT_IN_TX);
  359. ath9k_hw_cfg_output(ah, 0, AR_GPIO_OUTPUT_MUX_AS_BT_IN_RX);
  360. ath9k_hw_cfg_output(ah, 5, AR_GPIO_OUTPUT_MUX_AS_OUTPUT);
  361. } else if (mci->config & ATH_MCI_CONFIG_MCI_OBS_BT) {
  362. ath9k_hw_cfg_output(ah, 3, AR_GPIO_OUTPUT_MUX_AS_BT_IN_TX);
  363. ath9k_hw_cfg_output(ah, 2, AR_GPIO_OUTPUT_MUX_AS_BT_IN_RX);
  364. ath9k_hw_cfg_output(ah, 1, AR_GPIO_OUTPUT_MUX_AS_MCI_BT_DATA);
  365. ath9k_hw_cfg_output(ah, 0, AR_GPIO_OUTPUT_MUX_AS_MCI_BT_CLK);
  366. } else
  367. return;
  368. REG_SET_BIT(ah, AR_GPIO_INPUT_EN_VAL, AR_GPIO_JTAG_DISABLE);
  369. REG_RMW_FIELD(ah, AR_PHY_GLB_CONTROL, AR_GLB_DS_JTAG_DISABLE, 1);
  370. REG_RMW_FIELD(ah, AR_PHY_GLB_CONTROL, AR_GLB_WLAN_UART_INTF_EN, 0);
  371. REG_SET_BIT(ah, AR_GLB_GPIO_CONTROL, ATH_MCI_CONFIG_MCI_OBS_GPIO);
  372. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL2, AR_BTCOEX_CTRL2_GPIO_OBS_SEL, 0);
  373. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL2, AR_BTCOEX_CTRL2_MAC_BB_OBS_SEL, 1);
  374. REG_WRITE(ah, AR_OBS, 0x4b);
  375. REG_RMW_FIELD(ah, AR_DIAG_SW, AR_DIAG_OBS_PT_SEL1, 0x03);
  376. REG_RMW_FIELD(ah, AR_DIAG_SW, AR_DIAG_OBS_PT_SEL2, 0x01);
  377. REG_RMW_FIELD(ah, AR_MACMISC, AR_MACMISC_MISC_OBS_BUS_LSB, 0x02);
  378. REG_RMW_FIELD(ah, AR_MACMISC, AR_MACMISC_MISC_OBS_BUS_MSB, 0x03);
  379. REG_RMW_FIELD(ah, AR_PHY_TEST_CTL_STATUS,
  380. AR_PHY_TEST_CTL_DEBUGPORT_SEL, 0x07);
  381. }
  382. static bool ar9003_mci_send_coex_bt_flags(struct ath_hw *ah, bool wait_done,
  383. u8 opcode, u32 bt_flags)
  384. {
  385. u32 pld[4] = {0, 0, 0, 0};
  386. MCI_GPM_SET_TYPE_OPCODE(pld, MCI_GPM_COEX_AGENT,
  387. MCI_GPM_COEX_BT_UPDATE_FLAGS);
  388. *(((u8 *)pld) + MCI_GPM_COEX_B_BT_FLAGS_OP) = opcode;
  389. *(((u8 *)pld) + MCI_GPM_COEX_W_BT_FLAGS + 0) = bt_flags & 0xFF;
  390. *(((u8 *)pld) + MCI_GPM_COEX_W_BT_FLAGS + 1) = (bt_flags >> 8) & 0xFF;
  391. *(((u8 *)pld) + MCI_GPM_COEX_W_BT_FLAGS + 2) = (bt_flags >> 16) & 0xFF;
  392. *(((u8 *)pld) + MCI_GPM_COEX_W_BT_FLAGS + 3) = (bt_flags >> 24) & 0xFF;
  393. return ar9003_mci_send_message(ah, MCI_GPM, 0, pld, 16,
  394. wait_done, true);
  395. }
  396. static void ar9003_mci_sync_bt_state(struct ath_hw *ah)
  397. {
  398. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  399. u32 cur_bt_state;
  400. cur_bt_state = ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP);
  401. if (mci->bt_state != cur_bt_state)
  402. mci->bt_state = cur_bt_state;
  403. if (mci->bt_state != MCI_BT_SLEEP) {
  404. ar9003_mci_send_coex_version_query(ah, true);
  405. ar9003_mci_send_coex_wlan_channels(ah, true);
  406. if (mci->unhalt_bt_gpm == true)
  407. ar9003_mci_send_coex_halt_bt_gpm(ah, false, true);
  408. }
  409. }
  410. void ar9003_mci_check_bt(struct ath_hw *ah)
  411. {
  412. struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci;
  413. if (!mci_hw->ready)
  414. return;
  415. /*
  416. * check BT state again to make
  417. * sure it's not changed.
  418. */
  419. ar9003_mci_sync_bt_state(ah);
  420. ar9003_mci_2g5g_switch(ah, true);
  421. if ((mci_hw->bt_state == MCI_BT_AWAKE) &&
  422. (mci_hw->query_bt == true)) {
  423. mci_hw->need_flush_btinfo = true;
  424. }
  425. }
  426. static void ar9003_mci_process_gpm_extra(struct ath_hw *ah, u8 gpm_type,
  427. u8 gpm_opcode, u32 *p_gpm)
  428. {
  429. struct ath_common *common = ath9k_hw_common(ah);
  430. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  431. u8 *p_data = (u8 *) p_gpm;
  432. if (gpm_type != MCI_GPM_COEX_AGENT)
  433. return;
  434. switch (gpm_opcode) {
  435. case MCI_GPM_COEX_VERSION_QUERY:
  436. ath_dbg(common, MCI, "MCI Recv GPM COEX Version Query\n");
  437. ar9003_mci_send_coex_version_response(ah, true);
  438. break;
  439. case MCI_GPM_COEX_VERSION_RESPONSE:
  440. ath_dbg(common, MCI, "MCI Recv GPM COEX Version Response\n");
  441. mci->bt_ver_major =
  442. *(p_data + MCI_GPM_COEX_B_MAJOR_VERSION);
  443. mci->bt_ver_minor =
  444. *(p_data + MCI_GPM_COEX_B_MINOR_VERSION);
  445. mci->bt_version_known = true;
  446. ath_dbg(common, MCI, "MCI BT Coex version: %d.%d\n",
  447. mci->bt_ver_major, mci->bt_ver_minor);
  448. break;
  449. case MCI_GPM_COEX_STATUS_QUERY:
  450. ath_dbg(common, MCI,
  451. "MCI Recv GPM COEX Status Query = 0x%02X\n",
  452. *(p_data + MCI_GPM_COEX_B_WLAN_BITMAP));
  453. mci->wlan_channels_update = true;
  454. ar9003_mci_send_coex_wlan_channels(ah, true);
  455. break;
  456. case MCI_GPM_COEX_BT_PROFILE_INFO:
  457. mci->query_bt = true;
  458. ath_dbg(common, MCI, "MCI Recv GPM COEX BT_Profile_Info\n");
  459. break;
  460. case MCI_GPM_COEX_BT_STATUS_UPDATE:
  461. mci->query_bt = true;
  462. ath_dbg(common, MCI,
  463. "MCI Recv GPM COEX BT_Status_Update SEQ=%d (drop&query)\n",
  464. *(p_gpm + 3));
  465. break;
  466. default:
  467. break;
  468. }
  469. }
  470. static u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type,
  471. u8 gpm_opcode, int time_out)
  472. {
  473. struct ath_common *common = ath9k_hw_common(ah);
  474. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  475. u32 *p_gpm = NULL, mismatch = 0, more_data;
  476. u32 offset;
  477. u8 recv_type = 0, recv_opcode = 0;
  478. bool b_is_bt_cal_done = (gpm_type == MCI_GPM_BT_CAL_DONE);
  479. more_data = time_out ? MCI_GPM_NOMORE : MCI_GPM_MORE;
  480. while (time_out > 0) {
  481. if (p_gpm) {
  482. MCI_GPM_RECYCLE(p_gpm);
  483. p_gpm = NULL;
  484. }
  485. if (more_data != MCI_GPM_MORE)
  486. time_out = ar9003_mci_wait_for_interrupt(ah,
  487. AR_MCI_INTERRUPT_RX_MSG_RAW,
  488. AR_MCI_INTERRUPT_RX_MSG_GPM,
  489. time_out);
  490. if (!time_out)
  491. break;
  492. offset = ar9003_mci_get_next_gpm_offset(ah, false, &more_data);
  493. if (offset == MCI_GPM_INVALID)
  494. continue;
  495. p_gpm = (u32 *) (mci->gpm_buf + offset);
  496. recv_type = MCI_GPM_TYPE(p_gpm);
  497. recv_opcode = MCI_GPM_OPCODE(p_gpm);
  498. if (MCI_GPM_IS_CAL_TYPE(recv_type)) {
  499. if (recv_type == gpm_type) {
  500. if ((gpm_type == MCI_GPM_BT_CAL_DONE) &&
  501. !b_is_bt_cal_done) {
  502. gpm_type = MCI_GPM_BT_CAL_GRANT;
  503. continue;
  504. }
  505. break;
  506. }
  507. } else if ((recv_type == gpm_type) &&
  508. (recv_opcode == gpm_opcode))
  509. break;
  510. /*
  511. * check if it's cal_grant
  512. *
  513. * When we're waiting for cal_grant in reset routine,
  514. * it's possible that BT sends out cal_request at the
  515. * same time. Since BT's calibration doesn't happen
  516. * that often, we'll let BT completes calibration then
  517. * we continue to wait for cal_grant from BT.
  518. * Orginal: Wait BT_CAL_GRANT.
  519. * New: Receive BT_CAL_REQ -> send WLAN_CAL_GRANT->wait
  520. * BT_CAL_DONE -> Wait BT_CAL_GRANT.
  521. */
  522. if ((gpm_type == MCI_GPM_BT_CAL_GRANT) &&
  523. (recv_type == MCI_GPM_BT_CAL_REQ)) {
  524. u32 payload[4] = {0, 0, 0, 0};
  525. gpm_type = MCI_GPM_BT_CAL_DONE;
  526. MCI_GPM_SET_CAL_TYPE(payload,
  527. MCI_GPM_WLAN_CAL_GRANT);
  528. ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16,
  529. false, false);
  530. continue;
  531. } else {
  532. ath_dbg(common, MCI, "MCI GPM subtype not match 0x%x\n",
  533. *(p_gpm + 1));
  534. mismatch++;
  535. ar9003_mci_process_gpm_extra(ah, recv_type,
  536. recv_opcode, p_gpm);
  537. }
  538. }
  539. if (p_gpm) {
  540. MCI_GPM_RECYCLE(p_gpm);
  541. p_gpm = NULL;
  542. }
  543. if (time_out <= 0)
  544. time_out = 0;
  545. while (more_data == MCI_GPM_MORE) {
  546. offset = ar9003_mci_get_next_gpm_offset(ah, false, &more_data);
  547. if (offset == MCI_GPM_INVALID)
  548. break;
  549. p_gpm = (u32 *) (mci->gpm_buf + offset);
  550. recv_type = MCI_GPM_TYPE(p_gpm);
  551. recv_opcode = MCI_GPM_OPCODE(p_gpm);
  552. if (!MCI_GPM_IS_CAL_TYPE(recv_type))
  553. ar9003_mci_process_gpm_extra(ah, recv_type,
  554. recv_opcode, p_gpm);
  555. MCI_GPM_RECYCLE(p_gpm);
  556. }
  557. return time_out;
  558. }
  559. bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan)
  560. {
  561. struct ath_common *common = ath9k_hw_common(ah);
  562. struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci;
  563. u32 payload[4] = {0, 0, 0, 0};
  564. ar9003_mci_2g5g_changed(ah, IS_CHAN_2GHZ(chan));
  565. if (mci_hw->bt_state != MCI_BT_CAL_START)
  566. return false;
  567. mci_hw->bt_state = MCI_BT_CAL;
  568. /*
  569. * MCI FIX: disable mci interrupt here. This is to avoid
  570. * SW_MSG_DONE or RX_MSG bits to trigger MCI_INT and
  571. * lead to mci_intr reentry.
  572. */
  573. ar9003_mci_disable_interrupt(ah);
  574. MCI_GPM_SET_CAL_TYPE(payload, MCI_GPM_WLAN_CAL_GRANT);
  575. ar9003_mci_send_message(ah, MCI_GPM, 0, payload,
  576. 16, true, false);
  577. /* Wait BT calibration to be completed for 25ms */
  578. if (ar9003_mci_wait_for_gpm(ah, MCI_GPM_BT_CAL_DONE,
  579. 0, 25000))
  580. ath_dbg(common, MCI, "MCI BT_CAL_DONE received\n");
  581. else
  582. ath_dbg(common, MCI,
  583. "MCI BT_CAL_DONE not received\n");
  584. mci_hw->bt_state = MCI_BT_AWAKE;
  585. /* MCI FIX: enable mci interrupt here */
  586. ar9003_mci_enable_interrupt(ah);
  587. return true;
  588. }
  589. EXPORT_SYMBOL(ar9003_mci_start_reset);
  590. int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan,
  591. struct ath9k_hw_cal_data *caldata)
  592. {
  593. struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci;
  594. if (!mci_hw->ready)
  595. return 0;
  596. if (!IS_CHAN_2GHZ(chan) || (mci_hw->bt_state != MCI_BT_SLEEP))
  597. goto exit;
  598. if (!ar9003_mci_check_int(ah, AR_MCI_INTERRUPT_RX_MSG_REMOTE_RESET) &&
  599. !ar9003_mci_check_int(ah, AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE))
  600. goto exit;
  601. /*
  602. * BT is sleeping. Check if BT wakes up during
  603. * WLAN calibration. If BT wakes up during
  604. * WLAN calibration, need to go through all
  605. * message exchanges again and recal.
  606. */
  607. REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW,
  608. (AR_MCI_INTERRUPT_RX_MSG_REMOTE_RESET |
  609. AR_MCI_INTERRUPT_RX_MSG_REQ_WAKE));
  610. ar9003_mci_remote_reset(ah, true);
  611. ar9003_mci_send_sys_waking(ah, true);
  612. udelay(1);
  613. if (IS_CHAN_2GHZ(chan))
  614. ar9003_mci_send_lna_transfer(ah, true);
  615. mci_hw->bt_state = MCI_BT_AWAKE;
  616. REG_CLR_BIT(ah, AR_PHY_TIMING4,
  617. 1 << AR_PHY_TIMING_CONTROL4_DO_GAIN_DC_IQ_CAL_SHIFT);
  618. if (caldata) {
  619. caldata->done_txiqcal_once = false;
  620. caldata->done_txclcal_once = false;
  621. caldata->rtt_done = false;
  622. }
  623. if (!ath9k_hw_init_cal(ah, chan))
  624. return -EIO;
  625. REG_SET_BIT(ah, AR_PHY_TIMING4,
  626. 1 << AR_PHY_TIMING_CONTROL4_DO_GAIN_DC_IQ_CAL_SHIFT);
  627. exit:
  628. ar9003_mci_enable_interrupt(ah);
  629. return 0;
  630. }
  631. static void ar9003_mci_mute_bt(struct ath_hw *ah)
  632. {
  633. /* disable all MCI messages */
  634. REG_WRITE(ah, AR_MCI_MSG_ATTRIBUTES_TABLE, 0xffff0000);
  635. REG_SET_BIT(ah, AR_MCI_TX_CTRL, AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE);
  636. /* wait pending HW messages to flush out */
  637. udelay(10);
  638. /*
  639. * Send LNA_TAKE and SYS_SLEEPING when
  640. * 1. reset not after resuming from full sleep
  641. * 2. before reset MCI RX, to quiet BT and avoid MCI RX misalignment
  642. */
  643. ar9003_mci_send_lna_take(ah, true);
  644. udelay(5);
  645. ar9003_mci_send_sys_sleeping(ah, true);
  646. }
  647. static void ar9003_mci_osla_setup(struct ath_hw *ah, bool enable)
  648. {
  649. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  650. u32 thresh;
  651. if (!enable) {
  652. REG_CLR_BIT(ah, AR_BTCOEX_CTRL,
  653. AR_BTCOEX_CTRL_ONE_STEP_LOOK_AHEAD_EN);
  654. return;
  655. }
  656. REG_RMW_FIELD(ah, AR_MCI_SCHD_TABLE_2, AR_MCI_SCHD_TABLE_2_HW_BASED, 1);
  657. REG_RMW_FIELD(ah, AR_MCI_SCHD_TABLE_2,
  658. AR_MCI_SCHD_TABLE_2_MEM_BASED, 1);
  659. if (AR_SREV_9565(ah))
  660. REG_RMW_FIELD(ah, AR_MCI_MISC, AR_MCI_MISC_HW_FIX_EN, 1);
  661. if (!(mci->config & ATH_MCI_CONFIG_DISABLE_AGGR_THRESH)) {
  662. thresh = MS(mci->config, ATH_MCI_CONFIG_AGGR_THRESH);
  663. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL,
  664. AR_BTCOEX_CTRL_AGGR_THRESH, thresh);
  665. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL,
  666. AR_BTCOEX_CTRL_TIME_TO_NEXT_BT_THRESH_EN, 1);
  667. } else
  668. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL,
  669. AR_BTCOEX_CTRL_TIME_TO_NEXT_BT_THRESH_EN, 0);
  670. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL,
  671. AR_BTCOEX_CTRL_ONE_STEP_LOOK_AHEAD_EN, 1);
  672. }
  673. int ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g,
  674. bool is_full_sleep)
  675. {
  676. struct ath_common *common = ath9k_hw_common(ah);
  677. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  678. u32 regval, i;
  679. ath_dbg(common, MCI, "MCI Reset (full_sleep = %d, is_2g = %d)\n",
  680. is_full_sleep, is_2g);
  681. if (!mci->gpm_addr && !mci->sched_addr) {
  682. ath_err(common, "MCI GPM and schedule buffers are not allocated\n");
  683. return -ENOMEM;
  684. }
  685. if (REG_READ(ah, AR_BTCOEX_CTRL) == 0xdeadbeef) {
  686. ath_err(common, "BTCOEX control register is dead\n");
  687. return -EINVAL;
  688. }
  689. /* Program MCI DMA related registers */
  690. REG_WRITE(ah, AR_MCI_GPM_0, mci->gpm_addr);
  691. REG_WRITE(ah, AR_MCI_GPM_1, mci->gpm_len);
  692. REG_WRITE(ah, AR_MCI_SCHD_TABLE_0, mci->sched_addr);
  693. /*
  694. * To avoid MCI state machine be affected by incoming remote MCI msgs,
  695. * MCI mode will be enabled later, right before reset the MCI TX and RX.
  696. */
  697. regval = SM(1, AR_BTCOEX_CTRL_AR9462_MODE) |
  698. SM(1, AR_BTCOEX_CTRL_WBTIMER_EN) |
  699. SM(1, AR_BTCOEX_CTRL_PA_SHARED) |
  700. SM(1, AR_BTCOEX_CTRL_LNA_SHARED) |
  701. SM(0, AR_BTCOEX_CTRL_1_CHAIN_ACK) |
  702. SM(0, AR_BTCOEX_CTRL_1_CHAIN_BCN) |
  703. SM(0, AR_BTCOEX_CTRL_ONE_STEP_LOOK_AHEAD_EN);
  704. if (AR_SREV_9565(ah)) {
  705. regval |= SM(1, AR_BTCOEX_CTRL_NUM_ANTENNAS) |
  706. SM(1, AR_BTCOEX_CTRL_RX_CHAIN_MASK);
  707. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL2,
  708. AR_BTCOEX_CTRL2_TX_CHAIN_MASK, 0x1);
  709. } else {
  710. regval |= SM(2, AR_BTCOEX_CTRL_NUM_ANTENNAS) |
  711. SM(3, AR_BTCOEX_CTRL_RX_CHAIN_MASK);
  712. }
  713. REG_WRITE(ah, AR_BTCOEX_CTRL, regval);
  714. if (is_2g && !(mci->config & ATH_MCI_CONFIG_DISABLE_OSLA))
  715. ar9003_mci_osla_setup(ah, true);
  716. else
  717. ar9003_mci_osla_setup(ah, false);
  718. REG_SET_BIT(ah, AR_PHY_GLB_CONTROL,
  719. AR_BTCOEX_CTRL_SPDT_ENABLE);
  720. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL3,
  721. AR_BTCOEX_CTRL3_CONT_INFO_TIMEOUT, 20);
  722. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL2, AR_BTCOEX_CTRL2_RX_DEWEIGHT, 0);
  723. REG_RMW_FIELD(ah, AR_PCU_MISC, AR_PCU_BT_ANT_PREVENT_RX, 0);
  724. /* Set the time out to 3.125ms (5 BT slots) */
  725. REG_RMW_FIELD(ah, AR_BTCOEX_WL_LNA, AR_BTCOEX_WL_LNA_TIMEOUT, 0x3D090);
  726. /* concurrent tx priority */
  727. if (mci->config & ATH_MCI_CONFIG_CONCUR_TX) {
  728. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL2,
  729. AR_BTCOEX_CTRL2_DESC_BASED_TXPWR_ENABLE, 0);
  730. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL2,
  731. AR_BTCOEX_CTRL2_TXPWR_THRESH, 0x7f);
  732. REG_RMW_FIELD(ah, AR_BTCOEX_CTRL,
  733. AR_BTCOEX_CTRL_REDUCE_TXPWR, 0);
  734. for (i = 0; i < 8; i++)
  735. REG_WRITE(ah, AR_BTCOEX_MAX_TXPWR(i), 0x7f7f7f7f);
  736. }
  737. regval = MS(mci->config, ATH_MCI_CONFIG_CLK_DIV);
  738. REG_RMW_FIELD(ah, AR_MCI_TX_CTRL, AR_MCI_TX_CTRL_CLK_DIV, regval);
  739. REG_SET_BIT(ah, AR_BTCOEX_CTRL, AR_BTCOEX_CTRL_MCI_MODE_EN);
  740. /* Resetting the Rx and Tx paths of MCI */
  741. regval = REG_READ(ah, AR_MCI_COMMAND2);
  742. regval |= SM(1, AR_MCI_COMMAND2_RESET_TX);
  743. REG_WRITE(ah, AR_MCI_COMMAND2, regval);
  744. udelay(1);
  745. regval &= ~SM(1, AR_MCI_COMMAND2_RESET_TX);
  746. REG_WRITE(ah, AR_MCI_COMMAND2, regval);
  747. if (is_full_sleep) {
  748. ar9003_mci_mute_bt(ah);
  749. udelay(100);
  750. }
  751. /* Check pending GPM msg before MCI Reset Rx */
  752. ar9003_mci_check_gpm_offset(ah);
  753. regval |= SM(1, AR_MCI_COMMAND2_RESET_RX);
  754. REG_WRITE(ah, AR_MCI_COMMAND2, regval);
  755. udelay(1);
  756. regval &= ~SM(1, AR_MCI_COMMAND2_RESET_RX);
  757. REG_WRITE(ah, AR_MCI_COMMAND2, regval);
  758. ar9003_mci_get_next_gpm_offset(ah, true, NULL);
  759. REG_WRITE(ah, AR_MCI_MSG_ATTRIBUTES_TABLE,
  760. (SM(0xe801, AR_MCI_MSG_ATTRIBUTES_TABLE_INVALID_HDR) |
  761. SM(0x0000, AR_MCI_MSG_ATTRIBUTES_TABLE_CHECKSUM)));
  762. REG_CLR_BIT(ah, AR_MCI_TX_CTRL,
  763. AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE);
  764. ar9003_mci_observation_set_up(ah);
  765. mci->ready = true;
  766. ar9003_mci_prep_interface(ah);
  767. if (AR_SREV_9565(ah))
  768. REG_RMW_FIELD(ah, AR_MCI_DBG_CNT_CTRL,
  769. AR_MCI_DBG_CNT_CTRL_ENABLE, 0);
  770. if (en_int)
  771. ar9003_mci_enable_interrupt(ah);
  772. return 0;
  773. }
  774. void ar9003_mci_stop_bt(struct ath_hw *ah, bool save_fullsleep)
  775. {
  776. struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci;
  777. ar9003_mci_disable_interrupt(ah);
  778. if (mci_hw->ready && !save_fullsleep) {
  779. ar9003_mci_mute_bt(ah);
  780. udelay(20);
  781. REG_WRITE(ah, AR_BTCOEX_CTRL, 0);
  782. }
  783. mci_hw->bt_state = MCI_BT_SLEEP;
  784. mci_hw->ready = false;
  785. }
  786. static void ar9003_mci_send_2g5g_status(struct ath_hw *ah, bool wait_done)
  787. {
  788. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  789. u32 new_flags, to_set, to_clear;
  790. if (!mci->update_2g5g || (mci->bt_state == MCI_BT_SLEEP))
  791. return;
  792. if (mci->is_2g) {
  793. new_flags = MCI_2G_FLAGS;
  794. to_clear = MCI_2G_FLAGS_CLEAR_MASK;
  795. to_set = MCI_2G_FLAGS_SET_MASK;
  796. } else {
  797. new_flags = MCI_5G_FLAGS;
  798. to_clear = MCI_5G_FLAGS_CLEAR_MASK;
  799. to_set = MCI_5G_FLAGS_SET_MASK;
  800. }
  801. if (to_clear)
  802. ar9003_mci_send_coex_bt_flags(ah, wait_done,
  803. MCI_GPM_COEX_BT_FLAGS_CLEAR,
  804. to_clear);
  805. if (to_set)
  806. ar9003_mci_send_coex_bt_flags(ah, wait_done,
  807. MCI_GPM_COEX_BT_FLAGS_SET,
  808. to_set);
  809. }
  810. static void ar9003_mci_queue_unsent_gpm(struct ath_hw *ah, u8 header,
  811. u32 *payload, bool queue)
  812. {
  813. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  814. u8 type, opcode;
  815. /* check if the message is to be queued */
  816. if (header != MCI_GPM)
  817. return;
  818. type = MCI_GPM_TYPE(payload);
  819. opcode = MCI_GPM_OPCODE(payload);
  820. if (type != MCI_GPM_COEX_AGENT)
  821. return;
  822. switch (opcode) {
  823. case MCI_GPM_COEX_BT_UPDATE_FLAGS:
  824. if (*(((u8 *)payload) + MCI_GPM_COEX_B_BT_FLAGS_OP) ==
  825. MCI_GPM_COEX_BT_FLAGS_READ)
  826. break;
  827. mci->update_2g5g = queue;
  828. break;
  829. case MCI_GPM_COEX_WLAN_CHANNELS:
  830. mci->wlan_channels_update = queue;
  831. break;
  832. case MCI_GPM_COEX_HALT_BT_GPM:
  833. if (*(((u8 *)payload) + MCI_GPM_COEX_B_HALT_STATE) ==
  834. MCI_GPM_COEX_BT_GPM_UNHALT) {
  835. mci->unhalt_bt_gpm = queue;
  836. if (!queue)
  837. mci->halted_bt_gpm = false;
  838. }
  839. if (*(((u8 *)payload) + MCI_GPM_COEX_B_HALT_STATE) ==
  840. MCI_GPM_COEX_BT_GPM_HALT) {
  841. mci->halted_bt_gpm = !queue;
  842. }
  843. break;
  844. default:
  845. break;
  846. }
  847. }
  848. void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool force)
  849. {
  850. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  851. if (!mci->update_2g5g && !force)
  852. return;
  853. if (mci->is_2g) {
  854. ar9003_mci_send_2g5g_status(ah, true);
  855. ar9003_mci_send_lna_transfer(ah, true);
  856. udelay(5);
  857. REG_CLR_BIT(ah, AR_MCI_TX_CTRL,
  858. AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE);
  859. REG_CLR_BIT(ah, AR_PHY_GLB_CONTROL,
  860. AR_BTCOEX_CTRL_BT_OWN_SPDT_CTRL);
  861. if (!(mci->config & ATH_MCI_CONFIG_DISABLE_OSLA))
  862. ar9003_mci_osla_setup(ah, true);
  863. if (AR_SREV_9462(ah))
  864. REG_WRITE(ah, AR_SELFGEN_MASK, 0x02);
  865. } else {
  866. ar9003_mci_send_lna_take(ah, true);
  867. udelay(5);
  868. REG_SET_BIT(ah, AR_MCI_TX_CTRL,
  869. AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE);
  870. REG_SET_BIT(ah, AR_PHY_GLB_CONTROL,
  871. AR_BTCOEX_CTRL_BT_OWN_SPDT_CTRL);
  872. ar9003_mci_osla_setup(ah, false);
  873. ar9003_mci_send_2g5g_status(ah, true);
  874. }
  875. }
  876. bool ar9003_mci_send_message(struct ath_hw *ah, u8 header, u32 flag,
  877. u32 *payload, u8 len, bool wait_done,
  878. bool check_bt)
  879. {
  880. struct ath_common *common = ath9k_hw_common(ah);
  881. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  882. bool msg_sent = false;
  883. u32 regval;
  884. u32 saved_mci_int_en;
  885. int i;
  886. saved_mci_int_en = REG_READ(ah, AR_MCI_INTERRUPT_EN);
  887. regval = REG_READ(ah, AR_BTCOEX_CTRL);
  888. if ((regval == 0xdeadbeef) || !(regval & AR_BTCOEX_CTRL_MCI_MODE_EN)) {
  889. ath_dbg(common, MCI,
  890. "MCI Not sending 0x%x. MCI is not enabled. full_sleep = %d\n",
  891. header, (ah->power_mode == ATH9K_PM_FULL_SLEEP) ? 1 : 0);
  892. ar9003_mci_queue_unsent_gpm(ah, header, payload, true);
  893. return false;
  894. } else if (check_bt && (mci->bt_state == MCI_BT_SLEEP)) {
  895. ath_dbg(common, MCI,
  896. "MCI Don't send message 0x%x. BT is in sleep state\n",
  897. header);
  898. ar9003_mci_queue_unsent_gpm(ah, header, payload, true);
  899. return false;
  900. }
  901. if (wait_done)
  902. REG_WRITE(ah, AR_MCI_INTERRUPT_EN, 0);
  903. /* Need to clear SW_MSG_DONE raw bit before wait */
  904. REG_WRITE(ah, AR_MCI_INTERRUPT_RAW,
  905. (AR_MCI_INTERRUPT_SW_MSG_DONE |
  906. AR_MCI_INTERRUPT_MSG_FAIL_MASK));
  907. if (payload) {
  908. for (i = 0; (i * 4) < len; i++)
  909. REG_WRITE(ah, (AR_MCI_TX_PAYLOAD0 + i * 4),
  910. *(payload + i));
  911. }
  912. REG_WRITE(ah, AR_MCI_COMMAND0,
  913. (SM((flag & MCI_FLAG_DISABLE_TIMESTAMP),
  914. AR_MCI_COMMAND0_DISABLE_TIMESTAMP) |
  915. SM(len, AR_MCI_COMMAND0_LEN) |
  916. SM(header, AR_MCI_COMMAND0_HEADER)));
  917. if (wait_done &&
  918. !(ar9003_mci_wait_for_interrupt(ah, AR_MCI_INTERRUPT_RAW,
  919. AR_MCI_INTERRUPT_SW_MSG_DONE, 500)))
  920. ar9003_mci_queue_unsent_gpm(ah, header, payload, true);
  921. else {
  922. ar9003_mci_queue_unsent_gpm(ah, header, payload, false);
  923. msg_sent = true;
  924. }
  925. if (wait_done)
  926. REG_WRITE(ah, AR_MCI_INTERRUPT_EN, saved_mci_int_en);
  927. return msg_sent;
  928. }
  929. EXPORT_SYMBOL(ar9003_mci_send_message);
  930. void ar9003_mci_init_cal_req(struct ath_hw *ah, bool *is_reusable)
  931. {
  932. struct ath_common *common = ath9k_hw_common(ah);
  933. struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci;
  934. u32 pld[4] = {0, 0, 0, 0};
  935. if ((mci_hw->bt_state != MCI_BT_AWAKE) ||
  936. (mci_hw->config & ATH_MCI_CONFIG_DISABLE_MCI_CAL))
  937. return;
  938. MCI_GPM_SET_CAL_TYPE(pld, MCI_GPM_WLAN_CAL_REQ);
  939. pld[MCI_GPM_WLAN_CAL_W_SEQUENCE] = mci_hw->wlan_cal_seq++;
  940. ar9003_mci_send_message(ah, MCI_GPM, 0, pld, 16, true, false);
  941. if (ar9003_mci_wait_for_gpm(ah, MCI_GPM_BT_CAL_GRANT, 0, 50000)) {
  942. ath_dbg(common, MCI, "MCI BT_CAL_GRANT received\n");
  943. } else {
  944. *is_reusable = false;
  945. ath_dbg(common, MCI, "MCI BT_CAL_GRANT not received\n");
  946. }
  947. }
  948. void ar9003_mci_init_cal_done(struct ath_hw *ah)
  949. {
  950. struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci;
  951. u32 pld[4] = {0, 0, 0, 0};
  952. if ((mci_hw->bt_state != MCI_BT_AWAKE) ||
  953. (mci_hw->config & ATH_MCI_CONFIG_DISABLE_MCI_CAL))
  954. return;
  955. MCI_GPM_SET_CAL_TYPE(pld, MCI_GPM_WLAN_CAL_DONE);
  956. pld[MCI_GPM_WLAN_CAL_W_SEQUENCE] = mci_hw->wlan_cal_done++;
  957. ar9003_mci_send_message(ah, MCI_GPM, 0, pld, 16, true, false);
  958. }
  959. int ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf,
  960. u16 len, u32 sched_addr)
  961. {
  962. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  963. mci->gpm_addr = gpm_addr;
  964. mci->gpm_buf = gpm_buf;
  965. mci->gpm_len = len;
  966. mci->sched_addr = sched_addr;
  967. return ar9003_mci_reset(ah, true, true, true);
  968. }
  969. EXPORT_SYMBOL(ar9003_mci_setup);
  970. void ar9003_mci_cleanup(struct ath_hw *ah)
  971. {
  972. /* Turn off MCI and Jupiter mode. */
  973. REG_WRITE(ah, AR_BTCOEX_CTRL, 0x00);
  974. ar9003_mci_disable_interrupt(ah);
  975. }
  976. EXPORT_SYMBOL(ar9003_mci_cleanup);
  977. u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type)
  978. {
  979. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  980. u32 value = 0, tsf;
  981. u8 query_type;
  982. switch (state_type) {
  983. case MCI_STATE_ENABLE:
  984. if (mci->ready) {
  985. value = REG_READ(ah, AR_BTCOEX_CTRL);
  986. if ((value == 0xdeadbeef) || (value == 0xffffffff))
  987. value = 0;
  988. }
  989. value &= AR_BTCOEX_CTRL_MCI_MODE_EN;
  990. break;
  991. case MCI_STATE_LAST_SCHD_MSG_OFFSET:
  992. value = MS(REG_READ(ah, AR_MCI_RX_STATUS),
  993. AR_MCI_RX_LAST_SCHD_MSG_INDEX);
  994. /* Make it in bytes */
  995. value <<= 4;
  996. break;
  997. case MCI_STATE_REMOTE_SLEEP:
  998. value = MS(REG_READ(ah, AR_MCI_RX_STATUS),
  999. AR_MCI_RX_REMOTE_SLEEP) ?
  1000. MCI_BT_SLEEP : MCI_BT_AWAKE;
  1001. break;
  1002. case MCI_STATE_SET_BT_AWAKE:
  1003. mci->bt_state = MCI_BT_AWAKE;
  1004. ar9003_mci_send_coex_version_query(ah, true);
  1005. ar9003_mci_send_coex_wlan_channels(ah, true);
  1006. if (mci->unhalt_bt_gpm)
  1007. ar9003_mci_send_coex_halt_bt_gpm(ah, false, true);
  1008. ar9003_mci_2g5g_switch(ah, false);
  1009. break;
  1010. case MCI_STATE_RESET_REQ_WAKE:
  1011. ar9003_mci_reset_req_wakeup(ah);
  1012. mci->update_2g5g = true;
  1013. if (mci->config & ATH_MCI_CONFIG_MCI_OBS_MASK) {
  1014. /* Check if we still have control of the GPIOs */
  1015. if ((REG_READ(ah, AR_GLB_GPIO_CONTROL) &
  1016. ATH_MCI_CONFIG_MCI_OBS_GPIO) !=
  1017. ATH_MCI_CONFIG_MCI_OBS_GPIO) {
  1018. ar9003_mci_observation_set_up(ah);
  1019. }
  1020. }
  1021. break;
  1022. case MCI_STATE_SEND_WLAN_COEX_VERSION:
  1023. ar9003_mci_send_coex_version_response(ah, true);
  1024. break;
  1025. case MCI_STATE_SEND_VERSION_QUERY:
  1026. ar9003_mci_send_coex_version_query(ah, true);
  1027. break;
  1028. case MCI_STATE_SEND_STATUS_QUERY:
  1029. query_type = MCI_GPM_COEX_QUERY_BT_TOPOLOGY;
  1030. ar9003_mci_send_coex_bt_status_query(ah, true, query_type);
  1031. break;
  1032. case MCI_STATE_RECOVER_RX:
  1033. tsf = ath9k_hw_gettsf32(ah);
  1034. if ((tsf - mci->last_recovery) <= MCI_RECOVERY_DUR_TSF) {
  1035. ath_dbg(ath9k_hw_common(ah), MCI,
  1036. "(MCI) ignore Rx recovery\n");
  1037. break;
  1038. }
  1039. ath_dbg(ath9k_hw_common(ah), MCI, "(MCI) RECOVER RX\n");
  1040. mci->last_recovery = tsf;
  1041. ar9003_mci_prep_interface(ah);
  1042. mci->query_bt = true;
  1043. mci->need_flush_btinfo = true;
  1044. ar9003_mci_send_coex_wlan_channels(ah, true);
  1045. ar9003_mci_2g5g_switch(ah, false);
  1046. break;
  1047. case MCI_STATE_NEED_FTP_STOMP:
  1048. value = !(mci->config & ATH_MCI_CONFIG_DISABLE_FTP_STOMP);
  1049. break;
  1050. case MCI_STATE_NEED_FLUSH_BT_INFO:
  1051. value = (!mci->unhalt_bt_gpm && mci->need_flush_btinfo) ? 1 : 0;
  1052. mci->need_flush_btinfo = false;
  1053. break;
  1054. default:
  1055. break;
  1056. }
  1057. return value;
  1058. }
  1059. EXPORT_SYMBOL(ar9003_mci_state);
  1060. void ar9003_mci_bt_gain_ctrl(struct ath_hw *ah)
  1061. {
  1062. struct ath_common *common = ath9k_hw_common(ah);
  1063. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  1064. ath_dbg(common, MCI, "Give LNA and SPDT control to BT\n");
  1065. ar9003_mci_send_lna_take(ah, true);
  1066. udelay(50);
  1067. REG_SET_BIT(ah, AR_PHY_GLB_CONTROL, AR_BTCOEX_CTRL_BT_OWN_SPDT_CTRL);
  1068. mci->is_2g = false;
  1069. mci->update_2g5g = true;
  1070. ar9003_mci_send_2g5g_status(ah, true);
  1071. /* Force another 2g5g update at next scanning */
  1072. mci->update_2g5g = true;
  1073. }
  1074. void ar9003_mci_set_power_awake(struct ath_hw *ah)
  1075. {
  1076. u32 btcoex_ctrl2, diag_sw;
  1077. int i;
  1078. u8 lna_ctrl, bt_sleep;
  1079. for (i = 0; i < AH_WAIT_TIMEOUT; i++) {
  1080. btcoex_ctrl2 = REG_READ(ah, AR_BTCOEX_CTRL2);
  1081. if (btcoex_ctrl2 != 0xdeadbeef)
  1082. break;
  1083. udelay(AH_TIME_QUANTUM);
  1084. }
  1085. REG_WRITE(ah, AR_BTCOEX_CTRL2, (btcoex_ctrl2 | BIT(23)));
  1086. for (i = 0; i < AH_WAIT_TIMEOUT; i++) {
  1087. diag_sw = REG_READ(ah, AR_DIAG_SW);
  1088. if (diag_sw != 0xdeadbeef)
  1089. break;
  1090. udelay(AH_TIME_QUANTUM);
  1091. }
  1092. REG_WRITE(ah, AR_DIAG_SW, (diag_sw | BIT(27) | BIT(19) | BIT(18)));
  1093. lna_ctrl = REG_READ(ah, AR_OBS_BUS_CTRL) & 0x3;
  1094. bt_sleep = MS(REG_READ(ah, AR_MCI_RX_STATUS), AR_MCI_RX_REMOTE_SLEEP);
  1095. REG_WRITE(ah, AR_BTCOEX_CTRL2, btcoex_ctrl2);
  1096. REG_WRITE(ah, AR_DIAG_SW, diag_sw);
  1097. if (bt_sleep && (lna_ctrl == 2)) {
  1098. REG_SET_BIT(ah, AR_BTCOEX_RC, 0x1);
  1099. REG_CLR_BIT(ah, AR_BTCOEX_RC, 0x1);
  1100. udelay(50);
  1101. }
  1102. }
  1103. void ar9003_mci_check_gpm_offset(struct ath_hw *ah)
  1104. {
  1105. struct ath_common *common = ath9k_hw_common(ah);
  1106. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  1107. u32 offset;
  1108. /*
  1109. * This should only be called before "MAC Warm Reset" or "MCI Reset Rx".
  1110. */
  1111. offset = MS(REG_READ(ah, AR_MCI_GPM_1), AR_MCI_GPM_WRITE_PTR);
  1112. if (mci->gpm_idx == offset)
  1113. return;
  1114. ath_dbg(common, MCI, "GPM cached write pointer mismatch %d %d\n",
  1115. mci->gpm_idx, offset);
  1116. mci->query_bt = true;
  1117. mci->need_flush_btinfo = true;
  1118. mci->gpm_idx = 0;
  1119. }
  1120. u32 ar9003_mci_get_next_gpm_offset(struct ath_hw *ah, bool first, u32 *more)
  1121. {
  1122. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  1123. u32 offset, more_gpm = 0, gpm_ptr;
  1124. if (first) {
  1125. gpm_ptr = MS(REG_READ(ah, AR_MCI_GPM_1), AR_MCI_GPM_WRITE_PTR);
  1126. if (gpm_ptr >= mci->gpm_len)
  1127. gpm_ptr = 0;
  1128. mci->gpm_idx = gpm_ptr;
  1129. return gpm_ptr;
  1130. }
  1131. /*
  1132. * This could be useful to avoid new GPM message interrupt which
  1133. * may lead to spurious interrupt after power sleep, or multiple
  1134. * entry of ath_mci_intr().
  1135. * Adding empty GPM check by returning HAL_MCI_GPM_INVALID can
  1136. * alleviate this effect, but clearing GPM RX interrupt bit is
  1137. * safe, because whether this is called from hw or driver code
  1138. * there must be an interrupt bit set/triggered initially
  1139. */
  1140. REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_RAW,
  1141. AR_MCI_INTERRUPT_RX_MSG_GPM);
  1142. gpm_ptr = MS(REG_READ(ah, AR_MCI_GPM_1), AR_MCI_GPM_WRITE_PTR);
  1143. offset = gpm_ptr;
  1144. if (!offset)
  1145. offset = mci->gpm_len - 1;
  1146. else if (offset >= mci->gpm_len) {
  1147. if (offset != 0xFFFF)
  1148. offset = 0;
  1149. } else {
  1150. offset--;
  1151. }
  1152. if ((offset == 0xFFFF) || (gpm_ptr == mci->gpm_idx)) {
  1153. offset = MCI_GPM_INVALID;
  1154. more_gpm = MCI_GPM_NOMORE;
  1155. goto out;
  1156. }
  1157. for (;;) {
  1158. u32 temp_index;
  1159. /* skip reserved GPM if any */
  1160. if (offset != mci->gpm_idx)
  1161. more_gpm = MCI_GPM_MORE;
  1162. else
  1163. more_gpm = MCI_GPM_NOMORE;
  1164. temp_index = mci->gpm_idx;
  1165. if (temp_index >= mci->gpm_len)
  1166. temp_index = 0;
  1167. mci->gpm_idx++;
  1168. if (mci->gpm_idx >= mci->gpm_len)
  1169. mci->gpm_idx = 0;
  1170. if (ar9003_mci_is_gpm_valid(ah, temp_index)) {
  1171. offset = temp_index;
  1172. break;
  1173. }
  1174. if (more_gpm == MCI_GPM_NOMORE) {
  1175. offset = MCI_GPM_INVALID;
  1176. break;
  1177. }
  1178. }
  1179. if (offset != MCI_GPM_INVALID)
  1180. offset <<= 4;
  1181. out:
  1182. if (more)
  1183. *more = more_gpm;
  1184. return offset;
  1185. }
  1186. EXPORT_SYMBOL(ar9003_mci_get_next_gpm_offset);
  1187. void ar9003_mci_set_bt_version(struct ath_hw *ah, u8 major, u8 minor)
  1188. {
  1189. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  1190. mci->bt_ver_major = major;
  1191. mci->bt_ver_minor = minor;
  1192. mci->bt_version_known = true;
  1193. ath_dbg(ath9k_hw_common(ah), MCI, "MCI BT version set: %d.%d\n",
  1194. mci->bt_ver_major, mci->bt_ver_minor);
  1195. }
  1196. EXPORT_SYMBOL(ar9003_mci_set_bt_version);
  1197. void ar9003_mci_send_wlan_channels(struct ath_hw *ah)
  1198. {
  1199. struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
  1200. mci->wlan_channels_update = true;
  1201. ar9003_mci_send_coex_wlan_channels(ah, true);
  1202. }
  1203. EXPORT_SYMBOL(ar9003_mci_send_wlan_channels);
  1204. u16 ar9003_mci_get_max_txpower(struct ath_hw *ah, u8 ctlmode)
  1205. {
  1206. if (!ah->btcoex_hw.mci.concur_tx)
  1207. goto out;
  1208. if (ctlmode == CTL_2GHT20)
  1209. return ATH_BTCOEX_HT20_MAX_TXPOWER;
  1210. else if (ctlmode == CTL_2GHT40)
  1211. return ATH_BTCOEX_HT40_MAX_TXPOWER;
  1212. out:
  1213. return -1;
  1214. }