29
30
static bool ath9k_hw_4k_fill_eeprom(struct ath_hw *ah)
31
32
#define SIZE_EEPROM_4K (sizeof(struct ar5416_eeprom_4k) / sizeof(u16))
33
struct ath_common *common = ath9k_hw_common(ah);
32
34
u16 *eep_data = (u16 *)&ah->eeprom.map4k;
33
35
int addr, eep_start_loc = 0;
35
37
eep_start_loc = 64;
37
39
if (!ath9k_hw_use_flash(ah)) {
38
DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
40
ath_dbg(common, ATH_DBG_EEPROM,
39
41
"Reading from EEPROM, not flash\n");
42
44
for (addr = 0; addr < SIZE_EEPROM_4K; addr++) {
43
if (!ath9k_hw_nvram_read(ah, addr + eep_start_loc, eep_data)) {
44
DPRINTF(ah->ah_sc, ATH_DBG_EEPROM,
45
"Unable to read eeprom region \n");
45
if (!ath9k_hw_nvram_read(common, addr + eep_start_loc, eep_data)) {
46
ath_dbg(common, ATH_DBG_EEPROM,
47
"Unable to read eeprom region\n");
202
205
return pModal->db1_1;
203
206
case EEP_MINOR_REV:
204
return pBase->version & AR5416_EEP_VER_MINOR_MASK;
205
208
case EEP_TX_MASK:
206
209
return pBase->txMask;
207
210
case EEP_RX_MASK:
208
211
return pBase->rxMask;
209
212
case EEP_FRAC_N_5G:
214
case EEP_PWR_TABLE_OFFSET:
215
return AR5416_PWR_TABLE_OFFSET_DB;
217
return pModal->version;
218
case EEP_ANT_DIV_CTL1:
219
return pModal->antdiv_ctl1;
220
case EEP_TXGAIN_TYPE:
221
if (ver_minor >= AR5416_EEP_MINOR_VER_19)
222
return pBase->txGainType;
224
return AR5416_EEP_TXGAIN_ORIGINAL;
216
static void ath9k_hw_get_4k_gain_boundaries_pdadcs(struct ath_hw *ah,
217
struct ath9k_channel *chan,
218
struct cal_data_per_freq_4k *pRawDataSet,
219
u8 *bChans, u16 availPiers,
220
u16 tPdGainOverlap, int16_t *pMinCalPower,
221
u16 *pPdGainBoundaries, u8 *pPDADCValues,
224
#define TMP_VAL_VPD_TABLE \
225
((vpdTableI[i][sizeCurrVpdTable - 1] + (ss - maxIndex + 1) * vpdStep));
228
u16 idxL = 0, idxR = 0, numPiers;
229
static u8 vpdTableL[AR5416_EEP4K_NUM_PD_GAINS]
230
[AR5416_MAX_PWR_RANGE_IN_HALF_DB];
231
static u8 vpdTableR[AR5416_EEP4K_NUM_PD_GAINS]
232
[AR5416_MAX_PWR_RANGE_IN_HALF_DB];
233
static u8 vpdTableI[AR5416_EEP4K_NUM_PD_GAINS]
234
[AR5416_MAX_PWR_RANGE_IN_HALF_DB];
236
u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR;
237
u8 minPwrT4[AR5416_EEP4K_NUM_PD_GAINS];
238
u8 maxPwrT4[AR5416_EEP4K_NUM_PD_GAINS];
241
u16 sizeCurrVpdTable, maxIndex, tgtIndex;
243
int16_t minDelta = 0;
244
struct chan_centers centers;
245
#define PD_GAIN_BOUNDARY_DEFAULT 58;
247
ath9k_hw_get_channel_centers(ah, chan, ¢ers);
249
for (numPiers = 0; numPiers < availPiers; numPiers++) {
250
if (bChans[numPiers] == AR5416_BCHAN_UNUSED)
254
match = ath9k_hw_get_lower_upper_index(
255
(u8)FREQ2FBIN(centers.synth_center,
256
IS_CHAN_2GHZ(chan)), bChans, numPiers,
260
for (i = 0; i < numXpdGains; i++) {
261
minPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][0];
262
maxPwrT4[i] = pRawDataSet[idxL].pwrPdg[i][4];
263
ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
264
pRawDataSet[idxL].pwrPdg[i],
265
pRawDataSet[idxL].vpdPdg[i],
266
AR5416_EEP4K_PD_GAIN_ICEPTS,
270
for (i = 0; i < numXpdGains; i++) {
271
pVpdL = pRawDataSet[idxL].vpdPdg[i];
272
pPwrL = pRawDataSet[idxL].pwrPdg[i];
273
pVpdR = pRawDataSet[idxR].vpdPdg[i];
274
pPwrR = pRawDataSet[idxR].pwrPdg[i];
276
minPwrT4[i] = max(pPwrL[0], pPwrR[0]);
279
min(pPwrL[AR5416_EEP4K_PD_GAIN_ICEPTS - 1],
280
pPwrR[AR5416_EEP4K_PD_GAIN_ICEPTS - 1]);
283
ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
285
AR5416_EEP4K_PD_GAIN_ICEPTS,
287
ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
289
AR5416_EEP4K_PD_GAIN_ICEPTS,
292
for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) {
294
(u8)(ath9k_hw_interpolate((u16)
299
bChans[idxL], bChans[idxR],
300
vpdTableL[i][j], vpdTableR[i][j]));
305
*pMinCalPower = (int16_t)(minPwrT4[0] / 2);
309
for (i = 0; i < numXpdGains; i++) {
310
if (i == (numXpdGains - 1))
311
pPdGainBoundaries[i] =
312
(u16)(maxPwrT4[i] / 2);
314
pPdGainBoundaries[i] =
315
(u16)((maxPwrT4[i] + minPwrT4[i + 1]) / 4);
317
pPdGainBoundaries[i] =
318
min((u16)AR5416_MAX_RATE_POWER, pPdGainBoundaries[i]);
320
if ((i == 0) && !AR_SREV_5416_20_OR_LATER(ah)) {
321
minDelta = pPdGainBoundaries[0] - 23;
322
pPdGainBoundaries[0] = 23;
328
if (AR_SREV_9280_10_OR_LATER(ah))
329
ss = (int16_t)(0 - (minPwrT4[i] / 2));
333
ss = (int16_t)((pPdGainBoundaries[i - 1] -
335
tPdGainOverlap + 1 + minDelta);
337
vpdStep = (int16_t)(vpdTableI[i][1] - vpdTableI[i][0]);
338
vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
340
while ((ss < 0) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
341
tmpVal = (int16_t)(vpdTableI[i][0] + ss * vpdStep);
342
pPDADCValues[k++] = (u8)((tmpVal < 0) ? 0 : tmpVal);
346
sizeCurrVpdTable = (u8) ((maxPwrT4[i] - minPwrT4[i]) / 2 + 1);
347
tgtIndex = (u8)(pPdGainBoundaries[i] + tPdGainOverlap -
349
maxIndex = (tgtIndex < sizeCurrVpdTable) ?
350
tgtIndex : sizeCurrVpdTable;
352
while ((ss < maxIndex) && (k < (AR5416_NUM_PDADC_VALUES - 1)))
353
pPDADCValues[k++] = vpdTableI[i][ss++];
355
vpdStep = (int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] -
356
vpdTableI[i][sizeCurrVpdTable - 2]);
357
vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
359
if (tgtIndex >= maxIndex) {
360
while ((ss <= tgtIndex) &&
361
(k < (AR5416_NUM_PDADC_VALUES - 1))) {
362
tmpVal = (int16_t) TMP_VAL_VPD_TABLE;
363
pPDADCValues[k++] = (u8)((tmpVal > 255) ?
370
while (i < AR5416_EEP4K_PD_GAINS_IN_MASK) {
371
pPdGainBoundaries[i] = PD_GAIN_BOUNDARY_DEFAULT;
375
while (k < AR5416_NUM_PDADC_VALUES) {
376
pPDADCValues[k] = pPDADCValues[k - 1];
381
#undef TMP_VAL_VPD_TABLE
384
230
static void ath9k_hw_set_4k_power_cal_table(struct ath_hw *ah,
385
231
struct ath9k_channel *chan,
386
232
int16_t *pTxPowerIndexOffset)
234
struct ath_common *common = ath9k_hw_common(ah);
388
235
struct ar5416_eeprom_4k *pEepData = &ah->eeprom.map4k;
389
236
struct cal_data_per_freq_4k *pRawDataset;
390
237
u8 *pCalBChans = NULL;
391
238
u16 pdGainOverlap_t2;
392
239
static u8 pdadcValues[AR5416_NUM_PDADC_VALUES];
393
u16 gainBoundaries[AR5416_EEP4K_PD_GAINS_IN_MASK];
240
u16 gainBoundaries[AR5416_PD_GAINS_IN_MASK];
394
241
u16 numPiers, i, j;
395
int16_t tMinCalPower;
396
242
u16 numXpdGain, xpdMask;
397
243
u16 xpdGainValues[AR5416_EEP4K_NUM_PD_GAINS] = { 0, 0 };
398
244
u32 reg32, regOffset, regChainOffset;
1132
static u16 ath9k_hw_4k_get_eeprom_antenna_cfg(struct ath_hw *ah,
1133
struct ath9k_channel *chan)
1135
struct ar5416_eeprom_4k *eep = &ah->eeprom.map4k;
1136
struct modal_eep_4k_header *pModal = &eep->modalHeader;
1138
return pModal->antCtrlCommon & 0xFFFF;
1141
static u8 ath9k_hw_4k_get_num_ant_config(struct ath_hw *ah,
1142
enum ieee80211_band freq_band)
1147
989
static u16 ath9k_hw_4k_get_spur_channel(struct ath_hw *ah, u16 i, bool is2GHz)
1149
991
#define EEP_MAP4K_SPURCHAN \
1150
992
(ah->eeprom.map4k.modalHeader.spurChans[i].spurChan)
993
struct ath_common *common = ath9k_hw_common(ah);
1152
995
u16 spur_val = AR_NO_SPUR;
1154
DPRINTF(ah->ah_sc, ATH_DBG_ANI,
1155
"Getting spur idx %d is2Ghz. %d val %x\n",
997
ath_dbg(common, ATH_DBG_ANI,
998
"Getting spur idx:%d is2Ghz:%d val:%x\n",
1156
999
i, is2GHz, ah->config.spurchans[i][is2GHz]);
1158
1001
switch (ah->config.spurmode) {