aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/rt2x00/rt2800usb.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/rt2800usb.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/rt2800usb.c')
-rw-r--r--drivers/net/wireless/rt2x00/rt2800usb.c211
1 files changed, 1 insertions, 210 deletions
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