diff options
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800lib.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.c | 94 |
1 files changed, 45 insertions, 49 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 27bf887f1453..8ff7db853286 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c | |||
@@ -37,7 +37,7 @@ | |||
37 | #include <linux/module.h> | 37 | #include <linux/module.h> |
38 | 38 | ||
39 | #include "rt2x00.h" | 39 | #include "rt2x00.h" |
40 | #if defined(CONFIG_RT2800USB) || defined(CONFIG_RT2800USB_MODULE) | 40 | #if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE) |
41 | #include "rt2x00usb.h" | 41 | #include "rt2x00usb.h" |
42 | #endif | 42 | #endif |
43 | #include "rt2800lib.h" | 43 | #include "rt2800lib.h" |
@@ -220,8 +220,7 @@ void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev, | |||
220 | /* | 220 | /* |
221 | * RT2880 and RT3052 don't support MCU requests. | 221 | * RT2880 and RT3052 don't support MCU requests. |
222 | */ | 222 | */ |
223 | if (rt2x00_rt(&rt2x00dev->chip, RT2880) || | 223 | if (rt2x00_rt(rt2x00dev, RT2880) || rt2x00_rt(rt2x00dev, RT3052)) |
224 | rt2x00_rt(&rt2x00dev->chip, RT3052)) | ||
225 | return; | 224 | return; |
226 | 225 | ||
227 | mutex_lock(&rt2x00dev->csr_mutex); | 226 | mutex_lock(&rt2x00dev->csr_mutex); |
@@ -806,12 +805,12 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, | |||
806 | unsigned int tx_pin; | 805 | unsigned int tx_pin; |
807 | u8 bbp; | 806 | u8 bbp; |
808 | 807 | ||
809 | if ((rt2x00_rt(&rt2x00dev->chip, RT3070) || | 808 | if ((rt2x00_rt(rt2x00dev, RT3070) || |
810 | rt2x00_rt(&rt2x00dev->chip, RT3090)) && | 809 | rt2x00_rt(rt2x00dev, RT3090)) && |
811 | (rt2x00_rf(&rt2x00dev->chip, RF2020) || | 810 | (rt2x00_rf(rt2x00dev, RF2020) || |
812 | rt2x00_rf(&rt2x00dev->chip, RF3020) || | 811 | rt2x00_rf(rt2x00dev, RF3020) || |
813 | rt2x00_rf(&rt2x00dev->chip, RF3021) || | 812 | rt2x00_rf(rt2x00dev, RF3021) || |
814 | rt2x00_rf(&rt2x00dev->chip, RF3022))) | 813 | rt2x00_rf(rt2x00dev, RF3022))) |
815 | rt2800_config_channel_rt3x(rt2x00dev, conf, rf, info); | 814 | rt2800_config_channel_rt3x(rt2x00dev, conf, rf, info); |
816 | else | 815 | else |
817 | rt2800_config_channel_rt2x(rt2x00dev, conf, rf, info); | 816 | rt2800_config_channel_rt2x(rt2x00dev, conf, rf, info); |
@@ -878,7 +877,7 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, | |||
878 | rt2x00_set_field8(&bbp, BBP3_HT40_PLUS, conf_is_ht40_plus(conf)); | 877 | rt2x00_set_field8(&bbp, BBP3_HT40_PLUS, conf_is_ht40_plus(conf)); |
879 | rt2800_bbp_write(rt2x00dev, 3, bbp); | 878 | rt2800_bbp_write(rt2x00dev, 3, bbp); |
880 | 879 | ||
881 | if (rt2x00_rev(&rt2x00dev->chip) == RT2860C_VERSION) { | 880 | if (rt2x00_rev(rt2x00dev) == RT2860C_VERSION) { |
882 | if (conf_is_ht40(conf)) { | 881 | if (conf_is_ht40(conf)) { |
883 | rt2800_bbp_write(rt2x00dev, 69, 0x1a); | 882 | rt2800_bbp_write(rt2x00dev, 69, 0x1a); |
884 | rt2800_bbp_write(rt2x00dev, 70, 0x0a); | 883 | rt2800_bbp_write(rt2x00dev, 70, 0x0a); |
@@ -1041,7 +1040,7 @@ static u8 rt2800_get_default_vgc(struct rt2x00_dev *rt2x00dev) | |||
1041 | { | 1040 | { |
1042 | if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) { | 1041 | if (rt2x00dev->curr_band == IEEE80211_BAND_2GHZ) { |
1043 | if (rt2x00_intf_is_usb(rt2x00dev) && | 1042 | if (rt2x00_intf_is_usb(rt2x00dev) && |
1044 | rt2x00_rev(&rt2x00dev->chip) == RT3070_VERSION) | 1043 | rt2x00_rev(rt2x00dev) == RT3070_VERSION) |
1045 | return 0x1c + (2 * rt2x00dev->lna_gain); | 1044 | return 0x1c + (2 * rt2x00dev->lna_gain); |
1046 | else | 1045 | else |
1047 | return 0x2e + rt2x00dev->lna_gain; | 1046 | return 0x2e + rt2x00dev->lna_gain; |
@@ -1072,7 +1071,7 @@ EXPORT_SYMBOL_GPL(rt2800_reset_tuner); | |||
1072 | void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual, | 1071 | void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual, |
1073 | const u32 count) | 1072 | const u32 count) |
1074 | { | 1073 | { |
1075 | if (rt2x00_rev(&rt2x00dev->chip) == RT2860C_VERSION) | 1074 | if (rt2x00_rev(rt2x00dev) == RT2860C_VERSION) |
1076 | return; | 1075 | return; |
1077 | 1076 | ||
1078 | /* | 1077 | /* |
@@ -1121,7 +1120,7 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | |||
1121 | 1120 | ||
1122 | if (rt2x00_intf_is_usb(rt2x00dev)) { | 1121 | if (rt2x00_intf_is_usb(rt2x00dev)) { |
1123 | rt2800_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000); | 1122 | rt2800_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000); |
1124 | #if defined(CONFIG_RT2800USB) || defined(CONFIG_RT2800USB_MODULE) | 1123 | #if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE) |
1125 | rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0, | 1124 | rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0, |
1126 | USB_MODE_RESET, REGISTER_TIMEOUT); | 1125 | USB_MODE_RESET, REGISTER_TIMEOUT); |
1127 | #endif | 1126 | #endif |
@@ -1158,7 +1157,7 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | |||
1158 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); | 1157 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); |
1159 | 1158 | ||
1160 | if (rt2x00_intf_is_usb(rt2x00dev) && | 1159 | if (rt2x00_intf_is_usb(rt2x00dev) && |
1161 | rt2x00_rev(&rt2x00dev->chip) == RT3070_VERSION) { | 1160 | rt2x00_rev(rt2x00dev) == RT3070_VERSION) { |
1162 | rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400); | 1161 | rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400); |
1163 | rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000); | 1162 | rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000); |
1164 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); | 1163 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); |
@@ -1185,8 +1184,8 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | |||
1185 | 1184 | ||
1186 | rt2800_register_read(rt2x00dev, MAX_LEN_CFG, ®); | 1185 | rt2800_register_read(rt2x00dev, MAX_LEN_CFG, ®); |
1187 | rt2x00_set_field32(®, MAX_LEN_CFG_MAX_MPDU, AGGREGATION_SIZE); | 1186 | rt2x00_set_field32(®, MAX_LEN_CFG_MAX_MPDU, AGGREGATION_SIZE); |
1188 | if (rt2x00_rev(&rt2x00dev->chip) >= RT2880E_VERSION && | 1187 | if (rt2x00_rev(rt2x00dev) >= RT2880E_VERSION && |
1189 | rt2x00_rev(&rt2x00dev->chip) < RT3070_VERSION) | 1188 | rt2x00_rev(rt2x00dev) < RT3070_VERSION) |
1190 | rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, 2); | 1189 | rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, 2); |
1191 | else | 1190 | else |
1192 | rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, 1); | 1191 | rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, 1); |
@@ -1465,22 +1464,22 @@ int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) | |||
1465 | rt2800_bbp_write(rt2x00dev, 103, 0x00); | 1464 | rt2800_bbp_write(rt2x00dev, 103, 0x00); |
1466 | rt2800_bbp_write(rt2x00dev, 105, 0x05); | 1465 | rt2800_bbp_write(rt2x00dev, 105, 0x05); |
1467 | 1466 | ||
1468 | if (rt2x00_rev(&rt2x00dev->chip) == RT2860C_VERSION) { | 1467 | if (rt2x00_rev(rt2x00dev) == RT2860C_VERSION) { |
1469 | rt2800_bbp_write(rt2x00dev, 69, 0x16); | 1468 | rt2800_bbp_write(rt2x00dev, 69, 0x16); |
1470 | rt2800_bbp_write(rt2x00dev, 73, 0x12); | 1469 | rt2800_bbp_write(rt2x00dev, 73, 0x12); |
1471 | } | 1470 | } |
1472 | 1471 | ||
1473 | if (rt2x00_rev(&rt2x00dev->chip) > RT2860D_VERSION) | 1472 | if (rt2x00_rev(rt2x00dev) > RT2860D_VERSION) |
1474 | rt2800_bbp_write(rt2x00dev, 84, 0x19); | 1473 | rt2800_bbp_write(rt2x00dev, 84, 0x19); |
1475 | 1474 | ||
1476 | if (rt2x00_intf_is_usb(rt2x00dev) && | 1475 | if (rt2x00_intf_is_usb(rt2x00dev) && |
1477 | rt2x00_rev(&rt2x00dev->chip) == RT3070_VERSION) { | 1476 | rt2x00_rev(rt2x00dev) == RT3070_VERSION) { |
1478 | rt2800_bbp_write(rt2x00dev, 70, 0x0a); | 1477 | rt2800_bbp_write(rt2x00dev, 70, 0x0a); |
1479 | rt2800_bbp_write(rt2x00dev, 84, 0x99); | 1478 | rt2800_bbp_write(rt2x00dev, 84, 0x99); |
1480 | rt2800_bbp_write(rt2x00dev, 105, 0x05); | 1479 | rt2800_bbp_write(rt2x00dev, 105, 0x05); |
1481 | } | 1480 | } |
1482 | 1481 | ||
1483 | if (rt2x00_rt(&rt2x00dev->chip, RT3052)) { | 1482 | if (rt2x00_rt(rt2x00dev, RT3052)) { |
1484 | rt2800_bbp_write(rt2x00dev, 31, 0x08); | 1483 | rt2800_bbp_write(rt2x00dev, 31, 0x08); |
1485 | rt2800_bbp_write(rt2x00dev, 78, 0x0e); | 1484 | rt2800_bbp_write(rt2x00dev, 78, 0x0e); |
1486 | rt2800_bbp_write(rt2x00dev, 80, 0x08); | 1485 | rt2800_bbp_write(rt2x00dev, 80, 0x08); |
@@ -1566,13 +1565,13 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) | |||
1566 | u8 bbp; | 1565 | u8 bbp; |
1567 | 1566 | ||
1568 | if (rt2x00_intf_is_usb(rt2x00dev) && | 1567 | if (rt2x00_intf_is_usb(rt2x00dev) && |
1569 | rt2x00_rev(&rt2x00dev->chip) != RT3070_VERSION) | 1568 | rt2x00_rev(rt2x00dev) != RT3070_VERSION) |
1570 | return 0; | 1569 | return 0; |
1571 | 1570 | ||
1572 | if (rt2x00_intf_is_pci(rt2x00dev)) { | 1571 | if (rt2x00_intf_is_pci(rt2x00dev)) { |
1573 | if (!rt2x00_rf(&rt2x00dev->chip, RF3020) && | 1572 | if (!rt2x00_rf(rt2x00dev, RF3020) && |
1574 | !rt2x00_rf(&rt2x00dev->chip, RF3021) && | 1573 | !rt2x00_rf(rt2x00dev, RF3021) && |
1575 | !rt2x00_rf(&rt2x00dev->chip, RF3022)) | 1574 | !rt2x00_rf(rt2x00dev, RF3022)) |
1576 | return 0; | 1575 | return 0; |
1577 | } | 1576 | } |
1578 | 1577 | ||
@@ -1737,7 +1736,7 @@ int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1737 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820); | 1736 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820); |
1738 | rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word); | 1737 | rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word); |
1739 | EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word); | 1738 | EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word); |
1740 | } else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) { | 1739 | } else if (rt2x00_rev(rt2x00dev) < RT2883_VERSION) { |
1741 | /* | 1740 | /* |
1742 | * There is a max of 2 RX streams for RT28x0 series | 1741 | * There is a max of 2 RX streams for RT28x0 series |
1743 | */ | 1742 | */ |
@@ -1839,17 +1838,15 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1839 | rt2x00_set_chip_rf(rt2x00dev, value, reg); | 1838 | rt2x00_set_chip_rf(rt2x00dev, value, reg); |
1840 | 1839 | ||
1841 | if (rt2x00_intf_is_usb(rt2x00dev)) { | 1840 | if (rt2x00_intf_is_usb(rt2x00dev)) { |
1842 | struct rt2x00_chip *chip = &rt2x00dev->chip; | ||
1843 | |||
1844 | /* | 1841 | /* |
1845 | * The check for rt2860 is not a typo, some rt2870 hardware | 1842 | * The check for rt2860 is not a typo, some rt2870 hardware |
1846 | * identifies itself as rt2860 in the CSR register. | 1843 | * identifies itself as rt2860 in the CSR register. |
1847 | */ | 1844 | */ |
1848 | if (rt2x00_check_rev(chip, 0xfff00000, 0x28600000) || | 1845 | if (rt2x00_check_rev(rt2x00dev, 0xfff00000, 0x28600000) || |
1849 | rt2x00_check_rev(chip, 0xfff00000, 0x28700000) || | 1846 | rt2x00_check_rev(rt2x00dev, 0xfff00000, 0x28700000) || |
1850 | rt2x00_check_rev(chip, 0xfff00000, 0x28800000)) { | 1847 | rt2x00_check_rev(rt2x00dev, 0xfff00000, 0x28800000)) { |
1851 | rt2x00_set_chip_rt(rt2x00dev, RT2870); | 1848 | rt2x00_set_chip_rt(rt2x00dev, RT2870); |
1852 | } else if (rt2x00_check_rev(chip, 0xffff0000, 0x30700000)) { | 1849 | } else if (rt2x00_check_rev(rt2x00dev, 0xffff0000, 0x30700000)) { |
1853 | rt2x00_set_chip_rt(rt2x00dev, RT3070); | 1850 | rt2x00_set_chip_rt(rt2x00dev, RT3070); |
1854 | } else { | 1851 | } else { |
1855 | ERROR(rt2x00dev, "Invalid RT chipset detected.\n"); | 1852 | ERROR(rt2x00dev, "Invalid RT chipset detected.\n"); |
@@ -1858,14 +1855,14 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1858 | } | 1855 | } |
1859 | rt2x00_print_chip(rt2x00dev); | 1856 | rt2x00_print_chip(rt2x00dev); |
1860 | 1857 | ||
1861 | if (!rt2x00_rf(&rt2x00dev->chip, RF2820) && | 1858 | if (!rt2x00_rf(rt2x00dev, RF2820) && |
1862 | !rt2x00_rf(&rt2x00dev->chip, RF2850) && | 1859 | !rt2x00_rf(rt2x00dev, RF2850) && |
1863 | !rt2x00_rf(&rt2x00dev->chip, RF2720) && | 1860 | !rt2x00_rf(rt2x00dev, RF2720) && |
1864 | !rt2x00_rf(&rt2x00dev->chip, RF2750) && | 1861 | !rt2x00_rf(rt2x00dev, RF2750) && |
1865 | !rt2x00_rf(&rt2x00dev->chip, RF3020) && | 1862 | !rt2x00_rf(rt2x00dev, RF3020) && |
1866 | !rt2x00_rf(&rt2x00dev->chip, RF2020) && | 1863 | !rt2x00_rf(rt2x00dev, RF2020) && |
1867 | !rt2x00_rf(&rt2x00dev->chip, RF3021) && | 1864 | !rt2x00_rf(rt2x00dev, RF3021) && |
1868 | !rt2x00_rf(&rt2x00dev->chip, RF3022)) { | 1865 | !rt2x00_rf(rt2x00dev, RF3022)) { |
1869 | ERROR(rt2x00dev, "Invalid RF chipset detected.\n"); | 1866 | ERROR(rt2x00dev, "Invalid RF chipset detected.\n"); |
1870 | return -ENODEV; | 1867 | return -ENODEV; |
1871 | } | 1868 | } |
@@ -2013,7 +2010,6 @@ static const struct rf_channel rf_vals_302x[] = { | |||
2013 | 2010 | ||
2014 | int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | 2011 | int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) |
2015 | { | 2012 | { |
2016 | struct rt2x00_chip *chip = &rt2x00dev->chip; | ||
2017 | struct hw_mode_spec *spec = &rt2x00dev->spec; | 2013 | struct hw_mode_spec *spec = &rt2x00dev->spec; |
2018 | struct channel_info *info; | 2014 | struct channel_info *info; |
2019 | char *tx_power1; | 2015 | char *tx_power1; |
@@ -2049,19 +2045,19 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
2049 | spec->supported_bands = SUPPORT_BAND_2GHZ; | 2045 | spec->supported_bands = SUPPORT_BAND_2GHZ; |
2050 | spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; | 2046 | spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; |
2051 | 2047 | ||
2052 | if (rt2x00_rf(chip, RF2820) || | 2048 | if (rt2x00_rf(rt2x00dev, RF2820) || |
2053 | rt2x00_rf(chip, RF2720) || | 2049 | rt2x00_rf(rt2x00dev, RF2720) || |
2054 | (rt2x00_intf_is_pci(rt2x00dev) && rt2x00_rf(chip, RF3052))) { | 2050 | (rt2x00_intf_is_pci(rt2x00dev) && rt2x00_rf(rt2x00dev, RF3052))) { |
2055 | spec->num_channels = 14; | 2051 | spec->num_channels = 14; |
2056 | spec->channels = rf_vals; | 2052 | spec->channels = rf_vals; |
2057 | } else if (rt2x00_rf(chip, RF2850) || rt2x00_rf(chip, RF2750)) { | 2053 | } else if (rt2x00_rf(rt2x00dev, RF2850) || rt2x00_rf(rt2x00dev, RF2750)) { |
2058 | spec->supported_bands |= SUPPORT_BAND_5GHZ; | 2054 | spec->supported_bands |= SUPPORT_BAND_5GHZ; |
2059 | spec->num_channels = ARRAY_SIZE(rf_vals); | 2055 | spec->num_channels = ARRAY_SIZE(rf_vals); |
2060 | spec->channels = rf_vals; | 2056 | spec->channels = rf_vals; |
2061 | } else if (rt2x00_rf(chip, RF3020) || | 2057 | } else if (rt2x00_rf(rt2x00dev, RF3020) || |
2062 | rt2x00_rf(chip, RF2020) || | 2058 | rt2x00_rf(rt2x00dev, RF2020) || |
2063 | rt2x00_rf(chip, RF3021) || | 2059 | rt2x00_rf(rt2x00dev, RF3021) || |
2064 | rt2x00_rf(chip, RF3022)) { | 2060 | rt2x00_rf(rt2x00dev, RF3022)) { |
2065 | spec->num_channels = ARRAY_SIZE(rf_vals_302x); | 2061 | spec->num_channels = ARRAY_SIZE(rf_vals_302x); |
2066 | spec->channels = rf_vals_302x; | 2062 | spec->channels = rf_vals_302x; |
2067 | } | 2063 | } |
@@ -2069,7 +2065,7 @@ int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | |||
2069 | /* | 2065 | /* |
2070 | * Initialize HT information. | 2066 | * Initialize HT information. |
2071 | */ | 2067 | */ |
2072 | if (!rt2x00_rf(chip, RF2020)) | 2068 | if (!rt2x00_rf(rt2x00dev, RF2020)) |
2073 | spec->ht.ht_supported = true; | 2069 | spec->ht.ht_supported = true; |
2074 | else | 2070 | else |
2075 | spec->ht.ht_supported = false; | 2071 | spec->ht.ht_supported = false; |