aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2800lib.c
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/rt2x00/rt2800lib.c
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/rt2x00/rt2800lib.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c218
1 files changed, 218 insertions, 0 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,