27 return ((
ah->eeprom.map4k.baseEepHeader.version >> 12) & 0xF);
32 return ((
ah->eeprom.map4k.baseEepHeader.version) & 0xFFF);
35 #define SIZE_EEPROM_4K (sizeof(struct ar5416_eeprom_4k) / sizeof(u16)) 40 u16 *eep_data = (
u16 *)&
ah->eeprom.map4k;
42 int eep_start_loc = 64;
47 "Unable to read eeprom region\n");
58 u16 *eep_data = (
u16 *)&
ah->eeprom.map4k;
71 "Reading from EEPROM, not flash\n");
84 #define EEPROM_4K_SIZE (sizeof(struct ar5416_eeprom_4k) / sizeof(u16)) 97 DBG(
"ath9k: Reading Magic # failed\n");
102 "Read Magic = 0x%04X\n",
magic);
109 eepdata = (
u16 *) (&
ah->eeprom);
118 "Invalid EEPROM Magic. Endianness mismatch.\n");
124 DBG2(
"ath9k: need_swap = %s.\n",
125 need_swap ?
"True" :
"False");
128 el =
swab16(
ah->eeprom.map4k.baseEepHeader.length);
130 el =
ah->eeprom.map4k.baseEepHeader.length;
135 el = el /
sizeof(
u16);
137 eepdata = (
u16 *)(&
ah->eeprom);
139 for (i = 0; i < el; i++)
147 "EEPROM Endianness is not native.. Changing\n");
189 DBG(
"ath9k: Bad EEPROM checksum 0x%x or revision 0x%04x\n",
190 sum,
ah->eep_ops->get_eeprom_ver(
ah));
195 #undef EEPROM_4K_SIZE 230 return pModal->
db1_1;
262 u16 pdGainOverlap_t2;
266 u16 numXpdGain, xpdMask;
268 u32 reg32, regOffset, regChainOffset;
290 xpdGainValues[numXpdGain] =
297 (numXpdGain - 1) & 0x3);
306 (
ah->rxchainmask == 5 ||
ah->txchainmask == 5) &&
308 regChainOffset = (i == 1) ? 0x2000 : 0x1000;
310 regChainOffset = i * 0x1000;
316 pRawDataset, pCalBChans,
317 numPiers, pdGainOverlap_t2,
319 pdadcValues, numXpdGain);
327 |
SM(gainBoundaries[0],
329 |
SM(gainBoundaries[1],
331 |
SM(gainBoundaries[2],
333 |
SM(gainBoundaries[3],
337 regOffset =
AR_PHY_BASE + (672 << 2) + regChainOffset;
338 for (j = 0; j < 32; j++) {
339 reg32 = ((pdadcValues[4 * j + 0] & 0xFF) << 0) |
340 ((pdadcValues[4 * j + 1] & 0xFF) << 8) |
341 ((pdadcValues[4 * j + 2] & 0xFF) << 16)|
342 ((pdadcValues[4 * j + 3] & 0xFF) << 24);
346 "PDADC (%d,%4x): %4.4x %8.8x\n",
347 i, regChainOffset, regOffset,
351 "PDADC %3d Value %3d | " 352 "PDADC %3d Value %3d | " 353 "PDADC %3d Value %3d | " 354 "PDADC %3d Value %3d |\n",
355 i, 4 * j, pdadcValues[4 * j],
356 4 * j + 1, pdadcValues[4 * j + 1],
357 4 * j + 2, pdadcValues[4 * j + 2],
358 4 * j + 3, pdadcValues[4 * j + 3]);
367 *pTxPowerIndexOffset = 0;
374 u16 AntennaReduction,
375 u16 twiceMaxRegulatoryPower,
378 #define CMP_TEST_GRP \ 379 (((cfgCtl & ~CTL_MODE_M)| (pCtlMode[ctlMode] & CTL_MODE_M)) == \ 380 pEepData->ctlIndex[i]) \ 381 || (((cfgCtl & ~CTL_MODE_M) | (pCtlMode[ctlMode] & CTL_MODE_M)) == \ 382 ((pEepData->ctlIndex[i] & CTL_MODE_M) | SD_NO_CTL)) 387 u16 twiceMinEdgePower;
389 u16 scaledPower = 0, minCtlPower, maxRegAllowedPower;
396 static const u16 tpScaleReductionTable[5] =
402 0, { 0, 0, 0, 0} }, targetPowerCckExt = {
408 static const u16 ctlModesFor11g[] = {
416 twiceLargestAntenna = (
int16_t)
min(AntennaReduction -
417 twiceLargestAntenna, 0);
419 maxRegAllowedPower = twiceMaxRegulatoryPower + twiceLargestAntenna;
421 maxRegAllowedPower -=
422 (tpScaleReductionTable[(regulatory->
tp_scale)] * 2);
425 scaledPower =
min(powerLimit, maxRegAllowedPower);
426 scaledPower =
max((
u16)0, scaledPower);
429 pCtlMode = ctlModesFor11g;
434 &targetPowerCck, 4, 0);
438 &targetPowerOfdm, 4, 0);
442 &targetPowerHt20, 8, 0);
449 &targetPowerHt40, 8, 1);
453 &targetPowerCckExt, 4, 1);
457 &targetPowerOfdmExt, 4, 1);
460 for (ctlMode = 0; ctlMode < numCtlModes; ctlMode++) {
461 int isHt40CtlMode = (pCtlMode[ctlMode] ==
CTL_5GHT40) ||
471 if (
ah->eep_ops->get_eeprom_ver(
ah) == 14 &&
472 ah->eep_ops->get_eeprom_rev(
ah) <= 2)
490 min(twiceMaxEdgePower,
493 twiceMaxEdgePower = twiceMinEdgePower;
499 minCtlPower = (
u8)
min(twiceMaxEdgePower, scaledPower);
501 switch (pCtlMode[ctlMode]) {
504 targetPowerCck.
tPow2x[i] =
511 targetPowerOfdm.
tPow2x[i] =
518 targetPowerHt20.
tPow2x[i] =
524 targetPowerCckExt.tPow2x[0] =
525 min((
u16)targetPowerCckExt.tPow2x[0],
529 targetPowerOfdmExt.
tPow2x[0] =
535 targetPowerHt40.
tPow2x[i] =
550 targetPowerOfdm.
tPow2x[0];
568 targetPowerHt40.
tPow2x[i];
573 ratesArray[
rateExtCck] = targetPowerCckExt.tPow2x[0];
582 u8 twiceAntennaReduction,
583 u8 twiceMaxRegulatoryPower,
590 int16_t txPowerIndexOffset = 0;
594 memset(ratesArray, 0,
sizeof(ratesArray));
602 &ratesArray[0], cfgCtl,
603 twiceAntennaReduction,
604 twiceMaxRegulatoryPower,
610 for (i = 0; i <
ARRAY_SIZE(ratesArray); i++) {
611 ratesArray[i] = (
int16_t)(txPowerIndexOffset + ratesArray[i]);
722 (
INI_RA(&
ah->iniAddac, 7, 1) & (~0x18)) | biaslevel << 3;
791 u8 ob[5], db1[5], db2[5];
792 u8 ant_div_control1, ant_div_control2;
811 regVal |=
SM(ant_div_control1,
813 regVal |=
SM(ant_div_control2,
815 regVal |=
SM((ant_div_control2 >> 2),
817 regVal |=
SM((ant_div_control1 >> 1),
819 regVal |=
SM((ant_div_control1 >> 2),
827 regVal |=
SM((ant_div_control1 >> 3),
841 db1[0] = pModal->
db1_0;
842 db1[1] = pModal->
db1_1;
843 db1[2] = pModal->
db1_2;
844 db1[3] = pModal->
db1_3;
845 db1[4] = pModal->
db1_4;
847 db2[0] = pModal->
db2_0;
848 db2[1] = pModal->
db2_1;
849 db2[2] = pModal->
db2_2;
850 db2[3] = pModal->
db2_3;
851 db2[4] = pModal->
db2_4;
852 }
else if (pModal->
version == 1) {
855 db1[0] = pModal->
db1_0;
856 db1[1] = db1[2] = db1[3] = db1[4] = pModal->
db1_1;
857 db2[0] = pModal->
db2_0;
858 db2[1] = db2[2] = db2[3] = db2[4] = pModal->
db2_1;
862 for (i = 0; i < 5; i++) {
864 db1[i] = pModal->
db1_0;
865 db2[i] = pModal->
db1_0;
1015 if ((pBase->
txGainType == 0) && (bb_desired_scale != 0)) {
1016 u32 pwrctrl, mask, clr;
1019 pwrctrl = mask * bb_desired_scale;
1026 pwrctrl = mask * bb_desired_scale;
1031 pwrctrl = mask * bb_desired_scale;
1041 #define EEP_MAP4K_SPURCHAN \ 1042 (ah->eeprom.map4k.modalHeader.spurChans[i].spurChan) 1047 "Getting spur idx:%d is2Ghz:%d val:%x\n",
1048 i, is2GHz,
ah->config.spurchans[i][is2GHz]);
1050 switch (
ah->config.spurmode) {
1054 spur_val =
ah->config.spurchans[i][is2GHz];
1056 "Getting spur val from new loc. %d\n", spur_val);
1065 #undef EEP_MAP4K_SPURCHAN
static void ath9k_hw_set_4k_power_per_rate_table(struct ath_hw *ah, struct ath9k_channel *chan, int16_t *ratesArray, u16 cfgCtl, u16 AntennaReduction, u16 twiceMaxRegulatoryPower, u16 powerLimit)
#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 AR_PHY_POWER_TX_RATE5
#define AR_PHY_RF_CTL4_TX_END_XPAB_OFF
#define EINVAL
Invalid argument.
#define AR_PHY_9285_ANT_DIV_MAIN_GAINTB
static int ath9k_hw_4k_get_eeprom_ver(struct ath_hw *ah)
#define AR5416_EEP_VER_MINOR_MASK
#define AR9285_AN_RF2G4_DB2_4
static int __ath9k_hw_usb_4k_fill_eeprom(struct ath_hw *ah)
static int ath9k_hw_4k_fill_eeprom(struct ath_hw *ah)
#define AR_PHY_POWER_TX_RATE3
#define AR_SREV_9280_20_OR_LATER(_ah)
#define ar5416_get_ntxchains(_txchainmask)
#define AR9285_AN_RF2G4_DB2_0_S
#define AR9285_AN_RF2G4_DB1_4_S
#define AR_PHY_TIMING_CTRL4_IQCORR_Q_I_COFF
#define AR9271_AN_RF2G4_DB_2
#define AR_PHY_POWER_TX_RATE2
#define AR_PHY_TX_PWRCTRL9
#define AR5416_EEP4K_NUM_PD_GAINS
#define AR5416_EEPROM_MAGIC_OFFSET
#define AR5416_EEP4K_MAX_CHAINS
#define AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV
static void ath9k_hw_4k_set_addac(struct ath_hw *ah, struct ath9k_channel *chan __unused)
#define AR_EEPROM_MODAL_SPURS
#define AR_PHY_9285_ANT_DIV_CTL_ALL
#define AR9285_AN_RF2G3_OB_3_S
#define INI_RA(iniarray, row, column)
#define REGWRITE_BUFFER_FLUSH(_ah)
#define AR9285_AN_RF2G3_OB_2
#define AR_PHY_POWER_TX_RATE4
#define AR9271_AN_RF2G4_DB_2_S
const struct eeprom_ops eep_4k_ops
static int __ath9k_hw_4k_fill_eeprom(struct ath_hw *ah)
#define REG_RMW(_ah, _reg, _set, _clr)
#define AR_PHY_TPCRG1_PD_GAIN_3
#define AR_SREV_5416_20_OR_LATER(_ah)
#define ATH9K_POW_SM(_r, _s)
#define AR_PHY_9285_ANT_DIV_MAIN_LNACONF
#define AR5416_EEP4K_NUM_CTLS
#define AR9285_AN_RF2G3_OB_3
#define AR_PHY_TX_PWRCTRL8
#define EEP_MAP4K_SPURCHAN
#define AR9271_AN_RF2G3_OB_cck
#define AR_SREV_9285(_ah)
#define AR_PHY_MULTICHAIN_GAIN_CTL
#define AR9285_AN_RF2G4_DB2_4_S
#define AR9280_PHY_CCA_THRESH62
#define AR9271_AN_RF2G3_DB_1
#define AR_PHY_POWER_TX_RATE1
#define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_2
#define AR9271_AN_RF2G3_OB_cck_S
#define REG_RMW_FIELD(_a, _r, _f, _v)
#define AR5416_PD_GAINS_IN_MASK
#define AR5416_EEP_TXGAIN_ORIGINAL
struct modal_eep_4k_header modalHeader
static int ath9k_hw_4k_check_eeprom(struct ath_hw *ah)
#define AR9271_AN_RF2G3_OB_qam_S
#define AR_PHY_DESIRED_SZ
#define AR5416_EEP_MINOR_VER_7
#define AR_SREV_VERSION_9160
static u32 ath9k_hw_4k_get_eeprom(struct ath_hw *ah, enum eeprom_param param)
#define AR_PHY_GAIN_2GHZ_XATTEN2_DB
#define AR_PHY_SWITCH_COM
#define AR_PHY_CH0_TX_PWRCTRL13
u8 calFreqPier2G[AR5416_EEP4K_NUM_2G_CAL_PIERS]
#define AR9285_AN_RF2G3_OB_4
#define AR_PHY_TX_END_DATA_START
#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_PHY_TIMING_CTRL4(_i)
#define AR_PHY_GAIN_2GHZ_XATTEN2_MARGIN
#define __unused
Declare a variable or data structure as unused.
static u16 ath9k_hw_4k_get_spur_channel(struct ath_hw *ah, u16 i, int is2GHz)
#define AR9285_AN_RF2G3_DB1_2
static struct ath_regulatory * ath9k_hw_regulatory(struct ath_hw *ah)
static void ath9k_hw_4k_set_gain(struct ath_hw *ah, struct modal_eep_4k_header *pModal, struct ar5416_eeprom_4k *eep, u8 txRxAttenLocal)
#define AR9285_AN_RF2G4_DB2_3_S
static int ath9k_hw_4k_get_eeprom_rev(struct ath_hw *ah)
#define AR_PHY_TX_END_TO_A2_RX_ON
#define AR_PHY_SETTLING_SWITCH
#define SPUR_ENABLE_EEPROM
#define AR9285_AN_RF2G4_DB2_2
#define AR_PHY_CH0_TX_PWRCTRL12
#define AR9285_AN_RF2G3_DB1_1_S
#define ath9k_hw_use_flash(_ah)
#define AR_PHY_TPCRG1_PD_GAIN_2
#define AR5416_NUM_PDADC_VALUES
#define AR5416_NUM_2G_CCK_TARGET_POWERS
#define AR_PHY_TPCRG1_PD_GAIN_1
#define AR5416_EEP_NO_BACK_VER
struct cal_target_power_leg calTargetPower2G[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS]
int ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data)
#define AR_SREV_9271_10(_ah)
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
u8 ctlIndex[AR5416_EEP4K_NUM_CTLS]
#define AR5416_EEP4K_NUM_BAND_EDGES
#define AR9285_AN_RF2G3_DB1_0_S
struct hv_monitor_parameter param[4][32]
Parameters.
#define AR9285_AN_RF2G3_OB_4_S
#define AR9285_AN_RF2G3_DB1_1
#define AR5416_NUM_2G_20_TARGET_POWERS
#define AR9285_AN_RF2G4_DB1_3_S
static struct ath_common * ath9k_hw_common(struct ath_hw *ah)
#define AR9285_AN_RF2G4_DB2_2_S
#define AR_PHY_EXT_CCA0_THRESH62
#define AR_PHY_9285_ANT_DIV_CTL
#define AR_PHY_CCK_DETECT
void ath9k_hw_analog_shift_rmw(struct ath_hw *ah, u32 reg, u32 mask, u32 shift, u32 val)
#define EEP_4K_BB_DESIRED_SCALE_MASK
#define AR9285_AN_RF2G4_DB2_3
uint16_t magic
Magic signature.
#define AR5416_NUM_2G_40_TARGET_POWERS
#define AR9285_AN_RF2G4_DB1_4
struct ib_cm_common common
#define AR_PHY_CH0_TX_PWRCTRL11
int(* check_eeprom)(struct ath_hw *hw)
#define REG_READ(_ah, _reg)
struct cal_target_power_ht calTargetPower2GHT20[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS]
#define AR9285_AN_RF2G3_OB_0
struct cal_target_power_leg calTargetPowerCck[AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS]
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 AR9271_AN_RF2G3_DB_1_S
#define AR9285_AN_RF2G4_DB2_1_S
#define AR5416_EEP_MINOR_VER_3
#define AR5416_EEP4K_NUM_2G_CAL_PIERS
#define AR5416_PWR_TABLE_OFFSET_DB
#define AR9285_AN_RF2G4_DB2_1
#define SUB_NUM_CTL_MODES_AT_2G_40
#define AR9280_PHY_RXGAIN_TXRX_ATTEN
#define AR9285_AN_RF2G3_OB_2_S
#define AR_PHY_TPCRG5_PD_GAIN_OVERLAP
void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data, int eep_start_loc, int size)
static void ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah, struct ath9k_channel *chan, int16_t *pTxPowerIndexOffset)
#define AR9285_AN_RF2G3_DB1_0
#define AR_PHY_TX_END_PA_ON
#define REG_WRITE(_ah, _reg, _val)
#define AR9271_AN_RF2G3_OB_qam
#define AR9285_AN_RF2G3_OB_1
#define AR9271_AN_RF2G3_OB_psk
#define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_4
#define AR_SREV_9271(_ah)
#define AR5416_EEPROM_MAGIC
#define AR9285_AN_RF2G3_DB1_2_S
#define AR9285_AN_RF2G4_DB2_0
#define AR9271_AN_RF2G3_OB_psk_S
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 AR5416_EEP_MINOR_VER_2
#define AR_PHY_POWER_TX_RATE9
#define AR_PHY_DESIRED_SZ_ADC
struct cal_data_per_freq_4k calPierData2G[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_2G_CAL_PIERS]
struct cal_target_power_ht calTargetPower2GHT40[AR5416_EEP4K_NUM_2G_40_TARGET_POWERS]
#define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_1
static void ath9k_hw_4k_set_txpower(struct ath_hw *ah, struct ath9k_channel *chan, u16 cfgCtl, u8 twiceAntennaReduction, u8 twiceMaxRegulatoryPower, u8 powerLimit, int test)
#define DBG(...)
Print a debugging message.
struct base_eep_header_4k baseEepHeader
#define AR_PHY_RF_CTL4_TX_END_XPAA_OFF
struct cal_ctl_data_4k ctlData[AR5416_EEP4K_NUM_CTLS]
#define AR9280_PHY_RXGAIN_TXRX_MARGIN
struct cal_ctl_edges ctlEdges[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_BAND_EDGES]
#define AR_PHY_9285_ANT_DIV_ALT_GAINTB
#define AR_PHY_TX_PWRCTRL10
#define NULL
NULL pointer (VOID *)
#define AR_PHY_9285_ANT_DIV_ALT_LNACONF
static void ath9k_hw_4k_set_board_values(struct ath_hw *ah, struct ath9k_channel *chan)
#define AR_PHY_TPCRG1_NUM_PD_GAIN
#define AR9285_AN_RF2G3_OB_0_S
#define AR_PHY_POWER_TX_RATE7
#define ENABLE_REGWRITE_BUFFER(_ah)
#define AR5416_EEP_MINOR_VER_19
#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
#define AR9285_AN_RF2G3_OB_1_S
#define AR9285_AN_RF2G4_DB1_3