465
472
test_bit(ENTRY_TXD_REQ_TIMESTAMP, &txdesc->flags));
466
473
rt2x00_set_field32(&word, TXWI_W0_AMPDU,
467
474
test_bit(ENTRY_TXD_HT_AMPDU, &txdesc->flags));
468
rt2x00_set_field32(&word, TXWI_W0_MPDU_DENSITY, txdesc->mpdu_density);
469
rt2x00_set_field32(&word, TXWI_W0_TX_OP, txdesc->txop);
470
rt2x00_set_field32(&word, TXWI_W0_MCS, txdesc->mcs);
475
rt2x00_set_field32(&word, TXWI_W0_MPDU_DENSITY,
476
txdesc->u.ht.mpdu_density);
477
rt2x00_set_field32(&word, TXWI_W0_TX_OP, txdesc->u.ht.txop);
478
rt2x00_set_field32(&word, TXWI_W0_MCS, txdesc->u.ht.mcs);
471
479
rt2x00_set_field32(&word, TXWI_W0_BW,
472
480
test_bit(ENTRY_TXD_HT_BW_40, &txdesc->flags));
473
481
rt2x00_set_field32(&word, TXWI_W0_SHORT_GI,
474
482
test_bit(ENTRY_TXD_HT_SHORT_GI, &txdesc->flags));
475
rt2x00_set_field32(&word, TXWI_W0_STBC, txdesc->stbc);
483
rt2x00_set_field32(&word, TXWI_W0_STBC, txdesc->u.ht.stbc);
476
484
rt2x00_set_field32(&word, TXWI_W0_PHYMODE, txdesc->rate_mode);
477
485
rt2x00_desc_write(txwi, 0, word);
905
935
unsigned int ledmode =
906
936
rt2x00_get_field16(led->rt2x00dev->led_mcu_reg,
907
937
EEPROM_FREQ_LED_MODE);
909
if (led->type == LED_TYPE_RADIO) {
910
rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
912
} else if (led->type == LED_TYPE_ASSOC) {
913
rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
914
enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20);
915
} else if (led->type == LED_TYPE_QUALITY) {
917
* The brightness is divided into 6 levels (0 - 5),
918
* The specs tell us the following levels:
920
* to determine the level in a simple way we can simply
921
* work with bitshifting:
924
rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff,
925
(1 << brightness / (LED_FULL / 6)) - 1,
940
/* Check for SoC (SOC devices don't support MCU requests) */
941
if (rt2x00_is_soc(led->rt2x00dev)) {
942
rt2800_register_read(led->rt2x00dev, LED_CFG, ®);
944
/* Set LED Polarity */
945
rt2x00_set_field32(®, LED_CFG_LED_POLAR, polarity);
948
if (led->type == LED_TYPE_RADIO) {
949
rt2x00_set_field32(®, LED_CFG_G_LED_MODE,
951
} else if (led->type == LED_TYPE_ASSOC) {
952
rt2x00_set_field32(®, LED_CFG_Y_LED_MODE,
954
} else if (led->type == LED_TYPE_QUALITY) {
955
rt2x00_set_field32(®, LED_CFG_R_LED_MODE,
959
rt2800_register_write(led->rt2x00dev, LED_CFG, reg);
962
if (led->type == LED_TYPE_RADIO) {
963
rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
965
} else if (led->type == LED_TYPE_ASSOC) {
966
rt2800_mcu_request(led->rt2x00dev, MCU_LED, 0xff, ledmode,
967
enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20);
968
} else if (led->type == LED_TYPE_QUALITY) {
970
* The brightness is divided into 6 levels (0 - 5),
971
* The specs tell us the following levels:
973
* to determine the level in a simple way we can simply
974
* work with bitshifting:
977
rt2800_mcu_request(led->rt2x00dev, MCU_LED_STRENGTH, 0xff,
978
(1 << brightness / (LED_FULL / 6)) - 1,
1156
1227
if (flags & CONFIG_UPDATE_TYPE) {
1158
* Clear current synchronisation setup.
1160
rt2800_clear_beacon(rt2x00dev,
1161
HW_BEACON_OFFSET(intf->beacon->entry_idx));
1163
1229
* Enable synchronisation.
1165
1231
rt2800_register_read(rt2x00dev, BCN_TIME_CFG, ®);
1166
rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 1);
1167
1232
rt2x00_set_field32(®, BCN_TIME_CFG_TSF_SYNC, conf->sync);
1168
rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE,
1169
(conf->sync == TSF_SYNC_ADHOC ||
1170
conf->sync == TSF_SYNC_AP_NONE));
1171
1233
rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg);
1174
* Enable pre tbtt interrupt for beaconing modes
1176
rt2800_register_read(rt2x00dev, INT_TIMER_EN, ®);
1177
rt2x00_set_field32(®, INT_TIMER_EN_PRE_TBTT_TIMER,
1178
(conf->sync == TSF_SYNC_AP_NONE));
1179
rt2800_register_write(rt2x00dev, INT_TIMER_EN, reg);
1235
if (conf->sync == TSF_SYNC_AP_NONE) {
1237
* Tune beacon queue transmit parameters for AP mode
1239
rt2800_register_read(rt2x00dev, TBTT_SYNC_CFG, ®);
1240
rt2x00_set_field32(®, TBTT_SYNC_CFG_BCN_CWMIN, 0);
1241
rt2x00_set_field32(®, TBTT_SYNC_CFG_BCN_AIFSN, 1);
1242
rt2x00_set_field32(®, TBTT_SYNC_CFG_BCN_EXP_WIN, 32);
1243
rt2x00_set_field32(®, TBTT_SYNC_CFG_TBTT_ADJUST, 0);
1244
rt2800_register_write(rt2x00dev, TBTT_SYNC_CFG, reg);
1246
rt2800_register_read(rt2x00dev, TBTT_SYNC_CFG, ®);
1247
rt2x00_set_field32(®, TBTT_SYNC_CFG_BCN_CWMIN, 4);
1248
rt2x00_set_field32(®, TBTT_SYNC_CFG_BCN_AIFSN, 2);
1249
rt2x00_set_field32(®, TBTT_SYNC_CFG_BCN_EXP_WIN, 32);
1250
rt2x00_set_field32(®, TBTT_SYNC_CFG_TBTT_ADJUST, 16);
1251
rt2800_register_write(rt2x00dev, TBTT_SYNC_CFG, reg);
1183
1255
if (flags & CONFIG_UPDATE_MAC) {
1526
1630
rt2800_rfcsr_write(rt2x00dev, 7, rfcsr);
1634
#define RT5390_POWER_BOUND 0x27
1635
#define RT5390_FREQ_OFFSET_BOUND 0x5f
1637
static void rt2800_config_channel_rf53xx(struct rt2x00_dev *rt2x00dev,
1638
struct ieee80211_conf *conf,
1639
struct rf_channel *rf,
1640
struct channel_info *info)
1644
rt2800_rfcsr_write(rt2x00dev, 8, rf->rf1);
1645
rt2800_rfcsr_write(rt2x00dev, 9, rf->rf3);
1646
rt2800_rfcsr_read(rt2x00dev, 11, &rfcsr);
1647
rt2x00_set_field8(&rfcsr, RFCSR11_R, rf->rf2);
1648
rt2800_rfcsr_write(rt2x00dev, 11, rfcsr);
1650
rt2800_rfcsr_read(rt2x00dev, 49, &rfcsr);
1651
if (info->default_power1 > RT5390_POWER_BOUND)
1652
rt2x00_set_field8(&rfcsr, RFCSR49_TX, RT5390_POWER_BOUND);
1654
rt2x00_set_field8(&rfcsr, RFCSR49_TX, info->default_power1);
1655
rt2800_rfcsr_write(rt2x00dev, 49, rfcsr);
1657
rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr);
1658
rt2x00_set_field8(&rfcsr, RFCSR1_RF_BLOCK_EN, 1);
1659
rt2x00_set_field8(&rfcsr, RFCSR1_PLL_PD, 1);
1660
rt2x00_set_field8(&rfcsr, RFCSR1_RX0_PD, 1);
1661
rt2x00_set_field8(&rfcsr, RFCSR1_TX0_PD, 1);
1662
rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
1664
rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
1665
if (rt2x00dev->freq_offset > RT5390_FREQ_OFFSET_BOUND)
1666
rt2x00_set_field8(&rfcsr, RFCSR17_CODE,
1667
RT5390_FREQ_OFFSET_BOUND);
1669
rt2x00_set_field8(&rfcsr, RFCSR17_CODE, rt2x00dev->freq_offset);
1670
rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
1672
if (rf->channel <= 14) {
1673
int idx = rf->channel-1;
1675
if (test_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags)) {
1676
if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F)) {
1677
/* r55/r59 value array of channel 1~14 */
1678
static const char r55_bt_rev[] = {0x83, 0x83,
1679
0x83, 0x73, 0x73, 0x63, 0x53, 0x53,
1680
0x53, 0x43, 0x43, 0x43, 0x43, 0x43};
1681
static const char r59_bt_rev[] = {0x0e, 0x0e,
1682
0x0e, 0x0e, 0x0e, 0x0b, 0x0a, 0x09,
1683
0x07, 0x07, 0x07, 0x07, 0x07, 0x07};
1685
rt2800_rfcsr_write(rt2x00dev, 55,
1687
rt2800_rfcsr_write(rt2x00dev, 59,
1690
static const char r59_bt[] = {0x8b, 0x8b, 0x8b,
1691
0x8b, 0x8b, 0x8b, 0x8b, 0x8a, 0x89,
1692
0x88, 0x88, 0x86, 0x85, 0x84};
1694
rt2800_rfcsr_write(rt2x00dev, 59, r59_bt[idx]);
1697
if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F)) {
1698
static const char r55_nonbt_rev[] = {0x23, 0x23,
1699
0x23, 0x23, 0x13, 0x13, 0x03, 0x03,
1700
0x03, 0x03, 0x03, 0x03, 0x03, 0x03};
1701
static const char r59_nonbt_rev[] = {0x07, 0x07,
1702
0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
1703
0x07, 0x07, 0x06, 0x05, 0x04, 0x04};
1705
rt2800_rfcsr_write(rt2x00dev, 55,
1706
r55_nonbt_rev[idx]);
1707
rt2800_rfcsr_write(rt2x00dev, 59,
1708
r59_nonbt_rev[idx]);
1709
} else if (rt2x00_rt(rt2x00dev, RT5390)) {
1710
static const char r59_non_bt[] = {0x8f, 0x8f,
1711
0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8d,
1712
0x8a, 0x88, 0x88, 0x87, 0x87, 0x86};
1714
rt2800_rfcsr_write(rt2x00dev, 59,
1720
rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
1721
rt2x00_set_field8(&rfcsr, RFCSR30_TX_H20M, 0);
1722
rt2x00_set_field8(&rfcsr, RFCSR30_RX_H20M, 0);
1723
rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
1725
rt2800_rfcsr_read(rt2x00dev, 3, &rfcsr);
1726
rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1);
1727
rt2800_rfcsr_write(rt2x00dev, 3, rfcsr);
1529
1730
static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev,
1530
1731
struct ieee80211_conf *conf,
1531
1732
struct rf_channel *rf,
1562
1766
rt2800_bbp_write(rt2x00dev, 86, 0);
1564
1768
if (rf->channel <= 14) {
1565
if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags)) {
1566
rt2800_bbp_write(rt2x00dev, 82, 0x62);
1567
rt2800_bbp_write(rt2x00dev, 75, 0x46);
1569
rt2800_bbp_write(rt2x00dev, 82, 0x84);
1570
rt2800_bbp_write(rt2x00dev, 75, 0x50);
1769
if (!rt2x00_rt(rt2x00dev, RT5390)) {
1770
if (test_bit(CAPABILITY_EXTERNAL_LNA_BG,
1771
&rt2x00dev->cap_flags)) {
1772
rt2800_bbp_write(rt2x00dev, 82, 0x62);
1773
rt2800_bbp_write(rt2x00dev, 75, 0x46);
1775
rt2800_bbp_write(rt2x00dev, 82, 0x84);
1776
rt2800_bbp_write(rt2x00dev, 75, 0x50);
1573
1780
rt2800_bbp_write(rt2x00dev, 82, 0xf2);
1575
if (test_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags))
1782
if (test_bit(CAPABILITY_EXTERNAL_LNA_A, &rt2x00dev->cap_flags))
1576
1783
rt2800_bbp_write(rt2x00dev, 75, 0x46);
1578
1785
rt2800_bbp_write(rt2x00dev, 75, 0x50);
1637
1844
rt2800_register_read(rt2x00dev, CH_BUSY_STA_SEC, ®);
1847
static int rt2800_get_gain_calibration_delta(struct rt2x00_dev *rt2x00dev)
1856
* Read TSSI boundaries for temperature compensation from
1859
* Array idx 0 1 2 3 4 5 6 7 8
1860
* Matching Delta value -4 -3 -2 -1 0 +1 +2 +3 +4
1861
* Example TSSI bounds 0xF0 0xD0 0xB5 0xA0 0x88 0x45 0x25 0x15 0x00
1863
if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) {
1864
rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG1, &eeprom);
1865
tssi_bounds[0] = rt2x00_get_field16(eeprom,
1866
EEPROM_TSSI_BOUND_BG1_MINUS4);
1867
tssi_bounds[1] = rt2x00_get_field16(eeprom,
1868
EEPROM_TSSI_BOUND_BG1_MINUS3);
1870
rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG2, &eeprom);
1871
tssi_bounds[2] = rt2x00_get_field16(eeprom,
1872
EEPROM_TSSI_BOUND_BG2_MINUS2);
1873
tssi_bounds[3] = rt2x00_get_field16(eeprom,
1874
EEPROM_TSSI_BOUND_BG2_MINUS1);
1876
rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG3, &eeprom);
1877
tssi_bounds[4] = rt2x00_get_field16(eeprom,
1878
EEPROM_TSSI_BOUND_BG3_REF);
1879
tssi_bounds[5] = rt2x00_get_field16(eeprom,
1880
EEPROM_TSSI_BOUND_BG3_PLUS1);
1882
rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG4, &eeprom);
1883
tssi_bounds[6] = rt2x00_get_field16(eeprom,
1884
EEPROM_TSSI_BOUND_BG4_PLUS2);
1885
tssi_bounds[7] = rt2x00_get_field16(eeprom,
1886
EEPROM_TSSI_BOUND_BG4_PLUS3);
1888
rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_BG5, &eeprom);
1889
tssi_bounds[8] = rt2x00_get_field16(eeprom,
1890
EEPROM_TSSI_BOUND_BG5_PLUS4);
1892
step = rt2x00_get_field16(eeprom,
1893
EEPROM_TSSI_BOUND_BG5_AGC_STEP);
1895
rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A1, &eeprom);
1896
tssi_bounds[0] = rt2x00_get_field16(eeprom,
1897
EEPROM_TSSI_BOUND_A1_MINUS4);
1898
tssi_bounds[1] = rt2x00_get_field16(eeprom,
1899
EEPROM_TSSI_BOUND_A1_MINUS3);
1901
rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A2, &eeprom);
1902
tssi_bounds[2] = rt2x00_get_field16(eeprom,
1903
EEPROM_TSSI_BOUND_A2_MINUS2);
1904
tssi_bounds[3] = rt2x00_get_field16(eeprom,
1905
EEPROM_TSSI_BOUND_A2_MINUS1);
1907
rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A3, &eeprom);
1908
tssi_bounds[4] = rt2x00_get_field16(eeprom,
1909
EEPROM_TSSI_BOUND_A3_REF);
1910
tssi_bounds[5] = rt2x00_get_field16(eeprom,
1911
EEPROM_TSSI_BOUND_A3_PLUS1);
1913
rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A4, &eeprom);
1914
tssi_bounds[6] = rt2x00_get_field16(eeprom,
1915
EEPROM_TSSI_BOUND_A4_PLUS2);
1916
tssi_bounds[7] = rt2x00_get_field16(eeprom,
1917
EEPROM_TSSI_BOUND_A4_PLUS3);
1919
rt2x00_eeprom_read(rt2x00dev, EEPROM_TSSI_BOUND_A5, &eeprom);
1920
tssi_bounds[8] = rt2x00_get_field16(eeprom,
1921
EEPROM_TSSI_BOUND_A5_PLUS4);
1923
step = rt2x00_get_field16(eeprom,
1924
EEPROM_TSSI_BOUND_A5_AGC_STEP);
1928
* Check if temperature compensation is supported.
1930
if (tssi_bounds[4] == 0xff)
1934
* Read current TSSI (BBP 49).
1936
rt2800_bbp_read(rt2x00dev, 49, ¤t_tssi);
1939
* Compare TSSI value (BBP49) with the compensation boundaries
1940
* from the EEPROM and increase or decrease tx power.
1942
for (i = 0; i <= 3; i++) {
1943
if (current_tssi > tssi_bounds[i])
1948
for (i = 8; i >= 5; i--) {
1949
if (current_tssi < tssi_bounds[i])
1954
return (i - 4) * step;
1957
static int rt2800_get_txpower_bw_comp(struct rt2x00_dev *rt2x00dev,
1958
enum ieee80211_band band)
1965
rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_DELTA, &eeprom);
1968
* HT40 compensation not required.
1970
if (eeprom == 0xffff ||
1971
!test_bit(CONFIG_CHANNEL_HT40, &rt2x00dev->flags))
1974
if (band == IEEE80211_BAND_2GHZ) {
1975
comp_en = rt2x00_get_field16(eeprom,
1976
EEPROM_TXPOWER_DELTA_ENABLE_2G);
1978
comp_type = rt2x00_get_field16(eeprom,
1979
EEPROM_TXPOWER_DELTA_TYPE_2G);
1980
comp_value = rt2x00_get_field16(eeprom,
1981
EEPROM_TXPOWER_DELTA_VALUE_2G);
1983
comp_value = -comp_value;
1986
comp_en = rt2x00_get_field16(eeprom,
1987
EEPROM_TXPOWER_DELTA_ENABLE_5G);
1989
comp_type = rt2x00_get_field16(eeprom,
1990
EEPROM_TXPOWER_DELTA_TYPE_5G);
1991
comp_value = rt2x00_get_field16(eeprom,
1992
EEPROM_TXPOWER_DELTA_VALUE_5G);
1994
comp_value = -comp_value;
2001
static u8 rt2800_compensate_txpower(struct rt2x00_dev *rt2x00dev, int is_rate_b,
2002
enum ieee80211_band band, int power_level,
2003
u8 txpower, int delta)
2009
u8 eirp_txpower_criterion;
2012
if (!((band == IEEE80211_BAND_5GHZ) && is_rate_b))
2015
if (test_bit(CAPABILITY_POWER_LIMIT, &rt2x00dev->cap_flags)) {
2017
* Check if eirp txpower exceed txpower_limit.
2018
* We use OFDM 6M as criterion and its eirp txpower
2019
* is stored at EEPROM_EIRP_MAX_TX_POWER.
2020
* .11b data rate need add additional 4dbm
2021
* when calculating eirp txpower.
2023
rt2800_register_read(rt2x00dev, TX_PWR_CFG_0, ®);
2024
criterion = rt2x00_get_field32(reg, TX_PWR_CFG_0_6MBS);
2026
rt2x00_eeprom_read(rt2x00dev,
2027
EEPROM_EIRP_MAX_TX_POWER, &eeprom);
2029
if (band == IEEE80211_BAND_2GHZ)
2030
eirp_txpower_criterion = rt2x00_get_field16(eeprom,
2031
EEPROM_EIRP_MAX_TX_POWER_2GHZ);
2033
eirp_txpower_criterion = rt2x00_get_field16(eeprom,
2034
EEPROM_EIRP_MAX_TX_POWER_5GHZ);
2036
eirp_txpower = eirp_txpower_criterion + (txpower - criterion) +
2037
(is_rate_b ? 4 : 0) + delta;
2039
reg_limit = (eirp_txpower > power_level) ?
2040
(eirp_txpower - power_level) : 0;
2044
return txpower + delta - reg_limit;
1640
2047
static void rt2800_config_txpower(struct rt2x00_dev *rt2x00dev,
1641
const int max_txpower)
2048
enum ieee80211_band band,
1644
u8 max_value = (u8)max_txpower;
1652
* set to normal tx power mode: +/- 0dBm
2060
* Calculate HT40 compensation delta
2062
delta = rt2800_get_txpower_bw_comp(rt2x00dev, band);
2065
* calculate temperature compensation delta
2067
delta += rt2800_get_gain_calibration_delta(rt2x00dev);
2070
* set to normal bbp tx power control mode: +/- 0dBm
1654
2072
rt2800_bbp_read(rt2x00dev, 1, &r1);
1655
rt2x00_set_field8(&r1, BBP1_TX_POWER, 0);
2073
rt2x00_set_field8(&r1, BBP1_TX_POWER_CTRL, 0);
1656
2074
rt2800_bbp_write(rt2x00dev, 1, r1);
1659
* The eeprom contains the tx power values for each rate. These
1660
* values map to 100% tx power. Each 16bit word contains four tx
1661
* power values and the order is the same as used in the TX_PWR_CFG
1664
2075
offset = TX_PWR_CFG_0;
1666
2077
for (i = 0; i < EEPROM_TXPOWER_BYRATE_SIZE; i += 2) {
1674
2085
rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i,
1677
/* TX_PWR_CFG_0: 1MBS, TX_PWR_CFG_1: 24MBS,
2088
is_rate_b = i ? 0 : 1;
2090
* TX_PWR_CFG_0: 1MBS, TX_PWR_CFG_1: 24MBS,
1678
2091
* TX_PWR_CFG_2: MCS4, TX_PWR_CFG_3: MCS12,
1679
* TX_PWR_CFG_4: unknown */
2092
* TX_PWR_CFG_4: unknown
1680
2094
txpower = rt2x00_get_field16(eeprom,
1681
2095
EEPROM_TXPOWER_BYRATE_RATE0);
1682
rt2x00_set_field32(®, TX_PWR_CFG_RATE0,
1683
min(txpower, max_value));
2096
txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2097
power_level, txpower, delta);
2098
rt2x00_set_field32(®, TX_PWR_CFG_RATE0, txpower);
1685
/* TX_PWR_CFG_0: 2MBS, TX_PWR_CFG_1: 36MBS,
2101
* TX_PWR_CFG_0: 2MBS, TX_PWR_CFG_1: 36MBS,
1686
2102
* TX_PWR_CFG_2: MCS5, TX_PWR_CFG_3: MCS13,
1687
* TX_PWR_CFG_4: unknown */
2103
* TX_PWR_CFG_4: unknown
1688
2105
txpower = rt2x00_get_field16(eeprom,
1689
2106
EEPROM_TXPOWER_BYRATE_RATE1);
1690
rt2x00_set_field32(®, TX_PWR_CFG_RATE1,
1691
min(txpower, max_value));
2107
txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2108
power_level, txpower, delta);
2109
rt2x00_set_field32(®, TX_PWR_CFG_RATE1, txpower);
1693
/* TX_PWR_CFG_0: 55MBS, TX_PWR_CFG_1: 48MBS,
2112
* TX_PWR_CFG_0: 5.5MBS, TX_PWR_CFG_1: 48MBS,
1694
2113
* TX_PWR_CFG_2: MCS6, TX_PWR_CFG_3: MCS14,
1695
* TX_PWR_CFG_4: unknown */
2114
* TX_PWR_CFG_4: unknown
1696
2116
txpower = rt2x00_get_field16(eeprom,
1697
2117
EEPROM_TXPOWER_BYRATE_RATE2);
1698
rt2x00_set_field32(®, TX_PWR_CFG_RATE2,
1699
min(txpower, max_value));
2118
txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2119
power_level, txpower, delta);
2120
rt2x00_set_field32(®, TX_PWR_CFG_RATE2, txpower);
1701
/* TX_PWR_CFG_0: 11MBS, TX_PWR_CFG_1: 54MBS,
2123
* TX_PWR_CFG_0: 11MBS, TX_PWR_CFG_1: 54MBS,
1702
2124
* TX_PWR_CFG_2: MCS7, TX_PWR_CFG_3: MCS15,
1703
* TX_PWR_CFG_4: unknown */
2125
* TX_PWR_CFG_4: unknown
1704
2127
txpower = rt2x00_get_field16(eeprom,
1705
2128
EEPROM_TXPOWER_BYRATE_RATE3);
1706
rt2x00_set_field32(®, TX_PWR_CFG_RATE3,
1707
min(txpower, max_value));
2129
txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2130
power_level, txpower, delta);
2131
rt2x00_set_field32(®, TX_PWR_CFG_RATE3, txpower);
1709
2133
/* read the next four txpower values */
1710
2134
rt2x00_eeprom_read(rt2x00dev, EEPROM_TXPOWER_BYRATE + i + 1,
1713
/* TX_PWR_CFG_0: 6MBS, TX_PWR_CFG_1: MCS0,
2139
* TX_PWR_CFG_0: 6MBS, TX_PWR_CFG_1: MCS0,
1714
2140
* TX_PWR_CFG_2: MCS8, TX_PWR_CFG_3: unknown,
1715
* TX_PWR_CFG_4: unknown */
2141
* TX_PWR_CFG_4: unknown
1716
2143
txpower = rt2x00_get_field16(eeprom,
1717
2144
EEPROM_TXPOWER_BYRATE_RATE0);
1718
rt2x00_set_field32(®, TX_PWR_CFG_RATE4,
1719
min(txpower, max_value));
2145
txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2146
power_level, txpower, delta);
2147
rt2x00_set_field32(®, TX_PWR_CFG_RATE4, txpower);
1721
/* TX_PWR_CFG_0: 9MBS, TX_PWR_CFG_1: MCS1,
2150
* TX_PWR_CFG_0: 9MBS, TX_PWR_CFG_1: MCS1,
1722
2151
* TX_PWR_CFG_2: MCS9, TX_PWR_CFG_3: unknown,
1723
* TX_PWR_CFG_4: unknown */
2152
* TX_PWR_CFG_4: unknown
1724
2154
txpower = rt2x00_get_field16(eeprom,
1725
2155
EEPROM_TXPOWER_BYRATE_RATE1);
1726
rt2x00_set_field32(®, TX_PWR_CFG_RATE5,
1727
min(txpower, max_value));
2156
txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2157
power_level, txpower, delta);
2158
rt2x00_set_field32(®, TX_PWR_CFG_RATE5, txpower);
1729
/* TX_PWR_CFG_0: 12MBS, TX_PWR_CFG_1: MCS2,
2161
* TX_PWR_CFG_0: 12MBS, TX_PWR_CFG_1: MCS2,
1730
2162
* TX_PWR_CFG_2: MCS10, TX_PWR_CFG_3: unknown,
1731
* TX_PWR_CFG_4: unknown */
2163
* TX_PWR_CFG_4: unknown
1732
2165
txpower = rt2x00_get_field16(eeprom,
1733
2166
EEPROM_TXPOWER_BYRATE_RATE2);
1734
rt2x00_set_field32(®, TX_PWR_CFG_RATE6,
1735
min(txpower, max_value));
2167
txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2168
power_level, txpower, delta);
2169
rt2x00_set_field32(®, TX_PWR_CFG_RATE6, txpower);
1737
/* TX_PWR_CFG_0: 18MBS, TX_PWR_CFG_1: MCS3,
2172
* TX_PWR_CFG_0: 18MBS, TX_PWR_CFG_1: MCS3,
1738
2173
* TX_PWR_CFG_2: MCS11, TX_PWR_CFG_3: unknown,
1739
* TX_PWR_CFG_4: unknown */
2174
* TX_PWR_CFG_4: unknown
1740
2176
txpower = rt2x00_get_field16(eeprom,
1741
2177
EEPROM_TXPOWER_BYRATE_RATE3);
1742
rt2x00_set_field32(®, TX_PWR_CFG_RATE7,
1743
min(txpower, max_value));
2178
txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2179
power_level, txpower, delta);
2180
rt2x00_set_field32(®, TX_PWR_CFG_RATE7, txpower);
1745
2182
rt2800_register_write(rt2x00dev, offset, reg);
2180
2633
rt2800_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i),
2181
2634
wcid, sizeof(wcid));
2183
rt2800_register_write(rt2x00dev, MAC_WCID_ATTR_ENTRY(i), 1);
2636
rt2800_register_write(rt2x00dev, MAC_WCID_ATTR_ENTRY(i), 0);
2184
2637
rt2800_register_write(rt2x00dev, MAC_IVEIV_ENTRY(i), 0);
2188
2641
* Clear all beacons
2190
rt2800_clear_beacon(rt2x00dev, HW_BEACON_BASE0);
2191
rt2800_clear_beacon(rt2x00dev, HW_BEACON_BASE1);
2192
rt2800_clear_beacon(rt2x00dev, HW_BEACON_BASE2);
2193
rt2800_clear_beacon(rt2x00dev, HW_BEACON_BASE3);
2194
rt2800_clear_beacon(rt2x00dev, HW_BEACON_BASE4);
2195
rt2800_clear_beacon(rt2x00dev, HW_BEACON_BASE5);
2196
rt2800_clear_beacon(rt2x00dev, HW_BEACON_BASE6);
2197
rt2800_clear_beacon(rt2x00dev, HW_BEACON_BASE7);
2643
rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE0);
2644
rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE1);
2645
rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE2);
2646
rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE3);
2647
rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE4);
2648
rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE5);
2649
rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE6);
2650
rt2800_clear_beacon_register(rt2x00dev, HW_BEACON_BASE7);
2199
2652
if (rt2x00_is_usb(rt2x00dev)) {
2200
2653
rt2800_register_read(rt2x00dev, US_CYC_CNT, ®);
2201
2654
rt2x00_set_field32(®, US_CYC_CNT_CLOCK_CYCLE, 30);
2202
2655
rt2800_register_write(rt2x00dev, US_CYC_CNT, reg);
2656
} else if (rt2x00_is_pcie(rt2x00dev)) {
2657
rt2800_register_read(rt2x00dev, US_CYC_CNT, ®);
2658
rt2x00_set_field32(®, US_CYC_CNT_CLOCK_CYCLE, 125);
2659
rt2800_register_write(rt2x00dev, US_CYC_CNT, reg);
2205
2662
rt2800_register_read(rt2x00dev, HT_FBK_CFG0, ®);
2335
2792
rt2800_wait_bbp_ready(rt2x00dev)))
2336
2793
return -EACCES;
2338
if (rt2800_is_305x_soc(rt2x00dev))
2795
if (rt2x00_rt(rt2x00dev, RT5390)) {
2796
rt2800_bbp_read(rt2x00dev, 4, &value);
2797
rt2x00_set_field8(&value, BBP4_MAC_IF_CTRL, 1);
2798
rt2800_bbp_write(rt2x00dev, 4, value);
2801
if (rt2800_is_305x_soc(rt2x00dev) ||
2802
rt2x00_rt(rt2x00dev, RT5390))
2339
2803
rt2800_bbp_write(rt2x00dev, 31, 0x08);
2341
2805
rt2800_bbp_write(rt2x00dev, 65, 0x2c);
2342
2806
rt2800_bbp_write(rt2x00dev, 66, 0x38);
2808
if (rt2x00_rt(rt2x00dev, RT5390))
2809
rt2800_bbp_write(rt2x00dev, 68, 0x0b);
2344
2811
if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860C)) {
2345
2812
rt2800_bbp_write(rt2x00dev, 69, 0x16);
2346
2813
rt2800_bbp_write(rt2x00dev, 73, 0x12);
2814
} else if (rt2x00_rt(rt2x00dev, RT5390)) {
2815
rt2800_bbp_write(rt2x00dev, 69, 0x12);
2816
rt2800_bbp_write(rt2x00dev, 73, 0x13);
2817
rt2800_bbp_write(rt2x00dev, 75, 0x46);
2818
rt2800_bbp_write(rt2x00dev, 76, 0x28);
2819
rt2800_bbp_write(rt2x00dev, 77, 0x59);
2348
2821
rt2800_bbp_write(rt2x00dev, 69, 0x12);
2349
2822
rt2800_bbp_write(rt2x00dev, 73, 0x10);
2368
2842
rt2800_bbp_write(rt2x00dev, 82, 0x62);
2369
rt2800_bbp_write(rt2x00dev, 83, 0x6a);
2843
if (rt2x00_rt(rt2x00dev, RT5390))
2844
rt2800_bbp_write(rt2x00dev, 83, 0x7a);
2846
rt2800_bbp_write(rt2x00dev, 83, 0x6a);
2371
2848
if (rt2x00_rt_rev(rt2x00dev, RT2860, REV_RT2860D))
2372
2849
rt2800_bbp_write(rt2x00dev, 84, 0x19);
2850
else if (rt2x00_rt(rt2x00dev, RT5390))
2851
rt2800_bbp_write(rt2x00dev, 84, 0x9a);
2374
2853
rt2800_bbp_write(rt2x00dev, 84, 0x99);
2376
rt2800_bbp_write(rt2x00dev, 86, 0x00);
2855
if (rt2x00_rt(rt2x00dev, RT5390))
2856
rt2800_bbp_write(rt2x00dev, 86, 0x38);
2858
rt2800_bbp_write(rt2x00dev, 86, 0x00);
2377
2860
rt2800_bbp_write(rt2x00dev, 91, 0x04);
2378
rt2800_bbp_write(rt2x00dev, 92, 0x00);
2862
if (rt2x00_rt(rt2x00dev, RT5390))
2863
rt2800_bbp_write(rt2x00dev, 92, 0x02);
2865
rt2800_bbp_write(rt2x00dev, 92, 0x00);
2380
2867
if (rt2x00_rt_rev_gte(rt2x00dev, RT3070, REV_RT3070F) ||
2381
2868
rt2x00_rt_rev_gte(rt2x00dev, RT3071, REV_RT3071E) ||
2382
2869
rt2x00_rt_rev_gte(rt2x00dev, RT3090, REV_RT3090E) ||
2383
2870
rt2x00_rt_rev_gte(rt2x00dev, RT3390, REV_RT3390E) ||
2871
rt2x00_rt(rt2x00dev, RT5390) ||
2384
2872
rt2800_is_305x_soc(rt2x00dev))
2385
2873
rt2800_bbp_write(rt2x00dev, 103, 0xc0);
2387
2875
rt2800_bbp_write(rt2x00dev, 103, 0x00);
2877
if (rt2x00_rt(rt2x00dev, RT5390))
2878
rt2800_bbp_write(rt2x00dev, 104, 0x92);
2389
2880
if (rt2800_is_305x_soc(rt2x00dev))
2390
2881
rt2800_bbp_write(rt2x00dev, 105, 0x01);
2882
else if (rt2x00_rt(rt2x00dev, RT5390))
2883
rt2800_bbp_write(rt2x00dev, 105, 0x3c);
2392
2885
rt2800_bbp_write(rt2x00dev, 105, 0x05);
2393
rt2800_bbp_write(rt2x00dev, 106, 0x35);
2887
if (rt2x00_rt(rt2x00dev, RT5390))
2888
rt2800_bbp_write(rt2x00dev, 106, 0x03);
2890
rt2800_bbp_write(rt2x00dev, 106, 0x35);
2892
if (rt2x00_rt(rt2x00dev, RT5390))
2893
rt2800_bbp_write(rt2x00dev, 128, 0x12);
2395
2895
if (rt2x00_rt(rt2x00dev, RT3071) ||
2396
2896
rt2x00_rt(rt2x00dev, RT3090) ||
2397
rt2x00_rt(rt2x00dev, RT3390)) {
2897
rt2x00_rt(rt2x00dev, RT3390) ||
2898
rt2x00_rt(rt2x00dev, RT5390)) {
2398
2899
rt2800_bbp_read(rt2x00dev, 138, &value);
2400
2901
rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
2406
2907
rt2800_bbp_write(rt2x00dev, 138, value);
2910
if (rt2x00_rt(rt2x00dev, RT5390)) {
2913
rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
2914
div_mode = rt2x00_get_field16(eeprom,
2915
EEPROM_NIC_CONF1_ANT_DIVERSITY);
2916
ant = (div_mode == 3) ? 1 : 0;
2918
/* check if this is a Bluetooth combo card */
2919
if (test_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags)) {
2922
rt2800_register_read(rt2x00dev, GPIO_CTRL_CFG, ®);
2923
rt2x00_set_field32(®, GPIO_CTRL_CFG_GPIOD_BIT3, 0);
2924
rt2x00_set_field32(®, GPIO_CTRL_CFG_GPIOD_BIT6, 0);
2925
rt2x00_set_field32(®, GPIO_CTRL_CFG_BIT3, 0);
2926
rt2x00_set_field32(®, GPIO_CTRL_CFG_BIT6, 0);
2928
rt2x00_set_field32(®, GPIO_CTRL_CFG_BIT3, 1);
2930
rt2x00_set_field32(®, GPIO_CTRL_CFG_BIT6, 1);
2931
rt2800_register_write(rt2x00dev, GPIO_CTRL_CFG, reg);
2934
rt2800_bbp_read(rt2x00dev, 152, &value);
2936
rt2x00_set_field8(&value, BBP152_RX_DEFAULT_ANT, 1);
2938
rt2x00_set_field8(&value, BBP152_RX_DEFAULT_ANT, 0);
2939
rt2800_bbp_write(rt2x00dev, 152, value);
2941
/* Init frequency calibration */
2942
rt2800_bbp_write(rt2x00dev, 142, 1);
2943
rt2800_bbp_write(rt2x00dev, 143, 57);
2410
2946
for (i = 0; i < EEPROM_BBP_SIZE; i++) {
2411
2947
rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom);
2491
3031
!rt2x00_rt(rt2x00dev, RT3071) &&
2492
3032
!rt2x00_rt(rt2x00dev, RT3090) &&
2493
3033
!rt2x00_rt(rt2x00dev, RT3390) &&
3034
!rt2x00_rt(rt2x00dev, RT5390) &&
2494
3035
!rt2800_is_305x_soc(rt2x00dev))
2498
3039
* Init RF calibration.
2500
rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
2501
rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1);
2502
rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
2504
rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0);
2505
rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
3041
if (rt2x00_rt(rt2x00dev, RT5390)) {
3042
rt2800_rfcsr_read(rt2x00dev, 2, &rfcsr);
3043
rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_EN, 1);
3044
rt2800_rfcsr_write(rt2x00dev, 2, rfcsr);
3046
rt2x00_set_field8(&rfcsr, RFCSR2_RESCAL_EN, 0);
3047
rt2800_rfcsr_write(rt2x00dev, 2, rfcsr);
3049
rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
3050
rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1);
3051
rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
3053
rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0);
3054
rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
2507
3057
if (rt2x00_rt(rt2x00dev, RT3070) ||
2508
3058
rt2x00_rt(rt2x00dev, RT3071) ||
2593
3143
rt2800_rfcsr_write(rt2x00dev, 30, 0x00);
2594
3144
rt2800_rfcsr_write(rt2x00dev, 31, 0x00);
3146
} else if (rt2x00_rt(rt2x00dev, RT5390)) {
3147
rt2800_rfcsr_write(rt2x00dev, 1, 0x0f);
3148
rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
3149
rt2800_rfcsr_write(rt2x00dev, 3, 0x88);
3150
rt2800_rfcsr_write(rt2x00dev, 5, 0x10);
3151
if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F))
3152
rt2800_rfcsr_write(rt2x00dev, 6, 0xe0);
3154
rt2800_rfcsr_write(rt2x00dev, 6, 0xa0);
3155
rt2800_rfcsr_write(rt2x00dev, 7, 0x00);
3156
rt2800_rfcsr_write(rt2x00dev, 10, 0x53);
3157
rt2800_rfcsr_write(rt2x00dev, 11, 0x4a);
3158
rt2800_rfcsr_write(rt2x00dev, 12, 0xc6);
3159
rt2800_rfcsr_write(rt2x00dev, 13, 0x9f);
3160
rt2800_rfcsr_write(rt2x00dev, 14, 0x00);
3161
rt2800_rfcsr_write(rt2x00dev, 15, 0x00);
3162
rt2800_rfcsr_write(rt2x00dev, 16, 0x00);
3163
rt2800_rfcsr_write(rt2x00dev, 18, 0x03);
3164
rt2800_rfcsr_write(rt2x00dev, 19, 0x00);
3166
rt2800_rfcsr_write(rt2x00dev, 20, 0x00);
3167
rt2800_rfcsr_write(rt2x00dev, 21, 0x00);
3168
rt2800_rfcsr_write(rt2x00dev, 22, 0x20);
3169
rt2800_rfcsr_write(rt2x00dev, 23, 0x00);
3170
rt2800_rfcsr_write(rt2x00dev, 24, 0x00);
3171
if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F))
3172
rt2800_rfcsr_write(rt2x00dev, 25, 0x80);
3174
rt2800_rfcsr_write(rt2x00dev, 25, 0xc0);
3175
rt2800_rfcsr_write(rt2x00dev, 26, 0x00);
3176
rt2800_rfcsr_write(rt2x00dev, 27, 0x09);
3177
rt2800_rfcsr_write(rt2x00dev, 28, 0x00);
3178
rt2800_rfcsr_write(rt2x00dev, 29, 0x10);
3180
rt2800_rfcsr_write(rt2x00dev, 30, 0x00);
3181
rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
3182
rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
3183
rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
3184
rt2800_rfcsr_write(rt2x00dev, 34, 0x07);
3185
rt2800_rfcsr_write(rt2x00dev, 35, 0x12);
3186
rt2800_rfcsr_write(rt2x00dev, 36, 0x00);
3187
rt2800_rfcsr_write(rt2x00dev, 37, 0x08);
3188
rt2800_rfcsr_write(rt2x00dev, 38, 0x85);
3189
rt2800_rfcsr_write(rt2x00dev, 39, 0x1b);
3191
if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F))
3192
rt2800_rfcsr_write(rt2x00dev, 40, 0x0b);
3194
rt2800_rfcsr_write(rt2x00dev, 40, 0x4b);
3195
rt2800_rfcsr_write(rt2x00dev, 41, 0xbb);
3196
rt2800_rfcsr_write(rt2x00dev, 42, 0xd2);
3197
rt2800_rfcsr_write(rt2x00dev, 43, 0x9a);
3198
rt2800_rfcsr_write(rt2x00dev, 44, 0x0e);
3199
rt2800_rfcsr_write(rt2x00dev, 45, 0xa2);
3200
if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F))
3201
rt2800_rfcsr_write(rt2x00dev, 46, 0x73);
3203
rt2800_rfcsr_write(rt2x00dev, 46, 0x7b);
3204
rt2800_rfcsr_write(rt2x00dev, 47, 0x00);
3205
rt2800_rfcsr_write(rt2x00dev, 48, 0x10);
3206
rt2800_rfcsr_write(rt2x00dev, 49, 0x94);
3208
rt2800_rfcsr_write(rt2x00dev, 52, 0x38);
3209
if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F))
3210
rt2800_rfcsr_write(rt2x00dev, 53, 0x00);
3212
rt2800_rfcsr_write(rt2x00dev, 53, 0x84);
3213
rt2800_rfcsr_write(rt2x00dev, 54, 0x78);
3214
rt2800_rfcsr_write(rt2x00dev, 55, 0x44);
3215
rt2800_rfcsr_write(rt2x00dev, 56, 0x22);
3216
rt2800_rfcsr_write(rt2x00dev, 57, 0x80);
3217
rt2800_rfcsr_write(rt2x00dev, 58, 0x7f);
3218
rt2800_rfcsr_write(rt2x00dev, 59, 0x63);
3220
rt2800_rfcsr_write(rt2x00dev, 60, 0x45);
3221
if (rt2x00_rt_rev_gte(rt2x00dev, RT5390, REV_RT5390F))
3222
rt2800_rfcsr_write(rt2x00dev, 61, 0xd1);
3224
rt2800_rfcsr_write(rt2x00dev, 61, 0xdd);
3225
rt2800_rfcsr_write(rt2x00dev, 62, 0x00);
3226
rt2800_rfcsr_write(rt2x00dev, 63, 0x00);
2598
3229
if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F)) {
2642
3277
rt2800_init_rx_filter(rt2x00dev, true, 0x27, 0x15);
2646
* Set back to initial state
2648
rt2800_bbp_write(rt2x00dev, 24, 0);
2650
rt2800_rfcsr_read(rt2x00dev, 22, &rfcsr);
2651
rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 0);
2652
rt2800_rfcsr_write(rt2x00dev, 22, rfcsr);
2655
* set BBP back to BW20
2657
rt2800_bbp_read(rt2x00dev, 4, &bbp);
2658
rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 0);
2659
rt2800_bbp_write(rt2x00dev, 4, bbp);
3280
if (!rt2x00_rt(rt2x00dev, RT5390)) {
3282
* Set back to initial state
3284
rt2800_bbp_write(rt2x00dev, 24, 0);
3286
rt2800_rfcsr_read(rt2x00dev, 22, &rfcsr);
3287
rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 0);
3288
rt2800_rfcsr_write(rt2x00dev, 22, rfcsr);
3291
* Set BBP back to BW20
3293
rt2800_bbp_read(rt2x00dev, 4, &bbp);
3294
rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 0);
3295
rt2800_bbp_write(rt2x00dev, 4, bbp);
2661
3298
if (rt2x00_rt_rev_lt(rt2x00dev, RT3070, REV_RT3070F) ||
2662
3299
rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
2668
3305
rt2x00_set_field32(®, OPT_14_CSR_BIT0, 1);
2669
3306
rt2800_register_write(rt2x00dev, OPT_14_CSR, reg);
2671
rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
2672
rt2x00_set_field8(&rfcsr, RFCSR17_TX_LO1_EN, 0);
2673
if (rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
2674
rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) ||
2675
rt2x00_rt_rev_lt(rt2x00dev, RT3390, REV_RT3390E)) {
2676
if (test_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags))
2677
rt2x00_set_field8(&rfcsr, RFCSR17_R, 1);
3308
if (!rt2x00_rt(rt2x00dev, RT5390)) {
3309
rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
3310
rt2x00_set_field8(&rfcsr, RFCSR17_TX_LO1_EN, 0);
3311
if (rt2x00_rt(rt2x00dev, RT3070) ||
3312
rt2x00_rt_rev_lt(rt2x00dev, RT3071, REV_RT3071E) ||
3313
rt2x00_rt_rev_lt(rt2x00dev, RT3090, REV_RT3090E) ||
3314
rt2x00_rt_rev_lt(rt2x00dev, RT3390, REV_RT3390E)) {
3315
if (!test_bit(CAPABILITY_EXTERNAL_LNA_BG,
3316
&rt2x00dev->cap_flags))
3317
rt2x00_set_field8(&rfcsr, RFCSR17_R, 1);
3319
rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &eeprom);
3320
if (rt2x00_get_field16(eeprom, EEPROM_TXMIXER_GAIN_BG_VAL) >= 1)
3321
rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
3322
rt2x00_get_field16(eeprom,
3323
EEPROM_TXMIXER_GAIN_BG_VAL));
3324
rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
2679
rt2x00_eeprom_read(rt2x00dev, EEPROM_TXMIXER_GAIN_BG, &eeprom);
2680
if (rt2x00_get_field16(eeprom, EEPROM_TXMIXER_GAIN_BG_VAL) >= 1)
2681
rt2x00_set_field8(&rfcsr, RFCSR17_TXMIXER_GAIN,
2682
rt2x00_get_field16(eeprom,
2683
EEPROM_TXMIXER_GAIN_BG_VAL));
2684
rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
2686
3327
if (rt2x00_rt(rt2x00dev, RT3090)) {
2687
3328
rt2800_bbp_read(rt2x00dev, 138, &bbp);
3330
/* Turn off unused DAC1 and ADC1 to reduce power consumption */
2689
3331
rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF0, &eeprom);
2690
3332
if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH) == 1)
2691
3333
rt2x00_set_field8(&bbp, BBP138_RX_ADC1, 0);
3041
3697
* Identify default antenna configuration.
3043
rt2x00dev->default_ant.tx =
3699
rt2x00dev->default_ant.tx_chain_num =
3044
3700
rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_TXPATH);
3045
rt2x00dev->default_ant.rx =
3701
rt2x00dev->default_ant.rx_chain_num =
3046
3702
rt2x00_get_field16(eeprom, EEPROM_NIC_CONF0_RXPATH);
3049
* Read frequency offset and RF programming sequence.
3051
rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
3052
rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
3055
* Read external LNA informations.
3057
3704
rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC_CONF1, &eeprom);
3706
if (rt2x00_rt(rt2x00dev, RT3070) ||
3707
rt2x00_rt(rt2x00dev, RT3090) ||
3708
rt2x00_rt(rt2x00dev, RT3390)) {
3709
value = rt2x00_get_field16(eeprom,
3710
EEPROM_NIC_CONF1_ANT_DIVERSITY);
3715
rt2x00dev->default_ant.tx = ANTENNA_A;
3716
rt2x00dev->default_ant.rx = ANTENNA_A;
3719
rt2x00dev->default_ant.tx = ANTENNA_A;
3720
rt2x00dev->default_ant.rx = ANTENNA_B;
3724
rt2x00dev->default_ant.tx = ANTENNA_A;
3725
rt2x00dev->default_ant.rx = ANTENNA_A;
3729
* Determine external LNA informations.
3059
3731
if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_LNA_5G))
3060
__set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags);
3732
__set_bit(CAPABILITY_EXTERNAL_LNA_A, &rt2x00dev->cap_flags);
3061
3733
if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_EXTERNAL_LNA_2G))
3062
__set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags);
3734
__set_bit(CAPABILITY_EXTERNAL_LNA_BG, &rt2x00dev->cap_flags);
3065
3737
* Detect if this device has an hardware controlled radio.
3067
3739
if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_HW_RADIO))
3068
__set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags);
3740
__set_bit(CAPABILITY_HW_BUTTON, &rt2x00dev->cap_flags);
3743
* Detect if this device has Bluetooth co-existence.
3745
if (rt2x00_get_field16(eeprom, EEPROM_NIC_CONF1_BT_COEXIST))
3746
__set_bit(CAPABILITY_BT_COEXIST, &rt2x00dev->cap_flags);
3749
* Read frequency offset and RF programming sequence.
3751
rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom);
3752
rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET);
3071
3755
* Store led settings, for correct led behaviour.