aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt61pci.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt61pci.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c241
1 files changed, 141 insertions, 100 deletions
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 987e89009f7..0be147f364e 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -1,5 +1,5 @@
1/* 1/*
2 Copyright (C) 2004 - 2008 rt2x00 SourceForge Project 2 Copyright (C) 2004 - 2009 rt2x00 SourceForge Project
3 <http://rt2x00.serialmonkey.com> 3 <http://rt2x00.serialmonkey.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
@@ -146,12 +146,6 @@ static void rt61pci_rf_write(struct rt2x00_dev *rt2x00dev,
146 mutex_unlock(&rt2x00dev->csr_mutex); 146 mutex_unlock(&rt2x00dev->csr_mutex);
147} 147}
148 148
149#ifdef CONFIG_RT2X00_LIB_LEDS
150/*
151 * This function is only called from rt61pci_led_brightness()
152 * make gcc happy by placing this function inside the
153 * same ifdef statement as the caller.
154 */
155static void rt61pci_mcu_request(struct rt2x00_dev *rt2x00dev, 149static void rt61pci_mcu_request(struct rt2x00_dev *rt2x00dev,
156 const u8 command, const u8 token, 150 const u8 command, const u8 token,
157 const u8 arg0, const u8 arg1) 151 const u8 arg0, const u8 arg1)
@@ -180,7 +174,6 @@ static void rt61pci_mcu_request(struct rt2x00_dev *rt2x00dev,
180 mutex_unlock(&rt2x00dev->csr_mutex); 174 mutex_unlock(&rt2x00dev->csr_mutex);
181 175
182} 176}
183#endif /* CONFIG_RT2X00_LIB_LEDS */
184 177
185static void rt61pci_eepromregister_read(struct eeprom_93cx6 *eeprom) 178static void rt61pci_eepromregister_read(struct eeprom_93cx6 *eeprom)
186{ 179{
@@ -967,6 +960,50 @@ static void rt61pci_config_duration(struct rt2x00_dev *rt2x00dev,
967 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg); 960 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, reg);
968} 961}
969 962
963static void rt61pci_config_ps(struct rt2x00_dev *rt2x00dev,
964 struct rt2x00lib_conf *libconf)
965{
966 enum dev_state state =
967 (libconf->conf->flags & IEEE80211_CONF_PS) ?
968 STATE_SLEEP : STATE_AWAKE;
969 u32 reg;
970
971 if (state == STATE_SLEEP) {
972 rt2x00pci_register_read(rt2x00dev, MAC_CSR11, &reg);
973 rt2x00_set_field32(&reg, MAC_CSR11_DELAY_AFTER_TBCN,
974 libconf->conf->beacon_int - 10);
975 rt2x00_set_field32(&reg, MAC_CSR11_TBCN_BEFORE_WAKEUP,
976 libconf->conf->listen_interval - 1);
977 rt2x00_set_field32(&reg, MAC_CSR11_WAKEUP_LATENCY, 5);
978
979 /* We must first disable autowake before it can be enabled */
980 rt2x00_set_field32(&reg, MAC_CSR11_AUTOWAKE, 0);
981 rt2x00pci_register_write(rt2x00dev, MAC_CSR11, reg);
982
983 rt2x00_set_field32(&reg, MAC_CSR11_AUTOWAKE, 1);
984 rt2x00pci_register_write(rt2x00dev, MAC_CSR11, reg);
985
986 rt2x00pci_register_write(rt2x00dev, SOFT_RESET_CSR, 0x00000005);
987 rt2x00pci_register_write(rt2x00dev, IO_CNTL_CSR, 0x0000001c);
988 rt2x00pci_register_write(rt2x00dev, PCI_USEC_CSR, 0x00000060);
989
990 rt61pci_mcu_request(rt2x00dev, MCU_SLEEP, 0xff, 0, 0);
991 } else {
992 rt2x00pci_register_read(rt2x00dev, MAC_CSR11, &reg);
993 rt2x00_set_field32(&reg, MAC_CSR11_DELAY_AFTER_TBCN, 0);
994 rt2x00_set_field32(&reg, MAC_CSR11_TBCN_BEFORE_WAKEUP, 0);
995 rt2x00_set_field32(&reg, MAC_CSR11_AUTOWAKE, 0);
996 rt2x00_set_field32(&reg, MAC_CSR11_WAKEUP_LATENCY, 0);
997 rt2x00pci_register_write(rt2x00dev, MAC_CSR11, reg);
998
999 rt2x00pci_register_write(rt2x00dev, SOFT_RESET_CSR, 0x00000007);
1000 rt2x00pci_register_write(rt2x00dev, IO_CNTL_CSR, 0x00000018);
1001 rt2x00pci_register_write(rt2x00dev, PCI_USEC_CSR, 0x00000020);
1002
1003 rt61pci_mcu_request(rt2x00dev, MCU_WAKEUP, 0xff, 0, 0);
1004 }
1005}
1006
970static void rt61pci_config(struct rt2x00_dev *rt2x00dev, 1007static void rt61pci_config(struct rt2x00_dev *rt2x00dev,
971 struct rt2x00lib_conf *libconf, 1008 struct rt2x00lib_conf *libconf,
972 const unsigned int flags) 1009 const unsigned int flags)
@@ -984,6 +1021,8 @@ static void rt61pci_config(struct rt2x00_dev *rt2x00dev,
984 rt61pci_config_retry_limit(rt2x00dev, libconf); 1021 rt61pci_config_retry_limit(rt2x00dev, libconf);
985 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL) 1022 if (flags & IEEE80211_CONF_CHANGE_BEACON_INTERVAL)
986 rt61pci_config_duration(rt2x00dev, libconf); 1023 rt61pci_config_duration(rt2x00dev, libconf);
1024 if (flags & IEEE80211_CONF_CHANGE_PS)
1025 rt61pci_config_ps(rt2x00dev, libconf);
987} 1026}
988 1027
989/* 1028/*
@@ -1007,21 +1046,28 @@ static void rt61pci_link_stats(struct rt2x00_dev *rt2x00dev,
1007 qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR); 1046 qual->false_cca = rt2x00_get_field32(reg, STA_CSR1_FALSE_CCA_ERROR);
1008} 1047}
1009 1048
1010static void rt61pci_reset_tuner(struct rt2x00_dev *rt2x00dev) 1049static inline void rt61pci_set_vgc(struct rt2x00_dev *rt2x00dev,
1050 struct link_qual *qual, u8 vgc_level)
1011{ 1051{
1012 rt61pci_bbp_write(rt2x00dev, 17, 0x20); 1052 if (qual->vgc_level != vgc_level) {
1013 rt2x00dev->link.vgc_level = 0x20; 1053 rt61pci_bbp_write(rt2x00dev, 17, vgc_level);
1054 qual->vgc_level = vgc_level;
1055 qual->vgc_level_reg = vgc_level;
1056 }
1057}
1058
1059static void rt61pci_reset_tuner(struct rt2x00_dev *rt2x00dev,
1060 struct link_qual *qual)
1061{
1062 rt61pci_set_vgc(rt2x00dev, qual, 0x20);
1014} 1063}
1015 1064
1016static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev) 1065static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev,
1066 struct link_qual *qual, const u32 count)
1017{ 1067{
1018 int rssi = rt2x00_get_link_rssi(&rt2x00dev->link);
1019 u8 r17;
1020 u8 up_bound; 1068 u8 up_bound;
1021 u8 low_bound; 1069 u8 low_bound;
1022 1070
1023 rt61pci_bbp_read(rt2x00dev, 17, &r17);
1024
1025 /* 1071 /*
1026 * Determine r17 bounds. 1072 * Determine r17 bounds.
1027 */ 1073 */
@@ -1051,38 +1097,32 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
1051 /* 1097 /*
1052 * Special big-R17 for very short distance 1098 * Special big-R17 for very short distance
1053 */ 1099 */
1054 if (rssi >= -35) { 1100 if (qual->rssi >= -35) {
1055 if (r17 != 0x60) 1101 rt61pci_set_vgc(rt2x00dev, qual, 0x60);
1056 rt61pci_bbp_write(rt2x00dev, 17, 0x60);
1057 return; 1102 return;
1058 } 1103 }
1059 1104
1060 /* 1105 /*
1061 * Special big-R17 for short distance 1106 * Special big-R17 for short distance
1062 */ 1107 */
1063 if (rssi >= -58) { 1108 if (qual->rssi >= -58) {
1064 if (r17 != up_bound) 1109 rt61pci_set_vgc(rt2x00dev, qual, up_bound);
1065 rt61pci_bbp_write(rt2x00dev, 17, up_bound);
1066 return; 1110 return;
1067 } 1111 }
1068 1112
1069 /* 1113 /*
1070 * Special big-R17 for middle-short distance 1114 * Special big-R17 for middle-short distance
1071 */ 1115 */
1072 if (rssi >= -66) { 1116 if (qual->rssi >= -66) {
1073 low_bound += 0x10; 1117 rt61pci_set_vgc(rt2x00dev, qual, low_bound + 0x10);
1074 if (r17 != low_bound)
1075 rt61pci_bbp_write(rt2x00dev, 17, low_bound);
1076 return; 1118 return;
1077 } 1119 }
1078 1120
1079 /* 1121 /*
1080 * Special mid-R17 for middle distance 1122 * Special mid-R17 for middle distance
1081 */ 1123 */
1082 if (rssi >= -74) { 1124 if (qual->rssi >= -74) {
1083 low_bound += 0x08; 1125 rt61pci_set_vgc(rt2x00dev, qual, low_bound + 0x08);
1084 if (r17 != low_bound)
1085 rt61pci_bbp_write(rt2x00dev, 17, low_bound);
1086 return; 1126 return;
1087 } 1127 }
1088 1128
@@ -1090,12 +1130,12 @@ static void rt61pci_link_tuner(struct rt2x00_dev *rt2x00dev)
1090 * Special case: Change up_bound based on the rssi. 1130 * Special case: Change up_bound based on the rssi.
1091 * Lower up_bound when rssi is weaker then -74 dBm. 1131 * Lower up_bound when rssi is weaker then -74 dBm.
1092 */ 1132 */
1093 up_bound -= 2 * (-74 - rssi); 1133 up_bound -= 2 * (-74 - qual->rssi);
1094 if (low_bound > up_bound) 1134 if (low_bound > up_bound)
1095 up_bound = low_bound; 1135 up_bound = low_bound;
1096 1136
1097 if (r17 > up_bound) { 1137 if (qual->vgc_level > up_bound) {
1098 rt61pci_bbp_write(rt2x00dev, 17, up_bound); 1138 rt61pci_set_vgc(rt2x00dev, qual, up_bound);
1099 return; 1139 return;
1100 } 1140 }
1101 1141
@@ -1105,15 +1145,10 @@ dynamic_cca_tune:
1105 * r17 does not yet exceed upper limit, continue and base 1145 * r17 does not yet exceed upper limit, continue and base
1106 * the r17 tuning on the false CCA count. 1146 * the r17 tuning on the false CCA count.
1107 */ 1147 */
1108 if (rt2x00dev->link.qual.false_cca > 512 && r17 < up_bound) { 1148 if ((qual->false_cca > 512) && (qual->vgc_level < up_bound))
1109 if (++r17 > up_bound) 1149 rt61pci_set_vgc(rt2x00dev, qual, ++qual->vgc_level);
1110 r17 = up_bound; 1150 else if ((qual->false_cca < 100) && (qual->vgc_level > low_bound))
1111 rt61pci_bbp_write(rt2x00dev, 17, r17); 1151 rt61pci_set_vgc(rt2x00dev, qual, --qual->vgc_level);
1112 } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > low_bound) {
1113 if (--r17 < low_bound)
1114 r17 = low_bound;
1115 rt61pci_bbp_write(rt2x00dev, 17, r17);
1116 }
1117} 1152}
1118 1153
1119/* 1154/*
@@ -1141,25 +1176,37 @@ static char *rt61pci_get_firmware_name(struct rt2x00_dev *rt2x00dev)
1141 return fw_name; 1176 return fw_name;
1142} 1177}
1143 1178
1144static u16 rt61pci_get_firmware_crc(const void *data, const size_t len) 1179static int rt61pci_check_firmware(struct rt2x00_dev *rt2x00dev,
1180 const u8 *data, const size_t len)
1145{ 1181{
1182 u16 fw_crc;
1146 u16 crc; 1183 u16 crc;
1147 1184
1148 /* 1185 /*
1149 * Use the crc itu-t algorithm. 1186 * Only support 8kb firmware files.
1187 */
1188 if (len != 8192)
1189 return FW_BAD_LENGTH;
1190
1191 /*
1150 * The last 2 bytes in the firmware array are the crc checksum itself, 1192 * The last 2 bytes in the firmware array are the crc checksum itself,
1151 * this means that we should never pass those 2 bytes to the crc 1193 * this means that we should never pass those 2 bytes to the crc
1152 * algorithm. 1194 * algorithm.
1153 */ 1195 */
1196 fw_crc = (data[len - 2] << 8 | data[len - 1]);
1197
1198 /*
1199 * Use the crc itu-t algorithm.
1200 */
1154 crc = crc_itu_t(0, data, len - 2); 1201 crc = crc_itu_t(0, data, len - 2);
1155 crc = crc_itu_t_byte(crc, 0); 1202 crc = crc_itu_t_byte(crc, 0);
1156 crc = crc_itu_t_byte(crc, 0); 1203 crc = crc_itu_t_byte(crc, 0);
1157 1204
1158 return crc; 1205 return (fw_crc == crc) ? FW_OK : FW_BAD_CRC;
1159} 1206}
1160 1207
1161static int rt61pci_load_firmware(struct rt2x00_dev *rt2x00dev, const void *data, 1208static int rt61pci_load_firmware(struct rt2x00_dev *rt2x00dev,
1162 const size_t len) 1209 const u8 *data, const size_t len)
1163{ 1210{
1164 int i; 1211 int i;
1165 u32 reg; 1212 u32 reg;
@@ -1656,24 +1703,10 @@ static int rt61pci_enable_radio(struct rt2x00_dev *rt2x00dev)
1656 1703
1657static void rt61pci_disable_radio(struct rt2x00_dev *rt2x00dev) 1704static void rt61pci_disable_radio(struct rt2x00_dev *rt2x00dev)
1658{ 1705{
1659 u32 reg;
1660
1661 rt2x00pci_register_write(rt2x00dev, MAC_CSR10, 0x00001818);
1662
1663 /*
1664 * Disable synchronisation.
1665 */
1666 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, 0);
1667
1668 /* 1706 /*
1669 * Cancel RX and TX. 1707 * Disable power
1670 */ 1708 */
1671 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg); 1709 rt2x00pci_register_write(rt2x00dev, MAC_CSR10, 0x00001818);
1672 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC0, 1);
1673 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC1, 1);
1674 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC2, 1);
1675 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC3, 1);
1676 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1677} 1710}
1678 1711
1679static int rt61pci_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state) 1712static int rt61pci_set_state(struct rt2x00_dev *rt2x00dev, enum dev_state state)
@@ -1812,7 +1845,7 @@ static void rt61pci_write_tx_desc(struct rt2x00_dev *rt2x00dev,
1812 rt2x00_set_field32(&word, TXD_W0_TIMESTAMP, 1845 rt2x00_set_field32(&word, TXD_W0_TIMESTAMP,
1813 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags)); 1846 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
1814 rt2x00_set_field32(&word, TXD_W0_OFDM, 1847 rt2x00_set_field32(&word, TXD_W0_OFDM,
1815 test_bit(ENTRY_TXD_OFDM_RATE, &txdesc->flags)); 1848 (txdesc->rate_mode == RATE_MODE_OFDM));
1816 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs); 1849 rt2x00_set_field32(&word, TXD_W0_IFS, txdesc->ifs);
1817 rt2x00_set_field32(&word, TXD_W0_RETRY_MODE, 1850 rt2x00_set_field32(&word, TXD_W0_RETRY_MODE,
1818 test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags)); 1851 test_bit(ENTRY_TXD_RETRY_MODE, &txdesc->flags));
@@ -1896,6 +1929,24 @@ static void rt61pci_kick_tx_queue(struct rt2x00_dev *rt2x00dev,
1896 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg); 1929 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1897} 1930}
1898 1931
1932static void rt61pci_kill_tx_queue(struct rt2x00_dev *rt2x00dev,
1933 const enum data_queue_qid qid)
1934{
1935 u32 reg;
1936
1937 if (qid == QID_BEACON) {
1938 rt2x00pci_register_write(rt2x00dev, TXRX_CSR9, 0);
1939 return;
1940 }
1941
1942 rt2x00pci_register_read(rt2x00dev, TX_CNTL_CSR, &reg);
1943 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC0, (qid == QID_AC_BE));
1944 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC1, (qid == QID_AC_BK));
1945 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC2, (qid == QID_AC_VI));
1946 rt2x00_set_field32(&reg, TX_CNTL_CSR_ABORT_TX_AC3, (qid == QID_AC_VO));
1947 rt2x00pci_register_write(rt2x00dev, TX_CNTL_CSR, reg);
1948}
1949
1899/* 1950/*
1900 * RX control handlers 1951 * RX control handlers
1901 */ 1952 */
@@ -2195,7 +2246,8 @@ static int rt61pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
2195 if (word == 0xffff) { 2246 if (word == 0xffff) {
2196 rt2x00_set_field16(&word, EEPROM_NIC_ENABLE_DIVERSITY, 0); 2247 rt2x00_set_field16(&word, EEPROM_NIC_ENABLE_DIVERSITY, 0);
2197 rt2x00_set_field16(&word, EEPROM_NIC_TX_DIVERSITY, 0); 2248 rt2x00_set_field16(&word, EEPROM_NIC_TX_DIVERSITY, 0);
2198 rt2x00_set_field16(&word, EEPROM_NIC_TX_RX_FIXED, 0); 2249 rt2x00_set_field16(&word, EEPROM_NIC_RX_FIXED, 0);
2250 rt2x00_set_field16(&word, EEPROM_NIC_TX_FIXED, 0);
2199 rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_BG, 0); 2251 rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_BG, 0);
2200 rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0); 2252 rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0);
2201 rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_A, 0); 2253 rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_A, 0);
@@ -2339,24 +2391,10 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
2339 */ 2391 */
2340 if (rt2x00_rf(&rt2x00dev->chip, RF2529) && 2392 if (rt2x00_rf(&rt2x00dev->chip, RF2529) &&
2341 !test_bit(CONFIG_DOUBLE_ANTENNA, &rt2x00dev->flags)) { 2393 !test_bit(CONFIG_DOUBLE_ANTENNA, &rt2x00dev->flags)) {
2342 switch (rt2x00_get_field16(eeprom, EEPROM_NIC_TX_RX_FIXED)) { 2394 rt2x00dev->default_ant.rx =
2343 case 0: 2395 ANTENNA_A + rt2x00_get_field16(eeprom, EEPROM_NIC_RX_FIXED);
2344 rt2x00dev->default_ant.tx = ANTENNA_B; 2396 rt2x00dev->default_ant.tx =
2345 rt2x00dev->default_ant.rx = ANTENNA_A; 2397 ANTENNA_B - rt2x00_get_field16(eeprom, EEPROM_NIC_TX_FIXED);
2346 break;
2347 case 1:
2348 rt2x00dev->default_ant.tx = ANTENNA_B;
2349 rt2x00dev->default_ant.rx = ANTENNA_B;
2350 break;
2351 case 2:
2352 rt2x00dev->default_ant.tx = ANTENNA_A;
2353 rt2x00dev->default_ant.rx = ANTENNA_A;
2354 break;
2355 case 3:
2356 rt2x00dev->default_ant.tx = ANTENNA_A;
2357 rt2x00dev->default_ant.rx = ANTENNA_B;
2358 break;
2359 }
2360 2398
2361 if (rt2x00_get_field16(eeprom, EEPROM_NIC_TX_DIVERSITY)) 2399 if (rt2x00_get_field16(eeprom, EEPROM_NIC_TX_DIVERSITY))
2362 rt2x00dev->default_ant.tx = ANTENNA_SW_DIVERSITY; 2400 rt2x00dev->default_ant.tx = ANTENNA_SW_DIVERSITY;
@@ -2534,7 +2572,9 @@ static int rt61pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
2534 */ 2572 */
2535 rt2x00dev->hw->flags = 2573 rt2x00dev->hw->flags =
2536 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 2574 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
2537 IEEE80211_HW_SIGNAL_DBM; 2575 IEEE80211_HW_SIGNAL_DBM |
2576 IEEE80211_HW_SUPPORTS_PS |
2577 IEEE80211_HW_PS_NULLFUNC_STACK;
2538 rt2x00dev->hw->extra_tx_headroom = 0; 2578 rt2x00dev->hw->extra_tx_headroom = 0;
2539 2579
2540 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); 2580 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
@@ -2633,6 +2673,7 @@ static int rt61pci_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
2633 struct rt2x00_field32 field; 2673 struct rt2x00_field32 field;
2634 int retval; 2674 int retval;
2635 u32 reg; 2675 u32 reg;
2676 u32 offset;
2636 2677
2637 /* 2678 /*
2638 * First pass the configuration through rt2x00lib, that will 2679 * First pass the configuration through rt2x00lib, that will
@@ -2644,24 +2685,23 @@ static int rt61pci_conf_tx(struct ieee80211_hw *hw, u16 queue_idx,
2644 if (retval) 2685 if (retval)
2645 return retval; 2686 return retval;
2646 2687
2688 /*
2689 * We only need to perform additional register initialization
2690 * for WMM queues/
2691 */
2692 if (queue_idx >= 4)
2693 return 0;
2694
2647 queue = rt2x00queue_get_queue(rt2x00dev, queue_idx); 2695 queue = rt2x00queue_get_queue(rt2x00dev, queue_idx);
2648 2696
2649 /* Update WMM TXOP register */ 2697 /* Update WMM TXOP register */
2650 if (queue_idx < 2) { 2698 offset = AC_TXOP_CSR0 + (sizeof(u32) * (!!(queue_idx & 2)));
2651 field.bit_offset = queue_idx * 16; 2699 field.bit_offset = (queue_idx & 1) * 16;
2652 field.bit_mask = 0xffff << field.bit_offset; 2700 field.bit_mask = 0xffff << field.bit_offset;
2653 2701
2654 rt2x00pci_register_read(rt2x00dev, AC_TXOP_CSR0, &reg); 2702 rt2x00pci_register_read(rt2x00dev, offset, &reg);
2655 rt2x00_set_field32(&reg, field, queue->txop); 2703 rt2x00_set_field32(&reg, field, queue->txop);
2656 rt2x00pci_register_write(rt2x00dev, AC_TXOP_CSR0, reg); 2704 rt2x00pci_register_write(rt2x00dev, offset, reg);
2657 } else if (queue_idx < 4) {
2658 field.bit_offset = (queue_idx - 2) * 16;
2659 field.bit_mask = 0xffff << field.bit_offset;
2660
2661 rt2x00pci_register_read(rt2x00dev, AC_TXOP_CSR1, &reg);
2662 rt2x00_set_field32(&reg, field, queue->txop);
2663 rt2x00pci_register_write(rt2x00dev, AC_TXOP_CSR1, reg);
2664 }
2665 2705
2666 /* Update WMM registers */ 2706 /* Update WMM registers */
2667 field.bit_offset = queue_idx * 4; 2707 field.bit_offset = queue_idx * 4;
@@ -2717,7 +2757,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2717 .irq_handler = rt61pci_interrupt, 2757 .irq_handler = rt61pci_interrupt,
2718 .probe_hw = rt61pci_probe_hw, 2758 .probe_hw = rt61pci_probe_hw,
2719 .get_firmware_name = rt61pci_get_firmware_name, 2759 .get_firmware_name = rt61pci_get_firmware_name,
2720 .get_firmware_crc = rt61pci_get_firmware_crc, 2760 .check_firmware = rt61pci_check_firmware,
2721 .load_firmware = rt61pci_load_firmware, 2761 .load_firmware = rt61pci_load_firmware,
2722 .initialize = rt2x00pci_initialize, 2762 .initialize = rt2x00pci_initialize,
2723 .uninitialize = rt2x00pci_uninitialize, 2763 .uninitialize = rt2x00pci_uninitialize,
@@ -2732,6 +2772,7 @@ static const struct rt2x00lib_ops rt61pci_rt2x00_ops = {
2732 .write_tx_data = rt2x00pci_write_tx_data, 2772 .write_tx_data = rt2x00pci_write_tx_data,
2733 .write_beacon = rt61pci_write_beacon, 2773 .write_beacon = rt61pci_write_beacon,
2734 .kick_tx_queue = rt61pci_kick_tx_queue, 2774 .kick_tx_queue = rt61pci_kick_tx_queue,
2775 .kill_tx_queue = rt61pci_kill_tx_queue,
2735 .fill_rxdone = rt61pci_fill_rxdone, 2776 .fill_rxdone = rt61pci_fill_rxdone,
2736 .config_shared_key = rt61pci_config_shared_key, 2777 .config_shared_key = rt61pci_config_shared_key,
2737 .config_pairwise_key = rt61pci_config_pairwise_key, 2778 .config_pairwise_key = rt61pci_config_pairwise_key,