iPXE
Functions
ath9k_eeprom.c File Reference
#include <ipxe/io.h>
#include "hw.h"

Go to the source code of this file.

Functions

static u16 ath9k_hw_fbin2freq (u8 fbin, int is2GHz)
 
void ath9k_hw_analog_shift_regwrite (struct ath_hw *ah, u32 reg, u32 val)
 
void ath9k_hw_analog_shift_rmw (struct ath_hw *ah, u32 reg, u32 mask, u32 shift, u32 val)
 
int16_t ath9k_hw_interpolate (u16 target, u16 srcLeft, u16 srcRight, int16_t targetLeft, int16_t targetRight)
 
int ath9k_hw_get_lower_upper_index (u8 target, u8 *pList, u16 listSize, u16 *indexL, u16 *indexR)
 
void ath9k_hw_usb_gen_fill_eeprom (struct ath_hw *ah, u16 *eep_data, int eep_start_loc, int size)
 
int ath9k_hw_nvram_read (struct ath_common *common, u32 off, u16 *data)
 
void ath9k_hw_fill_vpd_table (u8 pwrMin, u8 pwrMax, u8 *pPwrList, u8 *pVpdList, u16 numIntercepts, u8 *pRetVpdList)
 
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)
 
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)
 
u16 ath9k_hw_get_max_edge_power (u16 freq, struct cal_ctl_edges *pRdEdgesPower, int is2GHz, int num_band_edges)
 
void ath9k_hw_update_regulatory_maxpower (struct ath_hw *ah)
 
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)
 
int ath9k_hw_eeprom_init (struct ath_hw *ah)
 

Function Documentation

◆ ath9k_hw_fbin2freq()

static u16 ath9k_hw_fbin2freq ( u8  fbin,
int  is2GHz 
)
inlinestatic

Definition at line 24 of file ath9k_eeprom.c.

25 {
26  if (fbin == AR5416_BCHAN_UNUSED)
27  return fbin;
28 
29  return (u16) ((is2GHz) ? (2300 + fbin) : (4800 + 5 * fbin));
30 }
uint16_t u16
Definition: stdint.h:21
#define AR5416_BCHAN_UNUSED
Definition: eeprom.h:157

References AR5416_BCHAN_UNUSED.

Referenced by ath9k_hw_get_legacy_target_powers(), ath9k_hw_get_max_edge_power(), and ath9k_hw_get_target_powers().

◆ ath9k_hw_analog_shift_regwrite()

void ath9k_hw_analog_shift_regwrite ( struct ath_hw ah,
u32  reg,
u32  val 
)

Definition at line 32 of file ath9k_eeprom.c.

33 {
34  REG_WRITE(ah, reg, val);
35 
36  if (ah->config.analog_shiftreg)
37  udelay(100);
38 }
static unsigned int unsigned int reg
Definition: myson.h:162
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
void __asmcall int val
Definition: setjmp.h:28
#define REG_WRITE(_ah, _reg, _val)
Definition: hw.h:77
uint8_t ah
Definition: registers.h:85

References ah, reg, REG_WRITE, udelay(), and val.

Referenced by ath9k_hw_ar9287_set_board_values().

◆ ath9k_hw_analog_shift_rmw()

void ath9k_hw_analog_shift_rmw ( struct ath_hw ah,
u32  reg,
u32  mask,
u32  shift,
u32  val 
)

Definition at line 40 of file ath9k_eeprom.c.

42 {
43  u32 regVal;
44 
45  regVal = REG_READ(ah, reg) & ~mask;
46  regVal |= (val << shift) & mask;
47 
48  REG_WRITE(ah, reg, regVal);
49 
50  if (ah->config.analog_shiftreg)
51  udelay(100);
52 }
static unsigned int unsigned int reg
Definition: myson.h:162
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:60
#define REG_READ(_ah, _reg)
Definition: hw.h:80
void __asmcall int val
Definition: setjmp.h:28
#define REG_WRITE(_ah, _reg, _val)
Definition: hw.h:77
uint8_t ah
Definition: registers.h:85
uint32_t u32
Definition: stdint.h:23

References ah, reg, REG_READ, REG_WRITE, udelay(), and val.

Referenced by ar9002_olc_init(), ath9k_hw_4k_set_board_values(), ath9k_hw_ar9287_set_board_values(), and ath9k_hw_def_set_board_values().

◆ ath9k_hw_interpolate()

int16_t ath9k_hw_interpolate ( u16  target,
u16  srcLeft,
u16  srcRight,
int16_t  targetLeft,
int16_t  targetRight 
)

Definition at line 54 of file ath9k_eeprom.c.

56 {
57  int16_t rv;
58 
59  if (srcRight == srcLeft) {
60  rv = targetLeft;
61  } else {
62  rv = (int16_t) (((target - srcLeft) * targetRight +
63  (srcRight - target) * targetLeft) /
64  (srcRight - srcLeft));
65  }
66  return rv;
67 }
signed short int16_t
Definition: stdint.h:16

Referenced by ath9k_hw_get_gain_boundaries_pdadcs(), ath9k_hw_get_legacy_target_powers(), and ath9k_hw_get_target_powers().

◆ ath9k_hw_get_lower_upper_index()

int ath9k_hw_get_lower_upper_index ( u8  target,
u8 pList,
u16  listSize,
u16 indexL,
u16 indexR 
)

Definition at line 69 of file ath9k_eeprom.c.

71 {
72  u16 i;
73 
74  if (target <= pList[0]) {
75  *indexL = *indexR = 0;
76  return 1;
77  }
78  if (target >= pList[listSize - 1]) {
79  *indexL = *indexR = (u16) (listSize - 1);
80  return 1;
81  }
82 
83  for (i = 0; i < listSize - 1; i++) {
84  if (pList[i] == target) {
85  *indexL = *indexR = i;
86  return 1;
87  }
88  if (target < pList[i + 1]) {
89  *indexL = i;
90  *indexR = (u16) (i + 1);
91  return 0;
92  }
93  }
94  return 0;
95 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21

References u16.

Referenced by ar9287_eeprom_get_tx_gain_index(), ath9k_get_txgain_index(), ath9k_hw_fill_vpd_table(), and ath9k_hw_get_gain_boundaries_pdadcs().

◆ ath9k_hw_usb_gen_fill_eeprom()

void ath9k_hw_usb_gen_fill_eeprom ( struct ath_hw ah,
u16 eep_data,
int  eep_start_loc,
int  size 
)

Definition at line 97 of file ath9k_eeprom.c.

99 {
100  int i = 0, j, addr;
101  u32 addrdata[8];
102  u32 data[8];
103 
104  for (addr = 0; addr < size; addr++) {
105  addrdata[i] = AR5416_EEPROM_OFFSET +
106  ((addr + eep_start_loc) << AR5416_EEPROM_S);
107  i++;
108  if (i == 8) {
109  REG_READ_MULTI(ah, addrdata, data, i);
110 
111  for (j = 0; j < i; j++) {
112  *eep_data = data[j];
113  eep_data++;
114  }
115  i = 0;
116  }
117  }
118 
119  if (i != 0) {
120  REG_READ_MULTI(ah, addrdata, data, i);
121 
122  for (j = 0; j < i; j++) {
123  *eep_data = data[j];
124  eep_data++;
125  }
126  }
127 }
#define REG_READ_MULTI(_ah, _addr, _val, _cnt)
Definition: hw.h:83
u32 addr
Definition: sky2.h:8
uint8_t size
Entry size (in 32-bit words)
Definition: ena.h:16
uint8_t data[48]
Additional event data.
Definition: ena.h:22
uint8_t ah
Definition: registers.h:85
#define AR5416_EEPROM_S
Definition: eeprom.h:60
uint32_t u32
Definition: stdint.h:23
#define AR5416_EEPROM_OFFSET
Definition: eeprom.h:61

References addr, ah, AR5416_EEPROM_OFFSET, AR5416_EEPROM_S, data, REG_READ_MULTI, and size.

Referenced by __ath9k_hw_usb_4k_fill_eeprom(), __ath9k_hw_usb_ar9287_fill_eeprom(), and __ath9k_hw_usb_def_fill_eeprom().

◆ ath9k_hw_nvram_read()

int ath9k_hw_nvram_read ( struct ath_common common,
u32  off,
u16 data 
)

Definition at line 129 of file ath9k_eeprom.c.

130 {
131  return common->bus_ops->eeprom_read(common, off, data);
132 }
struct ib_cm_common common
Definition: ib_mad.h:11
uint8_t data[48]
Additional event data.
Definition: ena.h:22

References common, and data.

Referenced by __ath9k_hw_4k_fill_eeprom(), __ath9k_hw_ar9287_fill_eeprom(), __ath9k_hw_def_fill_eeprom(), ar9300_eeprom_read_byte(), ar9300_eeprom_read_word(), ar9300_eeprom_restore_flash(), ath9k_hw_4k_check_eeprom(), ath9k_hw_ar9287_check_eeprom(), and ath9k_hw_def_check_eeprom().

◆ ath9k_hw_fill_vpd_table()

void ath9k_hw_fill_vpd_table ( u8  pwrMin,
u8  pwrMax,
u8 pPwrList,
u8 pVpdList,
u16  numIntercepts,
u8 pRetVpdList 
)

Definition at line 134 of file ath9k_eeprom.c.

137 {
138  u16 i, k;
139  u8 currPwr = pwrMin;
140  u16 idxL = 0, idxR = 0;
141 
142  for (i = 0; i <= (pwrMax - pwrMin) / 2; i++) {
143  ath9k_hw_get_lower_upper_index(currPwr, pPwrList,
144  numIntercepts, &(idxL),
145  &(idxR));
146  if (idxR < 1)
147  idxR = 1;
148  if (idxL == numIntercepts - 1)
149  idxL = (u16) (numIntercepts - 2);
150  if (pPwrList[idxL] == pPwrList[idxR])
151  k = pVpdList[idxL];
152  else
153  k = (u16)(((currPwr - pPwrList[idxL]) * pVpdList[idxR] +
154  (pPwrList[idxR] - currPwr) * pVpdList[idxL]) /
155  (pPwrList[idxR] - pPwrList[idxL]));
156  pRetVpdList[i] = (u8) k;
157  currPwr += 2;
158  }
159 }
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define u8
Definition: igbvf_osdep.h:38
int ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize, u16 *indexL, u16 *indexR)
Definition: ath9k_eeprom.c:69
static const uint32_t k[64]
MD5 constants.
Definition: md5.c:53
uint8_t u8
Definition: stdint.h:19

References ath9k_hw_get_lower_upper_index(), k, u16, and u8.

Referenced by ath9k_hw_get_gain_boundaries_pdadcs().

◆ ath9k_hw_get_legacy_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 
)

Definition at line 161 of file ath9k_eeprom.c.

167 {
168  struct chan_centers centers;
169  u16 clo, chi;
170  int i;
171  int matchIndex = -1, lowIndex = -1;
172  u16 freq;
173 
174  ath9k_hw_get_channel_centers(ah, chan, &centers);
175  freq = (isExtTarget) ? centers.ext_center : centers.ctl_center;
176 
177  if (freq <= ath9k_hw_fbin2freq(powInfo[0].bChannel,
178  IS_CHAN_2GHZ(chan))) {
179  matchIndex = 0;
180  } else {
181  for (i = 0; (i < numChannels) &&
182  (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
183  if (freq == ath9k_hw_fbin2freq(powInfo[i].bChannel,
184  IS_CHAN_2GHZ(chan))) {
185  matchIndex = i;
186  break;
187  } else if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
188  IS_CHAN_2GHZ(chan)) && i > 0 &&
189  freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
190  IS_CHAN_2GHZ(chan))) {
191  lowIndex = i - 1;
192  break;
193  }
194  }
195  if ((matchIndex == -1) && (lowIndex == -1))
196  matchIndex = i - 1;
197  }
198 
199  if (matchIndex != -1) {
200  *pNewPower = powInfo[matchIndex];
201  } else {
202  clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel,
203  IS_CHAN_2GHZ(chan));
204  chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel,
205  IS_CHAN_2GHZ(chan));
206 
207  for (i = 0; i < numRates; i++) {
208  pNewPower->tPow2x[i] =
209  (u8)ath9k_hw_interpolate(freq, clo, chi,
210  powInfo[lowIndex].tPow2x[i],
211  powInfo[lowIndex + 1].tPow2x[i]);
212  }
213  }
214 }
uint16_t u16
Definition: stdint.h:21
static u16 ath9k_hw_fbin2freq(u8 fbin, int is2GHz)
Definition: ath9k_eeprom.c:24
#define IS_CHAN_2GHZ(_c)
Definition: hw.h:361
int16_t ath9k_hw_interpolate(u16 target, u16 srcLeft, u16 srcRight, int16_t targetLeft, int16_t targetRight)
Definition: ath9k_eeprom.c:54
#define u8
Definition: igbvf_osdep.h:38
#define AR5416_BCHAN_UNUSED
Definition: eeprom.h:157
void ath9k_hw_get_channel_centers(struct ath_hw *ah __unused, struct ath9k_channel *chan, struct chan_centers *centers)
Definition: ath9k_hw.c:189
uint8_t ah
Definition: registers.h:85
u8 tPow2x[4]
Definition: ar9003_eeprom.h:24
if(natsemi->flags &NATSEMI_64BIT) return 1

References ah, AR5416_BCHAN_UNUSED, ath9k_hw_fbin2freq(), ath9k_hw_get_channel_centers(), ath9k_hw_interpolate(), chan_centers::ctl_center, chan_centers::ext_center, if(), IS_CHAN_2GHZ, tPow2x, cal_target_power_leg::tPow2x, and u8.

Referenced by ath9k_hw_set_4k_power_per_rate_table(), ath9k_hw_set_ar9287_power_per_rate_table(), and ath9k_hw_set_def_power_per_rate_table().

◆ ath9k_hw_get_target_powers()

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 
)

Definition at line 216 of file ath9k_eeprom.c.

222 {
223  struct chan_centers centers;
224  u16 clo, chi;
225  int i;
226  int matchIndex = -1, lowIndex = -1;
227  u16 freq;
228 
229  ath9k_hw_get_channel_centers(ah, chan, &centers);
230  freq = isHt40Target ? centers.synth_center : centers.ctl_center;
231 
232  if (freq <= ath9k_hw_fbin2freq(powInfo[0].bChannel, IS_CHAN_2GHZ(chan))) {
233  matchIndex = 0;
234  } else {
235  for (i = 0; (i < numChannels) &&
236  (powInfo[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
237  if (freq == ath9k_hw_fbin2freq(powInfo[i].bChannel,
238  IS_CHAN_2GHZ(chan))) {
239  matchIndex = i;
240  break;
241  } else
242  if (freq < ath9k_hw_fbin2freq(powInfo[i].bChannel,
243  IS_CHAN_2GHZ(chan)) && i > 0 &&
244  freq > ath9k_hw_fbin2freq(powInfo[i - 1].bChannel,
245  IS_CHAN_2GHZ(chan))) {
246  lowIndex = i - 1;
247  break;
248  }
249  }
250  if ((matchIndex == -1) && (lowIndex == -1))
251  matchIndex = i - 1;
252  }
253 
254  if (matchIndex != -1) {
255  *pNewPower = powInfo[matchIndex];
256  } else {
257  clo = ath9k_hw_fbin2freq(powInfo[lowIndex].bChannel,
258  IS_CHAN_2GHZ(chan));
259  chi = ath9k_hw_fbin2freq(powInfo[lowIndex + 1].bChannel,
260  IS_CHAN_2GHZ(chan));
261 
262  for (i = 0; i < numRates; i++) {
263  pNewPower->tPow2x[i] = (u8)ath9k_hw_interpolate(freq,
264  clo, chi,
265  powInfo[lowIndex].tPow2x[i],
266  powInfo[lowIndex + 1].tPow2x[i]);
267  }
268  }
269 }
uint16_t u16
Definition: stdint.h:21
static u16 ath9k_hw_fbin2freq(u8 fbin, int is2GHz)
Definition: ath9k_eeprom.c:24
#define IS_CHAN_2GHZ(_c)
Definition: hw.h:361
int16_t ath9k_hw_interpolate(u16 target, u16 srcLeft, u16 srcRight, int16_t targetLeft, int16_t targetRight)
Definition: ath9k_eeprom.c:54
#define u8
Definition: igbvf_osdep.h:38
#define AR5416_BCHAN_UNUSED
Definition: eeprom.h:157
void ath9k_hw_get_channel_centers(struct ath_hw *ah __unused, struct ath9k_channel *chan, struct chan_centers *centers)
Definition: ath9k_hw.c:189
uint8_t ah
Definition: registers.h:85
u8 tPow2x[4]
Definition: ar9003_eeprom.h:24

References ah, AR5416_BCHAN_UNUSED, ath9k_hw_fbin2freq(), ath9k_hw_get_channel_centers(), ath9k_hw_interpolate(), chan_centers::ctl_center, IS_CHAN_2GHZ, chan_centers::synth_center, tPow2x, cal_target_power_ht::tPow2x, and u8.

Referenced by ath9k_hw_set_4k_power_per_rate_table(), ath9k_hw_set_ar9287_power_per_rate_table(), and ath9k_hw_set_def_power_per_rate_table().

◆ ath9k_hw_get_max_edge_power()

u16 ath9k_hw_get_max_edge_power ( u16  freq,
struct cal_ctl_edges pRdEdgesPower,
int  is2GHz,
int  num_band_edges 
)

Definition at line 271 of file ath9k_eeprom.c.

273 {
274  u16 twiceMaxEdgePower = MAX_RATE_POWER;
275  int i;
276 
277  for (i = 0; (i < num_band_edges) &&
278  (pRdEdgesPower[i].bChannel != AR5416_BCHAN_UNUSED); i++) {
279  if (freq == ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel, is2GHz)) {
280  twiceMaxEdgePower = CTL_EDGE_TPOWER(pRdEdgesPower[i].ctl);
281  break;
282  } else if ((i > 0) &&
283  (freq < ath9k_hw_fbin2freq(pRdEdgesPower[i].bChannel,
284  is2GHz))) {
285  if (ath9k_hw_fbin2freq(pRdEdgesPower[i - 1].bChannel,
286  is2GHz) < freq &&
287  CTL_EDGE_FLAGS(pRdEdgesPower[i - 1].ctl)) {
288  twiceMaxEdgePower =
289  CTL_EDGE_TPOWER(pRdEdgesPower[i - 1].ctl);
290  }
291  break;
292  }
293  }
294 
295  return twiceMaxEdgePower;
296 }
uint16_t u16
Definition: stdint.h:21
static u16 ath9k_hw_fbin2freq(u8 fbin, int is2GHz)
Definition: ath9k_eeprom.c:24
#define CTL_EDGE_FLAGS(_ctl)
Definition: eeprom.h:214
#define AR5416_BCHAN_UNUSED
Definition: eeprom.h:157
#define CTL_EDGE_TPOWER(_ctl)
Definition: eeprom.h:213
#define MAX_RATE_POWER
Definition: hw.h:144

References AR5416_BCHAN_UNUSED, ath9k_hw_fbin2freq(), CTL_EDGE_FLAGS, CTL_EDGE_TPOWER, and MAX_RATE_POWER.

Referenced by ath9k_hw_set_4k_power_per_rate_table(), ath9k_hw_set_ar9287_power_per_rate_table(), and ath9k_hw_set_def_power_per_rate_table().

◆ ath9k_hw_update_regulatory_maxpower()

void ath9k_hw_update_regulatory_maxpower ( struct ath_hw ah)

Definition at line 298 of file ath9k_eeprom.c.

299 {
300  struct ath_regulatory *regulatory = ath9k_hw_regulatory(ah);
301 
302  switch (ar5416_get_ntxchains(ah->txchainmask)) {
303  case 1:
304  break;
305  case 2:
307  break;
308  case 3:
310  break;
311  default:
312  DBG2("ath9k: "
313  "Invalid chainmask configuration\n");
314  break;
315  }
316 }
#define ar5416_get_ntxchains(_txchainmask)
Definition: eeprom.h:706
static struct ath_regulatory * ath9k_hw_regulatory(struct ath_hw *ah)
Definition: hw.h:874
#define INCREASE_MAXPOW_BY_TWO_CHAIN
Definition: eeprom.h:86
#define INCREASE_MAXPOW_BY_THREE_CHAIN
Definition: eeprom.h:87
uint8_t ah
Definition: registers.h:85
u16 max_power_level
Definition: ath.h:139
#define DBG2(...)
Definition: compiler.h:515

References ah, ar5416_get_ntxchains, ath9k_hw_regulatory(), DBG2, INCREASE_MAXPOW_BY_THREE_CHAIN, INCREASE_MAXPOW_BY_TWO_CHAIN, and ath_regulatory::max_power_level.

◆ ath9k_hw_get_gain_boundaries_pdadcs()

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 
)

Definition at line 318 of file ath9k_eeprom.c.

325 {
326  int i, j, k;
327  int16_t ss;
328  u16 idxL = 0, idxR = 0, numPiers;
329  static u8 vpdTableL[AR5416_NUM_PD_GAINS]
331  static u8 vpdTableR[AR5416_NUM_PD_GAINS]
333  static u8 vpdTableI[AR5416_NUM_PD_GAINS]
335 
336  u8 *pVpdL, *pVpdR, *pPwrL, *pPwrR;
337  u8 minPwrT4[AR5416_NUM_PD_GAINS];
338  u8 maxPwrT4[AR5416_NUM_PD_GAINS];
339  int16_t vpdStep;
340  int16_t tmpVal;
341  u16 sizeCurrVpdTable, maxIndex, tgtIndex;
342  int match;
343  int16_t minDelta = 0;
344  struct chan_centers centers;
345  int pdgain_boundary_default;
346  struct cal_data_per_freq *data_def = pRawDataSet;
347  struct cal_data_per_freq_4k *data_4k = pRawDataSet;
348  struct cal_data_per_freq_ar9287 *data_9287 = pRawDataSet;
349  int eeprom_4k = AR_SREV_9285(ah) || AR_SREV_9271(ah);
350  int intercepts;
351 
352  if (AR_SREV_9287(ah))
353  intercepts = AR9287_PD_GAIN_ICEPTS;
354  else
355  intercepts = AR5416_PD_GAIN_ICEPTS;
356 
357  memset(&minPwrT4, 0, AR5416_NUM_PD_GAINS);
358  ath9k_hw_get_channel_centers(ah, chan, &centers);
359 
360  for (numPiers = 0; numPiers < availPiers; numPiers++) {
361  if (bChans[numPiers] == AR5416_BCHAN_UNUSED)
362  break;
363  }
364 
365  match = ath9k_hw_get_lower_upper_index((u8)FREQ2FBIN(centers.synth_center,
366  IS_CHAN_2GHZ(chan)),
367  bChans, numPiers, &idxL, &idxR);
368 
369  if (match) {
370  if (AR_SREV_9287(ah)) {
371  for (i = 0; i < numXpdGains; i++) {
372  minPwrT4[i] = data_9287[idxL].pwrPdg[i][0];
373  maxPwrT4[i] = data_9287[idxL].pwrPdg[i][intercepts - 1];
374  ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
375  data_9287[idxL].pwrPdg[i],
376  data_9287[idxL].vpdPdg[i],
377  intercepts,
378  vpdTableI[i]);
379  }
380  } else if (eeprom_4k) {
381  for (i = 0; i < numXpdGains; i++) {
382  minPwrT4[i] = data_4k[idxL].pwrPdg[i][0];
383  maxPwrT4[i] = data_4k[idxL].pwrPdg[i][intercepts - 1];
384  ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
385  data_4k[idxL].pwrPdg[i],
386  data_4k[idxL].vpdPdg[i],
387  intercepts,
388  vpdTableI[i]);
389  }
390  } else {
391  for (i = 0; i < numXpdGains; i++) {
392  minPwrT4[i] = data_def[idxL].pwrPdg[i][0];
393  maxPwrT4[i] = data_def[idxL].pwrPdg[i][intercepts - 1];
394  ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
395  data_def[idxL].pwrPdg[i],
396  data_def[idxL].vpdPdg[i],
397  intercepts,
398  vpdTableI[i]);
399  }
400  }
401  } else {
402  for (i = 0; i < numXpdGains; i++) {
403  if (AR_SREV_9287(ah)) {
404  pVpdL = data_9287[idxL].vpdPdg[i];
405  pPwrL = data_9287[idxL].pwrPdg[i];
406  pVpdR = data_9287[idxR].vpdPdg[i];
407  pPwrR = data_9287[idxR].pwrPdg[i];
408  } else if (eeprom_4k) {
409  pVpdL = data_4k[idxL].vpdPdg[i];
410  pPwrL = data_4k[idxL].pwrPdg[i];
411  pVpdR = data_4k[idxR].vpdPdg[i];
412  pPwrR = data_4k[idxR].pwrPdg[i];
413  } else {
414  pVpdL = data_def[idxL].vpdPdg[i];
415  pPwrL = data_def[idxL].pwrPdg[i];
416  pVpdR = data_def[idxR].vpdPdg[i];
417  pPwrR = data_def[idxR].pwrPdg[i];
418  }
419 
420  minPwrT4[i] = max(pPwrL[0], pPwrR[0]);
421 
422  maxPwrT4[i] =
423  min(pPwrL[intercepts - 1],
424  pPwrR[intercepts - 1]);
425 
426 
427  ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
428  pPwrL, pVpdL,
429  intercepts,
430  vpdTableL[i]);
431  ath9k_hw_fill_vpd_table(minPwrT4[i], maxPwrT4[i],
432  pPwrR, pVpdR,
433  intercepts,
434  vpdTableR[i]);
435 
436  for (j = 0; j <= (maxPwrT4[i] - minPwrT4[i]) / 2; j++) {
437  vpdTableI[i][j] =
439  FREQ2FBIN(centers.
440  synth_center,
442  (chan)),
443  bChans[idxL], bChans[idxR],
444  vpdTableL[i][j], vpdTableR[i][j]));
445  }
446  }
447  }
448 
449  k = 0;
450 
451  for (i = 0; i < numXpdGains; i++) {
452  if (i == (numXpdGains - 1))
453  pPdGainBoundaries[i] =
454  (u16)(maxPwrT4[i] / 2);
455  else
456  pPdGainBoundaries[i] =
457  (u16)((maxPwrT4[i] + minPwrT4[i + 1]) / 4);
458 
459  pPdGainBoundaries[i] =
460  min((u16)MAX_RATE_POWER, pPdGainBoundaries[i]);
461 
462  if ((i == 0) && !AR_SREV_5416_20_OR_LATER(ah)) {
463  minDelta = pPdGainBoundaries[0] - 23;
464  pPdGainBoundaries[0] = 23;
465  } else {
466  minDelta = 0;
467  }
468 
469  if (i == 0) {
471  ss = (int16_t)(0 - (minPwrT4[i] / 2));
472  else
473  ss = 0;
474  } else {
475  ss = (int16_t)((pPdGainBoundaries[i - 1] -
476  (minPwrT4[i] / 2)) -
477  tPdGainOverlap + 1 + minDelta);
478  }
479  vpdStep = (int16_t)(vpdTableI[i][1] - vpdTableI[i][0]);
480  vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
481 
482  while ((ss < 0) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
483  tmpVal = (int16_t)(vpdTableI[i][0] + ss * vpdStep);
484  pPDADCValues[k++] = (u8)((tmpVal < 0) ? 0 : tmpVal);
485  ss++;
486  }
487 
488  sizeCurrVpdTable = (u8) ((maxPwrT4[i] - minPwrT4[i]) / 2 + 1);
489  tgtIndex = (u8)(pPdGainBoundaries[i] + tPdGainOverlap -
490  (minPwrT4[i] / 2));
491  maxIndex = (tgtIndex < sizeCurrVpdTable) ?
492  tgtIndex : sizeCurrVpdTable;
493 
494  while ((ss < maxIndex) && (k < (AR5416_NUM_PDADC_VALUES - 1))) {
495  pPDADCValues[k++] = vpdTableI[i][ss++];
496  }
497 
498  vpdStep = (int16_t)(vpdTableI[i][sizeCurrVpdTable - 1] -
499  vpdTableI[i][sizeCurrVpdTable - 2]);
500  vpdStep = (int16_t)((vpdStep < 1) ? 1 : vpdStep);
501 
502  if (tgtIndex >= maxIndex) {
503  while ((ss <= tgtIndex) &&
504  (k < (AR5416_NUM_PDADC_VALUES - 1))) {
505  tmpVal = (int16_t)((vpdTableI[i][sizeCurrVpdTable - 1] +
506  (ss - maxIndex + 1) * vpdStep));
507  pPDADCValues[k++] = (u8)((tmpVal > 255) ?
508  255 : tmpVal);
509  ss++;
510  }
511  }
512  }
513 
514  if (eeprom_4k)
515  pdgain_boundary_default = 58;
516  else
517  pdgain_boundary_default = pPdGainBoundaries[i - 1];
518 
519  while (i < AR5416_PD_GAINS_IN_MASK) {
520  pPdGainBoundaries[i] = pdgain_boundary_default;
521  i++;
522  }
523 
524  while (k < AR5416_NUM_PDADC_VALUES) {
525  pPDADCValues[k] = pPDADCValues[k - 1];
526  k++;
527  }
528 }
#define AR5416_NUM_PD_GAINS
Definition: eeprom.h:153
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:21
#define max(x, y)
Definition: ath.h:39
#define AR_SREV_9280_20_OR_LATER(_ah)
Definition: reg.h:824
#define IS_CHAN_2GHZ(_c)
Definition: hw.h:361
u8 vpdPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS]
Definition: eeprom.h:516
#define min(x, y)
Definition: ath.h:34
#define AR_SREV_5416_20_OR_LATER(_ah)
Definition: reg.h:801
#define AR_SREV_9285(_ah)
Definition: reg.h:829
int16_t ath9k_hw_interpolate(u16 target, u16 srcLeft, u16 srcRight, int16_t targetLeft, int16_t targetRight)
Definition: ath9k_eeprom.c:54
u8 pwrPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS]
Definition: eeprom.h:515
#define FREQ2FBIN(x, y)
Definition: eeprom.h:102
#define AR5416_PD_GAINS_IN_MASK
Definition: eeprom.h:154
#define AR_SREV_9287(_ah)
Definition: reg.h:834
void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList, u8 *pVpdList, u16 numIntercepts, u8 *pRetVpdList)
Definition: ath9k_eeprom.c:134
u8 pwrPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS]
Definition: eeprom.h:542
u8 pwrPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS]
Definition: eeprom.h:510
#define u8
Definition: igbvf_osdep.h:38
#define AR5416_PD_GAIN_ICEPTS
Definition: eeprom.h:155
#define AR5416_NUM_PDADC_VALUES
Definition: eeprom.h:156
int ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize, u16 *indexL, u16 *indexR)
Definition: ath9k_eeprom.c:69
#define AR5416_BCHAN_UNUSED
Definition: eeprom.h:157
#define AR9287_PD_GAIN_ICEPTS
Definition: eeprom.h:201
uint32_t ss
Definition: librm.h:250
u8 vpdPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS]
Definition: eeprom.h:511
static const uint32_t k[64]
MD5 constants.
Definition: md5.c:53
u8 vpdPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS]
Definition: eeprom.h:543
#define AR_SREV_9271(_ah)
Definition: reg.h:853
void ath9k_hw_get_channel_centers(struct ath_hw *ah __unused, struct ath9k_channel *chan, struct chan_centers *centers)
Definition: ath9k_hw.c:189
uint8_t ah
Definition: registers.h:85
#define AR5416_MAX_PWR_RANGE_IN_HALF_DB
Definition: eeprom.h:158
signed short int16_t
Definition: stdint.h:16
uint8_t u8
Definition: stdint.h:19
#define MAX_RATE_POWER
Definition: hw.h:144
void * memset(void *dest, int character, size_t len) __nonnull

References ah, AR5416_BCHAN_UNUSED, AR5416_MAX_PWR_RANGE_IN_HALF_DB, AR5416_NUM_PD_GAINS, AR5416_NUM_PDADC_VALUES, AR5416_PD_GAIN_ICEPTS, AR5416_PD_GAINS_IN_MASK, AR9287_PD_GAIN_ICEPTS, AR_SREV_5416_20_OR_LATER, AR_SREV_9271, AR_SREV_9280_20_OR_LATER, AR_SREV_9285, AR_SREV_9287, ath9k_hw_fill_vpd_table(), ath9k_hw_get_channel_centers(), ath9k_hw_get_lower_upper_index(), ath9k_hw_interpolate(), FREQ2FBIN, IS_CHAN_2GHZ, k, max, MAX_RATE_POWER, memset(), min, cal_data_per_freq::pwrPdg, cal_data_per_freq_4k::pwrPdg, cal_data_per_freq_ar9287::pwrPdg, ss, chan_centers::synth_center, u16, u8, cal_data_per_freq::vpdPdg, cal_data_per_freq_4k::vpdPdg, and cal_data_per_freq_ar9287::vpdPdg.

Referenced by ath9k_hw_set_4k_power_cal_table(), ath9k_hw_set_ar9287_power_cal_table(), and ath9k_hw_set_def_power_cal_table().

◆ ath9k_hw_eeprom_init()

int ath9k_hw_eeprom_init ( struct ath_hw ah)

Definition at line 530 of file ath9k_eeprom.c.

531 {
532  int status;
533 
535  ah->eep_ops = &eep_ar9300_ops;
536  else if (AR_SREV_9287(ah)) {
537  ah->eep_ops = &eep_ar9287_ops;
538  } else if (AR_SREV_9285(ah) || AR_SREV_9271(ah)) {
539  ah->eep_ops = &eep_4k_ops;
540  } else {
541  ah->eep_ops = &eep_def_ops;
542  }
543 
544  if (!ah->eep_ops->fill_eeprom(ah))
545  return -EIO;
546 
547  status = ah->eep_ops->check_eeprom(ah);
548 
549  return status;
550 }
const struct eeprom_ops eep_4k_ops
#define AR_SREV_9285(_ah)
Definition: reg.h:829
const struct eeprom_ops eep_def_ops
uint8_t status
Status.
Definition: ena.h:16
#define AR_SREV_9287(_ah)
Definition: reg.h:834
#define AR_SREV_9300_20_OR_LATER(_ah)
Definition: reg.h:864
const struct eeprom_ops eep_ar9300_ops
const struct eeprom_ops eep_ar9287_ops
#define EIO
Input/output error.
Definition: errno.h:433
#define AR_SREV_9271(_ah)
Definition: reg.h:853
uint8_t ah
Definition: registers.h:85

References ah, AR_SREV_9271, AR_SREV_9285, AR_SREV_9287, AR_SREV_9300_20_OR_LATER, eep_4k_ops, eep_ar9287_ops, eep_ar9300_ops, eep_def_ops, EIO, and status.

Referenced by ath9k_hw_post_init().