28 u8 *calChans,
u16 availPiers,
u8 *pwr,
u8 *pcdacIdx)
31 u16 idxL = 0, idxR = 0, numPiers;
37 for (numPiers = 0; numPiers < availPiers; numPiers++)
43 calChans, numPiers, &idxL, &idxR);
45 pcdac = rawDatasetOpLoop[idxL].
pcdac[0][0];
46 *pwr = rawDatasetOpLoop[idxL].
pwrPdg[0][0];
48 pcdac = rawDatasetOpLoop[idxR].
pcdac[0][0];
49 *pwr = (rawDatasetOpLoop[idxL].
pwrPdg[0][0] +
50 rawDatasetOpLoop[idxR].
pwrPdg[0][0])/2;
53 while (pcdac >
ah->originalGain[i] &&
79 pPDADCValues[i] = 0x0;
81 pPDADCValues[i] = 0xFF;
86 return ((
ah->eeprom.def.baseEepHeader.version >> 12) & 0xF);
91 return ((
ah->eeprom.def.baseEepHeader.version) & 0xFFF);
94 #define SIZE_EEPROM_DEF (sizeof(struct ar5416_eeprom_def) / sizeof(u16)) 99 u16 *eep_data = (
u16 *)&
ah->eeprom.def;
101 int ar5416_eep_start_loc = 0x100;
107 "Unable to read eeprom region\n");
117 u16 *eep_data = (
u16 *)&
ah->eeprom.def;
130 "Reading from EEPROM, not flash\n");
139 #undef SIZE_EEPROM_DEF 152 DBG(
"ath9k: Reading Magic # failed\n");
158 "Read Magic = 0x%04X\n",
magic);
166 eepdata = (
u16 *) (&
ah->eeprom);
175 "Invalid EEPROM Magic. Endianness mismatch.\n");
181 DBG2(
"ath9k: need_swap = %s.\n",
182 need_swap ?
"True" :
"False");
185 el =
swab16(
ah->eeprom.def.baseEepHeader.length);
187 el =
ah->eeprom.def.baseEepHeader.length;
192 el = el /
sizeof(
u16);
194 eepdata = (
u16 *)(&
ah->eeprom);
196 for (i = 0; i < el; i++)
204 "EEPROM Endianness is not native.. Changing.\n");
240 for (i = 0; i < 3; i++) {
254 DBG(
"ath9k: Bad EEPROM checksum 0x%x or revision 0x%04x\n",
255 sum,
ah->eep_ops->get_eeprom_ver(
ah));
263 ah->need_an_top2_fixup = 1;
353 u8 txRxAttenLocal,
int regChainOffset,
int i)
375 |
SM(pModal-> bswMargin[i],
411 int i, regChainOffset;
426 (
ah->rxchainmask == 5 ||
ah->txchainmask == 5) && (i != 0))
427 regChainOffset = (i == 1) ? 0x2000 : 0x1000;
429 regChainOffset = i * 0x1000;
579 #define XPA_LVL_FREQ(cnt) (pModal->xpaBiasLvlFreq[cnt]) 595 u16 resetFreqBin, freqBin, freqCount = 0;
607 while (freqCount < 3) {
612 if (resetFreqBin >= freqBin)
622 7, 1) & (~0x18)) | biaslevel << 3;
625 6, 1) & (~0xc0)) | biaslevel << 6;
633 u16 pdGainOverlap_t2,
656 for (
k = 0;
k < numXpdGain;
k++)
657 gb[
k] = (
u16)(gb[
k] - *diff);
664 for (
k = 0;
k < numXpdGain;
k++)
676 #define NUM_PDADC(diff) (AR5416_NUM_PDADC_VALUES - diff) 688 pdadcValues[
k] = pdadcValues[
k + diff];
693 pdadcValues[
k] = pdadcValues[
NUM_PDADC(diff)];
704 #define SM_PD_GAIN(x) SM(0x38, AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_##x) 705 #define SM_PDGAIN_B(x, y) \ 706 SM((gainBoundaries[x]), AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_##y) 710 u16 pdGainOverlap_t2;
715 u16 numXpdGain, xpdMask;
717 u32 reg32, regOffset, regChainOffset;
746 pRawDataset)->vpdPdg[0][0];
755 xpdGainValues[numXpdGain] =
762 (numXpdGain - 1) & 0x3);
772 (
ah->rxchainmask == 5 ||
ah->txchainmask == 5) &&
774 regChainOffset = (i == 1) ? 0x2000 : 0x1000;
776 regChainOffset = i * 0x1000;
791 pCalBChans, numPiers, &txPower, &pcdacIdx);
793 txPower/2, pdadcValues);
797 pCalBChans, numPiers,
837 regOffset =
AR_PHY_BASE + (672 << 2) + regChainOffset;
838 for (j = 0; j < 32; j++) {
839 reg32 = ((pdadcValues[4 * j + 0] & 0xFF) << 0) |
840 ((pdadcValues[4 * j + 1] & 0xFF) << 8) |
841 ((pdadcValues[4 * j + 2] & 0xFF) << 16)|
842 ((pdadcValues[4 * j + 3] & 0xFF) << 24);
846 "PDADC (%d,%4x): %4.4x %8.8x\n",
847 i, regChainOffset, regOffset,
850 "PDADC: Chain %d | PDADC %3d " 851 "Value %3d | PDADC %3d Value %3d | " 852 "PDADC %3d Value %3d | PDADC %3d " 854 i, 4 * j, pdadcValues[4 * j],
855 4 * j + 1, pdadcValues[4 * j + 1],
856 4 * j + 2, pdadcValues[4 * j + 2],
857 4 * j + 3, pdadcValues[4 * j + 3]);
865 *pTxPowerIndexOffset = 0;
874 u16 AntennaReduction,
875 u16 twiceMaxRegulatoryPower,
878 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 879 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 9 884 static const u16 tpScaleReductionTable[5] =
894 0, { 0, 0, 0, 0} }, targetPowerCckExt = {
900 u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
901 static const u16 ctlModesFor11a[] = {
904 static const u16 ctlModesFor11g[] = {
913 u16 twiceMinEdgePower;
915 tx_chainmask =
ah->txchainmask;
919 twiceLargestAntenna =
max(
925 twiceLargestAntenna =
max((
u8)twiceLargestAntenna,
929 twiceLargestAntenna = (
int16_t)
min(AntennaReduction -
930 twiceLargestAntenna, 0);
932 maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
935 maxRegAllowedPower -=
936 (tpScaleReductionTable[(regulatory->
tp_scale)] * 2);
939 scaledPower =
min(powerLimit, maxRegAllowedPower);
961 pCtlMode = ctlModesFor11g;
966 &targetPowerCck, 4, 0);
970 &targetPowerOfdm, 4, 0);
974 &targetPowerHt20, 8, 0);
981 &targetPowerHt40, 8, 1);
985 &targetPowerCckExt, 4, 1);
989 &targetPowerOfdmExt, 4, 1);
994 pCtlMode = ctlModesFor11a;
999 &targetPowerOfdm, 4, 0);
1003 &targetPowerHt20, 8, 0);
1010 &targetPowerHt40, 8, 1);
1014 &targetPowerOfdmExt, 4, 1);
1018 for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
1019 int isHt40CtlMode = (pCtlMode[ctlMode] ==
CTL_5GHT40) ||
1028 if (
ah->eep_ops->get_eeprom_ver(
ah) == 14 &&
1029 ah->eep_ops->get_eeprom_rev(
ah) <= 2)
1039 rep = &(pEepData->
ctlData[i]);
1046 twiceMaxEdgePower =
min(twiceMaxEdgePower,
1049 twiceMaxEdgePower = twiceMinEdgePower;
1055 minCtlPower =
min(twiceMaxEdgePower, scaledPower);
1057 switch (pCtlMode[ctlMode]) {
1060 targetPowerCck.
tPow2x[i] =
1068 targetPowerOfdm.
tPow2x[i] =
1076 targetPowerHt20.
tPow2x[i] =
1082 targetPowerCckExt.tPow2x[0] =
min((
u16)
1083 targetPowerCckExt.tPow2x[0],
1089 targetPowerOfdmExt.
tPow2x[0],
1095 targetPowerHt40.
tPow2x[i] =
1107 targetPowerOfdm.
tPow2x[0];
1119 targetPowerCck.
tPow2x[1];
1121 targetPowerCck.
tPow2x[2];
1123 targetPowerCck.
tPow2x[3];
1128 targetPowerHt40.
tPow2x[i];
1135 targetPowerCckExt.tPow2x[0];
1143 u8 twiceAntennaReduction,
1144 u8 twiceMaxRegulatoryPower,
1147 #define RT_AR_DELTA(x) (ratesArray[x] - cck_ofdm_delta) 1153 int16_t txPowerIndexOffset = 0;
1155 unsigned int i, cck_ofdm_delta = 0;
1157 memset(ratesArray, 0,
sizeof(ratesArray));
1165 &ratesArray[0], cfgCtl,
1166 twiceAntennaReduction,
1167 twiceMaxRegulatoryPower,
1173 for (i = 0; i <
ARRAY_SIZE(ratesArray); i++) {
1174 ratesArray[i] = (
int16_t)(txPowerIndexOffset + ratesArray[i]);
1203 "Invalid chainmask configuration\n");
1214 pwr_table_offset =
ah->eep_ops->get_eeprom(
ah,
1216 ratesArray[i] -= pwr_table_offset * 2;
1314 #define EEP_DEF_SPURCHAN \ 1315 (ah->eeprom.def.modalHeader[is2GHz].spurChans[i].spurChan) 1320 "Getting spur idx:%d is2Ghz:%d val:%x\n",
1321 i, is2GHz,
ah->config.spurchans[i][is2GHz]);
1323 switch (
ah->config.spurmode) {
1327 spur_val =
ah->config.spurchans[i][is2GHz];
1329 "Getting spur val from new loc. %d\n", spur_val);
1338 #undef EEP_DEF_SPURCHAN
#define AR_PHY_DESIRED_SZ_PGA
#define AR_PHY_RF_CTL4_FRAME_XPAA_ON
void ath9k_hw_get_target_powers(struct ath_hw *ah, struct ath9k_channel *chan, struct cal_target_power_ht *powInfo, u16 numChannels, struct cal_target_power_ht *pNewPower, u16 numRates, int isHt40Target)
#define AR5416_NUM_PD_GAINS
#define AR_PHY_POWER_TX_RATE5
#define AR_PHY_RF_CTL4_TX_END_XPAB_OFF
#define EINVAL
Invalid argument.
#define AR_AN_RF2G1_CH1_DB_S
#define AR5416_EEP_VER_MINOR_MASK
#define AR_AN_RF2G1_CH0_OB_S
static void ath9k_hw_def_set_addac(struct ath_hw *ah, struct ath9k_channel *chan)
#define AR_PHY_POWER_TX_RATE3
#define AR_SREV_9280_20_OR_LATER(_ah)
#define ar5416_get_ntxchains(_txchainmask)
#define AR5416_NUM_5G_CAL_PIERS
#define AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF
#define AR_PHY_POWER_TX_RATE2
#define AR_PHY_TX_PWRCTRL9
#define AR9280_TX_GAIN_TABLE_SIZE
#define AR_AN_RF5G1_CH1_DB5
#define AR5416_EEPROM_MAGIC_OFFSET
#define XPA_LVL_FREQ(cnt)
#define AR_PHY_GAIN_2GHZ_BSW_ATTEN
#define AR_AN_TOP2_LOCALBIAS
#define AR_EEPROM_MODAL_SPURS
static void ath9k_get_txgain_index(struct ath_hw *ah, struct ath9k_channel *chan, struct calDataPerFreqOpLoop *rawDatasetOpLoop, u8 *calChans, u16 availPiers, u8 *pwr, u8 *pcdacIdx)
#define INI_RA(iniarray, row, column)
#define REGWRITE_BUFFER_FLUSH(_ah)
uint8_t size
Entry size (in 32-bit words)
#define SUB_NUM_CTL_MODES_AT_5G_40
#define AR_PHY_POWER_TX_RATE4
struct cal_ctl_edges ctlEdges[AR5416_MAX_CHAINS][AR5416_NUM_BAND_EDGES]
#define AR5416_EEP_MINOR_VER_20
#define AR_PHY_TPCRG1_PD_GAIN_3
#define AR_AN_TOP2_XPABIAS_LVL_S
#define AR_PHY_GAIN_2GHZ_BSW_MARGIN
#define AR_SREV_5416_20_OR_LATER(_ah)
#define ATH9K_POW_SM(_r, _s)
u8 calFreqPier5G[AR5416_NUM_5G_CAL_PIERS]
#define REDUCE_SCALED_POWER_BY_THREE_CHAIN
static int ath9k_hw_def_get_eeprom_rev(struct ath_hw *ah)
#define AR_PHY_EXT_CCA_THRESH62
#define AR5416_NUM_5G_20_TARGET_POWERS
const struct eeprom_ops eep_def_ops
#define AR9280_PHY_CCA_THRESH62
static void ath9k_hw_def_set_gain(struct ath_hw *ah, struct modal_eep_header *pModal, struct ar5416_eeprom_def *eep, u8 txRxAttenLocal, int regChainOffset, int i)
#define AR_PHY_RXGAIN_TXRX_ATTEN
#define AR_AN_RF2G1_CH0_DB
#define AR_PHY_POWER_TX_RATE1
struct cal_target_power_leg calTargetPower2G[AR5416_NUM_2G_20_TARGET_POWERS]
#define REG_RMW_FIELD(_a, _r, _f, _v)
#define AR5416_PD_GAINS_IN_MASK
#define AR_AN_TOP1_DACIPMODE
#define AR_SREV_9280_20(_ah)
#define AR_AN_RF5G1_CH0_OB5
#define AR_PHY_DESIRED_SZ
#define AR5416_EEP_MINOR_VER_7
#define AR5416_NUM_5G_40_TARGET_POWERS
#define AR_SREV_VERSION_9160
#define AR_PHY_GAIN_2GHZ_XATTEN2_DB
#define AR_PHY_SWITCH_COM
#define LNA_CTL_FORCE_XPA
static u32 ath9k_hw_def_get_eeprom(struct ath_hw *ah, enum eeprom_param param)
#define AR_PHY_FRAME_CTL_TX_CLIP
#define AR_PHY_CCK_TX_CTRL
static int16_t ath9k_change_gain_boundary_setting(struct ath_hw *ah, u16 *gb, u16 numXpdGain, u16 pdGainOverlap_t2, int8_t pwr_table_offset, int16_t *diff)
#define AR_PHY_TX_END_DATA_START
#define AR_PHY_POWER_TX_SUB
#define AR_PHY_GAIN_2GHZ_XATTEN1_DB
void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah, struct ath9k_channel *chan, void *pRawDataSet, u8 *bChans, u16 availPiers, u16 tPdGainOverlap, u16 *pPdGainBoundaries, u8 *pPDADCValues, u16 numXpdGains)
#define AR_AN_RF5G1_CH0_DB5_S
#define AR_AN_TOP2_XPABIAS_LVL
#define AR_PHY_TIMING_CTRL4(_i)
#define AR_PHY_GAIN_2GHZ_XATTEN2_MARGIN
static struct ath_regulatory * ath9k_hw_regulatory(struct ath_hw *ah)
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
static int ath9k_hw_def_check_eeprom(struct ath_hw *ah)
#define AR_PHY_TX_END_TO_A2_RX_ON
#define AR_PHY_SETTLING_SWITCH
#define AR_AN_RF5G1_CH1_OB5
#define AR_PHY_GAIN_2GHZ_RXTX_MARGIN
#define SPUR_ENABLE_EEPROM
struct cal_target_power_ht calTargetPower5GHT20[AR5416_NUM_5G_20_TARGET_POWERS]
static int ath9k_hw_def_get_eeprom_ver(struct ath_hw *ah)
#define AR_PHY_TX_PWRCTRL_INIT_TX_GAIN
#define AR_PHY_CCK_TX_CTRL_TX_DAC_SCALE_CCK
#define REDUCE_SCALED_POWER_BY_TWO_CHAIN
#define AR_PHY_TX_DESIRED_SCALE_CCK
static void ath9k_hw_def_set_txpower(struct ath_hw *ah, struct ath9k_channel *chan, u16 cfgCtl, u8 twiceAntennaReduction, u8 twiceMaxRegulatoryPower, u8 powerLimit, int test)
#define ath9k_hw_use_flash(_ah)
#define AR_PHY_TPCRG1_PD_GAIN_2
#define AR5416_NUM_PDADC_VALUES
static u16 ath9k_hw_def_get_spur_channel(struct ath_hw *ah, u16 i, int is2GHz)
int ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize, u16 *indexL, u16 *indexR)
#define AR5416_NUM_2G_CCK_TARGET_POWERS
#define AR_PHY_TPCRG1_PD_GAIN_1
#define AR5416_EEP_NO_BACK_VER
#define AR5416_NUM_BAND_EDGES
int ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data)
#define AR_AN_RF2G1_CH1_OB_S
u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower, int is2GHz, int num_band_edges)
struct cal_ctl_data ctlData[AR5416_NUM_CTLS]
#define AR_PHY_GAIN_2GHZ_XATTEN1_MARGIN
#define AR5416_BCHAN_UNUSED
#define AR_PHY_TX_PWRCTRL6_1
#define AR_SREV_9280(_ah)
struct cal_target_power_leg calTargetPower5G[AR5416_NUM_5G_20_TARGET_POWERS]
struct hv_monitor_parameter param[4][32]
Parameters.
#define AR_AN_RF2G1_CH0_DB_S
#define AR_PHY_TX_PWRCTRL_ERR_EST_MODE
#define AR_AN_RF2G1_CH1_OB
#define AR5416_EEP_MINOR_VER_21
#define AR5416_NUM_2G_20_TARGET_POWERS
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
#define AR_AN_RF5G1_CH1_DB5_S
#define AR_PHY_EXT_CCA0_THRESH62
u8 calFreqPier2G[AR5416_NUM_2G_CAL_PIERS]
#define OLC_FOR_AR9280_20_LATER
void ath9k_hw_analog_shift_rmw(struct ath_hw *ah, u32 reg, u32 mask, u32 shift, u32 val)
static void ath9k_adjust_pdadc_values(struct ath_hw *ah, int8_t pwr_table_offset, int16_t diff, u8 *pdadcValues)
static void ath9k_olc_get_pdadcs(struct ath_hw *ah, u32 initTxGain, int txPower, u8 *pPDADCValues)
struct modal_eep_header modalHeader[2]
uint16_t magic
Magic signature.
#define AR_PHY_FORCE_XPA_CFG
static const uint32_t k[64]
MD5 constants.
#define AR5416_NUM_2G_40_TARGET_POWERS
struct ib_cm_common common
int(* check_eeprom)(struct ath_hw *hw)
#define REG_READ(_ah, _reg)
#define AR_AN_RF5G1_CH0_OB5_S
void ath9k_hw_get_legacy_target_powers(struct ath_hw *ah, struct ath9k_channel *chan, struct cal_target_power_leg *powInfo, u16 numChannels, struct cal_target_power_leg *pNewPower, u16 numRates, int isExtTarget)
#define INCREASE_MAXPOW_BY_TWO_CHAIN
#define AR5416_EEP_MINOR_VER_3
#define AR5416_PWR_TABLE_OFFSET_DB
#define AR5416_MAX_CHAINS
#define SUB_NUM_CTL_MODES_AT_2G_40
struct cal_target_power_ht calTargetPower5GHT40[AR5416_NUM_5G_40_TARGET_POWERS]
struct cal_target_power_ht calTargetPower2GHT20[AR5416_NUM_2G_20_TARGET_POWERS]
#define AR9280_PHY_RXGAIN_TXRX_ATTEN
static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah, struct ath9k_channel *chan, int16_t *ratesArray, u16 cfgCtl, u16 AntennaReduction, u16 twiceMaxRegulatoryPower, u16 powerLimit)
struct cal_target_power_leg calTargetPowerCck[AR5416_NUM_2G_CCK_TARGET_POWERS]
#define AR_PHY_TPCRG5_PD_GAIN_OVERLAP
#define INCREASE_MAXPOW_BY_THREE_CHAIN
void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data, int eep_start_loc, int size)
#define AR_AN_RF2G1_CH0_OB
#define AR_PHY_TX_END_PA_ON
#define REG_WRITE(_ah, _reg, _val)
u8 ctlIndex[AR5416_NUM_CTLS]
#define AR_AN_TOP2_LOCALBIAS_S
static void ath9k_hw_def_set_board_values(struct ath_hw *ah, struct ath9k_channel *chan)
#define AR5416_NUM_2G_CAL_PIERS
#define AR5416_EEPROM_MAGIC
struct cal_data_per_freq calPierData5G[AR5416_MAX_CHAINS][AR5416_NUM_5G_CAL_PIERS]
static void ath9k_hw_set_def_power_cal_table(struct ath_hw *ah, struct ath9k_channel *chan, int16_t *pTxPowerIndexOffset)
void ath9k_hw_get_channel_centers(struct ath_hw *ah __unused, struct ath9k_channel *chan, struct chan_centers *centers)
#define AR_PHY_TX_PWRCTRL6_0
#define SPUR_ENABLE_IOCTL
uint16_t offset
Offset to command line.
#define AR_AN_RF2G1_CH1_DB
#define AR_PHY_SWITCH_CHAIN_0
#define AR_PHY_TX_PWRCTRL7
#define AR5416_EEP_MINOR_VER_22
#define AR5416_EEP_MINOR_VER_2
#define AR_PHY_POWER_TX_RATE9
struct cal_target_power_ht calTargetPower2GHT40[AR5416_NUM_2G_40_TARGET_POWERS]
#define AR_PHY_DESIRED_SZ_ADC
#define DBG(...)
Print a debugging message.
struct base_eep_header baseEepHeader
#define AR_PHY_RF_CTL4_TX_END_XPAA_OFF
#define AR9280_PHY_RXGAIN_TXRX_MARGIN
#define NULL
NULL pointer (VOID *)
#define AR_PHY_CCA_THRESH62
#define SM_PDGAIN_B(x, y)
#define AR_PHY_TPCRG1_NUM_PD_GAIN
#define AR_PHY_POWER_TX_RATE7
struct cal_data_per_freq calPierData2G[AR5416_MAX_CHAINS][AR5416_NUM_2G_CAL_PIERS]
#define ENABLE_REGWRITE_BUFFER(_ah)
#define AR5416_EEP_MINOR_VER_19
#define AR_PHY_POWER_TX_RATE8
static int ath9k_hw_def_fill_eeprom(struct ath_hw *ah)
if(natsemi->flags &NATSEMI_64BIT) return 1
static int __ath9k_hw_usb_def_fill_eeprom(struct ath_hw *ah)
#define AR_PHY_POWER_TX_RATE6
static int __ath9k_hw_def_fill_eeprom(struct ath_hw *ah)
#define AR_PHY_RF_CTL4_FRAME_XPAB_ON
void * memset(void *dest, int character, size_t len) __nonnull
#define AR_AN_RF5G1_CH1_OB5_S
#define LNA_CTL_LOCAL_BIAS
#define AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF
#define AR_AN_RF5G1_CH0_DB5