27 #define SIZE_EEPROM_AR9287 (sizeof(struct ar9287_eeprom) / sizeof(u16)) 31 return (
ah->eeprom.map9287.baseEepHeader.version >> 12) & 0xF;
36 return (
ah->eeprom.map9287.baseEepHeader.version) & 0xFFF;
46 eep_data = (
u16 *)eep;
52 "Unable to read eeprom region\n");
63 u16 *eep_data = (
u16 *)&
ah->eeprom.map9287;
77 "Reading from EEPROM, not flash\n");
88 u32 sum = 0, el, integer;
98 DBG(
"ath9k: Reading Magic # failed\n");
103 "Read Magic = 0x%04X\n",
magic);
110 eepdata = (
u16 *)(&
ah->eeprom);
119 "Invalid EEPROM Magic. Endianness mismatch.\n");
125 DBG2(
"ath9k: need_swap = %s.\n",
126 need_swap ?
"True" :
"False");
129 el =
swab16(
ah->eeprom.map9287.baseEepHeader.length);
131 el =
ah->eeprom.map9287.baseEepHeader.length;
136 el = el /
sizeof(
u16);
138 eepdata = (
u16 *)(&
ah->eeprom);
140 for (i = 0; i < el; i++)
184 DBG(
"ath9k: Bad EEPROM checksum 0x%x or revision 0x%04x\n",
185 sum,
ah->eep_ops->get_eeprom_ver(
ah));
251 u16 idxL = 0, idxR = 0, numPiers;
257 for (numPiers = 0; numPiers < availPiers; numPiers++) {
264 pCalChans, numPiers, &idxL, &idxR);
267 *pPwr = (
int8_t) pRawDatasetOpLoop[idxL].pwrPdg[0][0];
269 *pPwr = ((
int8_t) pRawDatasetOpLoop[idxL].pwrPdg[0][0] +
284 tmpVal = tmpVal & 0xFCFFFFFF;
285 tmpVal = tmpVal | (0x3 << 24);
291 tmpVal = tmpVal & 0xFCFFFFFF;
292 tmpVal = tmpVal | (0x3 << 24);
299 tmpVal = tmpVal & 0xff00ffff;
301 tmpVal = tmpVal | (a << 16);
309 tmpVal = tmpVal & 0xff00ffff;
311 tmpVal = tmpVal | (a << 16);
323 u16 pdGainOverlap_t2;
326 u16 numPiers = 0, i, j;
327 u16 numXpdGain, xpdMask;
329 u32 reg32, regOffset, regChainOffset, regval;
346 pRawDatasetOpenLoop =
348 ah->initPDADC = pRawDatasetOpenLoop->
vpdPdg[0][0];
359 xpdGainValues[numXpdGain] =
366 (numXpdGain - 1) & 0x3);
375 regChainOffset = i * 0x1000;
378 pRawDatasetOpenLoop =
385 pCalBChans, numPiers,
395 pCalBChans, numPiers,
408 regval =
SM(pdGainOverlap_t2,
410 |
SM(gainBoundaries[0],
412 |
SM(gainBoundaries[1],
414 |
SM(gainBoundaries[2],
416 |
SM(gainBoundaries[3],
432 pdadcValues[j] = pdadcValues[j+diff];
442 (672 << 2) + regChainOffset;
444 for (j = 0; j < 32; j++) {
445 reg32 = ((pdadcValues[4*j + 0] & 0xFF) << 0)
446 | ((pdadcValues[4*j + 1] & 0xFF) << 8)
447 | ((pdadcValues[4*j + 2] & 0xFF) << 16)
448 | ((pdadcValues[4*j + 3] & 0xFF) << 24);
458 *pTxPowerIndexOffset = 0;
465 u16 AntennaReduction,
466 u16 twiceMaxRegulatoryPower,
470 (((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == \ 471 pEepData->ctlIndex[i]) 474 (((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == \ 475 ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL)) 477 #define REDUCE_SCALED_POWER_BY_TWO_CHAIN 6 478 #define REDUCE_SCALED_POWER_BY_THREE_CHAIN 10 482 static const u16 tpScaleReductionTable[5] =
488 targetPowerCck = {0, {0, 0, 0, 0} };
490 targetPowerCckExt = {0, {0, 0, 0, 0} };
492 targetPowerHt40 = {0, {0, 0, 0, 0} };
493 u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
494 static const u16 ctlModesFor11g[] = {
503 u16 twiceMinEdgePower;
505 tx_chainmask =
ah->txchainmask;
512 twiceLargestAntenna = (
int16_t)
min((AntennaReduction) -
513 twiceLargestAntenna, 0);
519 maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
522 maxRegAllowedPower -=
523 (tpScaleReductionTable[(regulatory->
tp_scale)] * 2);
525 scaledPower =
min(powerLimit, maxRegAllowedPower);
547 scaledPower =
max((
u16)0, scaledPower);
557 pCtlMode = ctlModesFor11g;
562 &targetPowerCck, 4, 0);
566 &targetPowerOfdm, 4, 0);
570 &targetPowerHt20, 8, 0);
578 &targetPowerHt40, 8, 1);
582 &targetPowerCckExt, 4, 1);
586 &targetPowerOfdmExt, 4, 1);
590 for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
620 twiceMaxEdgePower =
min(twiceMaxEdgePower,
623 twiceMaxEdgePower = twiceMinEdgePower;
629 minCtlPower = (
u8)
min(twiceMaxEdgePower, scaledPower);
632 switch (pCtlMode[ctlMode]) {
634 for (i = 0; i <
ARRAY_SIZE(targetPowerCck.tPow2x); i++) {
635 targetPowerCck.tPow2x[i] =
636 (
u8)
min((
u16)targetPowerCck.tPow2x[i],
643 targetPowerOfdm.
tPow2x[i] =
651 targetPowerHt20.
tPow2x[i] =
657 targetPowerCckExt.tPow2x[0] =
658 (
u8)
min((
u16)targetPowerCckExt.tPow2x[0],
663 targetPowerOfdmExt.
tPow2x[0] =
670 targetPowerHt40.
tPow2x[i] =
697 ratesArray[
rate1l] = targetPowerCck.tPow2x[0];
699 ratesArray[
rate2l] = targetPowerCck.tPow2x[1];
701 ratesArray[
rate5_5l] = targetPowerCck.tPow2x[2];
703 ratesArray[
rate11l] = targetPowerCck.tPow2x[3];
714 ratesArray[
rateExtCck] = targetPowerCckExt.tPow2x[0];
719 #undef REDUCE_SCALED_POWER_BY_TWO_CHAIN 720 #undef REDUCE_SCALED_POWER_BY_THREE_CHAIN 725 u8 twiceAntennaReduction,
726 u8 twiceMaxRegulatoryPower,
733 int16_t txPowerIndexOffset = 0;
737 memset(ratesArray, 0,
sizeof(ratesArray));
744 &ratesArray[0], cfgCtl,
745 twiceAntennaReduction,
746 twiceMaxRegulatoryPower,
752 for (i = 0; i <
ARRAY_SIZE(ratesArray); i++) {
753 ratesArray[i] = (
int16_t)(txPowerIndexOffset + ratesArray[i]);
874 u32 regChainOffset, regval;
883 regChainOffset = i * 0x1000;
984 #define EEP_MAP9287_SPURCHAN \ 985 (ah->eeprom.map9287.modalHeader.spurChans[i].spurChan) 990 "Getting spur idx:%d is2Ghz:%d val:%x\n",
991 i, is2GHz,
ah->config.spurchans[i][is2GHz]);
993 switch (
ah->config.spurmode) {
997 spur_val =
ah->config.spurchans[i][is2GHz];
999 "Getting spur val from new loc. %d\n", spur_val);
1008 #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]
uint16_t magic
Magic signature.
#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)
uint32_t addr
Buffer address.
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
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