aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k
diff options
context:
space:
mode:
authorSujith Manoharan <c_manoha@qca.qualcomm.com>2012-02-22 02:11:24 -0500
committerJohn W. Linville <linville@tuxdriver.com>2012-02-27 14:06:37 -0500
commita3f846f12ce75c62bde4b6a1332416520c4fc00a (patch)
tree4b01b9abd0e4461d4ca69780837044c6ae1e8b5d /drivers/net/wireless/ath/ath9k
parentf4701b5a0dc3e047d4a9e11cd70d8839893bad17 (diff)
ath9k_hw: Cleanup MCI function declarations
This patch converts a few functions to static variants and removes extraneous declarations. Signed-off-by: Sujith Manoharan <c_manoha@qca.qualcomm.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath/ath9k')
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_mci.c508
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_mci.h13
2 files changed, 254 insertions, 267 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.c b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
index 597e707a0c7..b9652f6e5a4 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.c
@@ -82,7 +82,7 @@ static int ar9003_mci_wait_for_interrupt(struct ath_hw *ah, u32 address,
82 return time_out; 82 return time_out;
83} 83}
84 84
85void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done) 85static void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done)
86{ 86{
87 u32 payload[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffff00}; 87 u32 payload[4] = { 0xffffffff, 0xffffffff, 0xffffffff, 0xffffff00};
88 88
@@ -94,7 +94,7 @@ void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done)
94 udelay(5); 94 udelay(5);
95} 95}
96 96
97void ar9003_mci_send_lna_transfer(struct ath_hw *ah, bool wait_done) 97static void ar9003_mci_send_lna_transfer(struct ath_hw *ah, bool wait_done)
98{ 98{
99 u32 payload = 0x00000000; 99 u32 payload = 0x00000000;
100 100
@@ -112,7 +112,7 @@ static void ar9003_mci_send_req_wake(struct ath_hw *ah, bool wait_done)
112 udelay(5); 112 udelay(5);
113} 113}
114 114
115void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done) 115static void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done)
116{ 116{
117 if (!ATH9K_HW_CAP_MCI) 117 if (!ATH9K_HW_CAP_MCI)
118 return; 118 return;
@@ -223,8 +223,8 @@ static void ar9003_mci_send_coex_bt_status_query(struct ath_hw *ah,
223 } 223 }
224} 224}
225 225
226void ar9003_mci_send_coex_halt_bt_gpm(struct ath_hw *ah, bool halt, 226static void ar9003_mci_send_coex_halt_bt_gpm(struct ath_hw *ah, bool halt,
227 bool wait_done) 227 bool wait_done)
228{ 228{
229 struct ath_common *common = ath9k_hw_common(ah); 229 struct ath_common *common = ath9k_hw_common(ah);
230 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; 230 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
@@ -383,7 +383,7 @@ void ar9003_mci_set_full_sleep(struct ath_hw *ah)
383 REG_WRITE(ah, AR_RTC_KEEP_AWAKE, 0x2); 383 REG_WRITE(ah, AR_RTC_KEEP_AWAKE, 0x2);
384} 384}
385 385
386void ar9003_mci_disable_interrupt(struct ath_hw *ah) 386static void ar9003_mci_disable_interrupt(struct ath_hw *ah)
387{ 387{
388 if (!ATH9K_HW_CAP_MCI) 388 if (!ATH9K_HW_CAP_MCI)
389 return; 389 return;
@@ -392,7 +392,7 @@ void ar9003_mci_disable_interrupt(struct ath_hw *ah)
392 REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN, 0); 392 REG_WRITE(ah, AR_MCI_INTERRUPT_RX_MSG_EN, 0);
393} 393}
394 394
395void ar9003_mci_enable_interrupt(struct ath_hw *ah) 395static void ar9003_mci_enable_interrupt(struct ath_hw *ah)
396{ 396{
397 if (!ATH9K_HW_CAP_MCI) 397 if (!ATH9K_HW_CAP_MCI)
398 return; 398 return;
@@ -402,7 +402,7 @@ void ar9003_mci_enable_interrupt(struct ath_hw *ah)
402 AR_MCI_INTERRUPT_RX_MSG_DEFAULT); 402 AR_MCI_INTERRUPT_RX_MSG_DEFAULT);
403} 403}
404 404
405bool ar9003_mci_check_int(struct ath_hw *ah, u32 ints) 405static bool ar9003_mci_check_int(struct ath_hw *ah, u32 ints)
406{ 406{
407 u32 intr; 407 u32 intr;
408 408
@@ -455,7 +455,7 @@ void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked)
455 } 455 }
456} 456}
457 457
458void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool is_2g) 458static void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool is_2g)
459{ 459{
460 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci; 460 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
461 461
@@ -568,6 +568,36 @@ static bool ar9003_mci_send_coex_bt_flags(struct ath_hw *ah, bool wait_done,
568 wait_done, true); 568 wait_done, true);
569} 569}
570 570
571static void ar9003_mci_sync_bt_state(struct ath_hw *ah)
572{
573 struct ath_common *common = ath9k_hw_common(ah);
574 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
575 u32 cur_bt_state;
576
577 if (!ATH9K_HW_CAP_MCI)
578 return;
579
580 cur_bt_state = ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL);
581
582 if (mci->bt_state != cur_bt_state) {
583 ath_dbg(common, MCI,
584 "MCI BT state mismatches. old: %d, new: %d\n",
585 mci->bt_state, cur_bt_state);
586 mci->bt_state = cur_bt_state;
587 }
588
589 if (mci->bt_state != MCI_BT_SLEEP) {
590
591 ar9003_mci_send_coex_version_query(ah, true);
592 ar9003_mci_send_coex_wlan_channels(ah, true);
593
594 if (mci->unhalt_bt_gpm == true) {
595 ath_dbg(common, MCI, "MCI unhalt BT GPM\n");
596 ar9003_mci_send_coex_halt_bt_gpm(ah, false, true);
597 }
598 }
599}
600
571void ar9003_mci_check_bt(struct ath_hw *ah) 601void ar9003_mci_check_bt(struct ath_hw *ah)
572{ 602{
573 struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci; 603 struct ath9k_hw_mci *mci_hw = &ah->btcoex_hw.mci;
@@ -588,6 +618,188 @@ void ar9003_mci_check_bt(struct ath_hw *ah)
588 } 618 }
589} 619}
590 620
621static void ar9003_mci_process_gpm_extra(struct ath_hw *ah, u8 gpm_type,
622 u8 gpm_opcode, u32 *p_gpm)
623{
624 struct ath_common *common = ath9k_hw_common(ah);
625 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
626 u8 *p_data = (u8 *) p_gpm;
627
628 if (gpm_type != MCI_GPM_COEX_AGENT)
629 return;
630
631 switch (gpm_opcode) {
632 case MCI_GPM_COEX_VERSION_QUERY:
633 ath_dbg(common, MCI, "MCI Recv GPM COEX Version Query\n");
634 ar9003_mci_send_coex_version_response(ah, true);
635 break;
636 case MCI_GPM_COEX_VERSION_RESPONSE:
637 ath_dbg(common, MCI, "MCI Recv GPM COEX Version Response\n");
638 mci->bt_ver_major =
639 *(p_data + MCI_GPM_COEX_B_MAJOR_VERSION);
640 mci->bt_ver_minor =
641 *(p_data + MCI_GPM_COEX_B_MINOR_VERSION);
642 mci->bt_version_known = true;
643 ath_dbg(common, MCI, "MCI BT Coex version: %d.%d\n",
644 mci->bt_ver_major, mci->bt_ver_minor);
645 break;
646 case MCI_GPM_COEX_STATUS_QUERY:
647 ath_dbg(common, MCI,
648 "MCI Recv GPM COEX Status Query = 0x%02X\n",
649 *(p_data + MCI_GPM_COEX_B_WLAN_BITMAP));
650 mci->wlan_channels_update = true;
651 ar9003_mci_send_coex_wlan_channels(ah, true);
652 break;
653 case MCI_GPM_COEX_BT_PROFILE_INFO:
654 mci->query_bt = true;
655 ath_dbg(common, MCI, "MCI Recv GPM COEX BT_Profile_Info\n");
656 break;
657 case MCI_GPM_COEX_BT_STATUS_UPDATE:
658 mci->query_bt = true;
659 ath_dbg(common, MCI,
660 "MCI Recv GPM COEX BT_Status_Update SEQ=%d (drop&query)\n",
661 *(p_gpm + 3));
662 break;
663 default:
664 break;
665 }
666}
667
668static u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type,
669 u8 gpm_opcode, int time_out)
670{
671 struct ath_common *common = ath9k_hw_common(ah);
672 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
673 u32 *p_gpm = NULL, mismatch = 0, more_data;
674 u32 offset;
675 u8 recv_type = 0, recv_opcode = 0;
676 bool b_is_bt_cal_done = (gpm_type == MCI_GPM_BT_CAL_DONE);
677
678 if (!ATH9K_HW_CAP_MCI)
679 return 0;
680
681 more_data = time_out ? MCI_GPM_NOMORE : MCI_GPM_MORE;
682
683 while (time_out > 0) {
684 if (p_gpm) {
685 MCI_GPM_RECYCLE(p_gpm);
686 p_gpm = NULL;
687 }
688
689 if (more_data != MCI_GPM_MORE)
690 time_out = ar9003_mci_wait_for_interrupt(ah,
691 AR_MCI_INTERRUPT_RX_MSG_RAW,
692 AR_MCI_INTERRUPT_RX_MSG_GPM,
693 time_out);
694
695 if (!time_out)
696 break;
697
698 offset = ar9003_mci_state(ah,
699 MCI_STATE_NEXT_GPM_OFFSET, &more_data);
700
701 if (offset == MCI_GPM_INVALID)
702 continue;
703
704 p_gpm = (u32 *) (mci->gpm_buf + offset);
705 recv_type = MCI_GPM_TYPE(p_gpm);
706 recv_opcode = MCI_GPM_OPCODE(p_gpm);
707
708 if (MCI_GPM_IS_CAL_TYPE(recv_type)) {
709
710 if (recv_type == gpm_type) {
711
712 if ((gpm_type == MCI_GPM_BT_CAL_DONE) &&
713 !b_is_bt_cal_done) {
714 gpm_type = MCI_GPM_BT_CAL_GRANT;
715 ath_dbg(common, MCI,
716 "MCI Recv BT_CAL_DONE wait BT_CAL_GRANT\n");
717 continue;
718 }
719
720 break;
721 }
722 } else if ((recv_type == gpm_type) &&
723 (recv_opcode == gpm_opcode))
724 break;
725
726 /* not expected message */
727
728 /*
729 * check if it's cal_grant
730 *
731 * When we're waiting for cal_grant in reset routine,
732 * it's possible that BT sends out cal_request at the
733 * same time. Since BT's calibration doesn't happen
734 * that often, we'll let BT completes calibration then
735 * we continue to wait for cal_grant from BT.
736 * Orginal: Wait BT_CAL_GRANT.
737 * New: Receive BT_CAL_REQ -> send WLAN_CAL_GRANT->wait
738 * BT_CAL_DONE -> Wait BT_CAL_GRANT.
739 */
740
741 if ((gpm_type == MCI_GPM_BT_CAL_GRANT) &&
742 (recv_type == MCI_GPM_BT_CAL_REQ)) {
743
744 u32 payload[4] = {0, 0, 0, 0};
745
746 gpm_type = MCI_GPM_BT_CAL_DONE;
747 ath_dbg(common, MCI,
748 "MCI Rcv BT_CAL_REQ, send WLAN_CAL_GRANT\n");
749
750 MCI_GPM_SET_CAL_TYPE(payload,
751 MCI_GPM_WLAN_CAL_GRANT);
752
753 ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16,
754 false, false);
755
756 ath_dbg(common, MCI, "MCI now wait for BT_CAL_DONE\n");
757
758 continue;
759 } else {
760 ath_dbg(common, MCI, "MCI GPM subtype not match 0x%x\n",
761 *(p_gpm + 1));
762 mismatch++;
763 ar9003_mci_process_gpm_extra(ah, recv_type,
764 recv_opcode, p_gpm);
765 }
766 }
767 if (p_gpm) {
768 MCI_GPM_RECYCLE(p_gpm);
769 p_gpm = NULL;
770 }
771
772 if (time_out <= 0) {
773 time_out = 0;
774 ath_dbg(common, MCI,
775 "MCI GPM received timeout, mismatch = %d\n", mismatch);
776 } else
777 ath_dbg(common, MCI, "MCI Receive GPM type=0x%x, code=0x%x\n",
778 gpm_type, gpm_opcode);
779
780 while (more_data == MCI_GPM_MORE) {
781
782 ath_dbg(common, MCI, "MCI discard remaining GPM\n");
783 offset = ar9003_mci_state(ah, MCI_STATE_NEXT_GPM_OFFSET,
784 &more_data);
785
786 if (offset == MCI_GPM_INVALID)
787 break;
788
789 p_gpm = (u32 *) (mci->gpm_buf + offset);
790 recv_type = MCI_GPM_TYPE(p_gpm);
791 recv_opcode = MCI_GPM_OPCODE(p_gpm);
792
793 if (!MCI_GPM_IS_CAL_TYPE(recv_type))
794 ar9003_mci_process_gpm_extra(ah, recv_type,
795 recv_opcode, p_gpm);
796
797 MCI_GPM_RECYCLE(p_gpm);
798 }
799
800 return time_out;
801}
802
591bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan) 803bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan)
592{ 804{
593 struct ath_common *common = ath9k_hw_common(ah); 805 struct ath_common *common = ath9k_hw_common(ah);
@@ -693,6 +905,39 @@ exit:
693 return 0; 905 return 0;
694} 906}
695 907
908static void ar9003_mci_mute_bt(struct ath_hw *ah)
909{
910 struct ath_common *common = ath9k_hw_common(ah);
911
912 if (!ATH9K_HW_CAP_MCI)
913 return;
914
915 /* disable all MCI messages */
916 REG_WRITE(ah, AR_MCI_MSG_ATTRIBUTES_TABLE, 0xffff0000);
917 REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS0, 0xffffffff);
918 REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS1, 0xffffffff);
919 REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS2, 0xffffffff);
920 REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS3, 0xffffffff);
921 REG_SET_BIT(ah, AR_MCI_TX_CTRL, AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE);
922
923 /* wait pending HW messages to flush out */
924 udelay(10);
925
926 /*
927 * Send LNA_TAKE and SYS_SLEEPING when
928 * 1. reset not after resuming from full sleep
929 * 2. before reset MCI RX, to quiet BT and avoid MCI RX misalignment
930 */
931
932 ath_dbg(common, MCI, "MCI Send LNA take\n");
933 ar9003_mci_send_lna_take(ah, true);
934
935 udelay(5);
936
937 ath_dbg(common, MCI, "MCI Send sys sleeping\n");
938 ar9003_mci_send_sys_sleeping(ah, true);
939}
940
696void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, 941void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g,
697 bool is_full_sleep) 942 bool is_full_sleep)
698{ 943{
@@ -838,69 +1083,6 @@ void ar9003_mci_stop_bt(struct ath_hw *ah, bool save_fullsleep)
838 mci_hw->ready = false; 1083 mci_hw->ready = false;
839} 1084}
840 1085
841void ar9003_mci_mute_bt(struct ath_hw *ah)
842{
843 struct ath_common *common = ath9k_hw_common(ah);
844
845 if (!ATH9K_HW_CAP_MCI)
846 return;
847
848 /* disable all MCI messages */
849 REG_WRITE(ah, AR_MCI_MSG_ATTRIBUTES_TABLE, 0xffff0000);
850 REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS0, 0xffffffff);
851 REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS1, 0xffffffff);
852 REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS2, 0xffffffff);
853 REG_WRITE(ah, AR_BTCOEX_WL_WEIGHTS3, 0xffffffff);
854 REG_SET_BIT(ah, AR_MCI_TX_CTRL, AR_MCI_TX_CTRL_DISABLE_LNA_UPDATE);
855
856 /* wait pending HW messages to flush out */
857 udelay(10);
858
859 /*
860 * Send LNA_TAKE and SYS_SLEEPING when
861 * 1. reset not after resuming from full sleep
862 * 2. before reset MCI RX, to quiet BT and avoid MCI RX misalignment
863 */
864
865 ath_dbg(common, MCI, "MCI Send LNA take\n");
866 ar9003_mci_send_lna_take(ah, true);
867
868 udelay(5);
869
870 ath_dbg(common, MCI, "MCI Send sys sleeping\n");
871 ar9003_mci_send_sys_sleeping(ah, true);
872}
873
874void ar9003_mci_sync_bt_state(struct ath_hw *ah)
875{
876 struct ath_common *common = ath9k_hw_common(ah);
877 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
878 u32 cur_bt_state;
879
880 if (!ATH9K_HW_CAP_MCI)
881 return;
882
883 cur_bt_state = ar9003_mci_state(ah, MCI_STATE_REMOTE_SLEEP, NULL);
884
885 if (mci->bt_state != cur_bt_state) {
886 ath_dbg(common, MCI,
887 "MCI BT state mismatches. old: %d, new: %d\n",
888 mci->bt_state, cur_bt_state);
889 mci->bt_state = cur_bt_state;
890 }
891
892 if (mci->bt_state != MCI_BT_SLEEP) {
893
894 ar9003_mci_send_coex_version_query(ah, true);
895 ar9003_mci_send_coex_wlan_channels(ah, true);
896
897 if (mci->unhalt_bt_gpm == true) {
898 ath_dbg(common, MCI, "MCI unhalt BT GPM\n");
899 ar9003_mci_send_coex_halt_bt_gpm(ah, false, true);
900 }
901 }
902}
903
904static void ar9003_mci_send_2g5g_status(struct ath_hw *ah, bool wait_done) 1086static void ar9003_mci_send_2g5g_status(struct ath_hw *ah, bool wait_done)
905{ 1087{
906 struct ath_common *common = ath9k_hw_common(ah); 1088 struct ath_common *common = ath9k_hw_common(ah);
@@ -1229,188 +1411,6 @@ void ar9003_mci_cleanup(struct ath_hw *ah)
1229} 1411}
1230EXPORT_SYMBOL(ar9003_mci_cleanup); 1412EXPORT_SYMBOL(ar9003_mci_cleanup);
1231 1413
1232static void ar9003_mci_process_gpm_extra(struct ath_hw *ah, u8 gpm_type,
1233 u8 gpm_opcode, u32 *p_gpm)
1234{
1235 struct ath_common *common = ath9k_hw_common(ah);
1236 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
1237 u8 *p_data = (u8 *) p_gpm;
1238
1239 if (gpm_type != MCI_GPM_COEX_AGENT)
1240 return;
1241
1242 switch (gpm_opcode) {
1243 case MCI_GPM_COEX_VERSION_QUERY:
1244 ath_dbg(common, MCI, "MCI Recv GPM COEX Version Query\n");
1245 ar9003_mci_send_coex_version_response(ah, true);
1246 break;
1247 case MCI_GPM_COEX_VERSION_RESPONSE:
1248 ath_dbg(common, MCI, "MCI Recv GPM COEX Version Response\n");
1249 mci->bt_ver_major =
1250 *(p_data + MCI_GPM_COEX_B_MAJOR_VERSION);
1251 mci->bt_ver_minor =
1252 *(p_data + MCI_GPM_COEX_B_MINOR_VERSION);
1253 mci->bt_version_known = true;
1254 ath_dbg(common, MCI, "MCI BT Coex version: %d.%d\n",
1255 mci->bt_ver_major, mci->bt_ver_minor);
1256 break;
1257 case MCI_GPM_COEX_STATUS_QUERY:
1258 ath_dbg(common, MCI,
1259 "MCI Recv GPM COEX Status Query = 0x%02X\n",
1260 *(p_data + MCI_GPM_COEX_B_WLAN_BITMAP));
1261 mci->wlan_channels_update = true;
1262 ar9003_mci_send_coex_wlan_channels(ah, true);
1263 break;
1264 case MCI_GPM_COEX_BT_PROFILE_INFO:
1265 mci->query_bt = true;
1266 ath_dbg(common, MCI, "MCI Recv GPM COEX BT_Profile_Info\n");
1267 break;
1268 case MCI_GPM_COEX_BT_STATUS_UPDATE:
1269 mci->query_bt = true;
1270 ath_dbg(common, MCI,
1271 "MCI Recv GPM COEX BT_Status_Update SEQ=%d (drop&query)\n",
1272 *(p_gpm + 3));
1273 break;
1274 default:
1275 break;
1276 }
1277}
1278
1279u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type,
1280 u8 gpm_opcode, int time_out)
1281{
1282 struct ath_common *common = ath9k_hw_common(ah);
1283 struct ath9k_hw_mci *mci = &ah->btcoex_hw.mci;
1284 u32 *p_gpm = NULL, mismatch = 0, more_data;
1285 u32 offset;
1286 u8 recv_type = 0, recv_opcode = 0;
1287 bool b_is_bt_cal_done = (gpm_type == MCI_GPM_BT_CAL_DONE);
1288
1289 if (!ATH9K_HW_CAP_MCI)
1290 return 0;
1291
1292 more_data = time_out ? MCI_GPM_NOMORE : MCI_GPM_MORE;
1293
1294 while (time_out > 0) {
1295 if (p_gpm) {
1296 MCI_GPM_RECYCLE(p_gpm);
1297 p_gpm = NULL;
1298 }
1299
1300 if (more_data != MCI_GPM_MORE)
1301 time_out = ar9003_mci_wait_for_interrupt(ah,
1302 AR_MCI_INTERRUPT_RX_MSG_RAW,
1303 AR_MCI_INTERRUPT_RX_MSG_GPM,
1304 time_out);
1305
1306 if (!time_out)
1307 break;
1308
1309 offset = ar9003_mci_state(ah,
1310 MCI_STATE_NEXT_GPM_OFFSET, &more_data);
1311
1312 if (offset == MCI_GPM_INVALID)
1313 continue;
1314
1315 p_gpm = (u32 *) (mci->gpm_buf + offset);
1316 recv_type = MCI_GPM_TYPE(p_gpm);
1317 recv_opcode = MCI_GPM_OPCODE(p_gpm);
1318
1319 if (MCI_GPM_IS_CAL_TYPE(recv_type)) {
1320
1321 if (recv_type == gpm_type) {
1322
1323 if ((gpm_type == MCI_GPM_BT_CAL_DONE) &&
1324 !b_is_bt_cal_done) {
1325 gpm_type = MCI_GPM_BT_CAL_GRANT;
1326 ath_dbg(common, MCI,
1327 "MCI Recv BT_CAL_DONE wait BT_CAL_GRANT\n");
1328 continue;
1329 }
1330
1331 break;
1332 }
1333 } else if ((recv_type == gpm_type) &&
1334 (recv_opcode == gpm_opcode))
1335 break;
1336
1337 /* not expected message */
1338
1339 /*
1340 * check if it's cal_grant
1341 *
1342 * When we're waiting for cal_grant in reset routine,
1343 * it's possible that BT sends out cal_request at the
1344 * same time. Since BT's calibration doesn't happen
1345 * that often, we'll let BT completes calibration then
1346 * we continue to wait for cal_grant from BT.
1347 * Orginal: Wait BT_CAL_GRANT.
1348 * New: Receive BT_CAL_REQ -> send WLAN_CAL_GRANT->wait
1349 * BT_CAL_DONE -> Wait BT_CAL_GRANT.
1350 */
1351
1352 if ((gpm_type == MCI_GPM_BT_CAL_GRANT) &&
1353 (recv_type == MCI_GPM_BT_CAL_REQ)) {
1354
1355 u32 payload[4] = {0, 0, 0, 0};
1356
1357 gpm_type = MCI_GPM_BT_CAL_DONE;
1358 ath_dbg(common, MCI,
1359 "MCI Rcv BT_CAL_REQ, send WLAN_CAL_GRANT\n");
1360
1361 MCI_GPM_SET_CAL_TYPE(payload,
1362 MCI_GPM_WLAN_CAL_GRANT);
1363
1364 ar9003_mci_send_message(ah, MCI_GPM, 0, payload, 16,
1365 false, false);
1366
1367 ath_dbg(common, MCI, "MCI now wait for BT_CAL_DONE\n");
1368
1369 continue;
1370 } else {
1371 ath_dbg(common, MCI, "MCI GPM subtype not match 0x%x\n",
1372 *(p_gpm + 1));
1373 mismatch++;
1374 ar9003_mci_process_gpm_extra(ah, recv_type,
1375 recv_opcode, p_gpm);
1376 }
1377 }
1378 if (p_gpm) {
1379 MCI_GPM_RECYCLE(p_gpm);
1380 p_gpm = NULL;
1381 }
1382
1383 if (time_out <= 0) {
1384 time_out = 0;
1385 ath_dbg(common, MCI,
1386 "MCI GPM received timeout, mismatch = %d\n", mismatch);
1387 } else
1388 ath_dbg(common, MCI, "MCI Receive GPM type=0x%x, code=0x%x\n",
1389 gpm_type, gpm_opcode);
1390
1391 while (more_data == MCI_GPM_MORE) {
1392
1393 ath_dbg(common, MCI, "MCI discard remaining GPM\n");
1394 offset = ar9003_mci_state(ah, MCI_STATE_NEXT_GPM_OFFSET,
1395 &more_data);
1396
1397 if (offset == MCI_GPM_INVALID)
1398 break;
1399
1400 p_gpm = (u32 *) (mci->gpm_buf + offset);
1401 recv_type = MCI_GPM_TYPE(p_gpm);
1402 recv_opcode = MCI_GPM_OPCODE(p_gpm);
1403
1404 if (!MCI_GPM_IS_CAL_TYPE(recv_type))
1405 ar9003_mci_process_gpm_extra(ah, recv_type,
1406 recv_opcode, p_gpm);
1407
1408 MCI_GPM_RECYCLE(p_gpm);
1409 }
1410
1411 return time_out;
1412}
1413
1414u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data) 1414u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data)
1415{ 1415{
1416 struct ath_common *common = ath9k_hw_common(ah); 1416 struct ath_common *common = ath9k_hw_common(ah);
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mci.h b/drivers/net/wireless/ath/ath9k/ar9003_mci.h
index 39bbf67078d..507527b9f5a 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_mci.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_mci.h
@@ -258,21 +258,13 @@ bool ar9003_mci_send_message(struct ath_hw *ah, u8 header, u32 flag,
258 u32 *payload, u8 len, bool wait_done, 258 u32 *payload, u8 len, bool wait_done,
259 bool check_bt); 259 bool check_bt);
260void ar9003_mci_stop_bt(struct ath_hw *ah, bool sava_fullsleep); 260void ar9003_mci_stop_bt(struct ath_hw *ah, bool sava_fullsleep);
261void ar9003_mci_mute_bt(struct ath_hw *ah);
262u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data); 261u32 ar9003_mci_state(struct ath_hw *ah, u32 state_type, u32 *p_data);
263void ar9003_mci_init_cal_req(struct ath_hw *ah, bool *is_reusable); 262void ar9003_mci_init_cal_req(struct ath_hw *ah, bool *is_reusable);
264void ar9003_mci_init_cal_done(struct ath_hw *ah); 263void ar9003_mci_init_cal_done(struct ath_hw *ah);
265void ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf, 264void ar9003_mci_setup(struct ath_hw *ah, u32 gpm_addr, void *gpm_buf,
266 u16 len, u32 sched_addr); 265 u16 len, u32 sched_addr);
267void ar9003_mci_cleanup(struct ath_hw *ah); 266void ar9003_mci_cleanup(struct ath_hw *ah);
268void ar9003_mci_send_coex_halt_bt_gpm(struct ath_hw *ah, bool halt,
269 bool wait_done);
270u32 ar9003_mci_wait_for_gpm(struct ath_hw *ah, u8 gpm_type,
271 u8 gpm_opcode, int time_out);
272void ar9003_mci_2g5g_changed(struct ath_hw *ah, bool is_2g);
273void ar9003_mci_set_full_sleep(struct ath_hw *ah); 267void ar9003_mci_set_full_sleep(struct ath_hw *ah);
274void ar9003_mci_disable_interrupt(struct ath_hw *ah);
275void ar9003_mci_enable_interrupt(struct ath_hw *ah);
276void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool wait_done); 268void ar9003_mci_2g5g_switch(struct ath_hw *ah, bool wait_done);
277void ar9003_mci_check_bt(struct ath_hw *ah); 269void ar9003_mci_check_bt(struct ath_hw *ah);
278bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan); 270bool ar9003_mci_start_reset(struct ath_hw *ah, struct ath9k_channel *chan);
@@ -280,11 +272,6 @@ int ar9003_mci_end_reset(struct ath_hw *ah, struct ath9k_channel *chan,
280 struct ath9k_hw_cal_data *caldata); 272 struct ath9k_hw_cal_data *caldata);
281void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g, 273void ar9003_mci_reset(struct ath_hw *ah, bool en_int, bool is_2g,
282 bool is_full_sleep); 274 bool is_full_sleep);
283bool ar9003_mci_check_int(struct ath_hw *ah, u32 ints);
284void ar9003_mci_remote_reset(struct ath_hw *ah, bool wait_done);
285void ar9003_mci_send_sys_waking(struct ath_hw *ah, bool wait_done);
286void ar9003_mci_send_lna_transfer(struct ath_hw *ah, bool wait_done);
287void ar9003_mci_sync_bt_state(struct ath_hw *ah);
288void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr, 275void ar9003_mci_get_interrupt(struct ath_hw *ah, u32 *raw_intr,
289 u32 *rx_msg_intr); 276 u32 *rx_msg_intr);
290void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked); 277void ar9003_mci_get_isr(struct ath_hw *ah, enum ath9k_int *masked);