Commit 16c94ac6 authored by Sujith's avatar Sujith Committed by John W. Linville

ath9k_hw: Cleanup eeprom_9287.c

* Fix whitespace damage.
* Remove unused debug messages.
* Introduce a macro NUM_EEP_WORDS.
* Convert AR9287 to lowercase in function names.
Signed-off-by: default avatarSujith <Sujith.Manoharan@atheros.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent ad0e2b5a
...@@ -17,17 +17,19 @@ ...@@ -17,17 +17,19 @@
#include "hw.h" #include "hw.h"
#include "ar9002_phy.h" #include "ar9002_phy.h"
static int ath9k_hw_AR9287_get_eeprom_ver(struct ath_hw *ah) #define NUM_EEP_WORDS (sizeof(struct ar9287_eeprom) / sizeof(u16))
static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah)
{ {
return (ah->eeprom.map9287.baseEepHeader.version >> 12) & 0xF; return (ah->eeprom.map9287.baseEepHeader.version >> 12) & 0xF;
} }
static int ath9k_hw_AR9287_get_eeprom_rev(struct ath_hw *ah) static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah)
{ {
return (ah->eeprom.map9287.baseEepHeader.version) & 0xFFF; return (ah->eeprom.map9287.baseEepHeader.version) & 0xFFF;
} }
static bool ath9k_hw_AR9287_fill_eeprom(struct ath_hw *ah) static bool ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah)
{ {
struct ar9287_eeprom *eep = &ah->eeprom.map9287; struct ar9287_eeprom *eep = &ah->eeprom.map9287;
struct ath_common *common = ath9k_hw_common(ah); struct ath_common *common = ath9k_hw_common(ah);
...@@ -40,20 +42,20 @@ static bool ath9k_hw_AR9287_fill_eeprom(struct ath_hw *ah) ...@@ -40,20 +42,20 @@ static bool ath9k_hw_AR9287_fill_eeprom(struct ath_hw *ah)
"Reading from EEPROM, not flash\n"); "Reading from EEPROM, not flash\n");
} }
for (addr = 0; addr < sizeof(struct ar9287_eeprom) / sizeof(u16); for (addr = 0; addr < NUM_EEP_WORDS; addr++) {
addr++) { if (!ath9k_hw_nvram_read(common, addr + eep_start_loc,
if (!ath9k_hw_nvram_read(common, eep_data)) {
addr + eep_start_loc, eep_data)) {
ath_print(common, ATH_DBG_EEPROM, ath_print(common, ATH_DBG_EEPROM,
"Unable to read eeprom region\n"); "Unable to read eeprom region\n");
return false; return false;
} }
eep_data++; eep_data++;
} }
return true; return true;
} }
static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah) static int ath9k_hw_ar9287_check_eeprom(struct ath_hw *ah)
{ {
u32 sum = 0, el, integer; u32 sum = 0, el, integer;
u16 temp, word, magic, magic2, *eepdata; u16 temp, word, magic, magic2, *eepdata;
...@@ -63,8 +65,8 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah) ...@@ -63,8 +65,8 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah)
struct ath_common *common = ath9k_hw_common(ah); struct ath_common *common = ath9k_hw_common(ah);
if (!ath9k_hw_use_flash(ah)) { if (!ath9k_hw_use_flash(ah)) {
if (!ath9k_hw_nvram_read(common, if (!ath9k_hw_nvram_read(common, AR5416_EEPROM_MAGIC_OFFSET,
AR5416_EEPROM_MAGIC_OFFSET, &magic)) { &magic)) {
ath_print(common, ATH_DBG_FATAL, ath_print(common, ATH_DBG_FATAL,
"Reading Magic # failed\n"); "Reading Magic # failed\n");
return false; return false;
...@@ -72,6 +74,7 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah) ...@@ -72,6 +74,7 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah)
ath_print(common, ATH_DBG_EEPROM, ath_print(common, ATH_DBG_EEPROM,
"Read Magic = 0x%04X\n", magic); "Read Magic = 0x%04X\n", magic);
if (magic != AR5416_EEPROM_MAGIC) { if (magic != AR5416_EEPROM_MAGIC) {
magic2 = swab16(magic); magic2 = swab16(magic);
...@@ -79,9 +82,7 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah) ...@@ -79,9 +82,7 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah)
need_swap = true; need_swap = true;
eepdata = (u16 *)(&ah->eeprom); eepdata = (u16 *)(&ah->eeprom);
for (addr = 0; for (addr = 0; addr < NUM_EEP_WORDS; addr++) {
addr < sizeof(struct ar9287_eeprom) / sizeof(u16);
addr++) {
temp = swab16(*eepdata); temp = swab16(*eepdata);
*eepdata = temp; *eepdata = temp;
eepdata++; eepdata++;
...@@ -89,13 +90,14 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah) ...@@ -89,13 +90,14 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah)
} else { } else {
ath_print(common, ATH_DBG_FATAL, ath_print(common, ATH_DBG_FATAL,
"Invalid EEPROM Magic. " "Invalid EEPROM Magic. "
"endianness mismatch.\n"); "Endianness mismatch.\n");
return -EINVAL; return -EINVAL;
} }
} }
} }
ath_print(common, ATH_DBG_EEPROM, "need_swap = %s.\n", need_swap ?
"True" : "False"); ath_print(common, ATH_DBG_EEPROM, "need_swap = %s.\n",
need_swap ? "True" : "False");
if (need_swap) if (need_swap)
el = swab16(ah->eeprom.map9287.baseEepHeader.length); el = swab16(ah->eeprom.map9287.baseEepHeader.length);
...@@ -108,6 +110,7 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah) ...@@ -108,6 +110,7 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah)
el = el / sizeof(u16); el = el / sizeof(u16);
eepdata = (u16 *)(&ah->eeprom); eepdata = (u16 *)(&ah->eeprom);
for (i = 0; i < el; i++) for (i = 0; i < el; i++)
sum ^= *eepdata++; sum ^= *eepdata++;
...@@ -161,7 +164,7 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah) ...@@ -161,7 +164,7 @@ static int ath9k_hw_AR9287_check_eeprom(struct ath_hw *ah)
return 0; return 0;
} }
static u32 ath9k_hw_AR9287_get_eeprom(struct ath_hw *ah, static u32 ath9k_hw_ar9287_get_eeprom(struct ath_hw *ah,
enum eeprom_param param) enum eeprom_param param)
{ {
struct ar9287_eeprom *eep = &ah->eeprom.map9287; struct ar9287_eeprom *eep = &ah->eeprom.map9287;
...@@ -170,6 +173,7 @@ static u32 ath9k_hw_AR9287_get_eeprom(struct ath_hw *ah, ...@@ -170,6 +173,7 @@ static u32 ath9k_hw_AR9287_get_eeprom(struct ath_hw *ah,
u16 ver_minor; u16 ver_minor;
ver_minor = pBase->version & AR9287_EEP_VER_MINOR_MASK; ver_minor = pBase->version & AR9287_EEP_VER_MINOR_MASK;
switch (param) { switch (param) {
case EEP_NFTHRESH_2: case EEP_NFTHRESH_2:
return pModal->noiseFloorThreshCh[0]; return pModal->noiseFloorThreshCh[0];
...@@ -214,13 +218,14 @@ static u32 ath9k_hw_AR9287_get_eeprom(struct ath_hw *ah, ...@@ -214,13 +218,14 @@ static u32 ath9k_hw_AR9287_get_eeprom(struct ath_hw *ah,
} }
} }
static void ath9k_hw_get_ar9287_gain_boundaries_pdadcs(struct ath_hw *ah,
static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah,
struct ath9k_channel *chan, struct ath9k_channel *chan,
struct cal_data_per_freq_ar9287 *pRawDataSet, struct cal_data_per_freq_ar9287 *pRawDataSet,
u8 *bChans, u16 availPiers, u8 *bChans, u16 availPiers,
u16 tPdGainOverlap, int16_t *pMinCalPower, u16 tPdGainOverlap,
u16 *pPdGainBoundaries, u8 *pPDADCValues, int16_t *pMinCalPower,
u16 *pPdGainBoundaries,
u8 *pPDADCValues,
u16 numXpdGains) u16 numXpdGains)
{ {
#define TMP_VAL_VPD_TABLE \ #define TMP_VAL_VPD_TABLE \
...@@ -253,9 +258,8 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah, ...@@ -253,9 +258,8 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah,
} }
match = ath9k_hw_get_lower_upper_index( match = ath9k_hw_get_lower_upper_index(
(u8)FREQ2FBIN(centers.synth_center, (u8)FREQ2FBIN(centers.synth_center, IS_CHAN_2GHZ(chan)),
IS_CHAN_2GHZ(chan)), bChans, numPiers, bChans, numPiers, &idxL, &idxR);
&idxL, &idxR);
if (match) { if (match) {
for (i = 0; i < numXpdGains; i++) { for (i = 0; i < numXpdGains; i++) {
...@@ -264,7 +268,8 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah, ...@@ -264,7 +268,8 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah,
ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i], ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
pRawDataSet[idxL].pwrPdg[i], pRawDataSet[idxL].pwrPdg[i],
pRawDataSet[idxL].vpdPdg[i], pRawDataSet[idxL].vpdPdg[i],
AR9287_PD_GAIN_ICEPTS, vpdTableI[i]); AR9287_PD_GAIN_ICEPTS,
vpdTableI[i]);
} }
} else { } else {
for (i = 0; i < numXpdGains; i++) { for (i = 0; i < numXpdGains; i++) {
...@@ -275,8 +280,7 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah, ...@@ -275,8 +280,7 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah,
minPwrT4[i] = max(pPwrL[0], pPwrR[0]); minPwrT4[i] = max(pPwrL[0], pPwrR[0]);
maxPwrT4[i] = maxPwrT4[i] = min(pPwrL[AR9287_PD_GAIN_ICEPTS - 1],
min(pPwrL[AR9287_PD_GAIN_ICEPTS - 1],
pPwrR[AR9287_PD_GAIN_ICEPTS - 1]); pPwrR[AR9287_PD_GAIN_ICEPTS - 1]);
ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i], ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
...@@ -289,24 +293,25 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah, ...@@ -289,24 +293,25 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah,
vpdTableR[i]); vpdTableR[i]);
for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) { for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) {
vpdTableI[i][j] = vpdTableI[i][j] = (u8)(ath9k_hw_interpolate(
(u8)(ath9k_hw_interpolate((u16) (u16)FREQ2FBIN(centers. synth_center,
FREQ2FBIN(centers. synth_center,
IS_CHAN_2GHZ(chan)), IS_CHAN_2GHZ(chan)),
bChans[idxL], bChans[idxR], bChans[idxL], bChans[idxR],
vpdTableL[i][j], vpdTableR[i][j])); vpdTableL[i][j], vpdTableR[i][j]));
} }
} }
} }
*pMinCalPower = (int16_t)(minPwrT4[0] / 2);
*pMinCalPower = (int16_t)(minPwrT4[0] / 2);
k = 0; k = 0;
for (i = 0; i < numXpdGains; i++) { for (i = 0; i < numXpdGains; i++) {
if (i == (numXpdGains - 1)) if (i == (numXpdGains - 1))
pPdGainBoundaries[i] = (u16)(maxPwrT4[i] / 2); pPdGainBoundaries[i] =
(u16)(maxPwrT4[i] / 2);
else else
pPdGainBoundaries[i] = (u16)((maxPwrT4[i] + pPdGainBoundaries[i] =
minPwrT4[i+1]) / 4); (u16)((maxPwrT4[i] + minPwrT4[i+1]) / 4);
pPdGainBoundaries[i] = min((u16)AR5416_MAX_RATE_POWER, pPdGainBoundaries[i] = min((u16)AR5416_MAX_RATE_POWER,
pPdGainBoundaries[i]); pPdGainBoundaries[i]);
...@@ -330,6 +335,7 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah, ...@@ -330,6 +335,7 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah,
vpdStep = (int16_t)(vpdTableI[i][1] - vpdTableI[i][0]); vpdStep = (int16_t)(vpdTableI[i][1] - vpdTableI[i][0]);
vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep); vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
while ((ss < 0) && (k < (AR9287_NUM_PDADC_VALUES - 1))) { while ((ss < 0) && (k < (AR9287_NUM_PDADC_VALUES - 1))) {
tmpVal = (int16_t)(vpdTableI[i][0] + ss * vpdStep); tmpVal = (int16_t)(vpdTableI[i][0] + ss * vpdStep);
pPDADCValues[k++] = (u8)((tmpVal < 0) ? 0 : tmpVal); pPDADCValues[k++] = (u8)((tmpVal < 0) ? 0 : tmpVal);
...@@ -348,12 +354,13 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah, ...@@ -348,12 +354,13 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah,
vpdStep = (int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] - vpdStep = (int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] -
vpdTableI[i][sizeCurrVpdTable - 2]); vpdTableI[i][sizeCurrVpdTable - 2]);
vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep); vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
if (tgtIndex > maxIndex) { if (tgtIndex > maxIndex) {
while ((ss <= tgtIndex) && while ((ss <= tgtIndex) &&
(k < (AR9287_NUM_PDADC_VALUES - 1))) { (k < (AR9287_NUM_PDADC_VALUES - 1))) {
tmpVal = (int16_t) TMP_VAL_VPD_TABLE; tmpVal = (int16_t) TMP_VAL_VPD_TABLE;
pPDADCValues[k++] = (u8)((tmpVal > 255) ? pPDADCValues[k++] =
255 : tmpVal); (u8)((tmpVal > 255) ? 255 : tmpVal);
ss++; ss++;
} }
} }
...@@ -375,8 +382,7 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah, ...@@ -375,8 +382,7 @@ static void ath9k_hw_get_AR9287_gain_boundaries_pdadcs(struct ath_hw *ah,
static void ar9287_eeprom_get_tx_gain_index(struct ath_hw *ah, static void ar9287_eeprom_get_tx_gain_index(struct ath_hw *ah,
struct ath9k_channel *chan, struct ath9k_channel *chan,
struct cal_data_op_loop_ar9287 *pRawDatasetOpLoop, struct cal_data_op_loop_ar9287 *pRawDatasetOpLoop,
u8 *pCalChans, u16 availPiers, u8 *pCalChans, u16 availPiers, int8_t *pPwr)
int8_t *pPwr)
{ {
u16 idxL = 0, idxR = 0, numPiers; u16 idxL = 0, idxR = 0, numPiers;
bool match; bool match;
...@@ -391,8 +397,7 @@ static void ar9287_eeprom_get_tx_gain_index(struct ath_hw *ah, ...@@ -391,8 +397,7 @@ static void ar9287_eeprom_get_tx_gain_index(struct ath_hw *ah,
match = ath9k_hw_get_lower_upper_index( match = ath9k_hw_get_lower_upper_index(
(u8)FREQ2FBIN(centers.synth_center, IS_CHAN_2GHZ(chan)), (u8)FREQ2FBIN(centers.synth_center, IS_CHAN_2GHZ(chan)),
pCalChans, numPiers, pCalChans, numPiers, &idxL, &idxR);
&idxL, &idxR);
if (match) { if (match) {
*pPwr = (int8_t) pRawDatasetOpLoop[idxL].pwrPdg[0][0]; *pPwr = (int8_t) pRawDatasetOpLoop[idxL].pwrPdg[0][0];
...@@ -409,16 +414,22 @@ static void ar9287_eeprom_olpc_set_pdadcs(struct ath_hw *ah, ...@@ -409,16 +414,22 @@ static void ar9287_eeprom_olpc_set_pdadcs(struct ath_hw *ah,
u32 tmpVal; u32 tmpVal;
u32 a; u32 a;
/* Enable OLPC for chain 0 */
tmpVal = REG_READ(ah, 0xa270); tmpVal = REG_READ(ah, 0xa270);
tmpVal = tmpVal & 0xFCFFFFFF; tmpVal = tmpVal & 0xFCFFFFFF;
tmpVal = tmpVal | (0x3 << 24); tmpVal = tmpVal | (0x3 << 24);
REG_WRITE(ah, 0xa270, tmpVal); REG_WRITE(ah, 0xa270, tmpVal);
/* Enable OLPC for chain 1 */
tmpVal = REG_READ(ah, 0xb270); tmpVal = REG_READ(ah, 0xb270);
tmpVal = tmpVal & 0xFCFFFFFF; tmpVal = tmpVal & 0xFCFFFFFF;
tmpVal = tmpVal | (0x3 << 24); tmpVal = tmpVal | (0x3 << 24);
REG_WRITE(ah, 0xb270, tmpVal); REG_WRITE(ah, 0xb270, tmpVal);
/* Write the OLPC ref power for chain 0 */
if (chain == 0) { if (chain == 0) {
tmpVal = REG_READ(ah, 0xa398); tmpVal = REG_READ(ah, 0xa398);
tmpVal = tmpVal & 0xff00ffff; tmpVal = tmpVal & 0xff00ffff;
...@@ -427,6 +438,8 @@ static void ar9287_eeprom_olpc_set_pdadcs(struct ath_hw *ah, ...@@ -427,6 +438,8 @@ static void ar9287_eeprom_olpc_set_pdadcs(struct ath_hw *ah,
REG_WRITE(ah, 0xa398, tmpVal); REG_WRITE(ah, 0xa398, tmpVal);
} }
/* Write the OLPC ref power for chain 1 */
if (chain == 1) { if (chain == 1) {
tmpVal = REG_READ(ah, 0xb398); tmpVal = REG_READ(ah, 0xb398);
tmpVal = tmpVal & 0xff00ffff; tmpVal = tmpVal & 0xff00ffff;
...@@ -436,11 +449,10 @@ static void ar9287_eeprom_olpc_set_pdadcs(struct ath_hw *ah, ...@@ -436,11 +449,10 @@ static void ar9287_eeprom_olpc_set_pdadcs(struct ath_hw *ah,
} }
} }
static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah, static void ath9k_hw_set_ar9287_power_cal_table(struct ath_hw *ah,
struct ath9k_channel *chan, struct ath9k_channel *chan,
int16_t *pTxPowerIndexOffset) int16_t *pTxPowerIndexOffset)
{ {
struct ath_common *common = ath9k_hw_common(ah);
struct cal_data_per_freq_ar9287 *pRawDataset; struct cal_data_per_freq_ar9287 *pRawDataset;
struct cal_data_op_loop_ar9287 *pRawDatasetOpenLoop; struct cal_data_op_loop_ar9287 *pRawDatasetOpenLoop;
u8 *pCalBChans = NULL; u8 *pCalBChans = NULL;
...@@ -454,8 +466,10 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah, ...@@ -454,8 +466,10 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah,
u32 reg32, regOffset, regChainOffset; u32 reg32, regOffset, regChainOffset;
int16_t modalIdx, diff = 0; int16_t modalIdx, diff = 0;
struct ar9287_eeprom *pEepData = &ah->eeprom.map9287; struct ar9287_eeprom *pEepData = &ah->eeprom.map9287;
modalIdx = IS_CHAN_2GHZ(chan) ? 1 : 0; modalIdx = IS_CHAN_2GHZ(chan) ? 1 : 0;
xpdMask = pEepData->modalHeader.xpdGain; xpdMask = pEepData->modalHeader.xpdGain;
if ((pEepData->baseEepHeader.version & AR9287_EEP_VER_MINOR_MASK) >= if ((pEepData->baseEepHeader.version & AR9287_EEP_VER_MINOR_MASK) >=
AR9287_EEP_MINOR_VER_2) AR9287_EEP_MINOR_VER_2)
pdGainOverlap_t2 = pEepData->modalHeader.pdGainOverlap; pdGainOverlap_t2 = pEepData->modalHeader.pdGainOverlap;
...@@ -466,7 +480,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah, ...@@ -466,7 +480,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah,
if (IS_CHAN_2GHZ(chan)) { if (IS_CHAN_2GHZ(chan)) {
pCalBChans = pEepData->calFreqPier2G; pCalBChans = pEepData->calFreqPier2G;
numPiers = AR9287_NUM_2G_CAL_PIERS; numPiers = AR9287_NUM_2G_CAL_PIERS;
if (ath9k_hw_AR9287_get_eeprom(ah, EEP_OL_PWRCTRL)) { if (ath9k_hw_ar9287_get_eeprom(ah, EEP_OL_PWRCTRL)) {
pRawDatasetOpenLoop = pRawDatasetOpenLoop =
(struct cal_data_op_loop_ar9287 *) (struct cal_data_op_loop_ar9287 *)
pEepData->calPierData2G[0]; pEepData->calPierData2G[0];
...@@ -475,6 +489,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah, ...@@ -475,6 +489,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah,
} }
numXpdGain = 0; numXpdGain = 0;
for (i = 1; i <= AR9287_PD_GAINS_IN_MASK; i++) { for (i = 1; i <= AR9287_PD_GAINS_IN_MASK; i++) {
if ((xpdMask >> (AR9287_PD_GAINS_IN_MASK - i)) & 1) { if ((xpdMask >> (AR9287_PD_GAINS_IN_MASK - i)) & 1) {
if (numXpdGain >= AR9287_NUM_PD_GAINS) if (numXpdGain >= AR9287_NUM_PD_GAINS)
...@@ -499,7 +514,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah, ...@@ -499,7 +514,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah,
if (pEepData->baseEepHeader.txMask & (1 << i)) { if (pEepData->baseEepHeader.txMask & (1 << i)) {
pRawDatasetOpenLoop = (struct cal_data_op_loop_ar9287 *) pRawDatasetOpenLoop = (struct cal_data_op_loop_ar9287 *)
pEepData->calPierData2G[i]; pEepData->calPierData2G[i];
if (ath9k_hw_AR9287_get_eeprom(ah, EEP_OL_PWRCTRL)) { if (ath9k_hw_ar9287_get_eeprom(ah, EEP_OL_PWRCTRL)) {
int8_t txPower; int8_t txPower;
ar9287_eeprom_get_tx_gain_index(ah, chan, ar9287_eeprom_get_tx_gain_index(ah, chan,
pRawDatasetOpenLoop, pRawDatasetOpenLoop,
...@@ -510,7 +525,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah, ...@@ -510,7 +525,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah,
pRawDataset = pRawDataset =
(struct cal_data_per_freq_ar9287 *) (struct cal_data_per_freq_ar9287 *)
pEepData->calPierData2G[i]; pEepData->calPierData2G[i];
ath9k_hw_get_AR9287_gain_boundaries_pdadcs( ath9k_hw_get_ar9287_gain_boundaries_pdadcs(
ah, chan, pRawDataset, ah, chan, pRawDataset,
pCalBChans, numPiers, pCalBChans, numPiers,
pdGainOverlap_t2, pdGainOverlap_t2,
...@@ -519,7 +534,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah, ...@@ -519,7 +534,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah,
} }
if (i == 0) { if (i == 0) {
if (!ath9k_hw_AR9287_get_eeprom( if (!ath9k_hw_ar9287_get_eeprom(
ah, EEP_OL_PWRCTRL)) { ah, EEP_OL_PWRCTRL)) {
REG_WRITE(ah, AR_PHY_TPCRG5 + REG_WRITE(ah, AR_PHY_TPCRG5 +
regChainOffset, regChainOffset,
...@@ -555,7 +570,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah, ...@@ -555,7 +570,7 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah,
AR9287_NUM_PDADC_VALUES-diff]; AR9287_NUM_PDADC_VALUES-diff];
} }
if (!ath9k_hw_AR9287_get_eeprom(ah, EEP_OL_PWRCTRL)) { if (!ath9k_hw_ar9287_get_eeprom(ah, EEP_OL_PWRCTRL)) {
regOffset = AR_PHY_BASE + (672 << 2) + regOffset = AR_PHY_BASE + (672 << 2) +
regChainOffset; regChainOffset;
for (j = 0; j < 32; j++) { for (j = 0; j < 32; j++) {
...@@ -568,27 +583,6 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah, ...@@ -568,27 +583,6 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah,
((pdadcValues[4*j + 3] ((pdadcValues[4*j + 3]
& 0xFF) << 24) ; & 0xFF) << 24) ;
REG_WRITE(ah, regOffset, reg32); REG_WRITE(ah, regOffset, reg32);
ath_print(common, ATH_DBG_EEPROM,
"PDADC (%d,%4x): %4.4x "
"%8.8x\n",
i, regChainOffset, regOffset,
reg32);
ath_print(common, ATH_DBG_EEPROM,
"PDADC: Chain %d | "
"PDADC %3d Value %3d | "
"PDADC %3d Value %3d | "
"PDADC %3d Value %3d | "
"PDADC %3d Value %3d |\n",
i, 4 * j, pdadcValues[4 * j],
4 * j + 1,
pdadcValues[4 * j + 1],
4 * j + 2,
pdadcValues[4 * j + 2],
4 * j + 3,
pdadcValues[4 * j + 3]);
regOffset += 4; regOffset += 4;
} }
} }
...@@ -598,13 +592,17 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah, ...@@ -598,13 +592,17 @@ static void ath9k_hw_set_AR9287_power_cal_table(struct ath_hw *ah,
*pTxPowerIndexOffset = 0; *pTxPowerIndexOffset = 0;
} }
static void ath9k_hw_set_AR9287_power_per_rate_table(struct ath_hw *ah, static void ath9k_hw_set_ar9287_power_per_rate_table(struct ath_hw *ah,
struct ath9k_channel *chan, int16_t *ratesArray, u16 cfgCtl, struct ath9k_channel *chan,
u16 AntennaReduction, u16 twiceMaxRegulatoryPower, int16_t *ratesArray,
u16 cfgCtl,
u16 AntennaReduction,
u16 twiceMaxRegulatoryPower,
u16 powerLimit) u16 powerLimit)
{ {
#define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6
#define REDUCE_SCALED_POWER_BY_THREE_CHAIN 10 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 10
struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER; u16 twiceMaxEdgePower = AR5416_MAX_RATE_POWER;
static const u16 tpScaleReductionTable[5] = static const u16 tpScaleReductionTable[5] =
...@@ -659,6 +657,7 @@ static void ath9k_hw_set_AR9287_power_per_rate_table(struct ath_hw *ah, ...@@ -659,6 +657,7 @@ static void ath9k_hw_set_AR9287_power_per_rate_table(struct ath_hw *ah,
if (IS_CHAN_2GHZ(chan)) { if (IS_CHAN_2GHZ(chan)) {
numCtlModes = numCtlModes =
ARRAY_SIZE(ctlModesFor11g) - SUB_NUM_CTL_MODES_AT_2G_40; ARRAY_SIZE(ctlModesFor11g) - SUB_NUM_CTL_MODES_AT_2G_40;
pCtlMode = ctlModesFor11g; pCtlMode = ctlModesFor11g;
ath9k_hw_get_legacy_target_powers(ah, chan, ath9k_hw_get_legacy_target_powers(ah, chan,
...@@ -829,7 +828,7 @@ static void ath9k_hw_set_AR9287_power_per_rate_table(struct ath_hw *ah, ...@@ -829,7 +828,7 @@ static void ath9k_hw_set_AR9287_power_per_rate_table(struct ath_hw *ah,
#undef REDUCE_SCALED_POWER_BY_THREE_CHAIN #undef REDUCE_SCALED_POWER_BY_THREE_CHAIN
} }
static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah, static void ath9k_hw_ar9287_set_txpower(struct ath_hw *ah,
struct ath9k_channel *chan, u16 cfgCtl, struct ath9k_channel *chan, u16 cfgCtl,
u8 twiceAntennaReduction, u8 twiceAntennaReduction,
u8 twiceMaxRegulatoryPower, u8 twiceMaxRegulatoryPower,
...@@ -837,6 +836,7 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah, ...@@ -837,6 +836,7 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah,
{ {
#define INCREASE_MAXPOW_BY_TWO_CHAIN 6 #define INCREASE_MAXPOW_BY_TWO_CHAIN 6
#define INCREASE_MAXPOW_BY_THREE_CHAIN 10 #define INCREASE_MAXPOW_BY_THREE_CHAIN 10
struct ath_common *common = ath9k_hw_common(ah); struct ath_common *common = ath9k_hw_common(ah);
struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah); struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
struct ar9287_eeprom *pEepData = &ah->eeprom.map9287; struct ar9287_eeprom *pEepData = &ah->eeprom.map9287;
...@@ -852,13 +852,13 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah, ...@@ -852,13 +852,13 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah,
AR9287_EEP_MINOR_VER_2) AR9287_EEP_MINOR_VER_2)
ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc; ht40PowerIncForPdadc = pModal->ht40PowerIncForPdadc;
ath9k_hw_set_AR9287_power_per_rate_table(ah, chan, ath9k_hw_set_ar9287_power_per_rate_table(ah, chan,
&ratesArray[0], cfgCtl, &ratesArray[0], cfgCtl,
twiceAntennaReduction, twiceAntennaReduction,
twiceMaxRegulatoryPower, twiceMaxRegulatoryPower,
powerLimit); powerLimit);
ath9k_hw_set_AR9287_power_cal_table(ah, chan, &txPowerIndexOffset); ath9k_hw_set_ar9287_power_cal_table(ah, chan, &txPowerIndexOffset);
for (i = 0; i < ARRAY_SIZE(ratesArray); i++) { for (i = 0; i < ARRAY_SIZE(ratesArray); i++) {
ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]); ratesArray[i] = (int16_t)(txPowerIndexOffset + ratesArray[i]);
...@@ -909,7 +909,7 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah, ...@@ -909,7 +909,7 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah,
| ATH9K_POW_SM(ratesArray[rateHt20_4], 0)); | ATH9K_POW_SM(ratesArray[rateHt20_4], 0));
if (IS_CHAN_HT40(chan)) { if (IS_CHAN_HT40(chan)) {
if (ath9k_hw_AR9287_get_eeprom(ah, EEP_OL_PWRCTRL)) { if (ath9k_hw_ar9287_get_eeprom(ah, EEP_OL_PWRCTRL)) {
REG_WRITE(ah, AR_PHY_POWER_TX_RATE7, REG_WRITE(ah, AR_PHY_POWER_TX_RATE7,
ATH9K_POW_SM(ratesArray[rateHt40_3], 24) ATH9K_POW_SM(ratesArray[rateHt40_3], 24)
| ATH9K_POW_SM(ratesArray[rateHt40_2], 16) | ATH9K_POW_SM(ratesArray[rateHt40_2], 16)
...@@ -965,12 +965,10 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah, ...@@ -965,12 +965,10 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah,
case 1: case 1:
break; break;
case 2: case 2:
regulatory->max_power_level += regulatory->max_power_level += INCREASE_MAXPOW_BY_TWO_CHAIN;
INCREASE_MAXPOW_BY_TWO_CHAIN;
break; break;
case 3: case 3:
regulatory->max_power_level += regulatory->max_power_level += INCREASE_MAXPOW_BY_THREE_CHAIN;
INCREASE_MAXPOW_BY_THREE_CHAIN;
break; break;
default: default:
ath_print(common, ATH_DBG_EEPROM, ath_print(common, ATH_DBG_EEPROM,
...@@ -979,12 +977,12 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah, ...@@ -979,12 +977,12 @@ static void ath9k_hw_AR9287_set_txpower(struct ath_hw *ah,
} }
} }
static void ath9k_hw_AR9287_set_addac(struct ath_hw *ah, static void ath9k_hw_ar9287_set_addac(struct ath_hw *ah,
struct ath9k_channel *chan) struct ath9k_channel *chan)
{ {
} }
static void ath9k_hw_AR9287_set_board_values(struct ath_hw *ah, static void ath9k_hw_ar9287_set_board_values(struct ath_hw *ah,
struct ath9k_channel *chan) struct ath9k_channel *chan)
{ {
struct ar9287_eeprom *eep = &ah->eeprom.map9287; struct ar9287_eeprom *eep = &ah->eeprom.map9287;
...@@ -1125,13 +1123,13 @@ static void ath9k_hw_AR9287_set_board_values(struct ath_hw *ah, ...@@ -1125,13 +1123,13 @@ static void ath9k_hw_AR9287_set_board_values(struct ath_hw *ah,
pModal->xpaBiasLvl); pModal->xpaBiasLvl);
} }
static u8 ath9k_hw_AR9287_get_num_ant_config(struct ath_hw *ah, static u8 ath9k_hw_ar9287_get_num_ant_config(struct ath_hw *ah,
enum ieee80211_band freq_band) enum ieee80211_band freq_band)
{ {
return 1; return 1;
} }
static u16 ath9k_hw_AR9287_get_eeprom_antenna_cfg(struct ath_hw *ah, static u16 ath9k_hw_ar9287_get_eeprom_antenna_cfg(struct ath_hw *ah,
struct ath9k_channel *chan) struct ath9k_channel *chan)
{ {
struct ar9287_eeprom *eep = &ah->eeprom.map9287; struct ar9287_eeprom *eep = &ah->eeprom.map9287;
...@@ -1140,11 +1138,12 @@ static u16 ath9k_hw_AR9287_get_eeprom_antenna_cfg(struct ath_hw *ah, ...@@ -1140,11 +1138,12 @@ static u16 ath9k_hw_AR9287_get_eeprom_antenna_cfg(struct ath_hw *ah,
return pModal->antCtrlCommon & 0xFFFF; return pModal->antCtrlCommon & 0xFFFF;
} }
static u16 ath9k_hw_AR9287_get_spur_channel(struct ath_hw *ah, static u16 ath9k_hw_ar9287_get_spur_channel(struct ath_hw *ah,
u16 i, bool is2GHz) u16 i, bool is2GHz)
{ {
#define EEP_MAP9287_SPURCHAN \ #define EEP_MAP9287_SPURCHAN \
(ah->eeprom.map9287.modalHeader.spurChans[i].spurChan) (ah->eeprom.map9287.modalHeader.spurChans[i].spurChan)
struct ath_common *common = ath9k_hw_common(ah); struct ath_common *common = ath9k_hw_common(ah);
u16 spur_val = AR_NO_SPUR; u16 spur_val = AR_NO_SPUR;
...@@ -1171,15 +1170,15 @@ static u16 ath9k_hw_AR9287_get_spur_channel(struct ath_hw *ah, ...@@ -1171,15 +1170,15 @@ static u16 ath9k_hw_AR9287_get_spur_channel(struct ath_hw *ah,
} }
const struct eeprom_ops eep_ar9287_ops = { const struct eeprom_ops eep_ar9287_ops = {
.check_eeprom = ath9k_hw_AR9287_check_eeprom, .check_eeprom = ath9k_hw_ar9287_check_eeprom,
.get_eeprom = ath9k_hw_AR9287_get_eeprom, .get_eeprom = ath9k_hw_ar9287_get_eeprom,
.fill_eeprom = ath9k_hw_AR9287_fill_eeprom, .fill_eeprom = ath9k_hw_ar9287_fill_eeprom,
.get_eeprom_ver = ath9k_hw_AR9287_get_eeprom_ver, .get_eeprom_ver = ath9k_hw_ar9287_get_eeprom_ver,
.get_eeprom_rev = ath9k_hw_AR9287_get_eeprom_rev, .get_eeprom_rev = ath9k_hw_ar9287_get_eeprom_rev,
.get_num_ant_config = ath9k_hw_AR9287_get_num_ant_config, .get_num_ant_config = ath9k_hw_ar9287_get_num_ant_config,
.get_eeprom_antenna_cfg = ath9k_hw_AR9287_get_eeprom_antenna_cfg, .get_eeprom_antenna_cfg = ath9k_hw_ar9287_get_eeprom_antenna_cfg,
.set_board_values = ath9k_hw_AR9287_set_board_values, .set_board_values = ath9k_hw_ar9287_set_board_values,
.set_addac = ath9k_hw_AR9287_set_addac, .set_addac = ath9k_hw_ar9287_set_addac,
.set_txpower = ath9k_hw_AR9287_set_txpower, .set_txpower = ath9k_hw_ar9287_set_txpower,
.get_spur_channel = ath9k_hw_AR9287_get_spur_channel .get_spur_channel = ath9k_hw_ar9287_get_spur_channel
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment