diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-11-08 08:38:54 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-11-11 17:09:13 -0500 |
commit | 7ab71325cf0940099c376799aca6de7bc86ad2d0 (patch) | |
tree | fd6f8316362e19f87a322d19612fce296c779a28 /drivers | |
parent | 863cc978a73bc07f1de0e9a9bd9889bed6e618da (diff) |
rt2800: prepare for unification of EEPROM support code
* Factor out common code from rt2800[pci,usb]_validate_eeprom()
to rt2800_validate_eeprom().
* Fix interface specific comment in rt2800[pci,usb]_validate_eeprom().
* Enclose interface specific code in rt2800[pci,usb]_init_eeprom()
with rt2x00_intf_is_[pci,usb]() checks.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800pci.c | 51 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800usb.c | 40 |
2 files changed, 55 insertions, 36 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index 2f284a6f384e..67081a4f04bd 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c | |||
@@ -1091,29 +1091,13 @@ static irqreturn_t rt2800pci_interrupt(int irq, void *dev_instance) | |||
1091 | /* | 1091 | /* |
1092 | * Device probe functions. | 1092 | * Device probe functions. |
1093 | */ | 1093 | */ |
1094 | static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev) | 1094 | static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) |
1095 | { | 1095 | { |
1096 | u16 word; | 1096 | u16 word; |
1097 | u8 *mac; | 1097 | u8 *mac; |
1098 | u8 default_lna_gain; | 1098 | u8 default_lna_gain; |
1099 | 1099 | ||
1100 | /* | 1100 | /* |
1101 | * Read EEPROM into buffer | ||
1102 | */ | ||
1103 | switch(rt2x00dev->chip.rt) { | ||
1104 | case RT2880: | ||
1105 | case RT3052: | ||
1106 | rt2800pci_read_eeprom_soc(rt2x00dev); | ||
1107 | break; | ||
1108 | default: | ||
1109 | if (rt2800pci_efuse_detect(rt2x00dev)) | ||
1110 | rt2800pci_read_eeprom_efuse(rt2x00dev); | ||
1111 | else | ||
1112 | rt2800pci_read_eeprom_pci(rt2x00dev); | ||
1113 | break; | ||
1114 | } | ||
1115 | |||
1116 | /* | ||
1117 | * Start validation of the data that has been read. | 1101 | * Start validation of the data that has been read. |
1118 | */ | 1102 | */ |
1119 | mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0); | 1103 | mac = rt2x00_eeprom_addr(rt2x00dev, EEPROM_MAC_ADDR_0); |
@@ -1131,7 +1115,7 @@ static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1131 | EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word); | 1115 | EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word); |
1132 | } else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) { | 1116 | } else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) { |
1133 | /* | 1117 | /* |
1134 | * There is a max of 2 RX streams for RT2860 series | 1118 | * There is a max of 2 RX streams for RT28x0 series |
1135 | */ | 1119 | */ |
1136 | if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2) | 1120 | if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2) |
1137 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2); | 1121 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2); |
@@ -1210,6 +1194,27 @@ static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1210 | return 0; | 1194 | return 0; |
1211 | } | 1195 | } |
1212 | 1196 | ||
1197 | static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev) | ||
1198 | { | ||
1199 | /* | ||
1200 | * Read EEPROM into buffer | ||
1201 | */ | ||
1202 | switch (rt2x00dev->chip.rt) { | ||
1203 | case RT2880: | ||
1204 | case RT3052: | ||
1205 | rt2800pci_read_eeprom_soc(rt2x00dev); | ||
1206 | break; | ||
1207 | default: | ||
1208 | if (rt2800pci_efuse_detect(rt2x00dev)) | ||
1209 | rt2800pci_read_eeprom_efuse(rt2x00dev); | ||
1210 | else | ||
1211 | rt2800pci_read_eeprom_pci(rt2x00dev); | ||
1212 | break; | ||
1213 | } | ||
1214 | |||
1215 | return rt2800_validate_eeprom(rt2x00dev); | ||
1216 | } | ||
1217 | |||
1213 | static int rt2800pci_init_eeprom(struct rt2x00_dev *rt2x00dev) | 1218 | static int rt2800pci_init_eeprom(struct rt2x00_dev *rt2x00dev) |
1214 | { | 1219 | { |
1215 | u32 reg; | 1220 | u32 reg; |
@@ -1226,7 +1231,9 @@ static int rt2800pci_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1226 | */ | 1231 | */ |
1227 | value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); | 1232 | value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); |
1228 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); | 1233 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); |
1229 | rt2x00_set_chip_rf(rt2x00dev, value, reg); | 1234 | |
1235 | if (rt2x00_intf_is_pci(rt2x00dev)) | ||
1236 | rt2x00_set_chip_rf(rt2x00dev, value, reg); | ||
1230 | 1237 | ||
1231 | if (!rt2x00_rf(&rt2x00dev->chip, RF2820) && | 1238 | if (!rt2x00_rf(&rt2x00dev->chip, RF2820) && |
1232 | !rt2x00_rf(&rt2x00dev->chip, RF2850) && | 1239 | !rt2x00_rf(&rt2x00dev->chip, RF2850) && |
@@ -1234,8 +1241,10 @@ static int rt2800pci_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1234 | !rt2x00_rf(&rt2x00dev->chip, RF2750) && | 1241 | !rt2x00_rf(&rt2x00dev->chip, RF2750) && |
1235 | !rt2x00_rf(&rt2x00dev->chip, RF3020) && | 1242 | !rt2x00_rf(&rt2x00dev->chip, RF3020) && |
1236 | !rt2x00_rf(&rt2x00dev->chip, RF2020) && | 1243 | !rt2x00_rf(&rt2x00dev->chip, RF2020) && |
1237 | !rt2x00_rf(&rt2x00dev->chip, RF3021) && | 1244 | (rt2x00_intf_is_usb(rt2x00dev) || |
1238 | !rt2x00_rf(&rt2x00dev->chip, RF3022)) { | 1245 | (rt2x00_intf_is_pci(rt2x00dev) && |
1246 | !rt2x00_rf(&rt2x00dev->chip, RF3021) && | ||
1247 | !rt2x00_rf(&rt2x00dev->chip, RF3022)))) { | ||
1239 | ERROR(rt2x00dev, "Invalid RF chipset detected.\n"); | 1248 | ERROR(rt2x00dev, "Invalid RF chipset detected.\n"); |
1240 | return -ENODEV; | 1249 | return -ENODEV; |
1241 | } | 1250 | } |
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 3168ad4437a4..080947cc5d6b 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
@@ -665,14 +665,12 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry, | |||
665 | /* | 665 | /* |
666 | * Device probe functions. | 666 | * Device probe functions. |
667 | */ | 667 | */ |
668 | static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev) | 668 | static int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev) |
669 | { | 669 | { |
670 | u16 word; | 670 | u16 word; |
671 | u8 *mac; | 671 | u8 *mac; |
672 | u8 default_lna_gain; | 672 | u8 default_lna_gain; |
673 | 673 | ||
674 | rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE); | ||
675 | |||
676 | /* | 674 | /* |
677 | * Start validation of the data that has been read. | 675 | * Start validation of the data that has been read. |
678 | */ | 676 | */ |
@@ -691,7 +689,7 @@ static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev) | |||
691 | EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word); | 689 | EEPROM(rt2x00dev, "Antenna: 0x%04x\n", word); |
692 | } else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) { | 690 | } else if (rt2x00_rev(&rt2x00dev->chip) < RT2883_VERSION) { |
693 | /* | 691 | /* |
694 | * There is a max of 2 RX streams for RT2870 series | 692 | * There is a max of 2 RX streams for RT28x0 series |
695 | */ | 693 | */ |
696 | if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2) | 694 | if (rt2x00_get_field16(word, EEPROM_ANTENNA_RXPATH) > 2) |
697 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2); | 695 | rt2x00_set_field16(&word, EEPROM_ANTENNA_RXPATH, 2); |
@@ -770,6 +768,13 @@ static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev) | |||
770 | return 0; | 768 | return 0; |
771 | } | 769 | } |
772 | 770 | ||
771 | static int rt2800usb_validate_eeprom(struct rt2x00_dev *rt2x00dev) | ||
772 | { | ||
773 | rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, EEPROM_SIZE); | ||
774 | |||
775 | return rt2800_validate_eeprom(rt2x00dev); | ||
776 | } | ||
777 | |||
773 | static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev) | 778 | static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev) |
774 | { | 779 | { |
775 | u32 reg; | 780 | u32 reg; |
@@ -786,18 +791,23 @@ static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
786 | */ | 791 | */ |
787 | value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); | 792 | value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE); |
788 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); | 793 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); |
789 | rt2x00_set_chip(rt2x00dev, RT2870, value, reg); | ||
790 | 794 | ||
791 | /* | 795 | if (rt2x00_intf_is_usb(rt2x00dev)) { |
792 | * The check for rt2860 is not a typo, some rt2870 hardware | 796 | struct rt2x00_chip *chip = &rt2x00dev->chip; |
793 | * identifies itself as rt2860 in the CSR register. | 797 | |
794 | */ | 798 | rt2x00_set_chip(rt2x00dev, RT2870, value, reg); |
795 | if (!rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28600000) && | 799 | |
796 | !rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28700000) && | 800 | /* |
797 | !rt2x00_check_rev(&rt2x00dev->chip, 0xfff00000, 0x28800000) && | 801 | * The check for rt2860 is not a typo, some rt2870 hardware |
798 | !rt2x00_check_rev(&rt2x00dev->chip, 0xffff0000, 0x30700000)) { | 802 | * identifies itself as rt2860 in the CSR register. |
799 | ERROR(rt2x00dev, "Invalid RT chipset detected.\n"); | 803 | */ |
800 | return -ENODEV; | 804 | if (!rt2x00_check_rev(chip, 0xfff00000, 0x28600000) && |
805 | !rt2x00_check_rev(chip, 0xfff00000, 0x28700000) && | ||
806 | !rt2x00_check_rev(chip, 0xfff00000, 0x28800000) && | ||
807 | !rt2x00_check_rev(chip, 0xffff0000, 0x30700000)) { | ||
808 | ERROR(rt2x00dev, "Invalid RT chipset detected.\n"); | ||
809 | return -ENODEV; | ||
810 | } | ||
801 | } | 811 | } |
802 | 812 | ||
803 | if (!rt2x00_rf(&rt2x00dev->chip, RF2820) && | 813 | if (!rt2x00_rf(&rt2x00dev->chip, RF2820) && |