aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2500usb.c
diff options
context:
space:
mode:
authorAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
committerAndrea Bastoni <bastoni@cs.unc.edu>2010-05-30 19:16:45 -0400
commitada47b5fe13d89735805b566185f4885f5a3f750 (patch)
tree644b88f8a71896307d71438e9b3af49126ffb22b /drivers/net/wireless/rt2x00/rt2500usb.c
parent43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff)
parent3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff)
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2500usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c213
1 files changed, 40 insertions, 173 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 22dd6d9e2981..8ebb705fe106 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1,5 +1,5 @@
1/* 1/*
2 Copyright (C) 2004 - 2009 rt2x00 SourceForge Project 2 Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
3 <http://rt2x00.serialmonkey.com> 3 <http://rt2x00.serialmonkey.com>
4 4
5 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/slab.h>
32#include <linux/usb.h> 33#include <linux/usb.h>
33 34
34#include "rt2x00.h" 35#include "rt2x00.h"
@@ -368,7 +369,7 @@ static int rt2500usb_config_key(struct rt2x00_dev *rt2x00dev,
368 369
369 /* 370 /*
370 * The encryption key doesn't fit within the CSR cache, 371 * The encryption key doesn't fit within the CSR cache,
371 * this means we should allocate it seperately and use 372 * this means we should allocate it separately and use
372 * rt2x00usb_vendor_request() to send the key to the hardware. 373 * rt2x00usb_vendor_request() to send the key to the hardware.
373 */ 374 */
374 reg = KEY_ENTRY(key->hw_key_idx); 375 reg = KEY_ENTRY(key->hw_key_idx);
@@ -382,7 +383,7 @@ static int rt2500usb_config_key(struct rt2x00_dev *rt2x00dev,
382 /* 383 /*
383 * The driver does not support the IV/EIV generation 384 * The driver does not support the IV/EIV generation
384 * in hardware. However it demands the data to be provided 385 * in hardware. However it demands the data to be provided
385 * both seperately as well as inside the frame. 386 * both separately as well as inside the frame.
386 * We already provided the CONFIG_CRYPTO_COPY_IV to rt2x00lib 387 * We already provided the CONFIG_CRYPTO_COPY_IV to rt2x00lib
387 * to ensure rt2x00lib will not strip the data from the 388 * to ensure rt2x00lib will not strip the data from the
388 * frame after the copy, now we must tell mac80211 389 * frame after the copy, now we must tell mac80211
@@ -565,8 +566,7 @@ static void rt2500usb_config_ant(struct rt2x00_dev *rt2x00dev,
565 /* 566 /*
566 * RT2525E and RT5222 need to flip TX I/Q 567 * RT2525E and RT5222 need to flip TX I/Q
567 */ 568 */
568 if (rt2x00_rf(&rt2x00dev->chip, RF2525E) || 569 if (rt2x00_rf(rt2x00dev, RF2525E) || rt2x00_rf(rt2x00dev, RF5222)) {
569 rt2x00_rf(&rt2x00dev->chip, RF5222)) {
570 rt2x00_set_field8(&r2, BBP_R2_TX_IQ_FLIP, 1); 570 rt2x00_set_field8(&r2, BBP_R2_TX_IQ_FLIP, 1);
571 rt2x00_set_field16(&csr5, PHY_CSR5_CCK_FLIP, 1); 571 rt2x00_set_field16(&csr5, PHY_CSR5_CCK_FLIP, 1);
572 rt2x00_set_field16(&csr6, PHY_CSR6_OFDM_FLIP, 1); 572 rt2x00_set_field16(&csr6, PHY_CSR6_OFDM_FLIP, 1);
@@ -574,7 +574,7 @@ static void rt2500usb_config_ant(struct rt2x00_dev *rt2x00dev,
574 /* 574 /*
575 * RT2525E does not need RX I/Q Flip. 575 * RT2525E does not need RX I/Q Flip.
576 */ 576 */
577 if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) 577 if (rt2x00_rf(rt2x00dev, RF2525E))
578 rt2x00_set_field8(&r14, BBP_R14_RX_IQ_FLIP, 0); 578 rt2x00_set_field8(&r14, BBP_R14_RX_IQ_FLIP, 0);
579 } else { 579 } else {
580 rt2x00_set_field16(&csr5, PHY_CSR5_CCK_FLIP, 0); 580 rt2x00_set_field16(&csr5, PHY_CSR5_CCK_FLIP, 0);
@@ -598,7 +598,7 @@ static void rt2500usb_config_channel(struct rt2x00_dev *rt2x00dev,
598 /* 598 /*
599 * For RT2525E we should first set the channel to half band higher. 599 * For RT2525E we should first set the channel to half band higher.
600 */ 600 */
601 if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) { 601 if (rt2x00_rf(rt2x00dev, RF2525E)) {
602 static const u32 vals[] = { 602 static const u32 vals[] = {
603 0x000008aa, 0x000008ae, 0x000008ae, 0x000008b2, 603 0x000008aa, 0x000008ae, 0x000008ae, 0x000008b2,
604 0x000008b2, 0x000008b6, 0x000008b6, 0x000008ba, 604 0x000008b2, 0x000008b6, 0x000008b6, 0x000008ba,
@@ -716,139 +716,6 @@ static void rt2500usb_reset_tuner(struct rt2x00_dev *rt2x00dev,
716} 716}
717 717
718/* 718/*
719 * NOTE: This function is directly ported from legacy driver, but
720 * despite it being declared it was never called. Although link tuning
721 * sounds like a good idea, and usually works well for the other drivers,
722 * it does _not_ work with rt2500usb. Enabling this function will result
723 * in TX capabilities only until association kicks in. Immediately
724 * after the successful association all TX frames will be kept in the
725 * hardware queue and never transmitted.
726 */
727#if 0
728static void rt2500usb_link_tuner(struct rt2x00_dev *rt2x00dev)
729{
730 int rssi = rt2x00_get_link_rssi(&rt2x00dev->link);
731 u16 bbp_thresh;
732 u16 vgc_bound;
733 u16 sens;
734 u16 r24;
735 u16 r25;
736 u16 r61;
737 u16 r17_sens;
738 u8 r17;
739 u8 up_bound;
740 u8 low_bound;
741
742 /*
743 * Read current r17 value, as well as the sensitivity values
744 * for the r17 register.
745 */
746 rt2500usb_bbp_read(rt2x00dev, 17, &r17);
747 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R17, &r17_sens);
748
749 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_VGC, &vgc_bound);
750 up_bound = rt2x00_get_field16(vgc_bound, EEPROM_BBPTUNE_VGCUPPER);
751 low_bound = rt2x00_get_field16(vgc_bound, EEPROM_BBPTUNE_VGCLOWER);
752
753 /*
754 * If we are not associated, we should go straight to the
755 * dynamic CCA tuning.
756 */
757 if (!rt2x00dev->intf_associated)
758 goto dynamic_cca_tune;
759
760 /*
761 * Determine the BBP tuning threshold and correctly
762 * set BBP 24, 25 and 61.
763 */
764 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE, &bbp_thresh);
765 bbp_thresh = rt2x00_get_field16(bbp_thresh, EEPROM_BBPTUNE_THRESHOLD);
766
767 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R24, &r24);
768 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R25, &r25);
769 rt2x00_eeprom_read(rt2x00dev, EEPROM_BBPTUNE_R61, &r61);
770
771 if ((rssi + bbp_thresh) > 0) {
772 r24 = rt2x00_get_field16(r24, EEPROM_BBPTUNE_R24_HIGH);
773 r25 = rt2x00_get_field16(r25, EEPROM_BBPTUNE_R25_HIGH);
774 r61 = rt2x00_get_field16(r61, EEPROM_BBPTUNE_R61_HIGH);
775 } else {
776 r24 = rt2x00_get_field16(r24, EEPROM_BBPTUNE_R24_LOW);
777 r25 = rt2x00_get_field16(r25, EEPROM_BBPTUNE_R25_LOW);
778 r61 = rt2x00_get_field16(r61, EEPROM_BBPTUNE_R61_LOW);
779 }
780
781 rt2500usb_bbp_write(rt2x00dev, 24, r24);
782 rt2500usb_bbp_write(rt2x00dev, 25, r25);
783 rt2500usb_bbp_write(rt2x00dev, 61, r61);
784
785 /*
786 * A too low RSSI will cause too much false CCA which will
787 * then corrupt the R17 tuning. To remidy this the tuning should
788 * be stopped (While making sure the R17 value will not exceed limits)
789 */
790 if (rssi >= -40) {
791 if (r17 != 0x60)
792 rt2500usb_bbp_write(rt2x00dev, 17, 0x60);
793 return;
794 }
795
796 /*
797 * Special big-R17 for short distance
798 */
799 if (rssi >= -58) {
800 sens = rt2x00_get_field16(r17_sens, EEPROM_BBPTUNE_R17_LOW);
801 if (r17 != sens)
802 rt2500usb_bbp_write(rt2x00dev, 17, sens);
803 return;
804 }
805
806 /*
807 * Special mid-R17 for middle distance
808 */
809 if (rssi >= -74) {
810 sens = rt2x00_get_field16(r17_sens, EEPROM_BBPTUNE_R17_HIGH);
811 if (r17 != sens)
812 rt2500usb_bbp_write(rt2x00dev, 17, sens);
813 return;
814 }
815
816 /*
817 * Leave short or middle distance condition, restore r17
818 * to the dynamic tuning range.
819 */
820 low_bound = 0x32;
821 if (rssi < -77)
822 up_bound -= (-77 - rssi);
823
824 if (up_bound < low_bound)
825 up_bound = low_bound;
826
827 if (r17 > up_bound) {
828 rt2500usb_bbp_write(rt2x00dev, 17, up_bound);
829 rt2x00dev->link.vgc_level = up_bound;
830 return;
831 }
832
833dynamic_cca_tune:
834
835 /*
836 * R17 is inside the dynamic tuning range,
837 * start tuning the link based on the false cca counter.
838 */
839 if (rt2x00dev->link.qual.false_cca > 512 && r17 < up_bound) {
840 rt2500usb_bbp_write(rt2x00dev, 17, ++r17);
841 rt2x00dev->link.vgc_level = r17;
842 } else if (rt2x00dev->link.qual.false_cca < 100 && r17 > low_bound) {
843 rt2500usb_bbp_write(rt2x00dev, 17, --r17);
844 rt2x00dev->link.vgc_level = r17;
845 }
846}
847#else
848#define rt2500usb_link_tuner NULL
849#endif
850
851/*
852 * Initialization functions. 719 * Initialization functions.
853 */ 720 */
854static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev) 721static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev)
@@ -926,7 +793,7 @@ static int rt2500usb_init_registers(struct rt2x00_dev *rt2x00dev)
926 rt2x00_set_field16(&reg, MAC_CSR1_HOST_READY, 1); 793 rt2x00_set_field16(&reg, MAC_CSR1_HOST_READY, 1);
927 rt2500usb_register_write(rt2x00dev, MAC_CSR1, reg); 794 rt2500usb_register_write(rt2x00dev, MAC_CSR1, reg);
928 795
929 if (rt2x00_rev(&rt2x00dev->chip) >= RT2570_VERSION_C) { 796 if (rt2x00_rev(rt2x00dev) >= RT2570_VERSION_C) {
930 rt2500usb_register_read(rt2x00dev, PHY_CSR2, &reg); 797 rt2500usb_register_read(rt2x00dev, PHY_CSR2, &reg);
931 rt2x00_set_field16(&reg, PHY_CSR2_LNA, 0); 798 rt2x00_set_field16(&reg, PHY_CSR2_LNA, 0);
932 } else { 799 } else {
@@ -1543,19 +1410,17 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
1543 rt2500usb_register_read(rt2x00dev, MAC_CSR0, &reg); 1410 rt2500usb_register_read(rt2x00dev, MAC_CSR0, &reg);
1544 rt2x00_set_chip(rt2x00dev, RT2570, value, reg); 1411 rt2x00_set_chip(rt2x00dev, RT2570, value, reg);
1545 1412
1546 if (!rt2x00_check_rev(&rt2x00dev->chip, 0x000ffff0, 0) || 1413 if (((reg & 0xfff0) != 0) || ((reg & 0x0000000f) == 0)) {
1547 rt2x00_check_rev(&rt2x00dev->chip, 0x0000000f, 0)) {
1548
1549 ERROR(rt2x00dev, "Invalid RT chipset detected.\n"); 1414 ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
1550 return -ENODEV; 1415 return -ENODEV;
1551 } 1416 }
1552 1417
1553 if (!rt2x00_rf(&rt2x00dev->chip, RF2522) && 1418 if (!rt2x00_rf(rt2x00dev, RF2522) &&
1554 !rt2x00_rf(&rt2x00dev->chip, RF2523) && 1419 !rt2x00_rf(rt2x00dev, RF2523) &&
1555 !rt2x00_rf(&rt2x00dev->chip, RF2524) && 1420 !rt2x00_rf(rt2x00dev, RF2524) &&
1556 !rt2x00_rf(&rt2x00dev->chip, RF2525) && 1421 !rt2x00_rf(rt2x00dev, RF2525) &&
1557 !rt2x00_rf(&rt2x00dev->chip, RF2525E) && 1422 !rt2x00_rf(rt2x00dev, RF2525E) &&
1558 !rt2x00_rf(&rt2x00dev->chip, RF5222)) { 1423 !rt2x00_rf(rt2x00dev, RF5222)) {
1559 ERROR(rt2x00dev, "Invalid RF chipset detected.\n"); 1424 ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
1560 return -ENODEV; 1425 return -ENODEV;
1561 } 1426 }
@@ -1779,6 +1644,11 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1779 unsigned int i; 1644 unsigned int i;
1780 1645
1781 /* 1646 /*
1647 * Disable powersaving as default.
1648 */
1649 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
1650
1651 /*
1782 * Initialize all hw fields. 1652 * Initialize all hw fields.
1783 */ 1653 */
1784 rt2x00dev->hw->flags = 1654 rt2x00dev->hw->flags =
@@ -1788,8 +1658,6 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1788 IEEE80211_HW_SUPPORTS_PS | 1658 IEEE80211_HW_SUPPORTS_PS |
1789 IEEE80211_HW_PS_NULLFUNC_STACK; 1659 IEEE80211_HW_PS_NULLFUNC_STACK;
1790 1660
1791 rt2x00dev->hw->extra_tx_headroom = TXD_DESC_SIZE;
1792
1793 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); 1661 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
1794 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, 1662 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
1795 rt2x00_eeprom_addr(rt2x00dev, 1663 rt2x00_eeprom_addr(rt2x00dev,
@@ -1801,22 +1669,22 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1801 spec->supported_bands = SUPPORT_BAND_2GHZ; 1669 spec->supported_bands = SUPPORT_BAND_2GHZ;
1802 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM; 1670 spec->supported_rates = SUPPORT_RATE_CCK | SUPPORT_RATE_OFDM;
1803 1671
1804 if (rt2x00_rf(&rt2x00dev->chip, RF2522)) { 1672 if (rt2x00_rf(rt2x00dev, RF2522)) {
1805 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2522); 1673 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2522);
1806 spec->channels = rf_vals_bg_2522; 1674 spec->channels = rf_vals_bg_2522;
1807 } else if (rt2x00_rf(&rt2x00dev->chip, RF2523)) { 1675 } else if (rt2x00_rf(rt2x00dev, RF2523)) {
1808 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2523); 1676 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2523);
1809 spec->channels = rf_vals_bg_2523; 1677 spec->channels = rf_vals_bg_2523;
1810 } else if (rt2x00_rf(&rt2x00dev->chip, RF2524)) { 1678 } else if (rt2x00_rf(rt2x00dev, RF2524)) {
1811 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2524); 1679 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2524);
1812 spec->channels = rf_vals_bg_2524; 1680 spec->channels = rf_vals_bg_2524;
1813 } else if (rt2x00_rf(&rt2x00dev->chip, RF2525)) { 1681 } else if (rt2x00_rf(rt2x00dev, RF2525)) {
1814 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2525); 1682 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2525);
1815 spec->channels = rf_vals_bg_2525; 1683 spec->channels = rf_vals_bg_2525;
1816 } else if (rt2x00_rf(&rt2x00dev->chip, RF2525E)) { 1684 } else if (rt2x00_rf(rt2x00dev, RF2525E)) {
1817 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2525e); 1685 spec->num_channels = ARRAY_SIZE(rf_vals_bg_2525e);
1818 spec->channels = rf_vals_bg_2525e; 1686 spec->channels = rf_vals_bg_2525e;
1819 } else if (rt2x00_rf(&rt2x00dev->chip, RF5222)) { 1687 } else if (rt2x00_rf(rt2x00dev, RF5222)) {
1820 spec->supported_bands |= SUPPORT_BAND_5GHZ; 1688 spec->supported_bands |= SUPPORT_BAND_5GHZ;
1821 spec->num_channels = ARRAY_SIZE(rf_vals_5222); 1689 spec->num_channels = ARRAY_SIZE(rf_vals_5222);
1822 spec->channels = rf_vals_5222; 1690 spec->channels = rf_vals_5222;
@@ -1897,7 +1765,6 @@ static const struct ieee80211_ops rt2500usb_mac80211_ops = {
1897 .get_stats = rt2x00mac_get_stats, 1765 .get_stats = rt2x00mac_get_stats,
1898 .bss_info_changed = rt2x00mac_bss_info_changed, 1766 .bss_info_changed = rt2x00mac_bss_info_changed,
1899 .conf_tx = rt2x00mac_conf_tx, 1767 .conf_tx = rt2x00mac_conf_tx,
1900 .get_tx_stats = rt2x00mac_get_tx_stats,
1901 .rfkill_poll = rt2x00mac_rfkill_poll, 1768 .rfkill_poll = rt2x00mac_rfkill_poll,
1902}; 1769};
1903 1770
@@ -1910,7 +1777,6 @@ static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = {
1910 .rfkill_poll = rt2500usb_rfkill_poll, 1777 .rfkill_poll = rt2500usb_rfkill_poll,
1911 .link_stats = rt2500usb_link_stats, 1778 .link_stats = rt2500usb_link_stats,
1912 .reset_tuner = rt2500usb_reset_tuner, 1779 .reset_tuner = rt2500usb_reset_tuner,
1913 .link_tuner = rt2500usb_link_tuner,
1914 .write_tx_desc = rt2500usb_write_tx_desc, 1780 .write_tx_desc = rt2500usb_write_tx_desc,
1915 .write_tx_data = rt2x00usb_write_tx_data, 1781 .write_tx_data = rt2x00usb_write_tx_data,
1916 .write_beacon = rt2500usb_write_beacon, 1782 .write_beacon = rt2500usb_write_beacon,
@@ -1956,20 +1822,21 @@ static const struct data_queue_desc rt2500usb_queue_atim = {
1956}; 1822};
1957 1823
1958static const struct rt2x00_ops rt2500usb_ops = { 1824static const struct rt2x00_ops rt2500usb_ops = {
1959 .name = KBUILD_MODNAME, 1825 .name = KBUILD_MODNAME,
1960 .max_sta_intf = 1, 1826 .max_sta_intf = 1,
1961 .max_ap_intf = 1, 1827 .max_ap_intf = 1,
1962 .eeprom_size = EEPROM_SIZE, 1828 .eeprom_size = EEPROM_SIZE,
1963 .rf_size = RF_SIZE, 1829 .rf_size = RF_SIZE,
1964 .tx_queues = NUM_TX_QUEUES, 1830 .tx_queues = NUM_TX_QUEUES,
1965 .rx = &rt2500usb_queue_rx, 1831 .extra_tx_headroom = TXD_DESC_SIZE,
1966 .tx = &rt2500usb_queue_tx, 1832 .rx = &rt2500usb_queue_rx,
1967 .bcn = &rt2500usb_queue_bcn, 1833 .tx = &rt2500usb_queue_tx,
1968 .atim = &rt2500usb_queue_atim, 1834 .bcn = &rt2500usb_queue_bcn,
1969 .lib = &rt2500usb_rt2x00_ops, 1835 .atim = &rt2500usb_queue_atim,
1970 .hw = &rt2500usb_mac80211_ops, 1836 .lib = &rt2500usb_rt2x00_ops,
1837 .hw = &rt2500usb_mac80211_ops,
1971#ifdef CONFIG_RT2X00_LIB_DEBUGFS 1838#ifdef CONFIG_RT2X00_LIB_DEBUGFS
1972 .debugfs = &rt2500usb_rt2x00debug, 1839 .debugfs = &rt2500usb_rt2x00debug,
1973#endif /* CONFIG_RT2X00_LIB_DEBUGFS */ 1840#endif /* CONFIG_RT2X00_LIB_DEBUGFS */
1974}; 1841};
1975 1842