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/net/wireless/rt2x00/rt2800pci.c | |
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/net/wireless/rt2x00/rt2800pci.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800pci.c | 51 |
1 files changed, 30 insertions, 21 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 | } |