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, ®)) { 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()
1237 if (test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) in rt2800_watchdog()
1241 switch (queue->qid) { in rt2800_watchdog()
1256 if (rt2x00dev->intf_sta_count == 0) in rt2800_watchdog()
1272 ieee80211_restart_hw(rt2x00dev->hw); in rt2800_watchdog()
1290 struct data_queue *queue = rt2x00dev->bcn; in rt2800_update_beacons_setup()
1299 for (i = 0; i < queue->limit; i++) { in rt2800_update_beacons_setup()
1300 entry = &queue->entries[i]; in rt2800_update_beacons_setup()
1301 if (!test_bit(ENTRY_BCN_ENABLED, &entry->flags)) in rt2800_update_beacons_setup()
1303 off = rt2800_get_beacon_offset(rt2x00dev, entry->entry_idx); in rt2800_update_beacons_setup()
1316 bcn_num > 0 ? bcn_num - 1 : 0); in rt2800_update_beacons_setup()
1322 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2800_write_beacon()
1323 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); in rt2800_write_beacon()
1327 const int txwi_desc_size = entry->queue->winfo_size; in rt2800_write_beacon()
1341 memset(skb_push(entry->skb, txwi_desc_size), 0, txwi_desc_size); in rt2800_write_beacon()
1346 skbdesc->flags |= SKBDESC_DESC_IN_SKB; in rt2800_write_beacon()
1347 skbdesc->desc = entry->skb->data; in rt2800_write_beacon()
1348 skbdesc->desc_len = txwi_desc_size; in rt2800_write_beacon()
1363 padding_len = roundup(entry->skb->len, 4) - entry->skb->len; in rt2800_write_beacon()
1364 if (padding_len && skb_pad(entry->skb, padding_len)) { in rt2800_write_beacon()
1367 entry->skb = NULL; in rt2800_write_beacon()
1372 beacon_base = rt2800_hw_beacon_base(rt2x00dev, entry->entry_idx); in rt2800_write_beacon()
1374 rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data, in rt2800_write_beacon()
1375 entry->skb->len + padding_len); in rt2800_write_beacon()
1376 __set_bit(ENTRY_BCN_ENABLED, &entry->flags); in rt2800_write_beacon()
1391 dev_kfree_skb_any(entry->skb); in rt2800_write_beacon()
1392 entry->skb = NULL; in rt2800_write_beacon()
1400 const int txwi_desc_size = rt2x00dev->bcn->winfo_size; in rt2800_clear_beacon_register()
1416 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2800_clear_beacon()
1431 rt2800_clear_beacon_register(rt2x00dev, entry->entry_idx); in rt2800_clear_beacon()
1432 __clear_bit(ENTRY_BCN_ENABLED, &entry->flags); in rt2800_clear_beacon()
1513 (enabled && led->rt2x00dev->curr_band == NL80211_BAND_2GHZ); in rt2800_brightness_set()
1515 rt2x00_get_field16(led->rt2x00dev->led_mcu_reg, in rt2800_brightness_set()
1518 rt2x00_get_field16(led->rt2x00dev->led_mcu_reg, in rt2800_brightness_set()
1523 if (rt2x00_is_soc(led->rt2x00dev)) { in rt2800_brightness_set()
1524 reg = rt2800_register_read(led->rt2x00dev, LED_CFG); in rt2800_brightness_set()
1530 if (led->type == LED_TYPE_RADIO) { in rt2800_brightness_set()
1533 } else if (led->type == LED_TYPE_ASSOC) { in rt2800_brightness_set()
1536 } else if (led->type == LED_TYPE_QUALITY) { in rt2800_brightness_set()
1541 rt2800_register_write(led->rt2x00dev, LED_CFG, reg); in rt2800_brightness_set()
1544 if (led->type == LED_TYPE_RADIO) { in rt2800_brightness_set()
1545 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode, in rt2800_brightness_set()
1547 } else if (led->type == LED_TYPE_ASSOC) { in rt2800_brightness_set()
1548 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode, in rt2800_brightness_set()
1550 } else if (led->type == LED_TYPE_QUALITY) { in rt2800_brightness_set()
1552 * The brightness is divided into 6 levels (0 - 5), in rt2800_brightness_set()
1557 * (1 << level) - 1 in rt2800_brightness_set()
1559 rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff, in rt2800_brightness_set()
1560 (1 << brightness / (LED_FULL / 6)) - 1, in rt2800_brightness_set()
1569 led->rt2x00dev = rt2x00dev; in rt2800_init_led()
1570 led->type = type; in rt2800_init_led()
1571 led->led_dev.brightness_set = rt2800_brightness_set; in rt2800_init_led()
1572 led->flags = LED_INITIALIZED; in rt2800_init_led()
1628 offset = MAC_WCID_ATTR_ENTRY(key->hw_key_idx); in rt2800_config_wcid_attr_cipher()
1630 if (crypto->cmd == SET_KEY) { in rt2800_config_wcid_attr_cipher()
1633 !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)); in rt2800_config_wcid_attr_cipher()
1640 (crypto->cipher & 0x7)); in rt2800_config_wcid_attr_cipher()
1642 (crypto->cipher & 0x8) >> 3); in rt2800_config_wcid_attr_cipher()
1643 rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_RX_WIUDF, crypto->cipher); in rt2800_config_wcid_attr_cipher()
1655 if (test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags)) in rt2800_config_wcid_attr_cipher()
1658 offset = MAC_IVEIV_ENTRY(key->hw_key_idx); in rt2800_config_wcid_attr_cipher()
1661 if ((crypto->cipher == CIPHER_TKIP) || in rt2800_config_wcid_attr_cipher()
1662 (crypto->cipher == CIPHER_TKIP_NO_MIC) || in rt2800_config_wcid_attr_cipher()
1663 (crypto->cipher == CIPHER_AES)) in rt2800_config_wcid_attr_cipher()
1665 iveiv_entry.iv[3] |= key->keyidx << 6; in rt2800_config_wcid_attr_cipher()
1679 if (crypto->cmd == SET_KEY) { in rt2800_config_shared_key()
1680 key->hw_key_idx = (4 * crypto->bssidx) + key->keyidx; in rt2800_config_shared_key()
1682 memcpy(key_entry.key, crypto->key, in rt2800_config_shared_key()
1684 memcpy(key_entry.tx_mic, crypto->tx_mic, in rt2800_config_shared_key()
1686 memcpy(key_entry.rx_mic, crypto->rx_mic, in rt2800_config_shared_key()
1689 offset = SHARED_KEY_ENTRY(key->hw_key_idx); in rt2800_config_shared_key()
1701 field.bit_offset = 4 * (key->hw_key_idx % 8); in rt2800_config_shared_key()
1704 offset = SHARED_KEY_MODE_ENTRY(key->hw_key_idx / 8); in rt2800_config_shared_key()
1708 (crypto->cmd == SET_KEY) * crypto->cipher); in rt2800_config_shared_key()
1714 rt2800_config_wcid(rt2x00dev, crypto->address, key->hw_key_idx); in rt2800_config_shared_key()
1715 rt2800_config_wcid_attr_bssidx(rt2x00dev, key->hw_key_idx, in rt2800_config_shared_key()
1716 crypto->bssidx); in rt2800_config_shared_key()
1730 if (crypto->cmd == SET_KEY) { in rt2800_config_pairwise_key()
1735 if (crypto->wcid > WCID_END) in rt2800_config_pairwise_key()
1736 return -ENOSPC; in rt2800_config_pairwise_key()
1737 key->hw_key_idx = crypto->wcid; in rt2800_config_pairwise_key()
1739 memcpy(key_entry.key, crypto->key, in rt2800_config_pairwise_key()
1741 memcpy(key_entry.tx_mic, crypto->tx_mic, in rt2800_config_pairwise_key()
1743 memcpy(key_entry.rx_mic, crypto->rx_mic, in rt2800_config_pairwise_key()
1746 offset = PAIRWISE_KEY_ENTRY(key->hw_key_idx); in rt2800_config_pairwise_key()
1764 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_set_max_psdu_len()
1767 if (drv_data->ampdu_factor_cnt[i] > 0) in rt2800_set_max_psdu_len()
1770 max_psdu = min(drv_data->max_psdu, i); in rt2800_set_max_psdu_len()
1780 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_sta_add()
1781 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_sta_add()
1791 if (sta->ht_cap.ht_supported) { in rt2800_sta_add()
1792 drv_data->ampdu_factor_cnt[sta->ht_cap.ampdu_factor & 3]++; in rt2800_sta_add()
1800 wcid = find_first_zero_bit(drv_data->sta_ids, STA_IDS_SIZE) + WCID_START; in rt2800_sta_add()
1806 sta_priv->wcid = wcid; in rt2800_sta_add()
1810 * with the STA -> No error. in rt2800_sta_add()
1815 __set_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_sta_add()
1816 drv_data->wcid_to_sta[wcid - WCID_START] = sta; in rt2800_sta_add()
1822 rt2800_config_wcid(rt2x00dev, sta->addr, wcid); in rt2800_sta_add()
1832 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_sta_remove()
1833 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_sta_remove()
1835 int wcid = sta_priv->wcid; in rt2800_sta_remove()
1837 if (sta->ht_cap.ht_supported) { in rt2800_sta_remove()
1838 drv_data->ampdu_factor_cnt[sta->ht_cap.ampdu_factor & 3]--; in rt2800_sta_remove()
1849 drv_data->wcid_to_sta[wcid - WCID_START] = NULL; in rt2800_sta_remove()
1850 __clear_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_sta_remove()
1858 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_pre_reset_hw()
1859 struct data_queue *queue = rt2x00dev->bcn; in rt2800_pre_reset_hw()
1864 drv_data->wcid_to_sta[wcid - WCID_START] = NULL; in rt2800_pre_reset_hw()
1865 __clear_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_pre_reset_hw()
1868 for (i = 0; i < queue->limit; i++) { in rt2800_pre_reset_hw()
1869 entry = &queue->entries[i]; in rt2800_pre_reset_hw()
1870 clear_bit(ENTRY_BCN_ASSIGNED, &entry->flags); in rt2800_pre_reset_hw()
1892 !test_bit(CONFIG_MONITORING, &rt2x00dev->flags)); in rt2800_config_filter()
1931 rt2x00_set_field32(®, BCN_TIME_CFG_TSF_SYNC, conf->sync); in rt2800_config_intf()
1934 if (conf->sync == TSF_SYNC_AP_NONE) { in rt2800_config_intf()
1956 conf->sync == TSF_SYNC_AP_NONE) { in rt2800_config_intf()
1961 memcpy(conf->bssid, conf->mac, sizeof(conf->mac)); in rt2800_config_intf()
1965 if (!is_zero_ether_addr((const u8 *)conf->mac)) { in rt2800_config_intf()
1966 reg = le32_to_cpu(conf->mac[1]); in rt2800_config_intf()
1968 conf->mac[1] = cpu_to_le32(reg); in rt2800_config_intf()
1972 conf->mac, sizeof(conf->mac)); in rt2800_config_intf()
1976 if (!is_zero_ether_addr((const u8 *)conf->bssid)) { in rt2800_config_intf()
1977 reg = le32_to_cpu(conf->bssid[1]); in rt2800_config_intf()
1980 conf->bssid[1] = cpu_to_le32(reg); in rt2800_config_intf()
1984 conf->bssid, sizeof(conf->bssid)); in rt2800_config_intf()
1992 bool any_sta_nongf = !!(erp->ht_opmode & in rt2800_config_ht_opmode()
1994 u8 protection = erp->ht_opmode & IEEE80211_HT_OP_MODE_PROTECTION; in rt2800_config_ht_opmode()
2038 * -> fall through to mixed mode. in rt2800_config_ht_opmode()
2051 if (erp->cts_protection) { in rt2800_config_ht_opmode()
2052 /* don't duplicate RTS/CTS in CCK mode */ in rt2800_config_ht_opmode()
2093 !!erp->short_preamble); in rt2800_config_erp()
2100 erp->cts_protection ? 2 : 0); in rt2800_config_erp()
2106 0xff0 | erp->basic_rates); in rt2800_config_erp()
2113 erp->slot_time); in rt2800_config_erp()
2117 rt2x00_set_field32(®, XIFS_TIME_CFG_EIFS, erp->eifs); in rt2800_config_erp()
2124 erp->beacon_int * 16); in rt2800_config_erp()
2140 if (rt2x00dev->curr_band == NL80211_BAND_5GHZ) { in rt2800_config_3572bt_ant()
2204 switch (ant->tx_chain_num) { in rt2800_config_ant()
2223 switch (ant->rx_chain_num) { in rt2800_config_ant()
2234 rt2x00dev->default_ant.rx); in rt2800_config_ant()
2243 rt2x00dev->curr_band == NL80211_BAND_5GHZ); in rt2800_config_ant()
2259 if (ant->rx_chain_num == 1) in rt2800_config_ant()
2273 if (libconf->rf.channel <= 14) { in rt2800_config_lna_gain()
2276 } else if (libconf->rf.channel <= 64) { in rt2800_config_lna_gain()
2279 } else if (libconf->rf.channel <= 128) { in rt2800_config_lna_gain()
2303 rt2x00dev->lna_gain = lna_gain; in rt2800_config_lna_gain()
2308 return clk_get_rate(rt2x00dev->clk) == 20000000; in rt2800_clk_is_20mhz()
2318 freq_offset = rt2x00_get_field8(rt2x00dev->freq_offset, RFCSR17_CODE); in rt2800_freq_cal_mode1()
2339 prev_freq_offset--; in rt2800_freq_cal_mode1()
2353 rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf2xxx()
2355 if (rt2x00dev->default_ant.tx_chain_num == 1) in rt2800_config_channel_rf2xxx()
2356 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_TX1, 1); in rt2800_config_channel_rf2xxx()
2358 if (rt2x00dev->default_ant.rx_chain_num == 1) { in rt2800_config_channel_rf2xxx()
2359 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX1, 1); in rt2800_config_channel_rf2xxx()
2360 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1); in rt2800_config_channel_rf2xxx()
2361 } else if (rt2x00dev->default_ant.rx_chain_num == 2) in rt2800_config_channel_rf2xxx()
2362 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1); in rt2800_config_channel_rf2xxx()
2364 if (rf->channel > 14) { in rt2800_config_channel_rf2xxx()
2367 * make it a positive value (Minimum value is -7). in rt2800_config_channel_rf2xxx()
2371 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A_7DBM_BOOST, in rt2800_config_channel_rf2xxx()
2372 (info->default_power1 >= 0)); in rt2800_config_channel_rf2xxx()
2374 if (info->default_power1 < 0) in rt2800_config_channel_rf2xxx()
2375 info->default_power1 += 7; in rt2800_config_channel_rf2xxx()
2377 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A, info->default_power1); in rt2800_config_channel_rf2xxx()
2379 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A_7DBM_BOOST, in rt2800_config_channel_rf2xxx()
2380 (info->default_power2 >= 0)); in rt2800_config_channel_rf2xxx()
2382 if (info->default_power2 < 0) in rt2800_config_channel_rf2xxx()
2383 info->default_power2 += 7; in rt2800_config_channel_rf2xxx()
2385 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A, info->default_power2); in rt2800_config_channel_rf2xxx()
2387 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_G, info->default_power1); in rt2800_config_channel_rf2xxx()
2388 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_G, info->default_power2); in rt2800_config_channel_rf2xxx()
2391 rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf)); in rt2800_config_channel_rf2xxx()
2393 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2394 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2395 rt2800_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004); in rt2800_config_channel_rf2xxx()
2396 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2400 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2401 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2402 rt2800_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004); in rt2800_config_channel_rf2xxx()
2403 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2407 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2408 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2409 rt2800_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004); in rt2800_config_channel_rf2xxx()
2410 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2418 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3xxx()
2421 rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); in rt2800_config_channel_rf3xxx()
2424 rt2x00_set_field8(&rfcsr, RFCSR3_K, rf->rf3); in rt2800_config_channel_rf3xxx()
2428 rt2x00_set_field8(&rfcsr, RFCSR6_R1, rf->rf2); in rt2800_config_channel_rf3xxx()
2432 rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER, info->default_power1); in rt2800_config_channel_rf3xxx()
2436 rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER, info->default_power2); in rt2800_config_channel_rf3xxx()
2442 rt2x00dev->default_ant.rx_chain_num <= 1); in rt2800_config_channel_rf3xxx()
2444 rt2x00dev->default_ant.rx_chain_num <= 2); in rt2800_config_channel_rf3xxx()
2447 rt2x00dev->default_ant.tx_chain_num <= 1); in rt2800_config_channel_rf3xxx()
2449 rt2x00dev->default_ant.tx_chain_num <= 2); in rt2800_config_channel_rf3xxx()
2453 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf3xxx()
2461 calib_tx = drv_data->calibration_bw40; in rt2800_config_channel_rf3xxx()
2462 calib_rx = drv_data->calibration_bw40; in rt2800_config_channel_rf3xxx()
2464 calib_tx = drv_data->calibration_bw20; in rt2800_config_channel_rf3xxx()
2465 calib_rx = drv_data->calibration_bw20; in rt2800_config_channel_rf3xxx()
2496 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3052()
2500 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2501 rt2800_bbp_write(rt2x00dev, 25, drv_data->bbp25); in rt2800_config_channel_rf3052()
2502 rt2800_bbp_write(rt2x00dev, 26, drv_data->bbp26); in rt2800_config_channel_rf3052()
2508 rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); in rt2800_config_channel_rf3052()
2509 rt2800_rfcsr_write(rt2x00dev, 3, rf->rf3); in rt2800_config_channel_rf3052()
2512 rt2x00_set_field8(&rfcsr, RFCSR6_R1, rf->rf2); in rt2800_config_channel_rf3052()
2513 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2520 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2527 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2530 info->default_power1); in rt2800_config_channel_rf3052()
2534 (info->default_power1 & 0x3) | in rt2800_config_channel_rf3052()
2535 ((info->default_power1 & 0xC) << 1)); in rt2800_config_channel_rf3052()
2540 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2543 info->default_power2); in rt2800_config_channel_rf3052()
2547 (info->default_power2 & 0x3) | in rt2800_config_channel_rf3052()
2548 ((info->default_power2 & 0xC) << 1)); in rt2800_config_channel_rf3052()
2560 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2567 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3052()
2576 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3052()
2588 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf3052()
2592 rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw40); in rt2800_config_channel_rf3052()
2593 rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw40); in rt2800_config_channel_rf3052()
2595 rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw20); in rt2800_config_channel_rf3052()
2596 rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw20); in rt2800_config_channel_rf3052()
2599 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2607 drv_data->txmixer_gain_24g); in rt2800_config_channel_rf3052()
2629 drv_data->txmixer_gain_5g); in rt2800_config_channel_rf3052()
2632 if (rf->channel <= 64) { in rt2800_config_channel_rf3052()
2636 } else if (rf->channel <= 128) { in rt2800_config_channel_rf3052()
2652 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2668 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3053()
2685 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2687 rt2800_bbp_write(rt2x00dev, 25, drv_data->bbp25); in rt2800_config_channel_rf3053()
2688 rt2800_bbp_write(rt2x00dev, 26, drv_data->bbp26); in rt2800_config_channel_rf3053()
2698 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3053()
2699 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3 & 0xf); in rt2800_config_channel_rf3053()
2702 rt2x00_set_field8(&rfcsr, RFCSR11_R, (rf->rf2 & 0x3)); in rt2800_config_channel_rf3053()
2707 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2714 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2717 info->default_power1 & 0x1f); in rt2800_config_channel_rf3053()
2723 ((info->default_power1 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2724 (info->default_power1 & 7)); in rt2800_config_channel_rf3053()
2729 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2732 info->default_power2 & 0x1f); in rt2800_config_channel_rf3053()
2738 ((info->default_power2 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2739 (info->default_power2 & 7)); in rt2800_config_channel_rf3053()
2744 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2747 info->default_power3 & 0x1f); in rt2800_config_channel_rf3053()
2753 ((info->default_power3 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2754 (info->default_power3 & 7)); in rt2800_config_channel_rf3053()
2768 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3053()
2780 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3053()
2796 txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw40, in rt2800_config_channel_rf3053()
2798 txrx_h20m = rt2x00_get_field8(drv_data->calibration_bw40, in rt2800_config_channel_rf3053()
2801 txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw20, in rt2800_config_channel_rf3053()
2803 txrx_h20m = rt2x00_get_field8(drv_data->calibration_bw20, in rt2800_config_channel_rf3053()
2813 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2826 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2833 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2840 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2847 if (rf->channel >= 1 && rf->channel <= 14) in rt2800_config_channel_rf3053()
2849 else if (rf->channel >= 36 && rf->channel <= 64) in rt2800_config_channel_rf3053()
2851 else if (rf->channel >= 100 && rf->channel <= 128) in rt2800_config_channel_rf3053()
2863 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2876 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2886 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2901 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2907 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2917 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2929 if (rf->channel >= 1 && rf->channel <= 14) { in rt2800_config_channel_rf3053()
2936 } else if (rf->channel >= 36 && rf->channel <= 64) { in rt2800_config_channel_rf3053()
2943 } else if (rf->channel >= 100 && rf->channel <= 128) { in rt2800_config_channel_rf3053()
2973 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
2975 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
2980 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3853()
2981 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3853()
2983 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
2988 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3005 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3853()
3017 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3853()
3039 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3049 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3056 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3062 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3064 else if (rf->channel < 100) in rt2800_config_channel_rf3853()
3066 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
3076 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3081 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3083 else if (rf->channel < 100) in rt2800_config_channel_rf3853()
3085 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
3091 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3104 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3110 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3115 if (rf->channel <= 14) { in rt2800_config_channel_rf3853()
3116 pwr1 = info->default_power1 & 0x1f; in rt2800_config_channel_rf3853()
3117 pwr2 = info->default_power2 & 0x1f; in rt2800_config_channel_rf3853()
3118 pwr3 = info->default_power3 & 0x1f; in rt2800_config_channel_rf3853()
3120 pwr1 = 0x48 | ((info->default_power1 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3121 (info->default_power1 & 0x7); in rt2800_config_channel_rf3853()
3122 pwr2 = 0x48 | ((info->default_power2 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3123 (info->default_power2 & 0x7); in rt2800_config_channel_rf3853()
3124 pwr3 = 0x48 | ((info->default_power3 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3125 (info->default_power3 & 0x7); in rt2800_config_channel_rf3853()
3133 rf->channel, pwr1, pwr2, pwr3); in rt2800_config_channel_rf3853()
3135 bbp = (info->default_power1 >> 5) | in rt2800_config_channel_rf3853()
3136 ((info->default_power2 & 0xe0) >> 1); in rt2800_config_channel_rf3853()
3141 bbp |= (info->default_power3 & 0xe0) >> 1; in rt2800_config_channel_rf3853()
3145 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3175 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3290()
3176 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3290()
3178 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf2); in rt2800_config_channel_rf3290()
3182 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf3290()
3185 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf3290()
3190 if (rf->channel <= 14) { in rt2800_config_channel_rf3290()
3191 if (rf->channel == 6) in rt2800_config_channel_rf3290()
3196 if (rf->channel >= 1 && rf->channel <= 6) in rt2800_config_channel_rf3290()
3198 else if (rf->channel >= 7 && rf->channel <= 11) in rt2800_config_channel_rf3290()
3200 else if (rf->channel >= 12 && rf->channel <= 14) in rt2800_config_channel_rf3290()
3212 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3322()
3213 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3322()
3219 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf3322()
3222 rt2800_rfcsr_write(rt2x00dev, 47, info->default_power1); in rt2800_config_channel_rf3322()
3224 if (info->default_power2 > POWER_BOUND) in rt2800_config_channel_rf3322()
3227 rt2800_rfcsr_write(rt2x00dev, 48, info->default_power2); in rt2800_config_channel_rf3322()
3235 if ( rt2x00dev->default_ant.tx_chain_num == 2 ) in rt2800_config_channel_rf3322()
3240 if ( rt2x00dev->default_ant.rx_chain_num == 2 ) in rt2800_config_channel_rf3322()
3259 int idx = rf->channel-1; in rt2800_config_channel_rf53xx()
3261 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf53xx()
3262 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf53xx()
3264 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf2); in rt2800_config_channel_rf53xx()
3268 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf53xx()
3271 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf53xx()
3276 if (info->default_power2 > POWER_BOUND) in rt2800_config_channel_rf53xx()
3280 info->default_power2); in rt2800_config_channel_rf53xx()
3366 (rf->channel > 14 || conf_is_ht40(conf)) ? 5 : 0); in rt2800_config_channel_rf55xx()
3370 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1 & 0xff); in rt2800_config_channel_rf55xx()
3373 rt2x00_set_field8(&rfcsr, RFCSR9_K, rf->rf2 & 0xf); in rt2800_config_channel_rf55xx()
3374 rt2x00_set_field8(&rfcsr, RFCSR9_N, (rf->rf1 & 0x100) >> 8); in rt2800_config_channel_rf55xx()
3375 rt2x00_set_field8(&rfcsr, RFCSR9_MOD, ((rf->rf3 - 8) & 0x4) >> 2); in rt2800_config_channel_rf55xx()
3379 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf4 - 1); in rt2800_config_channel_rf55xx()
3380 rt2x00_set_field8(&rfcsr, RFCSR11_MOD, (rf->rf3 - 8) & 0x3); in rt2800_config_channel_rf55xx()
3383 if (rf->channel <= 14) { in rt2800_config_channel_rf55xx()
3415 /* TODO RF27 <- tssi */ in rt2800_config_channel_rf55xx()
3417 rfcsr = rf->channel <= 10 ? 0x07 : 0x06; in rt2800_config_channel_rf55xx()
3457 /* TODO RF27 <- tssi */ in rt2800_config_channel_rf55xx()
3459 if (rf->channel >= 36 && rf->channel <= 64) { in rt2800_config_channel_rf55xx()
3465 if (rf->channel <= 50) in rt2800_config_channel_rf55xx()
3467 else if (rf->channel >= 52) in rt2800_config_channel_rf55xx()
3476 if (rf->channel <= 50) { in rt2800_config_channel_rf55xx()
3479 } else if (rf->channel >= 52) { in rt2800_config_channel_rf55xx()
3488 } else if (rf->channel >= 100 && rf->channel <= 165) { in rt2800_config_channel_rf55xx()
3493 if (rf->channel <= 153) { in rt2800_config_channel_rf55xx()
3496 } else if (rf->channel >= 155) { in rt2800_config_channel_rf55xx()
3500 if (rf->channel <= 138) { in rt2800_config_channel_rf55xx()
3505 } else if (rf->channel >= 140) { in rt2800_config_channel_rf55xx()
3511 if (rf->channel <= 124) in rt2800_config_channel_rf55xx()
3513 else if (rf->channel >= 126) in rt2800_config_channel_rf55xx()
3515 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3517 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3520 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3522 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3524 if (rf->channel <= 128) in rt2800_config_channel_rf55xx()
3526 else if (rf->channel >= 130) in rt2800_config_channel_rf55xx()
3528 if (rf->channel <= 116) in rt2800_config_channel_rf55xx()
3530 else if (rf->channel >= 118) in rt2800_config_channel_rf55xx()
3532 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3534 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3536 if (rf->channel <= 116) in rt2800_config_channel_rf55xx()
3538 else if (rf->channel >= 118) in rt2800_config_channel_rf55xx()
3547 if (info->default_power1 > power_bound) in rt2800_config_channel_rf55xx()
3550 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf55xx()
3556 if (info->default_power2 > power_bound) in rt2800_config_channel_rf55xx()
3559 rt2x00_set_field8(&rfcsr, RFCSR50_TX, info->default_power2); in rt2800_config_channel_rf55xx()
3569 rt2x00dev->default_ant.tx_chain_num >= 1); in rt2800_config_channel_rf55xx()
3571 rt2x00dev->default_ant.tx_chain_num == 2); in rt2800_config_channel_rf55xx()
3575 rt2x00dev->default_ant.rx_chain_num >= 1); in rt2800_config_channel_rf55xx()
3577 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_config_channel_rf55xx()
3602 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3603 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3604 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3606 rt2800_bbp_write(rt2x00dev, 79, (rf->channel <= 14) ? 0x1C : 0x18); in rt2800_config_channel_rf55xx()
3607 rt2800_bbp_write(rt2x00dev, 80, (rf->channel <= 14) ? 0x0E : 0x08); in rt2800_config_channel_rf55xx()
3608 rt2800_bbp_write(rt2x00dev, 81, (rf->channel <= 14) ? 0x3A : 0x38); in rt2800_config_channel_rf55xx()
3609 rt2800_bbp_write(rt2x00dev, 82, (rf->channel <= 14) ? 0x62 : 0x92); in rt2800_config_channel_rf55xx()
3613 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0xE0 : 0xF0); in rt2800_config_channel_rf55xx()
3615 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x1F : 0x1E); in rt2800_config_channel_rf55xx()
3617 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x38 : 0x28); in rt2800_config_channel_rf55xx()
3619 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x32 : 0x20); in rt2800_config_channel_rf55xx()
3621 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x28 : 0x7F); in rt2800_config_channel_rf55xx()
3623 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x19 : 0x7F); in rt2800_config_channel_rf55xx()
3631 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf7620()
3645 * R20[7:0] in rf->rf1 in rt2800_config_channel_rf7620()
3649 rfcsr = (rf->rf1 & 0x00ff); in rt2800_config_channel_rf7620()
3671 * Ksd: R17<7:0> in rf->rf2 in rt2800_config_channel_rf7620()
3672 * R18<7:0> in rf->rf3 in rt2800_config_channel_rf7620()
3673 * R19<1:0> in rf->rf4 in rt2800_config_channel_rf7620()
3676 rfcsr = rf->rf2; in rt2800_config_channel_rf7620()
3680 rfcsr = rf->rf3; in rt2800_config_channel_rf7620()
3684 rt2x00_set_field8(&rfcsr, RFCSR19_K, rf->rf4); in rt2800_config_channel_rf7620()
3698 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3703 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3705 rt2x00dev->default_ant.rx_chain_num != 1); in rt2800_config_channel_rf7620()
3710 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3738 conf_is_ht40(conf) && (rf->channel == 11)); in rt2800_config_channel_rf7620()
3741 if (!test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) { in rt2800_config_channel_rf7620()
3743 rx_agc_fc = drv_data->rx_calibration_bw40; in rt2800_config_channel_rf7620()
3744 tx_agc_fc = drv_data->tx_calibration_bw40; in rt2800_config_channel_rf7620()
3746 rx_agc_fc = drv_data->rx_calibration_bw20; in rt2800_config_channel_rf7620()
3747 tx_agc_fc = drv_data->tx_calibration_bw20; in rt2800_config_channel_rf7620()
3799 max_power = chan->max_power * 2; in rt2800_config_alc()
3839 if (chan->center_freq > 2457) { in rt2800_config_alc()
3869 for (chain = 0; chain < rt2x00dev->default_ant.rx_chain_num; chain++) { in rt2800_bbp_write_with_rx_chain()
3988 bbp = (rf->channel > 14) ? 0x48 : 0x38; in rt3883_bbp_adjust()
3993 if (rf->channel <= 14) { in rt3883_bbp_adjust()
4002 if (rf->channel > 14) { in rt3883_bbp_adjust()
4022 info->default_power1 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4023 info->default_power1); in rt2800_config_channel()
4024 info->default_power2 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4025 info->default_power2); in rt2800_config_channel()
4026 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_config_channel()
4027 info->default_power3 = in rt2800_config_channel()
4028 rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4029 info->default_power3); in rt2800_config_channel()
4031 switch (rt2x00dev->chip.rt) { in rt2800_config_channel()
4037 switch (rt2x00dev->chip.rf) { in rt2800_config_channel()
4114 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4115 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4116 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4119 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); in rt2800_config_channel()
4121 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); in rt2800_config_channel()
4125 if (rf->channel > 14) { in rt2800_config_channel()
4137 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4138 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4139 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4142 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4143 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4144 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4146 if (rt2x00dev->default_ant.rx_chain_num > 1) in rt2800_config_channel()
4151 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4152 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4153 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4157 if (rf->channel <= 14) { in rt2800_config_channel()
4198 rt2x00_set_field32(®, TX_BAND_CFG_A, rf->channel > 14); in rt2800_config_channel()
4199 rt2x00_set_field32(®, TX_BAND_CFG_BG, rf->channel <= 14); in rt2800_config_channel()
4212 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel()
4216 rf->channel > 14); in rt2800_config_channel()
4218 rf->channel <= 14); in rt2800_config_channel()
4223 rf->channel > 14); in rt2800_config_channel()
4225 rf->channel <= 14); in rt2800_config_channel()
4230 rf->channel > 14); in rt2800_config_channel()
4235 rf->channel <= 14); in rt2800_config_channel()
4239 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel()
4266 if (rf->channel <= 14) in rt2800_config_channel()
4267 reg = 0x1c + (2 * rt2x00dev->lna_gain); in rt2800_config_channel()
4269 reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4282 if (rf->channel <= 14) in rt2800_config_channel()
4307 if (rf->channel <= 14) in rt2800_config_channel()
4308 reg = 0x1c + 2 * rt2x00dev->lna_gain; in rt2800_config_channel()
4310 reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4324 if (rf->channel <= 14) in rt2800_config_channel()
4325 reg = 0x2e + rt2x00dev->lna_gain; in rt2800_config_channel()
4327 reg = 0x20 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4352 reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain; in rt2800_config_channel()
4355 rt2800_iq_calibrate(rt2x00dev, rf->channel); in rt2800_config_channel()
4418 * Matching Delta value -4 -3 -2 -1 0 +1 +2 +3 +4 in rt2800_get_gain_calibration_delta()
4421 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_get_gain_calibration_delta()
4506 for (i = 8; i >= 5; i--) { in rt2800_get_gain_calibration_delta()
4512 return (i - 4) * step; in rt2800_get_gain_calibration_delta()
4529 !test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_get_txpower_bw_comp()
4541 comp_value = -comp_value; in rt2800_get_txpower_bw_comp()
4552 comp_value = -comp_value; in rt2800_get_txpower_bw_comp()
4576 delta = power_level - max_power; in rt2800_get_txpower_reg_delta()
4619 eirp_txpower = eirp_txpower_criterion + (txpower - criterion) + in rt2800_compensate_txpower()
4623 (eirp_txpower - power_level) : 0; in rt2800_compensate_txpower()
4627 txpower = max(0, txpower + delta - reg_limit); in rt2800_compensate_txpower()
4659 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt3593()
4675 if (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_config_txpower_rt3593()
5029 (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) ? in rt2800_config_txpower_rt3593()
5032 (i - TX_PWR_CFG_9_IDX - 1) : i, in rt2800_config_txpower_rt3593()
5045 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt6352()
5058 * Maybe some misunderstanding of what a signed 8-bit value is? Maybe in rt2800_config_txpower_rt6352()
5060 * used a fixed offset between HT20 and HT40 rates they had to work- in rt2800_config_txpower_rt6352()
5105 if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) { in rt2800_config_txpower_rt6352()
5122 * registers. As recent 2T chips use 8-bit instead of 4-bit values for in rt2800_config_txpower_rt6352()
5123 * power-offsets more space would be needed. Ralink decided to keep the in rt2800_config_txpower_rt6352()
5165 * for all rates, but allow to set only 4 discrete values: -12, -6, 0 and 6 dBm.
5178 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt28xx()
5193 switch (rt2x00dev->chip.rt) { in rt2800_config_txpower_rt28xx()
5214 chan->max_power); in rt2800_config_txpower_rt28xx()
5218 * gains -12, -6, 0, +6 dBm by setting values 2, 1, 0, 3 respectively. in rt2800_config_txpower_rt28xx()
5224 if (delta <= -12) { in rt2800_config_txpower_rt28xx()
5227 } else if (delta <= -6) { in rt2800_config_txpower_rt28xx()
5368 rt2800_config_txpower(rt2x00dev, rt2x00dev->hw->conf.chandef.chan, in rt2800_gain_calibration()
5369 rt2x00dev->tx_power); in rt2800_gain_calibration()
5380 * A voltage-controlled oscillator(VCO) is an electronic oscillator in rt2800_vco_calibration()
5391 switch (rt2x00dev->chip.rf) { in rt2800_vco_calibration()
5429 rt2x00dev->chip.rf); in rt2800_vco_calibration()
5437 if (rt2x00dev->rf_channel <= 14) { in rt2800_vco_calibration()
5438 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_vco_calibration()
5451 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_vco_calibration()
5467 if (rt2x00dev->default_ant.rx_chain_num == 1) { in rt2800_vco_calibration()
5497 * 2005/06/05 - On 11G, we also need this delay time. in rt2800_vco_calibration()
5512 libconf->conf->short_frame_max_tx_count); in rt2800_config_retry_limit()
5514 libconf->conf->long_frame_max_tx_count); in rt2800_config_retry_limit()
5522 (libconf->conf->flags & IEEE80211_CONF_PS) ? in rt2800_config_ps()
5532 libconf->conf->listen_interval - 1); in rt2800_config_ps()
5536 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); in rt2800_config_ps()
5544 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); in rt2800_config_ps()
5556 rt2800_config_channel(rt2x00dev, libconf->conf, in rt2800_config()
5557 &libconf->rf, &libconf->channel); in rt2800_config()
5558 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, in rt2800_config()
5559 libconf->conf->power_level); in rt2800_config()
5562 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, in rt2800_config()
5563 libconf->conf->power_level); in rt2800_config()
5582 qual->rx_failed = rt2x00_get_field32(reg, RX_STA_CNT0_CRC_ERR); in rt2800_link_stats()
5590 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_get_default_vgc()
5602 vgc = 0x1c + (2 * rt2x00dev->lna_gain); in rt2800_get_default_vgc()
5604 vgc = 0x2e + rt2x00dev->lna_gain; in rt2800_get_default_vgc()
5608 vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5610 vgc = 0x24 + (2 * rt2x00dev->lna_gain); in rt2800_get_default_vgc()
5612 if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_get_default_vgc()
5613 vgc = 0x32 + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5615 vgc = 0x3a + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5625 if (qual->vgc_level != vgc_level) { in rt2800_set_vgc()
5632 rt2800_bbp_write(rt2x00dev, 83, qual->rssi > -65 ? 0x4a : 0x7a); in rt2800_set_vgc()
5638 qual->vgc_level = vgc_level; in rt2800_set_vgc()
5639 qual->vgc_level_reg = vgc_level; in rt2800_set_vgc()
5664 switch (rt2x00dev->chip.rt) { in rt2800_link_tuner()
5667 if (qual->rssi > -65) { in rt2800_link_tuner()
5668 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) in rt2800_link_tuner()
5676 if (qual->rssi > -65) in rt2800_link_tuner()
5681 if (qual->rssi > -65) in rt2800_link_tuner()
5686 if (qual->rssi > -80) in rt2800_link_tuner()
5700 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_init_registers()
5890 drv_data->max_psdu = 3; in rt2800_init_registers()
5894 drv_data->max_psdu = 2; in rt2800_init_registers()
5896 drv_data->max_psdu = 1; in rt2800_init_registers()
5898 rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, drv_data->max_psdu); in rt2800_init_registers()
6066 * connection problems with 11g + CTS protection. Hence, use the same in rt2800_init_registers()
6095 if (!test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags)) in rt2800_init_registers()
6210 return -EACCES; in rt2800_wait_bbp_rf_ready()
6234 return -EACCES; in rt2800_wait_bbp_ready()
6486 /* Use 5-bit ADC for Acquisition and 8-bit ADC for data */ in rt2800_init_bbp_3290()
6836 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_init_bbp_5592()
6927 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_init_bbp_6352()
6933 /* Fix I/Q swap issue */ in rt2800_init_bbp_6352()
7134 switch (rt2x00dev->chip.rt) { in rt2800_init_bbp()
7247 if ((passband - stopband) <= filter_target) { in rt2800_init_rx_filter()
7249 overtuned += ((passband - stopband) == filter_target); in rt2800_init_rx_filter()
7256 rfcsr24 -= !!overtuned; in rt2800_init_rx_filter()
7277 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_rx_filter_calibration()
7293 drv_data->calibration_bw20 = in rt2800_rx_filter_calibration()
7295 drv_data->calibration_bw40 = in rt2800_rx_filter_calibration()
7301 drv_data->bbp25 = rt2800_bbp_read(rt2x00dev, 25); in rt2800_rx_filter_calibration()
7302 drv_data->bbp26 = rt2800_bbp_read(rt2x00dev, 26); in rt2800_rx_filter_calibration()
7323 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_normal_mode_setup_3xxx()
7339 if (drv_data->txmixer_gain_24g >= min_gain) { in rt2800_normal_mode_setup_3xxx()
7341 drv_data->txmixer_gain_24g); in rt2800_normal_mode_setup_3xxx()
7394 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_normal_mode_setup_3593()
7403 tx_gain = rt2x00_get_field8(drv_data->txmixer_gain_24g, in rt2800_normal_mode_setup_3593()
7629 &rt2x00dev->cap_flags); in rt2800_init_rfcsr_3352()
7631 &rt2x00dev->cap_flags); in rt2800_init_rfcsr_3352()
7841 if (rt2x00dev->default_ant.rx_chain_num == 1) in rt3593_post_bbp_init()
7884 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_init_rfcsr_3593()
7950 drv_data->calibration_bw20 = 0x1f; in rt2800_init_rfcsr_3593()
7951 drv_data->calibration_bw40 = 0x2f; in rt2800_init_rfcsr_3593()
7954 drv_data->bbp25 = rt2800_bbp_read(rt2x00dev, 25); in rt2800_init_rfcsr_3593()
7955 drv_data->bbp26 = rt2800_bbp_read(rt2x00dev, 26); in rt2800_init_rfcsr_3593()
8471 cal_val -= 128; in rt2800_lp_tx_filter_bw_cal()
8479 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_bw_filter_calibration()
8556 /* I-3 */ in rt2800_bw_filter_calibration()
8563 /* I-4,5,6,7,8,9 */ in rt2800_bw_filter_calibration()
8648 cal_diff = cal_r32_init - cal_r32_val; in rt2800_bw_filter_calibration()
8671 drv_data->tx_calibration_bw20 = tx_agc_fc; in rt2800_bw_filter_calibration()
8673 drv_data->tx_calibration_bw40 = tx_agc_fc; in rt2800_bw_filter_calibration()
8676 drv_data->rx_calibration_bw20 = rx_agc_fc; in rt2800_bw_filter_calibration()
8678 drv_data->rx_calibration_bw40 = rx_agc_fc; in rt2800_bw_filter_calibration()
8718 2 * test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)); in rt2800_bw_filter_calibration()
8740 rt2800_rfcsr_write(rt2x00dev, 12, rt2x00dev->freq_offset); in rt2800_init_rfcsr_6352()
9000 switch (rt2x00dev->chip.rt) { in rt2800_init_rfcsr()
9052 return -EIO; in rt2800_enable_radio()
9058 return -EIO; in rt2800_enable_radio()
9074 return -EIO; in rt2800_enable_radio()
9184 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_efuse_read()
9197 *(u32 *)&rt2x00dev->eeprom[i] = cpu_to_le32(reg); in rt2800_efuse_read()
9199 *(u32 *)&rt2x00dev->eeprom[i + 2] = cpu_to_le32(reg); in rt2800_efuse_read()
9201 *(u32 *)&rt2x00dev->eeprom[i + 4] = cpu_to_le32(reg); in rt2800_efuse_read()
9203 *(u32 *)&rt2x00dev->eeprom[i + 6] = cpu_to_le32(reg); in rt2800_efuse_read()
9205 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_efuse_read()
9251 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_validate_eeprom()
9340 drv_data->txmixer_gain_24g = rt2800_get_txmixer_gain_24g(rt2x00dev); in rt2800_validate_eeprom()
9354 drv_data->txmixer_gain_5g = rt2800_get_txmixer_gain_5g(rt2x00dev); in rt2800_validate_eeprom()
9451 return -ENODEV; in rt2800_init_eeprom()
9459 rt2x00dev->default_ant.tx_chain_num = in rt2800_init_eeprom()
9461 rt2x00dev->default_ant.rx_chain_num = in rt2800_init_eeprom()
9476 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
9477 rt2x00dev->default_ant.rx = ANTENNA_A; in rt2800_init_eeprom()
9480 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
9481 rt2x00dev->default_ant.rx = ANTENNA_B; in rt2800_init_eeprom()
9485 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
9486 rt2x00dev->default_ant.rx = ANTENNA_A; in rt2800_init_eeprom()
9492 rt2x00dev->default_ant.tx = ANTENNA_HW_DIVERSITY; /* Unused */ in rt2800_init_eeprom()
9493 rt2x00dev->default_ant.rx = ANTENNA_HW_DIVERSITY; /* Unused */ in rt2800_init_eeprom()
9500 __set_bit(CAPABILITY_EXTERNAL_LNA_A, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9502 __set_bit(CAPABILITY_EXTERNAL_LNA_BG, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9508 __set_bit(CAPABILITY_HW_BUTTON, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9511 * Detect if this device has Bluetooth co-existence. in rt2800_init_eeprom()
9515 __set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9521 rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET); in rt2800_init_eeprom()
9527 rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); in rt2800_init_eeprom()
9528 rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); in rt2800_init_eeprom()
9529 rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY); in rt2800_init_eeprom()
9531 rt2x00dev->led_mcu_reg = eeprom; in rt2800_init_eeprom()
9541 __set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9552 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9556 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
9935 struct hw_mode_spec *spec = &rt2x00dev->spec; in rt2800_probe_hw_mode()
9946 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; in rt2800_probe_hw_mode()
9952 rt2x00dev->hw->wiphy->retry_short = 2; in rt2800_probe_hw_mode()
9953 rt2x00dev->hw->wiphy->retry_long = 2; in rt2800_probe_hw_mode()
9958 ieee80211_hw_set(rt2x00dev->hw, REPORTS_TX_ACK_STATUS); in rt2800_probe_hw_mode()
9959 ieee80211_hw_set(rt2x00dev->hw, AMPDU_AGGREGATION); in rt2800_probe_hw_mode()
9960 ieee80211_hw_set(rt2x00dev->hw, PS_NULLFUNC_STACK); in rt2800_probe_hw_mode()
9961 ieee80211_hw_set(rt2x00dev->hw, SIGNAL_DBM); in rt2800_probe_hw_mode()
9962 ieee80211_hw_set(rt2x00dev->hw, SUPPORTS_PS); in rt2800_probe_hw_mode()
9972 ieee80211_hw_set(rt2x00dev->hw, HOST_BROADCAST_PS_BUFFERING); in rt2800_probe_hw_mode()
9974 ieee80211_hw_set(rt2x00dev->hw, MFP_CAPABLE); in rt2800_probe_hw_mode()
9976 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); in rt2800_probe_hw_mode()
9977 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, in rt2800_probe_hw_mode()
9990 rt2x00dev->hw->max_rates = 1; in rt2800_probe_hw_mode()
9991 rt2x00dev->hw->max_report_rates = 7; in rt2800_probe_hw_mode()
9992 rt2x00dev->hw->max_rate_tries = 1; in rt2800_probe_hw_mode()
9997 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; in rt2800_probe_hw_mode()
9999 switch (rt2x00dev->chip.rf) { in rt2800_probe_hw_mode()
10002 spec->num_channels = 14; in rt2800_probe_hw_mode()
10003 spec->channels = rf_vals; in rt2800_probe_hw_mode()
10008 spec->num_channels = ARRAY_SIZE(rf_vals); in rt2800_probe_hw_mode()
10009 spec->channels = rf_vals; in rt2800_probe_hw_mode()
10027 spec->num_channels = 14; in rt2800_probe_hw_mode()
10029 spec->channels = rf_vals_3x_xtal20; in rt2800_probe_hw_mode()
10031 spec->channels = rf_vals_3x; in rt2800_probe_hw_mode()
10035 spec->num_channels = ARRAY_SIZE(rf_vals_7620); in rt2800_probe_hw_mode()
10036 spec->channels = rf_vals_7620; in rt2800_probe_hw_mode()
10041 spec->num_channels = ARRAY_SIZE(rf_vals_3x); in rt2800_probe_hw_mode()
10042 spec->channels = rf_vals_3x; in rt2800_probe_hw_mode()
10046 spec->num_channels = ARRAY_SIZE(rf_vals_3853); in rt2800_probe_hw_mode()
10047 spec->channels = rf_vals_3853; in rt2800_probe_hw_mode()
10053 spec->num_channels = ARRAY_SIZE(rf_vals_5592_xtal40); in rt2800_probe_hw_mode()
10054 spec->channels = rf_vals_5592_xtal40; in rt2800_probe_hw_mode()
10056 spec->num_channels = ARRAY_SIZE(rf_vals_5592_xtal20); in rt2800_probe_hw_mode()
10057 spec->channels = rf_vals_5592_xtal20; in rt2800_probe_hw_mode()
10062 if (WARN_ON_ONCE(!spec->channels)) in rt2800_probe_hw_mode()
10063 return -ENODEV; in rt2800_probe_hw_mode()
10065 spec->supported_bands = SUPPORT_BAND_2GHZ; in rt2800_probe_hw_mode()
10066 if (spec->num_channels > 14) in rt2800_probe_hw_mode()
10067 spec->supported_bands |= SUPPORT_BAND_5GHZ; in rt2800_probe_hw_mode()
10073 spec->ht.ht_supported = true; in rt2800_probe_hw_mode()
10075 spec->ht.ht_supported = false; in rt2800_probe_hw_mode()
10077 spec->ht.cap = in rt2800_probe_hw_mode()
10083 tx_chains = rt2x00dev->default_ant.tx_chain_num; in rt2800_probe_hw_mode()
10084 rx_chains = rt2x00dev->default_ant.rx_chain_num; in rt2800_probe_hw_mode()
10087 spec->ht.cap |= IEEE80211_HT_CAP_TX_STBC; in rt2800_probe_hw_mode()
10089 spec->ht.cap |= rx_chains << IEEE80211_HT_CAP_RX_STBC_SHIFT; in rt2800_probe_hw_mode()
10091 spec->ht.ampdu_factor = (rx_chains > 1) ? 3 : 2; in rt2800_probe_hw_mode()
10092 spec->ht.ampdu_density = 4; in rt2800_probe_hw_mode()
10093 spec->ht.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; in rt2800_probe_hw_mode()
10095 spec->ht.mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; in rt2800_probe_hw_mode()
10096 spec->ht.mcs.tx_params |= in rt2800_probe_hw_mode()
10097 (tx_chains - 1) << IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; in rt2800_probe_hw_mode()
10102 spec->ht.mcs.rx_mask[2] = 0xff; in rt2800_probe_hw_mode()
10105 spec->ht.mcs.rx_mask[1] = 0xff; in rt2800_probe_hw_mode()
10108 spec->ht.mcs.rx_mask[0] = 0xff; in rt2800_probe_hw_mode()
10109 spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */ in rt2800_probe_hw_mode()
10116 info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); in rt2800_probe_hw_mode()
10118 return -ENOMEM; in rt2800_probe_hw_mode()
10120 spec->channels_info = info; in rt2800_probe_hw_mode()
10125 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_probe_hw_mode()
10138 if (spec->num_channels > 14) { in rt2800_probe_hw_mode()
10144 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_probe_hw_mode()
10151 for (i = 14; i < spec->num_channels; i++) { in rt2800_probe_hw_mode()
10152 info[i].default_power1 = default_power1[i - 14]; in rt2800_probe_hw_mode()
10153 info[i].default_power2 = default_power2[i - 14]; in rt2800_probe_hw_mode()
10155 info[i].default_power3 = default_power3[i - 14]; in rt2800_probe_hw_mode()
10159 switch (rt2x00dev->chip.rf) { in rt2800_probe_hw_mode()
10179 __set_bit(CAPABILITY_VCO_RECALIBRATION, &rt2x00dev->cap_flags); in rt2800_probe_hw_mode()
10221 return -ENODEV; in rt2800_probe_rt()
10270 __set_bit(CAPABILITY_CONTROL_FILTERS, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10271 __set_bit(CAPABILITY_CONTROL_FILTER_PSPOLL, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10273 __set_bit(CAPABILITY_PRE_TBTT_INTERRUPT, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10279 __set_bit(REQUIRE_FIRMWARE, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10280 __set_bit(REQUIRE_L2PAD, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10281 __set_bit(REQUIRE_TXSTATUS_FIFO, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10283 __set_bit(CAPABILITY_HW_CRYPTO, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10284 __set_bit(CAPABILITY_LINK_TUNING, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10285 __set_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10287 __set_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10289 __set_bit(REQUIRE_DMA, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10290 __set_bit(REQUIRE_TASKLET_CONTEXT, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10294 __set_bit(CAPABILITY_RESTART_HW, &rt2x00dev->cap_flags); in rt2800_probe_hw()
10295 rt2x00dev->link.watchdog_interval = msecs_to_jiffies(100); in rt2800_probe_hw()
10297 rt2x00dev->link.watchdog_disabled = true; in rt2800_probe_hw()
10303 rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET; in rt2800_probe_hw()
10316 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_key_seq()
10320 if (key->cipher != WLAN_CIPHER_SUITE_TKIP) in rt2800_get_key_seq()
10323 offset = MAC_IVEIV_ENTRY(key->hw_key_idx); in rt2800_get_key_seq()
10327 memcpy(&seq->tkip.iv16, &iveiv_entry.iv[0], 2); in rt2800_get_key_seq()
10328 memcpy(&seq->tkip.iv32, &iveiv_entry.iv[4], 4); in rt2800_get_key_seq()
10334 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_set_rts_threshold()
10374 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_conf_tx()
10406 rt2x00_set_field32(®, field, queue->txop); in rt2800_conf_tx()
10414 rt2x00_set_field32(®, field, queue->aifs); in rt2800_conf_tx()
10418 rt2x00_set_field32(®, field, queue->cw_min); in rt2800_conf_tx()
10422 rt2x00_set_field32(®, field, queue->cw_max); in rt2800_conf_tx()
10429 rt2x00_set_field32(®, EDCA_AC0_CFG_TX_OP, queue->txop); in rt2800_conf_tx()
10430 rt2x00_set_field32(®, EDCA_AC0_CFG_AIFSN, queue->aifs); in rt2800_conf_tx()
10431 rt2x00_set_field32(®, EDCA_AC0_CFG_CWMIN, queue->cw_min); in rt2800_conf_tx()
10432 rt2x00_set_field32(®, EDCA_AC0_CFG_CWMAX, queue->cw_max); in rt2800_conf_tx()
10441 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_tsf()
10457 struct ieee80211_sta *sta = params->sta; in rt2800_ampdu_action()
10458 enum ieee80211_ampdu_mlme_action action = params->action; in rt2800_ampdu_action()
10459 u16 tid = params->tid; in rt2800_ampdu_action()
10460 struct rt2x00_sta *sta_priv = (struct rt2x00_sta *)sta->drv_priv; in rt2800_ampdu_action()
10470 if (sta_priv->wcid > WCID_END) in rt2800_ampdu_action()
10471 return -ENOSPC; in rt2800_ampdu_action()
10489 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in rt2800_ampdu_action()
10494 rt2x00_warn((struct rt2x00_dev *)hw->priv, in rt2800_ampdu_action()
10505 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_survey()
10506 struct ieee80211_conf *conf = &hw->conf; in rt2800_get_survey()
10510 return -ENOENT; in rt2800_get_survey()
10512 survey->channel = conf->chandef.chan; in rt2800_get_survey()
10519 survey->filled = SURVEY_INFO_TIME | in rt2800_get_survey()
10523 survey->time = (idle + busy) / 1000; in rt2800_get_survey()
10524 survey->time_busy = busy / 1000; in rt2800_get_survey()
10525 survey->time_ext_busy = busy_ext / 1000; in rt2800_get_survey()
10528 if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) in rt2800_get_survey()
10529 survey->filled |= SURVEY_INFO_IN_USE; in rt2800_get_survey()