aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath9k/eeprom.c
diff options
context:
space:
mode:
authorSujith <Sujith.Manoharan@atheros.com>2009-02-09 02:57:12 -0500
committerJohn W. Linville <linville@tuxdriver.com>2009-02-13 13:45:05 -0500
commitcbe61d8a41210600bc76b212edcd4dc0f55c014f (patch)
treed8bd8e43d3556c58d410f1bef0d2ca3bf7d75c92 /drivers/net/wireless/ath9k/eeprom.c
parentba52da58be0acf3b7775972b2b5234ce64388c79 (diff)
ath9k: Merge ath_hal and ath_hal_5416 structures
Finally, merge these structures and have a single HW specific data structure. Signed-off-by: Sujith <Sujith.Manoharan@atheros.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k/eeprom.c')
-rw-r--r--drivers/net/wireless/ath9k/eeprom.c251
1 files changed, 106 insertions, 145 deletions
diff --git a/drivers/net/wireless/ath9k/eeprom.c b/drivers/net/wireless/ath9k/eeprom.c
index d58d8a330b64..94e79938b93a 100644
--- a/drivers/net/wireless/ath9k/eeprom.c
+++ b/drivers/net/wireless/ath9k/eeprom.c
@@ -16,7 +16,7 @@
16 16
17#include "ath9k.h" 17#include "ath9k.h"
18 18
19static void ath9k_hw_analog_shift_rmw(struct ath_hal *ah, 19static void ath9k_hw_analog_shift_rmw(struct ath_hw *ah,
20 u32 reg, u32 mask, 20 u32 reg, u32 mask,
21 u32 shift, u32 val) 21 u32 shift, u32 val)
22{ 22{
@@ -88,18 +88,17 @@ static inline bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList,
88 return false; 88 return false;
89} 89}
90 90
91static inline bool ath9k_hw_nvram_read(struct ath_hal *ah, u32 off, u16 *data) 91static inline bool ath9k_hw_nvram_read(struct ath_hw *ah, u32 off, u16 *data)
92{ 92{
93 struct ath_softc *sc = ah->ah_sc; 93 struct ath_softc *sc = ah->ah_sc;
94 94
95 return sc->bus_ops->eeprom_read(ah, off, data); 95 return sc->bus_ops->eeprom_read(ah, off, data);
96} 96}
97 97
98static bool ath9k_hw_fill_4k_eeprom(struct ath_hal *ah) 98static bool ath9k_hw_fill_4k_eeprom(struct ath_hw *ah)
99{ 99{
100#define SIZE_EEPROM_4K (sizeof(struct ar5416_eeprom_4k) / sizeof(u16)) 100#define SIZE_EEPROM_4K (sizeof(struct ar5416_eeprom_4k) / sizeof(u16))
101 struct ath_hal_5416 *ahp = AH5416(ah); 101 struct ar5416_eeprom_4k *eep = &ah->ah_eeprom.map4k;
102 struct ar5416_eeprom_4k *eep = &ahp->ah_eeprom.map4k;
103 u16 *eep_data; 102 u16 *eep_data;
104 int addr, eep_start_loc = 0; 103 int addr, eep_start_loc = 0;
105 104
@@ -124,11 +123,10 @@ static bool ath9k_hw_fill_4k_eeprom(struct ath_hal *ah)
124#undef SIZE_EEPROM_4K 123#undef SIZE_EEPROM_4K
125} 124}
126 125
127static bool ath9k_hw_fill_def_eeprom(struct ath_hal *ah) 126static bool ath9k_hw_fill_def_eeprom(struct ath_hw *ah)
128{ 127{
129#define SIZE_EEPROM_DEF (sizeof(struct ar5416_eeprom_def) / sizeof(u16)) 128#define SIZE_EEPROM_DEF (sizeof(struct ar5416_eeprom_def) / sizeof(u16))
130 struct ath_hal_5416 *ahp = AH5416(ah); 129 struct ar5416_eeprom_def *eep = &ah->ah_eeprom.def;
131 struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def;
132 u16 *eep_data; 130 u16 *eep_data;
133 int addr, ar5416_eep_start_loc = 0x100; 131 int addr, ar5416_eep_start_loc = 0x100;
134 132
@@ -147,23 +145,20 @@ static bool ath9k_hw_fill_def_eeprom(struct ath_hal *ah)
147#undef SIZE_EEPROM_DEF 145#undef SIZE_EEPROM_DEF
148} 146}
149 147
150static bool (*ath9k_fill_eeprom[]) (struct ath_hal *) = { 148static bool (*ath9k_fill_eeprom[]) (struct ath_hw *) = {
151 ath9k_hw_fill_def_eeprom, 149 ath9k_hw_fill_def_eeprom,
152 ath9k_hw_fill_4k_eeprom 150 ath9k_hw_fill_4k_eeprom
153}; 151};
154 152
155static inline bool ath9k_hw_fill_eeprom(struct ath_hal *ah) 153static inline bool ath9k_hw_fill_eeprom(struct ath_hw *ah)
156{ 154{
157 struct ath_hal_5416 *ahp = AH5416(ah); 155 return ath9k_fill_eeprom[ah->ah_eep_map](ah);
158
159 return ath9k_fill_eeprom[ahp->ah_eep_map](ah);
160} 156}
161 157
162static int ath9k_hw_check_def_eeprom(struct ath_hal *ah) 158static int ath9k_hw_check_def_eeprom(struct ath_hw *ah)
163{ 159{
164 struct ath_hal_5416 *ahp = AH5416(ah);
165 struct ar5416_eeprom_def *eep = 160 struct ar5416_eeprom_def *eep =
166 (struct ar5416_eeprom_def *) &ahp->ah_eeprom.def; 161 (struct ar5416_eeprom_def *) &ah->ah_eeprom.def;
167 u16 *eepdata, temp, magic, magic2; 162 u16 *eepdata, temp, magic, magic2;
168 u32 sum = 0, el; 163 u32 sum = 0, el;
169 bool need_swap = false; 164 bool need_swap = false;
@@ -187,7 +182,7 @@ static int ath9k_hw_check_def_eeprom(struct ath_hal *ah)
187 if (magic2 == AR5416_EEPROM_MAGIC) { 182 if (magic2 == AR5416_EEPROM_MAGIC) {
188 size = sizeof(struct ar5416_eeprom_def); 183 size = sizeof(struct ar5416_eeprom_def);
189 need_swap = true; 184 need_swap = true;
190 eepdata = (u16 *) (&ahp->ah_eeprom); 185 eepdata = (u16 *) (&ah->ah_eeprom);
191 186
192 for (addr = 0; addr < size / sizeof(u16); addr++) { 187 for (addr = 0; addr < size / sizeof(u16); addr++) {
193 temp = swab16(*eepdata); 188 temp = swab16(*eepdata);
@@ -214,16 +209,16 @@ static int ath9k_hw_check_def_eeprom(struct ath_hal *ah)
214 need_swap ? "True" : "False"); 209 need_swap ? "True" : "False");
215 210
216 if (need_swap) 211 if (need_swap)
217 el = swab16(ahp->ah_eeprom.def.baseEepHeader.length); 212 el = swab16(ah->ah_eeprom.def.baseEepHeader.length);
218 else 213 else
219 el = ahp->ah_eeprom.def.baseEepHeader.length; 214 el = ah->ah_eeprom.def.baseEepHeader.length;
220 215
221 if (el > sizeof(struct ar5416_eeprom_def)) 216 if (el > sizeof(struct ar5416_eeprom_def))
222 el = sizeof(struct ar5416_eeprom_def) / sizeof(u16); 217 el = sizeof(struct ar5416_eeprom_def) / sizeof(u16);
223 else 218 else
224 el = el / sizeof(u16); 219 el = el / sizeof(u16);
225 220
226 eepdata = (u16 *)(&ahp->ah_eeprom); 221 eepdata = (u16 *)(&ah->ah_eeprom);
227 222
228 for (i = 0; i < el; i++) 223 for (i = 0; i < el; i++)
229 sum ^= *eepdata++; 224 sum ^= *eepdata++;
@@ -277,23 +272,22 @@ static int ath9k_hw_check_def_eeprom(struct ath_hal *ah)
277 } 272 }
278 } 273 }
279 274
280 if (sum != 0xffff || ar5416_get_eep_ver(ahp) != AR5416_EEP_VER || 275 if (sum != 0xffff || ar5416_get_eep_ver(ah) != AR5416_EEP_VER ||
281 ar5416_get_eep_rev(ahp) < AR5416_EEP_NO_BACK_VER) { 276 ar5416_get_eep_rev(ah) < AR5416_EEP_NO_BACK_VER) {
282 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, 277 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
283 "Bad EEPROM checksum 0x%x or revision 0x%04x\n", 278 "Bad EEPROM checksum 0x%x or revision 0x%04x\n",
284 sum, ar5416_get_eep_ver(ahp)); 279 sum, ar5416_get_eep_ver(ah));
285 return -EINVAL; 280 return -EINVAL;
286 } 281 }
287 282
288 return 0; 283 return 0;
289} 284}
290 285
291static int ath9k_hw_check_4k_eeprom(struct ath_hal *ah) 286static int ath9k_hw_check_4k_eeprom(struct ath_hw *ah)
292{ 287{
293#define EEPROM_4K_SIZE (sizeof(struct ar5416_eeprom_4k) / sizeof(u16)) 288#define EEPROM_4K_SIZE (sizeof(struct ar5416_eeprom_4k) / sizeof(u16))
294 struct ath_hal_5416 *ahp = AH5416(ah);
295 struct ar5416_eeprom_4k *eep = 289 struct ar5416_eeprom_4k *eep =
296 (struct ar5416_eeprom_4k *) &ahp->ah_eeprom.map4k; 290 (struct ar5416_eeprom_4k *) &ah->ah_eeprom.map4k;
297 u16 *eepdata, temp, magic, magic2; 291 u16 *eepdata, temp, magic, magic2;
298 u32 sum = 0, el; 292 u32 sum = 0, el;
299 bool need_swap = false; 293 bool need_swap = false;
@@ -317,7 +311,7 @@ static int ath9k_hw_check_4k_eeprom(struct ath_hal *ah)
317 311
318 if (magic2 == AR5416_EEPROM_MAGIC) { 312 if (magic2 == AR5416_EEPROM_MAGIC) {
319 need_swap = true; 313 need_swap = true;
320 eepdata = (u16 *) (&ahp->ah_eeprom); 314 eepdata = (u16 *) (&ah->ah_eeprom);
321 315
322 for (addr = 0; addr < EEPROM_4K_SIZE; addr++) { 316 for (addr = 0; addr < EEPROM_4K_SIZE; addr++) {
323 temp = swab16(*eepdata); 317 temp = swab16(*eepdata);
@@ -344,16 +338,16 @@ static int ath9k_hw_check_4k_eeprom(struct ath_hal *ah)
344 need_swap ? "True" : "False"); 338 need_swap ? "True" : "False");
345 339
346 if (need_swap) 340 if (need_swap)
347 el = swab16(ahp->ah_eeprom.map4k.baseEepHeader.length); 341 el = swab16(ah->ah_eeprom.map4k.baseEepHeader.length);
348 else 342 else
349 el = ahp->ah_eeprom.map4k.baseEepHeader.length; 343 el = ah->ah_eeprom.map4k.baseEepHeader.length;
350 344
351 if (el > sizeof(struct ar5416_eeprom_def)) 345 if (el > sizeof(struct ar5416_eeprom_def))
352 el = sizeof(struct ar5416_eeprom_4k) / sizeof(u16); 346 el = sizeof(struct ar5416_eeprom_4k) / sizeof(u16);
353 else 347 else
354 el = el / sizeof(u16); 348 el = el / sizeof(u16);
355 349
356 eepdata = (u16 *)(&ahp->ah_eeprom); 350 eepdata = (u16 *)(&ah->ah_eeprom);
357 351
358 for (i = 0; i < el; i++) 352 for (i = 0; i < el; i++)
359 sum ^= *eepdata++; 353 sum ^= *eepdata++;
@@ -403,11 +397,11 @@ static int ath9k_hw_check_4k_eeprom(struct ath_hal *ah)
403 } 397 }
404 } 398 }
405 399
406 if (sum != 0xffff || ar5416_get_eep4k_ver(ahp) != AR5416_EEP_VER || 400 if (sum != 0xffff || ar5416_get_eep4k_ver(ah) != AR5416_EEP_VER ||
407 ar5416_get_eep4k_rev(ahp) < AR5416_EEP_NO_BACK_VER) { 401 ar5416_get_eep4k_rev(ah) < AR5416_EEP_NO_BACK_VER) {
408 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, 402 DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
409 "Bad EEPROM checksum 0x%x or revision 0x%04x\n", 403 "Bad EEPROM checksum 0x%x or revision 0x%04x\n",
410 sum, ar5416_get_eep4k_ver(ahp)); 404 sum, ar5416_get_eep4k_ver(ah));
411 return -EINVAL; 405 return -EINVAL;
412 } 406 }
413 407
@@ -415,16 +409,14 @@ static int ath9k_hw_check_4k_eeprom(struct ath_hal *ah)
415#undef EEPROM_4K_SIZE 409#undef EEPROM_4K_SIZE
416} 410}
417 411
418static int (*ath9k_check_eeprom[]) (struct ath_hal *) = { 412static int (*ath9k_check_eeprom[]) (struct ath_hw *) = {
419 ath9k_hw_check_def_eeprom, 413 ath9k_hw_check_def_eeprom,
420 ath9k_hw_check_4k_eeprom 414 ath9k_hw_check_4k_eeprom
421}; 415};
422 416
423static inline int ath9k_hw_check_eeprom(struct ath_hal *ah) 417static inline int ath9k_hw_check_eeprom(struct ath_hw *ah)
424{ 418{
425 struct ath_hal_5416 *ahp = AH5416(ah); 419 return ath9k_check_eeprom[ah->ah_eep_map](ah);
426
427 return ath9k_check_eeprom[ahp->ah_eep_map](ah);
428} 420}
429 421
430static inline bool ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList, 422static inline bool ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList,
@@ -456,7 +448,7 @@ static inline bool ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList,
456 return true; 448 return true;
457} 449}
458 450
459static void ath9k_hw_get_4k_gain_boundaries_pdadcs(struct ath_hal *ah, 451static void ath9k_hw_get_4k_gain_boundaries_pdadcs(struct ath_hw *ah,
460 struct ath9k_channel *chan, 452 struct ath9k_channel *chan,
461 struct cal_data_per_freq_4k *pRawDataSet, 453 struct cal_data_per_freq_4k *pRawDataSet,
462 u8 *bChans, u16 availPiers, 454 u8 *bChans, u16 availPiers,
@@ -624,7 +616,7 @@ static void ath9k_hw_get_4k_gain_boundaries_pdadcs(struct ath_hal *ah,
624#undef TMP_VAL_VPD_TABLE 616#undef TMP_VAL_VPD_TABLE
625} 617}
626 618
627static void ath9k_hw_get_def_gain_boundaries_pdadcs(struct ath_hal *ah, 619static void ath9k_hw_get_def_gain_boundaries_pdadcs(struct ath_hw *ah,
628 struct ath9k_channel *chan, 620 struct ath9k_channel *chan,
629 struct cal_data_per_freq *pRawDataSet, 621 struct cal_data_per_freq *pRawDataSet,
630 u8 *bChans, u16 availPiers, 622 u8 *bChans, u16 availPiers,
@@ -789,7 +781,7 @@ static void ath9k_hw_get_def_gain_boundaries_pdadcs(struct ath_hal *ah,
789 return; 781 return;
790} 782}
791 783
792static void ath9k_hw_get_legacy_target_powers(struct ath_hal *ah, 784static void ath9k_hw_get_legacy_target_powers(struct ath_hw *ah,
793 struct ath9k_channel *chan, 785 struct ath9k_channel *chan,
794 struct cal_target_power_leg *powInfo, 786 struct cal_target_power_leg *powInfo,
795 u16 numChannels, 787 u16 numChannels,
@@ -844,7 +836,7 @@ static void ath9k_hw_get_legacy_target_powers(struct ath_hal *ah,
844 } 836 }
845} 837}
846 838
847static void ath9k_hw_get_target_powers(struct ath_hal *ah, 839static void ath9k_hw_get_target_powers(struct ath_hw *ah,
848 struct ath9k_channel *chan, 840 struct ath9k_channel *chan,
849 struct cal_target_power_ht *powInfo, 841 struct cal_target_power_ht *powInfo,
850 u16 numChannels, 842 u16 numChannels,
@@ -927,12 +919,11 @@ static u16 ath9k_hw_get_max_edge_power(u16 freq,
927 return twiceMaxEdgePower; 919 return twiceMaxEdgePower;
928} 920}
929 921
930static bool ath9k_hw_set_def_power_cal_table(struct ath_hal *ah, 922static bool ath9k_hw_set_def_power_cal_table(struct ath_hw *ah,
931 struct ath9k_channel *chan, 923 struct ath9k_channel *chan,
932 int16_t *pTxPowerIndexOffset) 924 int16_t *pTxPowerIndexOffset)
933{ 925{
934 struct ath_hal_5416 *ahp = AH5416(ah); 926 struct ar5416_eeprom_def *pEepData = &ah->ah_eeprom.def;
935 struct ar5416_eeprom_def *pEepData = &ahp->ah_eeprom.def;
936 struct cal_data_per_freq *pRawDataset; 927 struct cal_data_per_freq *pRawDataset;
937 u8 *pCalBChans = NULL; 928 u8 *pCalBChans = NULL;
938 u16 pdGainOverlap_t2; 929 u16 pdGainOverlap_t2;
@@ -988,7 +979,7 @@ static bool ath9k_hw_set_def_power_cal_table(struct ath_hal *ah,
988 979
989 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 980 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
990 if (AR_SREV_5416_V20_OR_LATER(ah) && 981 if (AR_SREV_5416_V20_OR_LATER(ah) &&
991 (ahp->ah_rxchainmask == 5 || ahp->ah_txchainmask == 5) && 982 (ah->ah_rxchainmask == 5 || ah->ah_txchainmask == 5) &&
992 (i != 0)) { 983 (i != 0)) {
993 regChainOffset = (i == 1) ? 0x2000 : 0x1000; 984 regChainOffset = (i == 1) ? 0x2000 : 0x1000;
994 } else 985 } else
@@ -1054,12 +1045,11 @@ static bool ath9k_hw_set_def_power_cal_table(struct ath_hal *ah,
1054 return true; 1045 return true;
1055} 1046}
1056 1047
1057static bool ath9k_hw_set_4k_power_cal_table(struct ath_hal *ah, 1048static bool ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
1058 struct ath9k_channel *chan, 1049 struct ath9k_channel *chan,
1059 int16_t *pTxPowerIndexOffset) 1050 int16_t *pTxPowerIndexOffset)
1060{ 1051{
1061 struct ath_hal_5416 *ahp = AH5416(ah); 1052 struct ar5416_eeprom_4k *pEepData = &ah->ah_eeprom.map4k;
1062 struct ar5416_eeprom_4k *pEepData = &ahp->ah_eeprom.map4k;
1063 struct cal_data_per_freq_4k *pRawDataset; 1053 struct cal_data_per_freq_4k *pRawDataset;
1064 u8 *pCalBChans = NULL; 1054 u8 *pCalBChans = NULL;
1065 u16 pdGainOverlap_t2; 1055 u16 pdGainOverlap_t2;
@@ -1108,7 +1098,7 @@ static bool ath9k_hw_set_4k_power_cal_table(struct ath_hal *ah,
1108 1098
1109 for (i = 0; i < AR5416_MAX_CHAINS; i++) { 1099 for (i = 0; i < AR5416_MAX_CHAINS; i++) {
1110 if (AR_SREV_5416_V20_OR_LATER(ah) && 1100 if (AR_SREV_5416_V20_OR_LATER(ah) &&
1111 (ahp->ah_rxchainmask == 5 || ahp->ah_txchainmask == 5) && 1101 (ah->ah_rxchainmask == 5 || ah->ah_txchainmask == 5) &&
1112 (i != 0)) { 1102 (i != 0)) {
1113 regChainOffset = (i == 1) ? 0x2000 : 0x1000; 1103 regChainOffset = (i == 1) ? 0x2000 : 0x1000;
1114 } else 1104 } else
@@ -1171,7 +1161,7 @@ static bool ath9k_hw_set_4k_power_cal_table(struct ath_hal *ah,
1171 return true; 1161 return true;
1172} 1162}
1173 1163
1174static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah, 1164static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah,
1175 struct ath9k_channel *chan, 1165 struct ath9k_channel *chan,
1176 int16_t *ratesArray, 1166 int16_t *ratesArray,
1177 u16 cfgCtl, 1167 u16 cfgCtl,
@@ -1182,8 +1172,7 @@ static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
1182#define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */ 1172#define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */
1183#define REDUCE_SCALED_POWER_BY_THREE_CHAIN 10 /* 10*log10(3)*2 */ 1173#define REDUCE_SCALED_POWER_BY_THREE_CHAIN 10 /* 10*log10(3)*2 */
1184 1174
1185 struct ath_hal_5416 *ahp = AH5416(ah); 1175 struct ar5416_eeprom_def *pEepData = &ah->ah_eeprom.def;
1186 struct ar5416_eeprom_def *pEepData = &ahp->ah_eeprom.def;
1187 u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER; 1176 u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
1188 static const u16 tpScaleReductionTable[5] = 1177 static const u16 tpScaleReductionTable[5] =
1189 { 0, 3, 6, 9, AR5416_MAX_RATE_POWER }; 1178 { 0, 3, 6, 9, AR5416_MAX_RATE_POWER };
@@ -1213,7 +1202,7 @@ static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
1213 int tx_chainmask; 1202 int tx_chainmask;
1214 u16 twiceMinEdgePower; 1203 u16 twiceMinEdgePower;
1215 1204
1216 tx_chainmask = ahp->ah_txchainmask; 1205 tx_chainmask = ah->ah_txchainmask;
1217 1206
1218 ath9k_hw_get_channel_centers(ah, chan, &centers); 1207 ath9k_hw_get_channel_centers(ah, chan, &centers);
1219 1208
@@ -1322,7 +1311,7 @@ static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
1322 else 1311 else
1323 freq = centers.ctl_center; 1312 freq = centers.ctl_center;
1324 1313
1325 if (ar5416_get_eep_ver(ahp) == 14 && ar5416_get_eep_rev(ahp) <= 2) 1314 if (ar5416_get_eep_ver(ah) == 14 && ar5416_get_eep_rev(ah) <= 2)
1326 twiceMaxEdgePower = AR5416_MAX_RATE_POWER; 1315 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
1327 1316
1328 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT, 1317 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
@@ -1462,7 +1451,7 @@ static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hal *ah,
1462 return true; 1451 return true;
1463} 1452}
1464 1453
1465static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hal *ah, 1454static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah,
1466 struct ath9k_channel *chan, 1455 struct ath9k_channel *chan,
1467 int16_t *ratesArray, 1456 int16_t *ratesArray,
1468 u16 cfgCtl, 1457 u16 cfgCtl,
@@ -1470,8 +1459,7 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hal *ah,
1470 u16 twiceMaxRegulatoryPower, 1459 u16 twiceMaxRegulatoryPower,
1471 u16 powerLimit) 1460 u16 powerLimit)
1472{ 1461{
1473 struct ath_hal_5416 *ahp = AH5416(ah); 1462 struct ar5416_eeprom_4k *pEepData = &ah->ah_eeprom.map4k;
1474 struct ar5416_eeprom_4k *pEepData = &ahp->ah_eeprom.map4k;
1475 u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER; 1463 u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
1476 static const u16 tpScaleReductionTable[5] = 1464 static const u16 tpScaleReductionTable[5] =
1477 { 0, 3, 6, 9, AR5416_MAX_RATE_POWER }; 1465 { 0, 3, 6, 9, AR5416_MAX_RATE_POWER };
@@ -1499,7 +1487,7 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hal *ah,
1499 int tx_chainmask; 1487 int tx_chainmask;
1500 u16 twiceMinEdgePower; 1488 u16 twiceMinEdgePower;
1501 1489
1502 tx_chainmask = ahp->ah_txchainmask; 1490 tx_chainmask = ah->ah_txchainmask;
1503 1491
1504 ath9k_hw_get_channel_centers(ah, chan, &centers); 1492 ath9k_hw_get_channel_centers(ah, chan, &centers);
1505 1493
@@ -1560,8 +1548,8 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hal *ah,
1560 else 1548 else
1561 freq = centers.ctl_center; 1549 freq = centers.ctl_center;
1562 1550
1563 if (ar5416_get_eep_ver(ahp) == 14 && 1551 if (ar5416_get_eep_ver(ah) == 14 &&
1564 ar5416_get_eep_rev(ahp) <= 2) 1552 ar5416_get_eep_rev(ah) <= 2)
1565 twiceMaxEdgePower = AR5416_MAX_RATE_POWER; 1553 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
1566 1554
1567 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT, 1555 DPRINTF(ah->ah_sc, ATH_DBG_POWER_MGMT,
@@ -1698,15 +1686,14 @@ static bool ath9k_hw_set_4k_power_per_rate_table(struct ath_hal *ah,
1698 return true; 1686 return true;
1699} 1687}
1700 1688
1701static int ath9k_hw_def_set_txpower(struct ath_hal *ah, 1689static int ath9k_hw_def_set_txpower(struct ath_hw *ah,
1702 struct ath9k_channel *chan, 1690 struct ath9k_channel *chan,
1703 u16 cfgCtl, 1691 u16 cfgCtl,
1704 u8 twiceAntennaReduction, 1692 u8 twiceAntennaReduction,
1705 u8 twiceMaxRegulatoryPower, 1693 u8 twiceMaxRegulatoryPower,
1706 u8 powerLimit) 1694 u8 powerLimit)
1707{ 1695{
1708 struct ath_hal_5416 *ahp = AH5416(ah); 1696 struct ar5416_eeprom_def *pEepData = &ah->ah_eeprom.def;
1709 struct ar5416_eeprom_def *pEepData = &ahp->ah_eeprom.def;
1710 struct modal_eep_header *pModal = 1697 struct modal_eep_header *pModal =
1711 &(pEepData->modalHeader[IS_CHAN_2GHZ(chan)]); 1698 &(pEepData->modalHeader[IS_CHAN_2GHZ(chan)]);
1712 int16_t ratesArray[Ar5416RateSize]; 1699 int16_t ratesArray[Ar5416RateSize];
@@ -1831,15 +1818,14 @@ static int ath9k_hw_def_set_txpower(struct ath_hal *ah,
1831 return 0; 1818 return 0;
1832} 1819}
1833 1820
1834static int ath9k_hw_4k_set_txpower(struct ath_hal *ah, 1821static int ath9k_hw_4k_set_txpower(struct ath_hw *ah,
1835 struct ath9k_channel *chan, 1822 struct ath9k_channel *chan,
1836 u16 cfgCtl, 1823 u16 cfgCtl,
1837 u8 twiceAntennaReduction, 1824 u8 twiceAntennaReduction,
1838 u8 twiceMaxRegulatoryPower, 1825 u8 twiceMaxRegulatoryPower,
1839 u8 powerLimit) 1826 u8 powerLimit)
1840{ 1827{
1841 struct ath_hal_5416 *ahp = AH5416(ah); 1828 struct ar5416_eeprom_4k *pEepData = &ah->ah_eeprom.map4k;
1842 struct ar5416_eeprom_4k *pEepData = &ahp->ah_eeprom.map4k;
1843 struct modal_eep_4k_header *pModal = &pEepData->modalHeader; 1829 struct modal_eep_4k_header *pModal = &pEepData->modalHeader;
1844 int16_t ratesArray[Ar5416RateSize]; 1830 int16_t ratesArray[Ar5416RateSize];
1845 int16_t txPowerIndexOffset = 0; 1831 int16_t txPowerIndexOffset = 0;
@@ -1959,40 +1945,37 @@ static int ath9k_hw_4k_set_txpower(struct ath_hal *ah,
1959 return 0; 1945 return 0;
1960} 1946}
1961 1947
1962static int (*ath9k_set_txpower[]) (struct ath_hal *, 1948static int (*ath9k_set_txpower[]) (struct ath_hw *,
1963 struct ath9k_channel *, 1949 struct ath9k_channel *,
1964 u16, u8, u8, u8) = { 1950 u16, u8, u8, u8) = {
1965 ath9k_hw_def_set_txpower, 1951 ath9k_hw_def_set_txpower,
1966 ath9k_hw_4k_set_txpower 1952 ath9k_hw_4k_set_txpower
1967}; 1953};
1968 1954
1969int ath9k_hw_set_txpower(struct ath_hal *ah, 1955int ath9k_hw_set_txpower(struct ath_hw *ah,
1970 struct ath9k_channel *chan, 1956 struct ath9k_channel *chan,
1971 u16 cfgCtl, 1957 u16 cfgCtl,
1972 u8 twiceAntennaReduction, 1958 u8 twiceAntennaReduction,
1973 u8 twiceMaxRegulatoryPower, 1959 u8 twiceMaxRegulatoryPower,
1974 u8 powerLimit) 1960 u8 powerLimit)
1975{ 1961{
1976 struct ath_hal_5416 *ahp = AH5416(ah); 1962 return ath9k_set_txpower[ah->ah_eep_map](ah, chan, cfgCtl,
1977 1963 twiceAntennaReduction, twiceMaxRegulatoryPower,
1978 return ath9k_set_txpower[ahp->ah_eep_map](ah, chan, cfgCtl, 1964 powerLimit);
1979 twiceAntennaReduction, twiceMaxRegulatoryPower,
1980 powerLimit);
1981} 1965}
1982 1966
1983static void ath9k_hw_set_def_addac(struct ath_hal *ah, 1967static void ath9k_hw_set_def_addac(struct ath_hw *ah,
1984 struct ath9k_channel *chan) 1968 struct ath9k_channel *chan)
1985{ 1969{
1986#define XPA_LVL_FREQ(cnt) (pModal->xpaBiasLvlFreq[cnt]) 1970#define XPA_LVL_FREQ(cnt) (pModal->xpaBiasLvlFreq[cnt])
1987 struct modal_eep_header *pModal; 1971 struct modal_eep_header *pModal;
1988 struct ath_hal_5416 *ahp = AH5416(ah); 1972 struct ar5416_eeprom_def *eep = &ah->ah_eeprom.def;
1989 struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def;
1990 u8 biaslevel; 1973 u8 biaslevel;
1991 1974
1992 if (ah->hw_version.macVersion != AR_SREV_VERSION_9160) 1975 if (ah->hw_version.macVersion != AR_SREV_VERSION_9160)
1993 return; 1976 return;
1994 1977
1995 if (ar5416_get_eep_rev(ahp) < AR5416_EEP_MINOR_VER_7) 1978 if (ar5416_get_eep_rev(ah) < AR5416_EEP_MINOR_VER_7)
1996 return; 1979 return;
1997 1980
1998 pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]); 1981 pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
@@ -2026,60 +2009,54 @@ static void ath9k_hw_set_def_addac(struct ath_hal *ah,
2026 } 2009 }
2027 2010
2028 if (IS_CHAN_2GHZ(chan)) { 2011 if (IS_CHAN_2GHZ(chan)) {
2029 INI_RA(&ahp->ah_iniAddac, 7, 1) = (INI_RA(&ahp->ah_iniAddac, 2012 INI_RA(&ah->ah_iniAddac, 7, 1) = (INI_RA(&ah->ah_iniAddac,
2030 7, 1) & (~0x18)) | biaslevel << 3; 2013 7, 1) & (~0x18)) | biaslevel << 3;
2031 } else { 2014 } else {
2032 INI_RA(&ahp->ah_iniAddac, 6, 1) = (INI_RA(&ahp->ah_iniAddac, 2015 INI_RA(&ah->ah_iniAddac, 6, 1) = (INI_RA(&ah->ah_iniAddac,
2033 6, 1) & (~0xc0)) | biaslevel << 6; 2016 6, 1) & (~0xc0)) | biaslevel << 6;
2034 } 2017 }
2035#undef XPA_LVL_FREQ 2018#undef XPA_LVL_FREQ
2036} 2019}
2037 2020
2038static void ath9k_hw_set_4k_addac(struct ath_hal *ah, 2021static void ath9k_hw_set_4k_addac(struct ath_hw *ah,
2039 struct ath9k_channel *chan) 2022 struct ath9k_channel *chan)
2040{ 2023{
2041 struct modal_eep_4k_header *pModal; 2024 struct modal_eep_4k_header *pModal;
2042 struct ath_hal_5416 *ahp = AH5416(ah); 2025 struct ar5416_eeprom_4k *eep = &ah->ah_eeprom.map4k;
2043 struct ar5416_eeprom_4k *eep = &ahp->ah_eeprom.map4k;
2044 u8 biaslevel; 2026 u8 biaslevel;
2045 2027
2046 if (ah->hw_version.macVersion != AR_SREV_VERSION_9160) 2028 if (ah->hw_version.macVersion != AR_SREV_VERSION_9160)
2047 return; 2029 return;
2048 2030
2049 if (ar5416_get_eep_rev(ahp) < AR5416_EEP_MINOR_VER_7) 2031 if (ar5416_get_eep_rev(ah) < AR5416_EEP_MINOR_VER_7)
2050 return; 2032 return;
2051 2033
2052 pModal = &eep->modalHeader; 2034 pModal = &eep->modalHeader;
2053 2035
2054 if (pModal->xpaBiasLvl != 0xff) { 2036 if (pModal->xpaBiasLvl != 0xff) {
2055 biaslevel = pModal->xpaBiasLvl; 2037 biaslevel = pModal->xpaBiasLvl;
2056 INI_RA(&ahp->ah_iniAddac, 7, 1) = 2038 INI_RA(&ah->ah_iniAddac, 7, 1) =
2057 (INI_RA(&ahp->ah_iniAddac, 7, 1) & (~0x18)) | biaslevel << 3; 2039 (INI_RA(&ah->ah_iniAddac, 7, 1) & (~0x18)) | biaslevel << 3;
2058 } 2040 }
2059} 2041}
2060 2042
2061static void (*ath9k_set_addac[]) (struct ath_hal *, struct ath9k_channel *) = { 2043static void (*ath9k_set_addac[]) (struct ath_hw *, struct ath9k_channel *) = {
2062 ath9k_hw_set_def_addac, 2044 ath9k_hw_set_def_addac,
2063 ath9k_hw_set_4k_addac 2045 ath9k_hw_set_4k_addac
2064}; 2046};
2065 2047
2066void ath9k_hw_set_addac(struct ath_hal *ah, struct ath9k_channel *chan) 2048void ath9k_hw_set_addac(struct ath_hw *ah, struct ath9k_channel *chan)
2067{ 2049{
2068 struct ath_hal_5416 *ahp = AH5416(ah); 2050 ath9k_set_addac[ah->ah_eep_map](ah, chan);
2069
2070 ath9k_set_addac[ahp->ah_eep_map](ah, chan);
2071} 2051}
2072 2052
2073
2074
2075/* XXX: Clean me up, make me more legible */ 2053/* XXX: Clean me up, make me more legible */
2076static bool ath9k_hw_eeprom_set_def_board_values(struct ath_hal *ah, 2054static bool ath9k_hw_eeprom_set_def_board_values(struct ath_hw *ah,
2077 struct ath9k_channel *chan) 2055 struct ath9k_channel *chan)
2078{ 2056{
2079#define AR5416_VER_MASK (eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK) 2057#define AR5416_VER_MASK (eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK)
2080 struct modal_eep_header *pModal; 2058 struct modal_eep_header *pModal;
2081 struct ath_hal_5416 *ahp = AH5416(ah); 2059 struct ar5416_eeprom_def *eep = &ah->ah_eeprom.def;
2082 struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def;
2083 int i, regChainOffset; 2060 int i, regChainOffset;
2084 u8 txRxAttenLocal; 2061 u8 txRxAttenLocal;
2085 2062
@@ -2097,7 +2074,7 @@ static bool ath9k_hw_eeprom_set_def_board_values(struct ath_hal *ah,
2097 } 2074 }
2098 2075
2099 if (AR_SREV_5416_V20_OR_LATER(ah) && 2076 if (AR_SREV_5416_V20_OR_LATER(ah) &&
2100 (ahp->ah_rxchainmask == 5 || ahp->ah_txchainmask == 5) 2077 (ah->ah_rxchainmask == 5 || ah->ah_txchainmask == 5)
2101 && (i != 0)) 2078 && (i != 0))
2102 regChainOffset = (i == 1) ? 0x2000 : 0x1000; 2079 regChainOffset = (i == 1) ? 0x2000 : 0x1000;
2103 else 2080 else
@@ -2318,12 +2295,11 @@ static bool ath9k_hw_eeprom_set_def_board_values(struct ath_hal *ah,
2318#undef AR5416_VER_MASK 2295#undef AR5416_VER_MASK
2319} 2296}
2320 2297
2321static bool ath9k_hw_eeprom_set_4k_board_values(struct ath_hal *ah, 2298static bool ath9k_hw_eeprom_set_4k_board_values(struct ath_hw *ah,
2322 struct ath9k_channel *chan) 2299 struct ath9k_channel *chan)
2323{ 2300{
2324 struct modal_eep_4k_header *pModal; 2301 struct modal_eep_4k_header *pModal;
2325 struct ath_hal_5416 *ahp = AH5416(ah); 2302 struct ar5416_eeprom_4k *eep = &ah->ah_eeprom.map4k;
2326 struct ar5416_eeprom_4k *eep = &ahp->ah_eeprom.map4k;
2327 int regChainOffset; 2303 int regChainOffset;
2328 u8 txRxAttenLocal; 2304 u8 txRxAttenLocal;
2329 u8 ob[5], db1[5], db2[5]; 2305 u8 ob[5], db1[5], db2[5];
@@ -2505,66 +2481,59 @@ static bool ath9k_hw_eeprom_set_4k_board_values(struct ath_hal *ah,
2505 return true; 2481 return true;
2506} 2482}
2507 2483
2508static bool (*ath9k_eeprom_set_board_values[])(struct ath_hal *, 2484static bool (*ath9k_eeprom_set_board_values[])(struct ath_hw *,
2509 struct ath9k_channel *) = { 2485 struct ath9k_channel *) = {
2510 ath9k_hw_eeprom_set_def_board_values, 2486 ath9k_hw_eeprom_set_def_board_values,
2511 ath9k_hw_eeprom_set_4k_board_values 2487 ath9k_hw_eeprom_set_4k_board_values
2512}; 2488};
2513 2489
2514bool ath9k_hw_eeprom_set_board_values(struct ath_hal *ah, 2490bool ath9k_hw_eeprom_set_board_values(struct ath_hw *ah,
2515 struct ath9k_channel *chan) 2491 struct ath9k_channel *chan)
2516{ 2492{
2517 struct ath_hal_5416 *ahp = AH5416(ah); 2493 return ath9k_eeprom_set_board_values[ah->ah_eep_map](ah, chan);
2518
2519 return ath9k_eeprom_set_board_values[ahp->ah_eep_map](ah, chan);
2520} 2494}
2521 2495
2522static u16 ath9k_hw_get_def_eeprom_antenna_cfg(struct ath_hal *ah, 2496static u16 ath9k_hw_get_def_eeprom_antenna_cfg(struct ath_hw *ah,
2523 struct ath9k_channel *chan) 2497 struct ath9k_channel *chan)
2524{ 2498{
2525 struct ath_hal_5416 *ahp = AH5416(ah); 2499 struct ar5416_eeprom_def *eep = &ah->ah_eeprom.def;
2526 struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def;
2527 struct modal_eep_header *pModal = 2500 struct modal_eep_header *pModal =
2528 &(eep->modalHeader[IS_CHAN_2GHZ(chan)]); 2501 &(eep->modalHeader[IS_CHAN_2GHZ(chan)]);
2529 2502
2530 return pModal->antCtrlCommon & 0xFFFF; 2503 return pModal->antCtrlCommon & 0xFFFF;
2531} 2504}
2532 2505
2533static u16 ath9k_hw_get_4k_eeprom_antenna_cfg(struct ath_hal *ah, 2506static u16 ath9k_hw_get_4k_eeprom_antenna_cfg(struct ath_hw *ah,
2534 struct ath9k_channel *chan) 2507 struct ath9k_channel *chan)
2535{ 2508{
2536 struct ath_hal_5416 *ahp = AH5416(ah); 2509 struct ar5416_eeprom_4k *eep = &ah->ah_eeprom.map4k;
2537 struct ar5416_eeprom_4k *eep = &ahp->ah_eeprom.map4k;
2538 struct modal_eep_4k_header *pModal = &eep->modalHeader; 2510 struct modal_eep_4k_header *pModal = &eep->modalHeader;
2539 2511
2540 return pModal->antCtrlCommon & 0xFFFF; 2512 return pModal->antCtrlCommon & 0xFFFF;
2541} 2513}
2542 2514
2543static u16 (*ath9k_get_eeprom_antenna_cfg[])(struct ath_hal *, 2515static u16 (*ath9k_get_eeprom_antenna_cfg[])(struct ath_hw *,
2544 struct ath9k_channel *) = { 2516 struct ath9k_channel *) = {
2545 ath9k_hw_get_def_eeprom_antenna_cfg, 2517 ath9k_hw_get_def_eeprom_antenna_cfg,
2546 ath9k_hw_get_4k_eeprom_antenna_cfg 2518 ath9k_hw_get_4k_eeprom_antenna_cfg
2547}; 2519};
2548 2520
2549u16 ath9k_hw_get_eeprom_antenna_cfg(struct ath_hal *ah, 2521u16 ath9k_hw_get_eeprom_antenna_cfg(struct ath_hw *ah,
2550 struct ath9k_channel *chan) 2522 struct ath9k_channel *chan)
2551{ 2523{
2552 struct ath_hal_5416 *ahp = AH5416(ah); 2524 return ath9k_get_eeprom_antenna_cfg[ah->ah_eep_map](ah, chan);
2553
2554 return ath9k_get_eeprom_antenna_cfg[ahp->ah_eep_map](ah, chan);
2555} 2525}
2556 2526
2557static u8 ath9k_hw_get_4k_num_ant_config(struct ath_hal *ah, 2527static u8 ath9k_hw_get_4k_num_ant_config(struct ath_hw *ah,
2558 enum ieee80211_band freq_band) 2528 enum ieee80211_band freq_band)
2559{ 2529{
2560 return 1; 2530 return 1;
2561} 2531}
2562 2532
2563static u8 ath9k_hw_get_def_num_ant_config(struct ath_hal *ah, 2533static u8 ath9k_hw_get_def_num_ant_config(struct ath_hw *ah,
2564 enum ieee80211_band freq_band) 2534 enum ieee80211_band freq_band)
2565{ 2535{
2566 struct ath_hal_5416 *ahp = AH5416(ah); 2536 struct ar5416_eeprom_def *eep = &ah->ah_eeprom.def;
2567 struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def;
2568 struct modal_eep_header *pModal = 2537 struct modal_eep_header *pModal =
2569 &(eep->modalHeader[ATH9K_HAL_FREQ_BAND_2GHZ == freq_band]); 2538 &(eep->modalHeader[ATH9K_HAL_FREQ_BAND_2GHZ == freq_band]);
2570 struct base_eep_header *pBase = &eep->baseEepHeader; 2539 struct base_eep_header *pBase = &eep->baseEepHeader;
@@ -2579,27 +2548,24 @@ static u8 ath9k_hw_get_def_num_ant_config(struct ath_hal *ah,
2579 return num_ant_config; 2548 return num_ant_config;
2580} 2549}
2581 2550
2582static u8 (*ath9k_get_num_ant_config[])(struct ath_hal *, 2551static u8 (*ath9k_get_num_ant_config[])(struct ath_hw *,
2583 enum ieee80211_band) = { 2552 enum ieee80211_band) = {
2584 ath9k_hw_get_def_num_ant_config, 2553 ath9k_hw_get_def_num_ant_config,
2585 ath9k_hw_get_4k_num_ant_config 2554 ath9k_hw_get_4k_num_ant_config
2586}; 2555};
2587 2556
2588u8 ath9k_hw_get_num_ant_config(struct ath_hal *ah, 2557u8 ath9k_hw_get_num_ant_config(struct ath_hw *ah,
2589 enum ieee80211_band freq_band) 2558 enum ieee80211_band freq_band)
2590{ 2559{
2591 struct ath_hal_5416 *ahp = AH5416(ah); 2560 return ath9k_get_num_ant_config[ah->ah_eep_map](ah, freq_band);
2592
2593 return ath9k_get_num_ant_config[ahp->ah_eep_map](ah, freq_band);
2594} 2561}
2595 2562
2596u16 ath9k_hw_eeprom_get_spur_chan(struct ath_hal *ah, u16 i, bool is2GHz) 2563u16 ath9k_hw_eeprom_get_spur_chan(struct ath_hw *ah, u16 i, bool is2GHz)
2597{ 2564{
2598#define EEP_MAP4K_SPURCHAN \ 2565#define EEP_MAP4K_SPURCHAN \
2599 (ahp->ah_eeprom.map4k.modalHeader.spurChans[i].spurChan) 2566 (ah->ah_eeprom.map4k.modalHeader.spurChans[i].spurChan)
2600#define EEP_DEF_SPURCHAN \ 2567#define EEP_DEF_SPURCHAN \
2601 (ahp->ah_eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan) 2568 (ah->ah_eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan)
2602 struct ath_hal_5416 *ahp = AH5416(ah);
2603 u16 spur_val = AR_NO_SPUR; 2569 u16 spur_val = AR_NO_SPUR;
2604 2570
2605 DPRINTF(ah->ah_sc, ATH_DBG_ANI, 2571 DPRINTF(ah->ah_sc, ATH_DBG_ANI,
@@ -2615,7 +2581,7 @@ u16 ath9k_hw_eeprom_get_spur_chan(struct ath_hal *ah, u16 i, bool is2GHz)
2615 "Getting spur val from new loc. %d\n", spur_val); 2581 "Getting spur val from new loc. %d\n", spur_val);
2616 break; 2582 break;
2617 case SPUR_ENABLE_EEPROM: 2583 case SPUR_ENABLE_EEPROM:
2618 if (ahp->ah_eep_map == EEP_MAP_4KBITS) 2584 if (ah->ah_eep_map == EEP_MAP_4KBITS)
2619 spur_val = EEP_MAP4K_SPURCHAN; 2585 spur_val = EEP_MAP4K_SPURCHAN;
2620 else 2586 else
2621 spur_val = EEP_DEF_SPURCHAN; 2587 spur_val = EEP_DEF_SPURCHAN;
@@ -2628,11 +2594,10 @@ u16 ath9k_hw_eeprom_get_spur_chan(struct ath_hal *ah, u16 i, bool is2GHz)
2628#undef EEP_MAP4K_SPURCHAN 2594#undef EEP_MAP4K_SPURCHAN
2629} 2595}
2630 2596
2631static u32 ath9k_hw_get_eeprom_4k(struct ath_hal *ah, 2597static u32 ath9k_hw_get_eeprom_4k(struct ath_hw *ah,
2632 enum eeprom_param param) 2598 enum eeprom_param param)
2633{ 2599{
2634 struct ath_hal_5416 *ahp = AH5416(ah); 2600 struct ar5416_eeprom_4k *eep = &ah->ah_eeprom.map4k;
2635 struct ar5416_eeprom_4k *eep = &ahp->ah_eeprom.map4k;
2636 struct modal_eep_4k_header *pModal = &eep->modalHeader; 2601 struct modal_eep_4k_header *pModal = &eep->modalHeader;
2637 struct base_eep_header_4k *pBase = &eep->baseEepHeader; 2602 struct base_eep_header_4k *pBase = &eep->baseEepHeader;
2638 2603
@@ -2670,12 +2635,11 @@ static u32 ath9k_hw_get_eeprom_4k(struct ath_hal *ah,
2670 } 2635 }
2671} 2636}
2672 2637
2673static u32 ath9k_hw_get_eeprom_def(struct ath_hal *ah, 2638static u32 ath9k_hw_get_eeprom_def(struct ath_hw *ah,
2674 enum eeprom_param param) 2639 enum eeprom_param param)
2675{ 2640{
2676#define AR5416_VER_MASK (pBase->version & AR5416_EEP_VER_MINOR_MASK) 2641#define AR5416_VER_MASK (pBase->version & AR5416_EEP_VER_MINOR_MASK)
2677 struct ath_hal_5416 *ahp = AH5416(ah); 2642 struct ar5416_eeprom_def *eep = &ah->ah_eeprom.def;
2678 struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def;
2679 struct modal_eep_header *pModal = eep->modalHeader; 2643 struct modal_eep_header *pModal = eep->modalHeader;
2680 struct base_eep_header *pBase = &eep->baseEepHeader; 2644 struct base_eep_header *pBase = &eep->baseEepHeader;
2681 2645
@@ -2729,28 +2693,25 @@ static u32 ath9k_hw_get_eeprom_def(struct ath_hal *ah,
2729#undef AR5416_VER_MASK 2693#undef AR5416_VER_MASK
2730} 2694}
2731 2695
2732static u32 (*ath9k_get_eeprom[])(struct ath_hal *, enum eeprom_param) = { 2696static u32 (*ath9k_get_eeprom[])(struct ath_hw *, enum eeprom_param) = {
2733 ath9k_hw_get_eeprom_def, 2697 ath9k_hw_get_eeprom_def,
2734 ath9k_hw_get_eeprom_4k 2698 ath9k_hw_get_eeprom_4k
2735}; 2699};
2736 2700
2737u32 ath9k_hw_get_eeprom(struct ath_hal *ah, 2701u32 ath9k_hw_get_eeprom(struct ath_hw *ah,
2738 enum eeprom_param param) 2702 enum eeprom_param param)
2739{ 2703{
2740 struct ath_hal_5416 *ahp = AH5416(ah); 2704 return ath9k_get_eeprom[ah->ah_eep_map](ah, param);
2741
2742 return ath9k_get_eeprom[ahp->ah_eep_map](ah, param);
2743} 2705}
2744 2706
2745int ath9k_hw_eeprom_attach(struct ath_hal *ah) 2707int ath9k_hw_eeprom_attach(struct ath_hw *ah)
2746{ 2708{
2747 int status; 2709 int status;
2748 struct ath_hal_5416 *ahp = AH5416(ah);
2749 2710
2750 if (AR_SREV_9285(ah)) 2711 if (AR_SREV_9285(ah))
2751 ahp->ah_eep_map = EEP_MAP_4KBITS; 2712 ah->ah_eep_map = EEP_MAP_4KBITS;
2752 else 2713 else
2753 ahp->ah_eep_map = EEP_MAP_DEFAULT; 2714 ah->ah_eep_map = EEP_MAP_DEFAULT;
2754 2715
2755 if (!ath9k_hw_fill_eeprom(ah)) 2716 if (!ath9k_hw_fill_eeprom(ah))
2756 return -EIO; 2717 return -EIO;