25 #define SIZE_EEPROM_AR9287 (sizeof(struct ar9287_eeprom) / sizeof(u16)) 29 return (
ah->eeprom.map9287.baseEepHeader.version >> 12) & 0xF;
34 return (
ah->eeprom.map9287.baseEepHeader.version) & 0xFFF;
44 eep_data = (
u16 *)eep;
50 "Unable to read eeprom region\n");
61 u16 *eep_data = (
u16 *)&
ah->eeprom.map9287;
75 "Reading from EEPROM, not flash\n");
86 u32 sum = 0, el, integer;
96 DBG(
"ath9k: Reading Magic # failed\n");
101 "Read Magic = 0x%04X\n",
magic);
108 eepdata = (
u16 *)(&
ah->eeprom);
117 "Invalid EEPROM Magic. Endianness mismatch.\n");
123 DBG2(
"ath9k: need_swap = %s.\n",
124 need_swap ?
"True" :
"False");
127 el =
swab16(
ah->eeprom.map9287.baseEepHeader.length);
129 el =
ah->eeprom.map9287.baseEepHeader.length;
134 el = el /
sizeof(
u16);
136 eepdata = (
u16 *)(&
ah->eeprom);
138 for (i = 0; i < el; i++)
182 DBG(
"ath9k: Bad EEPROM checksum 0x%x or revision 0x%04x\n",
183 sum,
ah->eep_ops->get_eeprom_ver(
ah));
249 u16 idxL = 0, idxR = 0, numPiers;
255 for (numPiers = 0; numPiers < availPiers; numPiers++) {
262 pCalChans, numPiers, &idxL, &idxR);
265 *pPwr = (
int8_t) pRawDatasetOpLoop[idxL].pwrPdg[0][0];
267 *pPwr = ((
int8_t) pRawDatasetOpLoop[idxL].pwrPdg[0][0] +
282 tmpVal = tmpVal & 0xFCFFFFFF;
283 tmpVal = tmpVal | (0x3 << 24);
289 tmpVal = tmpVal & 0xFCFFFFFF;
290 tmpVal = tmpVal | (0x3 << 24);
297 tmpVal = tmpVal & 0xff00ffff;
299 tmpVal = tmpVal | (a << 16);
307 tmpVal = tmpVal & 0xff00ffff;
309 tmpVal = tmpVal | (a << 16);
321 u16 pdGainOverlap_t2;
324 u16 numPiers = 0, i, j;
325 u16 numXpdGain, xpdMask;
327 u32 reg32, regOffset, regChainOffset, regval;
344 pRawDatasetOpenLoop =
346 ah->initPDADC = pRawDatasetOpenLoop->
vpdPdg[0][0];
357 xpdGainValues[numXpdGain] =
364 (numXpdGain - 1) & 0x3);
373 regChainOffset = i * 0x1000;
376 pRawDatasetOpenLoop =
383 pCalBChans, numPiers,
393 pCalBChans, numPiers,
406 regval =
SM(pdGainOverlap_t2,
408 |
SM(gainBoundaries[0],
410 |
SM(gainBoundaries[1],
412 |
SM(gainBoundaries[2],
414 |
SM(gainBoundaries[3],
430 pdadcValues[j] = pdadcValues[j+diff];
440 (672 << 2) + regChainOffset;
442 for (j = 0; j < 32; j++) {
443 reg32 = ((pdadcValues[4*j + 0] & 0xFF) << 0)
444 | ((pdadcValues[4*j + 1] & 0xFF) << 8)
445 | ((pdadcValues[4*j + 2] & 0xFF) << 16)
446 | ((pdadcValues[4*j + 3] & 0xFF) << 24);
456 *pTxPowerIndexOffset = 0;
463 u16 AntennaReduction,
464 u16 twiceMaxRegulatoryPower,
468 (((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == \ 469 pEepData->ctlIndex[i]) 472 (((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == \ 473 ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL)) 475 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 476 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 10 480 static const u16 tpScaleReductionTable[5] =
486 targetPowerCck = {0, {0, 0, 0, 0} };
488 targetPowerCckExt = {0, {0, 0, 0, 0} };
490 targetPowerHt40 = {0, {0, 0, 0, 0} };
491 u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
492 static const u16 ctlModesFor11g[] = {
501 u16 twiceMinEdgePower;
503 tx_chainmask =
ah->txchainmask;
510 twiceLargestAntenna = (
int16_t)
min((AntennaReduction) -
511 twiceLargestAntenna, 0);
517 maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
520 maxRegAllowedPower -=
521 (tpScaleReductionTable[(regulatory->
tp_scale)] * 2);
523 scaledPower =
min(powerLimit, maxRegAllowedPower);
545 scaledPower =
max((
u16)0, scaledPower);
555 pCtlMode = ctlModesFor11g;
560 &targetPowerCck, 4, 0);
564 &targetPowerOfdm, 4, 0);
568 &targetPowerHt20, 8, 0);
576 &targetPowerHt40, 8, 1);
580 &targetPowerCckExt, 4, 1);
584 &targetPowerOfdmExt, 4, 1);
588 for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
618 twiceMaxEdgePower =
min(twiceMaxEdgePower,
621 twiceMaxEdgePower = twiceMinEdgePower;
627 minCtlPower = (
u8)
min(twiceMaxEdgePower, scaledPower);
630 switch (pCtlMode[ctlMode]) {
632 for (i = 0; i <
ARRAY_SIZE(targetPowerCck.tPow2x); i++) {
633 targetPowerCck.tPow2x[i] =
634 (
u8)
min((
u16)targetPowerCck.tPow2x[i],
641 targetPowerOfdm.
tPow2x[i] =
649 targetPowerHt20.
tPow2x[i] =
655 targetPowerCckExt.tPow2x[0] =
656 (
u8)
min((
u16)targetPowerCckExt.tPow2x[0],
661 targetPowerOfdmExt.
tPow2x[0] =
668 targetPowerHt40.
tPow2x[i] =
695 ratesArray[
rate1l] = targetPowerCck.tPow2x[0];
697 ratesArray[
rate2l] = targetPowerCck.tPow2x[1];
699 ratesArray[
rate5_5l] = targetPowerCck.tPow2x[2];
701 ratesArray[
rate11l] = targetPowerCck.tPow2x[3];
712 ratesArray[
rateExtCck] = targetPowerCckExt.tPow2x[0];
717 #undef REDUCE_SCALED_POWER_BY_TWO_CHAIN 718 #undef REDUCE_SCALED_POWER_BY_THREE_CHAIN 723 u8 twiceAntennaReduction,
724 u8 twiceMaxRegulatoryPower,
731 int16_t txPowerIndexOffset = 0;
735 memset(ratesArray, 0,
sizeof(ratesArray));
742 &ratesArray[0], cfgCtl,
743 twiceAntennaReduction,
744 twiceMaxRegulatoryPower,
750 for (i = 0; i <
ARRAY_SIZE(ratesArray); i++) {
751 ratesArray[i] = (
int16_t)(txPowerIndexOffset + ratesArray[i]);
872 u32 regChainOffset, regval;
881 regChainOffset = i * 0x1000;
982 #define EEP_MAP9287_SPURCHAN \ 983 (ah->eeprom.map9287.modalHeader.spurChans[i].spurChan) 988 "Getting spur idx:%d is2Ghz:%d val:%x\n",
989 i, is2GHz,
ah->config.spurchans[i][is2GHz]);
991 switch (
ah->config.spurmode) {
995 spur_val =
ah->config.spurchans[i][is2GHz];
997 "Getting spur val from new loc. %d\n", spur_val);
1006 #undef EEP_MAP9287_SPURCHAN struct cal_target_power_ht calTargetPower2GHT20[AR9287_NUM_2G_20_TARGET_POWERS]
#define AR9287_EEP_MINOR_VER_3
#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 AR9287_AN_TOP2_XPABIAS_LVL_S
u8 calFreqPier2G[AR9287_NUM_2G_CAL_PIERS]
#define AR9287_NUM_2G_CCK_TARGET_POWERS
#define AR_PHY_POWER_TX_RATE3
#define AR_SREV_9280_20_OR_LATER(_ah)
#define ar5416_get_ntxchains(_txchainmask)
#define AR9287_HTC_EEP_START_LOC
#define AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF
static int ath9k_hw_ar9287_get_eeprom_rev(struct ath_hw *ah)
static void ath9k_hw_ar9287_set_board_values(struct ath_hw *ah, struct ath9k_channel *chan)
#define AR_PHY_POWER_TX_RATE2
#define AR9287_AN_RF2G3_CH1
#define AR5416_EEPROM_MAGIC_OFFSET
struct cal_ctl_edges ctlEdges[AR9287_MAX_CHAINS][AR9287_NUM_BAND_EDGES]
#define AR9287_PWR_TABLE_OFFSET_DB
static void ar9287_eeprom_get_tx_gain_index(struct ath_hw *ah, struct ath9k_channel *chan, struct cal_data_op_loop_ar9287 *pRawDatasetOpLoop, u8 *pCalChans, u16 availPiers, int8_t *pPwr)
#define AR_EEPROM_MODAL_SPURS
#define REGWRITE_BUFFER_FLUSH(_ah)
static void ath9k_hw_ar9287_set_addac(struct ath_hw *ah __unused, struct ath9k_channel *chan __unused)
#define AR_PHY_POWER_TX_RATE4
#define AR_PHY_TPCRG1_PD_GAIN_3
static int ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah)
#define ATH9K_POW_SM(_r, _s)
#define AR9287_EEP_MINOR_VER_2
#define AR9287_AN_RF2G3_DB1
#define AR9280_PHY_CCA_THRESH62
#define AR_PHY_POWER_TX_RATE1
#define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_2
#define REG_RMW_FIELD(_a, _r, _f, _v)
#define AR5416_PD_GAINS_IN_MASK
#define AR_PHY_DESIRED_SZ
void ath9k_hw_analog_shift_regwrite(struct ath_hw *ah, u32 reg, u32 val)
#define AR_PHY_SWITCH_COM
#define AR9287_NUM_2G_CAL_PIERS
struct cal_target_power_leg calTargetPower2G[AR9287_NUM_2G_20_TARGET_POWERS]
#define AR9287_AN_RF2G3_DB2
static int ath9k_hw_ar9287_get_eeprom_ver(struct ath_hw *ah)
#define SIZE_EEPROM_AR9287
#define AR_PHY_TX_END_DATA_START
#define AR_PHY_GAIN_2GHZ_XATTEN1_DB
static void ath9k_hw_set_ar9287_power_per_rate_table(struct ath_hw *ah, struct ath9k_channel *chan, int16_t *ratesArray, u16 cfgCtl, u16 AntennaReduction, u16 twiceMaxRegulatoryPower, u16 powerLimit)
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_PHY_TIMING_CTRL4(_i)
#define __unused
Declare a variable or data structure as unused.
static void ath9k_hw_set_ar9287_power_cal_table(struct ath_hw *ah, struct ath9k_channel *chan, int16_t *pTxPowerIndexOffset)
static struct ath_regulatory * ath9k_hw_regulatory(struct ath_hw *ah)
#define AR_PHY_TX_END_TO_A2_RX_ON
#define AR_PHY_SETTLING_SWITCH
static u16 ath9k_hw_ar9287_get_spur_channel(struct ath_hw *ah, u16 i, int is2GHz)
static void ath9k_hw_ar9287_set_txpower(struct ath_hw *ah, struct ath9k_channel *chan, u16 cfgCtl, u8 twiceAntennaReduction, u8 twiceMaxRegulatoryPower, u8 powerLimit, int test)
#define SPUR_ENABLE_EEPROM
#define AR9287_NUM_2G_40_TARGET_POWERS
struct cal_target_power_leg calTargetPowerCck[AR9287_NUM_2G_CCK_TARGET_POWERS]
#define AR9287_AN_RF2G3_OB_PSK
#define ath9k_hw_use_flash(_ah)
#define AR_PHY_TPCRG1_PD_GAIN_2
#define AR5416_NUM_PDADC_VALUES
const struct eeprom_ops eep_ar9287_ops
int ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize, u16 *indexL, u16 *indexR)
#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)
u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower, int is2GHz, int num_band_edges)
#define AR_PHY_GAIN_2GHZ_XATTEN1_MARGIN
#define AR5416_BCHAN_UNUSED
struct hv_monitor_parameter param[4][32]
Parameters.
static int __ath9k_hw_usb_ar9287_fill_eeprom(struct ath_hw *ah)
union cal_data_per_freq_ar9287_u calPierData2G[AR9287_MAX_CHAINS][AR9287_NUM_2G_CAL_PIERS]
static void ar9287_eeprom_olpc_set_pdadcs(struct ath_hw *ah, int32_t txPower, u16 chain)
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
#define AR_PHY_EXT_CCA0_THRESH62
void ath9k_hw_analog_shift_rmw(struct ath_hw *ah, u32 reg, u32 mask, u32 shift, u32 val)
#define AR9287_NUM_2G_20_TARGET_POWERS
uint16_t magic
Magic signature.
static int __ath9k_hw_ar9287_fill_eeprom(struct ath_hw *ah)
static u32 ath9k_hw_ar9287_get_eeprom(struct ath_hw *ah, enum eeprom_param param)
struct ib_cm_common common
struct cal_target_power_ht calTargetPower2GHT40[AR9287_NUM_2G_40_TARGET_POWERS]
int(* check_eeprom)(struct ath_hw *hw)
static int ath9k_hw_ar9287_check_eeprom(struct ath_hw *ah)
#define REG_READ(_ah, _reg)
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 AR9287_AN_RF2G3_OB_QAM
#define REDUCE_SCALED_POWER_BY_THREE_CHAIN
#define SUB_NUM_CTL_MODES_AT_2G_40
#define EEP_MAP9287_SPURCHAN
#define AR9280_PHY_RXGAIN_TXRX_ATTEN
#define AR9287_AN_TOP2_XPABIAS_LVL
#define AR_PHY_TPCRG5_PD_GAIN_OVERLAP
struct cal_ctl_data_ar9287 ctlData[AR9287_NUM_CTLS]
void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data, int eep_start_loc, int size)
#define AR_PHY_TX_END_PA_ON
#define REG_WRITE(_ah, _reg, _val)
#define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_4
#define AR9287_AN_RF2G3_OB_CCK
#define AR5416_EEPROM_MAGIC
#define AR9287_AN_RF2G3_OB_PAL_OFF
void ath9k_hw_get_channel_centers(struct ath_hw *ah __unused, struct ath9k_channel *chan, struct chan_centers *centers)
#define SPUR_ENABLE_IOCTL
#define AR_PHY_SWITCH_CHAIN_0
#define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_3
#define AR_PHY_POWER_TX_RATE9
#define AR_PHY_DESIRED_SZ_ADC
#define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_1
#define DBG(...)
Print a debugging message.
#define AR_PHY_RF_CTL4_TX_END_XPAA_OFF
#define AR9280_PHY_RXGAIN_TXRX_MARGIN
#define REDUCE_SCALED_POWER_BY_TWO_CHAIN
struct modal_eep_ar9287_header modalHeader
#define NULL
NULL pointer (VOID *)
#define AR9287_AN_RF2G3_CH0
struct base_eep_ar9287_header baseEepHeader
#define AR9287_EEP_VER_MINOR_MASK
u8 ctlIndex[AR9287_NUM_CTLS]
#define AR_PHY_TPCRG1_NUM_PD_GAIN
#define AR9287_MAX_CHAINS
#define AR9287_EEP_START_LOC
#define AR_PHY_POWER_TX_RATE7
#define ENABLE_REGWRITE_BUFFER(_ah)
#define AR_PHY_POWER_TX_RATE8
if(natsemi->flags &NATSEMI_64BIT) return 1
#define AR_PHY_POWER_TX_RATE6
#define AR_PHY_RF_CTL4_FRAME_XPAB_ON
void * memset(void *dest, int character, size_t len) __nonnull
#define AR_PHY_TIMING_CTRL4_IQCORR_Q_Q_COFF