diff options
author | David S. Miller <davem@davemloft.net> | 2009-11-18 13:55:32 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-11-18 13:55:32 -0500 |
commit | dfef948ed2ba69cf041840b5e860d6b4e16fa0b1 (patch) | |
tree | eab385cabe589346bcf19385c997ab8dabaef7bd /drivers/net/wireless/rt2x00/rt2800lib.c | |
parent | ea31ba359c55e0734ff895692185d4c50cf0c537 (diff) | |
parent | c85e9d7739fc8d879c4293ea020760926d6f87cd (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800lib.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.c | 494 |
1 files changed, 483 insertions, 11 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index 5c7d74a6f16e..e94f1e13fea9 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c | |||
@@ -1,9 +1,15 @@ | |||
1 | /* | 1 | /* |
2 | Copyright (C) 2009 Bartlomiej Zolnierkiewicz | 2 | Copyright (C) 2009 Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> |
3 | 3 | Copyright (C) 2009 Gertjan van Wingerde <gwingerde@gmail.com> | |
4 | Based on the original rt2800pci.c and rt2800usb.c: | 4 | |
5 | 5 | Based on the original rt2800pci.c and rt2800usb.c. | |
6 | Copyright (C) 2004 - 2009 rt2x00 SourceForge Project | 6 | Copyright (C) 2009 Ivo van Doorn <IvDoorn@gmail.com> |
7 | Copyright (C) 2009 Alban Browaeys <prahal@yahoo.com> | ||
8 | Copyright (C) 2009 Felix Fietkau <nbd@openwrt.org> | ||
9 | Copyright (C) 2009 Luis Correia <luis.f.correia@gmail.com> | ||
10 | Copyright (C) 2009 Mattias Nissler <mattias.nissler@gmx.de> | ||
11 | Copyright (C) 2009 Mark Asselstine <asselsm@gmail.com> | ||
12 | Copyright (C) 2009 Xose Vazquez Perez <xose.vazquez@gmail.com> | ||
7 | <http://rt2x00.serialmonkey.com> | 13 | <http://rt2x00.serialmonkey.com> |
8 | 14 | ||
9 | This program is free software; you can redistribute it and/or modify | 15 | This program is free software; you can redistribute it and/or modify |
@@ -555,7 +561,8 @@ void rt2800_config_intf(struct rt2x00_dev *rt2x00dev, struct rt2x00_intf *intf, | |||
555 | rt2800_register_read(rt2x00dev, BCN_TIME_CFG, ®); | 561 | rt2800_register_read(rt2x00dev, BCN_TIME_CFG, ®); |
556 | rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 1); | 562 | rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 1); |
557 | rt2x00_set_field32(®, BCN_TIME_CFG_TSF_SYNC, conf->sync); | 563 | rt2x00_set_field32(®, BCN_TIME_CFG_TSF_SYNC, conf->sync); |
558 | rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 1); | 564 | rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, |
565 | (conf->sync == TSF_SYNC_BEACON)); | ||
559 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); | 566 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); |
560 | } | 567 | } |
561 | 568 | ||
@@ -769,7 +776,7 @@ static void rt2800_config_channel_rt3x(struct rt2x00_dev *rt2x00dev, | |||
769 | u8 rfcsr; | 776 | u8 rfcsr; |
770 | 777 | ||
771 | rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); | 778 | rt2800_rfcsr_write(rt2x00dev, 2, rf->rf1); |
772 | rt2800_rfcsr_write(rt2x00dev, 2, rf->rf3); | 779 | rt2800_rfcsr_write(rt2x00dev, 3, rf->rf3); |
773 | 780 | ||
774 | rt2800_rfcsr_read(rt2x00dev, 6, &rfcsr); | 781 | rt2800_rfcsr_read(rt2x00dev, 6, &rfcsr); |
775 | rt2x00_set_field8(&rfcsr, RFCSR6_R, rf->rf2); | 782 | rt2x00_set_field8(&rfcsr, RFCSR6_R, rf->rf2); |
@@ -801,10 +808,15 @@ static void rt2800_config_channel(struct rt2x00_dev *rt2x00dev, | |||
801 | unsigned int tx_pin; | 808 | unsigned int tx_pin; |
802 | u8 bbp; | 809 | u8 bbp; |
803 | 810 | ||
804 | if (rt2x00_rev(&rt2x00dev->chip) != RT3070_VERSION) | 811 | if ((rt2x00_rt(&rt2x00dev->chip, RT3070) || |
805 | rt2800_config_channel_rt2x(rt2x00dev, conf, rf, info); | 812 | rt2x00_rt(&rt2x00dev->chip, RT3090)) && |
806 | else | 813 | (rt2x00_rf(&rt2x00dev->chip, RF2020) || |
814 | rt2x00_rf(&rt2x00dev->chip, RF3020) || | ||
815 | rt2x00_rf(&rt2x00dev->chip, RF3021) || | ||
816 | rt2x00_rf(&rt2x00dev->chip, RF3022))) | ||
807 | rt2800_config_channel_rt3x(rt2x00dev, conf, rf, info); | 817 | rt2800_config_channel_rt3x(rt2x00dev, conf, rf, info); |
818 | else | ||
819 | rt2800_config_channel_rt2x(rt2x00dev, conf, rf, info); | ||
808 | 820 | ||
809 | /* | 821 | /* |
810 | * Change BBP settings | 822 | * Change BBP settings |
@@ -1084,7 +1096,7 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | |||
1084 | 1096 | ||
1085 | if (rt2x00_intf_is_usb(rt2x00dev)) { | 1097 | if (rt2x00_intf_is_usb(rt2x00dev)) { |
1086 | /* | 1098 | /* |
1087 | * Wait untill BBP and RF are ready. | 1099 | * Wait until BBP and RF are ready. |
1088 | */ | 1100 | */ |
1089 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | 1101 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { |
1090 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); | 1102 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); |
@@ -1659,6 +1671,466 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) | |||
1659 | } | 1671 | } |
1660 | EXPORT_SYMBOL_GPL(rt2800_init_rfcsr); | 1672 | EXPORT_SYMBOL_GPL(rt2800_init_rfcsr); |
1661 | 1673 | ||
1674 | int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev) | ||
1675 | { | ||
1676 | u32 reg; | ||
1677 | |||
1678 | rt2800_register_read(rt2x00dev, EFUSE_CTRL, ®); | ||
1679 | |||
1680 | return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT); | ||
1681 | } | ||
1682 | EXPORT_SYMBOL_GPL(rt2800_efuse_detect); | ||
1683 | |||
1684 | static void rt2800_efuse_read(struct rt2x00_dev *rt2x00dev, unsigned int i) | ||
1685 | { | ||
1686 | u32 reg; | ||
1687 | |||
1688 | mutex_lock(&rt2x00dev->csr_mutex); | ||
1689 | |||
1690 | rt2800_register_read_lock(rt2x00dev, EFUSE_CTRL, ®); | ||
1691 | rt2x00_set_field32(®, EFUSE_CTRL_ADDRESS_IN, i); | ||
1692 | rt2x00_set_field32(®, EFUSE_CTRL_MODE, 0); | ||
1693 | rt2x00_set_field32(®, EFUSE_CTRL_KICK, 1); | ||
1694 | rt2800_register_write_lock(rt2x00dev, EFUSE_CTRL, reg); | ||
1695 | |||
1696 | /* Wait until the EEPROM has been loaded */ | ||
1697 | rt2800_regbusy_read(rt2x00dev, EFUSE_CTRL, EFUSE_CTRL_KICK, ®); | ||
1698 | |||
1699 | /* Apparently the data is read from end to start */ | ||
1700 | rt2800_register_read_lock(rt2x00dev, EFUSE_DATA3, | ||
1701 | (u32 *)&rt2x00dev->eeprom[i]); | ||
1702 | rt2800_register_read_lock(rt2x00dev, EFUSE_DATA2, | ||
1703 | (u32 *)&rt2x00dev->eeprom[i + 2]); | ||
1704 | rt2800_register_read_lock(rt2x00dev, EFUSE_DATA1, | ||
1705 | (u32 *)&rt2x00dev->eeprom[i + 4]); | ||
1706 | rt2800_register_read_lock(rt2x00dev, EFUSE_DATA0, | ||
1707 | (u32 *)&rt2x00dev->eeprom[i + 6]); | ||
1708 | |||
1709 | mutex_unlock(&rt2x00dev->csr_mutex); | ||
1710 | } | ||
1711 | |||
1712 | void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev) | ||
1713 | { | ||
1714 | unsigned int i; | ||
1715 | |||
1716 | for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8) | ||
1717 | rt2800_efuse_read(rt2x00dev, i); | ||
1718 | } | ||
1719 | EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse); | ||
1720 | |||
1721 | int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) | ||
1722 | { | ||
1723 | u16 word; | ||
1724 | u8 *mac; | ||
1725 | u8 default_lna_gain; | ||
1726 | |||
1727 | /* | ||
1728 | * Start validation of the data that has been read. | ||
1729 | */ | ||
1730 | mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0); | ||
1731 | if (!is_valid_ether_addr(mac)) { | ||
1732 | random_ether_addr(mac); | ||
1733 | EEPROM(rt2x00dev, "MAC: %pM\n", mac); | ||
1734 | } | ||
1735 | |||
1736 | rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &word); | ||
1737 | if (word == 0xffff) { | ||
1738 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2); | ||
1739 | rt2x00_set_field16(&word, EEPROM_ANTENNA_TXPATH, 1); | ||
1740 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RF_TYPE, RF2820); | ||
1741 | rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word); | ||
1742 | EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word); | ||
1743 | } else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) { | ||
1744 | /* | ||
1745 | * There is a max of 2 RX streams for RT28x0 series | ||
1746 | */ | ||
1747 | if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2) | ||
1748 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2); | ||
1749 | rt2x00_eeprom_write(rt2x00dev, EEPROM_ANTENNA, word); | ||
1750 | } | ||
1751 | |||
1752 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &word); | ||
1753 | if (word == 0xffff) { | ||
1754 | rt2x00_set_field16(&word, EEPROM_NIC_HW_RADIO, 0); | ||
1755 | rt2x00_set_field16(&word, EEPROM_NIC_DYNAMIC_TX_AGC, 0); | ||
1756 | rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_BG, 0); | ||
1757 | rt2x00_set_field16(&word, EEPROM_NIC_EXTERNAL_LNA_A, 0); | ||
1758 | rt2x00_set_field16(&word, EEPROM_NIC_CARDBUS_ACCEL, 0); | ||
1759 | rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_BG, 0); | ||
1760 | rt2x00_set_field16(&word, EEPROM_NIC_BW40M_SB_A, 0); | ||
1761 | rt2x00_set_field16(&word, EEPROM_NIC_WPS_PBC, 0); | ||
1762 | rt2x00_set_field16(&word, EEPROM_NIC_BW40M_BG, 0); | ||
1763 | rt2x00_set_field16(&word, EEPROM_NIC_BW40M_A, 0); | ||
1764 | rt2x00_eeprom_write(rt2x00dev, EEPROM_NIC, word); | ||
1765 | EEPROM(rt2x00dev, "NIC: 0x%04x\n", word); | ||
1766 | } | ||
1767 | |||
1768 | rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &word); | ||
1769 | if ((word & 0x00ff) == 0x00ff) { | ||
1770 | rt2x00_set_field16(&word, EEPROM_FREQ_OFFSET, 0); | ||
1771 | rt2x00_set_field16(&word, EEPROM_FREQ_LED_MODE, | ||
1772 | LED_MODE_TXRX_ACTIVITY); | ||
1773 | rt2x00_set_field16(&word, EEPROM_FREQ_LED_POLARITY, 0); | ||
1774 | rt2x00_eeprom_write(rt2x00dev, EEPROM_FREQ, word); | ||
1775 | rt2x00_eeprom_write(rt2x00dev, EEPROM_LED1, 0x5555); | ||
1776 | rt2x00_eeprom_write(rt2x00dev, EEPROM_LED2, 0x2221); | ||
1777 | rt2x00_eeprom_write(rt2x00dev, EEPROM_LED3, 0xa9f8); | ||
1778 | EEPROM(rt2x00dev, "Freq: 0x%04x\n", word); | ||
1779 | } | ||
1780 | |||
1781 | /* | ||
1782 | * During the LNA validation we are going to use | ||
1783 | * lna0 as correct value. Note that EEPROM_LNA | ||
1784 | * is never validated. | ||
1785 | */ | ||
1786 | rt2x00_eeprom_read(rt2x00dev, EEPROM_LNA, &word); | ||
1787 | default_lna_gain = rt2x00_get_field16(word, EEPROM_LNA_A0); | ||
1788 | |||
1789 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG, &word); | ||
1790 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET0)) > 10) | ||
1791 | rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET0, 0); | ||
1792 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG_OFFSET1)) > 10) | ||
1793 | rt2x00_set_field16(&word, EEPROM_RSSI_BG_OFFSET1, 0); | ||
1794 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG, word); | ||
1795 | |||
1796 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_BG2, &word); | ||
1797 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_BG2_OFFSET2)) > 10) | ||
1798 | rt2x00_set_field16(&word, EEPROM_RSSI_BG2_OFFSET2, 0); | ||
1799 | if (rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0x00 || | ||
1800 | rt2x00_get_field16(word, EEPROM_RSSI_BG2_LNA_A1) == 0xff) | ||
1801 | rt2x00_set_field16(&word, EEPROM_RSSI_BG2_LNA_A1, | ||
1802 | default_lna_gain); | ||
1803 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_BG2, word); | ||
1804 | |||
1805 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A, &word); | ||
1806 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET0)) > 10) | ||
1807 | rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET0, 0); | ||
1808 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A_OFFSET1)) > 10) | ||
1809 | rt2x00_set_field16(&word, EEPROM_RSSI_A_OFFSET1, 0); | ||
1810 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A, word); | ||
1811 | |||
1812 | rt2x00_eeprom_read(rt2x00dev, EEPROM_RSSI_A2, &word); | ||
1813 | if (abs(rt2x00_get_field16(word, EEPROM_RSSI_A2_OFFSET2)) > 10) | ||
1814 | rt2x00_set_field16(&word, EEPROM_RSSI_A2_OFFSET2, 0); | ||
1815 | if (rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0x00 || | ||
1816 | rt2x00_get_field16(word, EEPROM_RSSI_A2_LNA_A2) == 0xff) | ||
1817 | rt2x00_set_field16(&word, EEPROM_RSSI_A2_LNA_A2, | ||
1818 | default_lna_gain); | ||
1819 | rt2x00_eeprom_write(rt2x00dev, EEPROM_RSSI_A2, word); | ||
1820 | |||
1821 | return 0; | ||
1822 | } | ||
1823 | EXPORT_SYMBOL_GPL(rt2800_validate_eeprom); | ||
1824 | |||
1825 | int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev) | ||
1826 | { | ||
1827 | u32 reg; | ||
1828 | u16 value; | ||
1829 | u16 eeprom; | ||
1830 | |||
1831 | /* | ||
1832 | * Read EEPROM word for configuration. | ||
1833 | */ | ||
1834 | rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom); | ||
1835 | |||
1836 | /* | ||
1837 | * Identify RF chipset. | ||
1838 | */ | ||
1839 | value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); | ||
1840 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); | ||
1841 | |||
1842 | rt2x00_set_chip_rf(rt2x00dev, value, reg); | ||
1843 | |||
1844 | if (rt2x00_intf_is_usb(rt2x00dev)) { | ||
1845 | struct rt2x00_chip *chip = &rt2x00dev->chip; | ||
1846 | |||
1847 | /* | ||
1848 | * The check for rt2860 is not a typo, some rt2870 hardware | ||
1849 | * identifies itself as rt2860 in the CSR register. | ||
1850 | */ | ||
1851 | if (rt2x00_check_rev(chip, 0xfff00000, 0x28600000) || | ||
1852 | rt2x00_check_rev(chip, 0xfff00000, 0x28700000) || | ||
1853 | rt2x00_check_rev(chip, 0xfff00000, 0x28800000)) { | ||
1854 | rt2x00_set_chip_rt(rt2x00dev, RT2870); | ||
1855 | } else if (rt2x00_check_rev(chip, 0xffff0000, 0x30700000)) { | ||
1856 | rt2x00_set_chip_rt(rt2x00dev, RT3070); | ||
1857 | } else { | ||
1858 | ERROR(rt2x00dev, "Invalid RT chipset detected.\n"); | ||
1859 | return -ENODEV; | ||
1860 | } | ||
1861 | } | ||
1862 | rt2x00_print_chip(rt2x00dev); | ||
1863 | |||
1864 | if (!rt2x00_rf(&rt2x00dev->chip, RF2820) && | ||
1865 | !rt2x00_rf(&rt2x00dev->chip, RF2850) && | ||
1866 | !rt2x00_rf(&rt2x00dev->chip, RF2720) && | ||
1867 | !rt2x00_rf(&rt2x00dev->chip, RF2750) && | ||
1868 | !rt2x00_rf(&rt2x00dev->chip, RF3020) && | ||
1869 | !rt2x00_rf(&rt2x00dev->chip, RF2020) && | ||
1870 | !rt2x00_rf(&rt2x00dev->chip, RF3021) && | ||
1871 | !rt2x00_rf(&rt2x00dev->chip, RF3022)) { | ||
1872 | ERROR(rt2x00dev, "Invalid RF chipset detected.\n"); | ||
1873 | return -ENODEV; | ||
1874 | } | ||
1875 | |||
1876 | /* | ||
1877 | * Identify default antenna configuration. | ||
1878 | */ | ||
1879 | rt2x00dev->default_ant.tx = | ||
1880 | rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH); | ||
1881 | rt2x00dev->default_ant.rx = | ||
1882 | rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH); | ||
1883 | |||
1884 | /* | ||
1885 | * Read frequency offset and RF programming sequence. | ||
1886 | */ | ||
1887 | rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &eeprom); | ||
1888 | rt2x00dev->freq_offset = rt2x00_get_field16(eeprom, EEPROM_FREQ_OFFSET); | ||
1889 | |||
1890 | /* | ||
1891 | * Read external LNA informations. | ||
1892 | */ | ||
1893 | rt2x00_eeprom_read(rt2x00dev, EEPROM_NIC, &eeprom); | ||
1894 | |||
1895 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_A)) | ||
1896 | __set_bit(CONFIG_EXTERNAL_LNA_A, &rt2x00dev->flags); | ||
1897 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_EXTERNAL_LNA_BG)) | ||
1898 | __set_bit(CONFIG_EXTERNAL_LNA_BG, &rt2x00dev->flags); | ||
1899 | |||
1900 | /* | ||
1901 | * Detect if this device has an hardware controlled radio. | ||
1902 | */ | ||
1903 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO)) | ||
1904 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); | ||
1905 | |||
1906 | /* | ||
1907 | * Store led settings, for correct led behaviour. | ||
1908 | */ | ||
1909 | #ifdef CONFIG_RT2X00_LIB_LEDS | ||
1910 | rt2800_init_led(rt2x00dev, &rt2x00dev->led_radio, LED_TYPE_RADIO); | ||
1911 | rt2800_init_led(rt2x00dev, &rt2x00dev->led_assoc, LED_TYPE_ASSOC); | ||
1912 | rt2800_init_led(rt2x00dev, &rt2x00dev->led_qual, LED_TYPE_QUALITY); | ||
1913 | |||
1914 | rt2x00_eeprom_read(rt2x00dev, EEPROM_FREQ, &rt2x00dev->led_mcu_reg); | ||
1915 | #endif /* CONFIG_RT2X00_LIB_LEDS */ | ||
1916 | |||
1917 | return 0; | ||
1918 | } | ||
1919 | EXPORT_SYMBOL_GPL(rt2800_init_eeprom); | ||
1920 | |||
1921 | /* | ||
1922 | * RF value list for rt28x0 | ||
1923 | * Supports: 2.4 GHz (all) & 5.2 GHz (RF2850 & RF2750) | ||
1924 | */ | ||
1925 | static const struct rf_channel rf_vals[] = { | ||
1926 | { 1, 0x18402ecc, 0x184c0786, 0x1816b455, 0x1800510b }, | ||
1927 | { 2, 0x18402ecc, 0x184c0786, 0x18168a55, 0x1800519f }, | ||
1928 | { 3, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800518b }, | ||
1929 | { 4, 0x18402ecc, 0x184c078a, 0x18168a55, 0x1800519f }, | ||
1930 | { 5, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800518b }, | ||
1931 | { 6, 0x18402ecc, 0x184c078e, 0x18168a55, 0x1800519f }, | ||
1932 | { 7, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800518b }, | ||
1933 | { 8, 0x18402ecc, 0x184c0792, 0x18168a55, 0x1800519f }, | ||
1934 | { 9, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800518b }, | ||
1935 | { 10, 0x18402ecc, 0x184c0796, 0x18168a55, 0x1800519f }, | ||
1936 | { 11, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800518b }, | ||
1937 | { 12, 0x18402ecc, 0x184c079a, 0x18168a55, 0x1800519f }, | ||
1938 | { 13, 0x18402ecc, 0x184c079e, 0x18168a55, 0x1800518b }, | ||
1939 | { 14, 0x18402ecc, 0x184c07a2, 0x18168a55, 0x18005193 }, | ||
1940 | |||
1941 | /* 802.11 UNI / HyperLan 2 */ | ||
1942 | { 36, 0x18402ecc, 0x184c099a, 0x18158a55, 0x180ed1a3 }, | ||
1943 | { 38, 0x18402ecc, 0x184c099e, 0x18158a55, 0x180ed193 }, | ||
1944 | { 40, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed183 }, | ||
1945 | { 44, 0x18402ec8, 0x184c0682, 0x18158a55, 0x180ed1a3 }, | ||
1946 | { 46, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed18b }, | ||
1947 | { 48, 0x18402ec8, 0x184c0686, 0x18158a55, 0x180ed19b }, | ||
1948 | { 52, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed193 }, | ||
1949 | { 54, 0x18402ec8, 0x184c068a, 0x18158a55, 0x180ed1a3 }, | ||
1950 | { 56, 0x18402ec8, 0x184c068e, 0x18158a55, 0x180ed18b }, | ||
1951 | { 60, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed183 }, | ||
1952 | { 62, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed193 }, | ||
1953 | { 64, 0x18402ec8, 0x184c0692, 0x18158a55, 0x180ed1a3 }, | ||
1954 | |||
1955 | /* 802.11 HyperLan 2 */ | ||
1956 | { 100, 0x18402ec8, 0x184c06b2, 0x18178a55, 0x180ed783 }, | ||
1957 | { 102, 0x18402ec8, 0x184c06b2, 0x18578a55, 0x180ed793 }, | ||
1958 | { 104, 0x18402ec8, 0x185c06b2, 0x18578a55, 0x180ed1a3 }, | ||
1959 | { 108, 0x18402ecc, 0x185c0a32, 0x18578a55, 0x180ed193 }, | ||
1960 | { 110, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed183 }, | ||
1961 | { 112, 0x18402ecc, 0x184c0a36, 0x18178a55, 0x180ed19b }, | ||
1962 | { 116, 0x18402ecc, 0x184c0a3a, 0x18178a55, 0x180ed1a3 }, | ||
1963 | { 118, 0x18402ecc, 0x184c0a3e, 0x18178a55, 0x180ed193 }, | ||
1964 | { 120, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed183 }, | ||
1965 | { 124, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed193 }, | ||
1966 | { 126, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed15b }, | ||
1967 | { 128, 0x18402ec4, 0x184c0382, 0x18178a55, 0x180ed1a3 }, | ||
1968 | { 132, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed18b }, | ||
1969 | { 134, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed193 }, | ||
1970 | { 136, 0x18402ec4, 0x184c0386, 0x18178a55, 0x180ed19b }, | ||
1971 | { 140, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed183 }, | ||
1972 | |||
1973 | /* 802.11 UNII */ | ||
1974 | { 149, 0x18402ec4, 0x184c038a, 0x18178a55, 0x180ed1a7 }, | ||
1975 | { 151, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed187 }, | ||
1976 | { 153, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed18f }, | ||
1977 | { 157, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed19f }, | ||
1978 | { 159, 0x18402ec4, 0x184c038e, 0x18178a55, 0x180ed1a7 }, | ||
1979 | { 161, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed187 }, | ||
1980 | { 165, 0x18402ec4, 0x184c0392, 0x18178a55, 0x180ed197 }, | ||
1981 | { 167, 0x18402ec4, 0x184c03d2, 0x18179855, 0x1815531f }, | ||
1982 | { 169, 0x18402ec4, 0x184c03d2, 0x18179855, 0x18155327 }, | ||
1983 | { 171, 0x18402ec4, 0x184c03d6, 0x18179855, 0x18155307 }, | ||
1984 | { 173, 0x18402ec4, 0x184c03d6, 0x18179855, 0x1815530f }, | ||
1985 | |||
1986 | /* 802.11 Japan */ | ||
1987 | { 184, 0x15002ccc, 0x1500491e, 0x1509be55, 0x150c0a0b }, | ||
1988 | { 188, 0x15002ccc, 0x15004922, 0x1509be55, 0x150c0a13 }, | ||
1989 | { 192, 0x15002ccc, 0x15004926, 0x1509be55, 0x150c0a1b }, | ||
1990 | { 196, 0x15002ccc, 0x1500492a, 0x1509be55, 0x150c0a23 }, | ||
1991 | { 208, 0x15002ccc, 0x1500493a, 0x1509be55, 0x150c0a13 }, | ||
1992 | { 212, 0x15002ccc, 0x1500493e, 0x1509be55, 0x150c0a1b }, | ||
1993 | { 216, 0x15002ccc, 0x15004982, 0x1509be55, 0x150c0a23 }, | ||
1994 | }; | ||
1995 | |||
1996 | /* | ||
1997 | * RF value list for rt3070 | ||
1998 | * Supports: 2.4 GHz | ||
1999 | */ | ||
2000 | static const struct rf_channel rf_vals_302x[] = { | ||
2001 | {1, 241, 2, 2 }, | ||
2002 | {2, 241, 2, 7 }, | ||
2003 | {3, 242, 2, 2 }, | ||
2004 | {4, 242, 2, 7 }, | ||
2005 | {5, 243, 2, 2 }, | ||
2006 | {6, 243, 2, 7 }, | ||
2007 | {7, 244, 2, 2 }, | ||
2008 | {8, 244, 2, 7 }, | ||
2009 | {9, 245, 2, 2 }, | ||
2010 | {10, 245, 2, 7 }, | ||
2011 | {11, 246, 2, 2 }, | ||
2012 | {12, 246, 2, 7 }, | ||
2013 | {13, 247, 2, 2 }, | ||
2014 | {14, 248, 2, 4 }, | ||
2015 | }; | ||
2016 | |||
2017 | int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev) | ||
2018 | { | ||
2019 | struct rt2x00_chip *chip = &rt2x00dev->chip; | ||
2020 | struct hw_mode_spec *spec = &rt2x00dev->spec; | ||
2021 | struct channel_info *info; | ||
2022 | char *tx_power1; | ||
2023 | char *tx_power2; | ||
2024 | unsigned int i; | ||
2025 | u16 eeprom; | ||
2026 | |||
2027 | /* | ||
2028 | * Initialize all hw fields. | ||
2029 | */ | ||
2030 | rt2x00dev->hw->flags = | ||
2031 | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | | ||
2032 | IEEE80211_HW_SIGNAL_DBM | | ||
2033 | IEEE80211_HW_SUPPORTS_PS | | ||
2034 | IEEE80211_HW_PS_NULLFUNC_STACK; | ||
2035 | |||
2036 | if (rt2x00_intf_is_usb(rt2x00dev)) | ||
2037 | rt2x00dev->hw->extra_tx_headroom = | ||
2038 | TXINFO_DESC_SIZE + TXWI_DESC_SIZE; | ||
2039 | else if (rt2x00_intf_is_pci(rt2x00dev)) | ||
2040 | rt2x00dev->hw->extra_tx_headroom = TXWI_DESC_SIZE; | ||
2041 | |||
2042 | SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); | ||
2043 | SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, | ||
2044 | rt2x00_eeprom_addr(rt2x00dev, | ||
2045 | EEPROM_MAC_ADDR_0)); | ||
2046 | |||
2047 | rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom); | ||
2048 | |||
2049 | /* | ||
2050 | * Initialize hw_mode information. | ||
2051 | */ | ||
2052 | spec->supported_bands = SUPPORT_BAND_2GHZ; | ||
2053 | spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; | ||
2054 | |||
2055 | if (rt2x00_rf(chip, RF2820) || | ||
2056 | rt2x00_rf(chip, RF2720) || | ||
2057 | (rt2x00_intf_is_pci(rt2x00dev) && rt2x00_rf(chip, RF3052))) { | ||
2058 | spec->num_channels = 14; | ||
2059 | spec->channels = rf_vals; | ||
2060 | } else if (rt2x00_rf(chip, RF2850) || rt2x00_rf(chip, RF2750)) { | ||
2061 | spec->supported_bands |= SUPPORT_BAND_5GHZ; | ||
2062 | spec->num_channels = ARRAY_SIZE(rf_vals); | ||
2063 | spec->channels = rf_vals; | ||
2064 | } else if (rt2x00_rf(chip, RF3020) || | ||
2065 | rt2x00_rf(chip, RF2020) || | ||
2066 | rt2x00_rf(chip, RF3021) || | ||
2067 | rt2x00_rf(chip, RF3022)) { | ||
2068 | spec->num_channels = ARRAY_SIZE(rf_vals_302x); | ||
2069 | spec->channels = rf_vals_302x; | ||
2070 | } | ||
2071 | |||
2072 | /* | ||
2073 | * Initialize HT information. | ||
2074 | */ | ||
2075 | spec->ht.ht_supported = true; | ||
2076 | spec->ht.cap = | ||
2077 | IEEE80211_HT_CAP_SUP_WIDTH_20_40 | | ||
2078 | IEEE80211_HT_CAP_GRN_FLD | | ||
2079 | IEEE80211_HT_CAP_SGI_20 | | ||
2080 | IEEE80211_HT_CAP_SGI_40 | | ||
2081 | IEEE80211_HT_CAP_TX_STBC | | ||
2082 | IEEE80211_HT_CAP_RX_STBC | | ||
2083 | IEEE80211_HT_CAP_PSMP_SUPPORT; | ||
2084 | spec->ht.ampdu_factor = 3; | ||
2085 | spec->ht.ampdu_density = 4; | ||
2086 | spec->ht.mcs.tx_params = | ||
2087 | IEEE80211_HT_MCS_TX_DEFINED | | ||
2088 | IEEE80211_HT_MCS_TX_RX_DIFF | | ||
2089 | ((rt2x00_get_field16(eeprom, EEPROM_ANTENNA_TXPATH) - 1) << | ||
2090 | IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); | ||
2091 | |||
2092 | switch (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RXPATH)) { | ||
2093 | case 3: | ||
2094 | spec->ht.mcs.rx_mask[2] = 0xff; | ||
2095 | case 2: | ||
2096 | spec->ht.mcs.rx_mask[1] = 0xff; | ||
2097 | case 1: | ||
2098 | spec->ht.mcs.rx_mask[0] = 0xff; | ||
2099 | spec->ht.mcs.rx_mask[4] = 0x1; /* MCS32 */ | ||
2100 | break; | ||
2101 | } | ||
2102 | |||
2103 | /* | ||
2104 | * Create channel information array | ||
2105 | */ | ||
2106 | info = kzalloc(spec->num_channels * sizeof(*info), GFP_KERNEL); | ||
2107 | if (!info) | ||
2108 | return -ENOMEM; | ||
2109 | |||
2110 | spec->channels_info = info; | ||
2111 | |||
2112 | tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG1); | ||
2113 | tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_BG2); | ||
2114 | |||
2115 | for (i = 0; i < 14; i++) { | ||
2116 | info[i].tx_power1 = TXPOWER_G_FROM_DEV(tx_power1[i]); | ||
2117 | info[i].tx_power2 = TXPOWER_G_FROM_DEV(tx_power2[i]); | ||
2118 | } | ||
2119 | |||
2120 | if (spec->num_channels > 14) { | ||
2121 | tx_power1 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A1); | ||
2122 | tx_power2 = rt2x00_eeprom_addr(rt2x00dev, EEPROM_TXPOWER_A2); | ||
2123 | |||
2124 | for (i = 14; i < spec->num_channels; i++) { | ||
2125 | info[i].tx_power1 = TXPOWER_A_FROM_DEV(tx_power1[i]); | ||
2126 | info[i].tx_power2 = TXPOWER_A_FROM_DEV(tx_power2[i]); | ||
2127 | } | ||
2128 | } | ||
2129 | |||
2130 | return 0; | ||
2131 | } | ||
2132 | EXPORT_SYMBOL_GPL(rt2800_probe_hw_mode); | ||
2133 | |||
1662 | /* | 2134 | /* |
1663 | * IEEE80211 stack callback functions. | 2135 | * IEEE80211 stack callback functions. |
1664 | */ | 2136 | */ |