2008-08-04 00:16:41 -07:00
|
|
|
/*
|
2009-03-13 09:07:23 +05:30
|
|
|
* Copyright (c) 2008-2009 Atheros Communications Inc.
|
2008-08-04 00:16:41 -07:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/**
|
|
|
|
* DOC: Programming Atheros 802.11n analog front end radios
|
|
|
|
*
|
|
|
|
* AR5416 MAC based PCI devices and AR518 MAC based PCI-Express
|
|
|
|
* devices have either an external AR2133 analog front end radio for single
|
|
|
|
* band 2.4 GHz communication or an AR5133 analog front end radio for dual
|
|
|
|
* band 2.4 GHz / 5 GHz communication.
|
|
|
|
*
|
|
|
|
* All devices after the AR5416 and AR5418 family starting with the AR9280
|
|
|
|
* have their analog front radios, MAC/BB and host PCIe/USB interface embedded
|
|
|
|
* into a single-chip and require less programming.
|
|
|
|
*
|
|
|
|
* The following single-chips exist with a respective embedded radio:
|
|
|
|
*
|
|
|
|
* AR9280 - 11n dual-band 2x2 MIMO for PCIe
|
|
|
|
* AR9281 - 11n single-band 1x2 MIMO for PCIe
|
|
|
|
* AR9285 - 11n single-band 1x1 for PCIe
|
|
|
|
* AR9287 - 11n single-band 2x2 MIMO for PCIe
|
|
|
|
*
|
|
|
|
* AR9220 - 11n dual-band 2x2 MIMO for PCI
|
|
|
|
* AR9223 - 11n single-band 2x2 MIMO for PCI
|
|
|
|
*
|
|
|
|
* AR9287 - 11n single-band 1x1 MIMO for USB
|
|
|
|
*/
|
|
|
|
|
2009-09-13 23:39:31 -07:00
|
|
|
#include "hw.h"
|
2008-08-04 00:16:41 -07:00
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/**
|
|
|
|
* ath9k_hw_write_regs - ??
|
|
|
|
*
|
|
|
|
* @ah: atheros hardware structure
|
|
|
|
* @modesIndex:
|
|
|
|
* @freqIndex:
|
|
|
|
* @regWrites:
|
|
|
|
*
|
|
|
|
* Used for both the chipsets with an external AR2133/AR5133 radios and
|
|
|
|
* single-chip devices.
|
|
|
|
*/
|
2008-08-04 00:16:41 -07:00
|
|
|
void
|
2009-02-09 13:27:12 +05:30
|
|
|
ath9k_hw_write_regs(struct ath_hw *ah, u32 modesIndex, u32 freqIndex,
|
2008-08-04 00:16:41 -07:00
|
|
|
int regWrites)
|
|
|
|
{
|
2009-02-09 13:27:26 +05:30
|
|
|
REG_WRITE_ARRAY(&ah->iniBB_RfGain, freqIndex, regWrites);
|
2008-08-04 00:16:41 -07:00
|
|
|
}
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/**
|
|
|
|
* ath9k_hw_set_channel - tune to a channel on the external AR2133/AR5133 radios
|
|
|
|
* @ah: atheros hardware stucture
|
|
|
|
* @chan:
|
|
|
|
*
|
|
|
|
* For the external AR2133/AR5133 radios, takes the MHz channel value and set
|
|
|
|
* the channel value. Assumes writes enabled to analog bus and bank6 register
|
|
|
|
* cache in ah->analogBank6Data.
|
|
|
|
*/
|
2008-08-04 00:16:41 -07:00
|
|
|
bool
|
2009-02-09 13:27:12 +05:30
|
|
|
ath9k_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
|
2008-08-04 00:16:41 -07:00
|
|
|
{
|
2009-09-13 02:42:02 -07:00
|
|
|
struct ath_common *common = ath9k_hw_common(ah);
|
2008-08-04 00:16:41 -07:00
|
|
|
u32 channelSel = 0;
|
|
|
|
u32 bModeSynth = 0;
|
|
|
|
u32 aModeRefSel = 0;
|
|
|
|
u32 reg32 = 0;
|
|
|
|
u16 freq;
|
|
|
|
struct chan_centers centers;
|
|
|
|
|
|
|
|
ath9k_hw_get_channel_centers(ah, chan, ¢ers);
|
|
|
|
freq = centers.synth_center;
|
|
|
|
|
|
|
|
if (freq < 4800) {
|
|
|
|
u32 txctl;
|
|
|
|
|
|
|
|
if (((freq - 2192) % 5) == 0) {
|
|
|
|
channelSel = ((freq - 672) * 2 - 3040) / 10;
|
|
|
|
bModeSynth = 0;
|
|
|
|
} else if (((freq - 2224) % 5) == 0) {
|
|
|
|
channelSel = ((freq - 704) * 2 - 3040) / 10;
|
|
|
|
bModeSynth = 1;
|
|
|
|
} else {
|
2009-09-13 02:42:02 -07:00
|
|
|
ath_print(common, ATH_DBG_FATAL,
|
|
|
|
"Invalid channel %u MHz\n", freq);
|
2008-08-04 00:16:41 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
channelSel = (channelSel << 2) & 0xff;
|
|
|
|
channelSel = ath9k_hw_reverse_bits(channelSel, 8);
|
|
|
|
|
|
|
|
txctl = REG_READ(ah, AR_PHY_CCK_TX_CTRL);
|
|
|
|
if (freq == 2484) {
|
|
|
|
|
|
|
|
REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
|
|
|
|
txctl | AR_PHY_CCK_TX_CTRL_JAPAN);
|
|
|
|
} else {
|
|
|
|
REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
|
|
|
|
txctl & ~AR_PHY_CCK_TX_CTRL_JAPAN);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else if ((freq % 20) == 0 && freq >= 5120) {
|
|
|
|
channelSel =
|
|
|
|
ath9k_hw_reverse_bits(((freq - 4800) / 20 << 2), 8);
|
|
|
|
aModeRefSel = ath9k_hw_reverse_bits(1, 2);
|
|
|
|
} else if ((freq % 10) == 0) {
|
|
|
|
channelSel =
|
|
|
|
ath9k_hw_reverse_bits(((freq - 4800) / 10 << 1), 8);
|
|
|
|
if (AR_SREV_9100(ah) || AR_SREV_9160_10_OR_LATER(ah))
|
|
|
|
aModeRefSel = ath9k_hw_reverse_bits(2, 2);
|
|
|
|
else
|
|
|
|
aModeRefSel = ath9k_hw_reverse_bits(1, 2);
|
|
|
|
} else if ((freq % 5) == 0) {
|
|
|
|
channelSel = ath9k_hw_reverse_bits((freq - 4800) / 5, 8);
|
|
|
|
aModeRefSel = ath9k_hw_reverse_bits(1, 2);
|
|
|
|
} else {
|
2009-09-13 02:42:02 -07:00
|
|
|
ath_print(common, ATH_DBG_FATAL,
|
|
|
|
"Invalid channel %u MHz\n", freq);
|
2008-08-04 00:16:41 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
reg32 =
|
|
|
|
(channelSel << 8) | (aModeRefSel << 2) | (bModeSynth << 1) |
|
|
|
|
(1 << 5) | 0x1;
|
|
|
|
|
|
|
|
REG_WRITE(ah, AR_PHY(0x37), reg32);
|
|
|
|
|
2009-02-09 13:27:26 +05:30
|
|
|
ah->curchan = chan;
|
|
|
|
ah->curchan_rad_index = -1;
|
2008-08-04 00:16:41 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/**
|
|
|
|
* ath9k_hw_ar9280_set_channel - set channel on single-chip device
|
|
|
|
* @ah: atheros hardware structure
|
|
|
|
* @chan:
|
|
|
|
*
|
|
|
|
* This is the function to change channel on single-chip devices, that is
|
|
|
|
* all devices after ar9280.
|
|
|
|
*
|
|
|
|
* This function takes the channel value in MHz and sets
|
|
|
|
* hardware channel value. Assumes writes have been enabled to analog bus.
|
|
|
|
*
|
|
|
|
* Actual Expression,
|
|
|
|
*
|
|
|
|
* For 2GHz channel,
|
|
|
|
* Channel Frequency = (3/4) * freq_ref * (chansel[8:0] + chanfrac[16:0]/2^17)
|
|
|
|
* (freq_ref = 40MHz)
|
|
|
|
*
|
|
|
|
* For 5GHz channel,
|
|
|
|
* Channel Frequency = (3/2) * freq_ref * (chansel[8:0] + chanfrac[16:0]/2^10)
|
|
|
|
* (freq_ref = 40MHz/(24>>amodeRefSel))
|
|
|
|
*/
|
2009-05-08 17:54:51 -07:00
|
|
|
void ath9k_hw_ar9280_set_channel(struct ath_hw *ah,
|
|
|
|
struct ath9k_channel *chan)
|
2008-08-04 00:16:41 -07:00
|
|
|
{
|
|
|
|
u16 bMode, fracMode, aModeRefSel = 0;
|
|
|
|
u32 freq, ndiv, channelSel = 0, channelFrac = 0, reg32 = 0;
|
|
|
|
struct chan_centers centers;
|
|
|
|
u32 refDivA = 24;
|
|
|
|
|
|
|
|
ath9k_hw_get_channel_centers(ah, chan, ¢ers);
|
|
|
|
freq = centers.synth_center;
|
|
|
|
|
|
|
|
reg32 = REG_READ(ah, AR_PHY_SYNTH_CONTROL);
|
|
|
|
reg32 &= 0xc0000000;
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
if (freq < 4800) { /* 2 GHz, fractional mode */
|
2008-08-04 00:16:41 -07:00
|
|
|
u32 txctl;
|
2009-09-18 15:04:07 +05:30
|
|
|
int regWrites = 0;
|
2008-08-04 00:16:41 -07:00
|
|
|
|
|
|
|
bMode = 1;
|
|
|
|
fracMode = 1;
|
|
|
|
aModeRefSel = 0;
|
|
|
|
channelSel = (freq * 0x10000) / 15;
|
|
|
|
|
2009-09-18 15:04:07 +05:30
|
|
|
if (AR_SREV_9287_11_OR_LATER(ah)) {
|
|
|
|
if (freq == 2484) {
|
2009-10-19 02:33:35 -04:00
|
|
|
/* Enable channel spreading for channel 14 */
|
2009-09-18 15:04:07 +05:30
|
|
|
REG_WRITE_ARRAY(&ah->iniCckfirJapan2484,
|
|
|
|
1, regWrites);
|
|
|
|
} else {
|
|
|
|
REG_WRITE_ARRAY(&ah->iniCckfirNormal,
|
|
|
|
1, regWrites);
|
|
|
|
}
|
2008-08-04 00:16:41 -07:00
|
|
|
} else {
|
2009-09-18 15:04:07 +05:30
|
|
|
txctl = REG_READ(ah, AR_PHY_CCK_TX_CTRL);
|
|
|
|
if (freq == 2484) {
|
|
|
|
/* Enable channel spreading for channel 14 */
|
|
|
|
REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
|
|
|
|
txctl | AR_PHY_CCK_TX_CTRL_JAPAN);
|
|
|
|
} else {
|
|
|
|
REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
|
|
|
|
txctl &~ AR_PHY_CCK_TX_CTRL_JAPAN);
|
|
|
|
}
|
2008-08-04 00:16:41 -07:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
bMode = 0;
|
|
|
|
fracMode = 0;
|
|
|
|
|
2009-02-12 10:06:45 +05:30
|
|
|
switch(ah->eep_ops->get_eeprom(ah, EEP_FRAC_N_5G)) {
|
|
|
|
case 0:
|
|
|
|
if ((freq % 20) == 0) {
|
|
|
|
aModeRefSel = 3;
|
|
|
|
} else if ((freq % 10) == 0) {
|
|
|
|
aModeRefSel = 2;
|
|
|
|
}
|
|
|
|
if (aModeRefSel)
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
default:
|
2008-08-04 00:16:41 -07:00
|
|
|
aModeRefSel = 0;
|
2009-10-19 02:33:35 -04:00
|
|
|
/*
|
|
|
|
* Enable 2G (fractional) mode for channels
|
|
|
|
* which are 5MHz spaced.
|
|
|
|
*/
|
2008-08-04 00:16:41 -07:00
|
|
|
fracMode = 1;
|
|
|
|
refDivA = 1;
|
|
|
|
channelSel = (freq * 0x8000) / 15;
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/* RefDivA setting */
|
2008-08-04 00:16:41 -07:00
|
|
|
REG_RMW_FIELD(ah, AR_AN_SYNTH9,
|
|
|
|
AR_AN_SYNTH9_REFDIVA, refDivA);
|
2009-02-12 10:06:45 +05:30
|
|
|
|
2008-08-04 00:16:41 -07:00
|
|
|
}
|
2009-02-12 10:06:45 +05:30
|
|
|
|
2008-08-04 00:16:41 -07:00
|
|
|
if (!fracMode) {
|
|
|
|
ndiv = (freq * (refDivA >> aModeRefSel)) / 60;
|
|
|
|
channelSel = ndiv & 0x1ff;
|
|
|
|
channelFrac = (ndiv & 0xfffffe00) * 2;
|
|
|
|
channelSel = (channelSel << 17) | channelFrac;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
reg32 = reg32 |
|
|
|
|
(bMode << 29) |
|
|
|
|
(fracMode << 28) | (aModeRefSel << 26) | (channelSel);
|
|
|
|
|
|
|
|
REG_WRITE(ah, AR_PHY_SYNTH_CONTROL, reg32);
|
|
|
|
|
2009-02-09 13:27:26 +05:30
|
|
|
ah->curchan = chan;
|
|
|
|
ah->curchan_rad_index = -1;
|
2008-08-04 00:16:41 -07:00
|
|
|
}
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/**
|
|
|
|
* ath9k_phy_modify_rx_buffer() - perform analog swizzling of parameters
|
|
|
|
* @rfbuf:
|
|
|
|
* @reg32:
|
|
|
|
* @numBits:
|
|
|
|
* @firstBit:
|
|
|
|
* @column:
|
|
|
|
*
|
|
|
|
* Performs analog "swizzling" of parameters into their location.
|
|
|
|
* Used on external AR2133/AR5133 radios.
|
|
|
|
*/
|
2008-08-04 00:16:41 -07:00
|
|
|
static void
|
|
|
|
ath9k_phy_modify_rx_buffer(u32 *rfBuf, u32 reg32,
|
|
|
|
u32 numBits, u32 firstBit,
|
|
|
|
u32 column)
|
|
|
|
{
|
|
|
|
u32 tmp32, mask, arrayEntry, lastBit;
|
|
|
|
int32_t bitPosition, bitsLeft;
|
|
|
|
|
|
|
|
tmp32 = ath9k_hw_reverse_bits(reg32, numBits);
|
|
|
|
arrayEntry = (firstBit - 1) / 8;
|
|
|
|
bitPosition = (firstBit - 1) % 8;
|
|
|
|
bitsLeft = numBits;
|
|
|
|
while (bitsLeft > 0) {
|
|
|
|
lastBit = (bitPosition + bitsLeft > 8) ?
|
|
|
|
8 : bitPosition + bitsLeft;
|
|
|
|
mask = (((1 << lastBit) - 1) ^ ((1 << bitPosition) - 1)) <<
|
|
|
|
(column * 8);
|
|
|
|
rfBuf[arrayEntry] &= ~mask;
|
|
|
|
rfBuf[arrayEntry] |= ((tmp32 << bitPosition) <<
|
|
|
|
(column * 8)) & mask;
|
|
|
|
bitsLeft -= 8 - bitPosition;
|
|
|
|
tmp32 = tmp32 >> (8 - bitPosition);
|
|
|
|
bitPosition = 0;
|
|
|
|
arrayEntry++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/* *
|
|
|
|
* ath9k_hw_set_rf_regs - programs rf registers based on EEPROM
|
|
|
|
* @ah: atheros hardware structure
|
|
|
|
* @chan:
|
|
|
|
* @modesIndex:
|
|
|
|
*
|
|
|
|
* Used for the external AR2133/AR5133 radios.
|
|
|
|
*
|
|
|
|
* Reads the EEPROM header info from the device structure and programs
|
|
|
|
* all rf registers. This routine requires access to the analog
|
|
|
|
* rf device. This is not required for single-chip devices.
|
|
|
|
*/
|
2008-08-04 00:16:41 -07:00
|
|
|
bool
|
2009-02-09 13:27:12 +05:30
|
|
|
ath9k_hw_set_rf_regs(struct ath_hw *ah, struct ath9k_channel *chan,
|
2008-08-04 00:16:41 -07:00
|
|
|
u16 modesIndex)
|
|
|
|
{
|
|
|
|
u32 eepMinorRev;
|
|
|
|
u32 ob5GHz = 0, db5GHz = 0;
|
|
|
|
u32 ob2GHz = 0, db2GHz = 0;
|
|
|
|
int regWrites = 0;
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/*
|
|
|
|
* Software does not need to program bank data
|
|
|
|
* for single chip devices, that is AR9280 or anything
|
|
|
|
* after that.
|
|
|
|
*/
|
2008-08-04 00:16:41 -07:00
|
|
|
if (AR_SREV_9280_10_OR_LATER(ah))
|
|
|
|
return true;
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/* Setup rf parameters */
|
2009-02-09 13:27:24 +05:30
|
|
|
eepMinorRev = ah->eep_ops->get_eeprom(ah, EEP_MINOR_REV);
|
2008-08-04 00:16:41 -07:00
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/* Setup Bank 0 Write */
|
2009-02-09 13:27:26 +05:30
|
|
|
RF_BANK_SETUP(ah->analogBank0Data, &ah->iniBank0, 1);
|
2008-08-04 00:16:41 -07:00
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/* Setup Bank 1 Write */
|
2009-02-09 13:27:26 +05:30
|
|
|
RF_BANK_SETUP(ah->analogBank1Data, &ah->iniBank1, 1);
|
2008-08-04 00:16:41 -07:00
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/* Setup Bank 2 Write */
|
2009-02-09 13:27:26 +05:30
|
|
|
RF_BANK_SETUP(ah->analogBank2Data, &ah->iniBank2, 1);
|
2008-08-04 00:16:41 -07:00
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/* Setup Bank 6 Write */
|
2009-02-09 13:27:26 +05:30
|
|
|
RF_BANK_SETUP(ah->analogBank3Data, &ah->iniBank3,
|
2008-08-04 00:16:41 -07:00
|
|
|
modesIndex);
|
|
|
|
{
|
|
|
|
int i;
|
2009-02-09 13:27:26 +05:30
|
|
|
for (i = 0; i < ah->iniBank6TPC.ia_rows; i++) {
|
|
|
|
ah->analogBank6Data[i] =
|
|
|
|
INI_RA(&ah->iniBank6TPC, i, modesIndex);
|
2008-08-04 00:16:41 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/* Only the 5 or 2 GHz OB/DB need to be set for a mode */
|
2008-08-04 00:16:41 -07:00
|
|
|
if (eepMinorRev >= 2) {
|
|
|
|
if (IS_CHAN_2GHZ(chan)) {
|
2009-02-09 13:27:24 +05:30
|
|
|
ob2GHz = ah->eep_ops->get_eeprom(ah, EEP_OB_2);
|
|
|
|
db2GHz = ah->eep_ops->get_eeprom(ah, EEP_DB_2);
|
2009-02-09 13:27:26 +05:30
|
|
|
ath9k_phy_modify_rx_buffer(ah->analogBank6Data,
|
2008-08-04 00:16:41 -07:00
|
|
|
ob2GHz, 3, 197, 0);
|
2009-02-09 13:27:26 +05:30
|
|
|
ath9k_phy_modify_rx_buffer(ah->analogBank6Data,
|
2008-08-04 00:16:41 -07:00
|
|
|
db2GHz, 3, 194, 0);
|
|
|
|
} else {
|
2009-02-09 13:27:24 +05:30
|
|
|
ob5GHz = ah->eep_ops->get_eeprom(ah, EEP_OB_5);
|
|
|
|
db5GHz = ah->eep_ops->get_eeprom(ah, EEP_DB_5);
|
2009-02-09 13:27:26 +05:30
|
|
|
ath9k_phy_modify_rx_buffer(ah->analogBank6Data,
|
2008-08-04 00:16:41 -07:00
|
|
|
ob5GHz, 3, 203, 0);
|
2009-02-09 13:27:26 +05:30
|
|
|
ath9k_phy_modify_rx_buffer(ah->analogBank6Data,
|
2008-08-04 00:16:41 -07:00
|
|
|
db5GHz, 3, 200, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/* Setup Bank 7 Setup */
|
2009-02-09 13:27:26 +05:30
|
|
|
RF_BANK_SETUP(ah->analogBank7Data, &ah->iniBank7, 1);
|
2008-08-04 00:16:41 -07:00
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/* Write Analog registers */
|
2009-02-09 13:27:26 +05:30
|
|
|
REG_WRITE_RF_ARRAY(&ah->iniBank0, ah->analogBank0Data,
|
2008-08-04 00:16:41 -07:00
|
|
|
regWrites);
|
2009-02-09 13:27:26 +05:30
|
|
|
REG_WRITE_RF_ARRAY(&ah->iniBank1, ah->analogBank1Data,
|
2008-08-04 00:16:41 -07:00
|
|
|
regWrites);
|
2009-02-09 13:27:26 +05:30
|
|
|
REG_WRITE_RF_ARRAY(&ah->iniBank2, ah->analogBank2Data,
|
2008-08-04 00:16:41 -07:00
|
|
|
regWrites);
|
2009-02-09 13:27:26 +05:30
|
|
|
REG_WRITE_RF_ARRAY(&ah->iniBank3, ah->analogBank3Data,
|
2008-08-04 00:16:41 -07:00
|
|
|
regWrites);
|
2009-02-09 13:27:26 +05:30
|
|
|
REG_WRITE_RF_ARRAY(&ah->iniBank6TPC, ah->analogBank6Data,
|
2008-08-04 00:16:41 -07:00
|
|
|
regWrites);
|
2009-02-09 13:27:26 +05:30
|
|
|
REG_WRITE_RF_ARRAY(&ah->iniBank7, ah->analogBank7Data,
|
2008-08-04 00:16:41 -07:00
|
|
|
regWrites);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/**
|
2009-10-19 02:33:39 -04:00
|
|
|
* ath9k_hw_rf_free_ext_banks - Free memory for analog bank scratch buffers
|
2009-10-19 02:33:35 -04:00
|
|
|
* @ah: atheros hardware struture
|
2009-10-19 02:33:39 -04:00
|
|
|
* For the external AR2133/AR5133 radios banks.
|
2009-10-19 02:33:35 -04:00
|
|
|
*/
|
2008-08-04 00:16:41 -07:00
|
|
|
void
|
2009-10-19 02:33:39 -04:00
|
|
|
ath9k_hw_rf_free_ext_banks(struct ath_hw *ah)
|
2008-08-04 00:16:41 -07:00
|
|
|
{
|
2009-08-03 12:24:49 -07:00
|
|
|
#define ATH_FREE_BANK(bank) do { \
|
|
|
|
kfree(bank); \
|
|
|
|
bank = NULL; \
|
|
|
|
} while (0);
|
|
|
|
|
2009-10-19 02:33:39 -04:00
|
|
|
BUG_ON(AR_SREV_9280_10_OR_LATER(ah));
|
|
|
|
|
2009-08-03 12:24:49 -07:00
|
|
|
ATH_FREE_BANK(ah->analogBank0Data);
|
|
|
|
ATH_FREE_BANK(ah->analogBank1Data);
|
|
|
|
ATH_FREE_BANK(ah->analogBank2Data);
|
|
|
|
ATH_FREE_BANK(ah->analogBank3Data);
|
|
|
|
ATH_FREE_BANK(ah->analogBank6Data);
|
|
|
|
ATH_FREE_BANK(ah->analogBank6TPCData);
|
|
|
|
ATH_FREE_BANK(ah->analogBank7Data);
|
|
|
|
ATH_FREE_BANK(ah->addac5416_21);
|
|
|
|
ATH_FREE_BANK(ah->bank6Temp);
|
2009-10-19 02:33:39 -04:00
|
|
|
|
2009-08-03 12:24:49 -07:00
|
|
|
#undef ATH_FREE_BANK
|
2008-08-04 00:16:41 -07:00
|
|
|
}
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/**
|
2009-10-19 02:33:37 -04:00
|
|
|
* ath9k_hw_rf_alloc_ext_banks - allocates banks for external radio programming
|
2009-10-19 02:33:35 -04:00
|
|
|
* @ah: atheros hardware structure
|
|
|
|
*
|
|
|
|
* Only required for older devices with external AR2133/AR5133 radios.
|
|
|
|
*/
|
2009-10-19 02:33:37 -04:00
|
|
|
int ath9k_hw_rf_alloc_ext_banks(struct ath_hw *ah)
|
2008-08-04 00:16:41 -07:00
|
|
|
{
|
2009-10-19 02:33:38 -04:00
|
|
|
#define ATH_ALLOC_BANK(bank, size) do { \
|
|
|
|
bank = kzalloc((sizeof(u32) * size), GFP_KERNEL); \
|
|
|
|
if (!bank) { \
|
|
|
|
ath_print(common, ATH_DBG_FATAL, \
|
|
|
|
"Cannot allocate RF banks\n"); \
|
|
|
|
return -ENOMEM; \
|
|
|
|
} \
|
|
|
|
} while (0);
|
|
|
|
|
2009-09-13 02:42:02 -07:00
|
|
|
struct ath_common *common = ath9k_hw_common(ah);
|
|
|
|
|
2009-10-19 02:33:37 -04:00
|
|
|
BUG_ON(AR_SREV_9280_10_OR_LATER(ah));
|
2008-08-04 00:16:41 -07:00
|
|
|
|
2009-10-19 02:33:38 -04:00
|
|
|
ATH_ALLOC_BANK(ah->analogBank0Data, ah->iniBank0.ia_rows);
|
|
|
|
ATH_ALLOC_BANK(ah->analogBank1Data, ah->iniBank1.ia_rows);
|
|
|
|
ATH_ALLOC_BANK(ah->analogBank2Data, ah->iniBank2.ia_rows);
|
|
|
|
ATH_ALLOC_BANK(ah->analogBank3Data, ah->iniBank3.ia_rows);
|
|
|
|
ATH_ALLOC_BANK(ah->analogBank6Data, ah->iniBank6.ia_rows);
|
|
|
|
ATH_ALLOC_BANK(ah->analogBank6TPCData, ah->iniBank6TPC.ia_rows);
|
|
|
|
ATH_ALLOC_BANK(ah->analogBank7Data, ah->iniBank7.ia_rows);
|
|
|
|
ATH_ALLOC_BANK(ah->addac5416_21,
|
|
|
|
ah->iniAddac.ia_rows * ah->iniAddac.ia_columns);
|
|
|
|
ATH_ALLOC_BANK(ah->bank6Temp, ah->iniBank6.ia_rows);
|
2008-08-04 00:16:41 -07:00
|
|
|
|
2009-10-19 02:33:37 -04:00
|
|
|
return 0;
|
2009-10-19 02:33:38 -04:00
|
|
|
#undef ATH_ALLOC_BANK
|
2008-08-04 00:16:41 -07:00
|
|
|
}
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/**
|
|
|
|
* ath9k_hw_decrease_chain_power()
|
|
|
|
*
|
|
|
|
* @ah: atheros hardware structure
|
|
|
|
* @chan:
|
|
|
|
*
|
|
|
|
* Only used on the AR5416 and AR5418 with the external AR2133/AR5133 radios.
|
|
|
|
*
|
|
|
|
* Sets a chain internal RF path to the lowest output power. Any
|
|
|
|
* further writes to bank6 after this setting will override these
|
|
|
|
* changes. Thus this function must be the last function in the
|
|
|
|
* sequence to modify bank 6.
|
|
|
|
*
|
|
|
|
* This function must be called after ar5416SetRfRegs() which is
|
|
|
|
* called from ath9k_hw_process_ini() due to swizzling of bank 6.
|
|
|
|
* Depends on ah->analogBank6Data being initialized by
|
|
|
|
* ath9k_hw_set_rf_regs()
|
|
|
|
*
|
|
|
|
* Additional additive reduction in power -
|
|
|
|
* change chain's switch table so chain's tx state is actually the rx
|
|
|
|
* state value. May produce different results in 2GHz/5GHz as well as
|
|
|
|
* board to board but in general should be a reduction.
|
|
|
|
*
|
|
|
|
* Activated by #ifdef ALTER_SWITCH. Not tried yet. If so, must be
|
|
|
|
* called after ah->eep_ops->set_board_values() due to RMW of
|
|
|
|
* PHY_SWITCH_CHAIN_0.
|
|
|
|
*/
|
2008-08-04 00:16:41 -07:00
|
|
|
void
|
2009-02-09 13:27:12 +05:30
|
|
|
ath9k_hw_decrease_chain_power(struct ath_hw *ah, struct ath9k_channel *chan)
|
2008-08-04 00:16:41 -07:00
|
|
|
{
|
|
|
|
int i, regWrites = 0;
|
|
|
|
u32 bank6SelMask;
|
2009-02-09 13:27:26 +05:30
|
|
|
u32 *bank6Temp = ah->bank6Temp;
|
2008-08-04 00:16:41 -07:00
|
|
|
|
2009-08-13 09:34:32 +05:30
|
|
|
switch (ah->config.diversity_control) {
|
2008-08-04 00:16:41 -07:00
|
|
|
case ATH9K_ANT_FIXED_A:
|
|
|
|
bank6SelMask =
|
2009-08-13 09:34:32 +05:30
|
|
|
(ah->config.antenna_switch_swap & ANTSWAP_AB) ?
|
2009-10-19 02:33:35 -04:00
|
|
|
REDUCE_CHAIN_0 : /* swapped, reduce chain 0 */
|
|
|
|
REDUCE_CHAIN_1; /* normal, select chain 1/2 to reduce */
|
2008-08-04 00:16:41 -07:00
|
|
|
break;
|
|
|
|
case ATH9K_ANT_FIXED_B:
|
|
|
|
bank6SelMask =
|
2009-08-13 09:34:32 +05:30
|
|
|
(ah->config.antenna_switch_swap & ANTSWAP_AB) ?
|
2009-10-19 02:33:35 -04:00
|
|
|
REDUCE_CHAIN_1 : /* swapped, reduce chain 1/2 */
|
|
|
|
REDUCE_CHAIN_0; /* normal, select chain 0 to reduce */
|
2008-08-04 00:16:41 -07:00
|
|
|
break;
|
|
|
|
case ATH9K_ANT_VARIABLE:
|
2009-10-19 02:33:35 -04:00
|
|
|
return; /* do not change anything */
|
2008-08-04 00:16:41 -07:00
|
|
|
break;
|
|
|
|
default:
|
2009-10-19 02:33:35 -04:00
|
|
|
return; /* do not change anything */
|
2008-08-04 00:16:41 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2009-02-09 13:27:26 +05:30
|
|
|
for (i = 0; i < ah->iniBank6.ia_rows; i++)
|
|
|
|
bank6Temp[i] = ah->analogBank6Data[i];
|
2008-08-04 00:16:41 -07:00
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/* Write Bank 5 to switch Bank 6 write to selected chain only */
|
2008-08-04 00:16:41 -07:00
|
|
|
REG_WRITE(ah, AR_PHY_BASE + 0xD8, bank6SelMask);
|
|
|
|
|
2009-10-19 02:33:35 -04:00
|
|
|
/*
|
|
|
|
* Modify Bank6 selected chain to use lowest amplification.
|
|
|
|
* Modifies the parameters to a value of 1.
|
|
|
|
* Depends on existing bank 6 values to be cached in
|
|
|
|
* ah->analogBank6Data
|
|
|
|
*/
|
2008-08-04 00:16:41 -07:00
|
|
|
ath9k_phy_modify_rx_buffer(bank6Temp, 1, 1, 189, 0);
|
|
|
|
ath9k_phy_modify_rx_buffer(bank6Temp, 1, 1, 190, 0);
|
|
|
|
ath9k_phy_modify_rx_buffer(bank6Temp, 1, 1, 191, 0);
|
|
|
|
ath9k_phy_modify_rx_buffer(bank6Temp, 1, 1, 192, 0);
|
|
|
|
ath9k_phy_modify_rx_buffer(bank6Temp, 1, 1, 193, 0);
|
|
|
|
ath9k_phy_modify_rx_buffer(bank6Temp, 1, 1, 222, 0);
|
|
|
|
ath9k_phy_modify_rx_buffer(bank6Temp, 1, 1, 245, 0);
|
|
|
|
ath9k_phy_modify_rx_buffer(bank6Temp, 1, 1, 246, 0);
|
|
|
|
ath9k_phy_modify_rx_buffer(bank6Temp, 1, 1, 247, 0);
|
|
|
|
|
2009-02-09 13:27:26 +05:30
|
|
|
REG_WRITE_RF_ARRAY(&ah->iniBank6, bank6Temp, regWrites);
|
2008-08-04 00:16:41 -07:00
|
|
|
|
|
|
|
REG_WRITE(ah, AR_PHY_BASE + 0xD8, 0x00000053);
|
|
|
|
#ifdef ALTER_SWITCH
|
|
|
|
REG_WRITE(ah, PHY_SWITCH_CHAIN_0,
|
|
|
|
(REG_READ(ah, PHY_SWITCH_CHAIN_0) & ~0x38)
|
|
|
|
| ((REG_READ(ah, PHY_SWITCH_CHAIN_0) >> 3) & 0x38));
|
|
|
|
#endif
|
|
|
|
}
|