Deleted Added
full compact
ar5416_reset.c (203882) ar5416_reset.c (203930)
1/*
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 2002-2008 Atheros Communications, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 *
1/*
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 2002-2008 Atheros Communications, Inc.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 *
17 * $FreeBSD: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c 203882 2010-02-14 16:26:32Z rpaulo $
17 * $FreeBSD: head/sys/dev/ath/ath_hal/ar5416/ar5416_reset.c 203930 2010-02-15 17:49:49Z rpaulo $
18 */
19#include "opt_ah.h"
20
21#include "ah.h"
22#include "ah_internal.h"
23#include "ah_devid.h"
24
25#include "ah_eeprom_v14.h"

--- 14 unchanged lines hidden (view full) ---

40#define RTC_PLL_SETTLE_DELAY 1000 /* 1 ms */
41
42static void ar5416InitDMA(struct ath_hal *ah);
43static void ar5416InitBB(struct ath_hal *ah, const struct ieee80211_channel *);
44static void ar5416InitIMR(struct ath_hal *ah, HAL_OPMODE opmode);
45static void ar5416InitQoS(struct ath_hal *ah);
46static void ar5416InitUserSettings(struct ath_hal *ah);
47
18 */
19#include "opt_ah.h"
20
21#include "ah.h"
22#include "ah_internal.h"
23#include "ah_devid.h"
24
25#include "ah_eeprom_v14.h"

--- 14 unchanged lines hidden (view full) ---

40#define RTC_PLL_SETTLE_DELAY 1000 /* 1 ms */
41
42static void ar5416InitDMA(struct ath_hal *ah);
43static void ar5416InitBB(struct ath_hal *ah, const struct ieee80211_channel *);
44static void ar5416InitIMR(struct ath_hal *ah, HAL_OPMODE opmode);
45static void ar5416InitQoS(struct ath_hal *ah);
46static void ar5416InitUserSettings(struct ath_hal *ah);
47
48static HAL_BOOL ar5416SetTransmitPower(struct ath_hal *ah,
49 const struct ieee80211_channel *chan, uint16_t *rfXpdGain);
50
51#if 0
52static HAL_BOOL ar5416ChannelChange(struct ath_hal *, const struct ieee80211_channel *);
53#endif
54static void ar5416SetDeltaSlope(struct ath_hal *, const struct ieee80211_channel *);
55
56static HAL_BOOL ar5416SetResetPowerOn(struct ath_hal *ah);
57static HAL_BOOL ar5416SetReset(struct ath_hal *ah, int type);
58static void ar5416InitPLL(struct ath_hal *ah, const struct ieee80211_channel *chan);
48#if 0
49static HAL_BOOL ar5416ChannelChange(struct ath_hal *, const struct ieee80211_channel *);
50#endif
51static void ar5416SetDeltaSlope(struct ath_hal *, const struct ieee80211_channel *);
52
53static HAL_BOOL ar5416SetResetPowerOn(struct ath_hal *ah);
54static HAL_BOOL ar5416SetReset(struct ath_hal *ah, int type);
55static void ar5416InitPLL(struct ath_hal *ah, const struct ieee80211_channel *chan);
59static HAL_BOOL ar5416SetBoardValues(struct ath_hal *, const struct ieee80211_channel *);
60static HAL_BOOL ar5416SetPowerPerRateTable(struct ath_hal *ah,
61 struct ar5416eeprom *pEepData,
62 const struct ieee80211_channel *chan, int16_t *ratesArray,
63 uint16_t cfgCtl, uint16_t AntennaReduction,
64 uint16_t twiceMaxRegulatoryPower,
65 uint16_t powerLimit);
66static HAL_BOOL ar5416SetPowerCalTable(struct ath_hal *ah,
67 struct ar5416eeprom *pEepData,
68 const struct ieee80211_channel *chan,
69 int16_t *pTxPowerIndexOffset);
70static uint16_t ar5416GetMaxEdgePower(uint16_t freq,
71 CAL_CTL_EDGES *pRdEdgesPower, HAL_BOOL is2GHz);
56static HAL_BOOL ar5416SetPowerPerRateTable(struct ath_hal *ah,
57 struct ar5416eeprom *pEepData,
58 const struct ieee80211_channel *chan, int16_t *ratesArray,
59 uint16_t cfgCtl, uint16_t AntennaReduction,
60 uint16_t twiceMaxRegulatoryPower,
61 uint16_t powerLimit);
62static HAL_BOOL ar5416SetPowerCalTable(struct ath_hal *ah,
63 struct ar5416eeprom *pEepData,
64 const struct ieee80211_channel *chan,
65 int16_t *pTxPowerIndexOffset);
66static uint16_t ar5416GetMaxEdgePower(uint16_t freq,
67 CAL_CTL_EDGES *pRdEdgesPower, HAL_BOOL is2GHz);
72static void ar5416GetTargetPowers(struct ath_hal *ah,
73 const struct ieee80211_channel *chan, CAL_TARGET_POWER_HT *powInfo,
74 uint16_t numChannels, CAL_TARGET_POWER_HT *pNewPower,
75 uint16_t numRates, HAL_BOOL isHt40Target);
76static void ar5416GetTargetPowersLeg(struct ath_hal *ah,
77 const struct ieee80211_channel *chan, CAL_TARGET_POWER_LEG *powInfo,
78 uint16_t numChannels, CAL_TARGET_POWER_LEG *pNewPower,
79 uint16_t numRates, HAL_BOOL isExtTarget);
80
81static int16_t interpolate(uint16_t target, uint16_t srcLeft,
82 uint16_t srcRight, int16_t targetLeft, int16_t targetRight);
83static void ar5416Set11nRegs(struct ath_hal *ah, const struct ieee80211_channel *chan);
84static void ar5416GetGainBoundariesAndPdadcs(struct ath_hal *ah,
85 const struct ieee80211_channel *chan, CAL_DATA_PER_FREQ *pRawDataSet,
86 uint8_t * bChans, uint16_t availPiers,
87 uint16_t tPdGainOverlap, int16_t *pMinCalPower,

--- 131 unchanged lines hidden (view full) ---

219 AH5416(ah)->ah_tx_chainmask == 0x5)
220 OS_REG_WRITE(ah, AR_PHY_ANALOG_SWAP, AR_PHY_SWAP_ALT_CHAIN);
221 /* Setup Chain Masks */
222 OS_REG_WRITE(ah, AR_PHY_RX_CHAINMASK, AH5416(ah)->ah_rx_chainmask);
223 OS_REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, AH5416(ah)->ah_rx_chainmask);
224 OS_REG_WRITE(ah, AR_SELFGEN_MASK, AH5416(ah)->ah_tx_chainmask);
225
226 /* Setup the transmit power values. */
68
69static int16_t interpolate(uint16_t target, uint16_t srcLeft,
70 uint16_t srcRight, int16_t targetLeft, int16_t targetRight);
71static void ar5416Set11nRegs(struct ath_hal *ah, const struct ieee80211_channel *chan);
72static void ar5416GetGainBoundariesAndPdadcs(struct ath_hal *ah,
73 const struct ieee80211_channel *chan, CAL_DATA_PER_FREQ *pRawDataSet,
74 uint8_t * bChans, uint16_t availPiers,
75 uint16_t tPdGainOverlap, int16_t *pMinCalPower,

--- 131 unchanged lines hidden (view full) ---

207 AH5416(ah)->ah_tx_chainmask == 0x5)
208 OS_REG_WRITE(ah, AR_PHY_ANALOG_SWAP, AR_PHY_SWAP_ALT_CHAIN);
209 /* Setup Chain Masks */
210 OS_REG_WRITE(ah, AR_PHY_RX_CHAINMASK, AH5416(ah)->ah_rx_chainmask);
211 OS_REG_WRITE(ah, AR_PHY_CAL_CHAINMASK, AH5416(ah)->ah_rx_chainmask);
212 OS_REG_WRITE(ah, AR_SELFGEN_MASK, AH5416(ah)->ah_tx_chainmask);
213
214 /* Setup the transmit power values. */
227 if (!ar5416SetTransmitPower(ah, chan, rfXpdGain)) {
215 if (!ah->ah_setTxPower(ah, chan, rfXpdGain)) {
228 HALDEBUG(ah, HAL_DEBUG_ANY,
229 "%s: error init'ing transmit power\n", __func__);
230 FAIL(HAL_EIO);
231 }
232
233 /* Write the analog registers */
234 if (!ahp->ah_rfHal->setRfRegs(ah, chan,
235 IEEE80211_IS_CHAN_2GHZ(chan) ? 2: 1, rfXpdGain)) {

--- 4 unchanged lines hidden (view full) ---

240
241 /* Write delta slope for OFDM enabled modes (A, G, Turbo) */
242 if (IEEE80211_IS_CHAN_OFDM(chan)|| IEEE80211_IS_CHAN_HT(chan))
243 ar5416SetDeltaSlope(ah, chan);
244
245 AH5416(ah)->ah_spurMitigate(ah, chan);
246
247 /* Setup board specific options for EEPROM version 3 */
216 HALDEBUG(ah, HAL_DEBUG_ANY,
217 "%s: error init'ing transmit power\n", __func__);
218 FAIL(HAL_EIO);
219 }
220
221 /* Write the analog registers */
222 if (!ahp->ah_rfHal->setRfRegs(ah, chan,
223 IEEE80211_IS_CHAN_2GHZ(chan) ? 2: 1, rfXpdGain)) {

--- 4 unchanged lines hidden (view full) ---

228
229 /* Write delta slope for OFDM enabled modes (A, G, Turbo) */
230 if (IEEE80211_IS_CHAN_OFDM(chan)|| IEEE80211_IS_CHAN_HT(chan))
231 ar5416SetDeltaSlope(ah, chan);
232
233 AH5416(ah)->ah_spurMitigate(ah, chan);
234
235 /* Setup board specific options for EEPROM version 3 */
248 if (!ar5416SetBoardValues(ah, chan)) {
236 if (!ah->ah_setBoardValues(ah, chan)) {
249 HALDEBUG(ah, HAL_DEBUG_ANY,
250 "%s: error setting board options\n", __func__);
251 FAIL(HAL_EIO);
252 }
253
254 OS_MARK(ah, AH_MARK_RESET_LINE, __LINE__);
255
256 OS_REG_WRITE(ah, AR_STA_ID0, LE_READ_4(ahp->ah_macaddr));

--- 531 unchanged lines hidden (view full) ---

788} AR5416_RATES;
789
790/**************************************************************
791 * ar5416SetTransmitPower
792 *
793 * Set the transmit power in the baseband for the given
794 * operating channel and mode.
795 */
237 HALDEBUG(ah, HAL_DEBUG_ANY,
238 "%s: error setting board options\n", __func__);
239 FAIL(HAL_EIO);
240 }
241
242 OS_MARK(ah, AH_MARK_RESET_LINE, __LINE__);
243
244 OS_REG_WRITE(ah, AR_STA_ID0, LE_READ_4(ahp->ah_macaddr));

--- 531 unchanged lines hidden (view full) ---

776} AR5416_RATES;
777
778/**************************************************************
779 * ar5416SetTransmitPower
780 *
781 * Set the transmit power in the baseband for the given
782 * operating channel and mode.
783 */
796static HAL_BOOL
784HAL_BOOL
797ar5416SetTransmitPower(struct ath_hal *ah,
798 const struct ieee80211_channel *chan, uint16_t *rfXpdGain)
799{
800#define POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
801#define N(a) (sizeof (a) / sizeof (a[0]))
802
803 MODAL_EEP_HEADER *pModal;
804 struct ath_hal_5212 *ahp = AH5212(ah);

--- 375 unchanged lines hidden (view full) ---

1180
1181 OS_REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_SLEEP_DERIVED_CLK);
1182}
1183
1184/*
1185 * Read EEPROM header info and program the device for correct operation
1186 * given the channel value.
1187 */
785ar5416SetTransmitPower(struct ath_hal *ah,
786 const struct ieee80211_channel *chan, uint16_t *rfXpdGain)
787{
788#define POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
789#define N(a) (sizeof (a) / sizeof (a[0]))
790
791 MODAL_EEP_HEADER *pModal;
792 struct ath_hal_5212 *ahp = AH5212(ah);

--- 375 unchanged lines hidden (view full) ---

1168
1169 OS_REG_WRITE(ah, AR_RTC_SLEEP_CLK, AR_RTC_SLEEP_DERIVED_CLK);
1170}
1171
1172/*
1173 * Read EEPROM header info and program the device for correct operation
1174 * given the channel value.
1175 */
1188static HAL_BOOL
1176HAL_BOOL
1189ar5416SetBoardValues(struct ath_hal *ah, const struct ieee80211_channel *chan)
1190{
1191 const HAL_EEPROM_v14 *ee = AH_PRIVATE(ah)->ah_eeprom;
1192 const struct ar5416eeprom *eep = &ee->ee_base;
1193 const MODAL_EEP_HEADER *pModal;
1194 int i, regChainOffset;
1195 uint8_t txRxAttenLocal; /* workaround for eeprom versions <= 14.2 */
1196

--- 420 unchanged lines hidden (view full) ---

1617}
1618
1619/**************************************************************
1620 * ar5416GetTargetPowers
1621 *
1622 * Return the rates of target power for the given target power table
1623 * channel, and number of channels
1624 */
1177ar5416SetBoardValues(struct ath_hal *ah, const struct ieee80211_channel *chan)
1178{
1179 const HAL_EEPROM_v14 *ee = AH_PRIVATE(ah)->ah_eeprom;
1180 const struct ar5416eeprom *eep = &ee->ee_base;
1181 const MODAL_EEP_HEADER *pModal;
1182 int i, regChainOffset;
1183 uint8_t txRxAttenLocal; /* workaround for eeprom versions <= 14.2 */
1184

--- 420 unchanged lines hidden (view full) ---

1605}
1606
1607/**************************************************************
1608 * ar5416GetTargetPowers
1609 *
1610 * Return the rates of target power for the given target power table
1611 * channel, and number of channels
1612 */
1625static void
1613void
1626ar5416GetTargetPowers(struct ath_hal *ah, const struct ieee80211_channel *chan,
1627 CAL_TARGET_POWER_HT *powInfo, uint16_t numChannels,
1628 CAL_TARGET_POWER_HT *pNewPower, uint16_t numRates,
1629 HAL_BOOL isHt40Target)
1630{
1631 uint16_t clo, chi;
1632 int i;
1633 int matchIndex = -1, lowIndex = -1;

--- 42 unchanged lines hidden (view full) ---

1676 }
1677}
1678/**************************************************************
1679 * ar5416GetTargetPowersLeg
1680 *
1681 * Return the four rates of target power for the given target power table
1682 * channel, and number of channels
1683 */
1614ar5416GetTargetPowers(struct ath_hal *ah, const struct ieee80211_channel *chan,
1615 CAL_TARGET_POWER_HT *powInfo, uint16_t numChannels,
1616 CAL_TARGET_POWER_HT *pNewPower, uint16_t numRates,
1617 HAL_BOOL isHt40Target)
1618{
1619 uint16_t clo, chi;
1620 int i;
1621 int matchIndex = -1, lowIndex = -1;

--- 42 unchanged lines hidden (view full) ---

1664 }
1665}
1666/**************************************************************
1667 * ar5416GetTargetPowersLeg
1668 *
1669 * Return the four rates of target power for the given target power table
1670 * channel, and number of channels
1671 */
1684static void
1672void
1685ar5416GetTargetPowersLeg(struct ath_hal *ah,
1686 const struct ieee80211_channel *chan,
1687 CAL_TARGET_POWER_LEG *powInfo, uint16_t numChannels,
1688 CAL_TARGET_POWER_LEG *pNewPower, uint16_t numRates,
1689 HAL_BOOL isExtTarget)
1690{
1691 uint16_t clo, chi;
1692 int i;

--- 510 unchanged lines hidden ---
1673ar5416GetTargetPowersLeg(struct ath_hal *ah,
1674 const struct ieee80211_channel *chan,
1675 CAL_TARGET_POWER_LEG *powInfo, uint16_t numChannels,
1676 CAL_TARGET_POWER_LEG *pNewPower, uint16_t numRates,
1677 HAL_BOOL isExtTarget)
1678{
1679 uint16_t clo, chi;
1680 int i;

--- 510 unchanged lines hidden ---