aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2800lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800lib.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c135
1 files changed, 82 insertions, 53 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 6331c61957a3..5cd096e2ae36 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -730,34 +730,20 @@ void rt2800_txdone(struct rt2x00_dev *rt2x00dev)
730 struct data_queue *queue; 730 struct data_queue *queue;
731 struct queue_entry *entry; 731 struct queue_entry *entry;
732 u32 reg; 732 u32 reg;
733 u8 pid; 733 u8 qid;
734 int i;
735 734
736 /* 735 while (kfifo_get(&rt2x00dev->txstatus_fifo, &reg)) {
737 * TX_STA_FIFO is a stack of X entries, hence read TX_STA_FIFO
738 * at most X times and also stop processing once the TX_STA_FIFO_VALID
739 * flag is not set anymore.
740 *
741 * The legacy drivers use X=TX_RING_SIZE but state in a comment
742 * that the TX_STA_FIFO stack has a size of 16. We stick to our
743 * tx ring size for now.
744 */
745 for (i = 0; i < rt2x00dev->ops->tx->entry_num; i++) {
746 rt2800_register_read(rt2x00dev, TX_STA_FIFO, &reg);
747 if (!rt2x00_get_field32(reg, TX_STA_FIFO_VALID))
748 break;
749 736
750 /* 737 /* TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus
751 * Skip this entry when it contains an invalid 738 * qid is guaranteed to be one of the TX QIDs
752 * queue identication number.
753 */ 739 */
754 pid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_QUEUE); 740 qid = rt2x00_get_field32(reg, TX_STA_FIFO_PID_QUEUE);
755 if (pid >= QID_RX) 741 queue = rt2x00queue_get_tx_queue(rt2x00dev, qid);
756 continue; 742 if (unlikely(!queue)) {
757 743 WARNING(rt2x00dev, "Got TX status for an unavailable "
758 queue = rt2x00queue_get_tx_queue(rt2x00dev, pid); 744 "queue %u, dropping\n", qid);
759 if (unlikely(!queue))
760 continue; 745 continue;
746 }
761 747
762 /* 748 /*
763 * Inside each queue, we process each entry in a chronological 749 * Inside each queue, we process each entry in a chronological
@@ -949,25 +935,49 @@ static void rt2800_brightness_set(struct led_classdev *led_cdev,
949 unsigned int ledmode = 935 unsigned int ledmode =
950 rt2x00_get_field16(led->rt2x00dev->led_mcu_reg, 936 rt2x00_get_field16(led->rt2x00dev->led_mcu_reg,
951 EEPROM_FREQ_LED_MODE); 937 EEPROM_FREQ_LED_MODE);
938 u32 reg;
952 939
953 if (led->type == LED_TYPE_RADIO) { 940 /* Check for SoC (SOC devices don't support MCU requests) */
954 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode, 941 if (rt2x00_is_soc(led->rt2x00dev)) {
955 enabled ? 0x20 : 0); 942 rt2800_register_read(led->rt2x00dev, LED_CFG, &reg);
956 } else if (led->type == LED_TYPE_ASSOC) { 943
957 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode, 944 /* Set LED Polarity */
958 enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20); 945 rt2x00_set_field32(&reg, LED_CFG_LED_POLAR, polarity);
959 } else if (led->type == LED_TYPE_QUALITY) { 946
960 /* 947 /* Set LED Mode */
961 * The brightness is divided into 6 levels (0 - 5), 948 if (led->type == LED_TYPE_RADIO) {
962 * The specs tell us the following levels: 949 rt2x00_set_field32(&reg, LED_CFG_G_LED_MODE,
963 * 0, 1 ,3, 7, 15, 31 950 enabled ? 3 : 0);
964 * to determine the level in a simple way we can simply 951 } else if (led->type == LED_TYPE_ASSOC) {
965 * work with bitshifting: 952 rt2x00_set_field32(&reg, LED_CFG_Y_LED_MODE,
966 * (1 << level) - 1 953 enabled ? 3 : 0);
967 */ 954 } else if (led->type == LED_TYPE_QUALITY) {
968 rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff, 955 rt2x00_set_field32(&reg, LED_CFG_R_LED_MODE,
969 (1 << brightness / (LED_FULL / 6)) - 1, 956 enabled ? 3 : 0);
970 polarity); 957 }
958
959 rt2800_register_write(led->rt2x00dev, LED_CFG, reg);
960
961 } else {
962 if (led->type == LED_TYPE_RADIO) {
963 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
964 enabled ? 0x20 : 0);
965 } else if (led->type == LED_TYPE_ASSOC) {
966 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
967 enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20);
968 } else if (led->type == LED_TYPE_QUALITY) {
969 /*
970 * The brightness is divided into 6 levels (0 - 5),
971 * The specs tell us the following levels:
972 * 0, 1 ,3, 7, 15, 31
973 * to determine the level in a simple way we can simply
974 * work with bitshifting:
975 * (1 << level) - 1
976 */
977 rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff,
978 (1 << brightness / (LED_FULL / 6)) - 1,
979 polarity);
980 }
971 } 981 }
972} 982}
973 983
@@ -1221,6 +1231,25 @@ void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf,
1221 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg); 1231 rt2800_register_read(rt2x00dev, BCN_TIME_CFG, &reg);
1222 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_SYNC, conf->sync); 1232 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_SYNC, conf->sync);
1223 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); 1233 rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
1234
1235 if (conf->sync == TSF_SYNC_AP_NONE) {
1236 /*
1237 * Tune beacon queue transmit parameters for AP mode
1238 */
1239 rt2800_register_read(rt2x00dev, TBTT_SYNC_CFG, &reg);
1240 rt2x00_set_field32(&reg, TBTT_SYNC_CFG_BCN_CWMIN, 0);
1241 rt2x00_set_field32(&reg, TBTT_SYNC_CFG_BCN_AIFSN, 1);
1242 rt2x00_set_field32(&reg, TBTT_SYNC_CFG_BCN_EXP_WIN, 32);
1243 rt2x00_set_field32(&reg, TBTT_SYNC_CFG_TBTT_ADJUST, 0);
1244 rt2800_register_write(rt2x00dev, TBTT_SYNC_CFG, reg);
1245 } else {
1246 rt2800_register_read(rt2x00dev, TBTT_SYNC_CFG, &reg);
1247 rt2x00_set_field32(&reg, TBTT_SYNC_CFG_BCN_CWMIN, 4);
1248 rt2x00_set_field32(&reg, TBTT_SYNC_CFG_BCN_AIFSN, 2);
1249 rt2x00_set_field32(&reg, TBTT_SYNC_CFG_BCN_EXP_WIN, 32);
1250 rt2x00_set_field32(&reg, TBTT_SYNC_CFG_TBTT_ADJUST, 16);
1251 rt2800_register_write(rt2x00dev, TBTT_SYNC_CFG, reg);
1252 }
1224 } 1253 }
1225 1254
1226 if (flags & CONFIG_UPDATE_MAC) { 1255 if (flags & CONFIG_UPDATE_MAC) {
@@ -1739,8 +1768,8 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
1739 1768
1740 if (rf->channel <= 14) { 1769 if (rf->channel <= 14) {
1741 if (!rt2x00_rt(rt2x00dev, RT5390)) { 1770 if (!rt2x00_rt(rt2x00dev, RT5390)) {
1742 if (test_bit(CONFIG_EXTERNAL_LNA_BG, 1771 if (test_bit(CAPABILITY_EXTERNAL_LNA_BG,
1743 &rt2x00dev->flags)) { 1772 &rt2x00dev->cap_flags)) {
1744 rt2800_bbp_write(rt2x00dev, 82, 0x62); 1773 rt2800_bbp_write(rt2x00dev, 82, 0x62);
1745 rt2800_bbp_write(rt2x00dev, 75, 0x46); 1774 rt2800_bbp_write(rt2x00dev, 75, 0x46);
1746 } else { 1775 } else {
@@ -1751,7 +1780,7 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
1751 } else { 1780 } else {
1752 rt2800_bbp_write(rt2x00dev, 82, 0xf2); 1781 rt2800_bbp_write(rt2x00dev, 82, 0xf2);
1753 1782
1754 if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags)) 1783 if (test_bit(CAPABILITY_EXTERNAL_LNA_A, &rt2x00dev->cap_flags))
1755 rt2800_bbp_write(rt2x00dev, 75, 0x46); 1784 rt2800_bbp_write(rt2x00dev, 75, 0x46);
1756 else 1785 else
1757 rt2800_bbp_write(rt2x00dev, 75, 0x50); 1786 rt2800_bbp_write(rt2x00dev, 75, 0x50);
@@ -1984,7 +2013,7 @@ static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b,
1984 if (!((band == IEEE80211_BAND_5GHZ) && is_rate_b)) 2013 if (!((band == IEEE80211_BAND_5GHZ) && is_rate_b))
1985 return txpower; 2014 return txpower;
1986 2015
1987 if (test_bit(CONFIG_SUPPORT_POWER_LIMIT, &rt2x00dev->flags)) { 2016 if (test_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags)) {
1988 /* 2017 /*
1989 * Check if eirp txpower exceed txpower_limit. 2018 * Check if eirp txpower exceed txpower_limit.
1990 * We use OFDM 6M as criterion and its eirp txpower 2019 * We use OFDM 6M as criterion and its eirp txpower
@@ -2384,7 +2413,7 @@ static int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
2384 } else if (rt2800_is_305x_soc(rt2x00dev)) { 2413 } else if (rt2800_is_305x_soc(rt2x00dev)) {
2385 rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400); 2414 rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400);
2386 rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000); 2415 rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000);
2387 rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x0000001f); 2416 rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000030);
2388 } else if (rt2x00_rt(rt2x00dev, RT5390)) { 2417 } else if (rt2x00_rt(rt2x00dev, RT5390)) {
2389 rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404); 2418 rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000404);
2390 rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606); 2419 rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606);
@@ -3285,8 +3314,8 @@ static int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
3285 rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) || 3314 rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
3286 rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) || 3315 rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) ||
3287 rt2x00_rt_rev_lt(rt2x00dev, RT3390, REV_RT3390E)) { 3316 rt2x00_rt_rev_lt(rt2x00dev, RT3390, REV_RT3390E)) {
3288 if (!test_bit(CONFIG_EXTERNAL_LNA_BG, 3317 if (!test_bit(CAPABILITY_EXTERNAL_LNA_BG,
3289 &rt2x00dev->flags)) 3318 &rt2x00dev->cap_flags))
3290 rt2x00_set_field8(&rfcsr, RFCSR17_R, 1); 3319 rt2x00_set_field8(&rfcsr, RFCSR17_R, 1);
3291 } 3320 }
3292 rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &eeprom); 3321 rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &eeprom);
@@ -3709,15 +3738,15 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
3709 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom); 3738 rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
3710 3739
3711 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_LNA_5G)) 3740 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_LNA_5G))
3712 __set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); 3741 __set_bit(CAPABILITY_EXTERNAL_LNA_A, &rt2x00dev->cap_flags);
3713 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_LNA_2G)) 3742 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_LNA_2G))
3714 __set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags); 3743 __set_bit(CAPABILITY_EXTERNAL_LNA_BG, &rt2x00dev->cap_flags);
3715 3744
3716 /* 3745 /*
3717 * Detect if this device has an hardware controlled radio. 3746 * Detect if this device has an hardware controlled radio.
3718 */ 3747 */
3719 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_HW_RADIO)) 3748 if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_HW_RADIO))
3720 __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); 3749 __set_bit(CAPABILITY_HW_BUTTON, &rt2x00dev->cap_flags);
3721 3750
3722 /* 3751 /*
3723 * Store led settings, for correct led behaviour. 3752 * Store led settings, for correct led behaviour.
@@ -3737,7 +3766,7 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
3737 3766
3738 if (rt2x00_get_field16(eeprom, EEPROM_EIRP_MAX_TX_POWER_2GHZ) < 3767 if (rt2x00_get_field16(eeprom, EEPROM_EIRP_MAX_TX_POWER_2GHZ) <
3739 EIRP_MAX_TX_POWER_LIMIT) 3768 EIRP_MAX_TX_POWER_LIMIT)
3740 __set_bit(CONFIG_SUPPORT_POWER_LIMIT, &rt2x00dev->flags); 3769 __set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags);
3741 3770
3742 return 0; 3771 return 0;
3743} 3772}