Lines Matching +full:txpower +full:- +full:5 +full:g
1 // SPDX-License-Identifier: GPL-2.0-or-later
24 #include <linux/crc-ccitt.h>
87 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_bbp_write()
104 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_bbp_write()
112 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_bbp_read()
136 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_bbp_read()
146 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_write()
152 switch (rt2x00dev->chip.rt) { in rt2800_rfcsr_write()
179 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_write()
198 rt2800_rfcsr_write_bank(rt2x00dev, 5, reg, value); in rt2800_rfcsr_write_dccal()
228 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_read()
238 switch (rt2x00dev->chip.rt) { in rt2800_rfcsr_read()
271 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_read()
287 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_rf_write()
304 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_rf_write()
395 wiphy_name(rt2x00dev->hw->wiphy), word)) in rt2800_eeprom_word_index()
414 wiphy_name(rt2x00dev->hw->wiphy), word); in rt2800_eeprom_word_index()
486 return -EIO; in rt2800_enable_wlan_rt3290()
526 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_mcu_request()
544 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_mcu_request()
561 return -EBUSY; in rt2800_wait_csr_ready()
584 return -EACCES; in rt2800_wait_wpdma_ready()
606 switch (rt2x00dev->chip.rt) { in rt2800_get_txwi_rxwi_size()
637 fw_crc = (data[len - 2] << 8 | data[len - 1]); in rt2800_check_firmware_crc()
646 crc = crc_ccitt(~0, data, len - 2); in rt2800_check_firmware_crc()
649 * There is a small difference between the crc-itu-t + bitrev and in rt2800_check_firmware_crc()
650 * the crc-ccitt crc calculation. In the latter method the 2 bytes in rt2800_check_firmware_crc()
723 return -EBUSY; in rt2800_load_firmware()
736 return -EBUSY; in rt2800_load_firmware()
770 return -EBUSY; in rt2800_load_firmware()
806 test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); in rt2800_write_tx_data()
808 test_bit(ENTRY_TXD_HT_MIMO_PS, &txdesc->flags)); in rt2800_write_tx_data()
811 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags)); in rt2800_write_tx_data()
813 test_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags)); in rt2800_write_tx_data()
815 txdesc->u.ht.mpdu_density); in rt2800_write_tx_data()
816 rt2x00_set_field32(&word, TXWI_W0_TX_OP, txdesc->u.ht.txop); in rt2800_write_tx_data()
817 rt2x00_set_field32(&word, TXWI_W0_MCS, txdesc->u.ht.mcs); in rt2800_write_tx_data()
819 test_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags)); in rt2800_write_tx_data()
821 test_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags)); in rt2800_write_tx_data()
822 rt2x00_set_field32(&word, TXWI_W0_STBC, txdesc->u.ht.stbc); in rt2800_write_tx_data()
823 rt2x00_set_field32(&word, TXWI_W0_PHYMODE, txdesc->rate_mode); in rt2800_write_tx_data()
828 test_bit(ENTRY_TXD_ACK, &txdesc->flags)); in rt2800_write_tx_data()
830 test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags)); in rt2800_write_tx_data()
831 rt2x00_set_field32(&word, TXWI_W1_BW_WIN_SIZE, txdesc->u.ht.ba_size); in rt2800_write_tx_data()
833 test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags) ? in rt2800_write_tx_data()
834 txdesc->key_idx : txdesc->u.ht.wcid); in rt2800_write_tx_data()
836 txdesc->length); in rt2800_write_tx_data()
837 rt2x00_set_field32(&word, TXWI_W1_PACKETID_QUEUE, entry->queue->qid); in rt2800_write_tx_data()
838 rt2x00_set_field32(&word, TXWI_W1_PACKETID_ENTRY, (entry->entry_idx % 3) + 1); in rt2800_write_tx_data()
850 for (i = 2; i < entry->queue->winfo_size / sizeof(__le32); i++) in rt2800_write_tx_data()
860 s8 base_val = rt2x00_rt(rt2x00dev, RT6352) ? -2 : -12; in rt2800_agc_to_rssi()
866 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_agc_to_rssi()
885 rssi0 = (rssi0) ? (base_val - offset0 - rt2x00dev->lna_gain - rssi0) : -128; in rt2800_agc_to_rssi()
886 rssi1 = (rssi1) ? (base_val - offset1 - rt2x00dev->lna_gain - rssi1) : -128; in rt2800_agc_to_rssi()
887 rssi2 = (rssi2) ? (base_val - offset2 - rt2x00dev->lna_gain - rssi2) : -128; in rt2800_agc_to_rssi()
891 * average doesn't deliver a fair answer either since -60:-60 would in rt2800_agc_to_rssi()
892 * be considered equally good as -50:-70 while the second is the one in rt2800_agc_to_rssi()
902 __le32 *rxwi = (__le32 *) entry->skb->data; in rt2800_process_rxwi()
907 rxdesc->cipher = rt2x00_get_field32(word, RXWI_W0_UDF); in rt2800_process_rxwi()
908 rxdesc->size = rt2x00_get_field32(word, RXWI_W0_MPDU_TOTAL_BYTE_COUNT); in rt2800_process_rxwi()
913 rxdesc->enc_flags |= RX_ENC_FLAG_SHORT_GI; in rt2800_process_rxwi()
916 rxdesc->bw = RATE_INFO_BW_40; in rt2800_process_rxwi()
921 rxdesc->dev_flags |= RXDONE_SIGNAL_MCS; in rt2800_process_rxwi()
922 rxdesc->signal = rt2x00_get_field32(word, RXWI_W1_MCS); in rt2800_process_rxwi()
923 rxdesc->rate_mode = rt2x00_get_field32(word, RXWI_W1_PHYMODE); in rt2800_process_rxwi()
928 if (rxdesc->rate_mode == RATE_MODE_CCK) in rt2800_process_rxwi()
929 rxdesc->signal &= ~0x8; in rt2800_process_rxwi()
936 rxdesc->rssi = rt2800_agc_to_rssi(entry->queue->rt2x00dev, word); in rt2800_process_rxwi()
940 skb_pull(entry->skb, entry->queue->winfo_size); in rt2800_process_rxwi()
963 idx -= 8; in rt2800_rate_from_status()
973 skbdesc->tx_rate_idx = idx; in rt2800_rate_from_status()
974 skbdesc->tx_rate_flags = flags; in rt2800_rate_from_status()
989 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) in rt2800_txdone_entry_check()
1009 rt2x00_dbg(entry->queue->rt2x00dev, in rt2800_txdone_entry_check()
1011 entry->queue->qid, entry->entry_idx); in rt2800_txdone_entry_check()
1021 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2800_txdone_entry()
1022 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_txdone_entry()
1023 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); in rt2800_txdone_entry()
1044 * If a frame was meant to be sent as a single non-aggregated MPDU in rt2800_txdone_entry()
1064 rt2800_rate_from_status(skbdesc, status, rt2x00dev->curr_band); in rt2800_txdone_entry()
1084 * mcs - real_mcs in rt2800_txdone_entry()
1087 txdesc.retry = ((mcs > real_mcs) ? mcs - real_mcs : 0); in rt2800_txdone_entry()
1095 txdesc.retry = rt2x00dev->long_retry; in rt2800_txdone_entry()
1100 * -> hw used fallback rates in rt2800_txdone_entry()
1106 /* RCU assures non-null sta will not be freed by mac80211. */ in rt2800_txdone_entry()
1109 skbdesc->sta = drv_data->wcid_to_sta[wcid - WCID_START]; in rt2800_txdone_entry()
1111 skbdesc->sta = NULL; in rt2800_txdone_entry()
1128 while (quota-- > 0 && kfifo_get(&rt2x00dev->txstatus_fifo, ®)) { in rt2800_txdone()
1130 * TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus qid is in rt2800_txdone()
1144 if (unlikely(test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || in rt2800_txdone()
1145 !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))) { in rt2800_txdone()
1147 entry->entry_idx, qid); in rt2800_txdone()
1163 if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) in rt2800_entry_txstatus_timeout()
1166 if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) in rt2800_entry_txstatus_timeout()
1171 ret = time_after(jiffies, entry->last_action + tout); in rt2800_entry_txstatus_timeout()
1173 rt2x00_dbg(entry->queue->rt2x00dev, in rt2800_entry_txstatus_timeout()
1175 entry->entry_idx, entry->queue->qid); in rt2800_entry_txstatus_timeout()
1218 * we loop until we find the first non-IO error entry. This in rt2800_txdone_nostatus()
1227 if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || in rt2800_txdone_nostatus()
1228 !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) in rt2800_txdone_nostatus()
1231 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) || in rt2800_txdone_nostatus()
1245 if (queue->wd_idx != cur_idx) { in rt2800_check_hung()
1246 queue->wd_idx = cur_idx; in rt2800_check_hung()
1247 queue->wd_count = 0; in rt2800_check_hung()
1249 queue->wd_count++; in rt2800_check_hung()
1251 return queue->wd_count > 16; in rt2800_check_hung()
1256 struct ieee80211_channel *chan = rt2x00dev->hw->conf.chandef.chan; in rt2800_update_survey()
1258 &rt2x00dev->chan_survey[chan->hw_value]; in rt2800_update_survey()
1260 chan_survey->time_idle += rt2800_register_read(rt2x00dev, CH_IDLE_STA); in rt2800_update_survey()
1261 chan_survey->time_busy += rt2800_register_read(rt2x00dev, CH_BUSY_STA); in rt2800_update_survey()
1262 chan_survey->time_ext_busy += rt2800_register_read(rt2x00dev, CH_BUSY_STA_SEC); in rt2800_update_survey()
1274 switch (queue->qid) { in rt2800_watchdog_hung()
1289 if (rt2x00dev->intf_sta_count == 0) in rt2800_watchdog_hung()
1308 queue->wd_count = 0; in rt2800_watchdog_hung()
1321 rt2x00dev->rxdma_busy++; in rt2800_watchdog_dma_busy()
1323 rt2x00dev->rxdma_busy = 0; in rt2800_watchdog_dma_busy()
1327 rt2x00dev->txdma_busy++; in rt2800_watchdog_dma_busy()
1329 rt2x00dev->txdma_busy = 0; in rt2800_watchdog_dma_busy()
1331 busy_rx = rt2x00dev->rxdma_busy > 30; in rt2800_watchdog_dma_busy()
1332 busy_tx = rt2x00dev->txdma_busy > 30; in rt2800_watchdog_dma_busy()
1343 rt2x00dev->rxdma_busy = 0; in rt2800_watchdog_dma_busy()
1344 rt2x00dev->txdma_busy = 0; in rt2800_watchdog_dma_busy()
1353 if (test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) in rt2800_watchdog()
1356 if (rt2x00dev->link.watchdog & RT2800_WATCHDOG_DMA_BUSY) in rt2800_watchdog()
1359 if (rt2x00dev->link.watchdog & RT2800_WATCHDOG_HANG) in rt2800_watchdog()
1363 ieee80211_restart_hw(rt2x00dev->hw); in rt2800_watchdog()
1381 struct data_queue *queue = rt2x00dev->bcn; in rt2800_update_beacons_setup()
1390 for (i = 0; i < queue->limit; i++) { in rt2800_update_beacons_setup()
1391 entry = &queue->entries[i]; in rt2800_update_beacons_setup()
1392 if (!test_bit(ENTRY_BCN_ENABLED, &entry->flags)) in rt2800_update_beacons_setup()
1394 off = rt2800_get_beacon_offset(rt2x00dev, entry->entry_idx); in rt2800_update_beacons_setup()
1407 bcn_num > 0 ? bcn_num - 1 : 0); in rt2800_update_beacons_setup()
1413 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2800_write_beacon()
1414 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); in rt2800_write_beacon()
1418 const int txwi_desc_size = entry->queue->winfo_size; in rt2800_write_beacon()
1432 memset(skb_push(entry->skb, txwi_desc_size), 0, txwi_desc_size); in rt2800_write_beacon()
1437 skbdesc->flags |= SKBDESC_DESC_IN_SKB; in rt2800_write_beacon()
1438 skbdesc->desc = entry->skb->data; in rt2800_write_beacon()
1439 skbdesc->desc_len = txwi_desc_size; in rt2800_write_beacon()
1454 padding_len = roundup(entry->skb->len, 4) - entry->skb->len; in rt2800_write_beacon()
1455 if (padding_len && skb_pad(entry->skb, padding_len)) { in rt2800_write_beacon()
1458 entry->skb = NULL; in rt2800_write_beacon()
1463 beacon_base = rt2800_hw_beacon_base(rt2x00dev, entry->entry_idx); in rt2800_write_beacon()
1465 rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data, in rt2800_write_beacon()
1466 entry->skb->len + padding_len); in rt2800_write_beacon()
1467 __set_bit(ENTRY_BCN_ENABLED, &entry->flags); in rt2800_write_beacon()
1482 dev_kfree_skb_any(entry->skb); in rt2800_write_beacon()
1483 entry->skb = NULL; in rt2800_write_beacon()
1491 const int txwi_desc_size = rt2x00dev->bcn->winfo_size; in rt2800_clear_beacon_register()
1507 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2800_clear_beacon()
1522 rt2800_clear_beacon_register(rt2x00dev, entry->entry_idx); in rt2800_clear_beacon()
1523 __clear_bit(ENTRY_BCN_ENABLED, &entry->flags); in rt2800_clear_beacon()
1604 (enabled && led->rt2x00dev->curr_band == NL80211_BAND_2GHZ); in rt2800_brightness_set()
1606 rt2x00_get_field16(led->rt2x00dev->led_mcu_reg, in rt2800_brightness_set()
1609 rt2x00_get_field16(led->rt2x00dev->led_mcu_reg, in rt2800_brightness_set()
1614 if (rt2x00_is_soc(led->rt2x00dev)) { in rt2800_brightness_set()
1615 reg = rt2800_register_read(led->rt2x00dev, LED_CFG); in rt2800_brightness_set()
1621 if (led->type == LED_TYPE_RADIO) { in rt2800_brightness_set()
1624 } else if (led->type == LED_TYPE_ASSOC) { in rt2800_brightness_set()
1627 } else if (led->type == LED_TYPE_QUALITY) { in rt2800_brightness_set()
1632 rt2800_register_write(led->rt2x00dev, LED_CFG, reg); in rt2800_brightness_set()
1635 if (led->type == LED_TYPE_RADIO) { in rt2800_brightness_set()
1636 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode, in rt2800_brightness_set()
1638 } else if (led->type == LED_TYPE_ASSOC) { in rt2800_brightness_set()
1639 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode, in rt2800_brightness_set()
1641 } else if (led->type == LED_TYPE_QUALITY) { in rt2800_brightness_set()
1643 * The brightness is divided into 6 levels (0 - 5), in rt2800_brightness_set()
1648 * (1 << level) - 1 in rt2800_brightness_set()
1650 rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff, in rt2800_brightness_set()
1651 (1 << brightness / (LED_FULL / 6)) - 1, in rt2800_brightness_set()
1660 led->rt2x00dev = rt2x00dev; in rt2800_init_led()
1661 led->type = type; in rt2800_init_led()
1662 led->led_dev.brightness_set = rt2800_brightness_set; in rt2800_init_led()
1663 led->flags = LED_INITIALIZED; in rt2800_init_led()
1719 offset = MAC_WCID_ATTR_ENTRY(key->hw_key_idx); in rt2800_config_wcid_attr_cipher()
1721 if (crypto->cmd == SET_KEY) { in rt2800_config_wcid_attr_cipher()
1724 !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)); in rt2800_config_wcid_attr_cipher()
1731 (crypto->cipher & 0x7)); in rt2800_config_wcid_attr_cipher()
1733 (crypto->cipher & 0x8) >> 3); in rt2800_config_wcid_attr_cipher()
1734 rt2x00_set_field32(®, MAC_WCID_ATTRIBUTE_RX_WIUDF, crypto->cipher); in rt2800_config_wcid_attr_cipher()
1746 if (test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags)) in rt2800_config_wcid_attr_cipher()
1749 offset = MAC_IVEIV_ENTRY(key->hw_key_idx); in rt2800_config_wcid_attr_cipher()
1752 if ((crypto->cipher == CIPHER_TKIP) || in rt2800_config_wcid_attr_cipher()
1753 (crypto->cipher == CIPHER_TKIP_NO_MIC) || in rt2800_config_wcid_attr_cipher()
1754 (crypto->cipher == CIPHER_AES)) in rt2800_config_wcid_attr_cipher()
1756 iveiv_entry.iv[3] |= key->keyidx << 6; in rt2800_config_wcid_attr_cipher()
1770 if (crypto->cmd == SET_KEY) { in rt2800_config_shared_key()
1771 key->hw_key_idx = (4 * crypto->bssidx) + key->keyidx; in rt2800_config_shared_key()
1773 memcpy(key_entry.key, crypto->key, in rt2800_config_shared_key()
1775 memcpy(key_entry.tx_mic, crypto->tx_mic, in rt2800_config_shared_key()
1777 memcpy(key_entry.rx_mic, crypto->rx_mic, in rt2800_config_shared_key()
1780 offset = SHARED_KEY_ENTRY(key->hw_key_idx); in rt2800_config_shared_key()
1792 field.bit_offset = 4 * (key->hw_key_idx % 8); in rt2800_config_shared_key()
1795 offset = SHARED_KEY_MODE_ENTRY(key->hw_key_idx / 8); in rt2800_config_shared_key()
1799 (crypto->cmd == SET_KEY) * crypto->cipher); in rt2800_config_shared_key()
1805 rt2800_config_wcid(rt2x00dev, crypto->address, key->hw_key_idx); in rt2800_config_shared_key()
1806 rt2800_config_wcid_attr_bssidx(rt2x00dev, key->hw_key_idx, in rt2800_config_shared_key()
1807 crypto->bssidx); in rt2800_config_shared_key()
1821 if (crypto->cmd == SET_KEY) { in rt2800_config_pairwise_key()
1826 if (crypto->wcid > WCID_END) in rt2800_config_pairwise_key()
1827 return -ENOSPC; in rt2800_config_pairwise_key()
1828 key->hw_key_idx = crypto->wcid; in rt2800_config_pairwise_key()
1830 memcpy(key_entry.key, crypto->key, in rt2800_config_pairwise_key()
1832 memcpy(key_entry.tx_mic, crypto->tx_mic, in rt2800_config_pairwise_key()
1834 memcpy(key_entry.rx_mic, crypto->rx_mic, in rt2800_config_pairwise_key()
1837 offset = PAIRWISE_KEY_ENTRY(key->hw_key_idx); in rt2800_config_pairwise_key()
1855 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_set_max_psdu_len()
1858 if (drv_data->ampdu_factor_cnt[i] > 0) in rt2800_set_max_psdu_len()
1861 max_psdu = min(drv_data->max_psdu, i); in rt2800_set_max_psdu_len()
1871 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_sta_add()
1872 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_sta_add()
1882 if (sta->deflink.ht_cap.ht_supported) { in rt2800_sta_add()
1883 drv_data->ampdu_factor_cnt[sta->deflink.ht_cap.ampdu_factor & 3]++; in rt2800_sta_add()
1891 wcid = find_first_zero_bit(drv_data->sta_ids, STA_IDS_SIZE) + WCID_START; in rt2800_sta_add()
1897 sta_priv->wcid = wcid; in rt2800_sta_add()
1901 * with the STA -> No error. in rt2800_sta_add()
1906 __set_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_sta_add()
1907 drv_data->wcid_to_sta[wcid - WCID_START] = sta; in rt2800_sta_add()
1913 rt2800_config_wcid(rt2x00dev, sta->addr, wcid); in rt2800_sta_add()
1923 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_sta_remove()
1924 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_sta_remove()
1926 int wcid = sta_priv->wcid; in rt2800_sta_remove()
1928 if (sta->deflink.ht_cap.ht_supported) { in rt2800_sta_remove()
1929 drv_data->ampdu_factor_cnt[sta->deflink.ht_cap.ampdu_factor & 3]--; in rt2800_sta_remove()
1940 drv_data->wcid_to_sta[wcid - WCID_START] = NULL; in rt2800_sta_remove()
1941 __clear_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_sta_remove()
1949 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_pre_reset_hw()
1950 struct data_queue *queue = rt2x00dev->bcn; in rt2800_pre_reset_hw()
1955 drv_data->wcid_to_sta[wcid - WCID_START] = NULL; in rt2800_pre_reset_hw()
1956 __clear_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_pre_reset_hw()
1959 for (i = 0; i < queue->limit; i++) { in rt2800_pre_reset_hw()
1960 entry = &queue->entries[i]; in rt2800_pre_reset_hw()
1961 clear_bit(ENTRY_BCN_ASSIGNED, &entry->flags); in rt2800_pre_reset_hw()
1983 !test_bit(CONFIG_MONITORING, &rt2x00dev->flags)); in rt2800_config_filter()
2022 rt2x00_set_field32(®, BCN_TIME_CFG_TSF_SYNC, conf->sync); in rt2800_config_intf()
2025 if (conf->sync == TSF_SYNC_AP_NONE) { in rt2800_config_intf()
2047 conf->sync == TSF_SYNC_AP_NONE) { in rt2800_config_intf()
2052 memcpy(conf->bssid, conf->mac, sizeof(conf->mac)); in rt2800_config_intf()
2056 if (!is_zero_ether_addr((const u8 *)conf->mac)) { in rt2800_config_intf()
2057 reg = le32_to_cpu(conf->mac[1]); in rt2800_config_intf()
2059 conf->mac[1] = cpu_to_le32(reg); in rt2800_config_intf()
2063 conf->mac, sizeof(conf->mac)); in rt2800_config_intf()
2067 if (!is_zero_ether_addr((const u8 *)conf->bssid)) { in rt2800_config_intf()
2068 reg = le32_to_cpu(conf->bssid[1]); in rt2800_config_intf()
2071 conf->bssid[1] = cpu_to_le32(reg); in rt2800_config_intf()
2075 conf->bssid, sizeof(conf->bssid)); in rt2800_config_intf()
2083 bool any_sta_nongf = !!(erp->ht_opmode & in rt2800_config_ht_opmode()
2085 u8 protection = erp->ht_opmode & IEEE80211_HT_OP_MODE_PROTECTION; in rt2800_config_ht_opmode()
2129 * -> fall through to mixed mode. in rt2800_config_ht_opmode()
2142 if (erp->cts_protection) { in rt2800_config_ht_opmode()
2184 !!erp->short_preamble); in rt2800_config_erp()
2191 erp->cts_protection ? 2 : 0); in rt2800_config_erp()
2197 0xff0 | erp->basic_rates); in rt2800_config_erp()
2204 erp->slot_time); in rt2800_config_erp()
2208 rt2x00_set_field32(®, XIFS_TIME_CFG_EIFS, erp->eifs); in rt2800_config_erp()
2215 erp->beacon_int * 16); in rt2800_config_erp()
2239 return -EACCES; in rt2800_wait_bbp_rf_ready()
2263 return -EACCES; in rt2800_wait_bbp_ready()
2273 if (rt2x00dev->curr_band == NL80211_BAND_5GHZ) { in rt2800_config_3572bt_ant()
2337 switch (ant->tx_chain_num) { in rt2800_config_ant()
2356 switch (ant->rx_chain_num) { in rt2800_config_ant()
2367 rt2x00dev->default_ant.rx); in rt2800_config_ant()
2376 rt2x00dev->curr_band == NL80211_BAND_5GHZ); in rt2800_config_ant()
2392 if (ant->rx_chain_num == 1) in rt2800_config_ant()
2406 if (libconf->rf.channel <= 14) { in rt2800_config_lna_gain()
2409 } else if (libconf->rf.channel <= 64) { in rt2800_config_lna_gain()
2412 } else if (libconf->rf.channel <= 128) { in rt2800_config_lna_gain()
2436 rt2x00dev->lna_gain = lna_gain; in rt2800_config_lna_gain()
2441 return clk_get_rate(rt2x00dev->clk) == 20000000; in rt2800_clk_is_20mhz()
2451 freq_offset = rt2x00_get_field8(rt2x00dev->freq_offset, RFCSR17_CODE); in rt2800_freq_cal_mode1()
2472 prev_freq_offset--; in rt2800_freq_cal_mode1()
2486 rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf2xxx()
2488 if (rt2x00dev->default_ant.tx_chain_num == 1) in rt2800_config_channel_rf2xxx()
2489 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_TX1, 1); in rt2800_config_channel_rf2xxx()
2491 if (rt2x00dev->default_ant.rx_chain_num == 1) { in rt2800_config_channel_rf2xxx()
2492 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX1, 1); in rt2800_config_channel_rf2xxx()
2493 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1); in rt2800_config_channel_rf2xxx()
2494 } else if (rt2x00dev->default_ant.rx_chain_num == 2) in rt2800_config_channel_rf2xxx()
2495 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1); in rt2800_config_channel_rf2xxx()
2497 if (rf->channel > 14) { in rt2800_config_channel_rf2xxx()
2500 * make it a positive value (Minimum value is -7). in rt2800_config_channel_rf2xxx()
2504 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A_7DBM_BOOST, in rt2800_config_channel_rf2xxx()
2505 (info->default_power1 >= 0)); in rt2800_config_channel_rf2xxx()
2507 if (info->default_power1 < 0) in rt2800_config_channel_rf2xxx()
2508 info->default_power1 += 7; in rt2800_config_channel_rf2xxx()
2510 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A, info->default_power1); in rt2800_config_channel_rf2xxx()
2512 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A_7DBM_BOOST, in rt2800_config_channel_rf2xxx()
2513 (info->default_power2 >= 0)); in rt2800_config_channel_rf2xxx()
2515 if (info->default_power2 < 0) in rt2800_config_channel_rf2xxx()
2516 info->default_power2 += 7; in rt2800_config_channel_rf2xxx()
2518 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A, info->default_power2); in rt2800_config_channel_rf2xxx()
2520 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_G, info->default_power1); in rt2800_config_channel_rf2xxx()
2521 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_G, info->default_power2); in rt2800_config_channel_rf2xxx()
2524 rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf)); in rt2800_config_channel_rf2xxx()
2526 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2527 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2528 rt2800_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004); in rt2800_config_channel_rf2xxx()
2529 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2533 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2534 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2535 rt2800_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004); in rt2800_config_channel_rf2xxx()
2536 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2540 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2541 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2542 rt2800_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004); in rt2800_config_channel_rf2xxx()
2543 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2551 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3xxx()
2554 rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); in rt2800_config_channel_rf3xxx()
2557 rt2x00_set_field8(&rfcsr, RFCSR3_K, rf->rf3); in rt2800_config_channel_rf3xxx()
2561 rt2x00_set_field8(&rfcsr, RFCSR6_R1, rf->rf2); in rt2800_config_channel_rf3xxx()
2565 rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER, info->default_power1); in rt2800_config_channel_rf3xxx()
2569 rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER, info->default_power2); in rt2800_config_channel_rf3xxx()
2575 rt2x00dev->default_ant.rx_chain_num <= 1); in rt2800_config_channel_rf3xxx()
2577 rt2x00dev->default_ant.rx_chain_num <= 2); in rt2800_config_channel_rf3xxx()
2580 rt2x00dev->default_ant.tx_chain_num <= 1); in rt2800_config_channel_rf3xxx()
2582 rt2x00dev->default_ant.tx_chain_num <= 2); in rt2800_config_channel_rf3xxx()
2586 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf3xxx()
2594 calib_tx = drv_data->calibration_bw40; in rt2800_config_channel_rf3xxx()
2595 calib_rx = drv_data->calibration_bw40; in rt2800_config_channel_rf3xxx()
2597 calib_tx = drv_data->calibration_bw20; in rt2800_config_channel_rf3xxx()
2598 calib_rx = drv_data->calibration_bw20; in rt2800_config_channel_rf3xxx()
2629 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3052()
2633 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2634 rt2800_bbp_write(rt2x00dev, 25, drv_data->bbp25); in rt2800_config_channel_rf3052()
2635 rt2800_bbp_write(rt2x00dev, 26, drv_data->bbp26); in rt2800_config_channel_rf3052()
2641 rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); in rt2800_config_channel_rf3052()
2642 rt2800_rfcsr_write(rt2x00dev, 3, rf->rf3); in rt2800_config_channel_rf3052()
2645 rt2x00_set_field8(&rfcsr, RFCSR6_R1, rf->rf2); in rt2800_config_channel_rf3052()
2646 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2652 rfcsr = rt2800_rfcsr_read(rt2x00dev, 5); in rt2800_config_channel_rf3052()
2653 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2657 rt2800_rfcsr_write(rt2x00dev, 5, rfcsr); in rt2800_config_channel_rf3052()
2660 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2663 info->default_power1); in rt2800_config_channel_rf3052()
2667 (info->default_power1 & 0x3) | in rt2800_config_channel_rf3052()
2668 ((info->default_power1 & 0xC) << 1)); in rt2800_config_channel_rf3052()
2673 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2676 info->default_power2); in rt2800_config_channel_rf3052()
2680 (info->default_power2 & 0x3) | in rt2800_config_channel_rf3052()
2681 ((info->default_power2 & 0xC) << 1)); in rt2800_config_channel_rf3052()
2693 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2700 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3052()
2709 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3052()
2721 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf3052()
2725 rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw40); in rt2800_config_channel_rf3052()
2726 rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw40); in rt2800_config_channel_rf3052()
2728 rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw20); in rt2800_config_channel_rf3052()
2729 rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw20); in rt2800_config_channel_rf3052()
2732 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2740 drv_data->txmixer_gain_24g); in rt2800_config_channel_rf3052()
2762 drv_data->txmixer_gain_5g); in rt2800_config_channel_rf3052()
2765 if (rf->channel <= 64) { in rt2800_config_channel_rf3052()
2769 } else if (rf->channel <= 128) { in rt2800_config_channel_rf3052()
2785 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2801 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3053()
2818 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2820 rt2800_bbp_write(rt2x00dev, 25, drv_data->bbp25); in rt2800_config_channel_rf3053()
2821 rt2800_bbp_write(rt2x00dev, 26, drv_data->bbp26); in rt2800_config_channel_rf3053()
2823 /* Hard code BBP 25 & 26 for 5GHz */ in rt2800_config_channel_rf3053()
2831 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3053()
2832 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3 & 0xf); in rt2800_config_channel_rf3053()
2835 rt2x00_set_field8(&rfcsr, RFCSR11_R, (rf->rf2 & 0x3)); in rt2800_config_channel_rf3053()
2840 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2847 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2850 info->default_power1 & 0x1f); in rt2800_config_channel_rf3053()
2856 ((info->default_power1 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2857 (info->default_power1 & 7)); in rt2800_config_channel_rf3053()
2862 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2865 info->default_power2 & 0x1f); in rt2800_config_channel_rf3053()
2871 ((info->default_power2 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2872 (info->default_power2 & 7)); in rt2800_config_channel_rf3053()
2877 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2880 info->default_power3 & 0x1f); in rt2800_config_channel_rf3053()
2886 ((info->default_power3 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2887 (info->default_power3 & 7)); in rt2800_config_channel_rf3053()
2901 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3053()
2913 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3053()
2929 txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw40, in rt2800_config_channel_rf3053()
2931 txrx_h20m = rt2x00_get_field8(drv_data->calibration_bw40, in rt2800_config_channel_rf3053()
2934 txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw20, in rt2800_config_channel_rf3053()
2936 txrx_h20m = rt2x00_get_field8(drv_data->calibration_bw20, in rt2800_config_channel_rf3053()
2946 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2959 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2966 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2973 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2980 if (rf->channel >= 1 && rf->channel <= 14) in rt2800_config_channel_rf3053()
2982 else if (rf->channel >= 36 && rf->channel <= 64) in rt2800_config_channel_rf3053()
2984 else if (rf->channel >= 100 && rf->channel <= 128) in rt2800_config_channel_rf3053()
2996 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
3009 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
3010 rt2x00_set_field8(&rfcsr, RFCSR51_BITS24, 5); in rt2800_config_channel_rf3053()
3019 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
3034 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
3040 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
3050 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
3062 if (rf->channel >= 1 && rf->channel <= 14) { in rt2800_config_channel_rf3053()
3069 } else if (rf->channel >= 36 && rf->channel <= 64) { in rt2800_config_channel_rf3053()
3076 } else if (rf->channel >= 100 && rf->channel <= 128) { in rt2800_config_channel_rf3053()
3106 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3108 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
3113 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3853()
3114 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3853()
3116 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3121 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3138 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3853()
3150 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3853()
3172 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3182 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3189 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3195 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3197 else if (rf->channel < 100) in rt2800_config_channel_rf3853()
3199 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
3209 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3214 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3216 else if (rf->channel < 100) in rt2800_config_channel_rf3853()
3218 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
3224 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3237 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3243 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3248 if (rf->channel <= 14) { in rt2800_config_channel_rf3853()
3249 pwr1 = info->default_power1 & 0x1f; in rt2800_config_channel_rf3853()
3250 pwr2 = info->default_power2 & 0x1f; in rt2800_config_channel_rf3853()
3251 pwr3 = info->default_power3 & 0x1f; in rt2800_config_channel_rf3853()
3253 pwr1 = 0x48 | ((info->default_power1 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3254 (info->default_power1 & 0x7); in rt2800_config_channel_rf3853()
3255 pwr2 = 0x48 | ((info->default_power2 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3256 (info->default_power2 & 0x7); in rt2800_config_channel_rf3853()
3257 pwr3 = 0x48 | ((info->default_power3 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3258 (info->default_power3 & 0x7); in rt2800_config_channel_rf3853()
3266 rf->channel, pwr1, pwr2, pwr3); in rt2800_config_channel_rf3853()
3268 bbp = (info->default_power1 >> 5) | in rt2800_config_channel_rf3853()
3269 ((info->default_power2 & 0xe0) >> 1); in rt2800_config_channel_rf3853()
3274 bbp |= (info->default_power3 & 0xe0) >> 1; in rt2800_config_channel_rf3853()
3278 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3308 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3290()
3309 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3290()
3311 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf2); in rt2800_config_channel_rf3290()
3315 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf3290()
3318 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf3290()
3323 if (rf->channel <= 14) { in rt2800_config_channel_rf3290()
3324 if (rf->channel == 6) in rt2800_config_channel_rf3290()
3329 if (rf->channel >= 1 && rf->channel <= 6) in rt2800_config_channel_rf3290()
3331 else if (rf->channel >= 7 && rf->channel <= 11) in rt2800_config_channel_rf3290()
3333 else if (rf->channel >= 12 && rf->channel <= 14) in rt2800_config_channel_rf3290()
3345 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3322()
3346 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3322()
3352 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf3322()
3355 rt2800_rfcsr_write(rt2x00dev, 47, info->default_power1); in rt2800_config_channel_rf3322()
3357 if (info->default_power2 > POWER_BOUND) in rt2800_config_channel_rf3322()
3360 rt2800_rfcsr_write(rt2x00dev, 48, info->default_power2); in rt2800_config_channel_rf3322()
3368 if ( rt2x00dev->default_ant.tx_chain_num == 2 ) in rt2800_config_channel_rf3322()
3373 if ( rt2x00dev->default_ant.rx_chain_num == 2 ) in rt2800_config_channel_rf3322()
3392 int idx = rf->channel-1; in rt2800_config_channel_rf53xx()
3394 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf53xx()
3395 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf53xx()
3397 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf2); in rt2800_config_channel_rf53xx()
3401 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf53xx()
3404 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf53xx()
3409 if (info->default_power2 > POWER_BOUND) in rt2800_config_channel_rf53xx()
3413 info->default_power2); in rt2800_config_channel_rf53xx()
3499 (rf->channel > 14 || conf_is_ht40(conf)) ? 5 : 0); in rt2800_config_channel_rf55xx()
3503 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1 & 0xff); in rt2800_config_channel_rf55xx()
3506 rt2x00_set_field8(&rfcsr, RFCSR9_K, rf->rf2 & 0xf); in rt2800_config_channel_rf55xx()
3507 rt2x00_set_field8(&rfcsr, RFCSR9_N, (rf->rf1 & 0x100) >> 8); in rt2800_config_channel_rf55xx()
3508 rt2x00_set_field8(&rfcsr, RFCSR9_MOD, ((rf->rf3 - 8) & 0x4) >> 2); in rt2800_config_channel_rf55xx()
3512 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf4 - 1); in rt2800_config_channel_rf55xx()
3513 rt2x00_set_field8(&rfcsr, RFCSR11_MOD, (rf->rf3 - 8) & 0x3); in rt2800_config_channel_rf55xx()
3516 if (rf->channel <= 14) { in rt2800_config_channel_rf55xx()
3548 /* TODO RF27 <- tssi */ in rt2800_config_channel_rf55xx()
3550 rfcsr = rf->channel <= 10 ? 0x07 : 0x06; in rt2800_config_channel_rf55xx()
3590 /* TODO RF27 <- tssi */ in rt2800_config_channel_rf55xx()
3592 if (rf->channel >= 36 && rf->channel <= 64) { in rt2800_config_channel_rf55xx()
3598 if (rf->channel <= 50) in rt2800_config_channel_rf55xx()
3600 else if (rf->channel >= 52) in rt2800_config_channel_rf55xx()
3609 if (rf->channel <= 50) { in rt2800_config_channel_rf55xx()
3612 } else if (rf->channel >= 52) { in rt2800_config_channel_rf55xx()
3621 } else if (rf->channel >= 100 && rf->channel <= 165) { in rt2800_config_channel_rf55xx()
3626 if (rf->channel <= 153) { in rt2800_config_channel_rf55xx()
3629 } else if (rf->channel >= 155) { in rt2800_config_channel_rf55xx()
3633 if (rf->channel <= 138) { in rt2800_config_channel_rf55xx()
3638 } else if (rf->channel >= 140) { in rt2800_config_channel_rf55xx()
3644 if (rf->channel <= 124) in rt2800_config_channel_rf55xx()
3646 else if (rf->channel >= 126) in rt2800_config_channel_rf55xx()
3648 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3650 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3653 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3655 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3657 if (rf->channel <= 128) in rt2800_config_channel_rf55xx()
3659 else if (rf->channel >= 130) in rt2800_config_channel_rf55xx()
3661 if (rf->channel <= 116) in rt2800_config_channel_rf55xx()
3663 else if (rf->channel >= 118) in rt2800_config_channel_rf55xx()
3665 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3667 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3669 if (rf->channel <= 116) in rt2800_config_channel_rf55xx()
3671 else if (rf->channel >= 118) in rt2800_config_channel_rf55xx()
3680 if (info->default_power1 > power_bound) in rt2800_config_channel_rf55xx()
3683 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf55xx()
3689 if (info->default_power2 > power_bound) in rt2800_config_channel_rf55xx()
3692 rt2x00_set_field8(&rfcsr, RFCSR50_TX, info->default_power2); in rt2800_config_channel_rf55xx()
3702 rt2x00dev->default_ant.tx_chain_num >= 1); in rt2800_config_channel_rf55xx()
3704 rt2x00dev->default_ant.tx_chain_num == 2); in rt2800_config_channel_rf55xx()
3708 rt2x00dev->default_ant.rx_chain_num >= 1); in rt2800_config_channel_rf55xx()
3710 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_config_channel_rf55xx()
3735 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3736 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3737 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3739 rt2800_bbp_write(rt2x00dev, 79, (rf->channel <= 14) ? 0x1C : 0x18); in rt2800_config_channel_rf55xx()
3740 rt2800_bbp_write(rt2x00dev, 80, (rf->channel <= 14) ? 0x0E : 0x08); in rt2800_config_channel_rf55xx()
3741 rt2800_bbp_write(rt2x00dev, 81, (rf->channel <= 14) ? 0x3A : 0x38); in rt2800_config_channel_rf55xx()
3742 rt2800_bbp_write(rt2x00dev, 82, (rf->channel <= 14) ? 0x62 : 0x92); in rt2800_config_channel_rf55xx()
3746 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0xE0 : 0xF0); in rt2800_config_channel_rf55xx()
3748 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x1F : 0x1E); in rt2800_config_channel_rf55xx()
3750 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x38 : 0x28); in rt2800_config_channel_rf55xx()
3752 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x32 : 0x20); in rt2800_config_channel_rf55xx()
3754 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x28 : 0x7F); in rt2800_config_channel_rf55xx()
3756 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x19 : 0x7F); in rt2800_config_channel_rf55xx()
3764 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf7620()
3778 * R20[7:0] in rf->rf1 in rt2800_config_channel_rf7620()
3782 rfcsr = (rf->rf1 & 0x00ff); in rt2800_config_channel_rf7620()
3804 * Ksd: R17<7:0> in rf->rf2 in rt2800_config_channel_rf7620()
3805 * R18<7:0> in rf->rf3 in rt2800_config_channel_rf7620()
3806 * R19<1:0> in rf->rf4 in rt2800_config_channel_rf7620()
3809 rfcsr = rf->rf2; in rt2800_config_channel_rf7620()
3813 rfcsr = rf->rf3; in rt2800_config_channel_rf7620()
3817 rt2x00_set_field8(&rfcsr, RFCSR19_K, rf->rf4); in rt2800_config_channel_rf7620()
3831 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3836 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3838 rt2x00dev->default_ant.rx_chain_num != 1); in rt2800_config_channel_rf7620()
3843 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3871 conf_is_ht40(conf) && (rf->channel == 11)); in rt2800_config_channel_rf7620()
3874 if (!test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) { in rt2800_config_channel_rf7620()
3876 rx_agc_fc = drv_data->rx_calibration_bw40; in rt2800_config_channel_rf7620()
3877 tx_agc_fc = drv_data->tx_calibration_bw40; in rt2800_config_channel_rf7620()
3879 rx_agc_fc = drv_data->rx_calibration_bw20; in rt2800_config_channel_rf7620()
3880 tx_agc_fc = drv_data->tx_calibration_bw20; in rt2800_config_channel_rf7620()
3882 rfcsr = rt2800_rfcsr_read_bank(rt2x00dev, 5, 6); in rt2800_config_channel_rf7620()
3885 rt2800_rfcsr_write_bank(rt2x00dev, 5, 6, rfcsr); in rt2800_config_channel_rf7620()
3886 rfcsr = rt2800_rfcsr_read_bank(rt2x00dev, 5, 7); in rt2800_config_channel_rf7620()
3889 rt2800_rfcsr_write_bank(rt2x00dev, 5, 7, rfcsr); in rt2800_config_channel_rf7620()
3899 rfcsr = rt2800_rfcsr_read_bank(rt2x00dev, 5, 58); in rt2800_config_channel_rf7620()
3902 rt2800_rfcsr_write_bank(rt2x00dev, 5, 58, rfcsr); in rt2800_config_channel_rf7620()
3903 rfcsr = rt2800_rfcsr_read_bank(rt2x00dev, 5, 59); in rt2800_config_channel_rf7620()
3906 rt2800_rfcsr_write_bank(rt2x00dev, 5, 59, rfcsr); in rt2800_config_channel_rf7620()
3922 int cur_channel = rt2x00dev->rf_channel; in rt2800_config_alc_rt6352()
3934 power_level = (power_level - 3) * 2; in rt2800_config_alc_rt6352()
3945 power_level -= rate_power; in rt2800_config_alc_rt6352()
3952 chan_power = power_group[cnt][cur_channel - 1]; in rt2800_config_alc_rt6352()
3986 if (chan->center_freq > 2457) { in rt2800_config_alc_rt6352()
4016 for (chain = 0; chain < rt2x00dev->default_ant.rx_chain_num; chain++) { in rt2800_bbp_write_with_rx_chain()
4113 s8 txpower) in rt2800_txpower_to_dev() argument
4117 txpower = rt2x00_get_field8(txpower, EEPROM_TXPOWER_ALC); in rt2800_txpower_to_dev()
4120 return clamp_t(s8, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER); in rt2800_txpower_to_dev()
4124 return clamp_t(s8, txpower, MIN_A_TXPOWER_3593, in rt2800_txpower_to_dev()
4127 return clamp_t(s8, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER); in rt2800_txpower_to_dev()
4135 bbp = (rf->channel > 14) ? 0x48 : 0x38; in rt3883_bbp_adjust()
4140 if (rf->channel <= 14) { in rt3883_bbp_adjust()
4149 if (rf->channel > 14) { in rt3883_bbp_adjust()
4169 info->default_power1 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4170 info->default_power1); in rt2800_config_channel()
4171 info->default_power2 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4172 info->default_power2); in rt2800_config_channel()
4173 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_config_channel()
4174 info->default_power3 = in rt2800_config_channel()
4175 rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4176 info->default_power3); in rt2800_config_channel()
4178 switch (rt2x00dev->chip.rt) { in rt2800_config_channel()
4184 switch (rt2x00dev->chip.rf) { in rt2800_config_channel()
4261 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4262 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4263 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4266 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); in rt2800_config_channel()
4268 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); in rt2800_config_channel()
4272 if (rf->channel > 14) { in rt2800_config_channel()
4273 /* Disable CCK Packet detection on 5GHz */ in rt2800_config_channel()
4284 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4285 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4286 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4289 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4290 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4291 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4293 if (rt2x00dev->default_ant.rx_chain_num > 1) in rt2800_config_channel()
4298 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4299 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4300 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4307 if (rf->channel <= 14) { in rt2800_config_channel()
4348 rt2x00_set_field32(®, TX_BAND_CFG_A, rf->channel > 14); in rt2800_config_channel()
4349 rt2x00_set_field32(®, TX_BAND_CFG_BG, rf->channel <= 14); in rt2800_config_channel()
4362 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel()
4366 rf->channel > 14); in rt2800_config_channel()
4368 rf->channel <= 14); in rt2800_config_channel()
4373 rf->channel > 14); in rt2800_config_channel()
4375 rf->channel <= 14); in rt2800_config_channel()
4380 rf->channel > 14); in rt2800_config_channel()
4385 rf->channel <= 14); in rt2800_config_channel()
4389 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel()
4416 if (rf->channel <= 14) in rt2800_config_channel()
4417 reg = 0x1c + (2 * rt2x00dev->lna_gain); in rt2800_config_channel()
4419 reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4432 if (rf->channel <= 14) in rt2800_config_channel()
4457 if (rf->channel <= 14) in rt2800_config_channel()
4458 reg = 0x1c + 2 * rt2x00dev->lna_gain; in rt2800_config_channel()
4460 reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4474 if (rf->channel <= 14) in rt2800_config_channel()
4475 reg = 0x2e + rt2x00dev->lna_gain; in rt2800_config_channel()
4477 reg = 0x20 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4488 bbp = (rf->channel <= 14 ? 0x1c : 0x24) + 2 * rt2x00dev->lna_gain; in rt2800_config_channel()
4491 rt2800_iq_calibrate(rt2x00dev, rf->channel); in rt2800_config_channel()
4504 if (rt2x00dev->default_ant.rx_chain_num == 1) { in rt2800_config_channel()
4519 bbp = rf->channel <= 14 ? 0x04 + 2 * rt2x00dev->lna_gain : 0; in rt2800_config_channel()
4584 * Array idx 0 1 2 3 4 5 6 7 8 in rt2800_get_gain_calibration_delta()
4585 * Matching Delta value -4 -3 -2 -1 0 +1 +2 +3 +4 in rt2800_get_gain_calibration_delta()
4588 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_get_gain_calibration_delta()
4604 tssi_bounds[5] = rt2x00_get_field16(eeprom, in rt2800_get_gain_calibration_delta()
4635 tssi_bounds[5] = rt2x00_get_field16(eeprom, in rt2800_get_gain_calibration_delta()
4673 for (i = 8; i >= 5; i--) { in rt2800_get_gain_calibration_delta()
4679 return (i - 4) * step; in rt2800_get_gain_calibration_delta()
4696 !test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_get_txpower_bw_comp()
4708 comp_value = -comp_value; in rt2800_get_txpower_bw_comp()
4719 comp_value = -comp_value; in rt2800_get_txpower_bw_comp()
4743 delta = power_level - max_power; in rt2800_get_txpower_reg_delta()
4749 u8 txpower, int delta) in rt2800_compensate_txpower() argument
4758 return min_t(u8, txpower, 0xc); in rt2800_compensate_txpower()
4761 return min_t(u8, txpower, 0xf); in rt2800_compensate_txpower()
4765 * Check if eirp txpower exceed txpower_limit. in rt2800_compensate_txpower()
4766 * We use OFDM 6M as criterion and its eirp txpower in rt2800_compensate_txpower()
4769 * when calculating eirp txpower. in rt2800_compensate_txpower()
4786 eirp_txpower = eirp_txpower_criterion + (txpower - criterion) + in rt2800_compensate_txpower()
4790 (eirp_txpower - power_level) : 0; in rt2800_compensate_txpower()
4794 txpower = max(0, txpower + delta - reg_limit); in rt2800_compensate_txpower()
4795 return min_t(u8, txpower, 0xc); in rt2800_compensate_txpower()
4822 u8 txpower; in rt2800_config_txpower_rt3593() local
4826 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt3593()
4842 if (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_config_txpower_rt3593()
4845 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
4850 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
4851 txpower = rt2800_compensate_txpower(rt2x00dev, 1, band, power_level, in rt2800_config_txpower_rt3593()
4852 txpower, delta); in rt2800_config_txpower_rt3593()
4854 TX_PWR_CFG_0_CCK1_CH0, txpower); in rt2800_config_txpower_rt3593()
4856 TX_PWR_CFG_0_CCK1_CH1, txpower); in rt2800_config_txpower_rt3593()
4858 TX_PWR_CFG_0_EXT_CCK1_CH2, txpower); in rt2800_config_txpower_rt3593()
4861 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
4862 txpower = rt2800_compensate_txpower(rt2x00dev, 1, band, power_level, in rt2800_config_txpower_rt3593()
4863 txpower, delta); in rt2800_config_txpower_rt3593()
4865 TX_PWR_CFG_0_CCK5_CH0, txpower); in rt2800_config_txpower_rt3593()
4867 TX_PWR_CFG_0_CCK5_CH1, txpower); in rt2800_config_txpower_rt3593()
4869 TX_PWR_CFG_0_EXT_CCK5_CH2, txpower); in rt2800_config_txpower_rt3593()
4872 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
4873 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4874 txpower, delta); in rt2800_config_txpower_rt3593()
4876 TX_PWR_CFG_0_OFDM6_CH0, txpower); in rt2800_config_txpower_rt3593()
4878 TX_PWR_CFG_0_OFDM6_CH1, txpower); in rt2800_config_txpower_rt3593()
4880 TX_PWR_CFG_0_EXT_OFDM6_CH2, txpower); in rt2800_config_txpower_rt3593()
4883 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); in rt2800_config_txpower_rt3593()
4884 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4885 txpower, delta); in rt2800_config_txpower_rt3593()
4887 TX_PWR_CFG_0_OFDM12_CH0, txpower); in rt2800_config_txpower_rt3593()
4889 TX_PWR_CFG_0_OFDM12_CH1, txpower); in rt2800_config_txpower_rt3593()
4891 TX_PWR_CFG_0_EXT_OFDM12_CH2, txpower); in rt2800_config_txpower_rt3593()
4893 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
4898 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
4899 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4900 txpower, delta); in rt2800_config_txpower_rt3593()
4902 TX_PWR_CFG_1_OFDM24_CH0, txpower); in rt2800_config_txpower_rt3593()
4904 TX_PWR_CFG_1_OFDM24_CH1, txpower); in rt2800_config_txpower_rt3593()
4906 TX_PWR_CFG_1_EXT_OFDM24_CH2, txpower); in rt2800_config_txpower_rt3593()
4909 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
4910 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4911 txpower, delta); in rt2800_config_txpower_rt3593()
4913 TX_PWR_CFG_1_OFDM48_CH0, txpower); in rt2800_config_txpower_rt3593()
4915 TX_PWR_CFG_1_OFDM48_CH1, txpower); in rt2800_config_txpower_rt3593()
4917 TX_PWR_CFG_1_EXT_OFDM48_CH2, txpower); in rt2800_config_txpower_rt3593()
4920 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
4921 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4922 txpower, delta); in rt2800_config_txpower_rt3593()
4924 TX_PWR_CFG_7_OFDM54_CH0, txpower); in rt2800_config_txpower_rt3593()
4926 TX_PWR_CFG_7_OFDM54_CH1, txpower); in rt2800_config_txpower_rt3593()
4928 TX_PWR_CFG_7_OFDM54_CH2, txpower); in rt2800_config_txpower_rt3593()
4930 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
4935 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
4936 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4937 txpower, delta); in rt2800_config_txpower_rt3593()
4939 TX_PWR_CFG_1_MCS0_CH0, txpower); in rt2800_config_txpower_rt3593()
4941 TX_PWR_CFG_1_MCS0_CH1, txpower); in rt2800_config_txpower_rt3593()
4943 TX_PWR_CFG_1_EXT_MCS0_CH2, txpower); in rt2800_config_txpower_rt3593()
4946 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
4947 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4948 txpower, delta); in rt2800_config_txpower_rt3593()
4950 TX_PWR_CFG_1_MCS2_CH0, txpower); in rt2800_config_txpower_rt3593()
4952 TX_PWR_CFG_1_MCS2_CH1, txpower); in rt2800_config_txpower_rt3593()
4954 TX_PWR_CFG_1_EXT_MCS2_CH2, txpower); in rt2800_config_txpower_rt3593()
4956 /* MCS 4,5 */ in rt2800_config_txpower_rt3593()
4957 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
4958 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4959 txpower, delta); in rt2800_config_txpower_rt3593()
4961 TX_PWR_CFG_2_MCS4_CH0, txpower); in rt2800_config_txpower_rt3593()
4963 TX_PWR_CFG_2_MCS4_CH1, txpower); in rt2800_config_txpower_rt3593()
4965 TX_PWR_CFG_2_EXT_MCS4_CH2, txpower); in rt2800_config_txpower_rt3593()
4968 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); in rt2800_config_txpower_rt3593()
4969 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4970 txpower, delta); in rt2800_config_txpower_rt3593()
4972 TX_PWR_CFG_2_MCS6_CH0, txpower); in rt2800_config_txpower_rt3593()
4974 TX_PWR_CFG_2_MCS6_CH1, txpower); in rt2800_config_txpower_rt3593()
4976 TX_PWR_CFG_2_EXT_MCS6_CH2, txpower); in rt2800_config_txpower_rt3593()
4978 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
4983 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
4984 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4985 txpower, delta); in rt2800_config_txpower_rt3593()
4987 TX_PWR_CFG_7_MCS7_CH0, txpower); in rt2800_config_txpower_rt3593()
4989 TX_PWR_CFG_7_MCS7_CH1, txpower); in rt2800_config_txpower_rt3593()
4991 TX_PWR_CFG_7_MCS7_CH2, txpower); in rt2800_config_txpower_rt3593()
4994 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
4995 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4996 txpower, delta); in rt2800_config_txpower_rt3593()
4998 TX_PWR_CFG_2_MCS8_CH0, txpower); in rt2800_config_txpower_rt3593()
5000 TX_PWR_CFG_2_MCS8_CH1, txpower); in rt2800_config_txpower_rt3593()
5002 TX_PWR_CFG_2_EXT_MCS8_CH2, txpower); in rt2800_config_txpower_rt3593()
5005 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
5006 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5007 txpower, delta); in rt2800_config_txpower_rt3593()
5009 TX_PWR_CFG_2_MCS10_CH0, txpower); in rt2800_config_txpower_rt3593()
5011 TX_PWR_CFG_2_MCS10_CH1, txpower); in rt2800_config_txpower_rt3593()
5013 TX_PWR_CFG_2_EXT_MCS10_CH2, txpower); in rt2800_config_txpower_rt3593()
5016 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); in rt2800_config_txpower_rt3593()
5017 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5018 txpower, delta); in rt2800_config_txpower_rt3593()
5020 TX_PWR_CFG_3_MCS12_CH0, txpower); in rt2800_config_txpower_rt3593()
5022 TX_PWR_CFG_3_MCS12_CH1, txpower); in rt2800_config_txpower_rt3593()
5024 TX_PWR_CFG_3_EXT_MCS12_CH2, txpower); in rt2800_config_txpower_rt3593()
5026 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
5031 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
5032 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5033 txpower, delta); in rt2800_config_txpower_rt3593()
5035 TX_PWR_CFG_3_MCS14_CH0, txpower); in rt2800_config_txpower_rt3593()
5037 TX_PWR_CFG_3_MCS14_CH1, txpower); in rt2800_config_txpower_rt3593()
5039 TX_PWR_CFG_3_EXT_MCS14_CH2, txpower); in rt2800_config_txpower_rt3593()
5042 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
5043 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5044 txpower, delta); in rt2800_config_txpower_rt3593()
5046 TX_PWR_CFG_8_MCS15_CH0, txpower); in rt2800_config_txpower_rt3593()
5048 TX_PWR_CFG_8_MCS15_CH1, txpower); in rt2800_config_txpower_rt3593()
5050 TX_PWR_CFG_8_MCS15_CH2, txpower); in rt2800_config_txpower_rt3593()
5053 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
5054 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5055 txpower, delta); in rt2800_config_txpower_rt3593()
5057 TX_PWR_CFG_5_MCS16_CH0, txpower); in rt2800_config_txpower_rt3593()
5059 TX_PWR_CFG_5_MCS16_CH1, txpower); in rt2800_config_txpower_rt3593()
5061 TX_PWR_CFG_5_MCS16_CH2, txpower); in rt2800_config_txpower_rt3593()
5064 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); in rt2800_config_txpower_rt3593()
5065 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5066 txpower, delta); in rt2800_config_txpower_rt3593()
5068 TX_PWR_CFG_5_MCS18_CH0, txpower); in rt2800_config_txpower_rt3593()
5070 TX_PWR_CFG_5_MCS18_CH1, txpower); in rt2800_config_txpower_rt3593()
5072 TX_PWR_CFG_5_MCS18_CH2, txpower); in rt2800_config_txpower_rt3593()
5074 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
5076 offset + 5); in rt2800_config_txpower_rt3593()
5079 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
5080 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5081 txpower, delta); in rt2800_config_txpower_rt3593()
5083 TX_PWR_CFG_6_MCS20_CH0, txpower); in rt2800_config_txpower_rt3593()
5085 TX_PWR_CFG_6_MCS20_CH1, txpower); in rt2800_config_txpower_rt3593()
5087 TX_PWR_CFG_6_MCS20_CH2, txpower); in rt2800_config_txpower_rt3593()
5090 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
5091 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5092 txpower, delta); in rt2800_config_txpower_rt3593()
5094 TX_PWR_CFG_6_MCS22_CH0, txpower); in rt2800_config_txpower_rt3593()
5096 TX_PWR_CFG_6_MCS22_CH1, txpower); in rt2800_config_txpower_rt3593()
5098 TX_PWR_CFG_6_MCS22_CH2, txpower); in rt2800_config_txpower_rt3593()
5101 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
5102 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5103 txpower, delta); in rt2800_config_txpower_rt3593()
5105 TX_PWR_CFG_8_MCS23_CH0, txpower); in rt2800_config_txpower_rt3593()
5107 TX_PWR_CFG_8_MCS23_CH1, txpower); in rt2800_config_txpower_rt3593()
5109 TX_PWR_CFG_8_MCS23_CH2, txpower); in rt2800_config_txpower_rt3593()
5111 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
5116 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
5117 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5118 txpower, delta); in rt2800_config_txpower_rt3593()
5120 TX_PWR_CFG_3_STBC0_CH0, txpower); in rt2800_config_txpower_rt3593()
5122 TX_PWR_CFG_3_STBC0_CH1, txpower); in rt2800_config_txpower_rt3593()
5124 TX_PWR_CFG_3_EXT_STBC0_CH2, txpower); in rt2800_config_txpower_rt3593()
5127 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
5128 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5129 txpower, delta); in rt2800_config_txpower_rt3593()
5131 TX_PWR_CFG_3_STBC2_CH0, txpower); in rt2800_config_txpower_rt3593()
5133 TX_PWR_CFG_3_STBC2_CH1, txpower); in rt2800_config_txpower_rt3593()
5135 TX_PWR_CFG_3_EXT_STBC2_CH2, txpower); in rt2800_config_txpower_rt3593()
5137 /* STBC, MCS 4,5 */ in rt2800_config_txpower_rt3593()
5138 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
5139 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5140 txpower, delta); in rt2800_config_txpower_rt3593()
5141 rt2x00_set_field32(®s[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE0, txpower); in rt2800_config_txpower_rt3593()
5142 rt2x00_set_field32(®s[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE1, txpower); in rt2800_config_txpower_rt3593()
5144 txpower); in rt2800_config_txpower_rt3593()
5147 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); in rt2800_config_txpower_rt3593()
5148 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5149 txpower, delta); in rt2800_config_txpower_rt3593()
5150 rt2x00_set_field32(®s[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE2, txpower); in rt2800_config_txpower_rt3593()
5151 rt2x00_set_field32(®s[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE3, txpower); in rt2800_config_txpower_rt3593()
5153 txpower); in rt2800_config_txpower_rt3593()
5155 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
5160 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
5161 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5162 txpower, delta); in rt2800_config_txpower_rt3593()
5164 TX_PWR_CFG_9_STBC7_CH0, txpower); in rt2800_config_txpower_rt3593()
5166 TX_PWR_CFG_9_STBC7_CH1, txpower); in rt2800_config_txpower_rt3593()
5168 TX_PWR_CFG_9_STBC7_CH2, txpower); in rt2800_config_txpower_rt3593()
5195 (band == NL80211_BAND_5GHZ) ? '5' : '2', in rt2800_config_txpower_rt3593()
5196 (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) ? in rt2800_config_txpower_rt3593()
5199 (i - TX_PWR_CFG_9_IDX - 1) : i, in rt2800_config_txpower_rt3593()
5212 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt6352()
5225 * Maybe some misunderstanding of what a signed 8-bit value is? Maybe in rt2800_config_txpower_rt6352()
5227 * used a fixed offset between HT20 and HT40 rates they had to work- in rt2800_config_txpower_rt6352()
5236 for (i = 0; i < 5; i++) { in rt2800_config_txpower_rt6352()
5272 if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) { in rt2800_config_txpower_rt6352()
5289 * registers. As recent 2T chips use 8-bit instead of 4-bit values for in rt2800_config_txpower_rt6352()
5290 * power-offsets more space would be needed. Ralink decided to keep the in rt2800_config_txpower_rt6352()
5332 * for all rates, but allow to set only 4 discrete values: -12, -6, 0 and 6 dBm.
5341 u8 txpower, r1; in rt2800_config_txpower_rt28xx() local
5345 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt28xx()
5349 * value read from EEPROM (different for 2GHz and for 5GHz). in rt2800_config_txpower_rt28xx()
5360 switch (rt2x00dev->chip.rt) { in rt2800_config_txpower_rt28xx()
5381 chan->max_power); in rt2800_config_txpower_rt28xx()
5385 * gains -12, -6, 0, +6 dBm by setting values 2, 1, 0, 3 respectively. in rt2800_config_txpower_rt28xx()
5391 if (delta <= -12) { in rt2800_config_txpower_rt28xx()
5394 } else if (delta <= -6) { in rt2800_config_txpower_rt28xx()
5413 /* read the next four txpower values */ in rt2800_config_txpower_rt28xx()
5424 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5426 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5427 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5428 rt2x00_set_field32(®, TX_PWR_CFG_RATE0, txpower); in rt2800_config_txpower_rt28xx()
5435 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5437 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5438 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5439 rt2x00_set_field32(®, TX_PWR_CFG_RATE1, txpower); in rt2800_config_txpower_rt28xx()
5446 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5448 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5449 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5450 rt2x00_set_field32(®, TX_PWR_CFG_RATE2, txpower); in rt2800_config_txpower_rt28xx()
5457 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5459 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5460 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5461 rt2x00_set_field32(®, TX_PWR_CFG_RATE3, txpower); in rt2800_config_txpower_rt28xx()
5463 /* read the next four txpower values */ in rt2800_config_txpower_rt28xx()
5474 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5476 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5477 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5478 rt2x00_set_field32(®, TX_PWR_CFG_RATE4, txpower); in rt2800_config_txpower_rt28xx()
5485 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5487 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5488 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5489 rt2x00_set_field32(®, TX_PWR_CFG_RATE5, txpower); in rt2800_config_txpower_rt28xx()
5496 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5498 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5499 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5500 rt2x00_set_field32(®, TX_PWR_CFG_RATE6, txpower); in rt2800_config_txpower_rt28xx()
5507 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5509 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5510 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5511 rt2x00_set_field32(®, TX_PWR_CFG_RATE7, txpower); in rt2800_config_txpower_rt28xx()
5535 rt2800_config_txpower(rt2x00dev, rt2x00dev->hw->conf.chandef.chan, in rt2800_gain_calibration()
5536 rt2x00dev->tx_power); in rt2800_gain_calibration()
5547 * A voltage-controlled oscillator(VCO) is an electronic oscillator in rt2800_vco_calibration()
5558 switch (rt2x00dev->chip.rf) { in rt2800_vco_calibration()
5587 rt2800_rfcsr_write(rt2x00dev, 5, 0x40); in rt2800_vco_calibration()
5596 rt2x00dev->chip.rf); in rt2800_vco_calibration()
5604 if (rt2x00dev->rf_channel <= 14) { in rt2800_vco_calibration()
5605 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_vco_calibration()
5618 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_vco_calibration()
5642 libconf->conf->short_frame_max_tx_count); in rt2800_config_retry_limit()
5644 libconf->conf->long_frame_max_tx_count); in rt2800_config_retry_limit()
5652 (libconf->conf->flags & IEEE80211_CONF_PS) ? in rt2800_config_ps()
5660 rt2x00_set_field32(®, AUTOWAKEUP_CFG_AUTO_LEAD_TIME, 5); in rt2800_config_ps()
5662 libconf->conf->listen_interval - 1); in rt2800_config_ps()
5666 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); in rt2800_config_ps()
5674 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); in rt2800_config_ps()
5687 * To provide correct survey data for survey-based ACS algorithm in rt2800_config()
5692 rt2800_config_channel(rt2x00dev, libconf->conf, in rt2800_config()
5693 &libconf->rf, &libconf->channel); in rt2800_config()
5694 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, in rt2800_config()
5695 libconf->conf->power_level); in rt2800_config()
5698 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, in rt2800_config()
5699 libconf->conf->power_level); in rt2800_config()
5718 qual->rx_failed = rt2x00_get_field32(reg, RX_STA_CNT0_CRC_ERR); in rt2800_link_stats()
5726 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_get_default_vgc()
5738 vgc = 0x1c + (2 * rt2x00dev->lna_gain); in rt2800_get_default_vgc()
5740 vgc = 0x2e + rt2x00dev->lna_gain; in rt2800_get_default_vgc()
5741 } else { /* 5GHZ band */ in rt2800_get_default_vgc()
5744 vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5746 vgc = 0x24 + (2 * rt2x00dev->lna_gain); in rt2800_get_default_vgc()
5748 if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_get_default_vgc()
5749 vgc = 0x32 + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5751 vgc = 0x3a + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5761 if (qual->vgc_level != vgc_level) { in rt2800_set_vgc()
5769 rt2800_bbp_write(rt2x00dev, 83, qual->rssi > -65 ? 0x4a : 0x7a); in rt2800_set_vgc()
5775 qual->vgc_level = vgc_level; in rt2800_set_vgc()
5776 qual->vgc_level_reg = vgc_level; in rt2800_set_vgc()
5801 switch (rt2x00dev->chip.rt) { in rt2800_link_tuner()
5804 if (qual->rssi > -65) { in rt2800_link_tuner()
5805 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) in rt2800_link_tuner()
5813 if (qual->rssi > -65) in rt2800_link_tuner()
5818 if (qual->rssi > -65) in rt2800_link_tuner()
5823 if (qual->rssi > -80) in rt2800_link_tuner()
5837 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_init_registers()
6049 drv_data->max_psdu = 3; in rt2800_init_registers()
6053 drv_data->max_psdu = 2; in rt2800_init_registers()
6055 drv_data->max_psdu = 1; in rt2800_init_registers()
6057 rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, drv_data->max_psdu); in rt2800_init_registers()
6225 * connection problems with 11g + CTS protection. Hence, use the same in rt2800_init_registers()
6254 if (!test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags)) in rt2800_init_registers()
6302 rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS6FBK, 5); in rt2800_init_registers()
6626 /* Use 5-bit ADC for Acquisition and 8-bit ADC for data */ in rt2800_init_bbp_3290()
6976 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_init_bbp_5592()
7047 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_init_bbp_6352()
7058 /* BBP for G band */ in rt2800_init_bbp_6352()
7134 /* BBP for G band GLRT function (BBP_128 ~ BBP_221) */ in rt2800_init_bbp_6352()
7219 /* BBP for G band DCOC function */ in rt2800_init_bbp_6352()
7256 switch (rt2x00dev->chip.rt) { in rt2800_init_bbp()
7369 if ((passband - stopband) <= filter_target) { in rt2800_init_rx_filter()
7371 overtuned += ((passband - stopband) == filter_target); in rt2800_init_rx_filter()
7378 rfcsr24 -= !!overtuned; in rt2800_init_rx_filter()
7399 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_rx_filter_calibration()
7415 drv_data->calibration_bw20 = in rt2800_rx_filter_calibration()
7417 drv_data->calibration_bw40 = in rt2800_rx_filter_calibration()
7423 drv_data->bbp25 = rt2800_bbp_read(rt2x00dev, 25); in rt2800_rx_filter_calibration()
7424 drv_data->bbp26 = rt2800_bbp_read(rt2x00dev, 26); in rt2800_rx_filter_calibration()
7445 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_normal_mode_setup_3xxx()
7461 if (drv_data->txmixer_gain_24g >= min_gain) { in rt2800_normal_mode_setup_3xxx()
7463 drv_data->txmixer_gain_24g); in rt2800_normal_mode_setup_3xxx()
7516 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_normal_mode_setup_3593()
7525 tx_gain = rt2x00_get_field8(drv_data->txmixer_gain_24g, in rt2800_normal_mode_setup_3593()
7588 rt2800_rfcsr_write(rt2x00dev, 5, 0x03); in rt2800_init_rfcsr_305x_soc()
7627 rt2800_rfcsr_write(rt2x00dev, 5, 0x03); in rt2800_init_rfcsr_30xx()
7751 &rt2x00dev->cap_flags); in rt2800_init_rfcsr_3352()
7753 &rt2x00dev->cap_flags); in rt2800_init_rfcsr_3352()
7763 rt2800_rfcsr_write(rt2x00dev, 5, 0x00); in rt2800_init_rfcsr_3352()
7858 rt2800_rfcsr_write(rt2x00dev, 5, 0x8b); in rt2800_init_rfcsr_3390()
7911 rt2800_rfcsr_write(rt2x00dev, 5, 0x05); in rt2800_init_rfcsr_3572()
7963 if (rt2x00dev->default_ant.rx_chain_num == 1) in rt3593_post_bbp_init()
8006 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_init_rfcsr_3593()
8019 rt2800_rfcsr_write(rt2x00dev, 5, 0x00); in rt2800_init_rfcsr_3593()
8072 drv_data->calibration_bw20 = 0x1f; in rt2800_init_rfcsr_3593()
8073 drv_data->calibration_bw40 = 0x2f; in rt2800_init_rfcsr_3593()
8076 drv_data->bbp25 = rt2800_bbp_read(rt2x00dev, 25); in rt2800_init_rfcsr_3593()
8077 drv_data->bbp26 = rt2800_bbp_read(rt2x00dev, 26); in rt2800_init_rfcsr_3593()
8094 rt2800_rfcsr_write(rt2x00dev, 5, 0x10); in rt2800_init_rfcsr_5350()
8162 const unsigned int eco = 5; in rt2800_init_rfcsr_3883()
8171 rt2800_rfcsr_write(rt2x00dev, 5, 0x00); in rt2800_init_rfcsr_3883()
8261 if (eco == 5) { in rt2800_init_rfcsr_3883()
8302 rt2800_rfcsr_write(rt2x00dev, 5, 0x10); in rt2800_init_rfcsr_5390()
8399 rt2800_rfcsr_write(rt2x00dev, 5, 0x10); in rt2800_init_rfcsr_5392()
8467 rt2800_rfcsr_write(rt2x00dev, 5, 0x10); in rt2800_init_rfcsr_5592()
8522 rfb5r1_org = rt2800_rfcsr_read_bank(rt2x00dev, 5, 1); in rt2800_rf_self_txdc_cal()
8525 rt2800_rfcsr_write_bank(rt2x00dev, 5, 1, 0x4); in rt2800_rf_self_txdc_cal()
8528 rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 1); in rt2800_rf_self_txdc_cal()
8532 rt2800_rfcsr_write_bank(rt2x00dev, 5, 1, rfb5r1_org); in rt2800_rf_self_txdc_cal()
8553 int calcode = ((d2 - d1) * 1000) / 43; in rt2800_calcrcalibrationcode()
8555 if ((calcode % 10) >= 5) in rt2800_calcrcalibrationcode()
8580 saverfb5r4 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4); in rt2800_r_calibration()
8581 saverfb5r17 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 17); in rt2800_r_calibration()
8582 saverfb5r18 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 18); in rt2800_r_calibration()
8583 saverfb5r19 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 19); in rt2800_r_calibration()
8584 saverfb5r20 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 20); in rt2800_r_calibration()
8614 rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, 0x27); in rt2800_r_calibration()
8615 rt2800_rfcsr_write_bank(rt2x00dev, 5, 17, 0x80); in rt2800_r_calibration()
8616 rt2800_rfcsr_write_bank(rt2x00dev, 5, 18, 0x83); in rt2800_r_calibration()
8617 rt2800_rfcsr_write_bank(rt2x00dev, 5, 19, 0x00); in rt2800_r_calibration()
8618 rt2800_rfcsr_write_bank(rt2x00dev, 5, 20, 0x20); in rt2800_r_calibration()
8631 d1 = bytevalue - 256; in rt2800_r_calibration()
8641 d2 = bytevalue - 256; in rt2800_r_calibration()
8666 rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, saverfb5r4); in rt2800_r_calibration()
8667 rt2800_rfcsr_write_bank(rt2x00dev, 5, 17, saverfb5r17); in rt2800_r_calibration()
8668 rt2800_rfcsr_write_bank(rt2x00dev, 5, 18, saverfb5r18); in rt2800_r_calibration()
8669 rt2800_rfcsr_write_bank(rt2x00dev, 5, 19, saverfb5r19); in rt2800_r_calibration()
8670 rt2800_rfcsr_write_bank(rt2x00dev, 5, 20, saverfb5r20); in rt2800_r_calibration()
8706 saverfb5r4 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4); in rt2800_rxdcoc_calibration()
8711 rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, saverfb5r4); in rt2800_rxdcoc_calibration()
8749 for (i = 15; i >= 0; i = i - 1) { in rt2800_do_sqrt_accumulation()
8815 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) in rt2800_rxiq_calibration()
8827 rfb5r3 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 3); in rt2800_rxiq_calibration()
8828 rfb5r4 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4); in rt2800_rxiq_calibration()
8829 rfb5r17 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 17); in rt2800_rxiq_calibration()
8830 rfb5r18 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 18); in rt2800_rxiq_calibration()
8831 rfb5r19 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 19); in rt2800_rxiq_calibration()
8832 rfb5r20 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 20); in rt2800_rxiq_calibration()
8855 rt2800_bbp_dcoc_write(rt2x00dev, 5, 0x0); in rt2800_rxiq_calibration()
8875 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_rxiq_calibration()
8938 for (i = 0; i < 5; i++) { in rt2800_rxiq_calibration()
8959 result = (bbptemp & 0xffffff) - 0x1000000; in rt2800_rxiq_calibration()
8975 bbpval1 = si - mi * mi; in rt2800_rxiq_calibration()
8992 vga_idx = vga_idx + 5; in rt2800_rxiq_calibration()
9003 sigma_i = rt2800_do_sqrt_accumulation(100 * (si - mi * mi)); in rt2800_rxiq_calibration()
9004 sigma_q = rt2800_do_sqrt_accumulation(100 * (sq - mq * mq)); in rt2800_rxiq_calibration()
9005 r_iq = 10 * (riq - (mi * mq)); in rt2800_rxiq_calibration()
9010 (sigma_i - sigma_q) <= 112 && in rt2800_rxiq_calibration()
9011 (sigma_i - sigma_q) >= -112 && in rt2800_rxiq_calibration()
9012 mi <= 32 && mi >= -32 && in rt2800_rxiq_calibration()
9013 mq <= 32 && mq >= -32) { in rt2800_rxiq_calibration()
9014 r_iq = 10 * (riq - (mi * mq)); in rt2800_rxiq_calibration()
9019 g_imb = ((-2) * 128 * (1000 - g_rx)) / (1000 + g_rx); in rt2800_rxiq_calibration()
9022 if (ph_rx > 20 || ph_rx < -20) { in rt2800_rxiq_calibration()
9027 if (g_imb > 12 || g_imb < -12) { in rt2800_rxiq_calibration()
9078 rt2800_rfcsr_write_bank(rt2x00dev, 5, 3, rfb5r3); in rt2800_rxiq_calibration()
9079 rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, rfb5r4); in rt2800_rxiq_calibration()
9080 rt2800_rfcsr_write_bank(rt2x00dev, 5, 17, rfb5r17); in rt2800_rxiq_calibration()
9081 rt2800_rfcsr_write_bank(rt2x00dev, 5, 18, rfb5r18); in rt2800_rxiq_calibration()
9082 rt2800_rfcsr_write_bank(rt2x00dev, 5, 19, rfb5r19); in rt2800_rxiq_calibration()
9083 rt2800_rfcsr_write_bank(rt2x00dev, 5, 20, rfb5r20); in rt2800_rxiq_calibration()
9135 rf_reg_record[CHAIN_0][5].bank = 4; in rt2800_rf_configstore()
9136 rf_reg_record[CHAIN_0][5].reg = 2; in rt2800_rf_configstore()
9137 rf_reg_record[CHAIN_0][5].value = rfvalue; in rt2800_rf_configstore()
9142 rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 3); in rt2800_rf_configstore()
9143 rf_reg_record[CHAIN_0][7].bank = 5; in rt2800_rf_configstore()
9146 rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4); in rt2800_rf_configstore()
9147 rf_reg_record[CHAIN_0][8].bank = 5; in rt2800_rf_configstore()
9150 rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 17); in rt2800_rf_configstore()
9151 rf_reg_record[CHAIN_0][9].bank = 5; in rt2800_rf_configstore()
9154 rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 18); in rt2800_rf_configstore()
9155 rf_reg_record[CHAIN_0][10].bank = 5; in rt2800_rf_configstore()
9158 rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 19); in rt2800_rf_configstore()
9159 rf_reg_record[CHAIN_0][11].bank = 5; in rt2800_rf_configstore()
9162 rfvalue = rt2800_rfcsr_read_bank(rt2x00dev, 5, 20); in rt2800_rf_configstore()
9163 rf_reg_record[CHAIN_0][12].bank = 5; in rt2800_rf_configstore()
9188 rf_reg_record[CHAIN_1][5].bank = 6; in rt2800_rf_configstore()
9189 rf_reg_record[CHAIN_1][5].reg = 2; in rt2800_rf_configstore()
9190 rf_reg_record[CHAIN_1][5].value = rfvalue; in rt2800_rf_configstore()
9286 fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; in rt2800_do_fft_accumulation()
9288 fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; in rt2800_do_fft_accumulation()
9295 tidxi = 0x40 - tidx; in rt2800_do_fft_accumulation()
9306 fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; in rt2800_do_fft_accumulation()
9308 fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; in rt2800_do_fft_accumulation()
9332 fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; in rt2800_read_fft_accumulation()
9334 fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; in rt2800_read_fft_accumulation()
9373 for (bidx = 5; bidx >= 0; bidx--) { in rt2800_loft_search()
9379 idx0 = idxf[iorq] - ibit; in rt2800_loft_search()
9385 idx1 = idxf[iorq] + (bidx == 5 ? 0 : ibit); in rt2800_loft_search()
9395 if (bidx != 5 && pf <= p0 && pf < p1) { in rt2800_loft_search()
9430 for (bidx = 5; bidx >= 1; bidx--) { in rt2800_iq_search()
9438 first_search = (gop == 0) ? (bidx == 3) : (bidx == 5); in rt2800_iq_search()
9446 idx0 = iq_err - ibit; in rt2800_iq_search()
9500 gerr = (gerr & 0x08) ? (gerr & 0x0F) - 0x10 : (gerr & 0x0F); in rt2800_iq_search()
9501 perr = (perr & 0x20) ? (perr & 0x3F) - 0x40 : (perr & 0x3F); in rt2800_iq_search()
9503 gerr = (gerr < -0x07) ? -0x07 : (gerr > 0x05) ? 0x05 : gerr; in rt2800_iq_search()
9504 gsta = gerr - 1; in rt2800_iq_search()
9507 perr = (perr < -0x1f) ? -0x1f : (perr > 0x1d) ? 0x1d : perr; in rt2800_iq_search()
9508 psta = perr - 1; in rt2800_iq_search()
9548 rt2800_rfcsr_write_bank(rt2x00dev, 5, 3, 0x2d); in rt2800_rf_aux_tx0_loopback()
9549 rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, 0x2d); in rt2800_rf_aux_tx0_loopback()
9550 rt2800_rfcsr_write_bank(rt2x00dev, 5, 17, 0x80); in rt2800_rf_aux_tx0_loopback()
9551 rt2800_rfcsr_write_bank(rt2x00dev, 5, 18, 0xd7); in rt2800_rf_aux_tx0_loopback()
9552 rt2800_rfcsr_write_bank(rt2x00dev, 5, 19, 0xa2); in rt2800_rf_aux_tx0_loopback()
9553 rt2800_rfcsr_write_bank(rt2x00dev, 5, 20, 0x20); in rt2800_rf_aux_tx0_loopback()
9694 vga_gain[ch_idx] = vga_gain[ch_idx] - 2) { in rt2800_loft_iq_calibration()
9815 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9823 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9842 if (!test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9867 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9877 if (test_bit(CAPABILITY_EXTERNAL_PA_TX1, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9893 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9912 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) in rt2800_loft_iq_calibration()
9919 if (test_bit(CAPABILITY_EXTERNAL_PA_TX1, &rt2x00dev->cap_flags)) in rt2800_loft_iq_calibration()
9924 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9928 vga_gain[ch_idx] = vga_gain[ch_idx] - 1; in rt2800_loft_iq_calibration()
9969 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9985 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) in rt2800_loft_iq_calibration()
10040 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 17); in rt2800_rf_lp_config()
10042 rt2800_rfcsr_write_bank(rt2x00dev, 5, 17, rf_val); in rt2800_rf_lp_config()
10045 rt2800_rfcsr_write_bank(rt2x00dev, 5, 18, 0xC1); in rt2800_rf_lp_config()
10046 rt2800_rfcsr_write_bank(rt2x00dev, 5, 19, 0x20); in rt2800_rf_lp_config()
10047 rt2800_rfcsr_write_bank(rt2x00dev, 5, 20, 0x02); in rt2800_rf_lp_config()
10048 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 3); in rt2800_rf_lp_config()
10051 rt2800_rfcsr_write_bank(rt2x00dev, 5, 3, rf_val); in rt2800_rf_lp_config()
10052 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4); in rt2800_rf_lp_config()
10055 rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, rf_val); in rt2800_rf_lp_config()
10056 rt2800_rfcsr_write_bank(rt2x00dev, 5, 5, 0x31); in rt2800_rf_lp_config()
10058 rt2800_rfcsr_write_bank(rt2x00dev, 5, 18, 0xF1); in rt2800_rf_lp_config()
10059 rt2800_rfcsr_write_bank(rt2x00dev, 5, 19, 0x18); in rt2800_rf_lp_config()
10060 rt2800_rfcsr_write_bank(rt2x00dev, 5, 20, 0x02); in rt2800_rf_lp_config()
10061 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 3); in rt2800_rf_lp_config()
10064 rt2800_rfcsr_write_bank(rt2x00dev, 5, 3, rf_val); in rt2800_rf_lp_config()
10065 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4); in rt2800_rf_lp_config()
10068 rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, rf_val); in rt2800_rf_lp_config()
10095 cal_val -= 128; in rt2800_lp_tx_filter_bw_cal()
10103 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_bw_filter_calibration()
10131 saverfb5r00 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 0); in rt2800_bw_filter_calibration()
10132 saverfb5r01 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 1); in rt2800_bw_filter_calibration()
10133 saverfb5r03 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 3); in rt2800_bw_filter_calibration()
10134 saverfb5r04 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 4); in rt2800_bw_filter_calibration()
10135 saverfb5r05 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 5); in rt2800_bw_filter_calibration()
10136 saverfb5r06 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 6); in rt2800_bw_filter_calibration()
10137 saverfb5r07 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 7); in rt2800_bw_filter_calibration()
10138 saverfb5r08 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 8); in rt2800_bw_filter_calibration()
10139 saverfb5r17 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 17); in rt2800_bw_filter_calibration()
10140 saverfb5r18 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 18); in rt2800_bw_filter_calibration()
10141 saverfb5r19 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 19); in rt2800_bw_filter_calibration()
10142 saverfb5r20 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 20); in rt2800_bw_filter_calibration()
10144 saverfb5r37 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 37); in rt2800_bw_filter_calibration()
10145 saverfb5r38 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 38); in rt2800_bw_filter_calibration()
10146 saverfb5r39 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 39); in rt2800_bw_filter_calibration()
10147 saverfb5r40 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 40); in rt2800_bw_filter_calibration()
10148 saverfb5r41 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 41); in rt2800_bw_filter_calibration()
10149 saverfb5r42 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 42); in rt2800_bw_filter_calibration()
10150 saverfb5r43 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 43); in rt2800_bw_filter_calibration()
10151 saverfb5r44 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 44); in rt2800_bw_filter_calibration()
10152 saverfb5r45 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 45); in rt2800_bw_filter_calibration()
10153 saverfb5r46 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 46); in rt2800_bw_filter_calibration()
10155 saverfb5r58 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 58); in rt2800_bw_filter_calibration()
10156 saverfb5r59 = rt2800_rfcsr_read_bank(rt2x00dev, 5, 59); in rt2800_bw_filter_calibration()
10158 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 0); in rt2800_bw_filter_calibration()
10160 rt2800_rfcsr_write_bank(rt2x00dev, 5, 0, rf_val); in rt2800_bw_filter_calibration()
10162 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 1); in rt2800_bw_filter_calibration()
10164 rt2800_rfcsr_write_bank(rt2x00dev, 5, 1, rf_val); in rt2800_bw_filter_calibration()
10169 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 1); in rt2800_bw_filter_calibration()
10175 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 0); in rt2800_bw_filter_calibration()
10178 rt2800_rfcsr_write_bank(rt2x00dev, 5, 0, rf_val); in rt2800_bw_filter_calibration()
10180 /* I-3 */ in rt2800_bw_filter_calibration()
10187 /* I-4,5,6,7,8,9 */ in rt2800_bw_filter_calibration()
10204 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 8); in rt2800_bw_filter_calibration()
10209 rt2800_rfcsr_write_bank(rt2x00dev, 5, 8, rf_val); in rt2800_bw_filter_calibration()
10216 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 58); in rt2800_bw_filter_calibration()
10218 rt2800_rfcsr_write_bank(rt2x00dev, 5, 58, rf_val); in rt2800_bw_filter_calibration()
10219 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 59); in rt2800_bw_filter_calibration()
10221 rt2800_rfcsr_write_bank(rt2x00dev, 5, 59, rf_val); in rt2800_bw_filter_calibration()
10224 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 6); in rt2800_bw_filter_calibration()
10226 rt2800_rfcsr_write_bank(rt2x00dev, 5, 6, rf_val); in rt2800_bw_filter_calibration()
10227 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 7); in rt2800_bw_filter_calibration()
10229 rt2800_rfcsr_write_bank(rt2x00dev, 5, 7, rf_val); in rt2800_bw_filter_calibration()
10247 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 58); in rt2800_bw_filter_calibration()
10250 rt2800_rfcsr_write_bank(rt2x00dev, 5, 58, rf_val); in rt2800_bw_filter_calibration()
10251 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 59); in rt2800_bw_filter_calibration()
10254 rt2800_rfcsr_write_bank(rt2x00dev, 5, 59, rf_val); in rt2800_bw_filter_calibration()
10256 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 6); in rt2800_bw_filter_calibration()
10259 rt2800_rfcsr_write_bank(rt2x00dev, 5, 6, rf_val); in rt2800_bw_filter_calibration()
10260 rf_val = rt2800_rfcsr_read_bank(rt2x00dev, 5, 7); in rt2800_bw_filter_calibration()
10263 rt2800_rfcsr_write_bank(rt2x00dev, 5, 7, rf_val); in rt2800_bw_filter_calibration()
10272 cal_diff = cal_r32_init - cal_r32_val; in rt2800_bw_filter_calibration()
10295 drv_data->tx_calibration_bw20 = tx_agc_fc; in rt2800_bw_filter_calibration()
10297 drv_data->tx_calibration_bw40 = tx_agc_fc; in rt2800_bw_filter_calibration()
10300 drv_data->rx_calibration_bw20 = rx_agc_fc; in rt2800_bw_filter_calibration()
10302 drv_data->rx_calibration_bw40 = rx_agc_fc; in rt2800_bw_filter_calibration()
10308 rt2800_rfcsr_write_bank(rt2x00dev, 5, 0, saverfb5r00); in rt2800_bw_filter_calibration()
10309 rt2800_rfcsr_write_bank(rt2x00dev, 5, 1, saverfb5r01); in rt2800_bw_filter_calibration()
10310 rt2800_rfcsr_write_bank(rt2x00dev, 5, 3, saverfb5r03); in rt2800_bw_filter_calibration()
10311 rt2800_rfcsr_write_bank(rt2x00dev, 5, 4, saverfb5r04); in rt2800_bw_filter_calibration()
10312 rt2800_rfcsr_write_bank(rt2x00dev, 5, 5, saverfb5r05); in rt2800_bw_filter_calibration()
10313 rt2800_rfcsr_write_bank(rt2x00dev, 5, 6, saverfb5r06); in rt2800_bw_filter_calibration()
10314 rt2800_rfcsr_write_bank(rt2x00dev, 5, 7, saverfb5r07); in rt2800_bw_filter_calibration()
10315 rt2800_rfcsr_write_bank(rt2x00dev, 5, 8, saverfb5r08); in rt2800_bw_filter_calibration()
10316 rt2800_rfcsr_write_bank(rt2x00dev, 5, 17, saverfb5r17); in rt2800_bw_filter_calibration()
10317 rt2800_rfcsr_write_bank(rt2x00dev, 5, 18, saverfb5r18); in rt2800_bw_filter_calibration()
10318 rt2800_rfcsr_write_bank(rt2x00dev, 5, 19, saverfb5r19); in rt2800_bw_filter_calibration()
10319 rt2800_rfcsr_write_bank(rt2x00dev, 5, 20, saverfb5r20); in rt2800_bw_filter_calibration()
10321 rt2800_rfcsr_write_bank(rt2x00dev, 5, 37, saverfb5r37); in rt2800_bw_filter_calibration()
10322 rt2800_rfcsr_write_bank(rt2x00dev, 5, 38, saverfb5r38); in rt2800_bw_filter_calibration()
10323 rt2800_rfcsr_write_bank(rt2x00dev, 5, 39, saverfb5r39); in rt2800_bw_filter_calibration()
10324 rt2800_rfcsr_write_bank(rt2x00dev, 5, 40, saverfb5r40); in rt2800_bw_filter_calibration()
10325 rt2800_rfcsr_write_bank(rt2x00dev, 5, 41, saverfb5r41); in rt2800_bw_filter_calibration()
10326 rt2800_rfcsr_write_bank(rt2x00dev, 5, 42, saverfb5r42); in rt2800_bw_filter_calibration()
10327 rt2800_rfcsr_write_bank(rt2x00dev, 5, 43, saverfb5r43); in rt2800_bw_filter_calibration()
10328 rt2800_rfcsr_write_bank(rt2x00dev, 5, 44, saverfb5r44); in rt2800_bw_filter_calibration()
10329 rt2800_rfcsr_write_bank(rt2x00dev, 5, 45, saverfb5r45); in rt2800_bw_filter_calibration()
10330 rt2800_rfcsr_write_bank(rt2x00dev, 5, 46, saverfb5r46); in rt2800_bw_filter_calibration()
10332 rt2800_rfcsr_write_bank(rt2x00dev, 5, 58, saverfb5r58); in rt2800_bw_filter_calibration()
10333 rt2800_rfcsr_write_bank(rt2x00dev, 5, 59, saverfb5r59); in rt2800_bw_filter_calibration()
10342 2 * test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)); in rt2800_bw_filter_calibration()
10479 rt2800_rfcsr_write(rt2x00dev, 5, 0x40); in rt2800_init_rfcsr_6352()
10486 rt2800_rfcsr_write(rt2x00dev, 12, rt2x00dev->freq_offset); in rt2800_init_rfcsr_6352()
10551 rt2800_rfcsr_write_chanreg(rt2x00dev, 5, 0x08); in rt2800_init_rfcsr_6352()
10673 rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00); in rt2800_init_rfcsr_6352()
10730 rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x20); in rt2800_init_rfcsr_6352()
10732 rt2800_rfcsr_write_dccal(rt2x00dev, 5, 0x00); in rt2800_init_rfcsr_6352()
10746 switch (rt2x00dev->chip.rt) { in rt2800_init_rfcsr()
10798 return -EIO; in rt2800_enable_radio()
10804 return -EIO; in rt2800_enable_radio()
10820 return -EIO; in rt2800_enable_radio()
10930 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_efuse_read()
10943 *(__le32 *)&rt2x00dev->eeprom[i] = cpu_to_le32(reg); in rt2800_efuse_read()
10945 *(__le32 *)&rt2x00dev->eeprom[i + 2] = cpu_to_le32(reg); in rt2800_efuse_read()
10947 *(__le32 *)&rt2x00dev->eeprom[i + 4] = cpu_to_le32(reg); in rt2800_efuse_read()
10949 *(__le32 *)&rt2x00dev->eeprom[i + 6] = cpu_to_le32(reg); in rt2800_efuse_read()
10951 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_efuse_read()
10997 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_validate_eeprom()
11086 drv_data->txmixer_gain_24g = rt2800_get_txmixer_gain_24g(rt2x00dev); in rt2800_validate_eeprom()
11100 drv_data->txmixer_gain_5g = rt2800_get_txmixer_gain_5g(rt2x00dev); in rt2800_validate_eeprom()
11199 return -ENODEV; in rt2800_init_eeprom()
11207 rt2x00dev->default_ant.tx_chain_num = in rt2800_init_eeprom()
11209 rt2x00dev->default_ant.rx_chain_num = in rt2800_init_eeprom()
11224 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
11225 rt2x00dev->default_ant.rx = ANTENNA_A; in rt2800_init_eeprom()
11228 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
11229 rt2x00dev->default_ant.rx = ANTENNA_B; in rt2800_init_eeprom()
11233 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
11234 rt2x00dev->default_ant.rx = ANTENNA_A; in rt2800_init_eeprom()
11240 rt2x00dev->default_ant.tx = ANTENNA_HW_DIVERSITY; /* Unused */ in rt2800_init_eeprom()
11241 rt2x00dev->default_ant.rx = ANTENNA_HW_DIVERSITY; /* Unused */ in rt2800_init_eeprom()
11248 __set_bit(CAPABILITY_EXTERNAL_LNA_A, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11250 __set_bit(CAPABILITY_EXTERNAL_LNA_BG, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11256 __set_bit(CAPABILITY_HW_BUTTON, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11259 * Detect if this device has Bluetooth co-existence. in rt2800_init_eeprom()
11263 __set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11269 rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET); in rt2800_init_eeprom()
11275 rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); in rt2800_init_eeprom()
11276 rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); in rt2800_init_eeprom()
11277 rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY); in rt2800_init_eeprom()
11279 rt2x00dev->led_mcu_reg = eeprom; in rt2800_init_eeprom()
11289 __set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11301 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11305 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11314 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11316 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11332 { 5, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
11407 {5, 243, 2, 2 },
11454 {157, 0x60, 0, 5},
11459 {169, 0x61, 0, 5},
11473 {5, 0xE6, 2, 0x14},
11490 {5, 243, 6, 2},
11535 {157, 0x60, 8, 5},
11540 {169, 0x61, 8, 5},
11551 {5, 486, 4, 10, 3},
11617 {5, 243, 2, 10, 3},
11667 {157, 96, 5, 12, 1},
11682 {5, 0x51, 0x44, 0x44, 0},
11696 struct hw_mode_spec *spec = &rt2x00dev->spec; in rt2800_probe_hw_mode()
11707 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; in rt2800_probe_hw_mode()
11713 rt2x00dev->hw->wiphy->retry_short = 2; in rt2800_probe_hw_mode()
11714 rt2x00dev->hw->wiphy->retry_long = 2; in rt2800_probe_hw_mode()
11719 ieee80211_hw_set(rt2x00dev->hw, REPORTS_TX_ACK_STATUS); in rt2800_probe_hw_mode()
11720 ieee80211_hw_set(rt2x00dev->hw, AMPDU_AGGREGATION); in rt2800_probe_hw_mode()
11721 ieee80211_hw_set(rt2x00dev->hw, PS_NULLFUNC_STACK); in rt2800_probe_hw_mode()
11722 ieee80211_hw_set(rt2x00dev->hw, SIGNAL_DBM); in rt2800_probe_hw_mode()
11723 ieee80211_hw_set(rt2x00dev->hw, SUPPORTS_PS); in rt2800_probe_hw_mode()
11733 ieee80211_hw_set(rt2x00dev->hw, HOST_BROADCAST_PS_BUFFERING); in rt2800_probe_hw_mode()
11735 ieee80211_hw_set(rt2x00dev->hw, MFP_CAPABLE); in rt2800_probe_hw_mode()
11737 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); in rt2800_probe_hw_mode()
11738 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, in rt2800_probe_hw_mode()
11751 rt2x00dev->hw->max_rates = 1; in rt2800_probe_hw_mode()
11752 rt2x00dev->hw->max_report_rates = 7; in rt2800_probe_hw_mode()
11753 rt2x00dev->hw->max_rate_tries = 1; in rt2800_probe_hw_mode()
11758 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; in rt2800_probe_hw_mode()
11760 switch (rt2x00dev->chip.rf) { in rt2800_probe_hw_mode()
11763 spec->num_channels = 14; in rt2800_probe_hw_mode()
11764 spec->channels = rf_vals; in rt2800_probe_hw_mode()
11769 spec->num_channels = ARRAY_SIZE(rf_vals); in rt2800_probe_hw_mode()
11770 spec->channels = rf_vals; in rt2800_probe_hw_mode()
11788 spec->num_channels = 14; in rt2800_probe_hw_mode()
11790 spec->channels = rf_vals_3x_xtal20; in rt2800_probe_hw_mode()
11792 spec->channels = rf_vals_3x; in rt2800_probe_hw_mode()
11796 spec->num_channels = ARRAY_SIZE(rf_vals_7620); in rt2800_probe_hw_mode()
11797 spec->channels = rf_vals_7620; in rt2800_probe_hw_mode()
11802 spec->num_channels = ARRAY_SIZE(rf_vals_3x); in rt2800_probe_hw_mode()
11803 spec->channels = rf_vals_3x; in rt2800_probe_hw_mode()
11807 spec->num_channels = ARRAY_SIZE(rf_vals_3853); in rt2800_probe_hw_mode()
11808 spec->channels = rf_vals_3853; in rt2800_probe_hw_mode()
11814 spec->num_channels = ARRAY_SIZE(rf_vals_5592_xtal40); in rt2800_probe_hw_mode()
11815 spec->channels = rf_vals_5592_xtal40; in rt2800_probe_hw_mode()
11817 spec->num_channels = ARRAY_SIZE(rf_vals_5592_xtal20); in rt2800_probe_hw_mode()
11818 spec->channels = rf_vals_5592_xtal20; in rt2800_probe_hw_mode()
11823 if (WARN_ON_ONCE(!spec->channels)) in rt2800_probe_hw_mode()
11824 return -ENODEV; in rt2800_probe_hw_mode()
11826 spec->supported_bands = SUPPORT_BAND_2GHZ; in rt2800_probe_hw_mode()
11827 if (spec->num_channels > 14) in rt2800_probe_hw_mode()
11828 spec->supported_bands |= SUPPORT_BAND_5GHZ; in rt2800_probe_hw_mode()
11834 spec->ht.ht_supported = true; in rt2800_probe_hw_mode()
11836 spec->ht.ht_supported = false; in rt2800_probe_hw_mode()
11838 spec->ht.cap = in rt2800_probe_hw_mode()
11844 tx_chains = rt2x00dev->default_ant.tx_chain_num; in rt2800_probe_hw_mode()
11845 rx_chains = rt2x00dev->default_ant.rx_chain_num; in rt2800_probe_hw_mode()
11848 spec->ht.cap |= IEEE80211_HT_CAP_TX_STBC; in rt2800_probe_hw_mode()
11850 spec->ht.cap |= rx_chains << IEEE80211_HT_CAP_RX_STBC_SHIFT; in rt2800_probe_hw_mode()
11852 spec->ht.ampdu_factor = (rx_chains > 1) ? 3 : 2; in rt2800_probe_hw_mode()
11853 spec->ht.ampdu_density = 4; in rt2800_probe_hw_mode()
11854 spec->ht.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; in rt2800_probe_hw_mode()
11856 spec->ht.mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; in rt2800_probe_hw_mode()
11857 spec->ht.mcs.tx_params |= in rt2800_probe_hw_mode()
11858 (tx_chains - 1) << IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; in rt2800_probe_hw_mode()
11863 spec->ht.mcs.rx_mask[2] = 0xff; in rt2800_probe_hw_mode()
11866 spec->ht.mcs.rx_mask[1] = 0xff; in rt2800_probe_hw_mode()
11869 spec->ht.mcs.rx_mask[0] = 0xff; in rt2800_probe_hw_mode()
11870 spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */ in rt2800_probe_hw_mode()
11877 info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); in rt2800_probe_hw_mode()
11879 return -ENOMEM; in rt2800_probe_hw_mode()
11881 rt2x00dev->chan_survey = in rt2800_probe_hw_mode()
11882 kcalloc(spec->num_channels, sizeof(struct rt2x00_chan_survey), in rt2800_probe_hw_mode()
11884 if (!rt2x00dev->chan_survey) { in rt2800_probe_hw_mode()
11886 return -ENOMEM; in rt2800_probe_hw_mode()
11889 spec->channels_info = info; in rt2800_probe_hw_mode()
11894 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_probe_hw_mode()
11907 if (spec->num_channels > 14) { in rt2800_probe_hw_mode()
11913 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_probe_hw_mode()
11920 for (i = 14; i < spec->num_channels; i++) { in rt2800_probe_hw_mode()
11921 info[i].default_power1 = default_power1[i - 14]; in rt2800_probe_hw_mode()
11922 info[i].default_power2 = default_power2[i - 14]; in rt2800_probe_hw_mode()
11924 info[i].default_power3 = default_power3[i - 14]; in rt2800_probe_hw_mode()
11928 switch (rt2x00dev->chip.rf) { in rt2800_probe_hw_mode()
11948 __set_bit(CAPABILITY_VCO_RECALIBRATION, &rt2x00dev->cap_flags); in rt2800_probe_hw_mode()
11990 return -ENODEV; in rt2800_probe_rt()
12039 __set_bit(CAPABILITY_CONTROL_FILTERS, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12040 __set_bit(CAPABILITY_CONTROL_FILTER_PSPOLL, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12042 __set_bit(CAPABILITY_PRE_TBTT_INTERRUPT, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12048 __set_bit(REQUIRE_FIRMWARE, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12049 __set_bit(REQUIRE_L2PAD, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12050 __set_bit(REQUIRE_TXSTATUS_FIFO, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12052 __set_bit(CAPABILITY_HW_CRYPTO, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12053 __set_bit(CAPABILITY_LINK_TUNING, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12054 __set_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12056 __set_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12058 __set_bit(REQUIRE_DMA, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12059 __set_bit(REQUIRE_TASKLET_CONTEXT, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12062 rt2x00dev->link.watchdog = modparam_watchdog; in rt2800_probe_hw()
12065 rt2x00dev->link.watchdog &= ~RT2800_WATCHDOG_DMA_BUSY; in rt2800_probe_hw()
12066 if (rt2x00dev->link.watchdog) { in rt2800_probe_hw()
12067 __set_bit(CAPABILITY_RESTART_HW, &rt2x00dev->cap_flags); in rt2800_probe_hw()
12068 rt2x00dev->link.watchdog_interval = msecs_to_jiffies(100); in rt2800_probe_hw()
12074 rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET; in rt2800_probe_hw()
12087 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_key_seq()
12091 if (key->cipher != WLAN_CIPHER_SUITE_TKIP) in rt2800_get_key_seq()
12094 offset = MAC_IVEIV_ENTRY(key->hw_key_idx); in rt2800_get_key_seq()
12098 memcpy(&seq->tkip.iv16, &iveiv_entry.iv[0], 2); in rt2800_get_key_seq()
12099 memcpy(&seq->tkip.iv32, &iveiv_entry.iv[4], 4); in rt2800_get_key_seq()
12105 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_set_rts_threshold()
12146 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_conf_tx()
12178 rt2x00_set_field32(®, field, queue->txop); in rt2800_conf_tx()
12186 rt2x00_set_field32(®, field, queue->aifs); in rt2800_conf_tx()
12190 rt2x00_set_field32(®, field, queue->cw_min); in rt2800_conf_tx()
12194 rt2x00_set_field32(®, field, queue->cw_max); in rt2800_conf_tx()
12201 rt2x00_set_field32(®, EDCA_AC0_CFG_TX_OP, queue->txop); in rt2800_conf_tx()
12202 rt2x00_set_field32(®, EDCA_AC0_CFG_AIFSN, queue->aifs); in rt2800_conf_tx()
12203 rt2x00_set_field32(®, EDCA_AC0_CFG_CWMIN, queue->cw_min); in rt2800_conf_tx()
12204 rt2x00_set_field32(®, EDCA_AC0_CFG_CWMAX, queue->cw_max); in rt2800_conf_tx()
12213 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_tsf()
12229 struct ieee80211_sta *sta = params->sta; in rt2800_ampdu_action()
12230 enum ieee80211_ampdu_mlme_action action = params->action; in rt2800_ampdu_action()
12231 u16 tid = params->tid; in rt2800_ampdu_action()
12232 struct rt2x00_sta *sta_priv = (struct rt2x00_sta *)sta->drv_priv; in rt2800_ampdu_action()
12242 if (sta_priv->wcid > WCID_END) in rt2800_ampdu_action()
12243 return -ENOSPC; in rt2800_ampdu_action()
12261 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in rt2800_ampdu_action()
12266 rt2x00_warn((struct rt2x00_dev *)hw->priv, in rt2800_ampdu_action()
12277 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_survey()
12279 &rt2x00dev->chan_survey[idx]; in rt2800_get_survey()
12282 if (idx >= rt2x00dev->bands[band].n_channels) { in rt2800_get_survey()
12283 idx -= rt2x00dev->bands[band].n_channels; in rt2800_get_survey()
12287 if (idx >= rt2x00dev->bands[band].n_channels) in rt2800_get_survey()
12288 return -ENOENT; in rt2800_get_survey()
12293 survey->channel = &rt2x00dev->bands[band].channels[idx]; in rt2800_get_survey()
12295 survey->filled = SURVEY_INFO_TIME | in rt2800_get_survey()
12299 survey->time = div_u64(chan_survey->time_idle + chan_survey->time_busy, 1000); in rt2800_get_survey()
12300 survey->time_busy = div_u64(chan_survey->time_busy, 1000); in rt2800_get_survey()
12301 survey->time_ext_busy = div_u64(chan_survey->time_ext_busy, 1000); in rt2800_get_survey()
12303 if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) in rt2800_get_survey()
12304 survey->filled |= SURVEY_INFO_IN_USE; in rt2800_get_survey()