Lines Matching +full:txpower +full:-

1 // SPDX-License-Identifier: GPL-2.0-or-later
24 #include <linux/crc-ccitt.h>
86 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_bbp_write()
103 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_bbp_write()
111 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_bbp_read()
135 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_bbp_read()
145 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_write()
151 switch (rt2x00dev->chip.rt) { in rt2800_rfcsr_write()
178 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_write()
227 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_read()
237 switch (rt2x00dev->chip.rt) { in rt2800_rfcsr_read()
270 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_rfcsr_read()
286 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_rf_write()
303 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_rf_write()
394 wiphy_name(rt2x00dev->hw->wiphy), word)) in rt2800_eeprom_word_index()
413 wiphy_name(rt2x00dev->hw->wiphy), word); in rt2800_eeprom_word_index()
485 return -EIO; in rt2800_enable_wlan_rt3290()
525 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_mcu_request()
543 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_mcu_request()
560 return -EBUSY; in rt2800_wait_csr_ready()
583 return -EACCES; in rt2800_wait_wpdma_ready()
605 switch (rt2x00dev->chip.rt) { in rt2800_get_txwi_rxwi_size()
636 fw_crc = (data[len - 2] << 8 | data[len - 1]); in rt2800_check_firmware_crc()
645 crc = crc_ccitt(~0, data, len - 2); in rt2800_check_firmware_crc()
648 * There is a small difference between the crc-itu-t + bitrev and in rt2800_check_firmware_crc()
649 * the crc-ccitt crc calculation. In the latter method the 2 bytes in rt2800_check_firmware_crc()
722 return -EBUSY; in rt2800_load_firmware()
735 return -EBUSY; in rt2800_load_firmware()
769 return -EBUSY; in rt2800_load_firmware()
805 test_bit(ENTRY_TXD_MORE_FRAG, &txdesc->flags)); in rt2800_write_tx_data()
807 test_bit(ENTRY_TXD_HT_MIMO_PS, &txdesc->flags)); in rt2800_write_tx_data()
810 test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags)); in rt2800_write_tx_data()
812 test_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags)); in rt2800_write_tx_data()
814 txdesc->u.ht.mpdu_density); in rt2800_write_tx_data()
815 rt2x00_set_field32(&word, TXWI_W0_TX_OP, txdesc->u.ht.txop); in rt2800_write_tx_data()
816 rt2x00_set_field32(&word, TXWI_W0_MCS, txdesc->u.ht.mcs); in rt2800_write_tx_data()
818 test_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags)); in rt2800_write_tx_data()
820 test_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags)); in rt2800_write_tx_data()
821 rt2x00_set_field32(&word, TXWI_W0_STBC, txdesc->u.ht.stbc); in rt2800_write_tx_data()
822 rt2x00_set_field32(&word, TXWI_W0_PHYMODE, txdesc->rate_mode); in rt2800_write_tx_data()
827 test_bit(ENTRY_TXD_ACK, &txdesc->flags)); in rt2800_write_tx_data()
829 test_bit(ENTRY_TXD_GENERATE_SEQ, &txdesc->flags)); in rt2800_write_tx_data()
830 rt2x00_set_field32(&word, TXWI_W1_BW_WIN_SIZE, txdesc->u.ht.ba_size); in rt2800_write_tx_data()
832 test_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags) ? in rt2800_write_tx_data()
833 txdesc->key_idx : txdesc->u.ht.wcid); in rt2800_write_tx_data()
835 txdesc->length); in rt2800_write_tx_data()
836 rt2x00_set_field32(&word, TXWI_W1_PACKETID_QUEUE, entry->queue->qid); in rt2800_write_tx_data()
837 rt2x00_set_field32(&word, TXWI_W1_PACKETID_ENTRY, (entry->entry_idx % 3) + 1); in rt2800_write_tx_data()
849 for (i = 2; i < entry->queue->winfo_size / sizeof(__le32); i++) in rt2800_write_tx_data()
864 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_agc_to_rssi()
883 rssi0 = (rssi0) ? (-12 - offset0 - rt2x00dev->lna_gain - rssi0) : -128; in rt2800_agc_to_rssi()
884 rssi1 = (rssi1) ? (-12 - offset1 - rt2x00dev->lna_gain - rssi1) : -128; in rt2800_agc_to_rssi()
885 rssi2 = (rssi2) ? (-12 - offset2 - rt2x00dev->lna_gain - rssi2) : -128; in rt2800_agc_to_rssi()
889 * average doesn't deliver a fair answer either since -60:-60 would in rt2800_agc_to_rssi()
890 * be considered equally good as -50:-70 while the second is the one in rt2800_agc_to_rssi()
900 __le32 *rxwi = (__le32 *) entry->skb->data; in rt2800_process_rxwi()
905 rxdesc->cipher = rt2x00_get_field32(word, RXWI_W0_UDF); in rt2800_process_rxwi()
906 rxdesc->size = rt2x00_get_field32(word, RXWI_W0_MPDU_TOTAL_BYTE_COUNT); in rt2800_process_rxwi()
911 rxdesc->enc_flags |= RX_ENC_FLAG_SHORT_GI; in rt2800_process_rxwi()
914 rxdesc->bw = RATE_INFO_BW_40; in rt2800_process_rxwi()
919 rxdesc->dev_flags |= RXDONE_SIGNAL_MCS; in rt2800_process_rxwi()
920 rxdesc->signal = rt2x00_get_field32(word, RXWI_W1_MCS); in rt2800_process_rxwi()
921 rxdesc->rate_mode = rt2x00_get_field32(word, RXWI_W1_PHYMODE); in rt2800_process_rxwi()
926 if (rxdesc->rate_mode == RATE_MODE_CCK) in rt2800_process_rxwi()
927 rxdesc->signal &= ~0x8; in rt2800_process_rxwi()
934 rxdesc->rssi = rt2800_agc_to_rssi(entry->queue->rt2x00dev, word); in rt2800_process_rxwi()
938 skb_pull(entry->skb, entry->queue->winfo_size); in rt2800_process_rxwi()
961 idx -= 8; in rt2800_rate_from_status()
971 skbdesc->tx_rate_idx = idx; in rt2800_rate_from_status()
972 skbdesc->tx_rate_flags = flags; in rt2800_rate_from_status()
987 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags)) in rt2800_txdone_entry_check()
1007 rt2x00_dbg(entry->queue->rt2x00dev, in rt2800_txdone_entry_check()
1009 entry->queue->qid, entry->entry_idx); in rt2800_txdone_entry_check()
1019 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2800_txdone_entry()
1020 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_txdone_entry()
1021 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); in rt2800_txdone_entry()
1042 * If a frame was meant to be sent as a single non-aggregated MPDU in rt2800_txdone_entry()
1062 rt2800_rate_from_status(skbdesc, status, rt2x00dev->curr_band); in rt2800_txdone_entry()
1082 * mcs - real_mcs in rt2800_txdone_entry()
1085 txdesc.retry = ((mcs > real_mcs) ? mcs - real_mcs : 0); in rt2800_txdone_entry()
1093 txdesc.retry = rt2x00dev->long_retry; in rt2800_txdone_entry()
1098 * -> hw used fallback rates in rt2800_txdone_entry()
1104 /* RCU assures non-null sta will not be freed by mac80211. */ in rt2800_txdone_entry()
1107 skbdesc->sta = drv_data->wcid_to_sta[wcid - WCID_START]; in rt2800_txdone_entry()
1109 skbdesc->sta = NULL; in rt2800_txdone_entry()
1126 while (quota-- > 0 && kfifo_get(&rt2x00dev->txstatus_fifo, &reg)) { in rt2800_txdone()
1128 * TX_STA_FIFO_PID_QUEUE is a 2-bit field, thus qid is in rt2800_txdone()
1142 if (unlikely(test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || in rt2800_txdone()
1143 !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags))) { in rt2800_txdone()
1145 entry->entry_idx, qid); in rt2800_txdone()
1161 if (!test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) in rt2800_entry_txstatus_timeout()
1164 if (test_bit(DEVICE_STATE_FLUSHING, &rt2x00dev->flags)) in rt2800_entry_txstatus_timeout()
1169 ret = time_after(jiffies, entry->last_action + tout); in rt2800_entry_txstatus_timeout()
1171 rt2x00_dbg(entry->queue->rt2x00dev, in rt2800_entry_txstatus_timeout()
1173 entry->entry_idx, entry->queue->qid); in rt2800_entry_txstatus_timeout()
1216 * we loop until we find the first non-IO error entry. This in rt2800_txdone_nostatus()
1225 if (test_bit(ENTRY_OWNER_DEVICE_DATA, &entry->flags) || in rt2800_txdone_nostatus()
1226 !test_bit(ENTRY_DATA_STATUS_PENDING, &entry->flags)) in rt2800_txdone_nostatus()
1229 if (test_bit(ENTRY_DATA_IO_FAILED, &entry->flags) || in rt2800_txdone_nostatus()
1243 if (queue->wd_idx != cur_idx) in rt2800_check_hung()
1244 queue->wd_count = 0; in rt2800_check_hung()
1246 queue->wd_count++; in rt2800_check_hung()
1248 return queue->wd_count > 16; in rt2800_check_hung()
1253 struct ieee80211_channel *chan = rt2x00dev->hw->conf.chandef.chan; in rt2800_update_survey()
1255 &rt2x00dev->chan_survey[chan->hw_value]; in rt2800_update_survey()
1257 chan_survey->time_idle += rt2800_register_read(rt2x00dev, CH_IDLE_STA); in rt2800_update_survey()
1258 chan_survey->time_busy += rt2800_register_read(rt2x00dev, CH_BUSY_STA); in rt2800_update_survey()
1259 chan_survey->time_ext_busy += rt2800_register_read(rt2x00dev, CH_BUSY_STA_SEC); in rt2800_update_survey()
1268 if (test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) in rt2800_watchdog()
1274 switch (queue->qid) { in rt2800_watchdog()
1289 if (rt2x00dev->intf_sta_count == 0) in rt2800_watchdog()
1305 ieee80211_restart_hw(rt2x00dev->hw); in rt2800_watchdog()
1323 struct data_queue *queue = rt2x00dev->bcn; in rt2800_update_beacons_setup()
1332 for (i = 0; i < queue->limit; i++) { in rt2800_update_beacons_setup()
1333 entry = &queue->entries[i]; in rt2800_update_beacons_setup()
1334 if (!test_bit(ENTRY_BCN_ENABLED, &entry->flags)) in rt2800_update_beacons_setup()
1336 off = rt2800_get_beacon_offset(rt2x00dev, entry->entry_idx); in rt2800_update_beacons_setup()
1349 bcn_num > 0 ? bcn_num - 1 : 0); in rt2800_update_beacons_setup()
1355 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2800_write_beacon()
1356 struct skb_frame_desc *skbdesc = get_skb_frame_desc(entry->skb); in rt2800_write_beacon()
1360 const int txwi_desc_size = entry->queue->winfo_size; in rt2800_write_beacon()
1374 memset(skb_push(entry->skb, txwi_desc_size), 0, txwi_desc_size); in rt2800_write_beacon()
1379 skbdesc->flags |= SKBDESC_DESC_IN_SKB; in rt2800_write_beacon()
1380 skbdesc->desc = entry->skb->data; in rt2800_write_beacon()
1381 skbdesc->desc_len = txwi_desc_size; in rt2800_write_beacon()
1396 padding_len = roundup(entry->skb->len, 4) - entry->skb->len; in rt2800_write_beacon()
1397 if (padding_len && skb_pad(entry->skb, padding_len)) { in rt2800_write_beacon()
1400 entry->skb = NULL; in rt2800_write_beacon()
1405 beacon_base = rt2800_hw_beacon_base(rt2x00dev, entry->entry_idx); in rt2800_write_beacon()
1407 rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data, in rt2800_write_beacon()
1408 entry->skb->len + padding_len); in rt2800_write_beacon()
1409 __set_bit(ENTRY_BCN_ENABLED, &entry->flags); in rt2800_write_beacon()
1424 dev_kfree_skb_any(entry->skb); in rt2800_write_beacon()
1425 entry->skb = NULL; in rt2800_write_beacon()
1433 const int txwi_desc_size = rt2x00dev->bcn->winfo_size; in rt2800_clear_beacon_register()
1449 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev; in rt2800_clear_beacon()
1464 rt2800_clear_beacon_register(rt2x00dev, entry->entry_idx); in rt2800_clear_beacon()
1465 __clear_bit(ENTRY_BCN_ENABLED, &entry->flags); in rt2800_clear_beacon()
1546 (enabled && led->rt2x00dev->curr_band == NL80211_BAND_2GHZ); in rt2800_brightness_set()
1548 rt2x00_get_field16(led->rt2x00dev->led_mcu_reg, in rt2800_brightness_set()
1551 rt2x00_get_field16(led->rt2x00dev->led_mcu_reg, in rt2800_brightness_set()
1556 if (rt2x00_is_soc(led->rt2x00dev)) { in rt2800_brightness_set()
1557 reg = rt2800_register_read(led->rt2x00dev, LED_CFG); in rt2800_brightness_set()
1563 if (led->type == LED_TYPE_RADIO) { in rt2800_brightness_set()
1566 } else if (led->type == LED_TYPE_ASSOC) { in rt2800_brightness_set()
1569 } else if (led->type == LED_TYPE_QUALITY) { in rt2800_brightness_set()
1574 rt2800_register_write(led->rt2x00dev, LED_CFG, reg); in rt2800_brightness_set()
1577 if (led->type == LED_TYPE_RADIO) { in rt2800_brightness_set()
1578 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode, in rt2800_brightness_set()
1580 } else if (led->type == LED_TYPE_ASSOC) { in rt2800_brightness_set()
1581 rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode, in rt2800_brightness_set()
1583 } else if (led->type == LED_TYPE_QUALITY) { in rt2800_brightness_set()
1585 * The brightness is divided into 6 levels (0 - 5), in rt2800_brightness_set()
1590 * (1 << level) - 1 in rt2800_brightness_set()
1592 rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff, in rt2800_brightness_set()
1593 (1 << brightness / (LED_FULL / 6)) - 1, in rt2800_brightness_set()
1602 led->rt2x00dev = rt2x00dev; in rt2800_init_led()
1603 led->type = type; in rt2800_init_led()
1604 led->led_dev.brightness_set = rt2800_brightness_set; in rt2800_init_led()
1605 led->flags = LED_INITIALIZED; in rt2800_init_led()
1661 offset = MAC_WCID_ATTR_ENTRY(key->hw_key_idx); in rt2800_config_wcid_attr_cipher()
1663 if (crypto->cmd == SET_KEY) { in rt2800_config_wcid_attr_cipher()
1666 !!(key->flags & IEEE80211_KEY_FLAG_PAIRWISE)); in rt2800_config_wcid_attr_cipher()
1673 (crypto->cipher & 0x7)); in rt2800_config_wcid_attr_cipher()
1675 (crypto->cipher & 0x8) >> 3); in rt2800_config_wcid_attr_cipher()
1676 rt2x00_set_field32(&reg, MAC_WCID_ATTRIBUTE_RX_WIUDF, crypto->cipher); in rt2800_config_wcid_attr_cipher()
1688 if (test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags)) in rt2800_config_wcid_attr_cipher()
1691 offset = MAC_IVEIV_ENTRY(key->hw_key_idx); in rt2800_config_wcid_attr_cipher()
1694 if ((crypto->cipher == CIPHER_TKIP) || in rt2800_config_wcid_attr_cipher()
1695 (crypto->cipher == CIPHER_TKIP_NO_MIC) || in rt2800_config_wcid_attr_cipher()
1696 (crypto->cipher == CIPHER_AES)) in rt2800_config_wcid_attr_cipher()
1698 iveiv_entry.iv[3] |= key->keyidx << 6; in rt2800_config_wcid_attr_cipher()
1712 if (crypto->cmd == SET_KEY) { in rt2800_config_shared_key()
1713 key->hw_key_idx = (4 * crypto->bssidx) + key->keyidx; in rt2800_config_shared_key()
1715 memcpy(key_entry.key, crypto->key, in rt2800_config_shared_key()
1717 memcpy(key_entry.tx_mic, crypto->tx_mic, in rt2800_config_shared_key()
1719 memcpy(key_entry.rx_mic, crypto->rx_mic, in rt2800_config_shared_key()
1722 offset = SHARED_KEY_ENTRY(key->hw_key_idx); in rt2800_config_shared_key()
1734 field.bit_offset = 4 * (key->hw_key_idx % 8); in rt2800_config_shared_key()
1737 offset = SHARED_KEY_MODE_ENTRY(key->hw_key_idx / 8); in rt2800_config_shared_key()
1741 (crypto->cmd == SET_KEY) * crypto->cipher); in rt2800_config_shared_key()
1747 rt2800_config_wcid(rt2x00dev, crypto->address, key->hw_key_idx); in rt2800_config_shared_key()
1748 rt2800_config_wcid_attr_bssidx(rt2x00dev, key->hw_key_idx, in rt2800_config_shared_key()
1749 crypto->bssidx); in rt2800_config_shared_key()
1763 if (crypto->cmd == SET_KEY) { in rt2800_config_pairwise_key()
1768 if (crypto->wcid > WCID_END) in rt2800_config_pairwise_key()
1769 return -ENOSPC; in rt2800_config_pairwise_key()
1770 key->hw_key_idx = crypto->wcid; in rt2800_config_pairwise_key()
1772 memcpy(key_entry.key, crypto->key, in rt2800_config_pairwise_key()
1774 memcpy(key_entry.tx_mic, crypto->tx_mic, in rt2800_config_pairwise_key()
1776 memcpy(key_entry.rx_mic, crypto->rx_mic, in rt2800_config_pairwise_key()
1779 offset = PAIRWISE_KEY_ENTRY(key->hw_key_idx); in rt2800_config_pairwise_key()
1797 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_set_max_psdu_len()
1800 if (drv_data->ampdu_factor_cnt[i] > 0) in rt2800_set_max_psdu_len()
1803 max_psdu = min(drv_data->max_psdu, i); in rt2800_set_max_psdu_len()
1813 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_sta_add()
1814 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_sta_add()
1824 if (sta->deflink.ht_cap.ht_supported) { in rt2800_sta_add()
1825 drv_data->ampdu_factor_cnt[sta->deflink.ht_cap.ampdu_factor & 3]++; in rt2800_sta_add()
1833 wcid = find_first_zero_bit(drv_data->sta_ids, STA_IDS_SIZE) + WCID_START; in rt2800_sta_add()
1839 sta_priv->wcid = wcid; in rt2800_sta_add()
1843 * with the STA -> No error. in rt2800_sta_add()
1848 __set_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_sta_add()
1849 drv_data->wcid_to_sta[wcid - WCID_START] = sta; in rt2800_sta_add()
1855 rt2800_config_wcid(rt2x00dev, sta->addr, wcid); in rt2800_sta_add()
1865 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_sta_remove()
1866 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_sta_remove()
1868 int wcid = sta_priv->wcid; in rt2800_sta_remove()
1870 if (sta->deflink.ht_cap.ht_supported) { in rt2800_sta_remove()
1871 drv_data->ampdu_factor_cnt[sta->deflink.ht_cap.ampdu_factor & 3]--; in rt2800_sta_remove()
1882 drv_data->wcid_to_sta[wcid - WCID_START] = NULL; in rt2800_sta_remove()
1883 __clear_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_sta_remove()
1891 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_pre_reset_hw()
1892 struct data_queue *queue = rt2x00dev->bcn; in rt2800_pre_reset_hw()
1897 drv_data->wcid_to_sta[wcid - WCID_START] = NULL; in rt2800_pre_reset_hw()
1898 __clear_bit(wcid - WCID_START, drv_data->sta_ids); in rt2800_pre_reset_hw()
1901 for (i = 0; i < queue->limit; i++) { in rt2800_pre_reset_hw()
1902 entry = &queue->entries[i]; in rt2800_pre_reset_hw()
1903 clear_bit(ENTRY_BCN_ASSIGNED, &entry->flags); in rt2800_pre_reset_hw()
1925 !test_bit(CONFIG_MONITORING, &rt2x00dev->flags)); in rt2800_config_filter()
1964 rt2x00_set_field32(&reg, BCN_TIME_CFG_TSF_SYNC, conf->sync); in rt2800_config_intf()
1967 if (conf->sync == TSF_SYNC_AP_NONE) { in rt2800_config_intf()
1989 conf->sync == TSF_SYNC_AP_NONE) { in rt2800_config_intf()
1994 memcpy(conf->bssid, conf->mac, sizeof(conf->mac)); in rt2800_config_intf()
1998 if (!is_zero_ether_addr((const u8 *)conf->mac)) { in rt2800_config_intf()
1999 reg = le32_to_cpu(conf->mac[1]); in rt2800_config_intf()
2001 conf->mac[1] = cpu_to_le32(reg); in rt2800_config_intf()
2005 conf->mac, sizeof(conf->mac)); in rt2800_config_intf()
2009 if (!is_zero_ether_addr((const u8 *)conf->bssid)) { in rt2800_config_intf()
2010 reg = le32_to_cpu(conf->bssid[1]); in rt2800_config_intf()
2013 conf->bssid[1] = cpu_to_le32(reg); in rt2800_config_intf()
2017 conf->bssid, sizeof(conf->bssid)); in rt2800_config_intf()
2025 bool any_sta_nongf = !!(erp->ht_opmode & in rt2800_config_ht_opmode()
2027 u8 protection = erp->ht_opmode & IEEE80211_HT_OP_MODE_PROTECTION; in rt2800_config_ht_opmode()
2071 * -> fall through to mixed mode. in rt2800_config_ht_opmode()
2084 if (erp->cts_protection) { in rt2800_config_ht_opmode()
2126 !!erp->short_preamble); in rt2800_config_erp()
2133 erp->cts_protection ? 2 : 0); in rt2800_config_erp()
2139 0xff0 | erp->basic_rates); in rt2800_config_erp()
2146 erp->slot_time); in rt2800_config_erp()
2150 rt2x00_set_field32(&reg, XIFS_TIME_CFG_EIFS, erp->eifs); in rt2800_config_erp()
2157 erp->beacon_int * 16); in rt2800_config_erp()
2181 return -EACCES; in rt2800_wait_bbp_rf_ready()
2205 return -EACCES; in rt2800_wait_bbp_ready()
2215 if (rt2x00dev->curr_band == NL80211_BAND_5GHZ) { in rt2800_config_3572bt_ant()
2279 switch (ant->tx_chain_num) { in rt2800_config_ant()
2298 switch (ant->rx_chain_num) { in rt2800_config_ant()
2309 rt2x00dev->default_ant.rx); in rt2800_config_ant()
2318 rt2x00dev->curr_band == NL80211_BAND_5GHZ); in rt2800_config_ant()
2334 if (ant->rx_chain_num == 1) in rt2800_config_ant()
2348 if (libconf->rf.channel <= 14) { in rt2800_config_lna_gain()
2351 } else if (libconf->rf.channel <= 64) { in rt2800_config_lna_gain()
2354 } else if (libconf->rf.channel <= 128) { in rt2800_config_lna_gain()
2378 rt2x00dev->lna_gain = lna_gain; in rt2800_config_lna_gain()
2383 return clk_get_rate(rt2x00dev->clk) == 20000000; in rt2800_clk_is_20mhz()
2393 freq_offset = rt2x00_get_field8(rt2x00dev->freq_offset, RFCSR17_CODE); in rt2800_freq_cal_mode1()
2414 prev_freq_offset--; in rt2800_freq_cal_mode1()
2428 rt2x00_set_field32(&rf->rf4, RF4_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf2xxx()
2430 if (rt2x00dev->default_ant.tx_chain_num == 1) in rt2800_config_channel_rf2xxx()
2431 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_TX1, 1); in rt2800_config_channel_rf2xxx()
2433 if (rt2x00dev->default_ant.rx_chain_num == 1) { in rt2800_config_channel_rf2xxx()
2434 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX1, 1); in rt2800_config_channel_rf2xxx()
2435 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1); in rt2800_config_channel_rf2xxx()
2436 } else if (rt2x00dev->default_ant.rx_chain_num == 2) in rt2800_config_channel_rf2xxx()
2437 rt2x00_set_field32(&rf->rf2, RF2_ANTENNA_RX2, 1); in rt2800_config_channel_rf2xxx()
2439 if (rf->channel > 14) { in rt2800_config_channel_rf2xxx()
2442 * make it a positive value (Minimum value is -7). in rt2800_config_channel_rf2xxx()
2446 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A_7DBM_BOOST, in rt2800_config_channel_rf2xxx()
2447 (info->default_power1 >= 0)); in rt2800_config_channel_rf2xxx()
2449 if (info->default_power1 < 0) in rt2800_config_channel_rf2xxx()
2450 info->default_power1 += 7; in rt2800_config_channel_rf2xxx()
2452 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_A, info->default_power1); in rt2800_config_channel_rf2xxx()
2454 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A_7DBM_BOOST, in rt2800_config_channel_rf2xxx()
2455 (info->default_power2 >= 0)); in rt2800_config_channel_rf2xxx()
2457 if (info->default_power2 < 0) in rt2800_config_channel_rf2xxx()
2458 info->default_power2 += 7; in rt2800_config_channel_rf2xxx()
2460 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_A, info->default_power2); in rt2800_config_channel_rf2xxx()
2462 rt2x00_set_field32(&rf->rf3, RF3_TXPOWER_G, info->default_power1); in rt2800_config_channel_rf2xxx()
2463 rt2x00_set_field32(&rf->rf4, RF4_TXPOWER_G, info->default_power2); in rt2800_config_channel_rf2xxx()
2466 rt2x00_set_field32(&rf->rf4, RF4_HT40, conf_is_ht40(conf)); in rt2800_config_channel_rf2xxx()
2468 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2469 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2470 rt2800_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004); in rt2800_config_channel_rf2xxx()
2471 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2475 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2476 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2477 rt2800_rf_write(rt2x00dev, 3, rf->rf3 | 0x00000004); in rt2800_config_channel_rf2xxx()
2478 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2482 rt2800_rf_write(rt2x00dev, 1, rf->rf1); in rt2800_config_channel_rf2xxx()
2483 rt2800_rf_write(rt2x00dev, 2, rf->rf2); in rt2800_config_channel_rf2xxx()
2484 rt2800_rf_write(rt2x00dev, 3, rf->rf3 & ~0x00000004); in rt2800_config_channel_rf2xxx()
2485 rt2800_rf_write(rt2x00dev, 4, rf->rf4); in rt2800_config_channel_rf2xxx()
2493 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3xxx()
2496 rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); in rt2800_config_channel_rf3xxx()
2499 rt2x00_set_field8(&rfcsr, RFCSR3_K, rf->rf3); in rt2800_config_channel_rf3xxx()
2503 rt2x00_set_field8(&rfcsr, RFCSR6_R1, rf->rf2); in rt2800_config_channel_rf3xxx()
2507 rt2x00_set_field8(&rfcsr, RFCSR12_TX_POWER, info->default_power1); in rt2800_config_channel_rf3xxx()
2511 rt2x00_set_field8(&rfcsr, RFCSR13_TX_POWER, info->default_power2); in rt2800_config_channel_rf3xxx()
2517 rt2x00dev->default_ant.rx_chain_num <= 1); in rt2800_config_channel_rf3xxx()
2519 rt2x00dev->default_ant.rx_chain_num <= 2); in rt2800_config_channel_rf3xxx()
2522 rt2x00dev->default_ant.tx_chain_num <= 1); in rt2800_config_channel_rf3xxx()
2524 rt2x00dev->default_ant.tx_chain_num <= 2); in rt2800_config_channel_rf3xxx()
2528 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf3xxx()
2536 calib_tx = drv_data->calibration_bw40; in rt2800_config_channel_rf3xxx()
2537 calib_rx = drv_data->calibration_bw40; in rt2800_config_channel_rf3xxx()
2539 calib_tx = drv_data->calibration_bw20; in rt2800_config_channel_rf3xxx()
2540 calib_rx = drv_data->calibration_bw20; in rt2800_config_channel_rf3xxx()
2571 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3052()
2575 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2576 rt2800_bbp_write(rt2x00dev, 25, drv_data->bbp25); in rt2800_config_channel_rf3052()
2577 rt2800_bbp_write(rt2x00dev, 26, drv_data->bbp26); in rt2800_config_channel_rf3052()
2583 rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); in rt2800_config_channel_rf3052()
2584 rt2800_rfcsr_write(rt2x00dev, 3, rf->rf3); in rt2800_config_channel_rf3052()
2587 rt2x00_set_field8(&rfcsr, RFCSR6_R1, rf->rf2); in rt2800_config_channel_rf3052()
2588 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2595 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2602 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2605 info->default_power1); in rt2800_config_channel_rf3052()
2609 (info->default_power1 & 0x3) | in rt2800_config_channel_rf3052()
2610 ((info->default_power1 & 0xC) << 1)); in rt2800_config_channel_rf3052()
2615 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2618 info->default_power2); in rt2800_config_channel_rf3052()
2622 (info->default_power2 & 0x3) | in rt2800_config_channel_rf3052()
2623 ((info->default_power2 & 0xC) << 1)); in rt2800_config_channel_rf3052()
2635 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2642 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3052()
2651 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3052()
2663 rt2x00_set_field8(&rfcsr, RFCSR23_FREQ_OFFSET, rt2x00dev->freq_offset); in rt2800_config_channel_rf3052()
2667 rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw40); in rt2800_config_channel_rf3052()
2668 rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw40); in rt2800_config_channel_rf3052()
2670 rt2800_rfcsr_write(rt2x00dev, 24, drv_data->calibration_bw20); in rt2800_config_channel_rf3052()
2671 rt2800_rfcsr_write(rt2x00dev, 31, drv_data->calibration_bw20); in rt2800_config_channel_rf3052()
2674 if (rf->channel <= 14) { in rt2800_config_channel_rf3052()
2682 drv_data->txmixer_gain_24g); in rt2800_config_channel_rf3052()
2704 drv_data->txmixer_gain_5g); in rt2800_config_channel_rf3052()
2707 if (rf->channel <= 64) { in rt2800_config_channel_rf3052()
2711 } else if (rf->channel <= 128) { in rt2800_config_channel_rf3052()
2727 if (rf->channel <= 14) in rt2800_config_channel_rf3052()
2743 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf3053()
2760 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2762 rt2800_bbp_write(rt2x00dev, 25, drv_data->bbp25); in rt2800_config_channel_rf3053()
2763 rt2800_bbp_write(rt2x00dev, 26, drv_data->bbp26); in rt2800_config_channel_rf3053()
2773 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3053()
2774 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3 & 0xf); in rt2800_config_channel_rf3053()
2777 rt2x00_set_field8(&rfcsr, RFCSR11_R, (rf->rf2 & 0x3)); in rt2800_config_channel_rf3053()
2782 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2789 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2792 info->default_power1 & 0x1f); in rt2800_config_channel_rf3053()
2798 ((info->default_power1 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2799 (info->default_power1 & 7)); in rt2800_config_channel_rf3053()
2804 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2807 info->default_power2 & 0x1f); in rt2800_config_channel_rf3053()
2813 ((info->default_power2 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2814 (info->default_power2 & 7)); in rt2800_config_channel_rf3053()
2819 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2822 info->default_power3 & 0x1f); in rt2800_config_channel_rf3053()
2828 ((info->default_power3 & 0x18) << 1) | in rt2800_config_channel_rf3053()
2829 (info->default_power3 & 7)); in rt2800_config_channel_rf3053()
2843 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3053()
2855 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3053()
2871 txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw40, in rt2800_config_channel_rf3053()
2873 txrx_h20m = rt2x00_get_field8(drv_data->calibration_bw40, in rt2800_config_channel_rf3053()
2876 txrx_agc_fc = rt2x00_get_field8(drv_data->calibration_bw20, in rt2800_config_channel_rf3053()
2878 txrx_h20m = rt2x00_get_field8(drv_data->calibration_bw20, in rt2800_config_channel_rf3053()
2888 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2901 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2908 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2915 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2922 if (rf->channel >= 1 && rf->channel <= 14) in rt2800_config_channel_rf3053()
2924 else if (rf->channel >= 36 && rf->channel <= 64) in rt2800_config_channel_rf3053()
2926 else if (rf->channel >= 100 && rf->channel <= 128) in rt2800_config_channel_rf3053()
2938 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2951 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2961 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2976 if (rf->channel <= 14) in rt2800_config_channel_rf3053()
2982 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
2992 if (rf->channel <= 14) { in rt2800_config_channel_rf3053()
3004 if (rf->channel >= 1 && rf->channel <= 14) { in rt2800_config_channel_rf3053()
3011 } else if (rf->channel >= 36 && rf->channel <= 64) { in rt2800_config_channel_rf3053()
3018 } else if (rf->channel >= 100 && rf->channel <= 128) { in rt2800_config_channel_rf3053()
3048 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3050 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
3055 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3853()
3056 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3853()
3058 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3063 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3080 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel_rf3853()
3092 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel_rf3853()
3114 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3124 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3131 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3137 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3139 else if (rf->channel < 100) in rt2800_config_channel_rf3853()
3141 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
3151 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3156 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3158 else if (rf->channel < 100) in rt2800_config_channel_rf3853()
3160 else if (rf->channel < 132) in rt2800_config_channel_rf3853()
3166 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3179 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3185 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3190 if (rf->channel <= 14) { in rt2800_config_channel_rf3853()
3191 pwr1 = info->default_power1 & 0x1f; in rt2800_config_channel_rf3853()
3192 pwr2 = info->default_power2 & 0x1f; in rt2800_config_channel_rf3853()
3193 pwr3 = info->default_power3 & 0x1f; in rt2800_config_channel_rf3853()
3195 pwr1 = 0x48 | ((info->default_power1 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3196 (info->default_power1 & 0x7); in rt2800_config_channel_rf3853()
3197 pwr2 = 0x48 | ((info->default_power2 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3198 (info->default_power2 & 0x7); in rt2800_config_channel_rf3853()
3199 pwr3 = 0x48 | ((info->default_power3 & 0x18) << 1) | in rt2800_config_channel_rf3853()
3200 (info->default_power3 & 0x7); in rt2800_config_channel_rf3853()
3208 rf->channel, pwr1, pwr2, pwr3); in rt2800_config_channel_rf3853()
3210 bbp = (info->default_power1 >> 5) | in rt2800_config_channel_rf3853()
3211 ((info->default_power2 & 0xe0) >> 1); in rt2800_config_channel_rf3853()
3216 bbp |= (info->default_power3 & 0xe0) >> 1; in rt2800_config_channel_rf3853()
3220 if (rf->channel <= 14) in rt2800_config_channel_rf3853()
3250 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3290()
3251 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3290()
3253 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf2); in rt2800_config_channel_rf3290()
3257 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf3290()
3260 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf3290()
3265 if (rf->channel <= 14) { in rt2800_config_channel_rf3290()
3266 if (rf->channel == 6) in rt2800_config_channel_rf3290()
3271 if (rf->channel >= 1 && rf->channel <= 6) in rt2800_config_channel_rf3290()
3273 else if (rf->channel >= 7 && rf->channel <= 11) in rt2800_config_channel_rf3290()
3275 else if (rf->channel >= 12 && rf->channel <= 14) in rt2800_config_channel_rf3290()
3287 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf3322()
3288 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf3322()
3294 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf3322()
3297 rt2800_rfcsr_write(rt2x00dev, 47, info->default_power1); in rt2800_config_channel_rf3322()
3299 if (info->default_power2 > POWER_BOUND) in rt2800_config_channel_rf3322()
3302 rt2800_rfcsr_write(rt2x00dev, 48, info->default_power2); in rt2800_config_channel_rf3322()
3310 if ( rt2x00dev->default_ant.tx_chain_num == 2 ) in rt2800_config_channel_rf3322()
3315 if ( rt2x00dev->default_ant.rx_chain_num == 2 ) in rt2800_config_channel_rf3322()
3334 int idx = rf->channel-1; in rt2800_config_channel_rf53xx()
3336 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1); in rt2800_config_channel_rf53xx()
3337 rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3); in rt2800_config_channel_rf53xx()
3339 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf2); in rt2800_config_channel_rf53xx()
3343 if (info->default_power1 > POWER_BOUND) in rt2800_config_channel_rf53xx()
3346 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf53xx()
3351 if (info->default_power2 > POWER_BOUND) in rt2800_config_channel_rf53xx()
3355 info->default_power2); in rt2800_config_channel_rf53xx()
3441 (rf->channel > 14 || conf_is_ht40(conf)) ? 5 : 0); in rt2800_config_channel_rf55xx()
3445 rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1 & 0xff); in rt2800_config_channel_rf55xx()
3448 rt2x00_set_field8(&rfcsr, RFCSR9_K, rf->rf2 & 0xf); in rt2800_config_channel_rf55xx()
3449 rt2x00_set_field8(&rfcsr, RFCSR9_N, (rf->rf1 & 0x100) >> 8); in rt2800_config_channel_rf55xx()
3450 rt2x00_set_field8(&rfcsr, RFCSR9_MOD, ((rf->rf3 - 8) & 0x4) >> 2); in rt2800_config_channel_rf55xx()
3454 rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf4 - 1); in rt2800_config_channel_rf55xx()
3455 rt2x00_set_field8(&rfcsr, RFCSR11_MOD, (rf->rf3 - 8) & 0x3); in rt2800_config_channel_rf55xx()
3458 if (rf->channel <= 14) { in rt2800_config_channel_rf55xx()
3490 /* TODO RF27 <- tssi */ in rt2800_config_channel_rf55xx()
3492 rfcsr = rf->channel <= 10 ? 0x07 : 0x06; in rt2800_config_channel_rf55xx()
3532 /* TODO RF27 <- tssi */ in rt2800_config_channel_rf55xx()
3534 if (rf->channel >= 36 && rf->channel <= 64) { in rt2800_config_channel_rf55xx()
3540 if (rf->channel <= 50) in rt2800_config_channel_rf55xx()
3542 else if (rf->channel >= 52) in rt2800_config_channel_rf55xx()
3551 if (rf->channel <= 50) { in rt2800_config_channel_rf55xx()
3554 } else if (rf->channel >= 52) { in rt2800_config_channel_rf55xx()
3563 } else if (rf->channel >= 100 && rf->channel <= 165) { in rt2800_config_channel_rf55xx()
3568 if (rf->channel <= 153) { in rt2800_config_channel_rf55xx()
3571 } else if (rf->channel >= 155) { in rt2800_config_channel_rf55xx()
3575 if (rf->channel <= 138) { in rt2800_config_channel_rf55xx()
3580 } else if (rf->channel >= 140) { in rt2800_config_channel_rf55xx()
3586 if (rf->channel <= 124) in rt2800_config_channel_rf55xx()
3588 else if (rf->channel >= 126) in rt2800_config_channel_rf55xx()
3590 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3592 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3595 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3597 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3599 if (rf->channel <= 128) in rt2800_config_channel_rf55xx()
3601 else if (rf->channel >= 130) in rt2800_config_channel_rf55xx()
3603 if (rf->channel <= 116) in rt2800_config_channel_rf55xx()
3605 else if (rf->channel >= 118) in rt2800_config_channel_rf55xx()
3607 if (rf->channel <= 138) in rt2800_config_channel_rf55xx()
3609 else if (rf->channel >= 140) in rt2800_config_channel_rf55xx()
3611 if (rf->channel <= 116) in rt2800_config_channel_rf55xx()
3613 else if (rf->channel >= 118) in rt2800_config_channel_rf55xx()
3622 if (info->default_power1 > power_bound) in rt2800_config_channel_rf55xx()
3625 rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1); in rt2800_config_channel_rf55xx()
3631 if (info->default_power2 > power_bound) in rt2800_config_channel_rf55xx()
3634 rt2x00_set_field8(&rfcsr, RFCSR50_TX, info->default_power2); in rt2800_config_channel_rf55xx()
3644 rt2x00dev->default_ant.tx_chain_num >= 1); in rt2800_config_channel_rf55xx()
3646 rt2x00dev->default_ant.tx_chain_num == 2); in rt2800_config_channel_rf55xx()
3650 rt2x00dev->default_ant.rx_chain_num >= 1); in rt2800_config_channel_rf55xx()
3652 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_config_channel_rf55xx()
3677 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3678 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3679 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel_rf55xx()
3681 rt2800_bbp_write(rt2x00dev, 79, (rf->channel <= 14) ? 0x1C : 0x18); in rt2800_config_channel_rf55xx()
3682 rt2800_bbp_write(rt2x00dev, 80, (rf->channel <= 14) ? 0x0E : 0x08); in rt2800_config_channel_rf55xx()
3683 rt2800_bbp_write(rt2x00dev, 81, (rf->channel <= 14) ? 0x3A : 0x38); in rt2800_config_channel_rf55xx()
3684 rt2800_bbp_write(rt2x00dev, 82, (rf->channel <= 14) ? 0x62 : 0x92); in rt2800_config_channel_rf55xx()
3688 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0xE0 : 0xF0); in rt2800_config_channel_rf55xx()
3690 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x1F : 0x1E); in rt2800_config_channel_rf55xx()
3692 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x38 : 0x28); in rt2800_config_channel_rf55xx()
3694 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x32 : 0x20); in rt2800_config_channel_rf55xx()
3696 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x28 : 0x7F); in rt2800_config_channel_rf55xx()
3698 rt2800_bbp_write(rt2x00dev, 196, (rf->channel <= 14) ? 0x19 : 0x7F); in rt2800_config_channel_rf55xx()
3706 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_config_channel_rf7620()
3720 * R20[7:0] in rf->rf1 in rt2800_config_channel_rf7620()
3724 rfcsr = (rf->rf1 & 0x00ff); in rt2800_config_channel_rf7620()
3746 * Ksd: R17<7:0> in rf->rf2 in rt2800_config_channel_rf7620()
3747 * R18<7:0> in rf->rf3 in rt2800_config_channel_rf7620()
3748 * R19<1:0> in rf->rf4 in rt2800_config_channel_rf7620()
3751 rfcsr = rf->rf2; in rt2800_config_channel_rf7620()
3755 rfcsr = rf->rf3; in rt2800_config_channel_rf7620()
3759 rt2x00_set_field8(&rfcsr, RFCSR19_K, rf->rf4); in rt2800_config_channel_rf7620()
3773 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3778 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3780 rt2x00dev->default_ant.rx_chain_num != 1); in rt2800_config_channel_rf7620()
3785 rt2x00dev->default_ant.tx_chain_num != 1); in rt2800_config_channel_rf7620()
3813 conf_is_ht40(conf) && (rf->channel == 11)); in rt2800_config_channel_rf7620()
3816 if (!test_bit(DEVICE_STATE_SCANNING, &rt2x00dev->flags)) { in rt2800_config_channel_rf7620()
3818 rx_agc_fc = drv_data->rx_calibration_bw40; in rt2800_config_channel_rf7620()
3819 tx_agc_fc = drv_data->tx_calibration_bw40; in rt2800_config_channel_rf7620()
3821 rx_agc_fc = drv_data->rx_calibration_bw20; in rt2800_config_channel_rf7620()
3822 tx_agc_fc = drv_data->tx_calibration_bw20; in rt2800_config_channel_rf7620()
3881 max_power = chan->max_power * 2; in rt2800_config_alc()
3913 if (chan->center_freq > 2457) { in rt2800_config_alc()
3943 for (chain = 0; chain < rt2x00dev->default_ant.rx_chain_num; chain++) { in rt2800_bbp_write_with_rx_chain()
4040 s8 txpower) in rt2800_txpower_to_dev() argument
4044 txpower = rt2x00_get_field8(txpower, EEPROM_TXPOWER_ALC); in rt2800_txpower_to_dev()
4047 return clamp_t(s8, txpower, MIN_G_TXPOWER, MAX_G_TXPOWER); in rt2800_txpower_to_dev()
4051 return clamp_t(s8, txpower, MIN_A_TXPOWER_3593, in rt2800_txpower_to_dev()
4054 return clamp_t(s8, txpower, MIN_A_TXPOWER, MAX_A_TXPOWER); in rt2800_txpower_to_dev()
4062 bbp = (rf->channel > 14) ? 0x48 : 0x38; in rt3883_bbp_adjust()
4067 if (rf->channel <= 14) { in rt3883_bbp_adjust()
4076 if (rf->channel > 14) { in rt3883_bbp_adjust()
4096 info->default_power1 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4097 info->default_power1); in rt2800_config_channel()
4098 info->default_power2 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4099 info->default_power2); in rt2800_config_channel()
4100 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_config_channel()
4101 info->default_power3 = in rt2800_config_channel()
4102 rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4103 info->default_power3); in rt2800_config_channel()
4105 switch (rt2x00dev->chip.rt) { in rt2800_config_channel()
4111 switch (rt2x00dev->chip.rf) { in rt2800_config_channel()
4188 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4189 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4190 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4193 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); in rt2800_config_channel()
4195 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); in rt2800_config_channel()
4199 if (rf->channel > 14) { in rt2800_config_channel()
4211 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4212 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4213 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4216 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4217 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4218 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4220 if (rt2x00dev->default_ant.rx_chain_num > 1) in rt2800_config_channel()
4225 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4226 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4227 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4234 if (rf->channel <= 14) { in rt2800_config_channel()
4275 rt2x00_set_field32(&reg, TX_BAND_CFG_A, rf->channel > 14); in rt2800_config_channel()
4276 rt2x00_set_field32(&reg, TX_BAND_CFG_BG, rf->channel <= 14); in rt2800_config_channel()
4289 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel()
4293 rf->channel > 14); in rt2800_config_channel()
4295 rf->channel <= 14); in rt2800_config_channel()
4300 rf->channel > 14); in rt2800_config_channel()
4302 rf->channel <= 14); in rt2800_config_channel()
4307 rf->channel > 14); in rt2800_config_channel()
4312 rf->channel <= 14); in rt2800_config_channel()
4316 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel()
4343 if (rf->channel <= 14) in rt2800_config_channel()
4344 reg = 0x1c + (2 * rt2x00dev->lna_gain); in rt2800_config_channel()
4346 reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4359 if (rf->channel <= 14) in rt2800_config_channel()
4384 if (rf->channel <= 14) in rt2800_config_channel()
4385 reg = 0x1c + 2 * rt2x00dev->lna_gain; in rt2800_config_channel()
4387 reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4401 if (rf->channel <= 14) in rt2800_config_channel()
4402 reg = 0x2e + rt2x00dev->lna_gain; in rt2800_config_channel()
4404 reg = 0x20 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4429 reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain; in rt2800_config_channel()
4433 rt2800_iq_calibrate(rt2x00dev, rf->channel); in rt2800_config_channel()
4438 &rt2x00dev->cap_flags)) { in rt2800_config_channel()
4533 * Matching Delta value -4 -3 -2 -1 0 +1 +2 +3 +4 in rt2800_get_gain_calibration_delta()
4536 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_get_gain_calibration_delta()
4621 for (i = 8; i >= 5; i--) { in rt2800_get_gain_calibration_delta()
4627 return (i - 4) * step; in rt2800_get_gain_calibration_delta()
4644 !test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_get_txpower_bw_comp()
4656 comp_value = -comp_value; in rt2800_get_txpower_bw_comp()
4667 comp_value = -comp_value; in rt2800_get_txpower_bw_comp()
4691 delta = power_level - max_power; in rt2800_get_txpower_reg_delta()
4697 u8 txpower, int delta) in rt2800_compensate_txpower() argument
4706 return min_t(u8, txpower, 0xc); in rt2800_compensate_txpower()
4709 return min_t(u8, txpower, 0xf); in rt2800_compensate_txpower()
4713 * Check if eirp txpower exceed txpower_limit. in rt2800_compensate_txpower()
4714 * We use OFDM 6M as criterion and its eirp txpower in rt2800_compensate_txpower()
4717 * when calculating eirp txpower. in rt2800_compensate_txpower()
4734 eirp_txpower = eirp_txpower_criterion + (txpower - criterion) + in rt2800_compensate_txpower()
4738 (eirp_txpower - power_level) : 0; in rt2800_compensate_txpower()
4742 txpower = max(0, txpower + delta - reg_limit); in rt2800_compensate_txpower()
4743 return min_t(u8, txpower, 0xc); in rt2800_compensate_txpower()
4770 u8 txpower; in rt2800_config_txpower_rt3593() local
4774 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt3593()
4790 if (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_config_txpower_rt3593()
4793 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
4798 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
4799 txpower = rt2800_compensate_txpower(rt2x00dev, 1, band, power_level, in rt2800_config_txpower_rt3593()
4800 txpower, delta); in rt2800_config_txpower_rt3593()
4802 TX_PWR_CFG_0_CCK1_CH0, txpower); in rt2800_config_txpower_rt3593()
4804 TX_PWR_CFG_0_CCK1_CH1, txpower); in rt2800_config_txpower_rt3593()
4806 TX_PWR_CFG_0_EXT_CCK1_CH2, txpower); in rt2800_config_txpower_rt3593()
4809 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
4810 txpower = rt2800_compensate_txpower(rt2x00dev, 1, band, power_level, in rt2800_config_txpower_rt3593()
4811 txpower, delta); in rt2800_config_txpower_rt3593()
4813 TX_PWR_CFG_0_CCK5_CH0, txpower); in rt2800_config_txpower_rt3593()
4815 TX_PWR_CFG_0_CCK5_CH1, txpower); in rt2800_config_txpower_rt3593()
4817 TX_PWR_CFG_0_EXT_CCK5_CH2, txpower); in rt2800_config_txpower_rt3593()
4820 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
4821 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4822 txpower, delta); in rt2800_config_txpower_rt3593()
4824 TX_PWR_CFG_0_OFDM6_CH0, txpower); in rt2800_config_txpower_rt3593()
4826 TX_PWR_CFG_0_OFDM6_CH1, txpower); in rt2800_config_txpower_rt3593()
4828 TX_PWR_CFG_0_EXT_OFDM6_CH2, txpower); in rt2800_config_txpower_rt3593()
4831 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); in rt2800_config_txpower_rt3593()
4832 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4833 txpower, delta); in rt2800_config_txpower_rt3593()
4835 TX_PWR_CFG_0_OFDM12_CH0, txpower); in rt2800_config_txpower_rt3593()
4837 TX_PWR_CFG_0_OFDM12_CH1, txpower); in rt2800_config_txpower_rt3593()
4839 TX_PWR_CFG_0_EXT_OFDM12_CH2, txpower); in rt2800_config_txpower_rt3593()
4841 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
4846 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
4847 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4848 txpower, delta); in rt2800_config_txpower_rt3593()
4850 TX_PWR_CFG_1_OFDM24_CH0, txpower); in rt2800_config_txpower_rt3593()
4852 TX_PWR_CFG_1_OFDM24_CH1, txpower); in rt2800_config_txpower_rt3593()
4854 TX_PWR_CFG_1_EXT_OFDM24_CH2, txpower); in rt2800_config_txpower_rt3593()
4857 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
4858 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4859 txpower, delta); in rt2800_config_txpower_rt3593()
4861 TX_PWR_CFG_1_OFDM48_CH0, txpower); in rt2800_config_txpower_rt3593()
4863 TX_PWR_CFG_1_OFDM48_CH1, txpower); in rt2800_config_txpower_rt3593()
4865 TX_PWR_CFG_1_EXT_OFDM48_CH2, txpower); in rt2800_config_txpower_rt3593()
4868 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
4869 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4870 txpower, delta); in rt2800_config_txpower_rt3593()
4872 TX_PWR_CFG_7_OFDM54_CH0, txpower); in rt2800_config_txpower_rt3593()
4874 TX_PWR_CFG_7_OFDM54_CH1, txpower); in rt2800_config_txpower_rt3593()
4876 TX_PWR_CFG_7_OFDM54_CH2, txpower); in rt2800_config_txpower_rt3593()
4878 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
4883 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); 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_1_MCS0_CH0, txpower); in rt2800_config_txpower_rt3593()
4889 TX_PWR_CFG_1_MCS0_CH1, txpower); in rt2800_config_txpower_rt3593()
4891 TX_PWR_CFG_1_EXT_MCS0_CH2, txpower); in rt2800_config_txpower_rt3593()
4894 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
4895 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4896 txpower, delta); in rt2800_config_txpower_rt3593()
4898 TX_PWR_CFG_1_MCS2_CH0, txpower); in rt2800_config_txpower_rt3593()
4900 TX_PWR_CFG_1_MCS2_CH1, txpower); in rt2800_config_txpower_rt3593()
4902 TX_PWR_CFG_1_EXT_MCS2_CH2, txpower); in rt2800_config_txpower_rt3593()
4905 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
4906 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4907 txpower, delta); in rt2800_config_txpower_rt3593()
4909 TX_PWR_CFG_2_MCS4_CH0, txpower); in rt2800_config_txpower_rt3593()
4911 TX_PWR_CFG_2_MCS4_CH1, txpower); in rt2800_config_txpower_rt3593()
4913 TX_PWR_CFG_2_EXT_MCS4_CH2, txpower); in rt2800_config_txpower_rt3593()
4916 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); in rt2800_config_txpower_rt3593()
4917 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4918 txpower, delta); in rt2800_config_txpower_rt3593()
4920 TX_PWR_CFG_2_MCS6_CH0, txpower); in rt2800_config_txpower_rt3593()
4922 TX_PWR_CFG_2_MCS6_CH1, txpower); in rt2800_config_txpower_rt3593()
4924 TX_PWR_CFG_2_EXT_MCS6_CH2, txpower); in rt2800_config_txpower_rt3593()
4926 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
4931 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
4932 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4933 txpower, delta); in rt2800_config_txpower_rt3593()
4935 TX_PWR_CFG_7_MCS7_CH0, txpower); in rt2800_config_txpower_rt3593()
4937 TX_PWR_CFG_7_MCS7_CH1, txpower); in rt2800_config_txpower_rt3593()
4939 TX_PWR_CFG_7_MCS7_CH2, txpower); in rt2800_config_txpower_rt3593()
4942 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
4943 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4944 txpower, delta); in rt2800_config_txpower_rt3593()
4946 TX_PWR_CFG_2_MCS8_CH0, txpower); in rt2800_config_txpower_rt3593()
4948 TX_PWR_CFG_2_MCS8_CH1, txpower); in rt2800_config_txpower_rt3593()
4950 TX_PWR_CFG_2_EXT_MCS8_CH2, txpower); in rt2800_config_txpower_rt3593()
4953 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
4954 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4955 txpower, delta); in rt2800_config_txpower_rt3593()
4957 TX_PWR_CFG_2_MCS10_CH0, txpower); in rt2800_config_txpower_rt3593()
4959 TX_PWR_CFG_2_MCS10_CH1, txpower); in rt2800_config_txpower_rt3593()
4961 TX_PWR_CFG_2_EXT_MCS10_CH2, txpower); in rt2800_config_txpower_rt3593()
4964 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); in rt2800_config_txpower_rt3593()
4965 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4966 txpower, delta); in rt2800_config_txpower_rt3593()
4968 TX_PWR_CFG_3_MCS12_CH0, txpower); in rt2800_config_txpower_rt3593()
4970 TX_PWR_CFG_3_MCS12_CH1, txpower); in rt2800_config_txpower_rt3593()
4972 TX_PWR_CFG_3_EXT_MCS12_CH2, txpower); in rt2800_config_txpower_rt3593()
4974 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
4979 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
4980 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4981 txpower, delta); in rt2800_config_txpower_rt3593()
4983 TX_PWR_CFG_3_MCS14_CH0, txpower); in rt2800_config_txpower_rt3593()
4985 TX_PWR_CFG_3_MCS14_CH1, txpower); in rt2800_config_txpower_rt3593()
4987 TX_PWR_CFG_3_EXT_MCS14_CH2, txpower); in rt2800_config_txpower_rt3593()
4990 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
4991 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
4992 txpower, delta); in rt2800_config_txpower_rt3593()
4994 TX_PWR_CFG_8_MCS15_CH0, txpower); in rt2800_config_txpower_rt3593()
4996 TX_PWR_CFG_8_MCS15_CH1, txpower); in rt2800_config_txpower_rt3593()
4998 TX_PWR_CFG_8_MCS15_CH2, txpower); in rt2800_config_txpower_rt3593()
5001 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
5002 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5003 txpower, delta); in rt2800_config_txpower_rt3593()
5005 TX_PWR_CFG_5_MCS16_CH0, txpower); in rt2800_config_txpower_rt3593()
5007 TX_PWR_CFG_5_MCS16_CH1, txpower); in rt2800_config_txpower_rt3593()
5009 TX_PWR_CFG_5_MCS16_CH2, txpower); in rt2800_config_txpower_rt3593()
5012 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); in rt2800_config_txpower_rt3593()
5013 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5014 txpower, delta); in rt2800_config_txpower_rt3593()
5016 TX_PWR_CFG_5_MCS18_CH0, txpower); in rt2800_config_txpower_rt3593()
5018 TX_PWR_CFG_5_MCS18_CH1, txpower); in rt2800_config_txpower_rt3593()
5020 TX_PWR_CFG_5_MCS18_CH2, txpower); in rt2800_config_txpower_rt3593()
5022 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
5027 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
5028 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5029 txpower, delta); in rt2800_config_txpower_rt3593()
5031 TX_PWR_CFG_6_MCS20_CH0, txpower); in rt2800_config_txpower_rt3593()
5033 TX_PWR_CFG_6_MCS20_CH1, txpower); in rt2800_config_txpower_rt3593()
5035 TX_PWR_CFG_6_MCS20_CH2, txpower); in rt2800_config_txpower_rt3593()
5038 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
5039 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5040 txpower, delta); in rt2800_config_txpower_rt3593()
5042 TX_PWR_CFG_6_MCS22_CH0, txpower); in rt2800_config_txpower_rt3593()
5044 TX_PWR_CFG_6_MCS22_CH1, txpower); in rt2800_config_txpower_rt3593()
5046 TX_PWR_CFG_6_MCS22_CH2, txpower); in rt2800_config_txpower_rt3593()
5049 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
5050 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5051 txpower, delta); in rt2800_config_txpower_rt3593()
5053 TX_PWR_CFG_8_MCS23_CH0, txpower); in rt2800_config_txpower_rt3593()
5055 TX_PWR_CFG_8_MCS23_CH1, txpower); in rt2800_config_txpower_rt3593()
5057 TX_PWR_CFG_8_MCS23_CH2, txpower); in rt2800_config_txpower_rt3593()
5059 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
5064 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); 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_3_STBC0_CH0, txpower); in rt2800_config_txpower_rt3593()
5070 TX_PWR_CFG_3_STBC0_CH1, txpower); in rt2800_config_txpower_rt3593()
5072 TX_PWR_CFG_3_EXT_STBC0_CH2, txpower); in rt2800_config_txpower_rt3593()
5075 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE1); in rt2800_config_txpower_rt3593()
5076 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5077 txpower, delta); in rt2800_config_txpower_rt3593()
5079 TX_PWR_CFG_3_STBC2_CH0, txpower); in rt2800_config_txpower_rt3593()
5081 TX_PWR_CFG_3_STBC2_CH1, txpower); in rt2800_config_txpower_rt3593()
5083 TX_PWR_CFG_3_EXT_STBC2_CH2, txpower); in rt2800_config_txpower_rt3593()
5086 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE2); in rt2800_config_txpower_rt3593()
5087 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5088 txpower, delta); in rt2800_config_txpower_rt3593()
5089 rt2x00_set_field32(&regs[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE0, txpower); in rt2800_config_txpower_rt3593()
5090 rt2x00_set_field32(&regs[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE1, txpower); in rt2800_config_txpower_rt3593()
5092 txpower); in rt2800_config_txpower_rt3593()
5095 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE3); in rt2800_config_txpower_rt3593()
5096 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5097 txpower, delta); in rt2800_config_txpower_rt3593()
5098 rt2x00_set_field32(&regs[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE2, txpower); in rt2800_config_txpower_rt3593()
5099 rt2x00_set_field32(&regs[TX_PWR_CFG_4_IDX], TX_PWR_CFG_RATE3, txpower); in rt2800_config_txpower_rt3593()
5101 txpower); in rt2800_config_txpower_rt3593()
5103 /* read the next four txpower values */ in rt2800_config_txpower_rt3593()
5108 txpower = rt2x00_get_field16(eeprom, EEPROM_TXPOWER_BYRATE_RATE0); in rt2800_config_txpower_rt3593()
5109 txpower = rt2800_compensate_txpower(rt2x00dev, 0, band, power_level, in rt2800_config_txpower_rt3593()
5110 txpower, delta); in rt2800_config_txpower_rt3593()
5112 TX_PWR_CFG_9_STBC7_CH0, txpower); in rt2800_config_txpower_rt3593()
5114 TX_PWR_CFG_9_STBC7_CH1, txpower); in rt2800_config_txpower_rt3593()
5116 TX_PWR_CFG_9_STBC7_CH2, txpower); in rt2800_config_txpower_rt3593()
5144 (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) ? in rt2800_config_txpower_rt3593()
5147 (i - TX_PWR_CFG_9_IDX - 1) : i, in rt2800_config_txpower_rt3593()
5160 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt6352()
5173 * Maybe some misunderstanding of what a signed 8-bit value is? Maybe in rt2800_config_txpower_rt6352()
5175 * used a fixed offset between HT20 and HT40 rates they had to work- in rt2800_config_txpower_rt6352()
5220 if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) { in rt2800_config_txpower_rt6352()
5237 * registers. As recent 2T chips use 8-bit instead of 4-bit values for in rt2800_config_txpower_rt6352()
5238 * power-offsets more space would be needed. Ralink decided to keep the in rt2800_config_txpower_rt6352()
5280 * for all rates, but allow to set only 4 discrete values: -12, -6, 0 and 6 dBm.
5289 u8 txpower, r1; in rt2800_config_txpower_rt28xx() local
5293 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt28xx()
5308 switch (rt2x00dev->chip.rt) { in rt2800_config_txpower_rt28xx()
5329 chan->max_power); in rt2800_config_txpower_rt28xx()
5333 * gains -12, -6, 0, +6 dBm by setting values 2, 1, 0, 3 respectively. in rt2800_config_txpower_rt28xx()
5339 if (delta <= -12) { in rt2800_config_txpower_rt28xx()
5342 } else if (delta <= -6) { in rt2800_config_txpower_rt28xx()
5361 /* read the next four txpower values */ in rt2800_config_txpower_rt28xx()
5372 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5374 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5375 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5376 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE0, txpower); in rt2800_config_txpower_rt28xx()
5383 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5385 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5386 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5387 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE1, txpower); in rt2800_config_txpower_rt28xx()
5394 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5396 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5397 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5398 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE2, txpower); in rt2800_config_txpower_rt28xx()
5405 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5407 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5408 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5409 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE3, txpower); in rt2800_config_txpower_rt28xx()
5411 /* read the next four txpower values */ in rt2800_config_txpower_rt28xx()
5422 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5424 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5425 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5426 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE4, txpower); in rt2800_config_txpower_rt28xx()
5433 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5435 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5436 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5437 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE5, txpower); in rt2800_config_txpower_rt28xx()
5444 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5446 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5447 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5448 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE6, txpower); in rt2800_config_txpower_rt28xx()
5455 txpower = rt2x00_get_field16(eeprom, in rt2800_config_txpower_rt28xx()
5457 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band, in rt2800_config_txpower_rt28xx()
5458 power_level, txpower, delta); in rt2800_config_txpower_rt28xx()
5459 rt2x00_set_field32(&reg, TX_PWR_CFG_RATE7, txpower); in rt2800_config_txpower_rt28xx()
5483 rt2800_config_txpower(rt2x00dev, rt2x00dev->hw->conf.chandef.chan, in rt2800_gain_calibration()
5484 rt2x00dev->tx_power); in rt2800_gain_calibration()
5495 * A voltage-controlled oscillator(VCO) is an electronic oscillator in rt2800_vco_calibration()
5506 switch (rt2x00dev->chip.rf) { in rt2800_vco_calibration()
5544 rt2x00dev->chip.rf); in rt2800_vco_calibration()
5552 if (rt2x00dev->rf_channel <= 14) { in rt2800_vco_calibration()
5553 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_vco_calibration()
5566 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_vco_calibration()
5582 if (rt2x00dev->default_ant.rx_chain_num == 1) { in rt2800_vco_calibration()
5612 * 2005/06/05 - On 11G, we also need this delay time. in rt2800_vco_calibration()
5627 libconf->conf->short_frame_max_tx_count); in rt2800_config_retry_limit()
5629 libconf->conf->long_frame_max_tx_count); in rt2800_config_retry_limit()
5637 (libconf->conf->flags & IEEE80211_CONF_PS) ? in rt2800_config_ps()
5647 libconf->conf->listen_interval - 1); in rt2800_config_ps()
5651 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); in rt2800_config_ps()
5659 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); in rt2800_config_ps()
5672 * To provide correct survey data for survey-based ACS algorithm in rt2800_config()
5677 rt2800_config_channel(rt2x00dev, libconf->conf, in rt2800_config()
5678 &libconf->rf, &libconf->channel); in rt2800_config()
5679 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, in rt2800_config()
5680 libconf->conf->power_level); in rt2800_config()
5683 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, in rt2800_config()
5684 libconf->conf->power_level); in rt2800_config()
5703 qual->rx_failed = rt2x00_get_field32(reg, RX_STA_CNT0_CRC_ERR); in rt2800_link_stats()
5711 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_get_default_vgc()
5723 vgc = 0x1c + (2 * rt2x00dev->lna_gain); in rt2800_get_default_vgc()
5725 vgc = 0x2e + rt2x00dev->lna_gain; in rt2800_get_default_vgc()
5729 vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5731 vgc = 0x24 + (2 * rt2x00dev->lna_gain); in rt2800_get_default_vgc()
5733 if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_get_default_vgc()
5734 vgc = 0x32 + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5736 vgc = 0x3a + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5746 if (qual->vgc_level != vgc_level) { in rt2800_set_vgc()
5754 rt2800_bbp_write(rt2x00dev, 83, qual->rssi > -65 ? 0x4a : 0x7a); in rt2800_set_vgc()
5760 qual->vgc_level = vgc_level; in rt2800_set_vgc()
5761 qual->vgc_level_reg = vgc_level; in rt2800_set_vgc()
5786 switch (rt2x00dev->chip.rt) { in rt2800_link_tuner()
5789 if (qual->rssi > -65) { in rt2800_link_tuner()
5790 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) in rt2800_link_tuner()
5798 if (qual->rssi > -65) in rt2800_link_tuner()
5803 if (qual->rssi > -65) in rt2800_link_tuner()
5808 if (qual->rssi > -80) in rt2800_link_tuner()
5822 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_init_registers()
6012 drv_data->max_psdu = 3; in rt2800_init_registers()
6016 drv_data->max_psdu = 2; in rt2800_init_registers()
6018 drv_data->max_psdu = 1; in rt2800_init_registers()
6020 rt2x00_set_field32(&reg, MAX_LEN_CFG_MAX_PSDU, drv_data->max_psdu); in rt2800_init_registers()
6217 if (!test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags)) in rt2800_init_registers()
6589 /* Use 5-bit ADC for Acquisition and 8-bit ADC for data */ in rt2800_init_bbp_3290()
6939 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_init_bbp_5592()
7010 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_init_bbp_6352()
7217 switch (rt2x00dev->chip.rt) { in rt2800_init_bbp()
7330 if ((passband - stopband) <= filter_target) { in rt2800_init_rx_filter()
7332 overtuned += ((passband - stopband) == filter_target); in rt2800_init_rx_filter()
7339 rfcsr24 -= !!overtuned; in rt2800_init_rx_filter()
7360 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_rx_filter_calibration()
7376 drv_data->calibration_bw20 = in rt2800_rx_filter_calibration()
7378 drv_data->calibration_bw40 = in rt2800_rx_filter_calibration()
7384 drv_data->bbp25 = rt2800_bbp_read(rt2x00dev, 25); in rt2800_rx_filter_calibration()
7385 drv_data->bbp26 = rt2800_bbp_read(rt2x00dev, 26); in rt2800_rx_filter_calibration()
7406 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_normal_mode_setup_3xxx()
7422 if (drv_data->txmixer_gain_24g >= min_gain) { in rt2800_normal_mode_setup_3xxx()
7424 drv_data->txmixer_gain_24g); in rt2800_normal_mode_setup_3xxx()
7477 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_normal_mode_setup_3593()
7486 tx_gain = rt2x00_get_field8(drv_data->txmixer_gain_24g, in rt2800_normal_mode_setup_3593()
7712 &rt2x00dev->cap_flags); in rt2800_init_rfcsr_3352()
7714 &rt2x00dev->cap_flags); in rt2800_init_rfcsr_3352()
7924 if (rt2x00dev->default_ant.rx_chain_num == 1) in rt3593_post_bbp_init()
7967 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_init_rfcsr_3593()
8033 drv_data->calibration_bw20 = 0x1f; in rt2800_init_rfcsr_3593()
8034 drv_data->calibration_bw40 = 0x2f; in rt2800_init_rfcsr_3593()
8037 drv_data->bbp25 = rt2800_bbp_read(rt2x00dev, 25); in rt2800_init_rfcsr_3593()
8038 drv_data->bbp26 = rt2800_bbp_read(rt2x00dev, 26); in rt2800_init_rfcsr_3593()
8514 int calcode = ((d2 - d1) * 1000) / 43; in rt2800_calcrcalibrationcode()
8592 d1 = bytevalue - 256; in rt2800_r_calibration()
8602 d2 = bytevalue - 256; in rt2800_r_calibration()
8710 for (i = 15; i >= 0; i = i - 1) { in rt2800_do_sqrt_accumulation()
8776 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) in rt2800_rxiq_calibration()
8836 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_rxiq_calibration()
8926 result = (bbptemp & 0xffffff) - 0x1000000; in rt2800_rxiq_calibration()
8944 bbpval1 = si - mi * mi; in rt2800_rxiq_calibration()
8972 sigma_i = rt2800_do_sqrt_accumulation(100 * (si - mi * mi)); in rt2800_rxiq_calibration()
8973 sigma_q = rt2800_do_sqrt_accumulation(100 * (sq - mq * mq)); in rt2800_rxiq_calibration()
8974 r_iq = 10 * (riq - (mi * mq)); in rt2800_rxiq_calibration()
8979 (sigma_i - sigma_q) <= 112 && in rt2800_rxiq_calibration()
8980 (sigma_i - sigma_q) >= -112 && in rt2800_rxiq_calibration()
8981 mi <= 32 && mi >= -32 && in rt2800_rxiq_calibration()
8982 mq <= 32 && mq >= -32) { in rt2800_rxiq_calibration()
8983 r_iq = 10 * (riq - (mi * mq)); in rt2800_rxiq_calibration()
8988 g_imb = ((-2) * 128 * (1000 - g_rx)) / (1000 + g_rx); in rt2800_rxiq_calibration()
8991 if (ph_rx > 20 || ph_rx < -20) { in rt2800_rxiq_calibration()
8996 if (g_imb > 12 || g_imb < -12) { in rt2800_rxiq_calibration()
9255 fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; in rt2800_do_fft_accumulation()
9257 fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; in rt2800_do_fft_accumulation()
9264 tidxi = 0x40 - tidx; in rt2800_do_fft_accumulation()
9275 fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; in rt2800_do_fft_accumulation()
9277 fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; in rt2800_do_fft_accumulation()
9301 fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; in rt2800_read_fft_accumulation()
9303 fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; in rt2800_read_fft_accumulation()
9342 for (bidx = 5; bidx >= 0; bidx--) { in rt2800_loft_search()
9348 idx0 = idxf[iorq] - ibit; in rt2800_loft_search()
9399 for (bidx = 5; bidx >= 1; bidx--) { in rt2800_iq_search()
9415 idx0 = iq_err - ibit; in rt2800_iq_search()
9469 gerr = (gerr & 0x08) ? (gerr & 0x0F) - 0x10 : (gerr & 0x0F); in rt2800_iq_search()
9470 perr = (perr & 0x20) ? (perr & 0x3F) - 0x40 : (perr & 0x3F); in rt2800_iq_search()
9472 gerr = (gerr < -0x07) ? -0x07 : (gerr > 0x05) ? 0x05 : gerr; in rt2800_iq_search()
9473 gsta = gerr - 1; in rt2800_iq_search()
9476 perr = (perr < -0x1f) ? -0x1f : (perr > 0x1d) ? 0x1d : perr; in rt2800_iq_search()
9477 psta = perr - 1; in rt2800_iq_search()
9663 vga_gain[ch_idx] = vga_gain[ch_idx] - 2) { in rt2800_loft_iq_calibration()
9787 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9795 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9814 if (!test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9839 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9849 if (test_bit(CAPABILITY_EXTERNAL_PA_TX1, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9865 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9884 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) in rt2800_loft_iq_calibration()
9891 if (test_bit(CAPABILITY_EXTERNAL_PA_TX1, &rt2x00dev->cap_flags)) in rt2800_loft_iq_calibration()
9896 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9900 vga_gain[ch_idx] = vga_gain[ch_idx] - 1; in rt2800_loft_iq_calibration()
9941 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9957 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) in rt2800_loft_iq_calibration()
10067 cal_val -= 128; in rt2800_lp_tx_filter_bw_cal()
10075 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_bw_filter_calibration()
10152 /* I-3 */ in rt2800_bw_filter_calibration()
10159 /* I-4,5,6,7,8,9 */ in rt2800_bw_filter_calibration()
10244 cal_diff = cal_r32_init - cal_r32_val; in rt2800_bw_filter_calibration()
10267 drv_data->tx_calibration_bw20 = tx_agc_fc; in rt2800_bw_filter_calibration()
10269 drv_data->tx_calibration_bw40 = tx_agc_fc; in rt2800_bw_filter_calibration()
10272 drv_data->rx_calibration_bw20 = rx_agc_fc; in rt2800_bw_filter_calibration()
10274 drv_data->rx_calibration_bw40 = rx_agc_fc; in rt2800_bw_filter_calibration()
10314 2 * test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)); in rt2800_bw_filter_calibration()
10336 rt2800_rfcsr_write(rt2x00dev, 12, rt2x00dev->freq_offset); in rt2800_init_rfcsr_6352()
10601 switch (rt2x00dev->chip.rt) { in rt2800_init_rfcsr()
10653 return -EIO; in rt2800_enable_radio()
10659 return -EIO; in rt2800_enable_radio()
10675 return -EIO; in rt2800_enable_radio()
10785 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_efuse_read()
10798 *(u32 *)&rt2x00dev->eeprom[i] = cpu_to_le32(reg); in rt2800_efuse_read()
10800 *(u32 *)&rt2x00dev->eeprom[i + 2] = cpu_to_le32(reg); in rt2800_efuse_read()
10802 *(u32 *)&rt2x00dev->eeprom[i + 4] = cpu_to_le32(reg); in rt2800_efuse_read()
10804 *(u32 *)&rt2x00dev->eeprom[i + 6] = cpu_to_le32(reg); in rt2800_efuse_read()
10806 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_efuse_read()
10852 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_validate_eeprom()
10941 drv_data->txmixer_gain_24g = rt2800_get_txmixer_gain_24g(rt2x00dev); in rt2800_validate_eeprom()
10955 drv_data->txmixer_gain_5g = rt2800_get_txmixer_gain_5g(rt2x00dev); in rt2800_validate_eeprom()
11054 return -ENODEV; in rt2800_init_eeprom()
11062 rt2x00dev->default_ant.tx_chain_num = in rt2800_init_eeprom()
11064 rt2x00dev->default_ant.rx_chain_num = in rt2800_init_eeprom()
11079 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
11080 rt2x00dev->default_ant.rx = ANTENNA_A; in rt2800_init_eeprom()
11083 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
11084 rt2x00dev->default_ant.rx = ANTENNA_B; in rt2800_init_eeprom()
11088 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
11089 rt2x00dev->default_ant.rx = ANTENNA_A; in rt2800_init_eeprom()
11095 rt2x00dev->default_ant.tx = ANTENNA_HW_DIVERSITY; /* Unused */ in rt2800_init_eeprom()
11096 rt2x00dev->default_ant.rx = ANTENNA_HW_DIVERSITY; /* Unused */ in rt2800_init_eeprom()
11103 __set_bit(CAPABILITY_EXTERNAL_LNA_A, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11105 __set_bit(CAPABILITY_EXTERNAL_LNA_BG, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11111 __set_bit(CAPABILITY_HW_BUTTON, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11114 * Detect if this device has Bluetooth co-existence. in rt2800_init_eeprom()
11118 __set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11124 rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET); in rt2800_init_eeprom()
11130 rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); in rt2800_init_eeprom()
11131 rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); in rt2800_init_eeprom()
11132 rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY); in rt2800_init_eeprom()
11134 rt2x00dev->led_mcu_reg = eeprom; in rt2800_init_eeprom()
11144 __set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11156 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11160 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11169 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11171 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11551 struct hw_mode_spec *spec = &rt2x00dev->spec; in rt2800_probe_hw_mode()
11562 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; in rt2800_probe_hw_mode()
11568 rt2x00dev->hw->wiphy->retry_short = 2; in rt2800_probe_hw_mode()
11569 rt2x00dev->hw->wiphy->retry_long = 2; in rt2800_probe_hw_mode()
11574 ieee80211_hw_set(rt2x00dev->hw, REPORTS_TX_ACK_STATUS); in rt2800_probe_hw_mode()
11575 ieee80211_hw_set(rt2x00dev->hw, AMPDU_AGGREGATION); in rt2800_probe_hw_mode()
11576 ieee80211_hw_set(rt2x00dev->hw, PS_NULLFUNC_STACK); in rt2800_probe_hw_mode()
11577 ieee80211_hw_set(rt2x00dev->hw, SIGNAL_DBM); in rt2800_probe_hw_mode()
11578 ieee80211_hw_set(rt2x00dev->hw, SUPPORTS_PS); in rt2800_probe_hw_mode()
11588 ieee80211_hw_set(rt2x00dev->hw, HOST_BROADCAST_PS_BUFFERING); in rt2800_probe_hw_mode()
11590 ieee80211_hw_set(rt2x00dev->hw, MFP_CAPABLE); in rt2800_probe_hw_mode()
11592 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); in rt2800_probe_hw_mode()
11593 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, in rt2800_probe_hw_mode()
11606 rt2x00dev->hw->max_rates = 1; in rt2800_probe_hw_mode()
11607 rt2x00dev->hw->max_report_rates = 7; in rt2800_probe_hw_mode()
11608 rt2x00dev->hw->max_rate_tries = 1; in rt2800_probe_hw_mode()
11613 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; in rt2800_probe_hw_mode()
11615 switch (rt2x00dev->chip.rf) { in rt2800_probe_hw_mode()
11618 spec->num_channels = 14; in rt2800_probe_hw_mode()
11619 spec->channels = rf_vals; in rt2800_probe_hw_mode()
11624 spec->num_channels = ARRAY_SIZE(rf_vals); in rt2800_probe_hw_mode()
11625 spec->channels = rf_vals; in rt2800_probe_hw_mode()
11643 spec->num_channels = 14; in rt2800_probe_hw_mode()
11645 spec->channels = rf_vals_3x_xtal20; in rt2800_probe_hw_mode()
11647 spec->channels = rf_vals_3x; in rt2800_probe_hw_mode()
11651 spec->num_channels = ARRAY_SIZE(rf_vals_7620); in rt2800_probe_hw_mode()
11652 spec->channels = rf_vals_7620; in rt2800_probe_hw_mode()
11657 spec->num_channels = ARRAY_SIZE(rf_vals_3x); in rt2800_probe_hw_mode()
11658 spec->channels = rf_vals_3x; in rt2800_probe_hw_mode()
11662 spec->num_channels = ARRAY_SIZE(rf_vals_3853); in rt2800_probe_hw_mode()
11663 spec->channels = rf_vals_3853; in rt2800_probe_hw_mode()
11669 spec->num_channels = ARRAY_SIZE(rf_vals_5592_xtal40); in rt2800_probe_hw_mode()
11670 spec->channels = rf_vals_5592_xtal40; in rt2800_probe_hw_mode()
11672 spec->num_channels = ARRAY_SIZE(rf_vals_5592_xtal20); in rt2800_probe_hw_mode()
11673 spec->channels = rf_vals_5592_xtal20; in rt2800_probe_hw_mode()
11678 if (WARN_ON_ONCE(!spec->channels)) in rt2800_probe_hw_mode()
11679 return -ENODEV; in rt2800_probe_hw_mode()
11681 spec->supported_bands = SUPPORT_BAND_2GHZ; in rt2800_probe_hw_mode()
11682 if (spec->num_channels > 14) in rt2800_probe_hw_mode()
11683 spec->supported_bands |= SUPPORT_BAND_5GHZ; in rt2800_probe_hw_mode()
11689 spec->ht.ht_supported = true; in rt2800_probe_hw_mode()
11691 spec->ht.ht_supported = false; in rt2800_probe_hw_mode()
11693 spec->ht.cap = in rt2800_probe_hw_mode()
11699 tx_chains = rt2x00dev->default_ant.tx_chain_num; in rt2800_probe_hw_mode()
11700 rx_chains = rt2x00dev->default_ant.rx_chain_num; in rt2800_probe_hw_mode()
11703 spec->ht.cap |= IEEE80211_HT_CAP_TX_STBC; in rt2800_probe_hw_mode()
11705 spec->ht.cap |= rx_chains << IEEE80211_HT_CAP_RX_STBC_SHIFT; in rt2800_probe_hw_mode()
11707 spec->ht.ampdu_factor = (rx_chains > 1) ? 3 : 2; in rt2800_probe_hw_mode()
11708 spec->ht.ampdu_density = 4; in rt2800_probe_hw_mode()
11709 spec->ht.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; in rt2800_probe_hw_mode()
11711 spec->ht.mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; in rt2800_probe_hw_mode()
11712 spec->ht.mcs.tx_params |= in rt2800_probe_hw_mode()
11713 (tx_chains - 1) << IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; in rt2800_probe_hw_mode()
11718 spec->ht.mcs.rx_mask[2] = 0xff; in rt2800_probe_hw_mode()
11721 spec->ht.mcs.rx_mask[1] = 0xff; in rt2800_probe_hw_mode()
11724 spec->ht.mcs.rx_mask[0] = 0xff; in rt2800_probe_hw_mode()
11725 spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */ in rt2800_probe_hw_mode()
11732 info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); in rt2800_probe_hw_mode()
11734 return -ENOMEM; in rt2800_probe_hw_mode()
11736 rt2x00dev->chan_survey = in rt2800_probe_hw_mode()
11737 kcalloc(spec->num_channels, sizeof(struct rt2x00_chan_survey), in rt2800_probe_hw_mode()
11739 if (!rt2x00dev->chan_survey) { in rt2800_probe_hw_mode()
11741 return -ENOMEM; in rt2800_probe_hw_mode()
11744 spec->channels_info = info; in rt2800_probe_hw_mode()
11749 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_probe_hw_mode()
11762 if (spec->num_channels > 14) { in rt2800_probe_hw_mode()
11768 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_probe_hw_mode()
11775 for (i = 14; i < spec->num_channels; i++) { in rt2800_probe_hw_mode()
11776 info[i].default_power1 = default_power1[i - 14]; in rt2800_probe_hw_mode()
11777 info[i].default_power2 = default_power2[i - 14]; in rt2800_probe_hw_mode()
11779 info[i].default_power3 = default_power3[i - 14]; in rt2800_probe_hw_mode()
11783 switch (rt2x00dev->chip.rf) { in rt2800_probe_hw_mode()
11803 __set_bit(CAPABILITY_VCO_RECALIBRATION, &rt2x00dev->cap_flags); in rt2800_probe_hw_mode()
11845 return -ENODEV; in rt2800_probe_rt()
11894 __set_bit(CAPABILITY_CONTROL_FILTERS, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11895 __set_bit(CAPABILITY_CONTROL_FILTER_PSPOLL, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11897 __set_bit(CAPABILITY_PRE_TBTT_INTERRUPT, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11903 __set_bit(REQUIRE_FIRMWARE, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11904 __set_bit(REQUIRE_L2PAD, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11905 __set_bit(REQUIRE_TXSTATUS_FIFO, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11907 __set_bit(CAPABILITY_HW_CRYPTO, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11908 __set_bit(CAPABILITY_LINK_TUNING, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11909 __set_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11911 __set_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11913 __set_bit(REQUIRE_DMA, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11914 __set_bit(REQUIRE_TASKLET_CONTEXT, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11918 __set_bit(CAPABILITY_RESTART_HW, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11919 rt2x00dev->link.watchdog_interval = msecs_to_jiffies(100); in rt2800_probe_hw()
11921 rt2x00dev->link.watchdog_disabled = true; in rt2800_probe_hw()
11927 rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET; in rt2800_probe_hw()
11940 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_key_seq()
11944 if (key->cipher != WLAN_CIPHER_SUITE_TKIP) in rt2800_get_key_seq()
11947 offset = MAC_IVEIV_ENTRY(key->hw_key_idx); in rt2800_get_key_seq()
11951 memcpy(&seq->tkip.iv16, &iveiv_entry.iv[0], 2); in rt2800_get_key_seq()
11952 memcpy(&seq->tkip.iv32, &iveiv_entry.iv[4], 4); in rt2800_get_key_seq()
11958 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_set_rts_threshold()
11999 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_conf_tx()
12031 rt2x00_set_field32(&reg, field, queue->txop); in rt2800_conf_tx()
12039 rt2x00_set_field32(&reg, field, queue->aifs); in rt2800_conf_tx()
12043 rt2x00_set_field32(&reg, field, queue->cw_min); in rt2800_conf_tx()
12047 rt2x00_set_field32(&reg, field, queue->cw_max); in rt2800_conf_tx()
12054 rt2x00_set_field32(&reg, EDCA_AC0_CFG_TX_OP, queue->txop); in rt2800_conf_tx()
12055 rt2x00_set_field32(&reg, EDCA_AC0_CFG_AIFSN, queue->aifs); in rt2800_conf_tx()
12056 rt2x00_set_field32(&reg, EDCA_AC0_CFG_CWMIN, queue->cw_min); in rt2800_conf_tx()
12057 rt2x00_set_field32(&reg, EDCA_AC0_CFG_CWMAX, queue->cw_max); in rt2800_conf_tx()
12066 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_tsf()
12082 struct ieee80211_sta *sta = params->sta; in rt2800_ampdu_action()
12083 enum ieee80211_ampdu_mlme_action action = params->action; in rt2800_ampdu_action()
12084 u16 tid = params->tid; in rt2800_ampdu_action()
12085 struct rt2x00_sta *sta_priv = (struct rt2x00_sta *)sta->drv_priv; in rt2800_ampdu_action()
12095 if (sta_priv->wcid > WCID_END) in rt2800_ampdu_action()
12096 return -ENOSPC; in rt2800_ampdu_action()
12114 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in rt2800_ampdu_action()
12119 rt2x00_warn((struct rt2x00_dev *)hw->priv, in rt2800_ampdu_action()
12130 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_survey()
12132 &rt2x00dev->chan_survey[idx]; in rt2800_get_survey()
12135 if (idx >= rt2x00dev->bands[band].n_channels) { in rt2800_get_survey()
12136 idx -= rt2x00dev->bands[band].n_channels; in rt2800_get_survey()
12140 if (idx >= rt2x00dev->bands[band].n_channels) in rt2800_get_survey()
12141 return -ENOENT; in rt2800_get_survey()
12146 survey->channel = &rt2x00dev->bands[band].channels[idx]; in rt2800_get_survey()
12148 survey->filled = SURVEY_INFO_TIME | in rt2800_get_survey()
12152 survey->time = div_u64(chan_survey->time_idle + chan_survey->time_busy, 1000); in rt2800_get_survey()
12153 survey->time_busy = div_u64(chan_survey->time_busy, 1000); in rt2800_get_survey()
12154 survey->time_ext_busy = div_u64(chan_survey->time_ext_busy, 1000); in rt2800_get_survey()
12156 if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) in rt2800_get_survey()
12157 survey->filled |= SURVEY_INFO_IN_USE; in rt2800_get_survey()