Lines Matching +full:cts +full:- +full:rts +full:- +full:swap

1 // SPDX-License-Identifier: GPL-2.0-or-later
24 #include <linux/crc-ccitt.h>
86 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_bbp_write()
103 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_bbp_write()
111 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_bbp_read()
135 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_bbp_read()
145 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_write()
151 switch (rt2x00dev->chip.rt) { in rt2800_rfcsr_write()
178 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_write()
207 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_read()
217 switch (rt2x00dev->chip.rt) { in rt2800_rfcsr_read()
250 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_read()
266 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_rf_write()
283 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_rf_write()
374 wiphy_name(rt2x00dev->hw->wiphy), word)) in rt2800_eeprom_word_index()
393 wiphy_name(rt2x00dev->hw->wiphy), word); in rt2800_eeprom_word_index()
465 return -EIO; in rt2800_enable_wlan_rt3290()
505 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_mcu_request()
523 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_mcu_request()
540 return -EBUSY; in rt2800_wait_csr_ready()
563 return -EACCES; in rt2800_wait_wpdma_ready()
585 switch (rt2x00dev->chip.rt) { in rt2800_get_txwi_rxwi_size()
616 fw_crc = (data[len - 2] << 8 | data[len - 1]); in rt2800_check_firmware_crc()
625 crc = crc_ccitt(~0, data, len - 2); in rt2800_check_firmware_crc()
628 * There is a small difference between the crc-itu-t + bitrev and in rt2800_check_firmware_crc()
629 * the crc-ccitt crc calculation. In the latter method the 2 bytes in rt2800_check_firmware_crc()
702 return -EBUSY; in rt2800_load_firmware()
715 return -EBUSY; in rt2800_load_firmware()
749 return -EBUSY; in rt2800_load_firmware()
785 test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); in rt2800_write_tx_data()
787 test_bit(ENTRY_TXD_HT_MIMO_PS, &txdesc->flags)); in rt2800_write_tx_data()
790 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags)); in rt2800_write_tx_data()
792 test_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags)); in rt2800_write_tx_data()
794 txdesc->u.ht.mpdu_density); in rt2800_write_tx_data()
795 rt2x00_set_field32(&word, TXWI_W0_TX_OP, txdesc->u.ht.txop); in rt2800_write_tx_data()
796 rt2x00_set_field32(&word, TXWI_W0_MCS, txdesc->u.ht.mcs); in rt2800_write_tx_data()
798 test_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags)); in rt2800_write_tx_data()
800 test_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags)); in rt2800_write_tx_data()
801 rt2x00_set_field32(&word, TXWI_W0_STBC, txdesc->u.ht.stbc); in rt2800_write_tx_data()
802 rt2x00_set_field32(&word, TXWI_W0_PHYMODE, txdesc->rate_mode); in rt2800_write_tx_data()
807 test_bit(ENTRY_TXD_ACK, &txdesc->flags)); in rt2800_write_tx_data()
809 test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags)); in rt2800_write_tx_data()
810 rt2x00_set_field32(&word, TXWI_W1_BW_WIN_SIZE, txdesc->u.ht.ba_size); in rt2800_write_tx_data()
812 test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags) ? in rt2800_write_tx_data()
813 txdesc->key_idx : txdesc->u.ht.wcid); in rt2800_write_tx_data()
815 txdesc->length); in rt2800_write_tx_data()
816 rt2x00_set_field32(&word, TXWI_W1_PACKETID_QUEUE, entry->queue->qid); in rt2800_write_tx_data()
817 rt2x00_set_field32(&word, TXWI_W1_PACKETID_ENTRY, (entry->entry_idx % 3) + 1); in rt2800_write_tx_data()
829 for (i = 2; i < entry->queue->winfo_size / sizeof(__le32); i++) in rt2800_write_tx_data()
844 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_agc_to_rssi()
863 rssi0 = (rssi0) ? (-12 - offset0 - rt2x00dev->lna_gain - rssi0) : -128; in rt2800_agc_to_rssi()
864 rssi1 = (rssi1) ? (-12 - offset1 - rt2x00dev->lna_gain - rssi1) : -128; in rt2800_agc_to_rssi()
865 rssi2 = (rssi2) ? (-12 - offset2 - rt2x00dev->lna_gain - rssi2) : -128; in rt2800_agc_to_rssi()
869 * average doesn't deliver a fair answer either since -60:-60 would in rt2800_agc_to_rssi()
870 * be considered equally good as -50:-70 while the second is the one in rt2800_agc_to_rssi()
880 __le32 *rxwi = (__le32 *) entry->skb->data; in rt2800_process_rxwi()
885 rxdesc->cipher = rt2x00_get_field32(word, RXWI_W0_UDF); in rt2800_process_rxwi()
886 rxdesc->size = rt2x00_get_field32(word, RXWI_W0_MPDU_TOTAL_BYTE_COUNT); in rt2800_process_rxwi()
891 rxdesc->enc_flags |= RX_ENC_FLAG_SHORT_GI; in rt2800_process_rxwi()
894 rxdesc->bw = RATE_INFO_BW_40; in rt2800_process_rxwi()
899 rxdesc->dev_flags |= RXDONE_SIGNAL_MCS; in rt2800_process_rxwi()
900 rxdesc->signal = rt2x00_get_field32(word, RXWI_W1_MCS); in rt2800_process_rxwi()
901 rxdesc->rate_mode = rt2x00_get_field32(word, RXWI_W1_PHYMODE); in rt2800_process_rxwi()
906 if (rxdesc->rate_mode == RATE_MODE_CCK) in rt2800_process_rxwi()
907 rxdesc->signal &= ~0x8; in rt2800_process_rxwi()
914 rxdesc->rssi = rt2800_agc_to_rssi(entry->queue->rt2x00dev, word); in rt2800_process_rxwi()
918 skb_pull(entry->skb, entry->queue->winfo_size); in rt2800_process_rxwi()
941 idx -= 8; in rt2800_rate_from_status()
951 skbdesc->tx_rate_idx = idx; in rt2800_rate_from_status()
952 skbdesc->tx_rate_flags = flags; in rt2800_rate_from_status()
967 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) in rt2800_txdone_entry_check()
987 rt2x00_dbg(entry->queue->rt2x00dev, in rt2800_txdone_entry_check()
989 entry->queue->qid, entry->entry_idx); in rt2800_txdone_entry_check()
999 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2800_txdone_entry()
1000 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_txdone_entry()
1001 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); in rt2800_txdone_entry()
1022 * If a frame was meant to be sent as a single non-aggregated MPDU in rt2800_txdone_entry()
1042 rt2800_rate_from_status(skbdesc, status, rt2x00dev->curr_band); in rt2800_txdone_entry()
1062 * mcs - real_mcs in rt2800_txdone_entry()
1065 txdesc.retry = ((mcs > real_mcs) ? mcs - real_mcs : 0); in rt2800_txdone_entry()
1073 txdesc.retry = rt2x00dev->long_retry; in rt2800_txdone_entry()
1078 * -> hw used fallback rates in rt2800_txdone_entry()
1084 /* RCU assures non-null sta will not be freed by mac80211. */ in rt2800_txdone_entry()
1087 skbdesc->sta = drv_data->wcid_to_sta[wcid - WCID_START]; in rt2800_txdone_entry()
1089 skbdesc->sta = NULL; in rt2800_txdone_entry()
1106 while (quota-- > 0 && kfifo_get(&rt2x00dev->txstatus_fifo, &reg)) { in rt2800_txdone()
1108 * TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus qid is in rt2800_txdone()
1122 if (unlikely(test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || in rt2800_txdone()
1123 !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))) { in rt2800_txdone()
1125 entry->entry_idx, qid); in rt2800_txdone()
1141 if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) in rt2800_entry_txstatus_timeout()
1144 if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) in rt2800_entry_txstatus_timeout()
1149 ret = time_after(jiffies, entry->last_action + tout); in rt2800_entry_txstatus_timeout()
1151 rt2x00_dbg(entry->queue->rt2x00dev, in rt2800_entry_txstatus_timeout()
1153 entry->entry_idx, entry->queue->qid); in rt2800_entry_txstatus_timeout()
1196 * we loop until we find the first non-IO error entry. This in rt2800_txdone_nostatus()
1205 if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || in rt2800_txdone_nostatus()
1206 !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) in rt2800_txdone_nostatus()
1209 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) || in rt2800_txdone_nostatus()
1223 if (queue->wd_idx != cur_idx) in rt2800_check_hung()
1224 queue->wd_count = 0; in rt2800_check_hung()
1226 queue->wd_count++; in rt2800_check_hung()
1228 return queue->wd_count > 16; in rt2800_check_hung()
1233 struct ieee80211_channel *chan = rt2x00dev->hw->conf.chandef.chan; in rt2800_update_survey()
1235 &rt2x00dev->chan_survey[chan->hw_value]; in rt2800_update_survey()
1237 chan_survey->time_idle += rt2800_register_read(rt2x00dev, CH_IDLE_STA); in rt2800_update_survey()
1238 chan_survey->time_busy += rt2800_register_read(rt2x00dev, CH_BUSY_STA); in rt2800_update_survey()
1239 chan_survey->time_ext_busy += rt2800_register_read(rt2x00dev, CH_BUSY_STA_SEC); in rt2800_update_survey()
1248 if (test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) in rt2800_watchdog()
1254 switch (queue->qid) { in rt2800_watchdog()
1269 if (rt2x00dev->intf_sta_count == 0) in rt2800_watchdog()
1285 ieee80211_restart_hw(rt2x00dev->hw); in rt2800_watchdog()
1303 struct data_queue *queue = rt2x00dev->bcn; in rt2800_update_beacons_setup()
1312 for (i = 0; i < queue->limit; i++) { in rt2800_update_beacons_setup()
1313 entry = &queue->entries[i]; in rt2800_update_beacons_setup()
1314 if (!test_bit(ENTRY_BCN_ENABLED, &entry->flags)) in rt2800_update_beacons_setup()
1316 off = rt2800_get_beacon_offset(rt2x00dev, entry->entry_idx); in rt2800_update_beacons_setup()
1329 bcn_num > 0 ? bcn_num - 1 : 0); in rt2800_update_beacons_setup()
1335 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2800_write_beacon()
1336 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); in rt2800_write_beacon()
1340 const int txwi_desc_size = entry->queue->winfo_size; in rt2800_write_beacon()
1354 memset(skb_push(entry->skb, txwi_desc_size), 0, txwi_desc_size); in rt2800_write_beacon()
1359 skbdesc->flags |= SKBDESC_DESC_IN_SKB; in rt2800_write_beacon()
1360 skbdesc->desc = entry->skb->data; in rt2800_write_beacon()
1361 skbdesc->desc_len = txwi_desc_size; in rt2800_write_beacon()
1376 padding_len = roundup(entry->skb->len, 4) - entry->skb->len; in rt2800_write_beacon()
1377 if (padding_len && skb_pad(entry->skb, padding_len)) { in rt2800_write_beacon()
1380 entry->skb = NULL; in rt2800_write_beacon()
1385 beacon_base = rt2800_hw_beacon_base(rt2x00dev, entry->entry_idx); in rt2800_write_beacon()
1387 rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data, in rt2800_write_beacon()
1388 entry->skb->len + padding_len); in rt2800_write_beacon()
1389 __set_bit(ENTRY_BCN_ENABLED, &entry->flags); in rt2800_write_beacon()
1404 dev_kfree_skb_any(entry->skb); in rt2800_write_beacon()
1405 entry->skb = NULL; in rt2800_write_beacon()
1413 const int txwi_desc_size = rt2x00dev->bcn->winfo_size; in rt2800_clear_beacon_register()
1429 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2800_clear_beacon()
1444 rt2800_clear_beacon_register(rt2x00dev, entry->entry_idx); in rt2800_clear_beacon()
1445 __clear_bit(ENTRY_BCN_ENABLED, &entry->flags); in rt2800_clear_beacon()
1526 (enabled && led->rt2x00dev->curr_band == NL80211_BAND_2GHZ); in rt2800_brightness_set()
1528 rt2x00_get_field16(led->rt2x00dev->led_mcu_reg, in rt2800_brightness_set()
1531 rt2x00_get_field16(led->rt2x00dev->led_mcu_reg, in rt2800_brightness_set()
1536 if (rt2x00_is_soc(led->rt2x00dev)) { in rt2800_brightness_set()
1537 reg = rt2800_register_read(led->rt2x00dev, LED_CFG); in rt2800_brightness_set()
1543 if (led->type == LED_TYPE_RADIO) { in rt2800_brightness_set()
1546 } else if (led->type == LED_TYPE_ASSOC) { in rt2800_brightness_set()
1549 } else if (led->type == LED_TYPE_QUALITY) { in rt2800_brightness_set()
1554 rt2800_register_write(led->rt2x00dev, LED_CFG, reg); in rt2800_brightness_set()
1557 if (led->type == LED_TYPE_RADIO) { in rt2800_brightness_set()
1558 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode, in rt2800_brightness_set()
1560 } else if (led->type == LED_TYPE_ASSOC) { in rt2800_brightness_set()
1561 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode, in rt2800_brightness_set()
1563 } else if (led->type == LED_TYPE_QUALITY) { in rt2800_brightness_set()
1565 * The brightness is divided into 6 levels (0 - 5), in rt2800_brightness_set()
1570 * (1 << level) - 1 in rt2800_brightness_set()
1572 rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff, in rt2800_brightness_set()
1573 (1 << brightness / (LED_FULL / 6)) - 1, in rt2800_brightness_set()
1582 led->rt2x00dev = rt2x00dev; in rt2800_init_led()
1583 led->type = type; in rt2800_init_led()
1584 led->led_dev.brightness_set = rt2800_brightness_set; in rt2800_init_led()
1585 led->flags = LED_INITIALIZED; in rt2800_init_led()
1641 offset = MAC_WCID_ATTR_ENTRY(key->hw_key_idx); in rt2800_config_wcid_attr_cipher()
1643 if (crypto->cmd == SET_KEY) { in rt2800_config_wcid_attr_cipher()
1646 !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)); in rt2800_config_wcid_attr_cipher()
1653 (crypto->cipher & 0x7)); in rt2800_config_wcid_attr_cipher()
1655 (crypto->cipher & 0x8) >> 3); in rt2800_config_wcid_attr_cipher()
1656 rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_RX_WIUDF, crypto->cipher); in rt2800_config_wcid_attr_cipher()
1668 if (test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags)) in rt2800_config_wcid_attr_cipher()
1671 offset = MAC_IVEIV_ENTRY(key->hw_key_idx); in rt2800_config_wcid_attr_cipher()
1674 if ((crypto->cipher == CIPHER_TKIP) || in rt2800_config_wcid_attr_cipher()
1675 (crypto->cipher == CIPHER_TKIP_NO_MIC) || in rt2800_config_wcid_attr_cipher()
1676 (crypto->cipher == CIPHER_AES)) in rt2800_config_wcid_attr_cipher()
1678 iveiv_entry.iv[3] |= key->keyidx << 6; in rt2800_config_wcid_attr_cipher()
1692 if (crypto->cmd == SET_KEY) { in rt2800_config_shared_key()
1693 key->hw_key_idx = (4 * crypto->bssidx) + key->keyidx; in rt2800_config_shared_key()
1695 memcpy(key_entry.key, crypto->key, in rt2800_config_shared_key()
1697 memcpy(key_entry.tx_mic, crypto->tx_mic, in rt2800_config_shared_key()
1699 memcpy(key_entry.rx_mic, crypto->rx_mic, in rt2800_config_shared_key()
1702 offset = SHARED_KEY_ENTRY(key->hw_key_idx); in rt2800_config_shared_key()
1714 field.bit_offset = 4 * (key->hw_key_idx % 8); in rt2800_config_shared_key()
1717 offset = SHARED_KEY_MODE_ENTRY(key->hw_key_idx / 8); in rt2800_config_shared_key()
1721 (crypto->cmd == SET_KEY) * crypto->cipher); in rt2800_config_shared_key()
1727 rt2800_config_wcid(rt2x00dev, crypto->address, key->hw_key_idx); in rt2800_config_shared_key()
1728 rt2800_config_wcid_attr_bssidx(rt2x00dev, key->hw_key_idx, in rt2800_config_shared_key()
1729 crypto->bssidx); in rt2800_config_shared_key()
1743 if (crypto->cmd == SET_KEY) { in rt2800_config_pairwise_key()
1748 if (crypto->wcid > WCID_END) in rt2800_config_pairwise_key()
1749 return -ENOSPC; in rt2800_config_pairwise_key()
1750 key->hw_key_idx = crypto->wcid; in rt2800_config_pairwise_key()
1752 memcpy(key_entry.key, crypto->key, in rt2800_config_pairwise_key()
1754 memcpy(key_entry.tx_mic, crypto->tx_mic, in rt2800_config_pairwise_key()
1756 memcpy(key_entry.rx_mic, crypto->rx_mic, in rt2800_config_pairwise_key()
1759 offset = PAIRWISE_KEY_ENTRY(key->hw_key_idx); in rt2800_config_pairwise_key()
1777 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_set_max_psdu_len()
1780 if (drv_data->ampdu_factor_cnt[i] > 0) in rt2800_set_max_psdu_len()
1783 max_psdu = min(drv_data->max_psdu, i); in rt2800_set_max_psdu_len()
1793 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_sta_add()
1794 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_sta_add()
1804 if (sta->ht_cap.ht_supported) { in rt2800_sta_add()
1805 drv_data->ampdu_factor_cnt[sta->ht_cap.ampdu_factor & 3]++; in rt2800_sta_add()
1813 wcid = find_first_zero_bit(drv_data->sta_ids, STA_IDS_SIZE) + WCID_START; in rt2800_sta_add()
1819 sta_priv->wcid = wcid; in rt2800_sta_add()
1823 * with the STA -> No error. in rt2800_sta_add()
1828 __set_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_sta_add()
1829 drv_data->wcid_to_sta[wcid - WCID_START] = sta; in rt2800_sta_add()
1835 rt2800_config_wcid(rt2x00dev, sta->addr, wcid); in rt2800_sta_add()
1845 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_sta_remove()
1846 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_sta_remove()
1848 int wcid = sta_priv->wcid; in rt2800_sta_remove()
1850 if (sta->ht_cap.ht_supported) { in rt2800_sta_remove()
1851 drv_data->ampdu_factor_cnt[sta->ht_cap.ampdu_factor & 3]--; in rt2800_sta_remove()
1862 drv_data->wcid_to_sta[wcid - WCID_START] = NULL; in rt2800_sta_remove()
1863 __clear_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_sta_remove()
1871 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_pre_reset_hw()
1872 struct data_queue *queue = rt2x00dev->bcn; in rt2800_pre_reset_hw()
1877 drv_data->wcid_to_sta[wcid - WCID_START] = NULL; in rt2800_pre_reset_hw()
1878 __clear_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_pre_reset_hw()
1881 for (i = 0; i < queue->limit; i++) { in rt2800_pre_reset_hw()
1882 entry = &queue->entries[i]; in rt2800_pre_reset_hw()
1883 clear_bit(ENTRY_BCN_ASSIGNED, &entry->flags); in rt2800_pre_reset_hw()
1905 !test_bit(CONFIG_MONITORING, &rt2x00dev->flags)); in rt2800_config_filter()
1944 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_SYNC, conf->sync); in rt2800_config_intf()
1947 if (conf->sync == TSF_SYNC_AP_NONE) { in rt2800_config_intf()
1969 conf->sync == TSF_SYNC_AP_NONE) { in rt2800_config_intf()
1974 memcpy(conf->bssid, conf->mac, sizeof(conf->mac)); in rt2800_config_intf()
1978 if (!is_zero_ether_addr((const u8 *)conf->mac)) { in rt2800_config_intf()
1979 reg = le32_to_cpu(conf->mac[1]); in rt2800_config_intf()
1981 conf->mac[1] = cpu_to_le32(reg); in rt2800_config_intf()
1985 conf->mac, sizeof(conf->mac)); in rt2800_config_intf()
1989 if (!is_zero_ether_addr((const u8 *)conf->bssid)) { in rt2800_config_intf()
1990 reg = le32_to_cpu(conf->bssid[1]); in rt2800_config_intf()
1993 conf->bssid[1] = cpu_to_le32(reg); in rt2800_config_intf()
1997 conf->bssid, sizeof(conf->bssid)); in rt2800_config_intf()
2005 bool any_sta_nongf = !!(erp->ht_opmode & in rt2800_config_ht_opmode()
2007 u8 protection = erp->ht_opmode & IEEE80211_HT_OP_MODE_PROTECTION; in rt2800_config_ht_opmode()
2051 * -> fall through to mixed mode. in rt2800_config_ht_opmode()
2064 if (erp->cts_protection) { in rt2800_config_ht_opmode()
2065 /* don't duplicate RTS/CTS in CCK mode */ in rt2800_config_ht_opmode()
2106 !!erp->short_preamble); in rt2800_config_erp()
2113 erp->cts_protection ? 2 : 0); in rt2800_config_erp()
2119 0xff0 | erp->basic_rates); in rt2800_config_erp()
2126 erp->slot_time); in rt2800_config_erp()
2130 rt2x00_set_field32(&reg, XIFS_TIME_CFG_EIFS, erp->eifs); in rt2800_config_erp()
2137 erp->beacon_int * 16); in rt2800_config_erp()
2153 if (rt2x00dev->curr_band == NL80211_BAND_5GHZ) { in rt2800_config_3572bt_ant()
2217 switch (ant->tx_chain_num) { in rt2800_config_ant()
2236 switch (ant->rx_chain_num) { in rt2800_config_ant()
2247 rt2x00dev->default_ant.rx); in rt2800_config_ant()
2256 rt2x00dev->curr_band == NL80211_BAND_5GHZ); in rt2800_config_ant()
2272 if (ant->rx_chain_num == 1) in rt2800_config_ant()
2286 if (libconf->rf.channel <= 14) { in rt2800_config_lna_gain()
2289 } else if (libconf->rf.channel <= 64) { in rt2800_config_lna_gain()
2292 } else if (libconf->rf.channel <= 128) { in rt2800_config_lna_gain()
2316 rt2x00dev->lna_gain = lna_gain; in rt2800_config_lna_gain()
2321 return clk_get_rate(rt2x00dev->clk) == 20000000; in rt2800_clk_is_20mhz()
2331 freq_offset = rt2x00_get_field8(rt2x00dev->freq_offset, RFCSR17_CODE); in rt2800_freq_cal_mode1()
2352 prev_freq_offset--; in rt2800_freq_cal_mode1()
2366 rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf2xxx()
2368 if (rt2x00dev->default_ant.tx_chain_num == 1) in rt2800_config_channel_rf2xxx()
2369 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_TX1, 1); in rt2800_config_channel_rf2xxx()
2371 if (rt2x00dev->default_ant.rx_chain_num == 1) { in rt2800_config_channel_rf2xxx()
2372 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX1, 1); in rt2800_config_channel_rf2xxx()
2373 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1); in rt2800_config_channel_rf2xxx()
2374 } else if (rt2x00dev->default_ant.rx_chain_num == 2) in rt2800_config_channel_rf2xxx()
2375 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1); in rt2800_config_channel_rf2xxx()
2377 if (rf->channel > 14) { in rt2800_config_channel_rf2xxx()
2380 * make it a positive value (Minimum value is -7). in rt2800_config_channel_rf2xxx()
2384 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A_7DBM_BOOST, in rt2800_config_channel_rf2xxx()
2385 (info->default_power1 >= 0)); in rt2800_config_channel_rf2xxx()
2387 if (info->default_power1 < 0) in rt2800_config_channel_rf2xxx()
2388 info->default_power1 += 7; in rt2800_config_channel_rf2xxx()
2390 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A, info->default_power1); in rt2800_config_channel_rf2xxx()
2392 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A_7DBM_BOOST, in rt2800_config_channel_rf2xxx()
2393 (info->default_power2 >= 0)); in rt2800_config_channel_rf2xxx()
2395 if (info->default_power2 < 0) in rt2800_config_channel_rf2xxx()
2396 info->default_power2 += 7; in rt2800_config_channel_rf2xxx()
2398 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A, info->default_power2); in rt2800_config_channel_rf2xxx()
2400 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_G, info->default_power1); in rt2800_config_channel_rf2xxx()
2401 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_G, info->default_power2); in rt2800_config_channel_rf2xxx()
2404 rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf)); in rt2800_config_channel_rf2xxx()
2406 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2407 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2408 rt2800_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004); in rt2800_config_channel_rf2xxx()
2409 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2413 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2414 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2415 rt2800_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004); in rt2800_config_channel_rf2xxx()
2416 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2420 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2421 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2422 rt2800_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004); in rt2800_config_channel_rf2xxx()
2423 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2431 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3xxx()
2434 rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); in rt2800_config_channel_rf3xxx()
2437 rt2x00_set_field8(&rfcsr, RFCSR3_K, rf->rf3); in rt2800_config_channel_rf3xxx()
2441 rt2x00_set_field8(&rfcsr, RFCSR6_R1, rf->rf2); in rt2800_config_channel_rf3xxx()
2445 rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER, info->default_power1); in rt2800_config_channel_rf3xxx()
2449 rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER, info->default_power2); in rt2800_config_channel_rf3xxx()
2455 rt2x00dev->default_ant.rx_chain_num <= 1); in rt2800_config_channel_rf3xxx()
2457 rt2x00dev->default_ant.rx_chain_num <= 2); in rt2800_config_channel_rf3xxx()
2460 rt2x00dev->default_ant.tx_chain_num <= 1); in rt2800_config_channel_rf3xxx()
2462 rt2x00dev->default_ant.tx_chain_num <= 2); in rt2800_config_channel_rf3xxx()
2466 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf3xxx()
2474 calib_tx = drv_data->calibration_bw40; in rt2800_config_channel_rf3xxx()
2475 calib_rx = drv_data->calibration_bw40; in rt2800_config_channel_rf3xxx()
2477 calib_tx = drv_data->calibration_bw20; in rt2800_config_channel_rf3xxx()
2478 calib_rx = drv_data->calibration_bw20; in rt2800_config_channel_rf3xxx()
2509 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3052()
2513 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2514 rt2800_bbp_write(rt2x00dev, 25, drv_data->bbp25); in rt2800_config_channel_rf3052()
2515 rt2800_bbp_write(rt2x00dev, 26, drv_data->bbp26); in rt2800_config_channel_rf3052()
2521 rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); in rt2800_config_channel_rf3052()
2522 rt2800_rfcsr_write(rt2x00dev, 3, rf->rf3); in rt2800_config_channel_rf3052()
2525 rt2x00_set_field8(&rfcsr, RFCSR6_R1, rf->rf2); in rt2800_config_channel_rf3052()
2526 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2533 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2540 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2543 info->default_power1); in rt2800_config_channel_rf3052()
2547 (info->default_power1 & 0x3) | in rt2800_config_channel_rf3052()
2548 ((info->default_power1 & 0xC) << 1)); in rt2800_config_channel_rf3052()
2553 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2556 info->default_power2); in rt2800_config_channel_rf3052()
2560 (info->default_power2 & 0x3) | in rt2800_config_channel_rf3052()
2561 ((info->default_power2 & 0xC) << 1)); in rt2800_config_channel_rf3052()
2573 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2580 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3052()
2589 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3052()
2601 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf3052()
2605 rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw40); in rt2800_config_channel_rf3052()
2606 rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw40); in rt2800_config_channel_rf3052()
2608 rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw20); in rt2800_config_channel_rf3052()
2609 rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw20); in rt2800_config_channel_rf3052()
2612 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2620 drv_data->txmixer_gain_24g); in rt2800_config_channel_rf3052()
2642 drv_data->txmixer_gain_5g); in rt2800_config_channel_rf3052()
2645 if (rf->channel <= 64) { in rt2800_config_channel_rf3052()
2649 } else if (rf->channel <= 128) { in rt2800_config_channel_rf3052()
2665 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2681 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3053()
2698 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2700 rt2800_bbp_write(rt2x00dev, 25, drv_data->bbp25); in rt2800_config_channel_rf3053()
2701 rt2800_bbp_write(rt2x00dev, 26, drv_data->bbp26); in rt2800_config_channel_rf3053()
2711 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3053()
2712 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3 & 0xf); in rt2800_config_channel_rf3053()
2715 rt2x00_set_field8(&rfcsr, RFCSR11_R, (rf->rf2 & 0x3)); in rt2800_config_channel_rf3053()
2720 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2727 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2730 info->default_power1 & 0x1f); in rt2800_config_channel_rf3053()
2736 ((info->default_power1 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2737 (info->default_power1 & 7)); in rt2800_config_channel_rf3053()
2742 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2745 info->default_power2 & 0x1f); in rt2800_config_channel_rf3053()
2751 ((info->default_power2 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2752 (info->default_power2 & 7)); in rt2800_config_channel_rf3053()
2757 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2760 info->default_power3 & 0x1f); in rt2800_config_channel_rf3053()
2766 ((info->default_power3 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2767 (info->default_power3 & 7)); in rt2800_config_channel_rf3053()
2781 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3053()
2793 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3053()
2809 txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw40, in rt2800_config_channel_rf3053()
2811 txrx_h20m = rt2x00_get_field8(drv_data->calibration_bw40, in rt2800_config_channel_rf3053()
2814 txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw20, in rt2800_config_channel_rf3053()
2816 txrx_h20m = rt2x00_get_field8(drv_data->calibration_bw20, in rt2800_config_channel_rf3053()
2826 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2839 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2846 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2853 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2860 if (rf->channel >= 1 && rf->channel <= 14) in rt2800_config_channel_rf3053()
2862 else if (rf->channel >= 36 && rf->channel <= 64) in rt2800_config_channel_rf3053()
2864 else if (rf->channel >= 100 && rf->channel <= 128) in rt2800_config_channel_rf3053()
2876 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2889 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2899 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2914 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2920 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2930 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2942 if (rf->channel >= 1 && rf->channel <= 14) { in rt2800_config_channel_rf3053()
2949 } else if (rf->channel >= 36 && rf->channel <= 64) { in rt2800_config_channel_rf3053()
2956 } else if (rf->channel >= 100 && rf->channel <= 128) { in rt2800_config_channel_rf3053()
2986 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
2988 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
2993 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3853()
2994 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3853()
2996 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3001 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3018 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3853()
3030 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3853()
3052 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3062 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3069 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3075 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3077 else if (rf->channel < 100) in rt2800_config_channel_rf3853()
3079 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
3089 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3094 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3096 else if (rf->channel < 100) in rt2800_config_channel_rf3853()
3098 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
3104 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3117 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3123 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3128 if (rf->channel <= 14) { in rt2800_config_channel_rf3853()
3129 pwr1 = info->default_power1 & 0x1f; in rt2800_config_channel_rf3853()
3130 pwr2 = info->default_power2 & 0x1f; in rt2800_config_channel_rf3853()
3131 pwr3 = info->default_power3 & 0x1f; in rt2800_config_channel_rf3853()
3133 pwr1 = 0x48 | ((info->default_power1 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3134 (info->default_power1 & 0x7); in rt2800_config_channel_rf3853()
3135 pwr2 = 0x48 | ((info->default_power2 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3136 (info->default_power2 & 0x7); in rt2800_config_channel_rf3853()
3137 pwr3 = 0x48 | ((info->default_power3 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3138 (info->default_power3 & 0x7); in rt2800_config_channel_rf3853()
3146 rf->channel, pwr1, pwr2, pwr3); in rt2800_config_channel_rf3853()
3148 bbp = (info->default_power1 >> 5) | in rt2800_config_channel_rf3853()
3149 ((info->default_power2 & 0xe0) >> 1); in rt2800_config_channel_rf3853()
3154 bbp |= (info->default_power3 & 0xe0) >> 1; in rt2800_config_channel_rf3853()
3158 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3188 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3290()
3189 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3290()
3191 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf2); in rt2800_config_channel_rf3290()
3195 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf3290()
3198 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf3290()
3203 if (rf->channel <= 14) { in rt2800_config_channel_rf3290()
3204 if (rf->channel == 6) in rt2800_config_channel_rf3290()
3209 if (rf->channel >= 1 && rf->channel <= 6) in rt2800_config_channel_rf3290()
3211 else if (rf->channel >= 7 && rf->channel <= 11) in rt2800_config_channel_rf3290()
3213 else if (rf->channel >= 12 && rf->channel <= 14) in rt2800_config_channel_rf3290()
3225 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3322()
3226 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3322()
3232 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf3322()
3235 rt2800_rfcsr_write(rt2x00dev, 47, info->default_power1); in rt2800_config_channel_rf3322()
3237 if (info->default_power2 > POWER_BOUND) in rt2800_config_channel_rf3322()
3240 rt2800_rfcsr_write(rt2x00dev, 48, info->default_power2); in rt2800_config_channel_rf3322()
3248 if ( rt2x00dev->default_ant.tx_chain_num == 2 ) in rt2800_config_channel_rf3322()
3253 if ( rt2x00dev->default_ant.rx_chain_num == 2 ) in rt2800_config_channel_rf3322()
3272 int idx = rf->channel-1; in rt2800_config_channel_rf53xx()
3274 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf53xx()
3275 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf53xx()
3277 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf2); in rt2800_config_channel_rf53xx()
3281 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf53xx()
3284 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf53xx()
3289 if (info->default_power2 > POWER_BOUND) in rt2800_config_channel_rf53xx()
3293 info->default_power2); in rt2800_config_channel_rf53xx()
3379 (rf->channel > 14 || conf_is_ht40(conf)) ? 5 : 0); in rt2800_config_channel_rf55xx()
3383 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1 & 0xff); in rt2800_config_channel_rf55xx()
3386 rt2x00_set_field8(&rfcsr, RFCSR9_K, rf->rf2 & 0xf); in rt2800_config_channel_rf55xx()
3387 rt2x00_set_field8(&rfcsr, RFCSR9_N, (rf->rf1 & 0x100) >> 8); in rt2800_config_channel_rf55xx()
3388 rt2x00_set_field8(&rfcsr, RFCSR9_MOD, ((rf->rf3 - 8) & 0x4) >> 2); in rt2800_config_channel_rf55xx()
3392 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf4 - 1); in rt2800_config_channel_rf55xx()
3393 rt2x00_set_field8(&rfcsr, RFCSR11_MOD, (rf->rf3 - 8) & 0x3); in rt2800_config_channel_rf55xx()
3396 if (rf->channel <= 14) { in rt2800_config_channel_rf55xx()
3428 /* TODO RF27 <- tssi */ in rt2800_config_channel_rf55xx()
3430 rfcsr = rf->channel <= 10 ? 0x07 : 0x06; in rt2800_config_channel_rf55xx()
3470 /* TODO RF27 <- tssi */ in rt2800_config_channel_rf55xx()
3472 if (rf->channel >= 36 && rf->channel <= 64) { in rt2800_config_channel_rf55xx()
3478 if (rf->channel <= 50) in rt2800_config_channel_rf55xx()
3480 else if (rf->channel >= 52) in rt2800_config_channel_rf55xx()
3489 if (rf->channel <= 50) { in rt2800_config_channel_rf55xx()
3492 } else if (rf->channel >= 52) { in rt2800_config_channel_rf55xx()
3501 } else if (rf->channel >= 100 && rf->channel <= 165) { in rt2800_config_channel_rf55xx()
3506 if (rf->channel <= 153) { in rt2800_config_channel_rf55xx()
3509 } else if (rf->channel >= 155) { in rt2800_config_channel_rf55xx()
3513 if (rf->channel <= 138) { in rt2800_config_channel_rf55xx()
3518 } else if (rf->channel >= 140) { in rt2800_config_channel_rf55xx()
3524 if (rf->channel <= 124) in rt2800_config_channel_rf55xx()
3526 else if (rf->channel >= 126) in rt2800_config_channel_rf55xx()
3528 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3530 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3533 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3535 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3537 if (rf->channel <= 128) in rt2800_config_channel_rf55xx()
3539 else if (rf->channel >= 130) in rt2800_config_channel_rf55xx()
3541 if (rf->channel <= 116) in rt2800_config_channel_rf55xx()
3543 else if (rf->channel >= 118) in rt2800_config_channel_rf55xx()
3545 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3547 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3549 if (rf->channel <= 116) in rt2800_config_channel_rf55xx()
3551 else if (rf->channel >= 118) in rt2800_config_channel_rf55xx()
3560 if (info->default_power1 > power_bound) in rt2800_config_channel_rf55xx()
3563 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf55xx()
3569 if (info->default_power2 > power_bound) in rt2800_config_channel_rf55xx()
3572 rt2x00_set_field8(&rfcsr, RFCSR50_TX, info->default_power2); in rt2800_config_channel_rf55xx()
3582 rt2x00dev->default_ant.tx_chain_num >= 1); in rt2800_config_channel_rf55xx()
3584 rt2x00dev->default_ant.tx_chain_num == 2); in rt2800_config_channel_rf55xx()
3588 rt2x00dev->default_ant.rx_chain_num >= 1); in rt2800_config_channel_rf55xx()
3590 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_config_channel_rf55xx()
3615 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3616 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3617 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3619 rt2800_bbp_write(rt2x00dev, 79, (rf->channel <= 14) ? 0x1C : 0x18); in rt2800_config_channel_rf55xx()
3620 rt2800_bbp_write(rt2x00dev, 80, (rf->channel <= 14) ? 0x0E : 0x08); in rt2800_config_channel_rf55xx()
3621 rt2800_bbp_write(rt2x00dev, 81, (rf->channel <= 14) ? 0x3A : 0x38); in rt2800_config_channel_rf55xx()
3622 rt2800_bbp_write(rt2x00dev, 82, (rf->channel <= 14) ? 0x62 : 0x92); in rt2800_config_channel_rf55xx()
3626 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0xE0 : 0xF0); in rt2800_config_channel_rf55xx()
3628 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x1F : 0x1E); in rt2800_config_channel_rf55xx()
3630 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x38 : 0x28); in rt2800_config_channel_rf55xx()
3632 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x32 : 0x20); in rt2800_config_channel_rf55xx()
3634 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x28 : 0x7F); in rt2800_config_channel_rf55xx()
3636 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x19 : 0x7F); in rt2800_config_channel_rf55xx()
3644 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf7620()
3658 * R20[7:0] in rf->rf1 in rt2800_config_channel_rf7620()
3662 rfcsr = (rf->rf1 & 0x00ff); in rt2800_config_channel_rf7620()
3684 * Ksd: R17<7:0> in rf->rf2 in rt2800_config_channel_rf7620()
3685 * R18<7:0> in rf->rf3 in rt2800_config_channel_rf7620()
3686 * R19<1:0> in rf->rf4 in rt2800_config_channel_rf7620()
3689 rfcsr = rf->rf2; in rt2800_config_channel_rf7620()
3693 rfcsr = rf->rf3; in rt2800_config_channel_rf7620()
3697 rt2x00_set_field8(&rfcsr, RFCSR19_K, rf->rf4); in rt2800_config_channel_rf7620()
3711 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3716 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3718 rt2x00dev->default_ant.rx_chain_num != 1); in rt2800_config_channel_rf7620()
3723 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3751 conf_is_ht40(conf) && (rf->channel == 11)); in rt2800_config_channel_rf7620()
3754 if (!test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) { in rt2800_config_channel_rf7620()
3756 rx_agc_fc = drv_data->rx_calibration_bw40; in rt2800_config_channel_rf7620()
3757 tx_agc_fc = drv_data->tx_calibration_bw40; in rt2800_config_channel_rf7620()
3759 rx_agc_fc = drv_data->rx_calibration_bw20; in rt2800_config_channel_rf7620()
3760 tx_agc_fc = drv_data->tx_calibration_bw20; in rt2800_config_channel_rf7620()
3812 max_power = chan->max_power * 2; in rt2800_config_alc()
3852 if (chan->center_freq > 2457) { in rt2800_config_alc()
3882 for (chain = 0; chain < rt2x00dev->default_ant.rx_chain_num; chain++) { in rt2800_bbp_write_with_rx_chain()
4001 bbp = (rf->channel > 14) ? 0x48 : 0x38; in rt3883_bbp_adjust()
4006 if (rf->channel <= 14) { in rt3883_bbp_adjust()
4015 if (rf->channel > 14) { in rt3883_bbp_adjust()
4035 info->default_power1 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4036 info->default_power1); in rt2800_config_channel()
4037 info->default_power2 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4038 info->default_power2); in rt2800_config_channel()
4039 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_config_channel()
4040 info->default_power3 = in rt2800_config_channel()
4041 rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4042 info->default_power3); in rt2800_config_channel()
4044 switch (rt2x00dev->chip.rt) { in rt2800_config_channel()
4050 switch (rt2x00dev->chip.rf) { in rt2800_config_channel()
4127 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4128 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4129 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4132 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); in rt2800_config_channel()
4134 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); in rt2800_config_channel()
4138 if (rf->channel > 14) { in rt2800_config_channel()
4150 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4151 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4152 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4155 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4156 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4157 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4159 if (rt2x00dev->default_ant.rx_chain_num > 1) in rt2800_config_channel()
4164 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4165 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4166 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4170 if (rf->channel <= 14) { in rt2800_config_channel()
4211 rt2x00_set_field32(&reg, TX_BAND_CFG_A, rf->channel > 14); in rt2800_config_channel()
4212 rt2x00_set_field32(&reg, TX_BAND_CFG_BG, rf->channel <= 14); in rt2800_config_channel()
4225 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel()
4229 rf->channel > 14); in rt2800_config_channel()
4231 rf->channel <= 14); in rt2800_config_channel()
4236 rf->channel > 14); in rt2800_config_channel()
4238 rf->channel <= 14); in rt2800_config_channel()
4243 rf->channel > 14); in rt2800_config_channel()
4248 rf->channel <= 14); in rt2800_config_channel()
4252 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel()
4279 if (rf->channel <= 14) in rt2800_config_channel()
4280 reg = 0x1c + (2 * rt2x00dev->lna_gain); in rt2800_config_channel()
4282 reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4295 if (rf->channel <= 14) in rt2800_config_channel()
4320 if (rf->channel <= 14) in rt2800_config_channel()
4321 reg = 0x1c + 2 * rt2x00dev->lna_gain; in rt2800_config_channel()
4323 reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4337 if (rf->channel <= 14) in rt2800_config_channel()
4338 reg = 0x2e + rt2x00dev->lna_gain; in rt2800_config_channel()
4340 reg = 0x20 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4365 reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain; in rt2800_config_channel()
4368 rt2800_iq_calibrate(rt2x00dev, rf->channel); in rt2800_config_channel()
4431 * Matching Delta value -4 -3 -2 -1 0 +1 +2 +3 +4 in rt2800_get_gain_calibration_delta()
4434 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_get_gain_calibration_delta()
4519 for (i = 8; i >= 5; i--) { in rt2800_get_gain_calibration_delta()
4525 return (i - 4) * step; in rt2800_get_gain_calibration_delta()
4542 !test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_get_txpower_bw_comp()
4554 comp_value = -comp_value; in rt2800_get_txpower_bw_comp()
4565 comp_value = -comp_value; in rt2800_get_txpower_bw_comp()
4589 delta = power_level - max_power; in rt2800_get_txpower_reg_delta()
4632 eirp_txpower = eirp_txpower_criterion + (txpower - criterion) + in rt2800_compensate_txpower()
4636 (eirp_txpower - power_level) : 0; in rt2800_compensate_txpower()
4640 txpower = max(0, txpower + delta - reg_limit); in rt2800_compensate_txpower()
4672 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt3593()
4688 if (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_config_txpower_rt3593()
5042 (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) ? in rt2800_config_txpower_rt3593()
5045 (i - TX_PWR_CFG_9_IDX - 1) : i, in rt2800_config_txpower_rt3593()
5058 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt6352()
5071 * Maybe some misunderstanding of what a signed 8-bit value is? Maybe in rt2800_config_txpower_rt6352()
5073 * used a fixed offset between HT20 and HT40 rates they had to work- in rt2800_config_txpower_rt6352()
5118 if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) { in rt2800_config_txpower_rt6352()
5135 * registers. As recent 2T chips use 8-bit instead of 4-bit values for in rt2800_config_txpower_rt6352()
5136 * power-offsets more space would be needed. Ralink decided to keep the in rt2800_config_txpower_rt6352()
5178 * for all rates, but allow to set only 4 discrete values: -12, -6, 0 and 6 dBm.
5191 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt28xx()
5206 switch (rt2x00dev->chip.rt) { in rt2800_config_txpower_rt28xx()
5227 chan->max_power); in rt2800_config_txpower_rt28xx()
5231 * gains -12, -6, 0, +6 dBm by setting values 2, 1, 0, 3 respectively. in rt2800_config_txpower_rt28xx()
5237 if (delta <= -12) { in rt2800_config_txpower_rt28xx()
5240 } else if (delta <= -6) { in rt2800_config_txpower_rt28xx()
5381 rt2800_config_txpower(rt2x00dev, rt2x00dev->hw->conf.chandef.chan, in rt2800_gain_calibration()
5382 rt2x00dev->tx_power); in rt2800_gain_calibration()
5393 * A voltage-controlled oscillator(VCO) is an electronic oscillator in rt2800_vco_calibration()
5404 switch (rt2x00dev->chip.rf) { in rt2800_vco_calibration()
5442 rt2x00dev->chip.rf); in rt2800_vco_calibration()
5450 if (rt2x00dev->rf_channel <= 14) { in rt2800_vco_calibration()
5451 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_vco_calibration()
5464 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_vco_calibration()
5480 if (rt2x00dev->default_ant.rx_chain_num == 1) { in rt2800_vco_calibration()
5510 * 2005/06/05 - On 11G, we also need this delay time. in rt2800_vco_calibration()
5525 libconf->conf->short_frame_max_tx_count); in rt2800_config_retry_limit()
5527 libconf->conf->long_frame_max_tx_count); in rt2800_config_retry_limit()
5535 (libconf->conf->flags & IEEE80211_CONF_PS) ? in rt2800_config_ps()
5545 libconf->conf->listen_interval - 1); in rt2800_config_ps()
5549 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); in rt2800_config_ps()
5557 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); in rt2800_config_ps()
5570 * To provide correct survey data for survey-based ACS algorithm in rt2800_config()
5575 rt2800_config_channel(rt2x00dev, libconf->conf, in rt2800_config()
5576 &libconf->rf, &libconf->channel); in rt2800_config()
5577 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, in rt2800_config()
5578 libconf->conf->power_level); in rt2800_config()
5581 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, in rt2800_config()
5582 libconf->conf->power_level); in rt2800_config()
5601 qual->rx_failed = rt2x00_get_field32(reg, RX_STA_CNT0_CRC_ERR); in rt2800_link_stats()
5609 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_get_default_vgc()
5621 vgc = 0x1c + (2 * rt2x00dev->lna_gain); in rt2800_get_default_vgc()
5623 vgc = 0x2e + rt2x00dev->lna_gain; in rt2800_get_default_vgc()
5627 vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5629 vgc = 0x24 + (2 * rt2x00dev->lna_gain); in rt2800_get_default_vgc()
5631 if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_get_default_vgc()
5632 vgc = 0x32 + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5634 vgc = 0x3a + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5644 if (qual->vgc_level != vgc_level) { in rt2800_set_vgc()
5651 rt2800_bbp_write(rt2x00dev, 83, qual->rssi > -65 ? 0x4a : 0x7a); in rt2800_set_vgc()
5657 qual->vgc_level = vgc_level; in rt2800_set_vgc()
5658 qual->vgc_level_reg = vgc_level; in rt2800_set_vgc()
5683 switch (rt2x00dev->chip.rt) { in rt2800_link_tuner()
5686 if (qual->rssi > -65) { in rt2800_link_tuner()
5687 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) in rt2800_link_tuner()
5695 if (qual->rssi > -65) in rt2800_link_tuner()
5700 if (qual->rssi > -65) in rt2800_link_tuner()
5705 if (qual->rssi > -80) in rt2800_link_tuner()
5719 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_init_registers()
5909 drv_data->max_psdu = 3; in rt2800_init_registers()
5913 drv_data->max_psdu = 2; in rt2800_init_registers()
5915 drv_data->max_psdu = 1; in rt2800_init_registers()
5917 rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_PSDU, drv_data->max_psdu); in rt2800_init_registers()
6085 * connection problems with 11g + CTS protection. Hence, use the same in rt2800_init_registers()
6114 if (!test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags)) in rt2800_init_registers()
6229 return -EACCES; in rt2800_wait_bbp_rf_ready()
6253 return -EACCES; in rt2800_wait_bbp_ready()
6505 /* Use 5-bit ADC for Acquisition and 8-bit ADC for data */ in rt2800_init_bbp_3290()
6855 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_init_bbp_5592()
6946 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_init_bbp_6352()
6952 /* Fix I/Q swap issue */ in rt2800_init_bbp_6352()
7153 switch (rt2x00dev->chip.rt) { in rt2800_init_bbp()
7266 if ((passband - stopband) <= filter_target) { in rt2800_init_rx_filter()
7268 overtuned += ((passband - stopband) == filter_target); in rt2800_init_rx_filter()
7275 rfcsr24 -= !!overtuned; in rt2800_init_rx_filter()
7296 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_rx_filter_calibration()
7312 drv_data->calibration_bw20 = in rt2800_rx_filter_calibration()
7314 drv_data->calibration_bw40 = in rt2800_rx_filter_calibration()
7320 drv_data->bbp25 = rt2800_bbp_read(rt2x00dev, 25); in rt2800_rx_filter_calibration()
7321 drv_data->bbp26 = rt2800_bbp_read(rt2x00dev, 26); in rt2800_rx_filter_calibration()
7342 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_normal_mode_setup_3xxx()
7358 if (drv_data->txmixer_gain_24g >= min_gain) { in rt2800_normal_mode_setup_3xxx()
7360 drv_data->txmixer_gain_24g); in rt2800_normal_mode_setup_3xxx()
7413 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_normal_mode_setup_3593()
7422 tx_gain = rt2x00_get_field8(drv_data->txmixer_gain_24g, in rt2800_normal_mode_setup_3593()
7648 &rt2x00dev->cap_flags); in rt2800_init_rfcsr_3352()
7650 &rt2x00dev->cap_flags); in rt2800_init_rfcsr_3352()
7860 if (rt2x00dev->default_ant.rx_chain_num == 1) in rt3593_post_bbp_init()
7903 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_init_rfcsr_3593()
7969 drv_data->calibration_bw20 = 0x1f; in rt2800_init_rfcsr_3593()
7970 drv_data->calibration_bw40 = 0x2f; in rt2800_init_rfcsr_3593()
7973 drv_data->bbp25 = rt2800_bbp_read(rt2x00dev, 25); in rt2800_init_rfcsr_3593()
7974 drv_data->bbp26 = rt2800_bbp_read(rt2x00dev, 26); in rt2800_init_rfcsr_3593()
8490 cal_val -= 128; in rt2800_lp_tx_filter_bw_cal()
8498 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_bw_filter_calibration()
8575 /* I-3 */ in rt2800_bw_filter_calibration()
8582 /* I-4,5,6,7,8,9 */ in rt2800_bw_filter_calibration()
8667 cal_diff = cal_r32_init - cal_r32_val; in rt2800_bw_filter_calibration()
8690 drv_data->tx_calibration_bw20 = tx_agc_fc; in rt2800_bw_filter_calibration()
8692 drv_data->tx_calibration_bw40 = tx_agc_fc; in rt2800_bw_filter_calibration()
8695 drv_data->rx_calibration_bw20 = rx_agc_fc; in rt2800_bw_filter_calibration()
8697 drv_data->rx_calibration_bw40 = rx_agc_fc; in rt2800_bw_filter_calibration()
8737 2 * test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)); in rt2800_bw_filter_calibration()
8759 rt2800_rfcsr_write(rt2x00dev, 12, rt2x00dev->freq_offset); in rt2800_init_rfcsr_6352()
9019 switch (rt2x00dev->chip.rt) { in rt2800_init_rfcsr()
9071 return -EIO; in rt2800_enable_radio()
9077 return -EIO; in rt2800_enable_radio()
9093 return -EIO; in rt2800_enable_radio()
9203 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_efuse_read()
9216 *(u32 *)&rt2x00dev->eeprom[i] = cpu_to_le32(reg); in rt2800_efuse_read()
9218 *(u32 *)&rt2x00dev->eeprom[i + 2] = cpu_to_le32(reg); in rt2800_efuse_read()
9220 *(u32 *)&rt2x00dev->eeprom[i + 4] = cpu_to_le32(reg); in rt2800_efuse_read()
9222 *(u32 *)&rt2x00dev->eeprom[i + 6] = cpu_to_le32(reg); in rt2800_efuse_read()
9224 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_efuse_read()
9270 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_validate_eeprom()
9359 drv_data->txmixer_gain_24g = rt2800_get_txmixer_gain_24g(rt2x00dev); in rt2800_validate_eeprom()
9373 drv_data->txmixer_gain_5g = rt2800_get_txmixer_gain_5g(rt2x00dev); in rt2800_validate_eeprom()
9470 return -ENODEV; in rt2800_init_eeprom()
9478 rt2x00dev->default_ant.tx_chain_num = in rt2800_init_eeprom()
9480 rt2x00dev->default_ant.rx_chain_num = in rt2800_init_eeprom()
9495 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
9496 rt2x00dev->default_ant.rx = ANTENNA_A; in rt2800_init_eeprom()
9499 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
9500 rt2x00dev->default_ant.rx = ANTENNA_B; in rt2800_init_eeprom()
9504 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
9505 rt2x00dev->default_ant.rx = ANTENNA_A; in rt2800_init_eeprom()
9511 rt2x00dev->default_ant.tx = ANTENNA_HW_DIVERSITY; /* Unused */ in rt2800_init_eeprom()
9512 rt2x00dev->default_ant.rx = ANTENNA_HW_DIVERSITY; /* Unused */ in rt2800_init_eeprom()
9519 __set_bit(CAPABILITY_EXTERNAL_LNA_A, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9521 __set_bit(CAPABILITY_EXTERNAL_LNA_BG, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9527 __set_bit(CAPABILITY_HW_BUTTON, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9530 * Detect if this device has Bluetooth co-existence. in rt2800_init_eeprom()
9534 __set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9540 rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET); in rt2800_init_eeprom()
9546 rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); in rt2800_init_eeprom()
9547 rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); in rt2800_init_eeprom()
9548 rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY); in rt2800_init_eeprom()
9550 rt2x00dev->led_mcu_reg = eeprom; in rt2800_init_eeprom()
9560 __set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9571 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9575 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9954 struct hw_mode_spec *spec = &rt2x00dev->spec; in rt2800_probe_hw_mode()
9965 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; in rt2800_probe_hw_mode()
9971 rt2x00dev->hw->wiphy->retry_short = 2; in rt2800_probe_hw_mode()
9972 rt2x00dev->hw->wiphy->retry_long = 2; in rt2800_probe_hw_mode()
9977 ieee80211_hw_set(rt2x00dev->hw, REPORTS_TX_ACK_STATUS); in rt2800_probe_hw_mode()
9978 ieee80211_hw_set(rt2x00dev->hw, AMPDU_AGGREGATION); in rt2800_probe_hw_mode()
9979 ieee80211_hw_set(rt2x00dev->hw, PS_NULLFUNC_STACK); in rt2800_probe_hw_mode()
9980 ieee80211_hw_set(rt2x00dev->hw, SIGNAL_DBM); in rt2800_probe_hw_mode()
9981 ieee80211_hw_set(rt2x00dev->hw, SUPPORTS_PS); in rt2800_probe_hw_mode()
9991 ieee80211_hw_set(rt2x00dev->hw, HOST_BROADCAST_PS_BUFFERING); in rt2800_probe_hw_mode()
9993 ieee80211_hw_set(rt2x00dev->hw, MFP_CAPABLE); in rt2800_probe_hw_mode()
9995 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); in rt2800_probe_hw_mode()
9996 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, in rt2800_probe_hw_mode()
10009 rt2x00dev->hw->max_rates = 1; in rt2800_probe_hw_mode()
10010 rt2x00dev->hw->max_report_rates = 7; in rt2800_probe_hw_mode()
10011 rt2x00dev->hw->max_rate_tries = 1; in rt2800_probe_hw_mode()
10016 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; in rt2800_probe_hw_mode()
10018 switch (rt2x00dev->chip.rf) { in rt2800_probe_hw_mode()
10021 spec->num_channels = 14; in rt2800_probe_hw_mode()
10022 spec->channels = rf_vals; in rt2800_probe_hw_mode()
10027 spec->num_channels = ARRAY_SIZE(rf_vals); in rt2800_probe_hw_mode()
10028 spec->channels = rf_vals; in rt2800_probe_hw_mode()
10046 spec->num_channels = 14; in rt2800_probe_hw_mode()
10048 spec->channels = rf_vals_3x_xtal20; in rt2800_probe_hw_mode()
10050 spec->channels = rf_vals_3x; in rt2800_probe_hw_mode()
10054 spec->num_channels = ARRAY_SIZE(rf_vals_7620); in rt2800_probe_hw_mode()
10055 spec->channels = rf_vals_7620; in rt2800_probe_hw_mode()
10060 spec->num_channels = ARRAY_SIZE(rf_vals_3x); in rt2800_probe_hw_mode()
10061 spec->channels = rf_vals_3x; in rt2800_probe_hw_mode()
10065 spec->num_channels = ARRAY_SIZE(rf_vals_3853); in rt2800_probe_hw_mode()
10066 spec->channels = rf_vals_3853; in rt2800_probe_hw_mode()
10072 spec->num_channels = ARRAY_SIZE(rf_vals_5592_xtal40); in rt2800_probe_hw_mode()
10073 spec->channels = rf_vals_5592_xtal40; in rt2800_probe_hw_mode()
10075 spec->num_channels = ARRAY_SIZE(rf_vals_5592_xtal20); in rt2800_probe_hw_mode()
10076 spec->channels = rf_vals_5592_xtal20; in rt2800_probe_hw_mode()
10081 if (WARN_ON_ONCE(!spec->channels)) in rt2800_probe_hw_mode()
10082 return -ENODEV; in rt2800_probe_hw_mode()
10084 spec->supported_bands = SUPPORT_BAND_2GHZ; in rt2800_probe_hw_mode()
10085 if (spec->num_channels > 14) in rt2800_probe_hw_mode()
10086 spec->supported_bands |= SUPPORT_BAND_5GHZ; in rt2800_probe_hw_mode()
10092 spec->ht.ht_supported = true; in rt2800_probe_hw_mode()
10094 spec->ht.ht_supported = false; in rt2800_probe_hw_mode()
10096 spec->ht.cap = in rt2800_probe_hw_mode()
10102 tx_chains = rt2x00dev->default_ant.tx_chain_num; in rt2800_probe_hw_mode()
10103 rx_chains = rt2x00dev->default_ant.rx_chain_num; in rt2800_probe_hw_mode()
10106 spec->ht.cap |= IEEE80211_HT_CAP_TX_STBC; in rt2800_probe_hw_mode()
10108 spec->ht.cap |= rx_chains << IEEE80211_HT_CAP_RX_STBC_SHIFT; in rt2800_probe_hw_mode()
10110 spec->ht.ampdu_factor = (rx_chains > 1) ? 3 : 2; in rt2800_probe_hw_mode()
10111 spec->ht.ampdu_density = 4; in rt2800_probe_hw_mode()
10112 spec->ht.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; in rt2800_probe_hw_mode()
10114 spec->ht.mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; in rt2800_probe_hw_mode()
10115 spec->ht.mcs.tx_params |= in rt2800_probe_hw_mode()
10116 (tx_chains - 1) << IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; in rt2800_probe_hw_mode()
10121 spec->ht.mcs.rx_mask[2] = 0xff; in rt2800_probe_hw_mode()
10124 spec->ht.mcs.rx_mask[1] = 0xff; in rt2800_probe_hw_mode()
10127 spec->ht.mcs.rx_mask[0] = 0xff; in rt2800_probe_hw_mode()
10128 spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */ in rt2800_probe_hw_mode()
10135 info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); in rt2800_probe_hw_mode()
10137 return -ENOMEM; in rt2800_probe_hw_mode()
10139 rt2x00dev->chan_survey = in rt2800_probe_hw_mode()
10140 kcalloc(spec->num_channels, sizeof(struct rt2x00_chan_survey), in rt2800_probe_hw_mode()
10142 if (!rt2x00dev->chan_survey) { in rt2800_probe_hw_mode()
10144 return -ENOMEM; in rt2800_probe_hw_mode()
10147 spec->channels_info = info; in rt2800_probe_hw_mode()
10152 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_probe_hw_mode()
10165 if (spec->num_channels > 14) { in rt2800_probe_hw_mode()
10171 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_probe_hw_mode()
10178 for (i = 14; i < spec->num_channels; i++) { in rt2800_probe_hw_mode()
10179 info[i].default_power1 = default_power1[i - 14]; in rt2800_probe_hw_mode()
10180 info[i].default_power2 = default_power2[i - 14]; in rt2800_probe_hw_mode()
10182 info[i].default_power3 = default_power3[i - 14]; in rt2800_probe_hw_mode()
10186 switch (rt2x00dev->chip.rf) { in rt2800_probe_hw_mode()
10206 __set_bit(CAPABILITY_VCO_RECALIBRATION, &rt2x00dev->cap_flags); in rt2800_probe_hw_mode()
10248 return -ENODEV; in rt2800_probe_rt()
10297 __set_bit(CAPABILITY_CONTROL_FILTERS, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10298 __set_bit(CAPABILITY_CONTROL_FILTER_PSPOLL, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10300 __set_bit(CAPABILITY_PRE_TBTT_INTERRUPT, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10306 __set_bit(REQUIRE_FIRMWARE, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10307 __set_bit(REQUIRE_L2PAD, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10308 __set_bit(REQUIRE_TXSTATUS_FIFO, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10310 __set_bit(CAPABILITY_HW_CRYPTO, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10311 __set_bit(CAPABILITY_LINK_TUNING, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10312 __set_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10314 __set_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10316 __set_bit(REQUIRE_DMA, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10317 __set_bit(REQUIRE_TASKLET_CONTEXT, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10321 __set_bit(CAPABILITY_RESTART_HW, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10322 rt2x00dev->link.watchdog_interval = msecs_to_jiffies(100); in rt2800_probe_hw()
10324 rt2x00dev->link.watchdog_disabled = true; in rt2800_probe_hw()
10330 rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET; in rt2800_probe_hw()
10343 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_key_seq()
10347 if (key->cipher != WLAN_CIPHER_SUITE_TKIP) in rt2800_get_key_seq()
10350 offset = MAC_IVEIV_ENTRY(key->hw_key_idx); in rt2800_get_key_seq()
10354 memcpy(&seq->tkip.iv16, &iveiv_entry.iv[0], 2); in rt2800_get_key_seq()
10355 memcpy(&seq->tkip.iv32, &iveiv_entry.iv[4], 4); in rt2800_get_key_seq()
10361 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_set_rts_threshold()
10401 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_conf_tx()
10433 rt2x00_set_field32(&reg, field, queue->txop); in rt2800_conf_tx()
10441 rt2x00_set_field32(&reg, field, queue->aifs); in rt2800_conf_tx()
10445 rt2x00_set_field32(&reg, field, queue->cw_min); in rt2800_conf_tx()
10449 rt2x00_set_field32(&reg, field, queue->cw_max); in rt2800_conf_tx()
10456 rt2x00_set_field32(&reg, EDCA_AC0_CFG_TX_OP, queue->txop); in rt2800_conf_tx()
10457 rt2x00_set_field32(&reg, EDCA_AC0_CFG_AIFSN, queue->aifs); in rt2800_conf_tx()
10458 rt2x00_set_field32(&reg, EDCA_AC0_CFG_CWMIN, queue->cw_min); in rt2800_conf_tx()
10459 rt2x00_set_field32(&reg, EDCA_AC0_CFG_CWMAX, queue->cw_max); in rt2800_conf_tx()
10468 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_tsf()
10484 struct ieee80211_sta *sta = params->sta; in rt2800_ampdu_action()
10485 enum ieee80211_ampdu_mlme_action action = params->action; in rt2800_ampdu_action()
10486 u16 tid = params->tid; in rt2800_ampdu_action()
10487 struct rt2x00_sta *sta_priv = (struct rt2x00_sta *)sta->drv_priv; in rt2800_ampdu_action()
10497 if (sta_priv->wcid > WCID_END) in rt2800_ampdu_action()
10498 return -ENOSPC; in rt2800_ampdu_action()
10516 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in rt2800_ampdu_action()
10521 rt2x00_warn((struct rt2x00_dev *)hw->priv, in rt2800_ampdu_action()
10532 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_survey()
10534 &rt2x00dev->chan_survey[idx]; in rt2800_get_survey()
10537 if (idx >= rt2x00dev->bands[band].n_channels) { in rt2800_get_survey()
10538 idx -= rt2x00dev->bands[band].n_channels; in rt2800_get_survey()
10542 if (idx >= rt2x00dev->bands[band].n_channels) in rt2800_get_survey()
10543 return -ENOENT; in rt2800_get_survey()
10548 survey->channel = &rt2x00dev->bands[band].channels[idx]; in rt2800_get_survey()
10550 survey->filled = SURVEY_INFO_TIME | in rt2800_get_survey()
10554 survey->time = div_u64(chan_survey->time_idle + chan_survey->time_busy, 1000); in rt2800_get_survey()
10555 survey->time_busy = div_u64(chan_survey->time_busy, 1000); in rt2800_get_survey()
10556 survey->time_ext_busy = div_u64(chan_survey->time_ext_busy, 1000); in rt2800_get_survey()
10558 if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) in rt2800_get_survey()
10559 survey->filled |= SURVEY_INFO_IN_USE; in rt2800_get_survey()