Lines Matching +full:upper +full:- +full:cal
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()
687 * Check if the chipset requires one of the upper parts in rt2800_check_firmware()
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, ®)) { 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(®, 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(®, 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(®, 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()
3788 /* RF for DC Cal BW */ 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()
3872 int cur_channel = rt2x00dev->rf_channel; in rt2800_config_alc_rt6352()
3884 power_level = (power_level - 3) * 2; in rt2800_config_alc_rt6352()
3895 power_level -= rate_power; in rt2800_config_alc_rt6352()
3902 chan_power = power_group[cnt][cur_channel - 1]; in rt2800_config_alc_rt6352()
3936 if (chan->center_freq > 2457) { in rt2800_config_alc_rt6352()
3966 for (chain = 0; chain < rt2x00dev->default_ant.rx_chain_num; chain++) { in rt2800_bbp_write_with_rx_chain()
3977 u8 cal; in rt2800_iq_calibrate() local
3982 cal = rt2x00_eeprom_byte(rt2x00dev, EEPROM_IQ_GAIN_CAL_TX0_2G); in rt2800_iq_calibrate()
3984 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
3987 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
3990 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
3993 cal = 0; in rt2800_iq_calibrate()
3994 rt2800_bbp_write(rt2x00dev, 159, cal); in rt2800_iq_calibrate()
3999 cal = rt2x00_eeprom_byte(rt2x00dev, EEPROM_IQ_PHASE_CAL_TX0_2G); in rt2800_iq_calibrate()
4001 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
4004 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
4007 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
4010 cal = 0; in rt2800_iq_calibrate()
4011 rt2800_bbp_write(rt2x00dev, 159, cal); in rt2800_iq_calibrate()
4016 cal = rt2x00_eeprom_byte(rt2x00dev, EEPROM_IQ_GAIN_CAL_TX1_2G); in rt2800_iq_calibrate()
4018 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
4021 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
4024 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
4027 cal = 0; in rt2800_iq_calibrate()
4028 rt2800_bbp_write(rt2x00dev, 159, cal); in rt2800_iq_calibrate()
4033 cal = rt2x00_eeprom_byte(rt2x00dev, EEPROM_IQ_PHASE_CAL_TX1_2G); in rt2800_iq_calibrate()
4035 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
4038 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
4041 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
4044 cal = 0; in rt2800_iq_calibrate()
4045 rt2800_bbp_write(rt2x00dev, 159, cal); in rt2800_iq_calibrate()
4051 cal = rt2x00_eeprom_byte(rt2x00dev, EEPROM_RF_IQ_COMPENSATION_CONTROL); in rt2800_iq_calibrate()
4052 rt2800_bbp_write(rt2x00dev, 159, cal != 0xff ? cal : 0); in rt2800_iq_calibrate()
4056 cal = rt2x00_eeprom_byte(rt2x00dev, in rt2800_iq_calibrate()
4058 rt2800_bbp_write(rt2x00dev, 159, cal != 0xff ? cal : 0); in rt2800_iq_calibrate()
4085 bbp = (rf->channel > 14) ? 0x48 : 0x38; in rt3883_bbp_adjust()
4090 if (rf->channel <= 14) { in rt3883_bbp_adjust()
4099 if (rf->channel > 14) { in rt3883_bbp_adjust()
4119 info->default_power1 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4120 info->default_power1); in rt2800_config_channel()
4121 info->default_power2 = rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4122 info->default_power2); in rt2800_config_channel()
4123 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_config_channel()
4124 info->default_power3 = in rt2800_config_channel()
4125 rt2800_txpower_to_dev(rt2x00dev, rf->channel, in rt2800_config_channel()
4126 info->default_power3); in rt2800_config_channel()
4128 switch (rt2x00dev->chip.rt) { in rt2800_config_channel()
4134 switch (rt2x00dev->chip.rf) { 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, 66, 0x26 + rt2x00dev->lna_gain); in rt2800_config_channel()
4218 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->lna_gain); in rt2800_config_channel()
4222 if (rf->channel > 14) { in rt2800_config_channel()
4234 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4235 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4236 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4239 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4240 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4241 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4243 if (rt2x00dev->default_ant.rx_chain_num > 1) in rt2800_config_channel()
4248 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4249 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4250 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->lna_gain); in rt2800_config_channel()
4257 if (rf->channel <= 14) { in rt2800_config_channel()
4298 rt2x00_set_field32(®, TX_BAND_CFG_A, rf->channel > 14); in rt2800_config_channel()
4299 rt2x00_set_field32(®, TX_BAND_CFG_BG, rf->channel <= 14); in rt2800_config_channel()
4312 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_config_channel()
4316 rf->channel > 14); in rt2800_config_channel()
4318 rf->channel <= 14); in rt2800_config_channel()
4323 rf->channel > 14); in rt2800_config_channel()
4325 rf->channel <= 14); in rt2800_config_channel()
4330 rf->channel > 14); in rt2800_config_channel()
4335 rf->channel <= 14); in rt2800_config_channel()
4339 switch (rt2x00dev->default_ant.rx_chain_num) { in rt2800_config_channel()
4366 if (rf->channel <= 14) in rt2800_config_channel()
4367 reg = 0x1c + (2 * rt2x00dev->lna_gain); in rt2800_config_channel()
4369 reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4382 if (rf->channel <= 14) in rt2800_config_channel()
4407 if (rf->channel <= 14) in rt2800_config_channel()
4408 reg = 0x1c + 2 * rt2x00dev->lna_gain; in rt2800_config_channel()
4410 reg = 0x22 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4424 if (rf->channel <= 14) in rt2800_config_channel()
4425 reg = 0x2e + rt2x00dev->lna_gain; in rt2800_config_channel()
4427 reg = 0x20 + ((rt2x00dev->lna_gain * 5) / 3); in rt2800_config_channel()
4452 reg = (rf->channel <= 14 ? 0x1c : 0x24) + 2*rt2x00dev->lna_gain; in rt2800_config_channel()
4456 rt2800_iq_calibrate(rt2x00dev, rf->channel); in rt2800_config_channel()
4461 &rt2x00dev->cap_flags)) { in rt2800_config_channel()
4556 * Matching Delta value -4 -3 -2 -1 0 +1 +2 +3 +4 in rt2800_get_gain_calibration_delta()
4559 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_get_gain_calibration_delta()
4644 for (i = 8; i >= 5; i--) { in rt2800_get_gain_calibration_delta()
4650 return (i - 4) * step; in rt2800_get_gain_calibration_delta()
4667 !test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_get_txpower_bw_comp()
4679 comp_value = -comp_value; in rt2800_get_txpower_bw_comp()
4690 comp_value = -comp_value; in rt2800_get_txpower_bw_comp()
4714 delta = power_level - max_power; in rt2800_get_txpower_reg_delta()
4757 eirp_txpower = eirp_txpower_criterion + (txpower - criterion) + in rt2800_compensate_txpower()
4761 (eirp_txpower - power_level) : 0; in rt2800_compensate_txpower()
4765 txpower = max(0, txpower + delta - reg_limit); in rt2800_compensate_txpower()
4797 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt3593()
4813 if (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_config_txpower_rt3593()
5167 (test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) ? in rt2800_config_txpower_rt3593()
5170 (i - TX_PWR_CFG_9_IDX - 1) : i, in rt2800_config_txpower_rt3593()
5183 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt6352()
5196 * Maybe some misunderstanding of what a signed 8-bit value is? Maybe in rt2800_config_txpower_rt6352()
5198 * used a fixed offset between HT20 and HT40 rates they had to work- in rt2800_config_txpower_rt6352()
5243 if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) { in rt2800_config_txpower_rt6352()
5260 * registers. As recent 2T chips use 8-bit instead of 4-bit values for in rt2800_config_txpower_rt6352()
5261 * power-offsets more space would be needed. Ralink decided to keep the in rt2800_config_txpower_rt6352()
5303 * for all rates, but allow to set only 4 discrete values: -12, -6, 0 and 6 dBm.
5316 enum nl80211_band band = chan->band; in rt2800_config_txpower_rt28xx()
5331 switch (rt2x00dev->chip.rt) { in rt2800_config_txpower_rt28xx()
5352 chan->max_power); in rt2800_config_txpower_rt28xx()
5356 * gains -12, -6, 0, +6 dBm by setting values 2, 1, 0, 3 respectively. in rt2800_config_txpower_rt28xx()
5362 if (delta <= -12) { in rt2800_config_txpower_rt28xx()
5365 } else if (delta <= -6) { in rt2800_config_txpower_rt28xx()
5506 rt2800_config_txpower(rt2x00dev, rt2x00dev->hw->conf.chandef.chan, in rt2800_gain_calibration()
5507 rt2x00dev->tx_power); in rt2800_gain_calibration()
5518 * A voltage-controlled oscillator(VCO) is an electronic oscillator in rt2800_vco_calibration()
5529 switch (rt2x00dev->chip.rf) { in rt2800_vco_calibration()
5567 rt2x00dev->chip.rf); in rt2800_vco_calibration()
5575 if (rt2x00dev->rf_channel <= 14) { in rt2800_vco_calibration()
5576 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_vco_calibration()
5589 switch (rt2x00dev->default_ant.tx_chain_num) { in rt2800_vco_calibration()
5605 if (rt2x00dev->default_ant.rx_chain_num == 1) { in rt2800_vco_calibration()
5635 * 2005/06/05 - On 11G, we also need this delay time. in rt2800_vco_calibration()
5650 libconf->conf->short_frame_max_tx_count); in rt2800_config_retry_limit()
5652 libconf->conf->long_frame_max_tx_count); in rt2800_config_retry_limit()
5660 (libconf->conf->flags & IEEE80211_CONF_PS) ? in rt2800_config_ps()
5670 libconf->conf->listen_interval - 1); in rt2800_config_ps()
5674 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); in rt2800_config_ps()
5682 rt2x00dev->ops->lib->set_device_state(rt2x00dev, state); in rt2800_config_ps()
5695 * To provide correct survey data for survey-based ACS algorithm in rt2800_config()
5700 rt2800_config_channel(rt2x00dev, libconf->conf, in rt2800_config()
5701 &libconf->rf, &libconf->channel); in rt2800_config()
5702 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, in rt2800_config()
5703 libconf->conf->power_level); in rt2800_config()
5706 rt2800_config_txpower(rt2x00dev, libconf->conf->chandef.chan, in rt2800_config()
5707 libconf->conf->power_level); in rt2800_config()
5726 qual->rx_failed = rt2x00_get_field32(reg, RX_STA_CNT0_CRC_ERR); in rt2800_link_stats()
5734 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) { in rt2800_get_default_vgc()
5746 vgc = 0x1c + (2 * rt2x00dev->lna_gain); in rt2800_get_default_vgc()
5748 vgc = 0x2e + rt2x00dev->lna_gain; in rt2800_get_default_vgc()
5752 vgc = 0x20 + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5754 vgc = 0x24 + (2 * rt2x00dev->lna_gain); in rt2800_get_default_vgc()
5756 if (!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)) in rt2800_get_default_vgc()
5757 vgc = 0x32 + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5759 vgc = 0x3a + (rt2x00dev->lna_gain * 5) / 3; in rt2800_get_default_vgc()
5769 if (qual->vgc_level != vgc_level) { in rt2800_set_vgc()
5777 rt2800_bbp_write(rt2x00dev, 83, qual->rssi > -65 ? 0x4a : 0x7a); in rt2800_set_vgc()
5783 qual->vgc_level = vgc_level; in rt2800_set_vgc()
5784 qual->vgc_level_reg = vgc_level; in rt2800_set_vgc()
5809 switch (rt2x00dev->chip.rt) { in rt2800_link_tuner()
5812 if (qual->rssi > -65) { in rt2800_link_tuner()
5813 if (rt2x00dev->curr_band == NL80211_BAND_2GHZ) in rt2800_link_tuner()
5821 if (qual->rssi > -65) in rt2800_link_tuner()
5826 if (qual->rssi > -65) in rt2800_link_tuner()
5831 if (qual->rssi > -80) in rt2800_link_tuner()
5845 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_init_registers()
6035 drv_data->max_psdu = 3; in rt2800_init_registers()
6039 drv_data->max_psdu = 2; in rt2800_init_registers()
6041 drv_data->max_psdu = 1; in rt2800_init_registers()
6043 rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, drv_data->max_psdu); in rt2800_init_registers()
6240 if (!test_bit(DEVICE_STATE_RESET, &rt2x00dev->flags)) in rt2800_init_registers()
6612 /* Use 5-bit ADC for Acquisition and 8-bit ADC for data */ in rt2800_init_bbp_3290()
6962 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_init_bbp_5592()
7033 rt2x00dev->default_ant.rx_chain_num == 2); in rt2800_init_bbp_6352()
7240 switch (rt2x00dev->chip.rt) { in rt2800_init_bbp()
7353 if ((passband - stopband) <= filter_target) { in rt2800_init_rx_filter()
7355 overtuned += ((passband - stopband) == filter_target); in rt2800_init_rx_filter()
7362 rfcsr24 -= !!overtuned; in rt2800_init_rx_filter()
7383 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_rx_filter_calibration()
7399 drv_data->calibration_bw20 = in rt2800_rx_filter_calibration()
7401 drv_data->calibration_bw40 = in rt2800_rx_filter_calibration()
7407 drv_data->bbp25 = rt2800_bbp_read(rt2x00dev, 25); in rt2800_rx_filter_calibration()
7408 drv_data->bbp26 = rt2800_bbp_read(rt2x00dev, 26); in rt2800_rx_filter_calibration()
7429 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_normal_mode_setup_3xxx()
7445 if (drv_data->txmixer_gain_24g >= min_gain) { in rt2800_normal_mode_setup_3xxx()
7447 drv_data->txmixer_gain_24g); in rt2800_normal_mode_setup_3xxx()
7500 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_normal_mode_setup_3593()
7509 tx_gain = rt2x00_get_field8(drv_data->txmixer_gain_24g, in rt2800_normal_mode_setup_3593()
7735 &rt2x00dev->cap_flags); in rt2800_init_rfcsr_3352()
7737 &rt2x00dev->cap_flags); in rt2800_init_rfcsr_3352()
7947 if (rt2x00dev->default_ant.rx_chain_num == 1) in rt3593_post_bbp_init()
7990 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_init_rfcsr_3593()
8056 drv_data->calibration_bw20 = 0x1f; in rt2800_init_rfcsr_3593()
8057 drv_data->calibration_bw40 = 0x2f; in rt2800_init_rfcsr_3593()
8060 drv_data->bbp25 = rt2800_bbp_read(rt2x00dev, 25); in rt2800_init_rfcsr_3593()
8061 drv_data->bbp26 = rt2800_bbp_read(rt2x00dev, 26); in rt2800_init_rfcsr_3593()
8537 int calcode = ((d2 - d1) * 1000) / 43; in rt2800_calcrcalibrationcode()
8615 d1 = bytevalue - 256; in rt2800_r_calibration()
8625 d2 = bytevalue - 256; in rt2800_r_calibration()
8733 for (i = 15; i >= 0; i = i - 1) { in rt2800_do_sqrt_accumulation()
8799 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) in rt2800_rxiq_calibration()
8859 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_rxiq_calibration()
8949 result = (bbptemp & 0xffffff) - 0x1000000; in rt2800_rxiq_calibration()
8965 bbpval1 = si - mi * mi; in rt2800_rxiq_calibration()
8993 sigma_i = rt2800_do_sqrt_accumulation(100 * (si - mi * mi)); in rt2800_rxiq_calibration()
8994 sigma_q = rt2800_do_sqrt_accumulation(100 * (sq - mq * mq)); in rt2800_rxiq_calibration()
8995 r_iq = 10 * (riq - (mi * mq)); in rt2800_rxiq_calibration()
9000 (sigma_i - sigma_q) <= 112 && in rt2800_rxiq_calibration()
9001 (sigma_i - sigma_q) >= -112 && in rt2800_rxiq_calibration()
9002 mi <= 32 && mi >= -32 && in rt2800_rxiq_calibration()
9003 mq <= 32 && mq >= -32) { in rt2800_rxiq_calibration()
9004 r_iq = 10 * (riq - (mi * mq)); in rt2800_rxiq_calibration()
9009 g_imb = ((-2) * 128 * (1000 - g_rx)) / (1000 + g_rx); in rt2800_rxiq_calibration()
9012 if (ph_rx > 20 || ph_rx < -20) { in rt2800_rxiq_calibration()
9017 if (g_imb > 12 || g_imb < -12) { in rt2800_rxiq_calibration()
9276 fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; in rt2800_do_fft_accumulation()
9278 fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; in rt2800_do_fft_accumulation()
9285 tidxi = 0x40 - tidx; in rt2800_do_fft_accumulation()
9296 fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; in rt2800_do_fft_accumulation()
9298 fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; in rt2800_do_fft_accumulation()
9322 fftout_i = (fftout_i & 0x8000) ? (fftout_i - 0x10000) : fftout_i; in rt2800_read_fft_accumulation()
9324 fftout_q = (fftout_q & 0x8000) ? (fftout_q - 0x10000) : fftout_q; in rt2800_read_fft_accumulation()
9363 for (bidx = 5; bidx >= 0; bidx--) { in rt2800_loft_search()
9369 idx0 = idxf[iorq] - ibit; in rt2800_loft_search()
9420 for (bidx = 5; bidx >= 1; bidx--) { in rt2800_iq_search()
9436 idx0 = iq_err - ibit; in rt2800_iq_search()
9490 gerr = (gerr & 0x08) ? (gerr & 0x0F) - 0x10 : (gerr & 0x0F); in rt2800_iq_search()
9491 perr = (perr & 0x20) ? (perr & 0x3F) - 0x40 : (perr & 0x3F); in rt2800_iq_search()
9493 gerr = (gerr < -0x07) ? -0x07 : (gerr > 0x05) ? 0x05 : gerr; in rt2800_iq_search()
9494 gsta = gerr - 1; in rt2800_iq_search()
9497 perr = (perr < -0x1f) ? -0x1f : (perr > 0x1d) ? 0x1d : perr; in rt2800_iq_search()
9498 psta = perr - 1; in rt2800_iq_search()
9684 vga_gain[ch_idx] = vga_gain[ch_idx] - 2) { in rt2800_loft_iq_calibration()
9808 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9816 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9835 if (!test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9860 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9870 if (test_bit(CAPABILITY_EXTERNAL_PA_TX1, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9886 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9905 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) in rt2800_loft_iq_calibration()
9912 if (test_bit(CAPABILITY_EXTERNAL_PA_TX1, &rt2x00dev->cap_flags)) in rt2800_loft_iq_calibration()
9917 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9921 vga_gain[ch_idx] = vga_gain[ch_idx] - 1; in rt2800_loft_iq_calibration()
9962 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) { in rt2800_loft_iq_calibration()
9978 if (test_bit(CAPABILITY_EXTERNAL_PA_TX0, &rt2x00dev->cap_flags)) in rt2800_loft_iq_calibration()
10088 cal_val -= 128; in rt2800_lp_tx_filter_bw_cal()
10096 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_bw_filter_calibration()
10173 /* I-3 */ in rt2800_bw_filter_calibration()
10180 /* I-4,5,6,7,8,9 */ in rt2800_bw_filter_calibration()
10265 cal_diff = cal_r32_init - cal_r32_val; in rt2800_bw_filter_calibration()
10288 drv_data->tx_calibration_bw20 = tx_agc_fc; in rt2800_bw_filter_calibration()
10290 drv_data->tx_calibration_bw40 = tx_agc_fc; in rt2800_bw_filter_calibration()
10293 drv_data->rx_calibration_bw20 = rx_agc_fc; in rt2800_bw_filter_calibration()
10295 drv_data->rx_calibration_bw40 = rx_agc_fc; in rt2800_bw_filter_calibration()
10335 2 * test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags)); in rt2800_bw_filter_calibration()
10357 rt2800_rfcsr_write(rt2x00dev, 12, rt2x00dev->freq_offset); in rt2800_init_rfcsr_6352()
10622 switch (rt2x00dev->chip.rt) { in rt2800_init_rfcsr()
10674 return -EIO; in rt2800_enable_radio()
10680 return -EIO; in rt2800_enable_radio()
10696 return -EIO; in rt2800_enable_radio()
10806 mutex_lock(&rt2x00dev->csr_mutex); in rt2800_efuse_read()
10819 *(u32 *)&rt2x00dev->eeprom[i] = cpu_to_le32(reg); in rt2800_efuse_read()
10821 *(u32 *)&rt2x00dev->eeprom[i + 2] = cpu_to_le32(reg); in rt2800_efuse_read()
10823 *(u32 *)&rt2x00dev->eeprom[i + 4] = cpu_to_le32(reg); in rt2800_efuse_read()
10825 *(u32 *)&rt2x00dev->eeprom[i + 6] = cpu_to_le32(reg); in rt2800_efuse_read()
10827 mutex_unlock(&rt2x00dev->csr_mutex); in rt2800_efuse_read()
10873 struct rt2800_drv_data *drv_data = rt2x00dev->drv_data; in rt2800_validate_eeprom()
10962 drv_data->txmixer_gain_24g = rt2800_get_txmixer_gain_24g(rt2x00dev); in rt2800_validate_eeprom()
10976 drv_data->txmixer_gain_5g = rt2800_get_txmixer_gain_5g(rt2x00dev); in rt2800_validate_eeprom()
11075 return -ENODEV; in rt2800_init_eeprom()
11083 rt2x00dev->default_ant.tx_chain_num = in rt2800_init_eeprom()
11085 rt2x00dev->default_ant.rx_chain_num = in rt2800_init_eeprom()
11100 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
11101 rt2x00dev->default_ant.rx = ANTENNA_A; in rt2800_init_eeprom()
11104 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
11105 rt2x00dev->default_ant.rx = ANTENNA_B; in rt2800_init_eeprom()
11109 rt2x00dev->default_ant.tx = ANTENNA_A; in rt2800_init_eeprom()
11110 rt2x00dev->default_ant.rx = ANTENNA_A; in rt2800_init_eeprom()
11116 rt2x00dev->default_ant.tx = ANTENNA_HW_DIVERSITY; /* Unused */ in rt2800_init_eeprom()
11117 rt2x00dev->default_ant.rx = ANTENNA_HW_DIVERSITY; /* Unused */ in rt2800_init_eeprom()
11124 __set_bit(CAPABILITY_EXTERNAL_LNA_A, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11126 __set_bit(CAPABILITY_EXTERNAL_LNA_BG, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11132 __set_bit(CAPABILITY_HW_BUTTON, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11135 * Detect if this device has Bluetooth co-existence. in rt2800_init_eeprom()
11139 __set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11145 rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET); in rt2800_init_eeprom()
11151 rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); in rt2800_init_eeprom()
11152 rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); in rt2800_init_eeprom()
11153 rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY); in rt2800_init_eeprom()
11155 rt2x00dev->led_mcu_reg = eeprom; in rt2800_init_eeprom()
11165 __set_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11177 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11181 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11190 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11192 &rt2x00dev->cap_flags); in rt2800_init_eeprom()
11572 struct hw_mode_spec *spec = &rt2x00dev->spec; in rt2800_probe_hw_mode()
11583 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; in rt2800_probe_hw_mode()
11589 rt2x00dev->hw->wiphy->retry_short = 2; in rt2800_probe_hw_mode()
11590 rt2x00dev->hw->wiphy->retry_long = 2; in rt2800_probe_hw_mode()
11595 ieee80211_hw_set(rt2x00dev->hw, REPORTS_TX_ACK_STATUS); in rt2800_probe_hw_mode()
11596 ieee80211_hw_set(rt2x00dev->hw, AMPDU_AGGREGATION); in rt2800_probe_hw_mode()
11597 ieee80211_hw_set(rt2x00dev->hw, PS_NULLFUNC_STACK); in rt2800_probe_hw_mode()
11598 ieee80211_hw_set(rt2x00dev->hw, SIGNAL_DBM); in rt2800_probe_hw_mode()
11599 ieee80211_hw_set(rt2x00dev->hw, SUPPORTS_PS); in rt2800_probe_hw_mode()
11609 ieee80211_hw_set(rt2x00dev->hw, HOST_BROADCAST_PS_BUFFERING); in rt2800_probe_hw_mode()
11611 ieee80211_hw_set(rt2x00dev->hw, MFP_CAPABLE); in rt2800_probe_hw_mode()
11613 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); in rt2800_probe_hw_mode()
11614 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, in rt2800_probe_hw_mode()
11627 rt2x00dev->hw->max_rates = 1; in rt2800_probe_hw_mode()
11628 rt2x00dev->hw->max_report_rates = 7; in rt2800_probe_hw_mode()
11629 rt2x00dev->hw->max_rate_tries = 1; in rt2800_probe_hw_mode()
11634 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; in rt2800_probe_hw_mode()
11636 switch (rt2x00dev->chip.rf) { in rt2800_probe_hw_mode()
11639 spec->num_channels = 14; in rt2800_probe_hw_mode()
11640 spec->channels = rf_vals; in rt2800_probe_hw_mode()
11645 spec->num_channels = ARRAY_SIZE(rf_vals); in rt2800_probe_hw_mode()
11646 spec->channels = rf_vals; in rt2800_probe_hw_mode()
11664 spec->num_channels = 14; in rt2800_probe_hw_mode()
11666 spec->channels = rf_vals_3x_xtal20; in rt2800_probe_hw_mode()
11668 spec->channels = rf_vals_3x; in rt2800_probe_hw_mode()
11672 spec->num_channels = ARRAY_SIZE(rf_vals_7620); in rt2800_probe_hw_mode()
11673 spec->channels = rf_vals_7620; in rt2800_probe_hw_mode()
11678 spec->num_channels = ARRAY_SIZE(rf_vals_3x); in rt2800_probe_hw_mode()
11679 spec->channels = rf_vals_3x; in rt2800_probe_hw_mode()
11683 spec->num_channels = ARRAY_SIZE(rf_vals_3853); in rt2800_probe_hw_mode()
11684 spec->channels = rf_vals_3853; in rt2800_probe_hw_mode()
11690 spec->num_channels = ARRAY_SIZE(rf_vals_5592_xtal40); in rt2800_probe_hw_mode()
11691 spec->channels = rf_vals_5592_xtal40; in rt2800_probe_hw_mode()
11693 spec->num_channels = ARRAY_SIZE(rf_vals_5592_xtal20); in rt2800_probe_hw_mode()
11694 spec->channels = rf_vals_5592_xtal20; in rt2800_probe_hw_mode()
11699 if (WARN_ON_ONCE(!spec->channels)) in rt2800_probe_hw_mode()
11700 return -ENODEV; in rt2800_probe_hw_mode()
11702 spec->supported_bands = SUPPORT_BAND_2GHZ; in rt2800_probe_hw_mode()
11703 if (spec->num_channels > 14) in rt2800_probe_hw_mode()
11704 spec->supported_bands |= SUPPORT_BAND_5GHZ; in rt2800_probe_hw_mode()
11710 spec->ht.ht_supported = true; in rt2800_probe_hw_mode()
11712 spec->ht.ht_supported = false; in rt2800_probe_hw_mode()
11714 spec->ht.cap = in rt2800_probe_hw_mode()
11720 tx_chains = rt2x00dev->default_ant.tx_chain_num; in rt2800_probe_hw_mode()
11721 rx_chains = rt2x00dev->default_ant.rx_chain_num; in rt2800_probe_hw_mode()
11724 spec->ht.cap |= IEEE80211_HT_CAP_TX_STBC; in rt2800_probe_hw_mode()
11726 spec->ht.cap |= rx_chains << IEEE80211_HT_CAP_RX_STBC_SHIFT; in rt2800_probe_hw_mode()
11728 spec->ht.ampdu_factor = (rx_chains > 1) ? 3 : 2; in rt2800_probe_hw_mode()
11729 spec->ht.ampdu_density = 4; in rt2800_probe_hw_mode()
11730 spec->ht.mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; in rt2800_probe_hw_mode()
11732 spec->ht.mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; in rt2800_probe_hw_mode()
11733 spec->ht.mcs.tx_params |= in rt2800_probe_hw_mode()
11734 (tx_chains - 1) << IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; in rt2800_probe_hw_mode()
11739 spec->ht.mcs.rx_mask[2] = 0xff; in rt2800_probe_hw_mode()
11742 spec->ht.mcs.rx_mask[1] = 0xff; in rt2800_probe_hw_mode()
11745 spec->ht.mcs.rx_mask[0] = 0xff; in rt2800_probe_hw_mode()
11746 spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */ in rt2800_probe_hw_mode()
11753 info = kcalloc(spec->num_channels, sizeof(*info), GFP_KERNEL); in rt2800_probe_hw_mode()
11755 return -ENOMEM; in rt2800_probe_hw_mode()
11757 rt2x00dev->chan_survey = in rt2800_probe_hw_mode()
11758 kcalloc(spec->num_channels, sizeof(struct rt2x00_chan_survey), in rt2800_probe_hw_mode()
11760 if (!rt2x00dev->chan_survey) { in rt2800_probe_hw_mode()
11762 return -ENOMEM; in rt2800_probe_hw_mode()
11765 spec->channels_info = info; in rt2800_probe_hw_mode()
11770 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_probe_hw_mode()
11783 if (spec->num_channels > 14) { in rt2800_probe_hw_mode()
11789 if (rt2x00dev->default_ant.tx_chain_num > 2) in rt2800_probe_hw_mode()
11796 for (i = 14; i < spec->num_channels; i++) { in rt2800_probe_hw_mode()
11797 info[i].default_power1 = default_power1[i - 14]; in rt2800_probe_hw_mode()
11798 info[i].default_power2 = default_power2[i - 14]; in rt2800_probe_hw_mode()
11800 info[i].default_power3 = default_power3[i - 14]; in rt2800_probe_hw_mode()
11804 switch (rt2x00dev->chip.rf) { in rt2800_probe_hw_mode()
11824 __set_bit(CAPABILITY_VCO_RECALIBRATION, &rt2x00dev->cap_flags); in rt2800_probe_hw_mode()
11866 return -ENODEV; in rt2800_probe_rt()
11915 __set_bit(CAPABILITY_CONTROL_FILTERS, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11916 __set_bit(CAPABILITY_CONTROL_FILTER_PSPOLL, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11918 __set_bit(CAPABILITY_PRE_TBTT_INTERRUPT, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11924 __set_bit(REQUIRE_FIRMWARE, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11925 __set_bit(REQUIRE_L2PAD, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11926 __set_bit(REQUIRE_TXSTATUS_FIFO, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11928 __set_bit(CAPABILITY_HW_CRYPTO, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11929 __set_bit(CAPABILITY_LINK_TUNING, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11930 __set_bit(REQUIRE_HT_TX_DESC, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11932 __set_bit(REQUIRE_PS_AUTOWAKE, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11934 __set_bit(REQUIRE_DMA, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11935 __set_bit(REQUIRE_TASKLET_CONTEXT, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11939 __set_bit(CAPABILITY_RESTART_HW, &rt2x00dev->cap_flags); in rt2800_probe_hw()
11940 rt2x00dev->link.watchdog_interval = msecs_to_jiffies(100); in rt2800_probe_hw()
11942 rt2x00dev->link.watchdog_disabled = true; in rt2800_probe_hw()
11948 rt2x00dev->rssi_offset = DEFAULT_RSSI_OFFSET; in rt2800_probe_hw()
11961 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_key_seq()
11965 if (key->cipher != WLAN_CIPHER_SUITE_TKIP) in rt2800_get_key_seq()
11968 offset = MAC_IVEIV_ENTRY(key->hw_key_idx); in rt2800_get_key_seq()
11972 memcpy(&seq->tkip.iv16, &iveiv_entry.iv[0], 2); in rt2800_get_key_seq()
11973 memcpy(&seq->tkip.iv32, &iveiv_entry.iv[4], 4); in rt2800_get_key_seq()
11979 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_set_rts_threshold()
12020 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_conf_tx()
12052 rt2x00_set_field32(®, field, queue->txop); in rt2800_conf_tx()
12060 rt2x00_set_field32(®, field, queue->aifs); in rt2800_conf_tx()
12064 rt2x00_set_field32(®, field, queue->cw_min); in rt2800_conf_tx()
12068 rt2x00_set_field32(®, field, queue->cw_max); in rt2800_conf_tx()
12075 rt2x00_set_field32(®, EDCA_AC0_CFG_TX_OP, queue->txop); in rt2800_conf_tx()
12076 rt2x00_set_field32(®, EDCA_AC0_CFG_AIFSN, queue->aifs); in rt2800_conf_tx()
12077 rt2x00_set_field32(®, EDCA_AC0_CFG_CWMIN, queue->cw_min); in rt2800_conf_tx()
12078 rt2x00_set_field32(®, EDCA_AC0_CFG_CWMAX, queue->cw_max); in rt2800_conf_tx()
12087 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_tsf()
12103 struct ieee80211_sta *sta = params->sta; in rt2800_ampdu_action()
12104 enum ieee80211_ampdu_mlme_action action = params->action; in rt2800_ampdu_action()
12105 u16 tid = params->tid; in rt2800_ampdu_action()
12106 struct rt2x00_sta *sta_priv = (struct rt2x00_sta *)sta->drv_priv; in rt2800_ampdu_action()
12116 if (sta_priv->wcid > WCID_END) in rt2800_ampdu_action()
12117 return -ENOSPC; in rt2800_ampdu_action()
12135 ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid); in rt2800_ampdu_action()
12140 rt2x00_warn((struct rt2x00_dev *)hw->priv, in rt2800_ampdu_action()
12151 struct rt2x00_dev *rt2x00dev = hw->priv; in rt2800_get_survey()
12153 &rt2x00dev->chan_survey[idx]; in rt2800_get_survey()
12156 if (idx >= rt2x00dev->bands[band].n_channels) { in rt2800_get_survey()
12157 idx -= rt2x00dev->bands[band].n_channels; in rt2800_get_survey()
12161 if (idx >= rt2x00dev->bands[band].n_channels) in rt2800_get_survey()
12162 return -ENOENT; in rt2800_get_survey()
12167 survey->channel = &rt2x00dev->bands[band].channels[idx]; in rt2800_get_survey()
12169 survey->filled = SURVEY_INFO_TIME | in rt2800_get_survey()
12173 survey->time = div_u64(chan_survey->time_idle + chan_survey->time_busy, 1000); in rt2800_get_survey()
12174 survey->time_busy = div_u64(chan_survey->time_busy, 1000); in rt2800_get_survey()
12175 survey->time_ext_busy = div_u64(chan_survey->time_ext_busy, 1000); in rt2800_get_survey()
12177 if (!(hw->conf.flags & IEEE80211_CONF_OFFCHANNEL)) in rt2800_get_survey()
12178 survey->filled |= SURVEY_INFO_IN_USE; in rt2800_get_survey()