diff options
author | Vasanthakumar Thiagarajan <vasanth@atheros.com> | 2009-01-23 04:10:37 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 16:01:25 -0500 |
commit | 81b1e19ac2cadc2f8a05c82ffb1abe20a0594d1f (patch) | |
tree | 43fe4aa271db7d171dcf3f1afc0de2875651a5bd /drivers/net/wireless/ath9k | |
parent | 3aa24e6031a0ca7a8803a103f5c183cd94e5ac98 (diff) |
ath9k: Clean up the way the eeprom antenna configuration is read
Signed-off-by: Vasanthakumar Thiagarajan <vasanth@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/ath9k')
-rw-r--r-- | drivers/net/wireless/ath9k/ath9k.h | 5 | ||||
-rw-r--r-- | drivers/net/wireless/ath9k/eeprom.c | 63 |
2 files changed, 17 insertions, 51 deletions
diff --git a/drivers/net/wireless/ath9k/ath9k.h b/drivers/net/wireless/ath9k/ath9k.h index 455a53649b32..5289d2878111 100644 --- a/drivers/net/wireless/ath9k/ath9k.h +++ b/drivers/net/wireless/ath9k/ath9k.h | |||
@@ -974,9 +974,8 @@ bool ath9k_hw_set_power_cal_table(struct ath_hal *ah, | |||
974 | int16_t *pTxPowerIndexOffset); | 974 | int16_t *pTxPowerIndexOffset); |
975 | bool ath9k_hw_eeprom_set_board_values(struct ath_hal *ah, | 975 | bool ath9k_hw_eeprom_set_board_values(struct ath_hal *ah, |
976 | struct ath9k_channel *chan); | 976 | struct ath9k_channel *chan); |
977 | int ath9k_hw_get_eeprom_antenna_cfg(struct ath_hal *ah, | 977 | u16 ath9k_hw_get_eeprom_antenna_cfg(struct ath_hal *ah, |
978 | struct ath9k_channel *chan, | 978 | struct ath9k_channel *chan); |
979 | u8 index, u16 *config); | ||
980 | u8 ath9k_hw_get_num_ant_config(struct ath_hal *ah, | 979 | u8 ath9k_hw_get_num_ant_config(struct ath_hal *ah, |
981 | enum ieee80211_band freq_band); | 980 | enum ieee80211_band freq_band); |
982 | u16 ath9k_hw_eeprom_get_spur_chan(struct ath_hal *ah, u16 i, bool is2GHz); | 981 | u16 ath9k_hw_eeprom_get_spur_chan(struct ath_hal *ah, u16 i, bool is2GHz); |
diff --git a/drivers/net/wireless/ath9k/eeprom.c b/drivers/net/wireless/ath9k/eeprom.c index 50cb3883416a..5038907e7432 100644 --- a/drivers/net/wireless/ath9k/eeprom.c +++ b/drivers/net/wireless/ath9k/eeprom.c | |||
@@ -2085,14 +2085,13 @@ static bool ath9k_hw_eeprom_set_def_board_values(struct ath_hal *ah, | |||
2085 | struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def; | 2085 | struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def; |
2086 | int i, regChainOffset; | 2086 | int i, regChainOffset; |
2087 | u8 txRxAttenLocal; | 2087 | u8 txRxAttenLocal; |
2088 | u16 ant_config; | ||
2089 | 2088 | ||
2090 | pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]); | 2089 | pModal = &(eep->modalHeader[IS_CHAN_2GHZ(chan)]); |
2091 | 2090 | ||
2092 | txRxAttenLocal = IS_CHAN_2GHZ(chan) ? 23 : 44; | 2091 | txRxAttenLocal = IS_CHAN_2GHZ(chan) ? 23 : 44; |
2093 | 2092 | ||
2094 | ath9k_hw_get_eeprom_antenna_cfg(ah, chan, 0, &ant_config); | 2093 | REG_WRITE(ah, AR_PHY_SWITCH_COM, |
2095 | REG_WRITE(ah, AR_PHY_SWITCH_COM, ant_config); | 2094 | ath9k_hw_get_eeprom_antenna_cfg(ah, chan)); |
2096 | 2095 | ||
2097 | for (i = 0; i < AR5416_MAX_CHAINS; i++) { | 2096 | for (i = 0; i < AR5416_MAX_CHAINS; i++) { |
2098 | if (AR_SREV_9280(ah)) { | 2097 | if (AR_SREV_9280(ah)) { |
@@ -2330,7 +2329,6 @@ static bool ath9k_hw_eeprom_set_4k_board_values(struct ath_hal *ah, | |||
2330 | struct ar5416_eeprom_4k *eep = &ahp->ah_eeprom.map4k; | 2329 | struct ar5416_eeprom_4k *eep = &ahp->ah_eeprom.map4k; |
2331 | int regChainOffset; | 2330 | int regChainOffset; |
2332 | u8 txRxAttenLocal; | 2331 | u8 txRxAttenLocal; |
2333 | u16 ant_config = 0; | ||
2334 | u8 ob[5], db1[5], db2[5]; | 2332 | u8 ob[5], db1[5], db2[5]; |
2335 | u8 ant_div_control1, ant_div_control2; | 2333 | u8 ant_div_control1, ant_div_control2; |
2336 | u32 regVal; | 2334 | u32 regVal; |
@@ -2340,8 +2338,8 @@ static bool ath9k_hw_eeprom_set_4k_board_values(struct ath_hal *ah, | |||
2340 | 2338 | ||
2341 | txRxAttenLocal = 23; | 2339 | txRxAttenLocal = 23; |
2342 | 2340 | ||
2343 | ath9k_hw_get_eeprom_antenna_cfg(ah, chan, 0, &ant_config); | 2341 | REG_WRITE(ah, AR_PHY_SWITCH_COM, |
2344 | REG_WRITE(ah, AR_PHY_SWITCH_COM, ant_config); | 2342 | ath9k_hw_get_eeprom_antenna_cfg(ah, chan)); |
2345 | 2343 | ||
2346 | regChainOffset = 0; | 2344 | regChainOffset = 0; |
2347 | REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset, | 2345 | REG_WRITE(ah, AR_PHY_SWITCH_CHAIN_0 + regChainOffset, |
@@ -2524,70 +2522,39 @@ bool ath9k_hw_eeprom_set_board_values(struct ath_hal *ah, | |||
2524 | return ath9k_eeprom_set_board_values[ahp->ah_eep_map](ah, chan); | 2522 | return ath9k_eeprom_set_board_values[ahp->ah_eep_map](ah, chan); |
2525 | } | 2523 | } |
2526 | 2524 | ||
2527 | static int ath9k_hw_get_def_eeprom_antenna_cfg(struct ath_hal *ah, | 2525 | static u16 ath9k_hw_get_def_eeprom_antenna_cfg(struct ath_hal *ah, |
2528 | struct ath9k_channel *chan, | 2526 | struct ath9k_channel *chan) |
2529 | u8 index, u16 *config) | ||
2530 | { | 2527 | { |
2531 | struct ath_hal_5416 *ahp = AH5416(ah); | 2528 | struct ath_hal_5416 *ahp = AH5416(ah); |
2532 | struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def; | 2529 | struct ar5416_eeprom_def *eep = &ahp->ah_eeprom.def; |
2533 | struct modal_eep_header *pModal = | 2530 | struct modal_eep_header *pModal = |
2534 | &(eep->modalHeader[IS_CHAN_2GHZ(chan)]); | 2531 | &(eep->modalHeader[IS_CHAN_2GHZ(chan)]); |
2535 | struct base_eep_header *pBase = &eep->baseEepHeader; | ||
2536 | 2532 | ||
2537 | switch (index) { | 2533 | return pModal->antCtrlCommon & 0xFFFF; |
2538 | case 0: | ||
2539 | *config = pModal->antCtrlCommon & 0xFFFF; | ||
2540 | return 0; | ||
2541 | case 1: | ||
2542 | if (pBase->version >= 0x0E0D) { | ||
2543 | if (pModal->useAnt1) { | ||
2544 | *config = | ||
2545 | ((pModal->antCtrlCommon & 0xFFFF0000) >> 16); | ||
2546 | return 0; | ||
2547 | } | ||
2548 | } | ||
2549 | break; | ||
2550 | default: | ||
2551 | break; | ||
2552 | } | ||
2553 | |||
2554 | return -EINVAL; | ||
2555 | } | 2534 | } |
2556 | 2535 | ||
2557 | static int ath9k_hw_get_4k_eeprom_antenna_cfg(struct ath_hal *ah, | 2536 | static u16 ath9k_hw_get_4k_eeprom_antenna_cfg(struct ath_hal *ah, |
2558 | struct ath9k_channel *chan, | 2537 | struct ath9k_channel *chan) |
2559 | u8 index, u16 *config) | ||
2560 | { | 2538 | { |
2561 | struct ath_hal_5416 *ahp = AH5416(ah); | 2539 | struct ath_hal_5416 *ahp = AH5416(ah); |
2562 | struct ar5416_eeprom_4k *eep = &ahp->ah_eeprom.map4k; | 2540 | struct ar5416_eeprom_4k *eep = &ahp->ah_eeprom.map4k; |
2563 | struct modal_eep_4k_header *pModal = &eep->modalHeader; | 2541 | struct modal_eep_4k_header *pModal = &eep->modalHeader; |
2564 | 2542 | ||
2565 | switch (index) { | 2543 | return pModal->antCtrlCommon & 0xFFFF; |
2566 | case 0: | ||
2567 | *config = pModal->antCtrlCommon & 0xFFFF; | ||
2568 | return 0; | ||
2569 | default: | ||
2570 | break; | ||
2571 | } | ||
2572 | |||
2573 | return -EINVAL; | ||
2574 | } | 2544 | } |
2575 | 2545 | ||
2576 | static int (*ath9k_get_eeprom_antenna_cfg[])(struct ath_hal *, | 2546 | static u16 (*ath9k_get_eeprom_antenna_cfg[])(struct ath_hal *, |
2577 | struct ath9k_channel *, | 2547 | struct ath9k_channel *) = { |
2578 | u8, u16 *) = { | ||
2579 | ath9k_hw_get_def_eeprom_antenna_cfg, | 2548 | ath9k_hw_get_def_eeprom_antenna_cfg, |
2580 | ath9k_hw_get_4k_eeprom_antenna_cfg | 2549 | ath9k_hw_get_4k_eeprom_antenna_cfg |
2581 | }; | 2550 | }; |
2582 | 2551 | ||
2583 | int ath9k_hw_get_eeprom_antenna_cfg(struct ath_hal *ah, | 2552 | u16 ath9k_hw_get_eeprom_antenna_cfg(struct ath_hal *ah, |
2584 | struct ath9k_channel *chan, | 2553 | struct ath9k_channel *chan) |
2585 | u8 index, u16 *config) | ||
2586 | { | 2554 | { |
2587 | struct ath_hal_5416 *ahp = AH5416(ah); | 2555 | struct ath_hal_5416 *ahp = AH5416(ah); |
2588 | 2556 | ||
2589 | return ath9k_get_eeprom_antenna_cfg[ahp->ah_eep_map](ah, chan, | 2557 | return ath9k_get_eeprom_antenna_cfg[ahp->ah_eep_map](ah, chan); |
2590 | index, config); | ||
2591 | } | 2558 | } |
2592 | 2559 | ||
2593 | static u8 ath9k_hw_get_4k_num_ant_config(struct ath_hal *ah, | 2560 | static u8 ath9k_hw_get_4k_num_ant_config(struct ath_hal *ah, |