aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k
diff options
context:
space:
mode:
authorJohn W. Linville <linville@tuxdriver.com>2010-05-17 13:57:43 -0400
committerJohn W. Linville <linville@tuxdriver.com>2010-05-17 13:57:43 -0400
commit6fe70aae0d128339febfabc073ba4c4a03de4f45 (patch)
tree711dff90df5ca4e07b5bddf11b2819e5cf2b7a93 /drivers/net/wireless/ath/ath9k
parent278554bd6579206921f5d8a523649a7a57f8850d (diff)
parent0c348d7c1422d59a86d6fb37b53d75788043e50b (diff)
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6 into for-davem
Diffstat (limited to 'drivers/net/wireless/ath/ath9k')
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c174
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.h10
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_initvals.h268
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.c236
-rw-r--r--drivers/net/wireless/ath/ath9k/debug.h8
-rw-r--r--drivers/net/wireless/ath/ath9k/hif_usb.c58
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_init.c7
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_hst.c51
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_hst.h15
-rw-r--r--drivers/net/wireless/ath/ath9k/recv.c3
11 files changed, 488 insertions, 346 deletions
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 8a79550dff71..23eb60ea5455 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -38,6 +38,9 @@
38#define AR_SWITCH_TABLE_ALL (0xfff) 38#define AR_SWITCH_TABLE_ALL (0xfff)
39#define AR_SWITCH_TABLE_ALL_S (0) 39#define AR_SWITCH_TABLE_ALL_S (0)
40 40
41#define LE16(x) __constant_cpu_to_le16(x)
42#define LE32(x) __constant_cpu_to_le32(x)
43
41static const struct ar9300_eeprom ar9300_default = { 44static const struct ar9300_eeprom ar9300_default = {
42 .eepromVersion = 2, 45 .eepromVersion = 2,
43 .templateVersion = 2, 46 .templateVersion = 2,
@@ -45,7 +48,7 @@ static const struct ar9300_eeprom ar9300_default = {
45 .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 48 .custData = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
46 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, 49 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
47 .baseEepHeader = { 50 .baseEepHeader = {
48 .regDmn = {0, 0x1f}, 51 .regDmn = { LE16(0), LE16(0x1f) },
49 .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */ 52 .txrxMask = 0x77, /* 4 bits tx and 4 bits rx */
50 .opCapFlags = { 53 .opCapFlags = {
51 .opFlags = AR9300_OPFLAGS_11G | AR9300_OPFLAGS_11A, 54 .opFlags = AR9300_OPFLAGS_11G | AR9300_OPFLAGS_11A,
@@ -76,15 +79,15 @@ static const struct ar9300_eeprom ar9300_default = {
76 .modalHeader2G = { 79 .modalHeader2G = {
77 /* ar9300_modal_eep_header 2g */ 80 /* ar9300_modal_eep_header 2g */
78 /* 4 idle,t1,t2,b(4 bits per setting) */ 81 /* 4 idle,t1,t2,b(4 bits per setting) */
79 .antCtrlCommon = 0x110, 82 .antCtrlCommon = LE32(0x110),
80 /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */ 83 /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
81 .antCtrlCommon2 = 0x22222, 84 .antCtrlCommon2 = LE32(0x22222),
82 85
83 /* 86 /*
84 * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r, 87 * antCtrlChain[AR9300_MAX_CHAINS]; 6 idle, t, r,
85 * rx1, rx12, b (2 bits each) 88 * rx1, rx12, b (2 bits each)
86 */ 89 */
87 .antCtrlChain = {0x150, 0x150, 0x150}, 90 .antCtrlChain = { LE16(0x150), LE16(0x150), LE16(0x150) },
88 91
89 /* 92 /*
90 * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db 93 * xatten1DB[AR9300_MAX_CHAINS]; 3 xatten1_db
@@ -287,12 +290,12 @@ static const struct ar9300_eeprom ar9300_default = {
287 }, 290 },
288 .modalHeader5G = { 291 .modalHeader5G = {
289 /* 4 idle,t1,t2,b (4 bits per setting) */ 292 /* 4 idle,t1,t2,b (4 bits per setting) */
290 .antCtrlCommon = 0x110, 293 .antCtrlCommon = LE32(0x110),
291 /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */ 294 /* 4 ra1l1, ra2l1, ra1l2,ra2l2,ra12 */
292 .antCtrlCommon2 = 0x22222, 295 .antCtrlCommon2 = LE32(0x22222),
293 /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */ 296 /* antCtrlChain 6 idle, t,r,rx1,rx12,b (2 bits each) */
294 .antCtrlChain = { 297 .antCtrlChain = {
295 0x000, 0x000, 0x000, 298 LE16(0x000), LE16(0x000), LE16(0x000),
296 }, 299 },
297 /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */ 300 /* xatten1DB 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
298 .xatten1DB = {0, 0, 0}, 301 .xatten1DB = {0, 0, 0},
@@ -620,9 +623,9 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
620 case EEP_MAC_MSW: 623 case EEP_MAC_MSW:
621 return eep->macAddr[4] << 8 | eep->macAddr[5]; 624 return eep->macAddr[4] << 8 | eep->macAddr[5];
622 case EEP_REG_0: 625 case EEP_REG_0:
623 return pBase->regDmn[0]; 626 return le16_to_cpu(pBase->regDmn[0]);
624 case EEP_REG_1: 627 case EEP_REG_1:
625 return pBase->regDmn[1]; 628 return le16_to_cpu(pBase->regDmn[1]);
626 case EEP_OP_CAP: 629 case EEP_OP_CAP:
627 return pBase->deviceCap; 630 return pBase->deviceCap;
628 case EEP_OP_MODE: 631 case EEP_OP_MODE:
@@ -640,93 +643,80 @@ static u32 ath9k_hw_ar9300_get_eeprom(struct ath_hw *ah,
640 /* Bit 4 is internal regulator flag */ 643 /* Bit 4 is internal regulator flag */
641 return (pBase->featureEnable & 0x10) >> 4; 644 return (pBase->featureEnable & 0x10) >> 4;
642 case EEP_SWREG: 645 case EEP_SWREG:
643 return pBase->swreg; 646 return le32_to_cpu(pBase->swreg);
644 default: 647 default:
645 return 0; 648 return 0;
646 } 649 }
647} 650}
648 651
649#ifdef __BIG_ENDIAN 652static bool ar9300_eeprom_read_byte(struct ath_common *common, int address,
650static void ar9300_swap_eeprom(struct ar9300_eeprom *eep) 653 u8 *buffer)
651{ 654{
652 u32 dword; 655 u16 val;
653 u16 word;
654 int i;
655
656 word = swab16(eep->baseEepHeader.regDmn[0]);
657 eep->baseEepHeader.regDmn[0] = word;
658
659 word = swab16(eep->baseEepHeader.regDmn[1]);
660 eep->baseEepHeader.regDmn[1] = word;
661
662 dword = swab32(eep->baseEepHeader.swreg);
663 eep->baseEepHeader.swreg = dword;
664 656
665 dword = swab32(eep->modalHeader2G.antCtrlCommon); 657 if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val)))
666 eep->modalHeader2G.antCtrlCommon = dword; 658 return false;
667 659
668 dword = swab32(eep->modalHeader2G.antCtrlCommon2); 660 *buffer = (val >> (8 * (address % 2))) & 0xff;
669 eep->modalHeader2G.antCtrlCommon2 = dword; 661 return true;
662}
670 663
671 dword = swab32(eep->modalHeader5G.antCtrlCommon); 664static bool ar9300_eeprom_read_word(struct ath_common *common, int address,
672 eep->modalHeader5G.antCtrlCommon = dword; 665 u8 *buffer)
666{
667 u16 val;
673 668
674 dword = swab32(eep->modalHeader5G.antCtrlCommon2); 669 if (unlikely(!ath9k_hw_nvram_read(common, address / 2, &val)))
675 eep->modalHeader5G.antCtrlCommon2 = dword; 670 return false;
676 671
677 for (i = 0; i < AR9300_MAX_CHAINS; i++) { 672 buffer[0] = val >> 8;
678 word = swab16(eep->modalHeader2G.antCtrlChain[i]); 673 buffer[1] = val & 0xff;
679 eep->modalHeader2G.antCtrlChain[i] = word;
680 674
681 word = swab16(eep->modalHeader5G.antCtrlChain[i]); 675 return true;
682 eep->modalHeader5G.antCtrlChain[i] = word;
683 }
684} 676}
685#endif
686 677
687static bool ar9300_hw_read_eeprom(struct ath_hw *ah, 678static bool ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer,
688 long address, u8 *buffer, int many) 679 int count)
689{ 680{
690 int i;
691 u8 value[2];
692 unsigned long eepAddr;
693 unsigned long byteAddr;
694 u16 *svalue;
695 struct ath_common *common = ath9k_hw_common(ah); 681 struct ath_common *common = ath9k_hw_common(ah);
682 int i;
696 683
697 if ((address < 0) || ((address + many) > AR9300_EEPROM_SIZE - 1)) { 684 if ((address < 0) || ((address + count) / 2 > AR9300_EEPROM_SIZE - 1)) {
698 ath_print(common, ATH_DBG_EEPROM, 685 ath_print(common, ATH_DBG_EEPROM,
699 "eeprom address not in range\n"); 686 "eeprom address not in range\n");
700 return false; 687 return false;
701 } 688 }
702 689
703 for (i = 0; i < many; i++) { 690 /*
704 eepAddr = (u16) (address + i) / 2; 691 * Since we're reading the bytes in reverse order from a little-endian
705 byteAddr = (u16) (address + i) % 2; 692 * word stream, an even address means we only use the lower half of
706 svalue = (u16 *) value; 693 * the 16-bit word at that address
707 if (!ath9k_hw_nvram_read(common, eepAddr, svalue)) { 694 */
708 ath_print(common, ATH_DBG_EEPROM, 695 if (address % 2 == 0) {
709 "unable to read eeprom region\n"); 696 if (!ar9300_eeprom_read_byte(common, address--, buffer++))
710 return false; 697 goto error;
711 } 698
712 *svalue = le16_to_cpu(*svalue); 699 count--;
713 buffer[i] = value[byteAddr];
714 } 700 }
715 701
716 return true; 702 for (i = 0; i < count / 2; i++) {
717} 703 if (!ar9300_eeprom_read_word(common, address, buffer))
704 goto error;
718 705
719static bool ar9300_read_eeprom(struct ath_hw *ah, 706 address -= 2;
720 int address, u8 *buffer, int many) 707 buffer += 2;
721{ 708 }
722 int it; 709
710 if (count % 2)
711 if (!ar9300_eeprom_read_byte(common, address, buffer))
712 goto error;
723 713
724 for (it = 0; it < many; it++)
725 if (!ar9300_hw_read_eeprom(ah,
726 (address - it),
727 (buffer + it), 1))
728 return false;
729 return true; 714 return true;
715
716error:
717 ath_print(common, ATH_DBG_EEPROM,
718 "unable to read eeprom region at offset %d\n", address);
719 return false;
730} 720}
731 721
732static void ar9300_comp_hdr_unpack(u8 *best, int *code, int *reference, 722static void ar9300_comp_hdr_unpack(u8 *best, int *code, int *reference,
@@ -927,30 +917,13 @@ fail:
927 */ 917 */
928static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah) 918static bool ath9k_hw_ar9300_fill_eeprom(struct ath_hw *ah)
929{ 919{
930 u8 *mptr = NULL; 920 u8 *mptr = (u8 *) &ah->eeprom.ar9300_eep;
931 int mdata_size;
932 921
933 mptr = (u8 *) &ah->eeprom.ar9300_eep; 922 if (ar9300_eeprom_restore_internal(ah, mptr,
934 mdata_size = sizeof(struct ar9300_eeprom); 923 sizeof(struct ar9300_eeprom)) < 0)
924 return false;
935 925
936 if (mptr && mdata_size > 0) { 926 return true;
937 /* At this point, mptr points to the eeprom data structure
938 * in it's "default" state. If this is big endian, swap the
939 * data structures back to "little endian"
940 */
941 /* First swap, default to Little Endian */
942#ifdef __BIG_ENDIAN
943 ar9300_swap_eeprom((struct ar9300_eeprom *)mptr);
944#endif
945 if (ar9300_eeprom_restore_internal(ah, mptr, mdata_size) >= 0)
946 return true;
947
948 /* Second Swap, back to Big Endian */
949#ifdef __BIG_ENDIAN
950 ar9300_swap_eeprom((struct ar9300_eeprom *)mptr);
951#endif
952 }
953 return false;
954} 927}
955 928
956/* XXX: review hardware docs */ 929/* XXX: review hardware docs */
@@ -998,21 +971,25 @@ static void ar9003_hw_xpa_bias_level_apply(struct ath_hw *ah, bool is2ghz)
998static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz) 971static u32 ar9003_hw_ant_ctrl_common_get(struct ath_hw *ah, bool is2ghz)
999{ 972{
1000 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 973 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
974 __le32 val;
1001 975
1002 if (is2ghz) 976 if (is2ghz)
1003 return eep->modalHeader2G.antCtrlCommon; 977 val = eep->modalHeader2G.antCtrlCommon;
1004 else 978 else
1005 return eep->modalHeader5G.antCtrlCommon; 979 val = eep->modalHeader5G.antCtrlCommon;
980 return le32_to_cpu(val);
1006} 981}
1007 982
1008static u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz) 983static u32 ar9003_hw_ant_ctrl_common_2_get(struct ath_hw *ah, bool is2ghz)
1009{ 984{
1010 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 985 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
986 __le32 val;
1011 987
1012 if (is2ghz) 988 if (is2ghz)
1013 return eep->modalHeader2G.antCtrlCommon2; 989 val = eep->modalHeader2G.antCtrlCommon2;
1014 else 990 else
1015 return eep->modalHeader5G.antCtrlCommon2; 991 val = eep->modalHeader5G.antCtrlCommon2;
992 return le32_to_cpu(val);
1016} 993}
1017 994
1018static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah, 995static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah,
@@ -1020,15 +997,16 @@ static u16 ar9003_hw_ant_ctrl_chain_get(struct ath_hw *ah,
1020 bool is2ghz) 997 bool is2ghz)
1021{ 998{
1022 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep; 999 struct ar9300_eeprom *eep = &ah->eeprom.ar9300_eep;
1000 __le16 val = 0;
1023 1001
1024 if (chain >= 0 && chain < AR9300_MAX_CHAINS) { 1002 if (chain >= 0 && chain < AR9300_MAX_CHAINS) {
1025 if (is2ghz) 1003 if (is2ghz)
1026 return eep->modalHeader2G.antCtrlChain[chain]; 1004 val = eep->modalHeader2G.antCtrlChain[chain];
1027 else 1005 else
1028 return eep->modalHeader5G.antCtrlChain[chain]; 1006 val = eep->modalHeader5G.antCtrlChain[chain];
1029 } 1007 }
1030 1008
1031 return 0; 1009 return le16_to_cpu(val);
1032} 1010}
1033 1011
1034static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz) 1012static void ar9003_hw_ant_ctrl_apply(struct ath_hw *ah, bool is2ghz)
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
index d8c0318f416f..23fb353c3bba 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.h
@@ -169,7 +169,7 @@ enum CompressAlgorithm {
169}; 169};
170 170
171struct ar9300_base_eep_hdr { 171struct ar9300_base_eep_hdr {
172 u16 regDmn[2]; 172 __le16 regDmn[2];
173 /* 4 bits tx and 4 bits rx */ 173 /* 4 bits tx and 4 bits rx */
174 u8 txrxMask; 174 u8 txrxMask;
175 struct eepFlags opCapFlags; 175 struct eepFlags opCapFlags;
@@ -199,16 +199,16 @@ struct ar9300_base_eep_hdr {
199 u8 rxBandSelectGpio; 199 u8 rxBandSelectGpio;
200 u8 txrxgain; 200 u8 txrxgain;
201 /* SW controlled internal regulator fields */ 201 /* SW controlled internal regulator fields */
202 u32 swreg; 202 __le32 swreg;
203} __packed; 203} __packed;
204 204
205struct ar9300_modal_eep_header { 205struct ar9300_modal_eep_header {
206 /* 4 idle, t1, t2, b (4 bits per setting) */ 206 /* 4 idle, t1, t2, b (4 bits per setting) */
207 u32 antCtrlCommon; 207 __le32 antCtrlCommon;
208 /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */ 208 /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
209 u32 antCtrlCommon2; 209 __le32 antCtrlCommon2;
210 /* 6 idle, t, r, rx1, rx12, b (2 bits each) */ 210 /* 6 idle, t, r, rx1, rx12, b (2 bits each) */
211 u16 antCtrlChain[AR9300_MAX_CHAINS]; 211 __le16 antCtrlChain[AR9300_MAX_CHAINS];
212 /* 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */ 212 /* 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
213 u8 xatten1DB[AR9300_MAX_CHAINS]; 213 u8 xatten1DB[AR9300_MAX_CHAINS];
214 /* 3 xatten1_margin for merlin (0xa20c/b20c 16:12 */ 214 /* 3 xatten1_margin for merlin (0xa20c/b20c 16:12 */
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_initvals.h b/drivers/net/wireless/ath/ath9k/ar9003_initvals.h
index ef6116e13033..db019dd220b7 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_initvals.h
+++ b/drivers/net/wireless/ath/ath9k/ar9003_initvals.h
@@ -25,8 +25,11 @@ static const u32 ar9300_2p0_radio_postamble[][5] = {
25 {0x000160ac, 0xa4653c00, 0xa4653c00, 0x24652800, 0x24652800}, 25 {0x000160ac, 0xa4653c00, 0xa4653c00, 0x24652800, 0x24652800},
26 {0x000160b0, 0x03284f3e, 0x03284f3e, 0x05d08f20, 0x05d08f20}, 26 {0x000160b0, 0x03284f3e, 0x03284f3e, 0x05d08f20, 0x05d08f20},
27 {0x0001610c, 0x08000000, 0x00000000, 0x00000000, 0x00000000}, 27 {0x0001610c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
28 {0x00016140, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
28 {0x0001650c, 0x08000000, 0x00000000, 0x00000000, 0x00000000}, 29 {0x0001650c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
30 {0x00016540, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
29 {0x0001690c, 0x08000000, 0x00000000, 0x00000000, 0x00000000}, 31 {0x0001690c, 0x08000000, 0x00000000, 0x00000000, 0x00000000},
32 {0x00016940, 0x10804008, 0x10804008, 0x50804008, 0x50804008},
30}; 33};
31 34
32static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p0[][5] = { 35static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p0[][5] = {
@@ -97,13 +100,13 @@ static const u32 ar9300Modes_lowest_ob_db_tx_gain_table_2p0[][5] = {
97 {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec}, 100 {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
98 {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec}, 101 {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
99 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 102 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
100 {0x00016048, 0x60001a61, 0x60001a61, 0x60001a61, 0x60001a61}, 103 {0x00016048, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
101 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 104 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
102 {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 105 {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
103 {0x00016448, 0x60001a61, 0x60001a61, 0x60001a61, 0x60001a61}, 106 {0x00016448, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
104 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 107 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
105 {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 108 {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
106 {0x00016848, 0x60001a61, 0x60001a61, 0x60001a61, 0x60001a61}, 109 {0x00016848, 0x62480001, 0x62480001, 0x62480001, 0x62480001},
107 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 110 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
108}; 111};
109 112
@@ -129,7 +132,7 @@ static const u32 ar9300_2p0_radio_core[][2] = {
129 {0x00016040, 0x7f80fff8}, 132 {0x00016040, 0x7f80fff8},
130 {0x0001604c, 0x76d005b5}, 133 {0x0001604c, 0x76d005b5},
131 {0x00016050, 0x556cf031}, 134 {0x00016050, 0x556cf031},
132 {0x00016054, 0x43449440}, 135 {0x00016054, 0x13449440},
133 {0x00016058, 0x0c51c92c}, 136 {0x00016058, 0x0c51c92c},
134 {0x0001605c, 0x3db7fffc}, 137 {0x0001605c, 0x3db7fffc},
135 {0x00016060, 0xfffffffc}, 138 {0x00016060, 0xfffffffc},
@@ -152,12 +155,11 @@ static const u32 ar9300_2p0_radio_core[][2] = {
152 {0x00016100, 0x3fffbe01}, 155 {0x00016100, 0x3fffbe01},
153 {0x00016104, 0xfff80000}, 156 {0x00016104, 0xfff80000},
154 {0x00016108, 0x00080010}, 157 {0x00016108, 0x00080010},
155 {0x00016140, 0x10804008},
156 {0x00016144, 0x02084080}, 158 {0x00016144, 0x02084080},
157 {0x00016148, 0x00000000}, 159 {0x00016148, 0x00000000},
158 {0x00016280, 0x058a0001}, 160 {0x00016280, 0x058a0001},
159 {0x00016284, 0x3d840208}, 161 {0x00016284, 0x3d840208},
160 {0x00016288, 0x01a20408}, 162 {0x00016288, 0x05a20408},
161 {0x0001628c, 0x00038c07}, 163 {0x0001628c, 0x00038c07},
162 {0x00016290, 0x40000004}, 164 {0x00016290, 0x40000004},
163 {0x00016294, 0x458aa14f}, 165 {0x00016294, 0x458aa14f},
@@ -190,7 +192,7 @@ static const u32 ar9300_2p0_radio_core[][2] = {
190 {0x00016440, 0x7f80fff8}, 192 {0x00016440, 0x7f80fff8},
191 {0x0001644c, 0x76d005b5}, 193 {0x0001644c, 0x76d005b5},
192 {0x00016450, 0x556cf031}, 194 {0x00016450, 0x556cf031},
193 {0x00016454, 0x43449440}, 195 {0x00016454, 0x13449440},
194 {0x00016458, 0x0c51c92c}, 196 {0x00016458, 0x0c51c92c},
195 {0x0001645c, 0x3db7fffc}, 197 {0x0001645c, 0x3db7fffc},
196 {0x00016460, 0xfffffffc}, 198 {0x00016460, 0xfffffffc},
@@ -199,7 +201,6 @@ static const u32 ar9300_2p0_radio_core[][2] = {
199 {0x00016500, 0x3fffbe01}, 201 {0x00016500, 0x3fffbe01},
200 {0x00016504, 0xfff80000}, 202 {0x00016504, 0xfff80000},
201 {0x00016508, 0x00080010}, 203 {0x00016508, 0x00080010},
202 {0x00016540, 0x10804008},
203 {0x00016544, 0x02084080}, 204 {0x00016544, 0x02084080},
204 {0x00016548, 0x00000000}, 205 {0x00016548, 0x00000000},
205 {0x00016780, 0x00000000}, 206 {0x00016780, 0x00000000},
@@ -231,7 +232,7 @@ static const u32 ar9300_2p0_radio_core[][2] = {
231 {0x00016840, 0x7f80fff8}, 232 {0x00016840, 0x7f80fff8},
232 {0x0001684c, 0x76d005b5}, 233 {0x0001684c, 0x76d005b5},
233 {0x00016850, 0x556cf031}, 234 {0x00016850, 0x556cf031},
234 {0x00016854, 0x43449440}, 235 {0x00016854, 0x13449440},
235 {0x00016858, 0x0c51c92c}, 236 {0x00016858, 0x0c51c92c},
236 {0x0001685c, 0x3db7fffc}, 237 {0x0001685c, 0x3db7fffc},
237 {0x00016860, 0xfffffffc}, 238 {0x00016860, 0xfffffffc},
@@ -240,7 +241,6 @@ static const u32 ar9300_2p0_radio_core[][2] = {
240 {0x00016900, 0x3fffbe01}, 241 {0x00016900, 0x3fffbe01},
241 {0x00016904, 0xfff80000}, 242 {0x00016904, 0xfff80000},
242 {0x00016908, 0x00080010}, 243 {0x00016908, 0x00080010},
243 {0x00016940, 0x10804008},
244 {0x00016944, 0x02084080}, 244 {0x00016944, 0x02084080},
245 {0x00016948, 0x00000000}, 245 {0x00016948, 0x00000000},
246 {0x00016b80, 0x00000000}, 246 {0x00016b80, 0x00000000},
@@ -588,12 +588,12 @@ static const u32 ar9200_merlin_2p0_radio_core[][2] = {
588 588
589static const u32 ar9300_2p0_baseband_postamble[][5] = { 589static const u32 ar9300_2p0_baseband_postamble[][5] = {
590 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */ 590 /* Addr 5G_HT20 5G_HT40 2G_HT40 2G_HT20 */
591 {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8005, 0xd00a800b}, 591 {0x00009810, 0xd00a8005, 0xd00a8005, 0xd00a8011, 0xd00a8011},
592 {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e}, 592 {0x00009820, 0x206a022e, 0x206a022e, 0x206a012e, 0x206a012e},
593 {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0}, 593 {0x00009824, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0, 0x5ac640d0},
594 {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881}, 594 {0x00009828, 0x06903081, 0x06903081, 0x06903881, 0x06903881},
595 {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4}, 595 {0x0000982c, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4, 0x05eea6d4},
596 {0x00009830, 0x0000059c, 0x0000059c, 0x0000059c, 0x00000b9c}, 596 {0x00009830, 0x0000059c, 0x0000059c, 0x0000119c, 0x0000119c},
597 {0x00009c00, 0x00000044, 0x000000c4, 0x000000c4, 0x00000044}, 597 {0x00009c00, 0x00000044, 0x000000c4, 0x000000c4, 0x00000044},
598 {0x00009e00, 0x0372161e, 0x0372161e, 0x037216a0, 0x037216a0}, 598 {0x00009e00, 0x0372161e, 0x0372161e, 0x037216a0, 0x037216a0},
599 {0x00009e04, 0x00802020, 0x00802020, 0x00802020, 0x00802020}, 599 {0x00009e04, 0x00802020, 0x00802020, 0x00802020, 0x00802020},
@@ -604,8 +604,8 @@ static const u32 ar9300_2p0_baseband_postamble[][5] = {
604 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c}, 604 {0x00009e1c, 0x0001cf9c, 0x0001cf9c, 0x00021f9c, 0x00021f9c},
605 {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce}, 605 {0x00009e20, 0x000003b5, 0x000003b5, 0x000003ce, 0x000003ce},
606 {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021}, 606 {0x00009e2c, 0x0000001c, 0x0000001c, 0x00000021, 0x00000021},
607 {0x00009e44, 0x02321e27, 0x02321e27, 0x02282324, 0x02282324}, 607 {0x00009e44, 0x02321e27, 0x02321e27, 0x02291e27, 0x02291e27},
608 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302010, 0x50302010}, 608 {0x00009e48, 0x5030201a, 0x5030201a, 0x50302012, 0x50302012},
609 {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000}, 609 {0x00009fc8, 0x0003f000, 0x0003f000, 0x0001a000, 0x0001a000},
610 {0x0000a204, 0x000037c0, 0x000037c4, 0x000037c4, 0x000037c0}, 610 {0x0000a204, 0x000037c0, 0x000037c4, 0x000037c4, 0x000037c0},
611 {0x0000a208, 0x00000104, 0x00000104, 0x00000004, 0x00000004}, 611 {0x0000a208, 0x00000104, 0x00000104, 0x00000004, 0x00000004},
@@ -674,7 +674,7 @@ static const u32 ar9300_2p0_baseband_core[][2] = {
674 {0x00009d10, 0x01834061}, 674 {0x00009d10, 0x01834061},
675 {0x00009d14, 0x00c0040b}, 675 {0x00009d14, 0x00c0040b},
676 {0x00009d18, 0x00000000}, 676 {0x00009d18, 0x00000000},
677 {0x00009e08, 0x0038233c}, 677 {0x00009e08, 0x0038230c},
678 {0x00009e24, 0x990bb515}, 678 {0x00009e24, 0x990bb515},
679 {0x00009e28, 0x0c6f0000}, 679 {0x00009e28, 0x0c6f0000},
680 {0x00009e30, 0x06336f77}, 680 {0x00009e30, 0x06336f77},
@@ -901,13 +901,13 @@ static const u32 ar9300Modes_high_power_tx_gain_table_2p0[][5] = {
901 {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec}, 901 {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
902 {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec}, 902 {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
903 {0x00016044, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6}, 903 {0x00016044, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
904 {0x00016048, 0xae481a61, 0xae481a61, 0xae481a61, 0xae481a61}, 904 {0x00016048, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
905 {0x00016068, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c}, 905 {0x00016068, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
906 {0x00016444, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6}, 906 {0x00016444, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
907 {0x00016448, 0xae481a61, 0xae481a61, 0xae481a61, 0xae481a61}, 907 {0x00016448, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
908 {0x00016468, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c}, 908 {0x00016468, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
909 {0x00016844, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6}, 909 {0x00016844, 0x056db2e6, 0x056db2e6, 0x056db2e6, 0x056db2e6},
910 {0x00016848, 0xae481a61, 0xae481a61, 0xae481a61, 0xae481a61}, 910 {0x00016848, 0xae480001, 0xae480001, 0xae480001, 0xae480001},
911 {0x00016868, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c}, 911 {0x00016868, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c, 0x6eb6db6c},
912}; 912};
913 913
@@ -979,13 +979,13 @@ static const u32 ar9300Modes_high_ob_db_tx_gain_table_2p0[][5] = {
979 {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec}, 979 {0x0000a5f8, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
980 {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec}, 980 {0x0000a5fc, 0x7584ff56, 0x7584ff56, 0x56801eec, 0x56801eec},
981 {0x00016044, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4}, 981 {0x00016044, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
982 {0x00016048, 0x8e481a61, 0x8e481a61, 0x8e481a61, 0x8e481a61}, 982 {0x00016048, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
983 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 983 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
984 {0x00016444, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4}, 984 {0x00016444, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
985 {0x00016448, 0x8e481a61, 0x8e481a61, 0x8e481a61, 0x8e481a61}, 985 {0x00016448, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
986 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 986 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
987 {0x00016844, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4}, 987 {0x00016844, 0x056db2e4, 0x056db2e4, 0x056db2e4, 0x056db2e4},
988 {0x00016848, 0x8e481a61, 0x8e481a61, 0x8e481a61, 0x8e481a61}, 988 {0x00016848, 0x8e480001, 0x8e480001, 0x8e480001, 0x8e480001},
989 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 989 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
990}; 990};
991 991
@@ -995,22 +995,22 @@ static const u32 ar9300Common_rx_gain_table_2p0[][2] = {
995 {0x0000a004, 0x00030002}, 995 {0x0000a004, 0x00030002},
996 {0x0000a008, 0x00050004}, 996 {0x0000a008, 0x00050004},
997 {0x0000a00c, 0x00810080}, 997 {0x0000a00c, 0x00810080},
998 {0x0000a010, 0x01800082}, 998 {0x0000a010, 0x00830082},
999 {0x0000a014, 0x01820181}, 999 {0x0000a014, 0x01810180},
1000 {0x0000a018, 0x01840183}, 1000 {0x0000a018, 0x01830182},
1001 {0x0000a01c, 0x01880185}, 1001 {0x0000a01c, 0x01850184},
1002 {0x0000a020, 0x018a0189}, 1002 {0x0000a020, 0x01890188},
1003 {0x0000a024, 0x02850284}, 1003 {0x0000a024, 0x018b018a},
1004 {0x0000a028, 0x02890288}, 1004 {0x0000a028, 0x018d018c},
1005 {0x0000a02c, 0x028b028a}, 1005 {0x0000a02c, 0x01910190},
1006 {0x0000a030, 0x028d028c}, 1006 {0x0000a030, 0x01930192},
1007 {0x0000a034, 0x02910290}, 1007 {0x0000a034, 0x01950194},
1008 {0x0000a038, 0x02930292}, 1008 {0x0000a038, 0x038a0196},
1009 {0x0000a03c, 0x03910390}, 1009 {0x0000a03c, 0x038c038b},
1010 {0x0000a040, 0x03930392}, 1010 {0x0000a040, 0x0390038d},
1011 {0x0000a044, 0x03950394}, 1011 {0x0000a044, 0x03920391},
1012 {0x0000a048, 0x00000396}, 1012 {0x0000a048, 0x03940393},
1013 {0x0000a04c, 0x00000000}, 1013 {0x0000a04c, 0x03960395},
1014 {0x0000a050, 0x00000000}, 1014 {0x0000a050, 0x00000000},
1015 {0x0000a054, 0x00000000}, 1015 {0x0000a054, 0x00000000},
1016 {0x0000a058, 0x00000000}, 1016 {0x0000a058, 0x00000000},
@@ -1023,14 +1023,14 @@ static const u32 ar9300Common_rx_gain_table_2p0[][2] = {
1023 {0x0000a074, 0x00000000}, 1023 {0x0000a074, 0x00000000},
1024 {0x0000a078, 0x00000000}, 1024 {0x0000a078, 0x00000000},
1025 {0x0000a07c, 0x00000000}, 1025 {0x0000a07c, 0x00000000},
1026 {0x0000a080, 0x28282828}, 1026 {0x0000a080, 0x22222229},
1027 {0x0000a084, 0x21212128}, 1027 {0x0000a084, 0x1d1d1d1d},
1028 {0x0000a088, 0x21212121}, 1028 {0x0000a088, 0x1d1d1d1d},
1029 {0x0000a08c, 0x1c1c1c21}, 1029 {0x0000a08c, 0x1d1d1d1d},
1030 {0x0000a090, 0x1c1c1c1c}, 1030 {0x0000a090, 0x171d1d1d},
1031 {0x0000a094, 0x17171c1c}, 1031 {0x0000a094, 0x11111717},
1032 {0x0000a098, 0x02020212}, 1032 {0x0000a098, 0x00030311},
1033 {0x0000a09c, 0x02020202}, 1033 {0x0000a09c, 0x00000000},
1034 {0x0000a0a0, 0x00000000}, 1034 {0x0000a0a0, 0x00000000},
1035 {0x0000a0a4, 0x00000000}, 1035 {0x0000a0a4, 0x00000000},
1036 {0x0000a0a8, 0x00000000}, 1036 {0x0000a0a8, 0x00000000},
@@ -1040,26 +1040,26 @@ static const u32 ar9300Common_rx_gain_table_2p0[][2] = {
1040 {0x0000a0b8, 0x00000000}, 1040 {0x0000a0b8, 0x00000000},
1041 {0x0000a0bc, 0x00000000}, 1041 {0x0000a0bc, 0x00000000},
1042 {0x0000a0c0, 0x001f0000}, 1042 {0x0000a0c0, 0x001f0000},
1043 {0x0000a0c4, 0x011f0100}, 1043 {0x0000a0c4, 0x01000101},
1044 {0x0000a0c8, 0x011d011e}, 1044 {0x0000a0c8, 0x011e011f},
1045 {0x0000a0cc, 0x011b011c}, 1045 {0x0000a0cc, 0x011c011d},
1046 {0x0000a0d0, 0x02030204}, 1046 {0x0000a0d0, 0x02030204},
1047 {0x0000a0d4, 0x02010202}, 1047 {0x0000a0d4, 0x02010202},
1048 {0x0000a0d8, 0x021f0200}, 1048 {0x0000a0d8, 0x021f0200},
1049 {0x0000a0dc, 0x021d021e}, 1049 {0x0000a0dc, 0x0302021e},
1050 {0x0000a0e0, 0x03010302}, 1050 {0x0000a0e0, 0x03000301},
1051 {0x0000a0e4, 0x031f0300}, 1051 {0x0000a0e4, 0x031e031f},
1052 {0x0000a0e8, 0x0402031e}, 1052 {0x0000a0e8, 0x0402031d},
1053 {0x0000a0ec, 0x04000401}, 1053 {0x0000a0ec, 0x04000401},
1054 {0x0000a0f0, 0x041e041f}, 1054 {0x0000a0f0, 0x041e041f},
1055 {0x0000a0f4, 0x05010502}, 1055 {0x0000a0f4, 0x0502041d},
1056 {0x0000a0f8, 0x051f0500}, 1056 {0x0000a0f8, 0x05000501},
1057 {0x0000a0fc, 0x0602051e}, 1057 {0x0000a0fc, 0x051e051f},
1058 {0x0000a100, 0x06000601}, 1058 {0x0000a100, 0x06010602},
1059 {0x0000a104, 0x061e061f}, 1059 {0x0000a104, 0x061f0600},
1060 {0x0000a108, 0x0703061d}, 1060 {0x0000a108, 0x061d061e},
1061 {0x0000a10c, 0x07010702}, 1061 {0x0000a10c, 0x07020703},
1062 {0x0000a110, 0x00000700}, 1062 {0x0000a110, 0x07000701},
1063 {0x0000a114, 0x00000000}, 1063 {0x0000a114, 0x00000000},
1064 {0x0000a118, 0x00000000}, 1064 {0x0000a118, 0x00000000},
1065 {0x0000a11c, 0x00000000}, 1065 {0x0000a11c, 0x00000000},
@@ -1072,26 +1072,26 @@ static const u32 ar9300Common_rx_gain_table_2p0[][2] = {
1072 {0x0000a138, 0x00000000}, 1072 {0x0000a138, 0x00000000},
1073 {0x0000a13c, 0x00000000}, 1073 {0x0000a13c, 0x00000000},
1074 {0x0000a140, 0x001f0000}, 1074 {0x0000a140, 0x001f0000},
1075 {0x0000a144, 0x011f0100}, 1075 {0x0000a144, 0x01000101},
1076 {0x0000a148, 0x011d011e}, 1076 {0x0000a148, 0x011e011f},
1077 {0x0000a14c, 0x011b011c}, 1077 {0x0000a14c, 0x011c011d},
1078 {0x0000a150, 0x02030204}, 1078 {0x0000a150, 0x02030204},
1079 {0x0000a154, 0x02010202}, 1079 {0x0000a154, 0x02010202},
1080 {0x0000a158, 0x021f0200}, 1080 {0x0000a158, 0x021f0200},
1081 {0x0000a15c, 0x021d021e}, 1081 {0x0000a15c, 0x0302021e},
1082 {0x0000a160, 0x03010302}, 1082 {0x0000a160, 0x03000301},
1083 {0x0000a164, 0x031f0300}, 1083 {0x0000a164, 0x031e031f},
1084 {0x0000a168, 0x0402031e}, 1084 {0x0000a168, 0x0402031d},
1085 {0x0000a16c, 0x04000401}, 1085 {0x0000a16c, 0x04000401},
1086 {0x0000a170, 0x041e041f}, 1086 {0x0000a170, 0x041e041f},
1087 {0x0000a174, 0x05010502}, 1087 {0x0000a174, 0x0502041d},
1088 {0x0000a178, 0x051f0500}, 1088 {0x0000a178, 0x05000501},
1089 {0x0000a17c, 0x0602051e}, 1089 {0x0000a17c, 0x051e051f},
1090 {0x0000a180, 0x06000601}, 1090 {0x0000a180, 0x06010602},
1091 {0x0000a184, 0x061e061f}, 1091 {0x0000a184, 0x061f0600},
1092 {0x0000a188, 0x0703061d}, 1092 {0x0000a188, 0x061d061e},
1093 {0x0000a18c, 0x07010702}, 1093 {0x0000a18c, 0x07020703},
1094 {0x0000a190, 0x00000700}, 1094 {0x0000a190, 0x07000701},
1095 {0x0000a194, 0x00000000}, 1095 {0x0000a194, 0x00000000},
1096 {0x0000a198, 0x00000000}, 1096 {0x0000a198, 0x00000000},
1097 {0x0000a19c, 0x00000000}, 1097 {0x0000a19c, 0x00000000},
@@ -1317,13 +1317,13 @@ static const u32 ar9300Modes_low_ob_db_tx_gain_table_2p0[][5] = {
1317 {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec}, 1317 {0x0000a5f8, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
1318 {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec}, 1318 {0x0000a5fc, 0x778a308c, 0x778a308c, 0x5d801eec, 0x5d801eec},
1319 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 1319 {0x00016044, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1320 {0x00016048, 0x64001a61, 0x64001a61, 0x64001a61, 0x64001a61}, 1320 {0x00016048, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
1321 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 1321 {0x00016068, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1322 {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 1322 {0x00016444, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1323 {0x00016448, 0x64001a61, 0x64001a61, 0x64001a61, 0x64001a61}, 1323 {0x00016448, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
1324 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 1324 {0x00016468, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1325 {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4}, 1325 {0x00016844, 0x012492d4, 0x012492d4, 0x012492d4, 0x012492d4},
1326 {0x00016848, 0x64001a61, 0x64001a61, 0x64001a61, 0x64001a61}, 1326 {0x00016848, 0x64000001, 0x64000001, 0x64000001, 0x64000001},
1327 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c}, 1327 {0x00016868, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c, 0x6db6db6c},
1328}; 1328};
1329 1329
@@ -1497,22 +1497,22 @@ static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
1497 {0x0000a004, 0x00030002}, 1497 {0x0000a004, 0x00030002},
1498 {0x0000a008, 0x00050004}, 1498 {0x0000a008, 0x00050004},
1499 {0x0000a00c, 0x00810080}, 1499 {0x0000a00c, 0x00810080},
1500 {0x0000a010, 0x01800082}, 1500 {0x0000a010, 0x00830082},
1501 {0x0000a014, 0x01820181}, 1501 {0x0000a014, 0x01810180},
1502 {0x0000a018, 0x01840183}, 1502 {0x0000a018, 0x01830182},
1503 {0x0000a01c, 0x01880185}, 1503 {0x0000a01c, 0x01850184},
1504 {0x0000a020, 0x018a0189}, 1504 {0x0000a020, 0x01890188},
1505 {0x0000a024, 0x02850284}, 1505 {0x0000a024, 0x018b018a},
1506 {0x0000a028, 0x02890288}, 1506 {0x0000a028, 0x018d018c},
1507 {0x0000a02c, 0x03850384}, 1507 {0x0000a02c, 0x03820190},
1508 {0x0000a030, 0x03890388}, 1508 {0x0000a030, 0x03840383},
1509 {0x0000a034, 0x038b038a}, 1509 {0x0000a034, 0x03880385},
1510 {0x0000a038, 0x038d038c}, 1510 {0x0000a038, 0x038a0389},
1511 {0x0000a03c, 0x03910390}, 1511 {0x0000a03c, 0x038c038b},
1512 {0x0000a040, 0x03930392}, 1512 {0x0000a040, 0x0390038d},
1513 {0x0000a044, 0x03950394}, 1513 {0x0000a044, 0x03920391},
1514 {0x0000a048, 0x00000396}, 1514 {0x0000a048, 0x03940393},
1515 {0x0000a04c, 0x00000000}, 1515 {0x0000a04c, 0x03960395},
1516 {0x0000a050, 0x00000000}, 1516 {0x0000a050, 0x00000000},
1517 {0x0000a054, 0x00000000}, 1517 {0x0000a054, 0x00000000},
1518 {0x0000a058, 0x00000000}, 1518 {0x0000a058, 0x00000000},
@@ -1525,15 +1525,15 @@ static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
1525 {0x0000a074, 0x00000000}, 1525 {0x0000a074, 0x00000000},
1526 {0x0000a078, 0x00000000}, 1526 {0x0000a078, 0x00000000},
1527 {0x0000a07c, 0x00000000}, 1527 {0x0000a07c, 0x00000000},
1528 {0x0000a080, 0x28282828}, 1528 {0x0000a080, 0x29292929},
1529 {0x0000a084, 0x28282828}, 1529 {0x0000a084, 0x29292929},
1530 {0x0000a088, 0x28282828}, 1530 {0x0000a088, 0x29292929},
1531 {0x0000a08c, 0x28282828}, 1531 {0x0000a08c, 0x29292929},
1532 {0x0000a090, 0x28282828}, 1532 {0x0000a090, 0x22292929},
1533 {0x0000a094, 0x21212128}, 1533 {0x0000a094, 0x1d1d2222},
1534 {0x0000a098, 0x171c1c1c}, 1534 {0x0000a098, 0x0c111117},
1535 {0x0000a09c, 0x02020212}, 1535 {0x0000a09c, 0x00030303},
1536 {0x0000a0a0, 0x00000202}, 1536 {0x0000a0a0, 0x00000000},
1537 {0x0000a0a4, 0x00000000}, 1537 {0x0000a0a4, 0x00000000},
1538 {0x0000a0a8, 0x00000000}, 1538 {0x0000a0a8, 0x00000000},
1539 {0x0000a0ac, 0x00000000}, 1539 {0x0000a0ac, 0x00000000},
@@ -1542,26 +1542,26 @@ static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
1542 {0x0000a0b8, 0x00000000}, 1542 {0x0000a0b8, 0x00000000},
1543 {0x0000a0bc, 0x00000000}, 1543 {0x0000a0bc, 0x00000000},
1544 {0x0000a0c0, 0x001f0000}, 1544 {0x0000a0c0, 0x001f0000},
1545 {0x0000a0c4, 0x011f0100}, 1545 {0x0000a0c4, 0x01000101},
1546 {0x0000a0c8, 0x011d011e}, 1546 {0x0000a0c8, 0x011e011f},
1547 {0x0000a0cc, 0x011b011c}, 1547 {0x0000a0cc, 0x011c011d},
1548 {0x0000a0d0, 0x02030204}, 1548 {0x0000a0d0, 0x02030204},
1549 {0x0000a0d4, 0x02010202}, 1549 {0x0000a0d4, 0x02010202},
1550 {0x0000a0d8, 0x021f0200}, 1550 {0x0000a0d8, 0x021f0200},
1551 {0x0000a0dc, 0x021d021e}, 1551 {0x0000a0dc, 0x0302021e},
1552 {0x0000a0e0, 0x03010302}, 1552 {0x0000a0e0, 0x03000301},
1553 {0x0000a0e4, 0x031f0300}, 1553 {0x0000a0e4, 0x031e031f},
1554 {0x0000a0e8, 0x0402031e}, 1554 {0x0000a0e8, 0x0402031d},
1555 {0x0000a0ec, 0x04000401}, 1555 {0x0000a0ec, 0x04000401},
1556 {0x0000a0f0, 0x041e041f}, 1556 {0x0000a0f0, 0x041e041f},
1557 {0x0000a0f4, 0x05010502}, 1557 {0x0000a0f4, 0x0502041d},
1558 {0x0000a0f8, 0x051f0500}, 1558 {0x0000a0f8, 0x05000501},
1559 {0x0000a0fc, 0x0602051e}, 1559 {0x0000a0fc, 0x051e051f},
1560 {0x0000a100, 0x06000601}, 1560 {0x0000a100, 0x06010602},
1561 {0x0000a104, 0x061e061f}, 1561 {0x0000a104, 0x061f0600},
1562 {0x0000a108, 0x0703061d}, 1562 {0x0000a108, 0x061d061e},
1563 {0x0000a10c, 0x07010702}, 1563 {0x0000a10c, 0x07020703},
1564 {0x0000a110, 0x00000700}, 1564 {0x0000a110, 0x07000701},
1565 {0x0000a114, 0x00000000}, 1565 {0x0000a114, 0x00000000},
1566 {0x0000a118, 0x00000000}, 1566 {0x0000a118, 0x00000000},
1567 {0x0000a11c, 0x00000000}, 1567 {0x0000a11c, 0x00000000},
@@ -1574,26 +1574,26 @@ static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
1574 {0x0000a138, 0x00000000}, 1574 {0x0000a138, 0x00000000},
1575 {0x0000a13c, 0x00000000}, 1575 {0x0000a13c, 0x00000000},
1576 {0x0000a140, 0x001f0000}, 1576 {0x0000a140, 0x001f0000},
1577 {0x0000a144, 0x011f0100}, 1577 {0x0000a144, 0x01000101},
1578 {0x0000a148, 0x011d011e}, 1578 {0x0000a148, 0x011e011f},
1579 {0x0000a14c, 0x011b011c}, 1579 {0x0000a14c, 0x011c011d},
1580 {0x0000a150, 0x02030204}, 1580 {0x0000a150, 0x02030204},
1581 {0x0000a154, 0x02010202}, 1581 {0x0000a154, 0x02010202},
1582 {0x0000a158, 0x021f0200}, 1582 {0x0000a158, 0x021f0200},
1583 {0x0000a15c, 0x021d021e}, 1583 {0x0000a15c, 0x0302021e},
1584 {0x0000a160, 0x03010302}, 1584 {0x0000a160, 0x03000301},
1585 {0x0000a164, 0x031f0300}, 1585 {0x0000a164, 0x031e031f},
1586 {0x0000a168, 0x0402031e}, 1586 {0x0000a168, 0x0402031d},
1587 {0x0000a16c, 0x04000401}, 1587 {0x0000a16c, 0x04000401},
1588 {0x0000a170, 0x041e041f}, 1588 {0x0000a170, 0x041e041f},
1589 {0x0000a174, 0x05010502}, 1589 {0x0000a174, 0x0502041d},
1590 {0x0000a178, 0x051f0500}, 1590 {0x0000a178, 0x05000501},
1591 {0x0000a17c, 0x0602051e}, 1591 {0x0000a17c, 0x051e051f},
1592 {0x0000a180, 0x06000601}, 1592 {0x0000a180, 0x06010602},
1593 {0x0000a184, 0x061e061f}, 1593 {0x0000a184, 0x061f0600},
1594 {0x0000a188, 0x0703061d}, 1594 {0x0000a188, 0x061d061e},
1595 {0x0000a18c, 0x07010702}, 1595 {0x0000a18c, 0x07020703},
1596 {0x0000a190, 0x00000700}, 1596 {0x0000a190, 0x07000701},
1597 {0x0000a194, 0x00000000}, 1597 {0x0000a194, 0x00000000},
1598 {0x0000a198, 0x00000000}, 1598 {0x0000a198, 0x00000000},
1599 {0x0000a19c, 0x00000000}, 1599 {0x0000a19c, 0x00000000},
@@ -1620,7 +1620,7 @@ static const u32 ar9300Common_wo_xlna_rx_gain_table_2p0[][2] = {
1620 {0x0000a1f0, 0x00000396}, 1620 {0x0000a1f0, 0x00000396},
1621 {0x0000a1f4, 0x00000396}, 1621 {0x0000a1f4, 0x00000396},
1622 {0x0000a1f8, 0x00000396}, 1622 {0x0000a1f8, 0x00000396},
1623 {0x0000a1fc, 0x00000296}, 1623 {0x0000a1fc, 0x00000196},
1624 {0x0000b000, 0x00010000}, 1624 {0x0000b000, 0x00010000},
1625 {0x0000b004, 0x00030002}, 1625 {0x0000b004, 0x00030002},
1626 {0x0000b008, 0x00050004}, 1626 {0x0000b008, 0x00050004},
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c
index 64e30cd45d05..29898f8d1893 100644
--- a/drivers/net/wireless/ath/ath9k/debug.c
+++ b/drivers/net/wireless/ath/ath9k/debug.c
@@ -78,6 +78,90 @@ static const struct file_operations fops_debug = {
78 78
79#define DMA_BUF_LEN 1024 79#define DMA_BUF_LEN 1024
80 80
81static ssize_t read_file_tx_chainmask(struct file *file, char __user *user_buf,
82 size_t count, loff_t *ppos)
83{
84 struct ath_softc *sc = file->private_data;
85 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
86 char buf[32];
87 unsigned int len;
88
89 len = snprintf(buf, sizeof(buf), "0x%08x\n", common->tx_chainmask);
90 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
91}
92
93static ssize_t write_file_tx_chainmask(struct file *file, const char __user *user_buf,
94 size_t count, loff_t *ppos)
95{
96 struct ath_softc *sc = file->private_data;
97 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
98 unsigned long mask;
99 char buf[32];
100 ssize_t len;
101
102 len = min(count, sizeof(buf) - 1);
103 if (copy_from_user(buf, user_buf, len))
104 return -EINVAL;
105
106 buf[len] = '\0';
107 if (strict_strtoul(buf, 0, &mask))
108 return -EINVAL;
109
110 common->tx_chainmask = mask;
111 sc->sc_ah->caps.tx_chainmask = mask;
112 return count;
113}
114
115static const struct file_operations fops_tx_chainmask = {
116 .read = read_file_tx_chainmask,
117 .write = write_file_tx_chainmask,
118 .open = ath9k_debugfs_open,
119 .owner = THIS_MODULE
120};
121
122
123static ssize_t read_file_rx_chainmask(struct file *file, char __user *user_buf,
124 size_t count, loff_t *ppos)
125{
126 struct ath_softc *sc = file->private_data;
127 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
128 char buf[32];
129 unsigned int len;
130
131 len = snprintf(buf, sizeof(buf), "0x%08x\n", common->rx_chainmask);
132 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
133}
134
135static ssize_t write_file_rx_chainmask(struct file *file, const char __user *user_buf,
136 size_t count, loff_t *ppos)
137{
138 struct ath_softc *sc = file->private_data;
139 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
140 unsigned long mask;
141 char buf[32];
142 ssize_t len;
143
144 len = min(count, sizeof(buf) - 1);
145 if (copy_from_user(buf, user_buf, len))
146 return -EINVAL;
147
148 buf[len] = '\0';
149 if (strict_strtoul(buf, 0, &mask))
150 return -EINVAL;
151
152 common->rx_chainmask = mask;
153 sc->sc_ah->caps.rx_chainmask = mask;
154 return count;
155}
156
157static const struct file_operations fops_rx_chainmask = {
158 .read = read_file_rx_chainmask,
159 .write = write_file_rx_chainmask,
160 .open = ath9k_debugfs_open,
161 .owner = THIS_MODULE
162};
163
164
81static ssize_t read_file_dma(struct file *file, char __user *user_buf, 165static ssize_t read_file_dma(struct file *file, char __user *user_buf,
82 size_t count, loff_t *ppos) 166 size_t count, loff_t *ppos)
83{ 167{
@@ -711,6 +795,86 @@ static const struct file_operations fops_recv = {
711 .owner = THIS_MODULE 795 .owner = THIS_MODULE
712}; 796};
713 797
798static ssize_t read_file_regidx(struct file *file, char __user *user_buf,
799 size_t count, loff_t *ppos)
800{
801 struct ath_softc *sc = file->private_data;
802 char buf[32];
803 unsigned int len;
804
805 len = snprintf(buf, sizeof(buf), "0x%08x\n", sc->debug.regidx);
806 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
807}
808
809static ssize_t write_file_regidx(struct file *file, const char __user *user_buf,
810 size_t count, loff_t *ppos)
811{
812 struct ath_softc *sc = file->private_data;
813 unsigned long regidx;
814 char buf[32];
815 ssize_t len;
816
817 len = min(count, sizeof(buf) - 1);
818 if (copy_from_user(buf, user_buf, len))
819 return -EINVAL;
820
821 buf[len] = '\0';
822 if (strict_strtoul(buf, 0, &regidx))
823 return -EINVAL;
824
825 sc->debug.regidx = regidx;
826 return count;
827}
828
829static const struct file_operations fops_regidx = {
830 .read = read_file_regidx,
831 .write = write_file_regidx,
832 .open = ath9k_debugfs_open,
833 .owner = THIS_MODULE
834};
835
836static ssize_t read_file_regval(struct file *file, char __user *user_buf,
837 size_t count, loff_t *ppos)
838{
839 struct ath_softc *sc = file->private_data;
840 struct ath_hw *ah = sc->sc_ah;
841 char buf[32];
842 unsigned int len;
843 u32 regval;
844
845 regval = REG_READ_D(ah, sc->debug.regidx);
846 len = snprintf(buf, sizeof(buf), "0x%08x\n", regval);
847 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
848}
849
850static ssize_t write_file_regval(struct file *file, const char __user *user_buf,
851 size_t count, loff_t *ppos)
852{
853 struct ath_softc *sc = file->private_data;
854 struct ath_hw *ah = sc->sc_ah;
855 unsigned long regval;
856 char buf[32];
857 ssize_t len;
858
859 len = min(count, sizeof(buf) - 1);
860 if (copy_from_user(buf, user_buf, len))
861 return -EINVAL;
862
863 buf[len] = '\0';
864 if (strict_strtoul(buf, 0, &regval))
865 return -EINVAL;
866
867 REG_WRITE_D(ah, sc->debug.regidx, regval);
868 return count;
869}
870
871static const struct file_operations fops_regval = {
872 .read = read_file_regval,
873 .write = write_file_regval,
874 .open = ath9k_debugfs_open,
875 .owner = THIS_MODULE
876};
877
714int ath9k_init_debug(struct ath_hw *ah) 878int ath9k_init_debug(struct ath_hw *ah)
715{ 879{
716 struct ath_common *common = ath9k_hw_common(ah); 880 struct ath_common *common = ath9k_hw_common(ah);
@@ -722,54 +886,55 @@ int ath9k_init_debug(struct ath_hw *ah)
722 sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy), 886 sc->debug.debugfs_phy = debugfs_create_dir(wiphy_name(sc->hw->wiphy),
723 ath9k_debugfs_root); 887 ath9k_debugfs_root);
724 if (!sc->debug.debugfs_phy) 888 if (!sc->debug.debugfs_phy)
725 goto err; 889 return -ENOMEM;
726 890
727#ifdef CONFIG_ATH_DEBUG 891#ifdef CONFIG_ATH_DEBUG
728 sc->debug.debugfs_debug = debugfs_create_file("debug", 892 if (!debugfs_create_file("debug", S_IRUSR | S_IWUSR,
729 S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug); 893 sc->debug.debugfs_phy, sc, &fops_debug))
730 if (!sc->debug.debugfs_debug)
731 goto err; 894 goto err;
732#endif 895#endif
733 896
734 sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUSR, 897 if (!debugfs_create_file("dma", S_IRUSR, sc->debug.debugfs_phy,
735 sc->debug.debugfs_phy, sc, &fops_dma); 898 sc, &fops_dma))
736 if (!sc->debug.debugfs_dma) 899 goto err;
900
901 if (!debugfs_create_file("interrupt", S_IRUSR, sc->debug.debugfs_phy,
902 sc, &fops_interrupt))
903 goto err;
904
905 if (!debugfs_create_file("rcstat", S_IRUSR, sc->debug.debugfs_phy,
906 sc, &fops_rcstat))
907 goto err;
908
909 if (!debugfs_create_file("wiphy", S_IRUSR | S_IWUSR,
910 sc->debug.debugfs_phy, sc, &fops_wiphy))
911 goto err;
912
913 if (!debugfs_create_file("xmit", S_IRUSR, sc->debug.debugfs_phy,
914 sc, &fops_xmit))
737 goto err; 915 goto err;
738 916
739 sc->debug.debugfs_interrupt = debugfs_create_file("interrupt", 917 if (!debugfs_create_file("recv", S_IRUSR, sc->debug.debugfs_phy,
740 S_IRUSR, 918 sc, &fops_recv))
741 sc->debug.debugfs_phy,
742 sc, &fops_interrupt);
743 if (!sc->debug.debugfs_interrupt)
744 goto err; 919 goto err;
745 920
746 sc->debug.debugfs_rcstat = debugfs_create_file("rcstat", 921 if (!debugfs_create_file("rx_chainmask", S_IRUSR | S_IWUSR,
747 S_IRUSR, 922 sc->debug.debugfs_phy, sc, &fops_rx_chainmask))
748 sc->debug.debugfs_phy,
749 sc, &fops_rcstat);
750 if (!sc->debug.debugfs_rcstat)
751 goto err; 923 goto err;
752 924
753 sc->debug.debugfs_wiphy = debugfs_create_file( 925 if (!debugfs_create_file("tx_chainmask", S_IRUSR | S_IWUSR,
754 "wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, 926 sc->debug.debugfs_phy, sc, &fops_tx_chainmask))
755 &fops_wiphy);
756 if (!sc->debug.debugfs_wiphy)
757 goto err; 927 goto err;
758 928
759 sc->debug.debugfs_xmit = debugfs_create_file("xmit", 929 if (!debugfs_create_file("regidx", S_IRUSR | S_IWUSR,
760 S_IRUSR, 930 sc->debug.debugfs_phy, sc, &fops_regidx))
761 sc->debug.debugfs_phy,
762 sc, &fops_xmit);
763 if (!sc->debug.debugfs_xmit)
764 goto err; 931 goto err;
765 932
766 sc->debug.debugfs_recv = debugfs_create_file("recv", 933 if (!debugfs_create_file("regval", S_IRUSR | S_IWUSR,
767 S_IRUSR, 934 sc->debug.debugfs_phy, sc, &fops_regval))
768 sc->debug.debugfs_phy,
769 sc, &fops_recv);
770 if (!sc->debug.debugfs_recv)
771 goto err; 935 goto err;
772 936
937 sc->debug.regidx = 0;
773 return 0; 938 return 0;
774err: 939err:
775 ath9k_exit_debug(ah); 940 ath9k_exit_debug(ah);
@@ -781,14 +946,7 @@ void ath9k_exit_debug(struct ath_hw *ah)
781 struct ath_common *common = ath9k_hw_common(ah); 946 struct ath_common *common = ath9k_hw_common(ah);
782 struct ath_softc *sc = (struct ath_softc *) common->priv; 947 struct ath_softc *sc = (struct ath_softc *) common->priv;
783 948
784 debugfs_remove(sc->debug.debugfs_recv); 949 debugfs_remove_recursive(sc->debug.debugfs_phy);
785 debugfs_remove(sc->debug.debugfs_xmit);
786 debugfs_remove(sc->debug.debugfs_wiphy);
787 debugfs_remove(sc->debug.debugfs_rcstat);
788 debugfs_remove(sc->debug.debugfs_interrupt);
789 debugfs_remove(sc->debug.debugfs_dma);
790 debugfs_remove(sc->debug.debugfs_debug);
791 debugfs_remove(sc->debug.debugfs_phy);
792} 950}
793 951
794int ath9k_debug_create_root(void) 952int ath9k_debug_create_root(void)
diff --git a/drivers/net/wireless/ath/ath9k/debug.h b/drivers/net/wireless/ath/ath9k/debug.h
index c545960e7ec5..5147b8709e10 100644
--- a/drivers/net/wireless/ath/ath9k/debug.h
+++ b/drivers/net/wireless/ath/ath9k/debug.h
@@ -153,13 +153,7 @@ struct ath_stats {
153 153
154struct ath9k_debug { 154struct ath9k_debug {
155 struct dentry *debugfs_phy; 155 struct dentry *debugfs_phy;
156 struct dentry *debugfs_debug; 156 u32 regidx;
157 struct dentry *debugfs_dma;
158 struct dentry *debugfs_interrupt;
159 struct dentry *debugfs_rcstat;
160 struct dentry *debugfs_wiphy;
161 struct dentry *debugfs_xmit;
162 struct dentry *debugfs_recv;
163 struct ath_stats stats; 157 struct ath_stats stats;
164}; 158};
165 159
diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c b/drivers/net/wireless/ath/ath9k/hif_usb.c
index 74872ca76f9a..46dc41a16faa 100644
--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
+++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
@@ -735,6 +735,14 @@ err:
735 return -ENOMEM; 735 return -ENOMEM;
736} 736}
737 737
738static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
739{
740 usb_kill_anchored_urbs(&hif_dev->regout_submitted);
741 ath9k_hif_usb_dealloc_reg_in_urb(hif_dev);
742 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
743 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
744}
745
738static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev) 746static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
739{ 747{
740 int transfer, err; 748 int transfer, err;
@@ -794,14 +802,6 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev,
794 goto err_fw_req; 802 goto err_fw_req;
795 } 803 }
796 804
797 /* Download firmware */
798 ret = ath9k_hif_usb_download_fw(hif_dev);
799 if (ret) {
800 dev_err(&hif_dev->udev->dev,
801 "ath9k_htc: Firmware - %s download failed\n", fw_name);
802 goto err_fw_download;
803 }
804
805 /* Alloc URBs */ 805 /* Alloc URBs */
806 ret = ath9k_hif_usb_alloc_urbs(hif_dev); 806 ret = ath9k_hif_usb_alloc_urbs(hif_dev);
807 if (ret) { 807 if (ret) {
@@ -810,25 +810,25 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev,
810 goto err_urb; 810 goto err_urb;
811 } 811 }
812 812
813 /* Download firmware */
814 ret = ath9k_hif_usb_download_fw(hif_dev);
815 if (ret) {
816 dev_err(&hif_dev->udev->dev,
817 "ath9k_htc: Firmware - %s download failed\n", fw_name);
818 goto err_fw_download;
819 }
820
813 return 0; 821 return 0;
814 822
815err_urb:
816 /* Nothing */
817err_fw_download: 823err_fw_download:
824 ath9k_hif_usb_dealloc_urbs(hif_dev);
825err_urb:
818 release_firmware(hif_dev->firmware); 826 release_firmware(hif_dev->firmware);
819err_fw_req: 827err_fw_req:
820 hif_dev->firmware = NULL; 828 hif_dev->firmware = NULL;
821 return ret; 829 return ret;
822} 830}
823 831
824static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
825{
826 usb_kill_anchored_urbs(&hif_dev->regout_submitted);
827 ath9k_hif_usb_dealloc_reg_in_urb(hif_dev);
828 ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
829 ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
830}
831
832static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev) 832static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev)
833{ 833{
834 ath9k_hif_usb_dealloc_urbs(hif_dev); 834 ath9k_hif_usb_dealloc_urbs(hif_dev);
@@ -859,21 +859,21 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
859#endif 859#endif
860 usb_set_intfdata(interface, hif_dev); 860 usb_set_intfdata(interface, hif_dev);
861 861
862 hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev, &hif_usb,
863 &hif_dev->udev->dev);
864 if (hif_dev->htc_handle == NULL) {
865 ret = -ENOMEM;
866 goto err_htc_hw_alloc;
867 }
868
862 ret = ath9k_hif_usb_dev_init(hif_dev, fw_name); 869 ret = ath9k_hif_usb_dev_init(hif_dev, fw_name);
863 if (ret) { 870 if (ret) {
864 ret = -EINVAL; 871 ret = -EINVAL;
865 goto err_hif_init_usb; 872 goto err_hif_init_usb;
866 } 873 }
867 874
868 hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev); 875 ret = ath9k_htc_hw_init(hif_dev->htc_handle,
869 if (hif_dev->htc_handle == NULL) { 876 &hif_dev->udev->dev, hif_dev->device_id);
870 ret = -ENOMEM;
871 goto err_htc_hw_alloc;
872 }
873
874 ret = ath9k_htc_hw_init(&hif_usb, hif_dev->htc_handle, hif_dev,
875 &hif_dev->udev->dev, hif_dev->device_id,
876 ATH9K_HIF_USB);
877 if (ret) { 877 if (ret) {
878 ret = -EINVAL; 878 ret = -EINVAL;
879 goto err_htc_hw_init; 879 goto err_htc_hw_init;
@@ -884,10 +884,10 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
884 return 0; 884 return 0;
885 885
886err_htc_hw_init: 886err_htc_hw_init:
887 ath9k_htc_hw_free(hif_dev->htc_handle);
888err_htc_hw_alloc:
889 ath9k_hif_usb_dev_deinit(hif_dev); 887 ath9k_hif_usb_dev_deinit(hif_dev);
890err_hif_init_usb: 888err_hif_init_usb:
889 ath9k_htc_hw_free(hif_dev->htc_handle);
890err_htc_hw_alloc:
891 usb_set_intfdata(interface, NULL); 891 usb_set_intfdata(interface, NULL);
892 kfree(hif_dev); 892 kfree(hif_dev);
893 usb_put_dev(udev); 893 usb_put_dev(udev);
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index 17111fc1d2cc..dc015077a8d9 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -81,6 +81,11 @@ static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv)
81{ 81{
82 int time_left; 82 int time_left;
83 83
84 if (atomic_read(&priv->htc->tgt_ready) > 0) {
85 atomic_dec(&priv->htc->tgt_ready);
86 return 0;
87 }
88
84 /* Firmware can take up to 50ms to get ready, to be safe use 1 second */ 89 /* Firmware can take up to 50ms to get ready, to be safe use 1 second */
85 time_left = wait_for_completion_timeout(&priv->htc->target_wait, HZ); 90 time_left = wait_for_completion_timeout(&priv->htc->target_wait, HZ);
86 if (!time_left) { 91 if (!time_left) {
@@ -88,6 +93,8 @@ static int ath9k_htc_wait_for_target(struct ath9k_htc_priv *priv)
88 return -ETIMEDOUT; 93 return -ETIMEDOUT;
89 } 94 }
90 95
96 atomic_dec(&priv->htc->tgt_ready);
97
91 return 0; 98 return 0;
92} 99}
93 100
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 6c386dad1d40..9d371c18eb41 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -1452,6 +1452,8 @@ static void ath9k_htc_sta_notify(struct ieee80211_hw *hw,
1452 struct ath9k_htc_priv *priv = hw->priv; 1452 struct ath9k_htc_priv *priv = hw->priv;
1453 int ret; 1453 int ret;
1454 1454
1455 mutex_lock(&priv->mutex);
1456
1455 switch (cmd) { 1457 switch (cmd) {
1456 case STA_NOTIFY_ADD: 1458 case STA_NOTIFY_ADD:
1457 ret = ath9k_htc_add_station(priv, vif, sta); 1459 ret = ath9k_htc_add_station(priv, vif, sta);
@@ -1464,6 +1466,8 @@ static void ath9k_htc_sta_notify(struct ieee80211_hw *hw,
1464 default: 1466 default:
1465 break; 1467 break;
1466 } 1468 }
1469
1470 mutex_unlock(&priv->mutex);
1467} 1471}
1468 1472
1469static int ath9k_htc_conf_tx(struct ieee80211_hw *hw, u16 queue, 1473static int ath9k_htc_conf_tx(struct ieee80211_hw *hw, u16 queue,
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c b/drivers/net/wireless/ath/ath9k/htc_hst.c
index 7bf6ce1e7e2e..064397fd738e 100644
--- a/drivers/net/wireless/ath/ath9k/htc_hst.c
+++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
@@ -39,7 +39,7 @@ static struct htc_endpoint *get_next_avail_ep(struct htc_endpoint *endpoint)
39{ 39{
40 enum htc_endpoint_id avail_epid; 40 enum htc_endpoint_id avail_epid;
41 41
42 for (avail_epid = ENDPOINT_MAX; avail_epid > ENDPOINT0; avail_epid--) 42 for (avail_epid = (ENDPOINT_MAX - 1); avail_epid > ENDPOINT0; avail_epid--)
43 if (endpoint[avail_epid].service_id == 0) 43 if (endpoint[avail_epid].service_id == 0)
44 return &endpoint[avail_epid]; 44 return &endpoint[avail_epid];
45 return NULL; 45 return NULL;
@@ -95,6 +95,7 @@ static void htc_process_target_rdy(struct htc_target *target,
95 endpoint = &target->endpoint[ENDPOINT0]; 95 endpoint = &target->endpoint[ENDPOINT0];
96 endpoint->service_id = HTC_CTRL_RSVD_SVC; 96 endpoint->service_id = HTC_CTRL_RSVD_SVC;
97 endpoint->max_msglen = HTC_MAX_CONTROL_MESSAGE_LENGTH; 97 endpoint->max_msglen = HTC_MAX_CONTROL_MESSAGE_LENGTH;
98 atomic_inc(&target->tgt_ready);
98 complete(&target->target_wait); 99 complete(&target->target_wait);
99} 100}
100 101
@@ -116,7 +117,7 @@ static void htc_process_conn_rsp(struct htc_target *target,
116 max_msglen = be16_to_cpu(svc_rspmsg->max_msg_len); 117 max_msglen = be16_to_cpu(svc_rspmsg->max_msg_len);
117 endpoint = &target->endpoint[epid]; 118 endpoint = &target->endpoint[epid];
118 119
119 for (tepid = ENDPOINT_MAX; tepid > ENDPOINT0; tepid--) { 120 for (tepid = (ENDPOINT_MAX - 1); tepid > ENDPOINT0; tepid--) {
120 tmp_endpoint = &target->endpoint[tepid]; 121 tmp_endpoint = &target->endpoint[tepid];
121 if (tmp_endpoint->service_id == service_id) { 122 if (tmp_endpoint->service_id == service_id) {
122 tmp_endpoint->service_id = 0; 123 tmp_endpoint->service_id = 0;
@@ -124,7 +125,7 @@ static void htc_process_conn_rsp(struct htc_target *target,
124 } 125 }
125 } 126 }
126 127
127 if (!tmp_endpoint) 128 if (tepid == ENDPOINT0)
128 return; 129 return;
129 130
130 endpoint->service_id = service_id; 131 endpoint->service_id = service_id;
@@ -297,7 +298,7 @@ void htc_stop(struct htc_target *target)
297 enum htc_endpoint_id epid; 298 enum htc_endpoint_id epid;
298 struct htc_endpoint *endpoint; 299 struct htc_endpoint *endpoint;
299 300
300 for (epid = ENDPOINT0; epid <= ENDPOINT_MAX; epid++) { 301 for (epid = ENDPOINT0; epid < ENDPOINT_MAX; epid++) {
301 endpoint = &target->endpoint[epid]; 302 endpoint = &target->endpoint[epid];
302 if (endpoint->service_id != 0) 303 if (endpoint->service_id != 0)
303 target->hif->stop(target->hif_dev, endpoint->ul_pipeid); 304 target->hif->stop(target->hif_dev, endpoint->ul_pipeid);
@@ -309,7 +310,7 @@ void htc_start(struct htc_target *target)
309 enum htc_endpoint_id epid; 310 enum htc_endpoint_id epid;
310 struct htc_endpoint *endpoint; 311 struct htc_endpoint *endpoint;
311 312
312 for (epid = ENDPOINT0; epid <= ENDPOINT_MAX; epid++) { 313 for (epid = ENDPOINT0; epid < ENDPOINT_MAX; epid++) {
313 endpoint = &target->endpoint[epid]; 314 endpoint = &target->endpoint[epid];
314 if (endpoint->service_id != 0) 315 if (endpoint->service_id != 0)
315 target->hif->start(target->hif_dev, 316 target->hif->start(target->hif_dev,
@@ -425,29 +426,19 @@ void ath9k_htc_rx_msg(struct htc_target *htc_handle,
425 } 426 }
426} 427}
427 428
428struct htc_target *ath9k_htc_hw_alloc(void *hif_handle) 429struct htc_target *ath9k_htc_hw_alloc(void *hif_handle,
430 struct ath9k_htc_hif *hif,
431 struct device *dev)
429{ 432{
433 struct htc_endpoint *endpoint;
430 struct htc_target *target; 434 struct htc_target *target;
431 435
432 target = kzalloc(sizeof(struct htc_target), GFP_KERNEL); 436 target = kzalloc(sizeof(struct htc_target), GFP_KERNEL);
433 if (!target) 437 if (!target) {
434 printk(KERN_ERR "Unable to allocate memory for" 438 printk(KERN_ERR "Unable to allocate memory for"
435 "target device\n"); 439 "target device\n");
436 440 return NULL;
437 return target; 441 }
438}
439
440void ath9k_htc_hw_free(struct htc_target *htc)
441{
442 kfree(htc);
443}
444
445int ath9k_htc_hw_init(struct ath9k_htc_hif *hif, struct htc_target *target,
446 void *hif_handle, struct device *dev, u16 devid,
447 enum ath9k_hif_transports transport)
448{
449 struct htc_endpoint *endpoint;
450 int err = 0;
451 442
452 init_completion(&target->target_wait); 443 init_completion(&target->target_wait);
453 init_completion(&target->cmd_wait); 444 init_completion(&target->cmd_wait);
@@ -461,8 +452,20 @@ int ath9k_htc_hw_init(struct ath9k_htc_hif *hif, struct htc_target *target,
461 endpoint->ul_pipeid = hif->control_ul_pipe; 452 endpoint->ul_pipeid = hif->control_ul_pipe;
462 endpoint->dl_pipeid = hif->control_dl_pipe; 453 endpoint->dl_pipeid = hif->control_dl_pipe;
463 454
464 err = ath9k_htc_probe_device(target, dev, devid); 455 atomic_set(&target->tgt_ready, 0);
465 if (err) { 456
457 return target;
458}
459
460void ath9k_htc_hw_free(struct htc_target *htc)
461{
462 kfree(htc);
463}
464
465int ath9k_htc_hw_init(struct htc_target *target,
466 struct device *dev, u16 devid)
467{
468 if (ath9k_htc_probe_device(target, dev, devid)) {
466 printk(KERN_ERR "Failed to initialize the device\n"); 469 printk(KERN_ERR "Failed to initialize the device\n");
467 return -ENODEV; 470 return -ENODEV;
468 } 471 }
diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.h b/drivers/net/wireless/ath/ath9k/htc_hst.h
index ea50ab032d20..faba6790328b 100644
--- a/drivers/net/wireless/ath/ath9k/htc_hst.h
+++ b/drivers/net/wireless/ath/ath9k/htc_hst.h
@@ -123,9 +123,6 @@ struct htc_endpoint {
123#define HTC_CONTROL_BUFFER_SIZE \ 123#define HTC_CONTROL_BUFFER_SIZE \
124 (HTC_MAX_CONTROL_MESSAGE_LENGTH + sizeof(struct htc_frame_hdr)) 124 (HTC_MAX_CONTROL_MESSAGE_LENGTH + sizeof(struct htc_frame_hdr))
125 125
126#define NUM_CONTROL_BUFFERS 8
127#define HST_ENDPOINT_MAX 8
128
129struct htc_control_buf { 126struct htc_control_buf {
130 struct htc_packet htc_pkt; 127 struct htc_packet htc_pkt;
131 u8 buf[HTC_CONTROL_BUFFER_SIZE]; 128 u8 buf[HTC_CONTROL_BUFFER_SIZE];
@@ -139,7 +136,7 @@ struct htc_target {
139 struct ath9k_htc_priv *drv_priv; 136 struct ath9k_htc_priv *drv_priv;
140 struct device *dev; 137 struct device *dev;
141 struct ath9k_htc_hif *hif; 138 struct ath9k_htc_hif *hif;
142 struct htc_endpoint endpoint[HST_ENDPOINT_MAX]; 139 struct htc_endpoint endpoint[ENDPOINT_MAX];
143 struct completion target_wait; 140 struct completion target_wait;
144 struct completion cmd_wait; 141 struct completion cmd_wait;
145 struct list_head list; 142 struct list_head list;
@@ -147,6 +144,7 @@ struct htc_target {
147 u16 credits; 144 u16 credits;
148 u16 credit_size; 145 u16 credit_size;
149 u8 htc_flags; 146 u8 htc_flags;
147 atomic_t tgt_ready;
150}; 148};
151 149
152enum htc_msg_id { 150enum htc_msg_id {
@@ -236,11 +234,12 @@ void ath9k_htc_rx_msg(struct htc_target *htc_handle,
236void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle, 234void ath9k_htc_txcompletion_cb(struct htc_target *htc_handle,
237 struct sk_buff *skb, bool txok); 235 struct sk_buff *skb, bool txok);
238 236
239struct htc_target *ath9k_htc_hw_alloc(void *hif_handle); 237struct htc_target *ath9k_htc_hw_alloc(void *hif_handle,
238 struct ath9k_htc_hif *hif,
239 struct device *dev);
240void ath9k_htc_hw_free(struct htc_target *htc); 240void ath9k_htc_hw_free(struct htc_target *htc);
241int ath9k_htc_hw_init(struct ath9k_htc_hif *hif, struct htc_target *target, 241int ath9k_htc_hw_init(struct htc_target *target,
242 void *hif_handle, struct device *dev, u16 devid, 242 struct device *dev, u16 devid);
243 enum ath9k_hif_transports transport);
244void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug); 243void ath9k_htc_hw_deinit(struct htc_target *target, bool hot_unplug);
245 244
246#endif /* HTC_HST_H */ 245#endif /* HTC_HST_H */
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c
index ac60c4ee62d3..ba139132c85f 100644
--- a/drivers/net/wireless/ath/ath9k/recv.c
+++ b/drivers/net/wireless/ath/ath9k/recv.c
@@ -150,11 +150,9 @@ static bool ath_rx_edma_buf_link(struct ath_softc *sc,
150static void ath_rx_addbuffer_edma(struct ath_softc *sc, 150static void ath_rx_addbuffer_edma(struct ath_softc *sc,
151 enum ath9k_rx_qtype qtype, int size) 151 enum ath9k_rx_qtype qtype, int size)
152{ 152{
153 struct ath_rx_edma *rx_edma;
154 struct ath_common *common = ath9k_hw_common(sc->sc_ah); 153 struct ath_common *common = ath9k_hw_common(sc->sc_ah);
155 u32 nbuf = 0; 154 u32 nbuf = 0;
156 155
157 rx_edma = &sc->rx.rx_edma[qtype];
158 if (list_empty(&sc->rx.rxbuf)) { 156 if (list_empty(&sc->rx.rxbuf)) {
159 ath_print(common, ATH_DBG_QUEUE, "No free rx buf available\n"); 157 ath_print(common, ATH_DBG_QUEUE, "No free rx buf available\n");
160 return; 158 return;
@@ -718,6 +716,7 @@ static bool ath_edma_get_buffers(struct ath_softc *sc,
718 __skb_unlink(skb, &rx_edma->rx_fifo); 716 __skb_unlink(skb, &rx_edma->rx_fifo);
719 list_add_tail(&bf->list, &sc->rx.rxbuf); 717 list_add_tail(&bf->list, &sc->rx.rxbuf);
720 ath_rx_edma_buf_link(sc, qtype); 718 ath_rx_edma_buf_link(sc, qtype);
719 return true;
721 } 720 }
722 skb_queue_tail(&rx_edma->rx_buffers, skb); 721 skb_queue_tail(&rx_edma->rx_buffers, skb);
723 722