aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>2009-11-08 08:39:32 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-11-11 17:09:15 -0500
commit4da2933fe1f2d3d9ed548660f5c02a9b0608a8c7 (patch)
treee795c232ea8e41c21ccf927d91449bf019ff53bd /drivers/net/wireless
parentf2b38cbfd98eb36799f45178c73b2ed81402abd8 (diff)
rt2800: unify rt2800*_probe_hw_mode()
Add rf_vals tables and rt2800_probe_hw_mode() to rt2800lib. Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> Acked-by: Ivo van Doorn <IvDoorn@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c218
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.h1
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c190
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c211
4 files changed, 221 insertions, 399 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index 2c211199e569..d7771eaee049 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -1859,6 +1859,224 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
1859EXPORT_SYMBOL_GPL(rt2800_init_eeprom); 1859EXPORT_SYMBOL_GPL(rt2800_init_eeprom);
1860 1860
1861/* 1861/*
1862 * RF value list for rt28x0
1863 * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
1864 */
1865static const struct rf_channel rf_vals[] = {
1866 { 1, 0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
1867 { 2, 0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
1868 { 3, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
1869 { 4, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
1870 { 5, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
1871 { 6, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
1872 { 7, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
1873 { 8, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
1874 { 9, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
1875 { 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
1876 { 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
1877 { 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
1878 { 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
1879 { 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
1880
1881 /* 802.11 UNI / HyperLan 2 */
1882 { 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
1883 { 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
1884 { 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
1885 { 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
1886 { 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
1887 { 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
1888 { 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
1889 { 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
1890 { 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
1891 { 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
1892 { 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
1893 { 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
1894
1895 /* 802.11 HyperLan 2 */
1896 { 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
1897 { 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
1898 { 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
1899 { 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
1900 { 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
1901 { 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
1902 { 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
1903 { 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
1904 { 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
1905 { 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
1906 { 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
1907 { 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
1908 { 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
1909 { 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
1910 { 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
1911 { 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
1912
1913 /* 802.11 UNII */
1914 { 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
1915 { 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
1916 { 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
1917 { 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
1918 { 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
1919 { 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
1920 { 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
1921 { 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
1922 { 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
1923 { 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
1924 { 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
1925
1926 /* 802.11 Japan */
1927 { 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
1928 { 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
1929 { 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
1930 { 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
1931 { 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
1932 { 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
1933 { 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
1934};
1935
1936/*
1937 * RF value list for rt3070
1938 * Supports: 2.4 GHz
1939 */
1940static const struct rf_channel rf_vals_3070[] = {
1941 {1, 241, 2, 2 },
1942 {2, 241, 2, 7 },
1943 {3, 242, 2, 2 },
1944 {4, 242, 2, 7 },
1945 {5, 243, 2, 2 },
1946 {6, 243, 2, 7 },
1947 {7, 244, 2, 2 },
1948 {8, 244, 2, 7 },
1949 {9, 245, 2, 2 },
1950 {10, 245, 2, 7 },
1951 {11, 246, 2, 2 },
1952 {12, 246, 2, 7 },
1953 {13, 247, 2, 2 },
1954 {14, 248, 2, 4 },
1955};
1956
1957int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1958{
1959 struct rt2x00_chip *chip = &rt2x00dev->chip;
1960 struct hw_mode_spec *spec = &rt2x00dev->spec;
1961 struct channel_info *info;
1962 char *tx_power1;
1963 char *tx_power2;
1964 unsigned int i;
1965 u16 eeprom;
1966
1967 /*
1968 * Initialize all hw fields.
1969 */
1970 rt2x00dev->hw->flags =
1971 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
1972 IEEE80211_HW_SIGNAL_DBM |
1973 IEEE80211_HW_SUPPORTS_PS |
1974 IEEE80211_HW_PS_NULLFUNC_STACK;
1975
1976 if (rt2x00_intf_is_usb(rt2x00dev))
1977 rt2x00dev->hw->extra_tx_headroom =
1978 TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
1979 else if (rt2x00_intf_is_pci(rt2x00dev))
1980 rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
1981
1982 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
1983 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
1984 rt2x00_eeprom_addr(rt2x00dev,
1985 EEPROM_MAC_ADDR_0));
1986
1987 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
1988
1989 /*
1990 * Initialize hw_mode information.
1991 */
1992 spec->supported_bands = SUPPORT_BAND_2GHZ;
1993 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
1994
1995 if (rt2x00_rf(chip, RF2820) ||
1996 rt2x00_rf(chip, RF2720) ||
1997 (rt2x00_intf_is_pci(rt2x00dev) &&
1998 (rt2x00_rf(chip, RF3020) ||
1999 rt2x00_rf(chip, RF3021) ||
2000 rt2x00_rf(chip, RF3022) ||
2001 rt2x00_rf(chip, RF2020) ||
2002 rt2x00_rf(chip, RF3052)))) {
2003 spec->num_channels = 14;
2004 spec->channels = rf_vals;
2005 } else if (rt2x00_rf(chip, RF2850) ||
2006 rt2x00_rf(chip, RF2750)) {
2007 spec->supported_bands |= SUPPORT_BAND_5GHZ;
2008 spec->num_channels = ARRAY_SIZE(rf_vals);
2009 spec->channels = rf_vals;
2010 } else if (rt2x00_intf_is_usb(rt2x00dev) &&
2011 (rt2x00_rf(chip, RF3020) ||
2012 rt2x00_rf(chip, RF2020))) {
2013 spec->num_channels = ARRAY_SIZE(rf_vals_3070);
2014 spec->channels = rf_vals_3070;
2015 }
2016
2017 /*
2018 * Initialize HT information.
2019 */
2020 spec->ht.ht_supported = true;
2021 spec->ht.cap =
2022 IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
2023 IEEE80211_HT_CAP_GRN_FLD |
2024 IEEE80211_HT_CAP_SGI_20 |
2025 IEEE80211_HT_CAP_SGI_40 |
2026 IEEE80211_HT_CAP_TX_STBC |
2027 IEEE80211_HT_CAP_RX_STBC |
2028 IEEE80211_HT_CAP_PSMP_SUPPORT;
2029 spec->ht.ampdu_factor = 3;
2030 spec->ht.ampdu_density = 4;
2031 spec->ht.mcs.tx_params =
2032 IEEE80211_HT_MCS_TX_DEFINED |
2033 IEEE80211_HT_MCS_TX_RX_DIFF |
2034 ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
2035 IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
2036
2037 switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
2038 case 3:
2039 spec->ht.mcs.rx_mask[2] = 0xff;
2040 case 2:
2041 spec->ht.mcs.rx_mask[1] = 0xff;
2042 case 1:
2043 spec->ht.mcs.rx_mask[0] = 0xff;
2044 spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
2045 break;
2046 }
2047
2048 /*
2049 * Create channel information array
2050 */
2051 info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
2052 if (!info)
2053 return -ENOMEM;
2054
2055 spec->channels_info = info;
2056
2057 tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
2058 tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
2059
2060 for (i = 0; i < 14; i++) {
2061 info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
2062 info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
2063 }
2064
2065 if (spec->num_channels > 14) {
2066 tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
2067 tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
2068
2069 for (i = 14; i < spec->num_channels; i++) {
2070 info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
2071 info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
2072 }
2073 }
2074
2075 return 0;
2076}
2077EXPORT_SYMBOL_GPL(rt2800_probe_hw_mode);
2078
2079/*
1862 * IEEE80211 stack callback functions. 2080 * IEEE80211 stack callback functions.
1863 */ 2081 */
1864static void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx, 2082static void rt2800_get_tkip_seq(struct ieee80211_hw *hw, u8 hw_key_idx,
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.h b/drivers/net/wireless/rt2x00/rt2800lib.h
index da447114c83b..2aa15f2b2c5d 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.h
+++ b/drivers/net/wireless/rt2x00/rt2800lib.h
@@ -131,6 +131,7 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev);
131 131
132int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev); 132int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
133int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev); 133int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
134int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev);
134 135
135extern const struct ieee80211_ops rt2800_mac80211_ops; 136extern const struct ieee80211_ops rt2800_mac80211_ops;
136 137
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index c60779069508..e8fe2eabebbd 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -1112,194 +1112,6 @@ static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
1112 return rt2800_validate_eeprom(rt2x00dev); 1112 return rt2800_validate_eeprom(rt2x00dev);
1113} 1113}
1114 1114
1115/*
1116 * RF value list for rt2860
1117 * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
1118 */
1119static const struct rf_channel rf_vals[] = {
1120 { 1, 0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
1121 { 2, 0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
1122 { 3, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
1123 { 4, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
1124 { 5, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
1125 { 6, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
1126 { 7, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
1127 { 8, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
1128 { 9, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
1129 { 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
1130 { 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
1131 { 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
1132 { 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
1133 { 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
1134
1135 /* 802.11 UNI / HyperLan 2 */
1136 { 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
1137 { 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
1138 { 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
1139 { 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
1140 { 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
1141 { 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
1142 { 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
1143 { 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
1144 { 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
1145 { 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
1146 { 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
1147 { 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
1148
1149 /* 802.11 HyperLan 2 */
1150 { 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
1151 { 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
1152 { 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
1153 { 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
1154 { 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
1155 { 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
1156 { 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
1157 { 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
1158 { 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
1159 { 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
1160 { 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
1161 { 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
1162 { 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
1163 { 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
1164 { 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
1165 { 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
1166
1167 /* 802.11 UNII */
1168 { 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
1169 { 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
1170 { 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
1171 { 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
1172 { 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
1173 { 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
1174 { 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
1175 { 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
1176 { 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
1177 { 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
1178 { 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
1179
1180 /* 802.11 Japan */
1181 { 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
1182 { 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
1183 { 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
1184 { 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
1185 { 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
1186 { 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
1187 { 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
1188};
1189
1190static int rt2800pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1191{
1192 struct rt2x00_chip *chip = &rt2x00dev->chip;
1193 struct hw_mode_spec *spec = &rt2x00dev->spec;
1194 struct channel_info *info;
1195 char *tx_power1;
1196 char *tx_power2;
1197 unsigned int i;
1198 u16 eeprom;
1199
1200 /*
1201 * Initialize all hw fields.
1202 */
1203 rt2x00dev->hw->flags =
1204 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
1205 IEEE80211_HW_SIGNAL_DBM |
1206 IEEE80211_HW_SUPPORTS_PS |
1207 IEEE80211_HW_PS_NULLFUNC_STACK;
1208
1209 if (rt2x00_intf_is_pci(rt2x00dev))
1210 rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE;
1211
1212 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
1213 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
1214 rt2x00_eeprom_addr(rt2x00dev,
1215 EEPROM_MAC_ADDR_0));
1216
1217 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
1218
1219 /*
1220 * Initialize hw_mode information.
1221 */
1222 spec->supported_bands = SUPPORT_BAND_2GHZ;
1223 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
1224
1225 if (rt2x00_rf(chip, RF2820) ||
1226 rt2x00_rf(chip, RF2720) ||
1227 (rt2x00_intf_is_pci(rt2x00dev) &&
1228 (rt2x00_rf(chip, RF3020) ||
1229 rt2x00_rf(chip, RF3021) ||
1230 rt2x00_rf(chip, RF3022) ||
1231 rt2x00_rf(chip, RF2020) ||
1232 rt2x00_rf(chip, RF3052)))) {
1233 spec->num_channels = 14;
1234 spec->channels = rf_vals;
1235 } else if (rt2x00_rf(chip, RF2850) ||
1236 rt2x00_rf(chip, RF2750)) {
1237 spec->supported_bands |= SUPPORT_BAND_5GHZ;
1238 spec->num_channels = ARRAY_SIZE(rf_vals);
1239 spec->channels = rf_vals;
1240 }
1241
1242 /*
1243 * Initialize HT information.
1244 */
1245 spec->ht.ht_supported = true;
1246 spec->ht.cap =
1247 IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
1248 IEEE80211_HT_CAP_GRN_FLD |
1249 IEEE80211_HT_CAP_SGI_20 |
1250 IEEE80211_HT_CAP_SGI_40 |
1251 IEEE80211_HT_CAP_TX_STBC |
1252 IEEE80211_HT_CAP_RX_STBC |
1253 IEEE80211_HT_CAP_PSMP_SUPPORT;
1254 spec->ht.ampdu_factor = 3;
1255 spec->ht.ampdu_density = 4;
1256 spec->ht.mcs.tx_params =
1257 IEEE80211_HT_MCS_TX_DEFINED |
1258 IEEE80211_HT_MCS_TX_RX_DIFF |
1259 ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
1260 IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
1261
1262 switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
1263 case 3:
1264 spec->ht.mcs.rx_mask[2] = 0xff;
1265 case 2:
1266 spec->ht.mcs.rx_mask[1] = 0xff;
1267 case 1:
1268 spec->ht.mcs.rx_mask[0] = 0xff;
1269 spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
1270 break;
1271 }
1272
1273 /*
1274 * Create channel information array
1275 */
1276 info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
1277 if (!info)
1278 return -ENOMEM;
1279
1280 spec->channels_info = info;
1281
1282 tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
1283 tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
1284
1285 for (i = 0; i < 14; i++) {
1286 info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
1287 info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
1288 }
1289
1290 if (spec->num_channels > 14) {
1291 tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
1292 tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
1293
1294 for (i = 14; i < spec->num_channels; i++) {
1295 info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
1296 info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
1297 }
1298 }
1299
1300 return 0;
1301}
1302
1303static const struct rt2800_ops rt2800pci_rt2800_ops = { 1115static const struct rt2800_ops rt2800pci_rt2800_ops = {
1304 .register_read = rt2x00pci_register_read, 1116 .register_read = rt2x00pci_register_read,
1305 .register_write = rt2x00pci_register_write, 1117 .register_write = rt2x00pci_register_write,
@@ -1331,7 +1143,7 @@ static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev)
1331 /* 1143 /*
1332 * Initialize hw specifications. 1144 * Initialize hw specifications.
1333 */ 1145 */
1334 retval = rt2800pci_probe_hw_mode(rt2x00dev); 1146 retval = rt2800_probe_hw_mode(rt2x00dev);
1335 if (retval) 1147 if (retval)
1336 return retval; 1148 return retval;
1337 1149
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index e86858a0e196..67bae36ecddf 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -672,215 +672,6 @@ static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev)
672 return rt2800_validate_eeprom(rt2x00dev); 672 return rt2800_validate_eeprom(rt2x00dev);
673} 673}
674 674
675/*
676 * RF value list for rt2870
677 * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750)
678 */
679static const struct rf_channel rf_vals[] = {
680 { 1, 0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b },
681 { 2, 0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f },
682 { 3, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b },
683 { 4, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f },
684 { 5, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b },
685 { 6, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f },
686 { 7, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b },
687 { 8, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f },
688 { 9, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b },
689 { 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f },
690 { 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b },
691 { 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f },
692 { 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b },
693 { 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 },
694
695 /* 802.11 UNI / HyperLan 2 */
696 { 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 },
697 { 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 },
698 { 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 },
699 { 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 },
700 { 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b },
701 { 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b },
702 { 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 },
703 { 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 },
704 { 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b },
705 { 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 },
706 { 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 },
707 { 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 },
708
709 /* 802.11 HyperLan 2 */
710 { 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 },
711 { 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 },
712 { 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 },
713 { 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 },
714 { 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 },
715 { 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b },
716 { 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 },
717 { 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 },
718 { 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 },
719 { 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 },
720 { 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b },
721 { 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 },
722 { 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b },
723 { 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 },
724 { 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b },
725 { 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 },
726
727 /* 802.11 UNII */
728 { 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 },
729 { 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 },
730 { 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f },
731 { 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f },
732 { 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 },
733 { 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 },
734 { 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 },
735 { 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f },
736 { 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 },
737 { 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 },
738 { 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f },
739
740 /* 802.11 Japan */
741 { 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b },
742 { 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 },
743 { 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b },
744 { 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 },
745 { 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 },
746 { 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b },
747 { 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 },
748};
749
750/*
751 * RF value list for rt3070
752 * Supports: 2.4 GHz
753 */
754static const struct rf_channel rf_vals_3070[] = {
755 {1, 241, 2, 2 },
756 {2, 241, 2, 7 },
757 {3, 242, 2, 2 },
758 {4, 242, 2, 7 },
759 {5, 243, 2, 2 },
760 {6, 243, 2, 7 },
761 {7, 244, 2, 2 },
762 {8, 244, 2, 7 },
763 {9, 245, 2, 2 },
764 {10, 245, 2, 7 },
765 {11, 246, 2, 2 },
766 {12, 246, 2, 7 },
767 {13, 247, 2, 2 },
768 {14, 248, 2, 4 },
769};
770
771static int rt2800usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
772{
773 struct rt2x00_chip *chip = &rt2x00dev->chip;
774 struct hw_mode_spec *spec = &rt2x00dev->spec;
775 struct channel_info *info;
776 char *tx_power1;
777 char *tx_power2;
778 unsigned int i;
779 u16 eeprom;
780
781 /*
782 * Initialize all hw fields.
783 */
784 rt2x00dev->hw->flags =
785 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
786 IEEE80211_HW_SIGNAL_DBM |
787 IEEE80211_HW_SUPPORTS_PS |
788 IEEE80211_HW_PS_NULLFUNC_STACK;
789
790 if (rt2x00_intf_is_usb(rt2x00dev))
791 rt2x00dev->hw->extra_tx_headroom =
792 TXINFO_DESC_SIZE + TXWI_DESC_SIZE;
793
794 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
795 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
796 rt2x00_eeprom_addr(rt2x00dev,
797 EEPROM_MAC_ADDR_0));
798
799 rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
800
801 /*
802 * Initialize hw_mode information.
803 */
804 spec->supported_bands = SUPPORT_BAND_2GHZ;
805 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
806
807 if (rt2x00_rf(chip, RF2820) ||
808 rt2x00_rf(chip, RF2720)) {
809 spec->num_channels = 14;
810 spec->channels = rf_vals;
811 } else if (rt2x00_rf(chip, RF2850) ||
812 rt2x00_rf(chip, RF2750)) {
813 spec->supported_bands |= SUPPORT_BAND_5GHZ;
814 spec->num_channels = ARRAY_SIZE(rf_vals);
815 spec->channels = rf_vals;
816 } else if (rt2x00_intf_is_usb(rt2x00dev) &&
817 (rt2x00_rf(chip, RF3020) ||
818 rt2x00_rf(chip, RF2020))) {
819 spec->num_channels = ARRAY_SIZE(rf_vals_3070);
820 spec->channels = rf_vals_3070;
821 }
822
823 /*
824 * Initialize HT information.
825 */
826 spec->ht.ht_supported = true;
827 spec->ht.cap =
828 IEEE80211_HT_CAP_SUP_WIDTH_20_40 |
829 IEEE80211_HT_CAP_GRN_FLD |
830 IEEE80211_HT_CAP_SGI_20 |
831 IEEE80211_HT_CAP_SGI_40 |
832 IEEE80211_HT_CAP_TX_STBC |
833 IEEE80211_HT_CAP_RX_STBC |
834 IEEE80211_HT_CAP_PSMP_SUPPORT;
835 spec->ht.ampdu_factor = 3;
836 spec->ht.ampdu_density = 4;
837 spec->ht.mcs.tx_params =
838 IEEE80211_HT_MCS_TX_DEFINED |
839 IEEE80211_HT_MCS_TX_RX_DIFF |
840 ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) <<
841 IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT);
842
843 switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) {
844 case 3:
845 spec->ht.mcs.rx_mask[2] = 0xff;
846 case 2:
847 spec->ht.mcs.rx_mask[1] = 0xff;
848 case 1:
849 spec->ht.mcs.rx_mask[0] = 0xff;
850 spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */
851 break;
852 }
853
854 /*
855 * Create channel information array
856 */
857 info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL);
858 if (!info)
859 return -ENOMEM;
860
861 spec->channels_info = info;
862
863 tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1);
864 tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2);
865
866 for (i = 0; i < 14; i++) {
867 info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]);
868 info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]);
869 }
870
871 if (spec->num_channels > 14) {
872 tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1);
873 tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2);
874
875 for (i = 14; i < spec->num_channels; i++) {
876 info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]);
877 info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]);
878 }
879 }
880
881 return 0;
882}
883
884static const struct rt2800_ops rt2800usb_rt2800_ops = { 675static const struct rt2800_ops rt2800usb_rt2800_ops = {
885 .register_read = rt2x00usb_register_read, 676 .register_read = rt2x00usb_register_read,
886 .register_write = rt2x00usb_register_write, 677 .register_write = rt2x00usb_register_write,
@@ -912,7 +703,7 @@ static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
912 /* 703 /*
913 * Initialize hw specifications. 704 * Initialize hw specifications.
914 */ 705 */
915 retval = rt2800usb_probe_hw_mode(rt2x00dev); 706 retval = rt2800_probe_hw_mode(rt2x00dev);
916 if (retval) 707 if (retval)
917 return retval; 708 return retval;
918 709