38 #include <linux/kernel.h>
39 #include <linux/module.h>
40 #include <linux/slab.h>
60 #define WAIT_FOR_BBP(__dev, __reg) \
61 rt2800_regbusy_read((__dev), BBP_CSR_CFG, BBP_CSR_CFG_BUSY, (__reg))
62 #define WAIT_FOR_RFCSR(__dev, __reg) \
63 rt2800_regbusy_read((__dev), RF_CSR_CFG, RF_CSR_CFG_BUSY, (__reg))
64 #define WAIT_FOR_RF(__dev, __reg) \
65 rt2800_regbusy_read((__dev), RF_CSR_CFG0, RF_CSR_CFG0_BUSY, (__reg))
66 #define WAIT_FOR_MCU(__dev, __reg) \
67 rt2800_regbusy_read((__dev), H2M_MAILBOX_CSR, \
68 H2M_MAILBOX_CSR_OWNER, (__reg))
70 static inline bool rt2800_is_305x_soc(
struct rt2x00_dev *rt2x00dev)
73 if (!rt2x00_is_soc(rt2x00dev) ||
74 !rt2x00_rt(rt2x00dev,
RT2872))
78 if (rt2x00_rf(rt2x00dev,
RF3020) ||
79 rt2x00_rf(rt2x00dev,
RF3021) ||
80 rt2x00_rf(rt2x00dev,
RF3022))
83 NOTICE(rt2x00dev,
"Unknown RF chipset on rt305x\n");
87 static void rt2800_bbp_write(
struct rt2x00_dev *rt2x00dev,
106 rt2800_register_write_lock(rt2x00dev,
BBP_CSR_CFG, reg);
112 static void rt2800_bbp_read(
struct rt2x00_dev *rt2x00dev,
113 const unsigned int word,
u8 *value)
134 rt2800_register_write_lock(rt2x00dev,
BBP_CSR_CFG, reg);
144 static void rt2800_rfcsr_write(
struct rt2x00_dev *rt2x00dev,
145 const unsigned int word,
const u8 value)
162 rt2800_register_write_lock(rt2x00dev,
RF_CSR_CFG, reg);
168 static void rt2800_rfcsr_read(
struct rt2x00_dev *rt2x00dev,
169 const unsigned int word,
u8 *value)
189 rt2800_register_write_lock(rt2x00dev,
RF_CSR_CFG, reg);
199 static void rt2800_rf_write(
struct rt2x00_dev *rt2x00dev,
200 const unsigned int word,
const u32 value)
217 rt2800_register_write_lock(rt2x00dev,
RF_CSR_CFG0, reg);
218 rt2x00_rf_write(rt2x00dev, word, value);
224 static int rt2800_enable_wlan_rt3290(
struct rt2x00_dev *rt2x00dev)
247 rt2800_register_read(rt2x00dev,
CMB_CTRL, ®);
254 if (i >= REGISTER_BUSY_COUNT) {
259 rt2800_register_write(rt2x00dev, 0x58, 0x018);
261 rt2800_register_write(rt2x00dev, 0x58, 0x418);
263 rt2800_register_write(rt2x00dev, 0x58, 0x618);
280 }
while (count != 0);
294 if (rt2x00_is_soc(rt2x00dev))
312 rt2800_register_write_lock(rt2x00dev,
HOST_CMD_CSR, reg);
325 rt2800_register_read(rt2x00dev,
MAC_CSR0, ®);
326 if (reg && reg != ~0)
331 ERROR(rt2x00dev,
"Unstable hardware.\n");
354 ERROR(rt2x00dev,
"WPDMA TX/RX busy [0x%08x].\n", reg);
373 static bool rt2800_check_firmware_crc(
const u8 *
data,
const size_t len)
383 fw_crc = (data[len - 2] << 8 | data[len - 1]);
402 return fw_crc ==
crc;
406 const u8 *
data,
const size_t len)
421 if (rt2x00_is_usb(rt2x00dev) || rt2x00_rt(rt2x00dev,
RT3290))
430 if (len != fw_len && (!multiple || (len % fw_len) != 0))
437 if (rt2x00_is_usb(rt2x00dev) &&
438 !rt2x00_rt(rt2x00dev,
RT2860) &&
439 !rt2x00_rt(rt2x00dev,
RT2872) &&
440 !rt2x00_rt(rt2x00dev,
RT3070) &&
441 ((len / fw_len) == 1))
448 while (offset < len) {
449 if (!rt2800_check_firmware_crc(data + offset, fw_len))
460 const u8 *
data,
const size_t len)
466 if (rt2x00_rt(rt2x00dev,
RT3290)) {
467 retval = rt2800_enable_wlan_rt3290(rt2x00dev);
484 if (rt2x00_is_pci(rt2x00dev)) {
485 if (rt2x00_rt(rt2x00dev,
RT3290) ||
486 rt2x00_rt(rt2x00dev,
RT3572) ||
487 rt2x00_rt(rt2x00dev,
RT5390) ||
488 rt2x00_rt(rt2x00dev,
RT5392)) {
489 rt2800_register_read(rt2x00dev,
AUX_CTRL, ®);
492 rt2800_register_write(rt2x00dev,
AUX_CTRL, reg);
494 rt2800_register_write(rt2x00dev,
PWR_PIN_CFG, 0x00000002);
502 rt2800_drv_write_firmware(rt2x00dev, data, len);
514 if (i == REGISTER_BUSY_COUNT) {
515 ERROR(rt2x00dev,
"PBF system register not ready.\n");
530 if (rt2x00_is_usb(rt2x00dev))
541 __le32 *txwi = rt2800_drv_get_txwi(entry);
547 rt2x00_desc_read(txwi, 0, &word);
558 txdesc->
u.
ht.mpdu_density);
567 rt2x00_desc_write(txwi, 0, word);
569 rt2x00_desc_read(txwi, 1, &word);
582 rt2x00_desc_write(txwi, 1, word);
591 _rt2x00_desc_write(txwi, 2, 0 );
592 _rt2x00_desc_write(txwi, 3, 0 );
596 static int rt2800_agc_to_rssi(
struct rt2x00_dev *rt2x00dev,
u32 rxwi_w2)
625 rssi0 = (rssi0) ? (-12 - offset0 - rt2x00dev->
lna_gain - rssi0) : -128;
626 rssi1 = (rssi1) ? (-12 - offset1 - rt2x00dev->
lna_gain - rssi1) : -128;
627 rssi2 = (rssi2) ? (-12 - offset2 - rt2x00dev->
lna_gain - rssi2) : -128;
635 rssi0 =
max(rssi0, rssi1);
636 return (
int)
max(rssi0, rssi2);
645 rt2x00_desc_read(rxwi, 0, &word);
650 rt2x00_desc_read(rxwi, 1, &word);
671 rt2x00_desc_read(rxwi, 2, &word);
676 rxdesc->
rssi = rt2800_agc_to_rssi(entry->queue->rt2x00dev, word);
687 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
698 rt2x00_desc_read(txwi, 0, &word);
722 if (
unlikely(aggr == 1 && ampdu == 0 && real_mcs != mcs)) {
727 if (aggr == 1 || ampdu == 1)
743 txdesc.
retry = ((mcs > real_mcs) ? mcs - real_mcs : 0);
767 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
769 unsigned int beacon_base;
770 unsigned int padding_len;
791 skbdesc->
desc = entry->skb->data;
807 padding_len =
roundup(entry->skb->len, 4) - entry->skb->len;
808 if (padding_len &&
skb_pad(entry->skb, padding_len)) {
809 ERROR(rt2x00dev,
"Failure padding beacon, aborting\n");
812 rt2800_register_write(rt2x00dev,
BCN_TIME_CFG, orig_reg);
817 rt2800_register_multiwrite(rt2x00dev, beacon_base, entry->skb->data,
818 entry->skb->len + padding_len);
834 static inline void rt2800_clear_beacon_register(
struct rt2x00_dev *rt2x00dev,
835 unsigned int beacon_base)
845 rt2800_register_write(rt2x00dev, beacon_base + i, 0);
850 struct rt2x00_dev *rt2x00dev = entry->queue->rt2x00dev;
864 rt2800_clear_beacon_register(rt2x00dev,
875 #ifdef CONFIG_RT2X00_LIB_DEBUGFS
879 .read = rt2800_register_read,
880 .write = rt2800_register_write,
883 .word_size =
sizeof(
u32),
887 .read = rt2x00_eeprom_read,
888 .write = rt2x00_eeprom_write,
890 .word_size =
sizeof(
u16),
894 .read = rt2800_bbp_read,
895 .write = rt2800_bbp_write,
897 .word_size =
sizeof(
u8),
901 .read = rt2x00_rf_read,
902 .write = rt2800_rf_write,
904 .word_size =
sizeof(
u32),
908 .read = rt2800_rfcsr_read,
909 .write = rt2800_rfcsr_write,
911 .word_size =
sizeof(
u8),
922 if (rt2x00_rt(rt2x00dev,
RT3290)) {
926 rt2800_register_read(rt2x00dev,
GPIO_CTRL, ®);
932 #ifdef CONFIG_RT2X00_LIB_LEDS
933 static void rt2800_brightness_set(
struct led_classdev *led_cdev,
939 unsigned int bg_mode =
944 unsigned int ledmode =
976 enabled ? (bg_mode ? 0x60 : 0xa0) : 0x20);
987 (1 << brightness / (
LED_FULL / 6)) - 1,
993 static void rt2800_init_led(
struct rt2x00_dev *rt2x00dev,
998 led->
led_dev.brightness_set = rt2800_brightness_set;
1006 static void rt2800_config_wcid(
struct rt2x00_dev *rt2x00dev,
1015 memset(&wcid_entry, 0xff,
sizeof(wcid_entry));
1019 rt2800_register_multiwrite(rt2x00dev, offset,
1020 &wcid_entry,
sizeof(wcid_entry));
1023 static void rt2800_delete_wcid_attr(
struct rt2x00_dev *rt2x00dev,
int wcid)
1027 rt2800_register_write(rt2x00dev, offset, 0);
1030 static void rt2800_config_wcid_attr_bssidx(
struct rt2x00_dev *rt2x00dev,
1031 int wcid,
u32 bssidx)
1040 rt2800_register_read(rt2x00dev, offset, ®);
1043 (bssidx & 0x8) >> 3);
1044 rt2800_register_write(rt2x00dev, offset, reg);
1047 static void rt2800_config_wcid_attr_cipher(
struct rt2x00_dev *rt2x00dev,
1058 rt2800_register_read(rt2x00dev, offset, ®);
1069 (crypto->
cipher & 0x8) >> 3);
1071 rt2800_register_write(rt2x00dev, offset, reg);
1074 rt2800_register_read(rt2x00dev, offset, ®);
1079 rt2800_register_write(rt2x00dev, offset, reg);
1084 memset(&iveiv_entry, 0,
sizeof(iveiv_entry));
1088 iveiv_entry.iv[3] |= 0x20;
1089 iveiv_entry.iv[3] |= key->
keyidx << 6;
1090 rt2800_register_multiwrite(rt2x00dev, offset,
1091 &iveiv_entry,
sizeof(iveiv_entry));
1107 sizeof(key_entry.
key));
1109 sizeof(key_entry.
tx_mic));
1111 sizeof(key_entry.
rx_mic));
1114 rt2800_register_multiwrite(rt2x00dev, offset,
1115 &key_entry,
sizeof(key_entry));
1130 rt2800_register_read(rt2x00dev, offset, ®);
1133 rt2800_register_write(rt2x00dev, offset, reg);
1139 rt2800_config_wcid_attr_bssidx(rt2x00dev, key->
hw_key_idx,
1141 rt2800_config_wcid_attr_cipher(rt2x00dev, crypto, key);
1147 static inline int rt2800_find_wcid(
struct rt2x00_dev *rt2x00dev)
1164 for (idx = 33; idx <= 222; idx++) {
1166 rt2800_register_multiread(rt2x00dev, offset, &wcid_entry,
1167 sizeof(wcid_entry));
1168 if (is_broadcast_ether_addr(wcid_entry.mac))
1191 if (crypto->
wcid < 0)
1196 sizeof(key_entry.
key));
1198 sizeof(key_entry.
tx_mic));
1200 sizeof(key_entry.
rx_mic));
1203 rt2800_register_multiwrite(rt2x00dev, offset,
1204 &key_entry,
sizeof(key_entry));
1210 rt2800_config_wcid_attr_cipher(rt2x00dev, crypto, key);
1225 wcid = rt2800_find_wcid(rt2x00dev);
1243 rt2800_delete_wcid_attr(rt2x00dev, wcid);
1244 rt2800_config_wcid(rt2x00dev, sta->
addr, wcid);
1245 rt2800_config_wcid_attr_bssidx(rt2x00dev, wcid,
1257 rt2800_config_wcid(rt2x00dev,
NULL, wcid);
1264 const unsigned int filter_flags)
1290 !(filter_flags & FIF_CONTROL));
1292 !(filter_flags & FIF_CONTROL));
1294 !(filter_flags & FIF_CONTROL));
1296 !(filter_flags & FIF_CONTROL));
1300 !(filter_flags & FIF_CONTROL));
1302 !(filter_flags & FIF_CONTROL));
1304 !(filter_flags & FIF_CONTROL));
1313 bool update_bssid =
false;
1344 if (flags & CONFIG_UPDATE_TYPE &&
1351 update_bssid =
true;
1354 if (!is_zero_ether_addr((
const u8 *)conf->
mac)) {
1361 conf->
mac,
sizeof(conf->
mac));
1365 if (!is_zero_ether_addr((
const u8 *)conf->
bssid)) {
1378 static void rt2800_config_ht_opmode(
struct rt2x00_dev *rt2x00dev,
1381 bool any_sta_nongf = !!(erp->
ht_opmode &
1384 u8 mm20_mode, mm40_mode, gf20_mode, gf40_mode;
1385 u16 mm20_rate, mm40_rate, gf20_rate, gf40_rate;
1389 mm20_rate = gf20_rate = 0x4004;
1392 mm40_rate = gf40_rate = 0x4084;
1394 switch (protection) {
1401 mm20_mode = mm40_mode = gf20_mode = gf40_mode = 0;
1410 mm20_mode = gf20_mode = 0;
1411 mm40_mode = gf40_mode = 2;
1434 mm20_mode = mm40_mode = gf20_mode = gf40_mode = 2;
1442 mm20_rate = mm40_rate = 0x0003;
1443 gf20_rate = gf40_rate = 0x0003;
1450 gf20_mode = gf40_mode = 2;
1498 rt2800_register_write(rt2x00dev,
HT_BASIC_RATE, 0x00008003);
1520 rt2800_config_ht_opmode(rt2x00dev, erp);
1524 static void rt2800_config_3572bt_ant(
struct rt2x00_dev *rt2x00dev)
1528 u8 led_ctrl, led_g_mode, led_r_mode;
1530 rt2800_register_read(rt2x00dev,
GPIO_SWITCH, ®);
1538 rt2800_register_write(rt2x00dev,
GPIO_SWITCH, reg);
1540 rt2800_register_read(rt2x00dev,
LED_CFG, ®);
1545 rt2x00_eeprom_read(rt2x00dev,
EEPROM_FREQ, &eeprom);
1547 if (led_ctrl == 0 || led_ctrl > 0x40) {
1550 rt2800_register_write(rt2x00dev,
LED_CFG, reg);
1553 (led_g_mode << 2) | led_r_mode, 1);
1558 static void rt2800_set_ant_diversity(
struct rt2x00_dev *rt2x00dev,
1565 if (rt2x00_is_pci(rt2x00dev)) {
1566 rt2800_register_read(rt2x00dev,
E2PROM_CSR, ®);
1568 rt2800_register_write(rt2x00dev,
E2PROM_CSR, reg);
1569 }
else if (rt2x00_is_usb(rt2x00dev))
1573 rt2800_register_read(rt2x00dev,
GPIO_CTRL, ®);
1576 rt2800_register_write(rt2x00dev,
GPIO_CTRL, reg);
1585 rt2800_bbp_read(rt2x00dev, 1, &r1);
1586 rt2800_bbp_read(rt2x00dev, 3, &r3);
1588 if (rt2x00_rt(rt2x00dev,
RT3572) &&
1590 rt2800_config_3572bt_ant(rt2x00dev);
1600 if (rt2x00_rt(rt2x00dev,
RT3572) &&
1616 if (rt2x00_rt(rt2x00dev,
RT3070) ||
1617 rt2x00_rt(rt2x00dev,
RT3090) ||
1618 rt2x00_rt(rt2x00dev,
RT3352) ||
1619 rt2x00_rt(rt2x00dev,
RT3390)) {
1620 rt2x00_eeprom_read(rt2x00dev,
1624 rt2800_set_ant_diversity(rt2x00dev,
1630 if (rt2x00_rt(rt2x00dev,
RT3572) &&
1635 rt2800_set_ant_diversity(rt2x00dev,
ANTENNA_B);
1645 rt2800_bbp_write(rt2x00dev, 3, r3);
1646 rt2800_bbp_write(rt2x00dev, 1, r1);
1650 static void rt2800_config_lna_gain(
struct rt2x00_dev *rt2x00dev,
1656 if (libconf->
rf.channel <= 14) {
1657 rt2x00_eeprom_read(rt2x00dev,
EEPROM_LNA, &eeprom);
1659 }
else if (libconf->
rf.channel <= 64) {
1660 rt2x00_eeprom_read(rt2x00dev,
EEPROM_LNA, &eeprom);
1662 }
else if (libconf->
rf.channel <= 128) {
1673 static void rt2800_config_channel_rf2xxx(
struct rt2x00_dev *rt2x00dev,
1686 }
else if (rt2x00dev->
default_ant.rx_chain_num == 2)
1718 rt2800_rf_write(rt2x00dev, 1, rf->
rf1);
1719 rt2800_rf_write(rt2x00dev, 2, rf->
rf2);
1720 rt2800_rf_write(rt2x00dev, 3, rf->
rf3 & ~0x00000004);
1721 rt2800_rf_write(rt2x00dev, 4, rf->
rf4);
1725 rt2800_rf_write(rt2x00dev, 1, rf->
rf1);
1726 rt2800_rf_write(rt2x00dev, 2, rf->
rf2);
1727 rt2800_rf_write(rt2x00dev, 3, rf->
rf3 | 0x00000004);
1728 rt2800_rf_write(rt2x00dev, 4, rf->
rf4);
1732 rt2800_rf_write(rt2x00dev, 1, rf->
rf1);
1733 rt2800_rf_write(rt2x00dev, 2, rf->
rf2);
1734 rt2800_rf_write(rt2x00dev, 3, rf->
rf3 & ~0x00000004);
1735 rt2800_rf_write(rt2x00dev, 4, rf->
rf4);
1738 static void rt2800_config_channel_rf3xxx(
struct rt2x00_dev *rt2x00dev,
1744 u8 rfcsr, calib_tx, calib_rx;
1746 rt2800_rfcsr_write(rt2x00dev, 2, rf->
rf1);
1748 rt2800_rfcsr_read(rt2x00dev, 3, &rfcsr);
1750 rt2800_rfcsr_write(rt2x00dev, 3, rfcsr);
1752 rt2800_rfcsr_read(rt2x00dev, 6, &rfcsr);
1754 rt2800_rfcsr_write(rt2x00dev, 6, rfcsr);
1756 rt2800_rfcsr_read(rt2x00dev, 12, &rfcsr);
1758 rt2800_rfcsr_write(rt2x00dev, 12, rfcsr);
1760 rt2800_rfcsr_read(rt2x00dev, 13, &rfcsr);
1762 rt2800_rfcsr_write(rt2x00dev, 13, rfcsr);
1764 rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr);
1775 rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
1777 rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
1779 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
1782 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
1784 rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr);
1786 rt2800_rfcsr_write(rt2x00dev, 23, rfcsr);
1788 if (rt2x00_rt(rt2x00dev,
RT3390)) {
1789 calib_tx = conf_is_ht40(conf) ? 0x68 : 0x4f;
1790 calib_rx = conf_is_ht40(conf) ? 0x6f : 0x4f;
1792 if (conf_is_ht40(conf)) {
1801 rt2800_rfcsr_read(rt2x00dev, 24, &rfcsr);
1803 rt2800_rfcsr_write(rt2x00dev, 24, rfcsr);
1805 rt2800_rfcsr_read(rt2x00dev, 31, &rfcsr);
1807 rt2800_rfcsr_write(rt2x00dev, 31, rfcsr);
1809 rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr);
1811 rt2800_rfcsr_write(rt2x00dev, 7, rfcsr);
1813 rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
1815 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
1818 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
1821 static void rt2800_config_channel_rf3052(
struct rt2x00_dev *rt2x00dev,
1831 rt2800_bbp_write(rt2x00dev, 25, drv_data->
bbp25);
1832 rt2800_bbp_write(rt2x00dev, 26, drv_data->
bbp26);
1834 rt2800_bbp_write(rt2x00dev, 25, 0x09);
1835 rt2800_bbp_write(rt2x00dev, 26, 0xff);
1838 rt2800_rfcsr_write(rt2x00dev, 2, rf->
rf1);
1839 rt2800_rfcsr_write(rt2x00dev, 3, rf->
rf3);
1841 rt2800_rfcsr_read(rt2x00dev, 6, &rfcsr);
1847 rt2800_rfcsr_write(rt2x00dev, 6, rfcsr);
1849 rt2800_rfcsr_read(rt2x00dev, 5, &rfcsr);
1854 rt2800_rfcsr_write(rt2x00dev, 5, rfcsr);
1856 rt2800_rfcsr_read(rt2x00dev, 12, &rfcsr);
1867 rt2800_rfcsr_write(rt2x00dev, 12, rfcsr);
1869 rt2800_rfcsr_read(rt2x00dev, 13, &rfcsr);
1880 rt2800_rfcsr_write(rt2x00dev, 13, rfcsr);
1882 rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr);
1913 rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
1915 rt2800_rfcsr_read(rt2x00dev, 23, &rfcsr);
1917 rt2800_rfcsr_write(rt2x00dev, 23, rfcsr);
1919 if (conf_is_ht40(conf)) {
1928 rt2800_rfcsr_write(rt2x00dev, 7, 0xd8);
1929 rt2800_rfcsr_write(rt2x00dev, 9, 0xc3);
1930 rt2800_rfcsr_write(rt2x00dev, 10, 0xf1);
1931 rt2800_rfcsr_write(rt2x00dev, 11, 0xb9);
1932 rt2800_rfcsr_write(rt2x00dev, 15, 0x53);
1936 rt2800_rfcsr_write(rt2x00dev, 16, rfcsr);
1937 rt2800_rfcsr_write(rt2x00dev, 17, 0x23);
1938 rt2800_rfcsr_write(rt2x00dev, 19, 0x93);
1939 rt2800_rfcsr_write(rt2x00dev, 20, 0xb3);
1940 rt2800_rfcsr_write(rt2x00dev, 25, 0x15);
1941 rt2800_rfcsr_write(rt2x00dev, 26, 0x85);
1942 rt2800_rfcsr_write(rt2x00dev, 27, 0x00);
1943 rt2800_rfcsr_write(rt2x00dev, 29, 0x9b);
1945 rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr);
1950 rt2800_rfcsr_write(rt2x00dev, 7, rfcsr);
1951 rt2800_rfcsr_write(rt2x00dev, 9, 0xc0);
1952 rt2800_rfcsr_write(rt2x00dev, 10, 0xf1);
1953 rt2800_rfcsr_write(rt2x00dev, 11, 0x00);
1954 rt2800_rfcsr_write(rt2x00dev, 15, 0x43);
1958 rt2800_rfcsr_write(rt2x00dev, 16, rfcsr);
1959 rt2800_rfcsr_write(rt2x00dev, 17, 0x23);
1961 rt2800_rfcsr_write(rt2x00dev, 19, 0xb7);
1962 rt2800_rfcsr_write(rt2x00dev, 20, 0xf6);
1963 rt2800_rfcsr_write(rt2x00dev, 25, 0x3d);
1964 }
else if (rf->
channel <= 128) {
1965 rt2800_rfcsr_write(rt2x00dev, 19, 0x74);
1966 rt2800_rfcsr_write(rt2x00dev, 20, 0xf4);
1967 rt2800_rfcsr_write(rt2x00dev, 25, 0x01);
1969 rt2800_rfcsr_write(rt2x00dev, 19, 0x72);
1970 rt2800_rfcsr_write(rt2x00dev, 20, 0xf3);
1971 rt2800_rfcsr_write(rt2x00dev, 25, 0x01);
1973 rt2800_rfcsr_write(rt2x00dev, 26, 0x87);
1974 rt2800_rfcsr_write(rt2x00dev, 27, 0x01);
1975 rt2800_rfcsr_write(rt2x00dev, 29, 0x9f);
1978 rt2800_register_read(rt2x00dev,
GPIO_CTRL, ®);
1984 rt2800_register_write(rt2x00dev,
GPIO_CTRL, reg);
1986 rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr);
1988 rt2800_rfcsr_write(rt2x00dev, 7, rfcsr);
1991 #define POWER_BOUND 0x27
1992 #define FREQ_OFFSET_BOUND 0x5f
1994 static void rt2800_config_channel_rf3290(
struct rt2x00_dev *rt2x00dev,
2001 rt2800_rfcsr_write(rt2x00dev, 8, rf->
rf1);
2002 rt2800_rfcsr_write(rt2x00dev, 9, rf->
rf3);
2003 rt2800_rfcsr_read(rt2x00dev, 11, &rfcsr);
2005 rt2800_rfcsr_write(rt2x00dev, 11, rfcsr);
2007 rt2800_rfcsr_read(rt2x00dev, 49, &rfcsr);
2012 rt2800_rfcsr_write(rt2x00dev, 49, rfcsr);
2014 rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
2019 rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
2023 rt2800_bbp_write(rt2x00dev, 68, 0x0c);
2025 rt2800_bbp_write(rt2x00dev, 68, 0x0b);
2028 rt2800_bbp_write(rt2x00dev, 59, 0x0f);
2030 rt2800_bbp_write(rt2x00dev, 59, 0x0e);
2032 rt2800_bbp_write(rt2x00dev, 59, 0x0d);
2036 static void rt2800_config_channel_rf3322(
struct rt2x00_dev *rt2x00dev,
2043 rt2800_rfcsr_write(rt2x00dev, 8, rf->
rf1);
2044 rt2800_rfcsr_write(rt2x00dev, 9, rf->
rf3);
2046 rt2800_rfcsr_write(rt2x00dev, 11, 0x42);
2047 rt2800_rfcsr_write(rt2x00dev, 12, 0x1c);
2048 rt2800_rfcsr_write(rt2x00dev, 13, 0x00);
2060 rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
2066 rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
2068 rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr);
2085 rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
2087 rt2800_rfcsr_write(rt2x00dev, 31, 80);
2090 static void rt2800_config_channel_rf53xx(
struct rt2x00_dev *rt2x00dev,
2097 rt2800_rfcsr_write(rt2x00dev, 8, rf->
rf1);
2098 rt2800_rfcsr_write(rt2x00dev, 9, rf->
rf3);
2099 rt2800_rfcsr_read(rt2x00dev, 11, &rfcsr);
2101 rt2800_rfcsr_write(rt2x00dev, 11, rfcsr);
2103 rt2800_rfcsr_read(rt2x00dev, 49, &rfcsr);
2108 rt2800_rfcsr_write(rt2x00dev, 49, rfcsr);
2110 if (rt2x00_rt(rt2x00dev,
RT5392)) {
2111 rt2800_rfcsr_read(rt2x00dev, 50, &rfcsr);
2117 rt2800_rfcsr_write(rt2x00dev, 50, rfcsr);
2120 rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr);
2121 if (rt2x00_rt(rt2x00dev,
RT5392)) {
2129 rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
2131 rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
2136 rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
2144 static const char r55_bt_rev[] = {0x83, 0x83,
2145 0x83, 0x73, 0x73, 0x63, 0x53, 0x53,
2146 0x53, 0x43, 0x43, 0x43, 0x43, 0x43};
2147 static const char r59_bt_rev[] = {0x0e, 0x0e,
2148 0x0e, 0x0e, 0x0e, 0x0b, 0x0a, 0x09,
2149 0x07, 0x07, 0x07, 0x07, 0x07, 0x07};
2151 rt2800_rfcsr_write(rt2x00dev, 55,
2153 rt2800_rfcsr_write(rt2x00dev, 59,
2156 static const char r59_bt[] = {0x8b, 0x8b, 0x8b,
2157 0x8b, 0x8b, 0x8b, 0x8b, 0x8a, 0x89,
2158 0x88, 0x88, 0x86, 0x85, 0x84};
2160 rt2800_rfcsr_write(rt2x00dev, 59, r59_bt[idx]);
2164 static const char r55_nonbt_rev[] = {0x23, 0x23,
2165 0x23, 0x23, 0x13, 0x13, 0x03, 0x03,
2166 0x03, 0x03, 0x03, 0x03, 0x03, 0x03};
2167 static const char r59_nonbt_rev[] = {0x07, 0x07,
2168 0x07, 0x07, 0x07, 0x07, 0x07, 0x07,
2169 0x07, 0x07, 0x06, 0x05, 0x04, 0x04};
2171 rt2800_rfcsr_write(rt2x00dev, 55,
2172 r55_nonbt_rev[idx]);
2173 rt2800_rfcsr_write(rt2x00dev, 59,
2174 r59_nonbt_rev[idx]);
2175 }
else if (rt2x00_rt(rt2x00dev,
RT5390) ||
2176 rt2x00_rt(rt2x00dev,
RT5392)) {
2177 static const char r59_non_bt[] = {0x8f, 0x8f,
2178 0x8f, 0x8f, 0x8f, 0x8f, 0x8f, 0x8d,
2179 0x8a, 0x88, 0x88, 0x87, 0x87, 0x86};
2181 rt2800_rfcsr_write(rt2x00dev, 59,
2188 static void rt2800_config_channel(
struct rt2x00_dev *rt2x00dev,
2194 unsigned int tx_pin;
2205 switch (rt2x00dev->
chip.rf) {
2211 rt2800_config_channel_rf3xxx(rt2x00dev, conf, rf, info);
2214 rt2800_config_channel_rf3052(rt2x00dev, conf, rf, info);
2217 rt2800_config_channel_rf3290(rt2x00dev, conf, rf, info);
2220 rt2800_config_channel_rf3322(rt2x00dev, conf, rf, info);
2227 rt2800_config_channel_rf53xx(rt2x00dev, conf, rf, info);
2230 rt2800_config_channel_rf2xxx(rt2x00dev, conf, rf, info);
2233 if (rt2x00_rf(rt2x00dev,
RF3290) ||
2234 rt2x00_rf(rt2x00dev,
RF3322) ||
2235 rt2x00_rf(rt2x00dev,
RF5360) ||
2236 rt2x00_rf(rt2x00dev,
RF5370) ||
2237 rt2x00_rf(rt2x00dev,
RF5372) ||
2238 rt2x00_rf(rt2x00dev,
RF5390) ||
2239 rt2x00_rf(rt2x00dev,
RF5392)) {
2240 rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
2243 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
2245 rt2800_rfcsr_read(rt2x00dev, 3, &rfcsr);
2247 rt2800_rfcsr_write(rt2x00dev, 3, rfcsr);
2253 if (rt2x00_rt(rt2x00dev,
RT3352)) {
2254 rt2800_bbp_write(rt2x00dev, 27, 0x0);
2255 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->
lna_gain);
2256 rt2800_bbp_write(rt2x00dev, 27, 0x20);
2257 rt2800_bbp_write(rt2x00dev, 66, 0x26 + rt2x00dev->
lna_gain);
2259 rt2800_bbp_write(rt2x00dev, 62, 0x37 - rt2x00dev->
lna_gain);
2260 rt2800_bbp_write(rt2x00dev, 63, 0x37 - rt2x00dev->
lna_gain);
2261 rt2800_bbp_write(rt2x00dev, 64, 0x37 - rt2x00dev->
lna_gain);
2262 rt2800_bbp_write(rt2x00dev, 86, 0);
2266 if (!rt2x00_rt(rt2x00dev,
RT5390) &&
2267 !rt2x00_rt(rt2x00dev,
RT5392)) {
2270 rt2800_bbp_write(rt2x00dev, 82, 0x62);
2271 rt2800_bbp_write(rt2x00dev, 75, 0x46);
2273 rt2800_bbp_write(rt2x00dev, 82, 0x84);
2274 rt2800_bbp_write(rt2x00dev, 75, 0x50);
2278 if (rt2x00_rt(rt2x00dev,
RT3572))
2279 rt2800_bbp_write(rt2x00dev, 82, 0x94);
2281 rt2800_bbp_write(rt2x00dev, 82, 0xf2);
2284 rt2800_bbp_write(rt2x00dev, 75, 0x46);
2286 rt2800_bbp_write(rt2x00dev, 75, 0x50);
2289 rt2800_register_read(rt2x00dev,
TX_BAND_CFG, ®);
2293 rt2800_register_write(rt2x00dev,
TX_BAND_CFG, reg);
2295 if (rt2x00_rt(rt2x00dev,
RT3572))
2296 rt2800_rfcsr_write(rt2x00dev, 8, 0);
2325 rt2800_register_write(rt2x00dev,
TX_PIN_CFG, tx_pin);
2327 if (rt2x00_rt(rt2x00dev,
RT3572))
2328 rt2800_rfcsr_write(rt2x00dev, 8, 0x80);
2330 rt2800_bbp_read(rt2x00dev, 4, &bbp);
2332 rt2800_bbp_write(rt2x00dev, 4, bbp);
2334 rt2800_bbp_read(rt2x00dev, 3, &bbp);
2336 rt2800_bbp_write(rt2x00dev, 3, bbp);
2339 if (conf_is_ht40(conf)) {
2340 rt2800_bbp_write(rt2x00dev, 69, 0x1a);
2341 rt2800_bbp_write(rt2x00dev, 70, 0x0a);
2342 rt2800_bbp_write(rt2x00dev, 73, 0x16);
2344 rt2800_bbp_write(rt2x00dev, 69, 0x16);
2345 rt2800_bbp_write(rt2x00dev, 70, 0x08);
2346 rt2800_bbp_write(rt2x00dev, 73, 0x11);
2355 rt2800_register_read(rt2x00dev,
CH_IDLE_STA, ®);
2356 rt2800_register_read(rt2x00dev,
CH_BUSY_STA, ®);
2362 if (rt2x00_rt(rt2x00dev,
RT3352)) {
2363 rt2800_bbp_read(rt2x00dev, 49, &bbp);
2365 rt2800_bbp_write(rt2x00dev, 49, bbp);
2369 static int rt2800_get_gain_calibration_delta(
struct rt2x00_dev *rt2x00dev)
2452 if (tssi_bounds[4] == 0xff || step == 0xff)
2458 rt2800_bbp_read(rt2x00dev, 49, ¤t_tssi);
2464 for (i = 0; i <= 3; i++) {
2465 if (current_tssi > tssi_bounds[i])
2470 for (i = 8; i >= 5; i--) {
2471 if (current_tssi < tssi_bounds[i])
2476 return (i - 4) *
step;
2479 static int rt2800_get_txpower_bw_comp(
struct rt2x00_dev *rt2x00dev,
2492 if (eeprom == 0xffff ||
2505 comp_value = -comp_value;
2516 comp_value = -comp_value;
2523 static u8 rt2800_compensate_txpower(
struct rt2x00_dev *rt2x00dev,
int is_rate_b,
2531 u8 eirp_txpower_criterion;
2548 rt2x00_eeprom_read(rt2x00dev,
2558 eirp_txpower = eirp_txpower_criterion + (txpower - criterion) +
2559 (is_rate_b ? 4 : 0) +
delta;
2561 reg_limit = (eirp_txpower > power_level) ?
2562 (eirp_txpower - power_level) : 0;
2566 return txpower + delta - reg_limit;
2569 static void rt2800_config_txpower(
struct rt2x00_dev *rt2x00dev,
2584 delta = rt2800_get_txpower_bw_comp(rt2x00dev, band);
2589 delta += rt2800_get_gain_calibration_delta(rt2x00dev);
2594 rt2800_bbp_read(rt2x00dev, 1, &r1);
2596 rt2800_bbp_write(rt2x00dev, 1, r1);
2604 rt2800_register_read(rt2x00dev, offset, ®);
2610 is_rate_b = i ? 0 : 1;
2618 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2619 power_level, txpower, delta);
2629 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2630 power_level, txpower, delta);
2640 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2641 power_level, txpower, delta);
2651 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2652 power_level, txpower, delta);
2667 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2668 power_level, txpower, delta);
2678 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2679 power_level, txpower, delta);
2689 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2690 power_level, txpower, delta);
2700 txpower = rt2800_compensate_txpower(rt2x00dev, is_rate_b, band,
2701 power_level, txpower, delta);
2704 rt2800_register_write(rt2x00dev, offset, reg);
2713 rt2800_config_txpower(rt2x00dev, rt2x00dev->
curr_band,
2731 rt2800_register_read(rt2x00dev,
TX_PIN_CFG, &tx_pin);
2733 rt2800_register_write(rt2x00dev,
TX_PIN_CFG, tx_pin);
2735 switch (rt2x00dev->
chip.rf) {
2742 rt2800_rfcsr_read(rt2x00dev, 7, &rfcsr);
2744 rt2800_rfcsr_write(rt2x00dev, 7, rfcsr);
2752 rt2800_rfcsr_read(rt2x00dev, 3, &rfcsr);
2754 rt2800_rfcsr_write(rt2x00dev, 3, rfcsr);
2762 rt2800_register_read(rt2x00dev,
TX_PIN_CFG, &tx_pin);
2790 rt2800_register_write(rt2x00dev,
TX_PIN_CFG, tx_pin);
2795 static void rt2800_config_retry_limit(
struct rt2x00_dev *rt2x00dev,
2800 rt2800_register_read(rt2x00dev,
TX_RTY_CFG, ®);
2802 libconf->
conf->short_frame_max_tx_count);
2804 libconf->
conf->long_frame_max_tx_count);
2805 rt2800_register_write(rt2x00dev,
TX_RTY_CFG, reg);
2808 static void rt2800_config_ps(
struct rt2x00_dev *rt2x00dev,
2822 libconf->
conf->listen_interval - 1);
2826 rt2x00dev->
ops->lib->set_device_state(rt2x00dev, state);
2834 rt2x00dev->
ops->lib->set_device_state(rt2x00dev, state);
2840 const unsigned int flags)
2843 rt2800_config_lna_gain(rt2x00dev, libconf);
2846 rt2800_config_channel(rt2x00dev, libconf->
conf,
2848 rt2800_config_txpower(rt2x00dev, libconf->
conf->channel->band,
2849 libconf->
conf->power_level);
2852 rt2800_config_txpower(rt2x00dev, libconf->
conf->channel->band,
2853 libconf->
conf->power_level);
2855 rt2800_config_retry_limit(rt2x00dev, libconf);
2857 rt2800_config_ps(rt2x00dev, libconf);
2871 rt2800_register_read(rt2x00dev,
RX_STA_CNT0, ®);
2876 static u8 rt2800_get_default_vgc(
struct rt2x00_dev *rt2x00dev)
2881 if (rt2x00_rt(rt2x00dev,
RT3070) ||
2882 rt2x00_rt(rt2x00dev,
RT3071) ||
2883 rt2x00_rt(rt2x00dev,
RT3090) ||
2884 rt2x00_rt(rt2x00dev,
RT3290) ||
2885 rt2x00_rt(rt2x00dev,
RT3390) ||
2886 rt2x00_rt(rt2x00dev,
RT3572) ||
2887 rt2x00_rt(rt2x00dev,
RT5390) ||
2888 rt2x00_rt(rt2x00dev,
RT5392))
2889 vgc = 0x1c + (2 * rt2x00dev->
lna_gain);
2893 if (rt2x00_rt(rt2x00dev,
RT3572))
2894 vgc = 0x22 + (rt2x00dev->
lna_gain * 5) / 3;
2897 vgc = 0x32 + (rt2x00dev->
lna_gain * 5) / 3;
2899 vgc = 0x3a + (rt2x00dev->
lna_gain * 5) / 3;
2906 static inline void rt2800_set_vgc(
struct rt2x00_dev *rt2x00dev,
2910 rt2800_bbp_write(rt2x00dev, 66, vgc_level);
2918 rt2800_set_vgc(rt2x00dev, qual, rt2800_get_default_vgc(rt2x00dev));
2931 rt2800_set_vgc(rt2x00dev, qual,
2932 rt2800_get_default_vgc(rt2x00dev) +
2933 ((qual->
rssi > -80) * 0x10));
2940 static int rt2800_init_registers(
struct rt2x00_dev *rt2x00dev)
2949 ret = rt2800_drv_init_registers(rt2x00dev);
2953 rt2800_register_read(rt2x00dev,
BCN_OFFSET0, ®);
2958 rt2800_register_write(rt2x00dev,
BCN_OFFSET0, reg);
2960 rt2800_register_read(rt2x00dev,
BCN_OFFSET1, ®);
2965 rt2800_register_write(rt2x00dev,
BCN_OFFSET1, reg);
2968 rt2800_register_write(rt2x00dev,
HT_BASIC_RATE, 0x00008003);
2970 rt2800_register_write(rt2x00dev,
MAC_SYS_CTRL, 0x00000000);
2988 if (rt2x00_rt(rt2x00dev,
RT3290)) {
2995 rt2800_register_read(rt2x00dev,
CMB_CTRL, ®);
2999 rt2800_register_write(rt2x00dev,
CMB_CTRL, reg);
3002 rt2800_register_read(rt2x00dev,
OSC_CTRL, ®);
3006 rt2800_register_write(rt2x00dev,
OSC_CTRL, reg);
3008 rt2800_register_read(rt2x00dev,
COEX_CFG0, ®);
3010 rt2800_register_write(rt2x00dev,
COEX_CFG0, reg);
3012 rt2800_register_read(rt2x00dev,
COEX_CFG2, ®);
3017 rt2800_register_write(rt2x00dev,
COEX_CFG2, reg);
3019 rt2800_register_read(rt2x00dev,
PLL_CTRL, ®);
3021 rt2800_register_write(rt2x00dev,
PLL_CTRL, reg);
3024 if (rt2x00_rt(rt2x00dev,
RT3071) ||
3025 rt2x00_rt(rt2x00dev,
RT3090) ||
3026 rt2x00_rt(rt2x00dev,
RT3290) ||
3027 rt2x00_rt(rt2x00dev,
RT3390)) {
3029 if (rt2x00_rt(rt2x00dev,
RT3290))
3036 rt2800_register_write(rt2x00dev,
TX_SW_CFG1, 0x00000000);
3048 rt2800_register_write(rt2x00dev,
TX_SW_CFG2, 0x00000000);
3050 }
else if (rt2x00_rt(rt2x00dev,
RT3070)) {
3051 rt2800_register_write(rt2x00dev,
TX_SW_CFG0, 0x00000400);
3054 rt2800_register_write(rt2x00dev,
TX_SW_CFG1, 0x00000000);
3055 rt2800_register_write(rt2x00dev,
TX_SW_CFG2, 0x0000002c);
3057 rt2800_register_write(rt2x00dev,
TX_SW_CFG1, 0x00080606);
3058 rt2800_register_write(rt2x00dev,
TX_SW_CFG2, 0x00000000);
3060 }
else if (rt2800_is_305x_soc(rt2x00dev)) {
3061 rt2800_register_write(rt2x00dev,
TX_SW_CFG0, 0x00000400);
3062 rt2800_register_write(rt2x00dev,
TX_SW_CFG1, 0x00000000);
3063 rt2800_register_write(rt2x00dev,
TX_SW_CFG2, 0x00000030);
3064 }
else if (rt2x00_rt(rt2x00dev,
RT3352)) {
3065 rt2800_register_write(rt2x00dev,
TX_SW_CFG0, 0x00000402);
3066 rt2800_register_write(rt2x00dev,
TX_SW_CFG1, 0x00080606);
3067 rt2800_register_write(rt2x00dev,
TX_SW_CFG2, 0x00000000);
3068 }
else if (rt2x00_rt(rt2x00dev,
RT3572)) {
3069 rt2800_register_write(rt2x00dev,
TX_SW_CFG0, 0x00000400);
3070 rt2800_register_write(rt2x00dev,
TX_SW_CFG1, 0x00080606);
3071 }
else if (rt2x00_rt(rt2x00dev,
RT5390) ||
3072 rt2x00_rt(rt2x00dev,
RT5392)) {
3073 rt2800_register_write(rt2x00dev,
TX_SW_CFG0, 0x00000404);
3074 rt2800_register_write(rt2x00dev,
TX_SW_CFG1, 0x00080606);
3075 rt2800_register_write(rt2x00dev,
TX_SW_CFG2, 0x00000000);
3077 rt2800_register_write(rt2x00dev,
TX_SW_CFG0, 0x00000000);
3078 rt2800_register_write(rt2x00dev,
TX_SW_CFG1, 0x00080606);
3081 rt2800_register_read(rt2x00dev,
TX_LINK_CFG, ®);
3090 rt2800_register_write(rt2x00dev,
TX_LINK_CFG, reg);
3098 rt2800_register_read(rt2x00dev,
MAX_LEN_CFG, ®);
3101 rt2x00_rt(rt2x00dev,
RT2883) ||
3108 rt2800_register_write(rt2x00dev,
MAX_LEN_CFG, reg);
3110 rt2800_register_read(rt2x00dev,
LED_CFG, ®);
3118 rt2800_register_write(rt2x00dev,
LED_CFG, reg);
3120 rt2800_register_write(rt2x00dev,
PBF_MAX_PCNT, 0x1f3fbf9f);
3122 rt2800_register_read(rt2x00dev,
TX_RTY_CFG, ®);
3129 rt2800_register_write(rt2x00dev,
TX_RTY_CFG, reg);
3219 if (rt2x00_is_usb(rt2x00dev)) {
3220 rt2800_register_write(rt2x00dev,
PBF_CFG, 0xf40006);
3252 rt2800_register_write(rt2x00dev,
TXOP_HLDR_ET, 0x00000002);
3254 rt2800_register_read(rt2x00dev,
TX_RTS_CFG, ®);
3259 rt2800_register_write(rt2x00dev,
TX_RTS_CFG, reg);
3261 rt2800_register_write(rt2x00dev,
EXP_ACK_TIME, 0x002400ca);
3278 rt2800_register_write(rt2x00dev,
PWR_PIN_CFG, 0x00000003);
3283 for (i = 0; i < 4; i++)
3284 rt2800_register_write(rt2x00dev,
3287 for (i = 0; i < 256; i++) {
3288 rt2800_config_wcid(rt2x00dev,
NULL, i);
3289 rt2800_delete_wcid_attr(rt2x00dev, i);
3305 if (rt2x00_is_usb(rt2x00dev)) {
3306 rt2800_register_read(rt2x00dev,
US_CYC_CNT, ®);
3308 rt2800_register_write(rt2x00dev,
US_CYC_CNT, reg);
3309 }
else if (rt2x00_is_pcie(rt2x00dev)) {
3310 rt2800_register_read(rt2x00dev,
US_CYC_CNT, ®);
3312 rt2800_register_write(rt2x00dev,
US_CYC_CNT, reg);
3315 rt2800_register_read(rt2x00dev,
HT_FBK_CFG0, ®);
3324 rt2800_register_write(rt2x00dev,
HT_FBK_CFG0, reg);
3326 rt2800_register_read(rt2x00dev,
HT_FBK_CFG1, ®);
3335 rt2800_register_write(rt2x00dev,
HT_FBK_CFG1, reg);
3337 rt2800_register_read(rt2x00dev,
LG_FBK_CFG0, ®);
3346 rt2800_register_write(rt2x00dev,
LG_FBK_CFG0, reg);
3348 rt2800_register_read(rt2x00dev,
LG_FBK_CFG1, ®);
3353 rt2800_register_write(rt2x00dev,
LG_FBK_CFG1, reg);
3368 rt2800_register_read(rt2x00dev,
RX_STA_CNT0, ®);
3369 rt2800_register_read(rt2x00dev,
RX_STA_CNT1, ®);
3370 rt2800_register_read(rt2x00dev,
RX_STA_CNT2, ®);
3371 rt2800_register_read(rt2x00dev,
TX_STA_CNT0, ®);
3372 rt2800_register_read(rt2x00dev,
TX_STA_CNT1, ®);
3373 rt2800_register_read(rt2x00dev,
TX_STA_CNT2, ®);
3385 rt2800_register_read(rt2x00dev,
CH_TIME_CFG, ®);
3391 rt2800_register_write(rt2x00dev,
CH_TIME_CFG, reg);
3396 static int rt2800_wait_bbp_rf_ready(
struct rt2x00_dev *rt2x00dev)
3409 ERROR(rt2x00dev,
"BBP/RF register access failed, aborting.\n");
3413 static int rt2800_wait_bbp_ready(
struct rt2x00_dev *rt2x00dev)
3427 rt2800_bbp_read(rt2x00dev, 0, &value);
3428 if ((value != 0xff) && (value != 0x00))
3433 ERROR(rt2x00dev,
"BBP register access failed, aborting.\n");
3437 static int rt2800_init_bbp(
struct rt2x00_dev *rt2x00dev)
3444 if (
unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev) ||
3445 rt2800_wait_bbp_ready(rt2x00dev)))
3448 if (rt2x00_rt(rt2x00dev,
RT3352)) {
3449 rt2800_bbp_write(rt2x00dev, 3, 0x00);
3450 rt2800_bbp_write(rt2x00dev, 4, 0x50);
3453 if (rt2x00_rt(rt2x00dev,
RT3290) ||
3454 rt2x00_rt(rt2x00dev,
RT5390) ||
3455 rt2x00_rt(rt2x00dev,
RT5392)) {
3456 rt2800_bbp_read(rt2x00dev, 4, &value);
3458 rt2800_bbp_write(rt2x00dev, 4, value);
3461 if (rt2800_is_305x_soc(rt2x00dev) ||
3462 rt2x00_rt(rt2x00dev,
RT3290) ||
3463 rt2x00_rt(rt2x00dev,
RT3352) ||
3464 rt2x00_rt(rt2x00dev,
RT3572) ||
3465 rt2x00_rt(rt2x00dev,
RT5390) ||
3466 rt2x00_rt(rt2x00dev,
RT5392))
3467 rt2800_bbp_write(rt2x00dev, 31, 0x08);
3469 if (rt2x00_rt(rt2x00dev,
RT3352))
3470 rt2800_bbp_write(rt2x00dev, 47, 0x48);
3472 rt2800_bbp_write(rt2x00dev, 65, 0x2c);
3473 rt2800_bbp_write(rt2x00dev, 66, 0x38);
3475 if (rt2x00_rt(rt2x00dev,
RT3290) ||
3476 rt2x00_rt(rt2x00dev,
RT3352) ||
3477 rt2x00_rt(rt2x00dev,
RT5390) ||
3478 rt2x00_rt(rt2x00dev,
RT5392))
3479 rt2800_bbp_write(rt2x00dev, 68, 0x0b);
3482 rt2800_bbp_write(rt2x00dev, 69, 0x16);
3483 rt2800_bbp_write(rt2x00dev, 73, 0x12);
3484 }
else if (rt2x00_rt(rt2x00dev,
RT3290) ||
3485 rt2x00_rt(rt2x00dev,
RT3352) ||
3486 rt2x00_rt(rt2x00dev,
RT5390) ||
3487 rt2x00_rt(rt2x00dev,
RT5392)) {
3488 rt2800_bbp_write(rt2x00dev, 69, 0x12);
3489 rt2800_bbp_write(rt2x00dev, 73, 0x13);
3490 rt2800_bbp_write(rt2x00dev, 75, 0x46);
3491 rt2800_bbp_write(rt2x00dev, 76, 0x28);
3493 if (rt2x00_rt(rt2x00dev,
RT3290))
3494 rt2800_bbp_write(rt2x00dev, 77, 0x58);
3496 rt2800_bbp_write(rt2x00dev, 77, 0x59);
3498 rt2800_bbp_write(rt2x00dev, 69, 0x12);
3499 rt2800_bbp_write(rt2x00dev, 73, 0x10);
3502 rt2800_bbp_write(rt2x00dev, 70, 0x0a);
3504 if (rt2x00_rt(rt2x00dev,
RT3070) ||
3505 rt2x00_rt(rt2x00dev,
RT3071) ||
3506 rt2x00_rt(rt2x00dev,
RT3090) ||
3507 rt2x00_rt(rt2x00dev,
RT3390) ||
3508 rt2x00_rt(rt2x00dev,
RT3572) ||
3509 rt2x00_rt(rt2x00dev,
RT5390) ||
3510 rt2x00_rt(rt2x00dev,
RT5392)) {
3511 rt2800_bbp_write(rt2x00dev, 79, 0x13);
3512 rt2800_bbp_write(rt2x00dev, 80, 0x05);
3513 rt2800_bbp_write(rt2x00dev, 81, 0x33);
3514 }
else if (rt2800_is_305x_soc(rt2x00dev)) {
3515 rt2800_bbp_write(rt2x00dev, 78, 0x0e);
3516 rt2800_bbp_write(rt2x00dev, 80, 0x08);
3517 }
else if (rt2x00_rt(rt2x00dev,
RT3290)) {
3518 rt2800_bbp_write(rt2x00dev, 74, 0x0b);
3519 rt2800_bbp_write(rt2x00dev, 79, 0x18);
3520 rt2800_bbp_write(rt2x00dev, 80, 0x09);
3521 rt2800_bbp_write(rt2x00dev, 81, 0x33);
3522 }
else if (rt2x00_rt(rt2x00dev,
RT3352)) {
3523 rt2800_bbp_write(rt2x00dev, 78, 0x0e);
3524 rt2800_bbp_write(rt2x00dev, 80, 0x08);
3525 rt2800_bbp_write(rt2x00dev, 81, 0x37);
3527 rt2800_bbp_write(rt2x00dev, 81, 0x37);
3530 rt2800_bbp_write(rt2x00dev, 82, 0x62);
3531 if (rt2x00_rt(rt2x00dev,
RT3290) ||
3532 rt2x00_rt(rt2x00dev,
RT5390) ||
3533 rt2x00_rt(rt2x00dev,
RT5392))
3534 rt2800_bbp_write(rt2x00dev, 83, 0x7a);
3536 rt2800_bbp_write(rt2x00dev, 83, 0x6a);
3539 rt2800_bbp_write(rt2x00dev, 84, 0x19);
3540 else if (rt2x00_rt(rt2x00dev,
RT3290) ||
3541 rt2x00_rt(rt2x00dev,
RT5390) ||
3542 rt2x00_rt(rt2x00dev,
RT5392))
3543 rt2800_bbp_write(rt2x00dev, 84, 0x9a);
3545 rt2800_bbp_write(rt2x00dev, 84, 0x99);
3547 if (rt2x00_rt(rt2x00dev,
RT3290) ||
3548 rt2x00_rt(rt2x00dev,
RT3352) ||
3549 rt2x00_rt(rt2x00dev,
RT5390) ||
3550 rt2x00_rt(rt2x00dev,
RT5392))
3551 rt2800_bbp_write(rt2x00dev, 86, 0x38);
3553 rt2800_bbp_write(rt2x00dev, 86, 0x00);
3555 if (rt2x00_rt(rt2x00dev,
RT3352) ||
3556 rt2x00_rt(rt2x00dev,
RT5392))
3557 rt2800_bbp_write(rt2x00dev, 88, 0x90);
3559 rt2800_bbp_write(rt2x00dev, 91, 0x04);
3561 if (rt2x00_rt(rt2x00dev,
RT3290) ||
3562 rt2x00_rt(rt2x00dev,
RT3352) ||
3563 rt2x00_rt(rt2x00dev,
RT5390) ||
3564 rt2x00_rt(rt2x00dev,
RT5392))
3565 rt2800_bbp_write(rt2x00dev, 92, 0x02);
3567 rt2800_bbp_write(rt2x00dev, 92, 0x00);
3569 if (rt2x00_rt(rt2x00dev,
RT5392)) {
3570 rt2800_bbp_write(rt2x00dev, 95, 0x9a);
3571 rt2800_bbp_write(rt2x00dev, 98, 0x12);
3578 rt2x00_rt(rt2x00dev,
RT3290) ||
3579 rt2x00_rt(rt2x00dev,
RT3352) ||
3580 rt2x00_rt(rt2x00dev,
RT3572) ||
3581 rt2x00_rt(rt2x00dev,
RT5390) ||
3582 rt2x00_rt(rt2x00dev,
RT5392) ||
3583 rt2800_is_305x_soc(rt2x00dev))
3584 rt2800_bbp_write(rt2x00dev, 103, 0xc0);
3586 rt2800_bbp_write(rt2x00dev, 103, 0x00);
3588 if (rt2x00_rt(rt2x00dev,
RT3290) ||
3589 rt2x00_rt(rt2x00dev,
RT3352) ||
3590 rt2x00_rt(rt2x00dev,
RT5390) ||
3591 rt2x00_rt(rt2x00dev,
RT5392))
3592 rt2800_bbp_write(rt2x00dev, 104, 0x92);
3594 if (rt2800_is_305x_soc(rt2x00dev))
3595 rt2800_bbp_write(rt2x00dev, 105, 0x01);
3596 else if (rt2x00_rt(rt2x00dev,
RT3290))
3597 rt2800_bbp_write(rt2x00dev, 105, 0x1c);
3598 else if (rt2x00_rt(rt2x00dev,
RT3352))
3599 rt2800_bbp_write(rt2x00dev, 105, 0x34);
3600 else if (rt2x00_rt(rt2x00dev,
RT5390) ||
3601 rt2x00_rt(rt2x00dev,
RT5392))
3602 rt2800_bbp_write(rt2x00dev, 105, 0x3c);
3604 rt2800_bbp_write(rt2x00dev, 105, 0x05);
3606 if (rt2x00_rt(rt2x00dev,
RT3290) ||
3607 rt2x00_rt(rt2x00dev,
RT5390))
3608 rt2800_bbp_write(rt2x00dev, 106, 0x03);
3609 else if (rt2x00_rt(rt2x00dev,
RT3352))
3610 rt2800_bbp_write(rt2x00dev, 106, 0x05);
3611 else if (rt2x00_rt(rt2x00dev,
RT5392))
3612 rt2800_bbp_write(rt2x00dev, 106, 0x12);
3614 rt2800_bbp_write(rt2x00dev, 106, 0x35);
3616 if (rt2x00_rt(rt2x00dev,
RT3352))
3617 rt2800_bbp_write(rt2x00dev, 120, 0x50);
3619 if (rt2x00_rt(rt2x00dev,
RT3290) ||
3620 rt2x00_rt(rt2x00dev,
RT5390) ||
3621 rt2x00_rt(rt2x00dev,
RT5392))
3622 rt2800_bbp_write(rt2x00dev, 128, 0x12);
3624 if (rt2x00_rt(rt2x00dev,
RT5392)) {
3625 rt2800_bbp_write(rt2x00dev, 134, 0xd0);
3626 rt2800_bbp_write(rt2x00dev, 135, 0xf6);
3629 if (rt2x00_rt(rt2x00dev,
RT3352))
3630 rt2800_bbp_write(rt2x00dev, 137, 0x0f);
3632 if (rt2x00_rt(rt2x00dev,
RT3071) ||
3633 rt2x00_rt(rt2x00dev,
RT3090) ||
3634 rt2x00_rt(rt2x00dev,
RT3390) ||
3635 rt2x00_rt(rt2x00dev,
RT3572) ||
3636 rt2x00_rt(rt2x00dev,
RT5390) ||
3637 rt2x00_rt(rt2x00dev,
RT5392)) {
3638 rt2800_bbp_read(rt2x00dev, 138, &value);
3646 rt2800_bbp_write(rt2x00dev, 138, value);
3649 if (rt2x00_rt(rt2x00dev,
RT3290)) {
3650 rt2800_bbp_write(rt2x00dev, 67, 0x24);
3651 rt2800_bbp_write(rt2x00dev, 143, 0x04);
3652 rt2800_bbp_write(rt2x00dev, 142, 0x99);
3653 rt2800_bbp_write(rt2x00dev, 150, 0x30);
3654 rt2800_bbp_write(rt2x00dev, 151, 0x2e);
3655 rt2800_bbp_write(rt2x00dev, 152, 0x20);
3656 rt2800_bbp_write(rt2x00dev, 153, 0x34);
3657 rt2800_bbp_write(rt2x00dev, 154, 0x40);
3658 rt2800_bbp_write(rt2x00dev, 155, 0x3b);
3659 rt2800_bbp_write(rt2x00dev, 253, 0x04);
3661 rt2800_bbp_read(rt2x00dev, 47, &value);
3663 rt2800_bbp_write(rt2x00dev, 47, value);
3666 rt2800_bbp_read(rt2x00dev, 3, &value);
3669 rt2800_bbp_write(rt2x00dev, 3, value);
3672 if (rt2x00_rt(rt2x00dev,
RT3352)) {
3673 rt2800_bbp_write(rt2x00dev, 163, 0xbd);
3675 rt2800_bbp_write(rt2x00dev, 179, 0x02);
3676 rt2800_bbp_write(rt2x00dev, 180, 0x00);
3677 rt2800_bbp_write(rt2x00dev, 182, 0x40);
3678 rt2800_bbp_write(rt2x00dev, 180, 0x01);
3679 rt2800_bbp_write(rt2x00dev, 182, 0x9c);
3680 rt2800_bbp_write(rt2x00dev, 179, 0x00);
3682 rt2800_bbp_write(rt2x00dev, 142, 0x04);
3683 rt2800_bbp_write(rt2x00dev, 143, 0x3b);
3684 rt2800_bbp_write(rt2x00dev, 142, 0x06);
3685 rt2800_bbp_write(rt2x00dev, 143, 0xa0);
3686 rt2800_bbp_write(rt2x00dev, 142, 0x07);
3687 rt2800_bbp_write(rt2x00dev, 143, 0xa1);
3688 rt2800_bbp_write(rt2x00dev, 142, 0x08);
3689 rt2800_bbp_write(rt2x00dev, 143, 0xa2);
3691 rt2800_bbp_write(rt2x00dev, 148, 0xc8);
3694 if (rt2x00_rt(rt2x00dev,
RT5390) ||
3695 rt2x00_rt(rt2x00dev,
RT5392)) {
3701 ant = (div_mode == 3) ? 1 : 0;
3707 rt2800_register_read(rt2x00dev,
GPIO_CTRL, ®);
3716 rt2800_register_write(rt2x00dev,
GPIO_CTRL, reg);
3721 rt2800_bbp_write(rt2x00dev, 150, 0);
3722 rt2800_bbp_write(rt2x00dev, 151, 0);
3723 rt2800_bbp_write(rt2x00dev, 154, 0);
3726 rt2800_bbp_read(rt2x00dev, 152, &value);
3731 rt2800_bbp_write(rt2x00dev, 152, value);
3734 rt2800_bbp_write(rt2x00dev, 142, 1);
3735 rt2800_bbp_write(rt2x00dev, 143, 57);
3741 if (eeprom != 0xffff && eeprom != 0x0000) {
3744 rt2800_bbp_write(rt2x00dev, reg_id, value);
3751 static u8 rt2800_init_rx_filter(
struct rt2x00_dev *rt2x00dev,
3752 bool bw40,
u8 rfcsr24,
u8 filter_target)
3761 rt2800_rfcsr_write(rt2x00dev, 24, rfcsr24);
3763 rt2800_bbp_read(rt2x00dev, 4, &bbp);
3765 rt2800_bbp_write(rt2x00dev, 4, bbp);
3767 rt2800_rfcsr_read(rt2x00dev, 31, &rfcsr);
3769 rt2800_rfcsr_write(rt2x00dev, 31, rfcsr);
3771 rt2800_rfcsr_read(rt2x00dev, 22, &rfcsr);
3773 rt2800_rfcsr_write(rt2x00dev, 22, rfcsr);
3778 rt2800_bbp_write(rt2x00dev, 24, 0);
3780 for (i = 0; i < 100; i++) {
3781 rt2800_bbp_write(rt2x00dev, 25, 0x90);
3784 rt2800_bbp_read(rt2x00dev, 55, &passband);
3792 rt2800_bbp_write(rt2x00dev, 24, 0x06);
3794 for (i = 0; i < 100; i++) {
3795 rt2800_bbp_write(rt2x00dev, 25, 0x90);
3798 rt2800_bbp_read(rt2x00dev, 55, &stopband);
3800 if ((passband - stopband) <= filter_target) {
3802 overtuned += ((passband - stopband) == filter_target);
3806 rt2800_rfcsr_write(rt2x00dev, 24, rfcsr24);
3809 rfcsr24 -= !!overtuned;
3811 rt2800_rfcsr_write(rt2x00dev, 24, rfcsr24);
3815 static int rt2800_init_rfcsr(
struct rt2x00_dev *rt2x00dev)
3823 if (!rt2x00_rt(rt2x00dev,
RT3070) &&
3824 !rt2x00_rt(rt2x00dev,
RT3071) &&
3825 !rt2x00_rt(rt2x00dev,
RT3090) &&
3826 !rt2x00_rt(rt2x00dev,
RT3290) &&
3827 !rt2x00_rt(rt2x00dev,
RT3352) &&
3828 !rt2x00_rt(rt2x00dev,
RT3390) &&
3829 !rt2x00_rt(rt2x00dev,
RT3572) &&
3830 !rt2x00_rt(rt2x00dev,
RT5390) &&
3831 !rt2x00_rt(rt2x00dev,
RT5392) &&
3832 !rt2800_is_305x_soc(rt2x00dev))
3838 if (rt2x00_rt(rt2x00dev,
RT3290) ||
3839 rt2x00_rt(rt2x00dev,
RT5390) ||
3840 rt2x00_rt(rt2x00dev,
RT5392)) {
3841 rt2800_rfcsr_read(rt2x00dev, 2, &rfcsr);
3843 rt2800_rfcsr_write(rt2x00dev, 2, rfcsr);
3846 rt2800_rfcsr_write(rt2x00dev, 2, rfcsr);
3848 rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
3850 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
3853 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
3856 if (rt2x00_rt(rt2x00dev,
RT3070) ||
3857 rt2x00_rt(rt2x00dev,
RT3071) ||
3858 rt2x00_rt(rt2x00dev,
RT3090)) {
3859 rt2800_rfcsr_write(rt2x00dev, 4, 0x40);
3860 rt2800_rfcsr_write(rt2x00dev, 5, 0x03);
3861 rt2800_rfcsr_write(rt2x00dev, 6, 0x02);
3862 rt2800_rfcsr_write(rt2x00dev, 7, 0x60);
3863 rt2800_rfcsr_write(rt2x00dev, 9, 0x0f);
3864 rt2800_rfcsr_write(rt2x00dev, 10, 0x41);
3865 rt2800_rfcsr_write(rt2x00dev, 11, 0x21);
3866 rt2800_rfcsr_write(rt2x00dev, 12, 0x7b);
3867 rt2800_rfcsr_write(rt2x00dev, 14, 0x90);
3868 rt2800_rfcsr_write(rt2x00dev, 15, 0x58);
3869 rt2800_rfcsr_write(rt2x00dev, 16, 0xb3);
3870 rt2800_rfcsr_write(rt2x00dev, 17, 0x92);
3871 rt2800_rfcsr_write(rt2x00dev, 18, 0x2c);
3872 rt2800_rfcsr_write(rt2x00dev, 19, 0x02);
3873 rt2800_rfcsr_write(rt2x00dev, 20, 0xba);
3874 rt2800_rfcsr_write(rt2x00dev, 21, 0xdb);
3875 rt2800_rfcsr_write(rt2x00dev, 24, 0x16);
3876 rt2800_rfcsr_write(rt2x00dev, 25, 0x01);
3877 rt2800_rfcsr_write(rt2x00dev, 29, 0x1f);
3878 }
else if (rt2x00_rt(rt2x00dev,
RT3290)) {
3879 rt2800_rfcsr_write(rt2x00dev, 1, 0x0f);
3880 rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
3881 rt2800_rfcsr_write(rt2x00dev, 3, 0x08);
3882 rt2800_rfcsr_write(rt2x00dev, 4, 0x00);
3883 rt2800_rfcsr_write(rt2x00dev, 6, 0xa0);
3884 rt2800_rfcsr_write(rt2x00dev, 8, 0xf3);
3885 rt2800_rfcsr_write(rt2x00dev, 9, 0x02);
3886 rt2800_rfcsr_write(rt2x00dev, 10, 0x53);
3887 rt2800_rfcsr_write(rt2x00dev, 11, 0x4a);
3888 rt2800_rfcsr_write(rt2x00dev, 12, 0x46);
3889 rt2800_rfcsr_write(rt2x00dev, 13, 0x9f);
3890 rt2800_rfcsr_write(rt2x00dev, 18, 0x02);
3891 rt2800_rfcsr_write(rt2x00dev, 22, 0x20);
3892 rt2800_rfcsr_write(rt2x00dev, 25, 0x83);
3893 rt2800_rfcsr_write(rt2x00dev, 26, 0x82);
3894 rt2800_rfcsr_write(rt2x00dev, 27, 0x09);
3895 rt2800_rfcsr_write(rt2x00dev, 29, 0x10);
3896 rt2800_rfcsr_write(rt2x00dev, 30, 0x10);
3897 rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
3898 rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
3899 rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
3900 rt2800_rfcsr_write(rt2x00dev, 34, 0x05);
3901 rt2800_rfcsr_write(rt2x00dev, 35, 0x12);
3902 rt2800_rfcsr_write(rt2x00dev, 36, 0x00);
3903 rt2800_rfcsr_write(rt2x00dev, 38, 0x85);
3904 rt2800_rfcsr_write(rt2x00dev, 39, 0x1b);
3905 rt2800_rfcsr_write(rt2x00dev, 40, 0x0b);
3906 rt2800_rfcsr_write(rt2x00dev, 41, 0xbb);
3907 rt2800_rfcsr_write(rt2x00dev, 42, 0xd5);
3908 rt2800_rfcsr_write(rt2x00dev, 43, 0x7b);
3909 rt2800_rfcsr_write(rt2x00dev, 44, 0x0e);
3910 rt2800_rfcsr_write(rt2x00dev, 45, 0xa2);
3911 rt2800_rfcsr_write(rt2x00dev, 46, 0x73);
3912 rt2800_rfcsr_write(rt2x00dev, 47, 0x00);
3913 rt2800_rfcsr_write(rt2x00dev, 48, 0x10);
3914 rt2800_rfcsr_write(rt2x00dev, 49, 0x98);
3915 rt2800_rfcsr_write(rt2x00dev, 52, 0x38);
3916 rt2800_rfcsr_write(rt2x00dev, 53, 0x00);
3917 rt2800_rfcsr_write(rt2x00dev, 54, 0x78);
3918 rt2800_rfcsr_write(rt2x00dev, 55, 0x43);
3919 rt2800_rfcsr_write(rt2x00dev, 56, 0x02);
3920 rt2800_rfcsr_write(rt2x00dev, 57, 0x80);
3921 rt2800_rfcsr_write(rt2x00dev, 58, 0x7f);
3922 rt2800_rfcsr_write(rt2x00dev, 59, 0x09);
3923 rt2800_rfcsr_write(rt2x00dev, 60, 0x45);
3924 rt2800_rfcsr_write(rt2x00dev, 61, 0xc1);
3925 }
else if (rt2x00_rt(rt2x00dev,
RT3390)) {
3926 rt2800_rfcsr_write(rt2x00dev, 0, 0xa0);
3927 rt2800_rfcsr_write(rt2x00dev, 1, 0xe1);
3928 rt2800_rfcsr_write(rt2x00dev, 2, 0xf1);
3929 rt2800_rfcsr_write(rt2x00dev, 3, 0x62);
3930 rt2800_rfcsr_write(rt2x00dev, 4, 0x40);
3931 rt2800_rfcsr_write(rt2x00dev, 5, 0x8b);
3932 rt2800_rfcsr_write(rt2x00dev, 6, 0x42);
3933 rt2800_rfcsr_write(rt2x00dev, 7, 0x34);
3934 rt2800_rfcsr_write(rt2x00dev, 8, 0x00);
3935 rt2800_rfcsr_write(rt2x00dev, 9, 0xc0);
3936 rt2800_rfcsr_write(rt2x00dev, 10, 0x61);
3937 rt2800_rfcsr_write(rt2x00dev, 11, 0x21);
3938 rt2800_rfcsr_write(rt2x00dev, 12, 0x3b);
3939 rt2800_rfcsr_write(rt2x00dev, 13, 0xe0);
3940 rt2800_rfcsr_write(rt2x00dev, 14, 0x90);
3941 rt2800_rfcsr_write(rt2x00dev, 15, 0x53);
3942 rt2800_rfcsr_write(rt2x00dev, 16, 0xe0);
3943 rt2800_rfcsr_write(rt2x00dev, 17, 0x94);
3944 rt2800_rfcsr_write(rt2x00dev, 18, 0x5c);
3945 rt2800_rfcsr_write(rt2x00dev, 19, 0x4a);
3946 rt2800_rfcsr_write(rt2x00dev, 20, 0xb2);
3947 rt2800_rfcsr_write(rt2x00dev, 21, 0xf6);
3948 rt2800_rfcsr_write(rt2x00dev, 22, 0x00);
3949 rt2800_rfcsr_write(rt2x00dev, 23, 0x14);
3950 rt2800_rfcsr_write(rt2x00dev, 24, 0x08);
3951 rt2800_rfcsr_write(rt2x00dev, 25, 0x3d);
3952 rt2800_rfcsr_write(rt2x00dev, 26, 0x85);
3953 rt2800_rfcsr_write(rt2x00dev, 27, 0x00);
3954 rt2800_rfcsr_write(rt2x00dev, 28, 0x41);
3955 rt2800_rfcsr_write(rt2x00dev, 29, 0x8f);
3956 rt2800_rfcsr_write(rt2x00dev, 30, 0x20);
3957 rt2800_rfcsr_write(rt2x00dev, 31, 0x0f);
3958 }
else if (rt2x00_rt(rt2x00dev,
RT3572)) {
3959 rt2800_rfcsr_write(rt2x00dev, 0, 0x70);
3960 rt2800_rfcsr_write(rt2x00dev, 1, 0x81);
3961 rt2800_rfcsr_write(rt2x00dev, 2, 0xf1);
3962 rt2800_rfcsr_write(rt2x00dev, 3, 0x02);
3963 rt2800_rfcsr_write(rt2x00dev, 4, 0x4c);
3964 rt2800_rfcsr_write(rt2x00dev, 5, 0x05);
3965 rt2800_rfcsr_write(rt2x00dev, 6, 0x4a);
3966 rt2800_rfcsr_write(rt2x00dev, 7, 0xd8);
3967 rt2800_rfcsr_write(rt2x00dev, 9, 0xc3);
3968 rt2800_rfcsr_write(rt2x00dev, 10, 0xf1);
3969 rt2800_rfcsr_write(rt2x00dev, 11, 0xb9);
3970 rt2800_rfcsr_write(rt2x00dev, 12, 0x70);
3971 rt2800_rfcsr_write(rt2x00dev, 13, 0x65);
3972 rt2800_rfcsr_write(rt2x00dev, 14, 0xa0);
3973 rt2800_rfcsr_write(rt2x00dev, 15, 0x53);
3974 rt2800_rfcsr_write(rt2x00dev, 16, 0x4c);
3975 rt2800_rfcsr_write(rt2x00dev, 17, 0x23);
3976 rt2800_rfcsr_write(rt2x00dev, 18, 0xac);
3977 rt2800_rfcsr_write(rt2x00dev, 19, 0x93);
3978 rt2800_rfcsr_write(rt2x00dev, 20, 0xb3);
3979 rt2800_rfcsr_write(rt2x00dev, 21, 0xd0);
3980 rt2800_rfcsr_write(rt2x00dev, 22, 0x00);
3981 rt2800_rfcsr_write(rt2x00dev, 23, 0x3c);
3982 rt2800_rfcsr_write(rt2x00dev, 24, 0x16);
3983 rt2800_rfcsr_write(rt2x00dev, 25, 0x15);
3984 rt2800_rfcsr_write(rt2x00dev, 26, 0x85);
3985 rt2800_rfcsr_write(rt2x00dev, 27, 0x00);
3986 rt2800_rfcsr_write(rt2x00dev, 28, 0x00);
3987 rt2800_rfcsr_write(rt2x00dev, 29, 0x9b);
3988 rt2800_rfcsr_write(rt2x00dev, 30, 0x09);
3989 rt2800_rfcsr_write(rt2x00dev, 31, 0x10);
3990 }
else if (rt2800_is_305x_soc(rt2x00dev)) {
3991 rt2800_rfcsr_write(rt2x00dev, 0, 0x50);
3992 rt2800_rfcsr_write(rt2x00dev, 1, 0x01);
3993 rt2800_rfcsr_write(rt2x00dev, 2, 0xf7);
3994 rt2800_rfcsr_write(rt2x00dev, 3, 0x75);
3995 rt2800_rfcsr_write(rt2x00dev, 4, 0x40);
3996 rt2800_rfcsr_write(rt2x00dev, 5, 0x03);
3997 rt2800_rfcsr_write(rt2x00dev, 6, 0x02);
3998 rt2800_rfcsr_write(rt2x00dev, 7, 0x50);
3999 rt2800_rfcsr_write(rt2x00dev, 8, 0x39);
4000 rt2800_rfcsr_write(rt2x00dev, 9, 0x0f);
4001 rt2800_rfcsr_write(rt2x00dev, 10, 0x60);
4002 rt2800_rfcsr_write(rt2x00dev, 11, 0x21);
4003 rt2800_rfcsr_write(rt2x00dev, 12, 0x75);
4004 rt2800_rfcsr_write(rt2x00dev, 13, 0x75);
4005 rt2800_rfcsr_write(rt2x00dev, 14, 0x90);
4006 rt2800_rfcsr_write(rt2x00dev, 15, 0x58);
4007 rt2800_rfcsr_write(rt2x00dev, 16, 0xb3);
4008 rt2800_rfcsr_write(rt2x00dev, 17, 0x92);
4009 rt2800_rfcsr_write(rt2x00dev, 18, 0x2c);
4010 rt2800_rfcsr_write(rt2x00dev, 19, 0x02);
4011 rt2800_rfcsr_write(rt2x00dev, 20, 0xba);
4012 rt2800_rfcsr_write(rt2x00dev, 21, 0xdb);
4013 rt2800_rfcsr_write(rt2x00dev, 22, 0x00);
4014 rt2800_rfcsr_write(rt2x00dev, 23, 0x31);
4015 rt2800_rfcsr_write(rt2x00dev, 24, 0x08);
4016 rt2800_rfcsr_write(rt2x00dev, 25, 0x01);
4017 rt2800_rfcsr_write(rt2x00dev, 26, 0x25);
4018 rt2800_rfcsr_write(rt2x00dev, 27, 0x23);
4019 rt2800_rfcsr_write(rt2x00dev, 28, 0x13);
4020 rt2800_rfcsr_write(rt2x00dev, 29, 0x83);
4021 rt2800_rfcsr_write(rt2x00dev, 30, 0x00);
4022 rt2800_rfcsr_write(rt2x00dev, 31, 0x00);
4024 }
else if (rt2x00_rt(rt2x00dev,
RT3352)) {
4025 rt2800_rfcsr_write(rt2x00dev, 0, 0xf0);
4026 rt2800_rfcsr_write(rt2x00dev, 1, 0x23);
4027 rt2800_rfcsr_write(rt2x00dev, 2, 0x50);
4028 rt2800_rfcsr_write(rt2x00dev, 3, 0x18);
4029 rt2800_rfcsr_write(rt2x00dev, 4, 0x00);
4030 rt2800_rfcsr_write(rt2x00dev, 5, 0x00);
4031 rt2800_rfcsr_write(rt2x00dev, 6, 0x33);
4032 rt2800_rfcsr_write(rt2x00dev, 7, 0x00);
4033 rt2800_rfcsr_write(rt2x00dev, 8, 0xf1);
4034 rt2800_rfcsr_write(rt2x00dev, 9, 0x02);
4035 rt2800_rfcsr_write(rt2x00dev, 10, 0xd2);
4036 rt2800_rfcsr_write(rt2x00dev, 11, 0x42);
4037 rt2800_rfcsr_write(rt2x00dev, 12, 0x1c);
4038 rt2800_rfcsr_write(rt2x00dev, 13, 0x00);
4039 rt2800_rfcsr_write(rt2x00dev, 14, 0x5a);
4040 rt2800_rfcsr_write(rt2x00dev, 15, 0x00);
4041 rt2800_rfcsr_write(rt2x00dev, 16, 0x01);
4042 rt2800_rfcsr_write(rt2x00dev, 18, 0x45);
4043 rt2800_rfcsr_write(rt2x00dev, 19, 0x02);
4044 rt2800_rfcsr_write(rt2x00dev, 20, 0x00);
4045 rt2800_rfcsr_write(rt2x00dev, 21, 0x00);
4046 rt2800_rfcsr_write(rt2x00dev, 22, 0x00);
4047 rt2800_rfcsr_write(rt2x00dev, 23, 0x00);
4048 rt2800_rfcsr_write(rt2x00dev, 24, 0x00);
4049 rt2800_rfcsr_write(rt2x00dev, 25, 0x80);
4050 rt2800_rfcsr_write(rt2x00dev, 26, 0x00);
4051 rt2800_rfcsr_write(rt2x00dev, 27, 0x03);
4052 rt2800_rfcsr_write(rt2x00dev, 28, 0x03);
4053 rt2800_rfcsr_write(rt2x00dev, 29, 0x00);
4054 rt2800_rfcsr_write(rt2x00dev, 30, 0x10);
4055 rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
4056 rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
4057 rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
4058 rt2800_rfcsr_write(rt2x00dev, 34, 0x01);
4059 rt2800_rfcsr_write(rt2x00dev, 35, 0x03);
4060 rt2800_rfcsr_write(rt2x00dev, 36, 0xbd);
4061 rt2800_rfcsr_write(rt2x00dev, 37, 0x3c);
4062 rt2800_rfcsr_write(rt2x00dev, 38, 0x5f);
4063 rt2800_rfcsr_write(rt2x00dev, 39, 0xc5);
4064 rt2800_rfcsr_write(rt2x00dev, 40, 0x33);
4065 rt2800_rfcsr_write(rt2x00dev, 41, 0x5b);
4066 rt2800_rfcsr_write(rt2x00dev, 42, 0x5b);
4067 rt2800_rfcsr_write(rt2x00dev, 43, 0xdb);
4068 rt2800_rfcsr_write(rt2x00dev, 44, 0xdb);
4069 rt2800_rfcsr_write(rt2x00dev, 45, 0xdb);
4070 rt2800_rfcsr_write(rt2x00dev, 46, 0xdd);
4071 rt2800_rfcsr_write(rt2x00dev, 47, 0x0d);
4072 rt2800_rfcsr_write(rt2x00dev, 48, 0x14);
4073 rt2800_rfcsr_write(rt2x00dev, 49, 0x00);
4074 rt2800_rfcsr_write(rt2x00dev, 50, 0x2d);
4075 rt2800_rfcsr_write(rt2x00dev, 51, 0x7f);
4076 rt2800_rfcsr_write(rt2x00dev, 52, 0x00);
4077 rt2800_rfcsr_write(rt2x00dev, 53, 0x52);
4078 rt2800_rfcsr_write(rt2x00dev, 54, 0x1b);
4079 rt2800_rfcsr_write(rt2x00dev, 55, 0x7f);
4080 rt2800_rfcsr_write(rt2x00dev, 56, 0x00);
4081 rt2800_rfcsr_write(rt2x00dev, 57, 0x52);
4082 rt2800_rfcsr_write(rt2x00dev, 58, 0x1b);
4083 rt2800_rfcsr_write(rt2x00dev, 59, 0x00);
4084 rt2800_rfcsr_write(rt2x00dev, 60, 0x00);
4085 rt2800_rfcsr_write(rt2x00dev, 61, 0x00);
4086 rt2800_rfcsr_write(rt2x00dev, 62, 0x00);
4087 rt2800_rfcsr_write(rt2x00dev, 63, 0x00);
4088 }
else if (rt2x00_rt(rt2x00dev,
RT5390)) {
4089 rt2800_rfcsr_write(rt2x00dev, 1, 0x0f);
4090 rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
4091 rt2800_rfcsr_write(rt2x00dev, 3, 0x88);
4092 rt2800_rfcsr_write(rt2x00dev, 5, 0x10);
4094 rt2800_rfcsr_write(rt2x00dev, 6, 0xe0);
4096 rt2800_rfcsr_write(rt2x00dev, 6, 0xa0);
4097 rt2800_rfcsr_write(rt2x00dev, 7, 0x00);
4098 rt2800_rfcsr_write(rt2x00dev, 10, 0x53);
4099 rt2800_rfcsr_write(rt2x00dev, 11, 0x4a);
4100 rt2800_rfcsr_write(rt2x00dev, 12, 0xc6);
4101 rt2800_rfcsr_write(rt2x00dev, 13, 0x9f);
4102 rt2800_rfcsr_write(rt2x00dev, 14, 0x00);
4103 rt2800_rfcsr_write(rt2x00dev, 15, 0x00);
4104 rt2800_rfcsr_write(rt2x00dev, 16, 0x00);
4105 rt2800_rfcsr_write(rt2x00dev, 18, 0x03);
4106 rt2800_rfcsr_write(rt2x00dev, 19, 0x00);
4108 rt2800_rfcsr_write(rt2x00dev, 20, 0x00);
4109 rt2800_rfcsr_write(rt2x00dev, 21, 0x00);
4110 rt2800_rfcsr_write(rt2x00dev, 22, 0x20);
4111 rt2800_rfcsr_write(rt2x00dev, 23, 0x00);
4112 rt2800_rfcsr_write(rt2x00dev, 24, 0x00);
4114 rt2800_rfcsr_write(rt2x00dev, 25, 0x80);
4116 rt2800_rfcsr_write(rt2x00dev, 25, 0xc0);
4117 rt2800_rfcsr_write(rt2x00dev, 26, 0x00);
4118 rt2800_rfcsr_write(rt2x00dev, 27, 0x09);
4119 rt2800_rfcsr_write(rt2x00dev, 28, 0x00);
4120 rt2800_rfcsr_write(rt2x00dev, 29, 0x10);
4122 rt2800_rfcsr_write(rt2x00dev, 30, 0x00);
4123 rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
4124 rt2800_rfcsr_write(rt2x00dev, 32, 0x80);
4125 rt2800_rfcsr_write(rt2x00dev, 33, 0x00);
4126 rt2800_rfcsr_write(rt2x00dev, 34, 0x07);
4127 rt2800_rfcsr_write(rt2x00dev, 35, 0x12);
4128 rt2800_rfcsr_write(rt2x00dev, 36, 0x00);
4129 rt2800_rfcsr_write(rt2x00dev, 37, 0x08);
4130 rt2800_rfcsr_write(rt2x00dev, 38, 0x85);
4131 rt2800_rfcsr_write(rt2x00dev, 39, 0x1b);
4134 rt2800_rfcsr_write(rt2x00dev, 40, 0x0b);
4136 rt2800_rfcsr_write(rt2x00dev, 40, 0x4b);
4137 rt2800_rfcsr_write(rt2x00dev, 41, 0xbb);
4138 rt2800_rfcsr_write(rt2x00dev, 42, 0xd2);
4139 rt2800_rfcsr_write(rt2x00dev, 43, 0x9a);
4140 rt2800_rfcsr_write(rt2x00dev, 44, 0x0e);
4141 rt2800_rfcsr_write(rt2x00dev, 45, 0xa2);
4143 rt2800_rfcsr_write(rt2x00dev, 46, 0x73);
4145 rt2800_rfcsr_write(rt2x00dev, 46, 0x7b);
4146 rt2800_rfcsr_write(rt2x00dev, 47, 0x00);
4147 rt2800_rfcsr_write(rt2x00dev, 48, 0x10);
4148 rt2800_rfcsr_write(rt2x00dev, 49, 0x94);
4150 rt2800_rfcsr_write(rt2x00dev, 52, 0x38);
4152 rt2800_rfcsr_write(rt2x00dev, 53, 0x00);
4154 rt2800_rfcsr_write(rt2x00dev, 53, 0x84);
4155 rt2800_rfcsr_write(rt2x00dev, 54, 0x78);
4156 rt2800_rfcsr_write(rt2x00dev, 55, 0x44);
4157 rt2800_rfcsr_write(rt2x00dev, 56, 0x22);
4158 rt2800_rfcsr_write(rt2x00dev, 57, 0x80);
4159 rt2800_rfcsr_write(rt2x00dev, 58, 0x7f);
4160 rt2800_rfcsr_write(rt2x00dev, 59, 0x63);
4162 rt2800_rfcsr_write(rt2x00dev, 60, 0x45);
4164 rt2800_rfcsr_write(rt2x00dev, 61, 0xd1);
4166 rt2800_rfcsr_write(rt2x00dev, 61, 0xdd);
4167 rt2800_rfcsr_write(rt2x00dev, 62, 0x00);
4168 rt2800_rfcsr_write(rt2x00dev, 63, 0x00);
4169 }
else if (rt2x00_rt(rt2x00dev,
RT5392)) {
4170 rt2800_rfcsr_write(rt2x00dev, 1, 0x17);
4171 rt2800_rfcsr_write(rt2x00dev, 2, 0x80);
4172 rt2800_rfcsr_write(rt2x00dev, 3, 0x88);
4173 rt2800_rfcsr_write(rt2x00dev, 5, 0x10);
4174 rt2800_rfcsr_write(rt2x00dev, 6, 0xe0);
4175 rt2800_rfcsr_write(rt2x00dev, 7, 0x00);
4176 rt2800_rfcsr_write(rt2x00dev, 10, 0x53);
4177 rt2800_rfcsr_write(rt2x00dev, 11, 0x4a);
4178 rt2800_rfcsr_write(rt2x00dev, 12, 0x46);
4179 rt2800_rfcsr_write(rt2x00dev, 13, 0x9f);
4180 rt2800_rfcsr_write(rt2x00dev, 14, 0x00);
4181 rt2800_rfcsr_write(rt2x00dev, 15, 0x00);
4182 rt2800_rfcsr_write(rt2x00dev, 16, 0x00);
4183 rt2800_rfcsr_write(rt2x00dev, 18, 0x03);
4184 rt2800_rfcsr_write(rt2x00dev, 19, 0x4d);
4185 rt2800_rfcsr_write(rt2x00dev, 20, 0x00);
4186 rt2800_rfcsr_write(rt2x00dev, 21, 0x8d);
4187 rt2800_rfcsr_write(rt2x00dev, 22, 0x20);
4188 rt2800_rfcsr_write(rt2x00dev, 23, 0x0b);
4189 rt2800_rfcsr_write(rt2x00dev, 24, 0x44);
4190 rt2800_rfcsr_write(rt2x00dev, 25, 0x80);
4191 rt2800_rfcsr_write(rt2x00dev, 26, 0x82);
4192 rt2800_rfcsr_write(rt2x00dev, 27, 0x09);
4193 rt2800_rfcsr_write(rt2x00dev, 28, 0x00);
4194 rt2800_rfcsr_write(rt2x00dev, 29, 0x10);
4195 rt2800_rfcsr_write(rt2x00dev, 30, 0x10);
4196 rt2800_rfcsr_write(rt2x00dev, 31, 0x80);
4197 rt2800_rfcsr_write(rt2x00dev, 32, 0x20);
4198 rt2800_rfcsr_write(rt2x00dev, 33, 0xC0);
4199 rt2800_rfcsr_write(rt2x00dev, 34, 0x07);
4200 rt2800_rfcsr_write(rt2x00dev, 35, 0x12);
4201 rt2800_rfcsr_write(rt2x00dev, 36, 0x00);
4202 rt2800_rfcsr_write(rt2x00dev, 37, 0x08);
4203 rt2800_rfcsr_write(rt2x00dev, 38, 0x89);
4204 rt2800_rfcsr_write(rt2x00dev, 39, 0x1b);
4205 rt2800_rfcsr_write(rt2x00dev, 40, 0x0f);
4206 rt2800_rfcsr_write(rt2x00dev, 41, 0xbb);
4207 rt2800_rfcsr_write(rt2x00dev, 42, 0xd5);
4208 rt2800_rfcsr_write(rt2x00dev, 43, 0x9b);
4209 rt2800_rfcsr_write(rt2x00dev, 44, 0x0e);
4210 rt2800_rfcsr_write(rt2x00dev, 45, 0xa2);
4211 rt2800_rfcsr_write(rt2x00dev, 46, 0x73);
4212 rt2800_rfcsr_write(rt2x00dev, 47, 0x0c);
4213 rt2800_rfcsr_write(rt2x00dev, 48, 0x10);
4214 rt2800_rfcsr_write(rt2x00dev, 49, 0x94);
4215 rt2800_rfcsr_write(rt2x00dev, 50, 0x94);
4216 rt2800_rfcsr_write(rt2x00dev, 51, 0x3a);
4217 rt2800_rfcsr_write(rt2x00dev, 52, 0x48);
4218 rt2800_rfcsr_write(rt2x00dev, 53, 0x44);
4219 rt2800_rfcsr_write(rt2x00dev, 54, 0x38);
4220 rt2800_rfcsr_write(rt2x00dev, 55, 0x43);
4221 rt2800_rfcsr_write(rt2x00dev, 56, 0xa1);
4222 rt2800_rfcsr_write(rt2x00dev, 57, 0x00);
4223 rt2800_rfcsr_write(rt2x00dev, 58, 0x39);
4224 rt2800_rfcsr_write(rt2x00dev, 59, 0x07);
4225 rt2800_rfcsr_write(rt2x00dev, 60, 0x45);
4226 rt2800_rfcsr_write(rt2x00dev, 61, 0x91);
4227 rt2800_rfcsr_write(rt2x00dev, 62, 0x39);
4228 rt2800_rfcsr_write(rt2x00dev, 63, 0x07);
4232 rt2800_register_read(rt2x00dev,
LDO_CFG0, ®);
4235 rt2800_register_write(rt2x00dev,
LDO_CFG0, reg);
4236 }
else if (rt2x00_rt(rt2x00dev,
RT3071) ||
4237 rt2x00_rt(rt2x00dev,
RT3090)) {
4238 rt2800_rfcsr_write(rt2x00dev, 31, 0x14);
4240 rt2800_rfcsr_read(rt2x00dev, 6, &rfcsr);
4242 rt2800_rfcsr_write(rt2x00dev, 6, rfcsr);
4244 rt2800_register_read(rt2x00dev,
LDO_CFG0, ®);
4254 rt2800_register_write(rt2x00dev,
LDO_CFG0, reg);
4256 rt2800_register_read(rt2x00dev,
GPIO_SWITCH, ®);
4258 rt2800_register_write(rt2x00dev,
GPIO_SWITCH, reg);
4259 }
else if (rt2x00_rt(rt2x00dev,
RT3390)) {
4260 rt2800_register_read(rt2x00dev,
GPIO_SWITCH, ®);
4262 rt2800_register_write(rt2x00dev,
GPIO_SWITCH, reg);
4263 }
else if (rt2x00_rt(rt2x00dev,
RT3572)) {
4264 rt2800_rfcsr_read(rt2x00dev, 6, &rfcsr);
4266 rt2800_rfcsr_write(rt2x00dev, 6, rfcsr);
4268 rt2800_register_read(rt2x00dev,
LDO_CFG0, ®);
4271 rt2800_register_write(rt2x00dev,
LDO_CFG0, reg);
4273 rt2800_register_read(rt2x00dev,
LDO_CFG0, ®);
4276 rt2800_register_write(rt2x00dev,
LDO_CFG0, reg);
4282 if (rt2x00_rt(rt2x00dev,
RT3070)) {
4284 rt2800_init_rx_filter(rt2x00dev,
false, 0x07, 0x16);
4286 rt2800_init_rx_filter(rt2x00dev,
true, 0x27, 0x19);
4287 }
else if (rt2x00_rt(rt2x00dev,
RT3071) ||
4288 rt2x00_rt(rt2x00dev,
RT3090) ||
4289 rt2x00_rt(rt2x00dev,
RT3352) ||
4290 rt2x00_rt(rt2x00dev,
RT3390) ||
4291 rt2x00_rt(rt2x00dev,
RT3572)) {
4293 rt2800_init_rx_filter(rt2x00dev,
false, 0x07, 0x13);
4295 rt2800_init_rx_filter(rt2x00dev,
true, 0x27, 0x15);
4301 rt2800_bbp_read(rt2x00dev, 25, &drv_data->
bbp25);
4302 rt2800_bbp_read(rt2x00dev, 26, &drv_data->
bbp26);
4304 if (!rt2x00_rt(rt2x00dev,
RT5390) &&
4305 !rt2x00_rt(rt2x00dev,
RT5392)) {
4309 rt2800_bbp_write(rt2x00dev, 24, 0);
4311 rt2800_rfcsr_read(rt2x00dev, 22, &rfcsr);
4313 rt2800_rfcsr_write(rt2x00dev, 22, rfcsr);
4318 rt2800_bbp_read(rt2x00dev, 4, &bbp);
4320 rt2800_bbp_write(rt2x00dev, 4, bbp);
4327 rt2800_rfcsr_write(rt2x00dev, 27, 0x03);
4329 rt2800_register_read(rt2x00dev,
OPT_14_CSR, ®);
4331 rt2800_register_write(rt2x00dev,
OPT_14_CSR, reg);
4333 if (!rt2x00_rt(rt2x00dev,
RT5390) &&
4334 !rt2x00_rt(rt2x00dev,
RT5392)) {
4335 rt2800_rfcsr_read(rt2x00dev, 17, &rfcsr);
4337 if (rt2x00_rt(rt2x00dev,
RT3070) ||
4347 rt2800_rfcsr_write(rt2x00dev, 17, rfcsr);
4350 if (rt2x00_rt(rt2x00dev,
RT3090)) {
4351 rt2800_bbp_read(rt2x00dev, 138, &bbp);
4360 rt2800_bbp_write(rt2x00dev, 138, bbp);
4363 if (rt2x00_rt(rt2x00dev,
RT3071) ||
4364 rt2x00_rt(rt2x00dev,
RT3090) ||
4365 rt2x00_rt(rt2x00dev,
RT3390)) {
4366 rt2800_rfcsr_read(rt2x00dev, 1, &rfcsr);
4372 rt2800_rfcsr_write(rt2x00dev, 1, rfcsr);
4374 rt2800_rfcsr_read(rt2x00dev, 15, &rfcsr);
4376 rt2800_rfcsr_write(rt2x00dev, 15, rfcsr);
4378 rt2800_rfcsr_read(rt2x00dev, 20, &rfcsr);
4380 rt2800_rfcsr_write(rt2x00dev, 20, rfcsr);
4382 rt2800_rfcsr_read(rt2x00dev, 21, &rfcsr);
4384 rt2800_rfcsr_write(rt2x00dev, 21, rfcsr);
4387 if (rt2x00_rt(rt2x00dev,
RT3070)) {
4388 rt2800_rfcsr_read(rt2x00dev, 27, &rfcsr);
4396 rt2800_rfcsr_write(rt2x00dev, 27, rfcsr);
4399 if (rt2x00_rt(rt2x00dev,
RT3290)) {
4400 rt2800_rfcsr_read(rt2x00dev, 29, &rfcsr);
4402 rt2800_rfcsr_write(rt2x00dev, 29, rfcsr);
4405 if (rt2x00_rt(rt2x00dev,
RT5390) ||
4406 rt2x00_rt(rt2x00dev,
RT5392)) {
4407 rt2800_rfcsr_read(rt2x00dev, 38, &rfcsr);
4409 rt2800_rfcsr_write(rt2x00dev, 38, rfcsr);
4411 rt2800_rfcsr_read(rt2x00dev, 39, &rfcsr);
4413 rt2800_rfcsr_write(rt2x00dev, 39, rfcsr);
4415 rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr);
4417 rt2800_rfcsr_write(rt2x00dev, 30, rfcsr);
4432 rt2800_init_registers(rt2x00dev) ||
4433 rt2800_init_bbp(rt2x00dev) ||
4434 rt2800_init_rfcsr(rt2x00dev)))
4442 if (rt2x00_is_usb(rt2x00dev) &&
4443 (rt2x00_rt(rt2x00dev,
RT3070) ||
4444 rt2x00_rt(rt2x00dev,
RT3071) ||
4445 rt2x00_rt(rt2x00dev,
RT3572))) {
4478 word & 0xff, (word >> 8) & 0xff);
4482 word & 0xff, (word >> 8) & 0xff);
4486 word & 0xff, (word >> 8) & 0xff);
4513 if (rt2x00_rt(rt2x00dev,
RT3290))
4518 rt2800_register_read(rt2x00dev, efuse_ctrl_reg, ®);
4523 static void rt2800_efuse_read(
struct rt2x00_dev *rt2x00dev,
unsigned int i)
4527 u16 efuse_data0_reg;
4528 u16 efuse_data1_reg;
4529 u16 efuse_data2_reg;
4530 u16 efuse_data3_reg;
4532 if (rt2x00_rt(rt2x00dev,
RT3290)) {
4547 rt2800_register_read_lock(rt2x00dev, efuse_ctrl_reg, ®);
4551 rt2800_register_write_lock(rt2x00dev, efuse_ctrl_reg, reg);
4554 rt2800_regbusy_read(rt2x00dev, efuse_ctrl_reg,
EFUSE_CTRL_KICK, ®);
4556 rt2800_register_read_lock(rt2x00dev, efuse_data3_reg, ®);
4559 rt2800_register_read_lock(rt2x00dev, efuse_data2_reg, ®);
4561 rt2800_register_read_lock(rt2x00dev, efuse_data1_reg, ®);
4563 rt2800_register_read_lock(rt2x00dev, efuse_data0_reg, ®);
4574 rt2800_efuse_read(rt2x00dev, i);
4578 static int rt2800_validate_eeprom(
struct rt2x00_dev *rt2x00dev)
4583 u8 default_lna_gain;
4588 rt2800_read_eeprom(rt2x00dev);
4594 if (!is_valid_ether_addr(mac)) {
4595 eth_random_addr(mac);
4596 EEPROM(rt2x00dev,
"MAC: %pM\n", mac);
4600 if (word == 0xffff) {
4605 EEPROM(rt2x00dev,
"Antenna: 0x%04x\n", word);
4606 }
else if (rt2x00_rt(rt2x00dev,
RT2860) ||
4607 rt2x00_rt(rt2x00dev,
RT2872)) {
4617 if (word == 0xffff) {
4634 EEPROM(rt2x00dev,
"NIC: 0x%04x\n", word);
4637 rt2x00_eeprom_read(rt2x00dev,
EEPROM_FREQ, &word);
4638 if ((word & 0x00ff) == 0x00ff) {
4640 rt2x00_eeprom_write(rt2x00dev,
EEPROM_FREQ, word);
4641 EEPROM(rt2x00dev,
"Freq: 0x%04x\n", word);
4643 if ((word & 0xff00) == 0xff00) {
4647 rt2x00_eeprom_write(rt2x00dev,
EEPROM_FREQ, word);
4651 EEPROM(rt2x00dev,
"Led Mode: 0x%04x\n", word);
4659 rt2x00_eeprom_read(rt2x00dev,
EEPROM_LNA, &word);
4670 if ((word & 0x00ff) != 0x00ff) {
4687 if ((word & 0x00ff) != 0x00ff) {
4713 static int rt2800_init_eeprom(
struct rt2x00_dev *rt2x00dev)
4729 if (rt2x00_rt(rt2x00dev,
RT3290))
4732 rt2800_register_read(rt2x00dev,
MAC_CSR0, ®);
4744 switch (rt2x00dev->
chip.rt) {
4759 ERROR(rt2x00dev,
"Invalid RT chipset 0x%04x detected.\n", rt2x00dev->
chip.rt);
4763 switch (rt2x00dev->
chip.rf) {
4783 ERROR(rt2x00dev,
"Invalid RF chipset 0x%04x detected.\n",
4784 rt2x00dev->
chip.rf);
4798 if (rt2x00_rt(rt2x00dev,
RT3070) ||
4799 rt2x00_rt(rt2x00dev,
RT3090) ||
4800 rt2x00_rt(rt2x00dev,
RT3352) ||
4801 rt2x00_rt(rt2x00dev,
RT3390)) {
4849 rt2x00_eeprom_read(rt2x00dev,
EEPROM_FREQ, &eeprom);
4855 #ifdef CONFIG_RT2X00_LIB_LEDS
4856 rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio,
LED_TYPE_RADIO);
4857 rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc,
LED_TYPE_ASSOC);
4860 rt2x00dev->led_mcu_reg = eeprom;
4880 { 1, 0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
4881 { 2, 0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
4882 { 3, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
4883 { 4, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
4884 { 5, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
4885 { 6, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
4886 { 7, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
4887 { 8, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
4888 { 9, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
4889 { 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
4890 { 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
4891 { 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
4892 { 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
4893 { 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
4896 { 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
4897 { 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
4898 { 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
4899 { 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
4900 { 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
4901 { 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
4902 { 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
4903 { 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
4904 { 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
4905 { 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
4906 { 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
4907 { 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
4910 { 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
4911 { 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
4912 { 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
4913 { 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
4914 { 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
4915 { 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
4916 { 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
4917 { 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
4918 { 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
4919 { 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
4920 { 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
4921 { 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
4922 { 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
4923 { 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
4924 { 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
4925 { 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
4928 { 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
4929 { 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
4930 { 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
4931 { 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
4932 { 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
4933 { 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
4934 { 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
4935 { 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
4936 { 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
4937 { 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
4938 { 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
4941 { 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
4942 { 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
4943 { 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
4944 { 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
4945 { 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
4946 { 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
4947 { 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
4954 static const struct rf_channel rf_vals_3x[] = {
5016 static int rt2800_probe_hw_mode(
struct rt2x00_dev *rt2x00dev)
5028 if (rt2x00_is_pci(rt2x00dev) || rt2x00_is_soc(rt2x00dev))
5034 rt2x00dev->
hw->flags =
5048 if (!rt2x00_is_usb(rt2x00dev))
5049 rt2x00dev->
hw->flags |=
5052 SET_IEEE80211_DEV(rt2x00dev->
hw, rt2x00dev->
dev);
5053 SET_IEEE80211_PERM_ADDR(rt2x00dev->
hw,
5054 rt2x00_eeprom_addr(rt2x00dev,
5066 rt2x00dev->
hw->max_rates = 1;
5067 rt2x00dev->
hw->max_report_rates = 7;
5068 rt2x00dev->
hw->max_rate_tries = 1;
5078 if (rt2x00_rf(rt2x00dev,
RF2820) ||
5079 rt2x00_rf(rt2x00dev,
RF2720)) {
5082 }
else if (rt2x00_rf(rt2x00dev,
RF2850) ||
5083 rt2x00_rf(rt2x00dev,
RF2750)) {
5087 }
else if (rt2x00_rf(rt2x00dev,
RF3020) ||
5088 rt2x00_rf(rt2x00dev,
RF2020) ||
5089 rt2x00_rf(rt2x00dev,
RF3021) ||
5090 rt2x00_rf(rt2x00dev,
RF3022) ||
5091 rt2x00_rf(rt2x00dev,
RF3290) ||
5092 rt2x00_rf(rt2x00dev,
RF3320) ||
5093 rt2x00_rf(rt2x00dev,
RF3322) ||
5094 rt2x00_rf(rt2x00dev,
RF5360) ||
5095 rt2x00_rf(rt2x00dev,
RF5370) ||
5096 rt2x00_rf(rt2x00dev,
RF5372) ||
5097 rt2x00_rf(rt2x00dev,
RF5390) ||
5098 rt2x00_rf(rt2x00dev,
RF5392)) {
5101 }
else if (rt2x00_rf(rt2x00dev,
RF3052)) {
5110 if (!rt2x00_rf(rt2x00dev,
RF2020))
5111 spec->
ht.ht_supported =
true;
5113 spec->
ht.ht_supported =
false;
5128 spec->
ht.ampdu_factor = 3;
5129 spec->
ht.ampdu_density = 4;
5130 spec->
ht.mcs.tx_params =
5138 spec->
ht.mcs.rx_mask[2] = 0xff;
5140 spec->
ht.mcs.rx_mask[1] = 0xff;
5142 spec->
ht.mcs.rx_mask[0] = 0xff;
5143 spec->
ht.mcs.rx_mask[4] = 0x1;
5159 for (i = 0; i < 14; i++) {
5174 switch (rt2x00dev->
chip.rf) {
5202 retval = rt2800_validate_eeprom(rt2x00dev);
5206 retval = rt2800_init_eeprom(rt2x00dev);
5214 rt2800_register_read(rt2x00dev,
GPIO_CTRL, ®);
5216 rt2800_register_write(rt2x00dev,
GPIO_CTRL, reg);
5221 retval = rt2800_probe_hw_mode(rt2x00dev);
5230 if (!rt2x00_is_usb(rt2x00dev))
5236 if (!rt2x00_is_soc(rt2x00dev))
5240 if (!rt2800_hwcrypt_disabled(rt2x00dev))
5244 if (rt2x00_is_usb(rt2x00dev))
5271 rt2800_register_multiread(rt2x00dev, offset,
5272 &iveiv_entry,
sizeof(iveiv_entry));
5274 memcpy(iv16, &iveiv_entry.
iv[0],
sizeof(*iv16));
5275 memcpy(iv32, &iveiv_entry.
iv[4],
sizeof(*iv32));
5285 rt2800_register_read(rt2x00dev,
TX_RTS_CFG, ®);
5287 rt2800_register_write(rt2x00dev,
TX_RTS_CFG, reg);
5345 queue = rt2x00queue_get_tx_queue(rt2x00dev, queue_idx);
5352 rt2800_register_read(rt2x00dev, offset, ®);
5354 rt2800_register_write(rt2x00dev, offset, reg);
5375 rt2800_register_read(rt2x00dev, offset, ®);
5380 rt2800_register_write(rt2x00dev, offset, reg);
5457 rt2800_register_read(rt2x00dev,
CH_IDLE_STA, &idle);
5458 rt2800_register_read(rt2x00dev,
CH_BUSY_STA, &busy);