iPXE
ath5k_eeprom.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2008 Reyk Floeter <reyk@openbsd.org>
3  * Copyright (c) 2006-2009 Nick Kossifidis <mickflemm@gmail.com>
4  * Copyright (c) 2008-2009 Felix Fietkau <nbd@openwrt.org>
5  *
6  * Lightly modified for iPXE, July 2009, by Joshua Oreman <oremanj@rwcr.net>.
7  *
8  * Permission to use, copy, modify, and distribute this software for any
9  * purpose with or without fee is hereby granted, provided that the above
10  * copyright notice and this permission notice appear in all copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
13  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
15  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
16  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
17  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
18  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19  *
20  */
21 
22 FILE_LICENCE ( MIT );
23 FILE_SECBOOT ( FORBIDDEN );
24 
25 /*************************************\
26 * EEPROM access functions and helpers *
27 \*************************************/
28 
29 #include <unistd.h>
30 #include <stdlib.h>
31 
32 #include "ath5k.h"
33 #include "reg.h"
34 #include "base.h"
35 
36 /*
37  * Read from eeprom
38  */
40 {
42 
43  /* Avoid returning uninitialised data on error */
44  *data = 0xffff;
45 
46  /*
47  * Initialize EEPROM access
48  */
49  if (ah->ah_version == AR5K_AR5210) {
52  } else {
56  }
57 
62  return -EIO;
64  0xffff);
65  return 0;
66  }
67  udelay(15);
68  }
69 
70  return -ETIMEDOUT;
71 }
72 
73 /*
74  * Translate binary channel representation in EEPROM to frequency
75  */
77  unsigned int mode)
78 {
79  u16 val;
80 
81  if (bin == AR5K_EEPROM_CHANNEL_DIS)
82  return bin;
83 
84  if (mode == AR5K_EEPROM_MODE_11A) {
86  val = (5 * bin) + 4800;
87  else
88  val = bin > 62 ? (10 * 62) + (5 * (bin - 62)) + 5100 :
89  (bin * 10) + 5100;
90  } else {
92  val = bin + 2300;
93  else
94  val = bin + 2400;
95  }
96 
97  return val;
98 }
99 
100 /*
101  * Initialize eeprom & capabilities structs
102  */
103 static int
105 {
106  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
107  int ret;
108  u16 val;
109 
110  /*
111  * Read values from EEPROM and store them in the capability structure
112  */
118 
119  /* Return if we have an old EEPROM */
120  if (ah->ah_ee_version < AR5K_EEPROM_VERSION_3_0)
121  return 0;
122 
124  ee_ant_gain);
125 
126  if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0) {
129 
130  /* XXX: Don't know which versions include these two */
132 
135 
136  if (ee->ee_version >= AR5K_EEPROM_VERSION_5_0) {
140  }
141  }
142 
143  if (ah->ah_ee_version < AR5K_EEPROM_VERSION_3_3) {
145  ee->ee_ob[AR5K_EEPROM_MODE_11B][0] = val & 0x7;
146  ee->ee_db[AR5K_EEPROM_MODE_11B][0] = (val >> 3) & 0x7;
147 
149  ee->ee_ob[AR5K_EEPROM_MODE_11G][0] = val & 0x7;
150  ee->ee_db[AR5K_EEPROM_MODE_11G][0] = (val >> 3) & 0x7;
151  }
152 
154 
155  if ((ah->ah_mac_version == (AR5K_SREV_AR2425 >> 4)) && val)
156  ee->ee_is_hb63 = 1;
157  else
158  ee->ee_is_hb63 = 0;
159 
163 
164  return 0;
165 }
166 
167 
168 /*
169  * Read antenna infos from eeprom
170  */
172  unsigned int mode)
173 {
174  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
175  u32 o = *offset;
176  u16 val;
177  int ret, i = 0;
178 
179  AR5K_EEPROM_READ(o++, val);
180  ee->ee_switch_settling[mode] = (val >> 8) & 0x7f;
181  ee->ee_atn_tx_rx[mode] = (val >> 2) & 0x3f;
182  ee->ee_ant_control[mode][i] = (val << 4) & 0x3f;
183 
184  AR5K_EEPROM_READ(o++, val);
185  ee->ee_ant_control[mode][i++] |= (val >> 12) & 0xf;
186  ee->ee_ant_control[mode][i++] = (val >> 6) & 0x3f;
187  ee->ee_ant_control[mode][i++] = val & 0x3f;
188 
189  AR5K_EEPROM_READ(o++, val);
190  ee->ee_ant_control[mode][i++] = (val >> 10) & 0x3f;
191  ee->ee_ant_control[mode][i++] = (val >> 4) & 0x3f;
192  ee->ee_ant_control[mode][i] = (val << 2) & 0x3f;
193 
194  AR5K_EEPROM_READ(o++, val);
195  ee->ee_ant_control[mode][i++] |= (val >> 14) & 0x3;
196  ee->ee_ant_control[mode][i++] = (val >> 8) & 0x3f;
197  ee->ee_ant_control[mode][i++] = (val >> 2) & 0x3f;
198  ee->ee_ant_control[mode][i] = (val << 4) & 0x3f;
199 
200  AR5K_EEPROM_READ(o++, val);
201  ee->ee_ant_control[mode][i++] |= (val >> 12) & 0xf;
202  ee->ee_ant_control[mode][i++] = (val >> 6) & 0x3f;
203  ee->ee_ant_control[mode][i++] = val & 0x3f;
204 
205  /* Get antenna modes */
206  ah->ah_antenna[mode][0] =
207  (ee->ee_ant_control[mode][0] << 4);
208  ah->ah_antenna[mode][AR5K_ANT_FIXED_A] =
209  ee->ee_ant_control[mode][1] |
210  (ee->ee_ant_control[mode][2] << 6) |
211  (ee->ee_ant_control[mode][3] << 12) |
212  (ee->ee_ant_control[mode][4] << 18) |
213  (ee->ee_ant_control[mode][5] << 24);
214  ah->ah_antenna[mode][AR5K_ANT_FIXED_B] =
215  ee->ee_ant_control[mode][6] |
216  (ee->ee_ant_control[mode][7] << 6) |
217  (ee->ee_ant_control[mode][8] << 12) |
218  (ee->ee_ant_control[mode][9] << 18) |
219  (ee->ee_ant_control[mode][10] << 24);
220 
221  /* return new offset */
222  *offset = o;
223 
224  return 0;
225 }
226 
227 /*
228  * Read supported modes and some mode-specific calibration data
229  * from eeprom
230  */
232  unsigned int mode)
233 {
234  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
235  u32 o = *offset;
236  u16 val;
237  int ret;
238 
239  ee->ee_n_piers[mode] = 0;
240  AR5K_EEPROM_READ(o++, val);
241  ee->ee_adc_desired_size[mode] = (s8)((val >> 8) & 0xff);
242  switch(mode) {
244  ee->ee_ob[mode][3] = (val >> 5) & 0x7;
245  ee->ee_db[mode][3] = (val >> 2) & 0x7;
246  ee->ee_ob[mode][2] = (val << 1) & 0x7;
247 
248  AR5K_EEPROM_READ(o++, val);
249  ee->ee_ob[mode][2] |= (val >> 15) & 0x1;
250  ee->ee_db[mode][2] = (val >> 12) & 0x7;
251  ee->ee_ob[mode][1] = (val >> 9) & 0x7;
252  ee->ee_db[mode][1] = (val >> 6) & 0x7;
253  ee->ee_ob[mode][0] = (val >> 3) & 0x7;
254  ee->ee_db[mode][0] = val & 0x7;
255  break;
258  ee->ee_ob[mode][1] = (val >> 4) & 0x7;
259  ee->ee_db[mode][1] = val & 0x7;
260  break;
261  }
262 
263  AR5K_EEPROM_READ(o++, val);
264  ee->ee_tx_end2xlna_enable[mode] = (val >> 8) & 0xff;
265  ee->ee_thr_62[mode] = val & 0xff;
266 
267  if (ah->ah_ee_version <= AR5K_EEPROM_VERSION_3_2)
268  ee->ee_thr_62[mode] = mode == AR5K_EEPROM_MODE_11A ? 15 : 28;
269 
270  AR5K_EEPROM_READ(o++, val);
271  ee->ee_tx_end2xpa_disable[mode] = (val >> 8) & 0xff;
272  ee->ee_tx_frm2xpa_enable[mode] = val & 0xff;
273 
274  AR5K_EEPROM_READ(o++, val);
275  ee->ee_pga_desired_size[mode] = (val >> 8) & 0xff;
276 
277  if ((val & 0xff) & 0x80)
278  ee->ee_noise_floor_thr[mode] = -((((val & 0xff) ^ 0xff)) + 1);
279  else
280  ee->ee_noise_floor_thr[mode] = val & 0xff;
281 
282  if (ah->ah_ee_version <= AR5K_EEPROM_VERSION_3_2)
283  ee->ee_noise_floor_thr[mode] =
284  mode == AR5K_EEPROM_MODE_11A ? -54 : -1;
285 
286  AR5K_EEPROM_READ(o++, val);
287  ee->ee_xlna_gain[mode] = (val >> 5) & 0xff;
288  ee->ee_x_gain[mode] = (val >> 1) & 0xf;
289  ee->ee_xpd[mode] = val & 0x1;
290 
291  if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0)
292  ee->ee_fixed_bias[mode] = (val >> 13) & 0x1;
293 
294  if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_3_3) {
295  AR5K_EEPROM_READ(o++, val);
296  ee->ee_false_detect[mode] = (val >> 6) & 0x7f;
297 
298  if (mode == AR5K_EEPROM_MODE_11A)
299  ee->ee_xr_power[mode] = val & 0x3f;
300  else {
301  ee->ee_ob[mode][0] = val & 0x7;
302  ee->ee_db[mode][0] = (val >> 3) & 0x7;
303  }
304  }
305 
306  if (ah->ah_ee_version < AR5K_EEPROM_VERSION_3_4) {
309  } else {
310  ee->ee_i_gain[mode] = (val >> 13) & 0x7;
311 
312  AR5K_EEPROM_READ(o++, val);
313  ee->ee_i_gain[mode] |= (val << 3) & 0x38;
314 
315  if (mode == AR5K_EEPROM_MODE_11G) {
316  ee->ee_cck_ofdm_power_delta = (val >> 3) & 0xff;
317  if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_6)
318  ee->ee_scaled_cck_delta = (val >> 11) & 0x1f;
319  }
320  }
321 
322  if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0 &&
324  ee->ee_i_cal[mode] = (val >> 8) & 0x3f;
325  ee->ee_q_cal[mode] = (val >> 3) & 0x1f;
326  }
327 
328  if (ah->ah_ee_version < AR5K_EEPROM_VERSION_4_0)
329  goto done;
330 
331  /* Note: >= v5 have bg freq piers on another location
332  * so these freq piers are ignored for >= v5 (should be 0xff
333  * anyway) */
334  switch(mode) {
336  if (ah->ah_ee_version < AR5K_EEPROM_VERSION_4_1)
337  break;
338 
339  AR5K_EEPROM_READ(o++, val);
340  ee->ee_margin_tx_rx[mode] = val & 0x3f;
341  break;
343  AR5K_EEPROM_READ(o++, val);
344 
345  ee->ee_pwr_cal_b[0].freq =
346  ath5k_eeprom_bin2freq(ee, val & 0xff, mode);
348  ee->ee_n_piers[mode]++;
349 
350  ee->ee_pwr_cal_b[1].freq =
351  ath5k_eeprom_bin2freq(ee, (val >> 8) & 0xff, mode);
353  ee->ee_n_piers[mode]++;
354 
355  AR5K_EEPROM_READ(o++, val);
356  ee->ee_pwr_cal_b[2].freq =
357  ath5k_eeprom_bin2freq(ee, val & 0xff, mode);
359  ee->ee_n_piers[mode]++;
360 
361  if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_1)
362  ee->ee_margin_tx_rx[mode] = (val >> 8) & 0x3f;
363  break;
365  AR5K_EEPROM_READ(o++, val);
366 
367  ee->ee_pwr_cal_g[0].freq =
368  ath5k_eeprom_bin2freq(ee, val & 0xff, mode);
370  ee->ee_n_piers[mode]++;
371 
372  ee->ee_pwr_cal_g[1].freq =
373  ath5k_eeprom_bin2freq(ee, (val >> 8) & 0xff, mode);
375  ee->ee_n_piers[mode]++;
376 
377  AR5K_EEPROM_READ(o++, val);
378  ee->ee_turbo_max_power[mode] = val & 0x7f;
379  ee->ee_xr_power[mode] = (val >> 7) & 0x3f;
380 
381  AR5K_EEPROM_READ(o++, val);
382  ee->ee_pwr_cal_g[2].freq =
383  ath5k_eeprom_bin2freq(ee, val & 0xff, mode);
385  ee->ee_n_piers[mode]++;
386 
387  if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_1)
388  ee->ee_margin_tx_rx[mode] = (val >> 8) & 0x3f;
389 
390  AR5K_EEPROM_READ(o++, val);
391  ee->ee_i_cal[mode] = (val >> 8) & 0x3f;
392  ee->ee_q_cal[mode] = (val >> 3) & 0x1f;
393 
394  if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_2) {
395  AR5K_EEPROM_READ(o++, val);
396  ee->ee_cck_ofdm_gain_delta = val & 0xff;
397  }
398  break;
399  }
400 
401 done:
402  /* return new offset */
403  *offset = o;
404 
405  return 0;
406 }
407 
408 /*
409  * Read turbo mode information on newer EEPROM versions
410  */
411 static int
413  u32 *offset, unsigned int mode)
414 {
415  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
416  u32 o = *offset;
417  u16 val;
418  int ret;
419 
421  return 0;
422 
423  AR5K_EEPROM_READ(o++, val);
424  switch (mode){
426  ee->ee_switch_settling_turbo[mode] = (val >> 6) & 0x7f;
427 
428  ee->ee_atn_tx_rx_turbo[mode] = (val >> 13) & 0x7;
429  AR5K_EEPROM_READ(o++, val);
430  ee->ee_atn_tx_rx_turbo[mode] |= (val & 0x7) << 3;
431  ee->ee_margin_tx_rx_turbo[mode] = (val >> 3) & 0x3f;
432 
433  ee->ee_adc_desired_size_turbo[mode] = (val >> 9) & 0x7f;
434  AR5K_EEPROM_READ(o++, val);
435  ee->ee_adc_desired_size_turbo[mode] |= (val & 0x1) << 7;
436  ee->ee_pga_desired_size_turbo[mode] = (val >> 1) & 0xff;
437 
438  if (AR5K_EEPROM_EEMAP(ee->ee_misc0) >=2)
439  ee->ee_pd_gain_overlap = (val >> 9) & 0xf;
440  break;
442  ee->ee_switch_settling_turbo[mode] = (val >> 8) & 0x7f;
443 
444  ee->ee_atn_tx_rx_turbo[mode] = (val >> 15) & 0x7;
445  AR5K_EEPROM_READ(o++, val);
446  ee->ee_atn_tx_rx_turbo[mode] |= (val & 0x1f) << 1;
447  ee->ee_margin_tx_rx_turbo[mode] = (val >> 5) & 0x3f;
448 
449  ee->ee_adc_desired_size_turbo[mode] = (val >> 11) & 0x7f;
450  AR5K_EEPROM_READ(o++, val);
451  ee->ee_adc_desired_size_turbo[mode] |= (val & 0x7) << 5;
452  ee->ee_pga_desired_size_turbo[mode] = (val >> 3) & 0xff;
453  break;
454  }
455 
456  /* return new offset */
457  *offset = o;
458 
459  return 0;
460 }
461 
462 /* Read mode-specific data (except power calibration data) */
463 static int
465 {
466  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
467  u32 mode_offset[3];
468  unsigned int mode;
469  u32 offset;
470  int ret;
471 
472  /*
473  * Get values for all modes
474  */
475  mode_offset[AR5K_EEPROM_MODE_11A] = AR5K_EEPROM_MODES_11A(ah->ah_ee_version);
476  mode_offset[AR5K_EEPROM_MODE_11B] = AR5K_EEPROM_MODES_11B(ah->ah_ee_version);
477  mode_offset[AR5K_EEPROM_MODE_11G] = AR5K_EEPROM_MODES_11G(ah->ah_ee_version);
478 
481 
483  offset = mode_offset[mode];
484 
486  if (ret)
487  return ret;
488 
490  if (ret)
491  return ret;
492 
494  if (ret)
495  return ret;
496  }
497 
498  /* override for older eeprom versions for better performance */
499  if (ah->ah_ee_version <= AR5K_EEPROM_VERSION_3_2) {
503  }
504 
505  return 0;
506 }
507 
508 /* Read the frequency piers for each mode (mostly used on newer eeproms with 0xff
509  * frequency mask) */
510 static inline int
512  struct ath5k_chan_pcal_info *pc, unsigned int mode)
513 {
514  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
515  int o = *offset;
516  int i = 0;
517  u8 freq1, freq2;
518  int ret;
519  u16 val;
520 
521  ee->ee_n_piers[mode] = 0;
522  while(i < max) {
523  AR5K_EEPROM_READ(o++, val);
524 
525  freq1 = val & 0xff;
526  if (!freq1)
527  break;
528 
529  pc[i++].freq = ath5k_eeprom_bin2freq(ee,
530  freq1, mode);
531  ee->ee_n_piers[mode]++;
532 
533  freq2 = (val >> 8) & 0xff;
534  if (!freq2)
535  break;
536 
537  pc[i++].freq = ath5k_eeprom_bin2freq(ee,
538  freq2, mode);
539  ee->ee_n_piers[mode]++;
540  }
541 
542  /* return new offset */
543  *offset = o;
544 
545  return 0;
546 }
547 
548 /* Read frequency piers for 802.11a */
549 static int
551 {
552  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
553  struct ath5k_chan_pcal_info *pcal = ee->ee_pwr_cal_a;
554  int i, ret;
555  u16 val;
556  u8 mask;
557 
558  if (ee->ee_version >= AR5K_EEPROM_VERSION_3_3) {
562  } else {
563  mask = AR5K_EEPROM_FREQ_M(ah->ah_ee_version);
564 
566  pcal[0].freq = (val >> 9) & mask;
567  pcal[1].freq = (val >> 2) & mask;
568  pcal[2].freq = (val << 5) & mask;
569 
571  pcal[2].freq |= (val >> 11) & 0x1f;
572  pcal[3].freq = (val >> 4) & mask;
573  pcal[4].freq = (val << 3) & mask;
574 
576  pcal[4].freq |= (val >> 13) & 0x7;
577  pcal[5].freq = (val >> 6) & mask;
578  pcal[6].freq = (val << 1) & mask;
579 
581  pcal[6].freq |= (val >> 15) & 0x1;
582  pcal[7].freq = (val >> 8) & mask;
583  pcal[8].freq = (val >> 1) & mask;
584  pcal[9].freq = (val << 6) & mask;
585 
587  pcal[9].freq |= (val >> 10) & 0x3f;
588 
589  /* Fixed number of piers */
591 
592  for (i = 0; i < AR5K_EEPROM_N_5GHZ_CHAN; i++) {
593  pcal[i].freq = ath5k_eeprom_bin2freq(ee,
594  pcal[i].freq, AR5K_EEPROM_MODE_11A);
595  }
596  }
597 
598  return 0;
599 }
600 
601 /* Read frequency piers for 802.11bg on eeprom versions >= 5 and eemap >= 2 */
602 static inline int
603 ath5k_eeprom_init_11bg_2413(struct ath5k_hw *ah, unsigned int mode, int offset)
604 {
605  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
606  struct ath5k_chan_pcal_info *pcal;
607 
608  switch(mode) {
610  pcal = ee->ee_pwr_cal_b;
611  break;
613  pcal = ee->ee_pwr_cal_g;
614  break;
615  default:
616  return -EINVAL;
617  }
618 
621  mode);
622 
623  return 0;
624 }
625 
626 /*
627  * Read power calibration for RF5111 chips
628  *
629  * For RF5111 we have an XPD -eXternal Power Detector- curve
630  * for each calibrated channel. Each curve has 0,5dB Power steps
631  * on x axis and PCDAC steps (offsets) on y axis and looks like an
632  * exponential function. To recreate the curve we read 11 points
633  * here and interpolate later.
634  */
635 
636 /* Used to match PCDAC steps with power values on RF5111 chips
637  * (eeprom versions < 4). For RF5111 we have 11 pre-defined PCDAC
638  * steps that match with the power values we read from eeprom. On
639  * older eeprom versions (< 3.2) these steps are equaly spaced at
640  * 10% of the pcdac curve -until the curve reaches it's maximum-
641  * (11 steps from 0 to 100%) but on newer eeprom versions (>= 3.2)
642  * these 11 steps are spaced in a different way. This function returns
643  * the pcdac steps based on eeprom version and curve min/max so that we
644  * can have pcdac/pwr points.
645  */
646 static inline void
648 {
649  static const u16 intercepts3[] =
650  { 0, 5, 10, 20, 30, 50, 70, 85, 90, 95, 100 };
651  static const u16 intercepts3_2[] =
652  { 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100 };
653  const u16 *ip;
654  unsigned i;
655 
656  if (ah->ah_ee_version >= AR5K_EEPROM_VERSION_3_2)
657  ip = intercepts3_2;
658  else
659  ip = intercepts3;
660 
661  for (i = 0; i < ARRAY_SIZE(intercepts3); i++)
662  vp[i] = (ip[i] * max + (100 - ip[i]) * min) / 100;
663 }
664 
665 /* Convert RF5111 specific data to generic raw data
666  * used by interpolation code */
667 static int
669  struct ath5k_chan_pcal_info *chinfo)
670 {
671  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
672  struct ath5k_chan_pcal_info_rf5111 *pcinfo;
673  struct ath5k_pdgain_info *pd;
674  u8 pier, point, idx;
675  u8 *pdgain_idx = ee->ee_pdc_to_idx[mode];
676 
677  /* Fill raw data for each calibration pier */
678  for (pier = 0; pier < ee->ee_n_piers[mode]; pier++) {
679 
680  pcinfo = &chinfo[pier].rf5111_info;
681 
682  /* Allocate pd_curves for this cal pier */
683  chinfo[pier].pd_curves =
685  sizeof(struct ath5k_pdgain_info));
686 
687  if (!chinfo[pier].pd_curves)
688  return -ENOMEM;
689 
690  /* Only one curve for RF5111
691  * find out which one and place
692  * in in pd_curves.
693  * Note: ee_x_gain is reversed here */
694  for (idx = 0; idx < AR5K_EEPROM_N_PD_CURVES; idx++) {
695 
696  if (!((ee->ee_x_gain[mode] >> idx) & 0x1)) {
697  pdgain_idx[0] = idx;
698  break;
699  }
700  }
701 
702  ee->ee_pd_gains[mode] = 1;
703 
704  pd = &chinfo[pier].pd_curves[idx];
705 
707 
708  /* Allocate pd points for this curve */
710  if (!pd->pd_step)
711  return -ENOMEM;
712 
714  if (!pd->pd_pwr)
715  return -ENOMEM;
716 
717  /* Fill raw dataset
718  * (convert power to 0.25dB units
719  * for RF5112 combatibility) */
720  for (point = 0; point < pd->pd_points; point++) {
721 
722  /* Absolute values */
723  pd->pd_pwr[point] = 2 * pcinfo->pwr[point];
724 
725  /* Already sorted */
726  pd->pd_step[point] = pcinfo->pcdac[point];
727  }
728 
729  /* Set min/max pwr */
730  chinfo[pier].min_pwr = pd->pd_pwr[0];
731  chinfo[pier].max_pwr = pd->pd_pwr[10];
732 
733  }
734 
735  return 0;
736 }
737 
738 /* Parse EEPROM data */
739 static int
741 {
742  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
743  struct ath5k_chan_pcal_info *pcal;
744  int offset, ret;
745  int i;
746  u16 val;
747 
749  switch(mode) {
751  if (!AR5K_EEPROM_HDR_11A(ee->ee_header))
752  return 0;
753 
756  if (ret < 0)
757  return ret;
758 
760  pcal = ee->ee_pwr_cal_a;
761  break;
763  if (!AR5K_EEPROM_HDR_11B(ee->ee_header) &&
765  return 0;
766 
767  pcal = ee->ee_pwr_cal_b;
769 
770  /* fixed piers */
771  pcal[0].freq = 2412;
772  pcal[1].freq = 2447;
773  pcal[2].freq = 2484;
774  ee->ee_n_piers[mode] = 3;
775  break;
777  if (!AR5K_EEPROM_HDR_11G(ee->ee_header))
778  return 0;
779 
780  pcal = ee->ee_pwr_cal_g;
782 
783  /* fixed piers */
784  pcal[0].freq = 2312;
785  pcal[1].freq = 2412;
786  pcal[2].freq = 2484;
787  ee->ee_n_piers[mode] = 3;
788  break;
789  default:
790  return -EINVAL;
791  }
792 
793  for (i = 0; i < ee->ee_n_piers[mode]; i++) {
794  struct ath5k_chan_pcal_info_rf5111 *cdata =
795  &pcal[i].rf5111_info;
796 
798  cdata->pcdac_max = ((val >> 10) & AR5K_EEPROM_PCDAC_M);
799  cdata->pcdac_min = ((val >> 4) & AR5K_EEPROM_PCDAC_M);
800  cdata->pwr[0] = ((val << 2) & AR5K_EEPROM_POWER_M);
801 
803  cdata->pwr[0] |= ((val >> 14) & 0x3);
804  cdata->pwr[1] = ((val >> 8) & AR5K_EEPROM_POWER_M);
805  cdata->pwr[2] = ((val >> 2) & AR5K_EEPROM_POWER_M);
806  cdata->pwr[3] = ((val << 4) & AR5K_EEPROM_POWER_M);
807 
809  cdata->pwr[3] |= ((val >> 12) & 0xf);
810  cdata->pwr[4] = ((val >> 6) & AR5K_EEPROM_POWER_M);
811  cdata->pwr[5] = (val & AR5K_EEPROM_POWER_M);
812 
814  cdata->pwr[6] = ((val >> 10) & AR5K_EEPROM_POWER_M);
815  cdata->pwr[7] = ((val >> 4) & AR5K_EEPROM_POWER_M);
816  cdata->pwr[8] = ((val << 2) & AR5K_EEPROM_POWER_M);
817 
819  cdata->pwr[8] |= ((val >> 14) & 0x3);
820  cdata->pwr[9] = ((val >> 8) & AR5K_EEPROM_POWER_M);
821  cdata->pwr[10] = ((val >> 2) & AR5K_EEPROM_POWER_M);
822 
824  cdata->pcdac_max, cdata->pcdac);
825  }
826 
828 }
829 
830 
831 /*
832  * Read power calibration for RF5112 chips
833  *
834  * For RF5112 we have 4 XPD -eXternal Power Detector- curves
835  * for each calibrated channel on 0, -6, -12 and -18dbm but we only
836  * use the higher (3) and the lower (0) curves. Each curve has 0.5dB
837  * power steps on x axis and PCDAC steps on y axis and looks like a
838  * linear function. To recreate the curve and pass the power values
839  * on hw, we read 4 points for xpd 0 (lower gain -> max power)
840  * and 3 points for xpd 3 (higher gain -> lower power) here and
841  * interpolate later.
842  *
843  * Note: Many vendors just use xpd 0 so xpd 3 is zeroed.
844  */
845 
846 /* Convert RF5112 specific data to generic raw data
847  * used by interpolation code */
848 static int
850  struct ath5k_chan_pcal_info *chinfo)
851 {
852  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
853  struct ath5k_chan_pcal_info_rf5112 *pcinfo;
854  u8 *pdgain_idx = ee->ee_pdc_to_idx[mode];
855  unsigned int pier, pdg, point;
856 
857  /* Fill raw data for each calibration pier */
858  for (pier = 0; pier < ee->ee_n_piers[mode]; pier++) {
859 
860  pcinfo = &chinfo[pier].rf5112_info;
861 
862  /* Allocate pd_curves for this cal pier */
863  chinfo[pier].pd_curves =
865  sizeof(struct ath5k_pdgain_info));
866 
867  if (!chinfo[pier].pd_curves)
868  return -ENOMEM;
869 
870  /* Fill pd_curves */
871  for (pdg = 0; pdg < ee->ee_pd_gains[mode]; pdg++) {
872 
873  u8 idx = pdgain_idx[pdg];
874  struct ath5k_pdgain_info *pd =
875  &chinfo[pier].pd_curves[idx];
876 
877  /* Lowest gain curve (max power) */
878  if (pdg == 0) {
879  /* One more point for better accuracy */
881 
882  /* Allocate pd points for this curve */
883  pd->pd_step = calloc(pd->pd_points, sizeof(u8));
884 
885  if (!pd->pd_step)
886  return -ENOMEM;
887 
888  pd->pd_pwr = calloc(pd->pd_points, sizeof(s16));
889 
890  if (!pd->pd_pwr)
891  return -ENOMEM;
892 
893 
894  /* Fill raw dataset
895  * (all power levels are in 0.25dB units) */
896  pd->pd_step[0] = pcinfo->pcdac_x0[0];
897  pd->pd_pwr[0] = pcinfo->pwr_x0[0];
898 
899  for (point = 1; point < pd->pd_points;
900  point++) {
901  /* Absolute values */
902  pd->pd_pwr[point] =
903  pcinfo->pwr_x0[point];
904 
905  /* Deltas */
906  pd->pd_step[point] =
907  pd->pd_step[point - 1] +
908  pcinfo->pcdac_x0[point];
909  }
910 
911  /* Set min power for this frequency */
912  chinfo[pier].min_pwr = pd->pd_pwr[0];
913 
914  /* Highest gain curve (min power) */
915  } else if (pdg == 1) {
916 
918 
919  /* Allocate pd points for this curve */
920  pd->pd_step = calloc(pd->pd_points, sizeof(u8));
921 
922  if (!pd->pd_step)
923  return -ENOMEM;
924 
925  pd->pd_pwr = calloc(pd->pd_points, sizeof(s16));
926 
927  if (!pd->pd_pwr)
928  return -ENOMEM;
929 
930  /* Fill raw dataset
931  * (all power levels are in 0.25dB units) */
932  for (point = 0; point < pd->pd_points;
933  point++) {
934  /* Absolute values */
935  pd->pd_pwr[point] =
936  pcinfo->pwr_x3[point];
937 
938  /* Fixed points */
939  pd->pd_step[point] =
940  pcinfo->pcdac_x3[point];
941  }
942 
943  /* Since we have a higher gain curve
944  * override min power */
945  chinfo[pier].min_pwr = pd->pd_pwr[0];
946  }
947  }
948  }
949 
950  return 0;
951 }
952 
953 /* Parse EEPROM data */
954 static int
956 {
957  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
958  struct ath5k_chan_pcal_info_rf5112 *chan_pcal_info;
959  struct ath5k_chan_pcal_info *gen_chan_info;
960  u8 *pdgain_idx = ee->ee_pdc_to_idx[mode];
961  u32 offset;
962  u8 i, c;
963  u16 val;
964  int ret;
965  u8 pd_gains = 0;
966 
967  /* Count how many curves we have and
968  * identify them (which one of the 4
969  * available curves we have on each count).
970  * Curves are stored from lower (x0) to
971  * higher (x3) gain */
972  for (i = 0; i < AR5K_EEPROM_N_PD_CURVES; i++) {
973  /* ee_x_gain[mode] is x gain mask */
974  if ((ee->ee_x_gain[mode] >> i) & 0x1)
975  pdgain_idx[pd_gains++] = i;
976  }
977  ee->ee_pd_gains[mode] = pd_gains;
978 
979  if (pd_gains == 0 || pd_gains > 2)
980  return -EINVAL;
981 
982  switch (mode) {
984  /*
985  * Read 5GHz EEPROM channels
986  */
989 
991  gen_chan_info = ee->ee_pwr_cal_a;
992  break;
997 
998  /* NB: frequency piers parsed during mode init */
999  gen_chan_info = ee->ee_pwr_cal_b;
1000  break;
1001  case AR5K_EEPROM_MODE_11G:
1003  if (AR5K_EEPROM_HDR_11A(ee->ee_header))
1005  else if (AR5K_EEPROM_HDR_11B(ee->ee_header))
1007 
1008  /* NB: frequency piers parsed during mode init */
1009  gen_chan_info = ee->ee_pwr_cal_g;
1010  break;
1011  default:
1012  return -EINVAL;
1013  }
1014 
1015  for (i = 0; i < ee->ee_n_piers[mode]; i++) {
1016  chan_pcal_info = &gen_chan_info[i].rf5112_info;
1017 
1018  /* Power values in quarter dB
1019  * for the lower xpd gain curve
1020  * (0 dBm -> higher output power) */
1021  for (c = 0; c < AR5K_EEPROM_N_XPD0_POINTS; c++) {
1023  chan_pcal_info->pwr_x0[c] = (s8) (val & 0xff);
1024  chan_pcal_info->pwr_x0[++c] = (s8) ((val >> 8) & 0xff);
1025  }
1026 
1027  /* PCDAC steps
1028  * corresponding to the above power
1029  * measurements */
1031  chan_pcal_info->pcdac_x0[1] = (val & 0x1f);
1032  chan_pcal_info->pcdac_x0[2] = ((val >> 5) & 0x1f);
1033  chan_pcal_info->pcdac_x0[3] = ((val >> 10) & 0x1f);
1034 
1035  /* Power values in quarter dB
1036  * for the higher xpd gain curve
1037  * (18 dBm -> lower output power) */
1039  chan_pcal_info->pwr_x3[0] = (s8) (val & 0xff);
1040  chan_pcal_info->pwr_x3[1] = (s8) ((val >> 8) & 0xff);
1041 
1043  chan_pcal_info->pwr_x3[2] = (val & 0xff);
1044 
1045  /* PCDAC steps
1046  * corresponding to the above power
1047  * measurements (fixed) */
1048  chan_pcal_info->pcdac_x3[0] = 20;
1049  chan_pcal_info->pcdac_x3[1] = 35;
1050  chan_pcal_info->pcdac_x3[2] = 63;
1051 
1052  if (ee->ee_version >= AR5K_EEPROM_VERSION_4_3) {
1053  chan_pcal_info->pcdac_x0[0] = ((val >> 8) & 0x3f);
1054 
1055  /* Last xpd0 power level is also channel maximum */
1056  gen_chan_info[i].max_pwr = chan_pcal_info->pwr_x0[3];
1057  } else {
1058  chan_pcal_info->pcdac_x0[0] = 1;
1059  gen_chan_info[i].max_pwr = (s8) ((val >> 8) & 0xff);
1060  }
1061 
1062  }
1063 
1064  return ath5k_eeprom_convert_pcal_info_5112(ah, mode, gen_chan_info);
1065 }
1066 
1067 
1068 /*
1069  * Read power calibration for RF2413 chips
1070  *
1071  * For RF2413 we have a Power to PDDAC table (Power Detector)
1072  * instead of a PCDAC and 4 pd gain curves for each calibrated channel.
1073  * Each curve has power on x axis in 0.5 db steps and PDDADC steps on y
1074  * axis and looks like an exponential function like the RF5111 curve.
1075  *
1076  * To recreate the curves we read here the points and interpolate
1077  * later. Note that in most cases only 2 (higher and lower) curves are
1078  * used (like RF5112) but vendors have the oportunity to include all
1079  * 4 curves on eeprom. The final curve (higher power) has an extra
1080  * point for better accuracy like RF5112.
1081  */
1082 
1083 /* For RF2413 power calibration data doesn't start on a fixed location and
1084  * if a mode is not supported, it's section is missing -not zeroed-.
1085  * So we need to calculate the starting offset for each section by using
1086  * these two functions */
1087 
1088 /* Return the size of each section based on the mode and the number of pd
1089  * gains available (maximum 4). */
1090 static inline unsigned int
1092 {
1093  static const unsigned int pdgains_size[] = { 4, 6, 9, 12 };
1094  unsigned int sz;
1095 
1096  sz = pdgains_size[ee->ee_pd_gains[mode] - 1];
1097  sz *= ee->ee_n_piers[mode];
1098 
1099  return sz;
1100 }
1101 
1102 /* Return the starting offset for a section based on the modes supported
1103  * and each section's size. */
1104 static unsigned int
1106 {
1108 
1109  switch(mode) {
1110  case AR5K_EEPROM_MODE_11G:
1111  if (AR5K_EEPROM_HDR_11B(ee->ee_header))
1115  /* fall through */
1116  case AR5K_EEPROM_MODE_11B:
1117  if (AR5K_EEPROM_HDR_11A(ee->ee_header))
1121  /* fall through */
1122  case AR5K_EEPROM_MODE_11A:
1123  break;
1124  default:
1125  break;
1126  }
1127 
1128  return offset;
1129 }
1130 
1131 /* Convert RF2413 specific data to generic raw data
1132  * used by interpolation code */
1133 static int
1135  struct ath5k_chan_pcal_info *chinfo)
1136 {
1137  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
1138  struct ath5k_chan_pcal_info_rf2413 *pcinfo;
1139  u8 *pdgain_idx = ee->ee_pdc_to_idx[mode];
1140  unsigned int pier, point;
1141  int pdg;
1142 
1143  /* Fill raw data for each calibration pier */
1144  for (pier = 0; pier < ee->ee_n_piers[mode]; pier++) {
1145 
1146  pcinfo = &chinfo[pier].rf2413_info;
1147 
1148  /* Allocate pd_curves for this cal pier */
1149  chinfo[pier].pd_curves =
1151  sizeof(struct ath5k_pdgain_info));
1152 
1153  if (!chinfo[pier].pd_curves)
1154  return -ENOMEM;
1155 
1156  /* Fill pd_curves */
1157  for (pdg = 0; pdg < ee->ee_pd_gains[mode]; pdg++) {
1158 
1159  u8 idx = pdgain_idx[pdg];
1160  struct ath5k_pdgain_info *pd =
1161  &chinfo[pier].pd_curves[idx];
1162 
1163  /* One more point for the highest power
1164  * curve (lowest gain) */
1165  if (pdg == ee->ee_pd_gains[mode] - 1)
1167  else
1169 
1170  /* Allocate pd points for this curve */
1171  pd->pd_step = calloc(pd->pd_points, sizeof(u8));
1172 
1173  if (!pd->pd_step)
1174  return -ENOMEM;
1175 
1176  pd->pd_pwr = calloc(pd->pd_points, sizeof(s16));
1177 
1178  if (!pd->pd_pwr)
1179  return -ENOMEM;
1180 
1181  /* Fill raw dataset
1182  * convert all pwr levels to
1183  * quarter dB for RF5112 combatibility */
1184  pd->pd_step[0] = pcinfo->pddac_i[pdg];
1185  pd->pd_pwr[0] = 4 * pcinfo->pwr_i[pdg];
1186 
1187  for (point = 1; point < pd->pd_points; point++) {
1188 
1189  pd->pd_pwr[point] = pd->pd_pwr[point - 1] +
1190  2 * pcinfo->pwr[pdg][point - 1];
1191 
1192  pd->pd_step[point] = pd->pd_step[point - 1] +
1193  pcinfo->pddac[pdg][point - 1];
1194 
1195  }
1196 
1197  /* Highest gain curve -> min power */
1198  if (pdg == 0)
1199  chinfo[pier].min_pwr = pd->pd_pwr[0];
1200 
1201  /* Lowest gain curve -> max power */
1202  if (pdg == ee->ee_pd_gains[mode] - 1)
1203  chinfo[pier].max_pwr =
1204  pd->pd_pwr[pd->pd_points - 1];
1205  }
1206  }
1207 
1208  return 0;
1209 }
1210 
1211 /* Parse EEPROM data */
1212 static int
1214 {
1215  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
1216  struct ath5k_chan_pcal_info_rf2413 *pcinfo;
1217  struct ath5k_chan_pcal_info *chinfo;
1218  u8 *pdgain_idx = ee->ee_pdc_to_idx[mode];
1219  u32 offset;
1220  int idx, i, ret;
1221  u16 val;
1222  u8 pd_gains = 0;
1223 
1224  /* Count how many curves we have and
1225  * identify them (which one of the 4
1226  * available curves we have on each count).
1227  * Curves are stored from higher to
1228  * lower gain so we go backwards */
1229  for (idx = AR5K_EEPROM_N_PD_CURVES - 1; idx >= 0; idx--) {
1230  /* ee_x_gain[mode] is x gain mask */
1231  if ((ee->ee_x_gain[mode] >> idx) & 0x1)
1232  pdgain_idx[pd_gains++] = idx;
1233 
1234  }
1235  ee->ee_pd_gains[mode] = pd_gains;
1236 
1237  if (pd_gains == 0)
1238  return -EINVAL;
1239 
1241  switch (mode) {
1242  case AR5K_EEPROM_MODE_11A:
1243  if (!AR5K_EEPROM_HDR_11A(ee->ee_header))
1244  return 0;
1245 
1248  chinfo = ee->ee_pwr_cal_a;
1249  break;
1250  case AR5K_EEPROM_MODE_11B:
1251  if (!AR5K_EEPROM_HDR_11B(ee->ee_header))
1252  return 0;
1253 
1256  chinfo = ee->ee_pwr_cal_b;
1257  break;
1258  case AR5K_EEPROM_MODE_11G:
1259  if (!AR5K_EEPROM_HDR_11G(ee->ee_header))
1260  return 0;
1261 
1264  chinfo = ee->ee_pwr_cal_g;
1265  break;
1266  default:
1267  return -EINVAL;
1268  }
1269 
1270  for (i = 0; i < ee->ee_n_piers[mode]; i++) {
1271  pcinfo = &chinfo[i].rf2413_info;
1272 
1273  /*
1274  * Read pwr_i, pddac_i and the first
1275  * 2 pd points (pwr, pddac)
1276  */
1278  pcinfo->pwr_i[0] = val & 0x1f;
1279  pcinfo->pddac_i[0] = (val >> 5) & 0x7f;
1280  pcinfo->pwr[0][0] = (val >> 12) & 0xf;
1281 
1283  pcinfo->pddac[0][0] = val & 0x3f;
1284  pcinfo->pwr[0][1] = (val >> 6) & 0xf;
1285  pcinfo->pddac[0][1] = (val >> 10) & 0x3f;
1286 
1288  pcinfo->pwr[0][2] = val & 0xf;
1289  pcinfo->pddac[0][2] = (val >> 4) & 0x3f;
1290 
1291  pcinfo->pwr[0][3] = 0;
1292  pcinfo->pddac[0][3] = 0;
1293 
1294  if (pd_gains > 1) {
1295  /*
1296  * Pd gain 0 is not the last pd gain
1297  * so it only has 2 pd points.
1298  * Continue wih pd gain 1.
1299  */
1300  pcinfo->pwr_i[1] = (val >> 10) & 0x1f;
1301 
1302  pcinfo->pddac_i[1] = (val >> 15) & 0x1;
1304  pcinfo->pddac_i[1] |= (val & 0x3F) << 1;
1305 
1306  pcinfo->pwr[1][0] = (val >> 6) & 0xf;
1307  pcinfo->pddac[1][0] = (val >> 10) & 0x3f;
1308 
1310  pcinfo->pwr[1][1] = val & 0xf;
1311  pcinfo->pddac[1][1] = (val >> 4) & 0x3f;
1312  pcinfo->pwr[1][2] = (val >> 10) & 0xf;
1313 
1314  pcinfo->pddac[1][2] = (val >> 14) & 0x3;
1316  pcinfo->pddac[1][2] |= (val & 0xF) << 2;
1317 
1318  pcinfo->pwr[1][3] = 0;
1319  pcinfo->pddac[1][3] = 0;
1320  } else if (pd_gains == 1) {
1321  /*
1322  * Pd gain 0 is the last one so
1323  * read the extra point.
1324  */
1325  pcinfo->pwr[0][3] = (val >> 10) & 0xf;
1326 
1327  pcinfo->pddac[0][3] = (val >> 14) & 0x3;
1329  pcinfo->pddac[0][3] |= (val & 0xF) << 2;
1330  }
1331 
1332  /*
1333  * Proceed with the other pd_gains
1334  * as above.
1335  */
1336  if (pd_gains > 2) {
1337  pcinfo->pwr_i[2] = (val >> 4) & 0x1f;
1338  pcinfo->pddac_i[2] = (val >> 9) & 0x7f;
1339 
1341  pcinfo->pwr[2][0] = (val >> 0) & 0xf;
1342  pcinfo->pddac[2][0] = (val >> 4) & 0x3f;
1343  pcinfo->pwr[2][1] = (val >> 10) & 0xf;
1344 
1345  pcinfo->pddac[2][1] = (val >> 14) & 0x3;
1347  pcinfo->pddac[2][1] |= (val & 0xF) << 2;
1348 
1349  pcinfo->pwr[2][2] = (val >> 4) & 0xf;
1350  pcinfo->pddac[2][2] = (val >> 8) & 0x3f;
1351 
1352  pcinfo->pwr[2][3] = 0;
1353  pcinfo->pddac[2][3] = 0;
1354  } else if (pd_gains == 2) {
1355  pcinfo->pwr[1][3] = (val >> 4) & 0xf;
1356  pcinfo->pddac[1][3] = (val >> 8) & 0x3f;
1357  }
1358 
1359  if (pd_gains > 3) {
1360  pcinfo->pwr_i[3] = (val >> 14) & 0x3;
1362  pcinfo->pwr_i[3] |= ((val >> 0) & 0x7) << 2;
1363 
1364  pcinfo->pddac_i[3] = (val >> 3) & 0x7f;
1365  pcinfo->pwr[3][0] = (val >> 10) & 0xf;
1366  pcinfo->pddac[3][0] = (val >> 14) & 0x3;
1367 
1369  pcinfo->pddac[3][0] |= (val & 0xF) << 2;
1370  pcinfo->pwr[3][1] = (val >> 4) & 0xf;
1371  pcinfo->pddac[3][1] = (val >> 8) & 0x3f;
1372 
1373  pcinfo->pwr[3][2] = (val >> 14) & 0x3;
1375  pcinfo->pwr[3][2] |= ((val >> 0) & 0x3) << 2;
1376 
1377  pcinfo->pddac[3][2] = (val >> 2) & 0x3f;
1378  pcinfo->pwr[3][3] = (val >> 8) & 0xf;
1379 
1380  pcinfo->pddac[3][3] = (val >> 12) & 0xF;
1382  pcinfo->pddac[3][3] |= ((val >> 0) & 0x3) << 4;
1383  } else if (pd_gains == 3) {
1384  pcinfo->pwr[2][3] = (val >> 14) & 0x3;
1386  pcinfo->pwr[2][3] |= ((val >> 0) & 0x3) << 2;
1387 
1388  pcinfo->pddac[2][3] = (val >> 2) & 0x3f;
1389  }
1390  }
1391 
1392  return ath5k_eeprom_convert_pcal_info_2413(ah, mode, chinfo);
1393 }
1394 
1395 
1396 /*
1397  * Read per rate target power (this is the maximum tx power
1398  * supported by the card). This info is used when setting
1399  * tx power, no matter the channel.
1400  *
1401  * This also works for v5 EEPROMs.
1402  */
1403 static int
1405 {
1406  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
1407  struct ath5k_rate_pcal_info *rate_pcal_info;
1408  u8 *rate_target_pwr_num;
1409  u32 offset;
1410  u16 val;
1411  int ret, i;
1412 
1414  rate_target_pwr_num = &ee->ee_rate_target_pwr_num[mode];
1415  switch (mode) {
1416  case AR5K_EEPROM_MODE_11A:
1418  rate_pcal_info = ee->ee_rate_tpwr_a;
1420  break;
1421  case AR5K_EEPROM_MODE_11B:
1423  rate_pcal_info = ee->ee_rate_tpwr_b;
1424  ee->ee_rate_target_pwr_num[mode] = 2; /* 3rd is g mode's 1st */
1425  break;
1426  case AR5K_EEPROM_MODE_11G:
1428  rate_pcal_info = ee->ee_rate_tpwr_g;
1430  break;
1431  default:
1432  return -EINVAL;
1433  }
1434 
1435  /* Different freq mask for older eeproms (<= v3.2) */
1436  if (ee->ee_version <= AR5K_EEPROM_VERSION_3_2) {
1437  for (i = 0; i < (*rate_target_pwr_num); i++) {
1439  rate_pcal_info[i].freq =
1440  ath5k_eeprom_bin2freq(ee, (val >> 9) & 0x7f, mode);
1441 
1442  rate_pcal_info[i].target_power_6to24 = ((val >> 3) & 0x3f);
1443  rate_pcal_info[i].target_power_36 = (val << 3) & 0x3f;
1444 
1446 
1447  if (rate_pcal_info[i].freq == AR5K_EEPROM_CHANNEL_DIS ||
1448  val == 0) {
1449  (*rate_target_pwr_num) = i;
1450  break;
1451  }
1452 
1453  rate_pcal_info[i].target_power_36 |= ((val >> 13) & 0x7);
1454  rate_pcal_info[i].target_power_48 = ((val >> 7) & 0x3f);
1455  rate_pcal_info[i].target_power_54 = ((val >> 1) & 0x3f);
1456  }
1457  } else {
1458  for (i = 0; i < (*rate_target_pwr_num); i++) {
1460  rate_pcal_info[i].freq =
1461  ath5k_eeprom_bin2freq(ee, (val >> 8) & 0xff, mode);
1462 
1463  rate_pcal_info[i].target_power_6to24 = ((val >> 2) & 0x3f);
1464  rate_pcal_info[i].target_power_36 = (val << 4) & 0x3f;
1465 
1467 
1468  if (rate_pcal_info[i].freq == AR5K_EEPROM_CHANNEL_DIS ||
1469  val == 0) {
1470  (*rate_target_pwr_num) = i;
1471  break;
1472  }
1473 
1474  rate_pcal_info[i].target_power_36 |= (val >> 12) & 0xf;
1475  rate_pcal_info[i].target_power_48 = ((val >> 6) & 0x3f);
1476  rate_pcal_info[i].target_power_54 = (val & 0x3f);
1477  }
1478  }
1479 
1480  return 0;
1481 }
1482 
1483 /*
1484  * Read per channel calibration info from EEPROM
1485  *
1486  * This info is used to calibrate the baseband power table. Imagine
1487  * that for each channel there is a power curve that's hw specific
1488  * (depends on amplifier etc) and we try to "correct" this curve using
1489  * offests we pass on to phy chip (baseband -> before amplifier) so that
1490  * it can use accurate power values when setting tx power (takes amplifier's
1491  * performance on each channel into account).
1492  *
1493  * EEPROM provides us with the offsets for some pre-calibrated channels
1494  * and we have to interpolate to create the full table for these channels and
1495  * also the table for any channel.
1496  */
1497 static int
1499 {
1500  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
1501  int (*read_pcal)(struct ath5k_hw *hw, int mode);
1502  int mode;
1503  int err;
1504 
1505  if ((ah->ah_ee_version >= AR5K_EEPROM_VERSION_4_0) &&
1506  (AR5K_EEPROM_EEMAP(ee->ee_misc0) == 1))
1508  else if ((ah->ah_ee_version >= AR5K_EEPROM_VERSION_5_0) &&
1509  (AR5K_EEPROM_EEMAP(ee->ee_misc0) == 2))
1511  else
1513 
1514 
1516  mode++) {
1517  err = read_pcal(ah, mode);
1518  if (err)
1519  return err;
1520 
1522  if (err < 0)
1523  return err;
1524  }
1525 
1526  return 0;
1527 }
1528 
1529 static int
1531 {
1532  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
1533  struct ath5k_chan_pcal_info *chinfo;
1534  u8 pier, pdg;
1535 
1536  switch (mode) {
1537  case AR5K_EEPROM_MODE_11A:
1538  if (!AR5K_EEPROM_HDR_11A(ee->ee_header))
1539  return 0;
1540  chinfo = ee->ee_pwr_cal_a;
1541  break;
1542  case AR5K_EEPROM_MODE_11B:
1543  if (!AR5K_EEPROM_HDR_11B(ee->ee_header))
1544  return 0;
1545  chinfo = ee->ee_pwr_cal_b;
1546  break;
1547  case AR5K_EEPROM_MODE_11G:
1548  if (!AR5K_EEPROM_HDR_11G(ee->ee_header))
1549  return 0;
1550  chinfo = ee->ee_pwr_cal_g;
1551  break;
1552  default:
1553  return -EINVAL;
1554  }
1555 
1556  for (pier = 0; pier < ee->ee_n_piers[mode]; pier++) {
1557  if (!chinfo[pier].pd_curves)
1558  continue;
1559 
1560  for (pdg = 0; pdg < ee->ee_pd_gains[mode]; pdg++) {
1561  struct ath5k_pdgain_info *pd =
1562  &chinfo[pier].pd_curves[pdg];
1563 
1564  if (pd != NULL) {
1565  free(pd->pd_step);
1566  free(pd->pd_pwr);
1567  }
1568  }
1569 
1570  free(chinfo[pier].pd_curves);
1571  }
1572 
1573  return 0;
1574 }
1575 
1576 void
1578 {
1579  u8 mode;
1580 
1583 }
1584 
1585 /* Read conformance test limits used for regulatory control */
1586 static int
1588 {
1589  struct ath5k_eeprom_info *ee = &ah->ah_capabilities.cap_eeprom;
1590  struct ath5k_edge_power *rep;
1591  unsigned int fmask, pmask;
1592  unsigned int ctl_mode;
1593  int ret, i, j;
1594  u32 offset;
1595  u16 val;
1596 
1597  pmask = AR5K_EEPROM_POWER_M;
1598  fmask = AR5K_EEPROM_FREQ_M(ee->ee_version);
1601  for (i = 0; i < ee->ee_ctls; i += 2) {
1603  ee->ee_ctl[i] = (val >> 8) & 0xff;
1604  ee->ee_ctl[i + 1] = val & 0xff;
1605  }
1606 
1611  else
1613 
1614  rep = ee->ee_ctl_pwr;
1615  for(i = 0; i < ee->ee_ctls; i++) {
1616  switch(ee->ee_ctl[i] & AR5K_CTL_MODE_M) {
1617  case AR5K_CTL_11A:
1618  case AR5K_CTL_TURBO:
1619  ctl_mode = AR5K_EEPROM_MODE_11A;
1620  break;
1621  default:
1622  ctl_mode = AR5K_EEPROM_MODE_11G;
1623  break;
1624  }
1625  if (ee->ee_ctl[i] == 0) {
1627  offset += 8;
1628  else
1629  offset += 7;
1630  rep += AR5K_EEPROM_N_EDGES;
1631  continue;
1632  }
1633  if (ee->ee_version >= AR5K_EEPROM_VERSION_3_3) {
1634  for (j = 0; j < AR5K_EEPROM_N_EDGES; j += 2) {
1636  rep[j].freq = (val >> 8) & fmask;
1637  rep[j + 1].freq = val & fmask;
1638  }
1639  for (j = 0; j < AR5K_EEPROM_N_EDGES; j += 2) {
1641  rep[j].edge = (val >> 8) & pmask;
1642  rep[j].flag = (val >> 14) & 1;
1643  rep[j + 1].edge = val & pmask;
1644  rep[j + 1].flag = (val >> 6) & 1;
1645  }
1646  } else {
1648  rep[0].freq = (val >> 9) & fmask;
1649  rep[1].freq = (val >> 2) & fmask;
1650  rep[2].freq = (val << 5) & fmask;
1651 
1653  rep[2].freq |= (val >> 11) & 0x1f;
1654  rep[3].freq = (val >> 4) & fmask;
1655  rep[4].freq = (val << 3) & fmask;
1656 
1658  rep[4].freq |= (val >> 13) & 0x7;
1659  rep[5].freq = (val >> 6) & fmask;
1660  rep[6].freq = (val << 1) & fmask;
1661 
1663  rep[6].freq |= (val >> 15) & 0x1;
1664  rep[7].freq = (val >> 8) & fmask;
1665 
1666  rep[0].edge = (val >> 2) & pmask;
1667  rep[1].edge = (val << 4) & pmask;
1668 
1670  rep[1].edge |= (val >> 12) & 0xf;
1671  rep[2].edge = (val >> 6) & pmask;
1672  rep[3].edge = val & pmask;
1673 
1675  rep[4].edge = (val >> 10) & pmask;
1676  rep[5].edge = (val >> 4) & pmask;
1677  rep[6].edge = (val << 2) & pmask;
1678 
1680  rep[6].edge |= (val >> 14) & 0x3;
1681  rep[7].edge = (val >> 8) & pmask;
1682  }
1683  for (j = 0; j < AR5K_EEPROM_N_EDGES; j++) {
1684  rep[j].freq = ath5k_eeprom_bin2freq(ee,
1685  rep[j].freq, ctl_mode);
1686  }
1687  rep += AR5K_EEPROM_N_EDGES;
1688  }
1689 
1690  return 0;
1691 }
1692 
1693 
1694 /*
1695  * Initialize eeprom power tables
1696  */
1697 int
1699 {
1700  int err;
1701 
1703  if (err < 0)
1704  return err;
1705 
1706  err = ath5k_eeprom_init_modes(ah);
1707  if (err < 0)
1708  return err;
1709 
1711  if (err < 0)
1712  return err;
1713 
1715  if (err < 0)
1716  return err;
1717 
1718  return 0;
1719 }
1720 
1721 /*
1722  * Read the MAC address from eeprom
1723  */
1725 {
1726  u8 mac_d[ETH_ALEN] = {};
1727  u32 total, offset;
1728  u16 data;
1729  int octet, ret;
1730 
1731  ret = ath5k_hw_eeprom_read(ah, 0x20, &data);
1732  if (ret)
1733  return ret;
1734 
1735  for (offset = 0x1f, octet = 0, total = 0; offset >= 0x1d; offset--) {
1736  ret = ath5k_hw_eeprom_read(ah, offset, &data);
1737  if (ret)
1738  return ret;
1739 
1740  total += data;
1741  mac_d[octet + 1] = data & 0xff;
1742  mac_d[octet] = data >> 8;
1743  octet += 2;
1744  }
1745 
1746  if (!total || total == 3 * 0xffff)
1747  return -EINVAL;
1748 
1749  memcpy(mac, mac_d, ETH_ALEN);
1750 
1751  return 0;
1752 }
1753 
1755 {
1756  u16 data;
1757 
1759 
1760  if ((ah->ah_mac_version == (AR5K_SREV_AR2425 >> 4)) && data)
1761  return 1;
1762  else
1763  return 0;
1764 }
1765 
u16 ee_xr_power[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:400
#define u16
Definition: vga.h:20
uint16_t u16
Definition: stdint.h:22
int8_t s8
Definition: stdint.h:19
#define EINVAL
Invalid argument.
Definition: errno.h:429
u8 ee_pd_gains[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:423
#define AR5K_EEPROM_HDR_11B(_v)
Definition: eeprom.h:70
static int ath5k_eeprom_read_turbo_modes(struct ath5k_hw *ah, u32 *offset, unsigned int mode)
Definition: ath5k_eeprom.c:412
int16_t s16
Definition: stdint.h:21
#define AR5K_EEPROM_N_5GHZ_CHAN
Definition: eeprom.h:182
#define AR5K_EEPROM_MISC5
Definition: eeprom.h:116
#define AR5K_EEPROM_GROUP4_OFFSET
Definition: eeprom.h:143
#define AR5K_EEPROM_VERSION_4_2
Definition: eeprom.h:53
#define AR5K_EEPROM_IS_HB63
Definition: eeprom.h:30
#define max(x, y)
Definition: ath.h:41
struct ath5k_pdgain_info * pd_curves
Definition: eeprom.h:342
#define AR5K_EEPROM_MODE_11G
Definition: eeprom.h:66
void __asmcall int val
Definition: setjmp.h:12
u16 ee_thr_62[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:409
#define AR5K_EEPROM_N_PD_CURVES
Definition: eeprom.h:206
s8 ee_adc_desired_size_turbo[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:447
u8 ee_ctl[AR5K_EEPROM_MAX_CTLS]
Definition: eeprom.h:440
#define AR5K_EEPROM_MODE_11A
Definition: eeprom.h:64
#define AR5K_EEPROM_CAL_DATA_START(_v)
Definition: eeprom.h:112
u8 ee_pdc_to_idx[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_PD_GAINS]
Definition: eeprom.h:425
#define AR5K_EEPROM_TARGET_PWRSTART(_v)
Definition: eeprom.h:99
uint16_t mode
Acceleration mode.
Definition: ena.h:26
s8 pwr_x0[AR5K_EEPROM_N_XPD0_POINTS]
Definition: eeprom.h:294
#define AR5K_EEPROM_N_2GHZ_CHAN
Definition: eeprom.h:183
#define AR5K_EEPROM_POWER_M
Definition: eeprom.h:213
#define AR5K_EEPROM_N_XPD3_POINTS
Definition: eeprom.h:208
u16 ee_false_detect[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:420
#define min(x, y)
Definition: ath.h:36
static int ath5k_eeprom_read_target_rate_pwr_info(struct ath5k_hw *ah, unsigned int mode)
#define AR5K_EEPROM_PROTECT
Definition: eeprom.h:160
u8 ee_rate_target_pwr_num[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:433
u16 ee_x_gain[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:412
#define AR5K_EEPROM_OBDB1_2GHZ
Definition: eeprom.h:158
#define vp
Definition: 3c515.c:239
#define AR5K_PCICFG
Definition: reg.h:882
#define AR5K_REG_MS(_val, _flags)
Definition: ath5k.h:90
#define AR5K_EEPROM_BASE
Definition: reg.h:1056
uint8_t mac[ETH_ALEN]
MAC address.
Definition: ena.h:24
#define AR5K_EEPROM_N_PWR_POINTS_5111
Definition: eeprom.h:187
#define AR5K_EEPROM_CMD_READ
Definition: reg.h:1070
s16 ee_noise_floor_thr[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:444
u8 pwr[AR5K_EEPROM_N_PWR_POINTS_5111]
Definition: eeprom.h:280
#define AR5K_EEPROM_MISC6
Definition: eeprom.h:125
static unsigned int ath5k_pdgains_size_2413(struct ath5k_eeprom_info *ee, unsigned int mode)
u16 ee_tx_end2xlna_enable[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:406
Definition: hw.c:16
s8 ee_pd_gain_overlap
Definition: eeprom.h:449
ath5k_hw_get_isr - Get interrupt status
Definition: ath5k.h:955
static unsigned int ath5k_cal_data_offset_2413(struct ath5k_eeprom_info *ee, int mode)
u16 ee_ant_control[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_PCDAC]
Definition: eeprom.h:403
#define AR5K_EEPROM_STAT_RDDONE
Definition: reg.h:1082
#define AR5K_EEPROM_TARGET_PWR_OFF_11G(_v)
Definition: eeprom.h:153
u16 ee_db[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_OBDB]
Definition: eeprom.h:405
s8 pwr_x3[AR5K_EEPROM_N_XPD3_POINTS]
Definition: eeprom.h:295
static int ath5k_eeprom_convert_pcal_info_2413(struct ath5k_hw *ah, int mode, struct ath5k_chan_pcal_info *chinfo)
struct ath5k_chan_pcal_info ee_pwr_cal_b[AR5K_EEPROM_N_2GHZ_CHAN_MAX]
Definition: eeprom.h:429
#define ENOMEM
Not enough space.
Definition: errno.h:535
void * memcpy(void *dest, const void *src, size_t len) __nonnull
s8 ee_adc_desired_size[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:445
#define AR5K_EEPROM_MAGIC
Definition: eeprom.h:24
#define AR5K_EEPROM_HDR_T_5GHZ_DBM(_v)
Definition: eeprom.h:73
static int ath5k_eeprom_free_pcal_info(struct ath5k_hw *ah, int mode)
#define AR5K_EEPROM_GROUP5_OFFSET
Definition: eeprom.h:144
static int ath5k_hw_eeprom_read(struct ath5k_hw *ah, u32 offset, u16 *data)
Definition: ath5k_eeprom.c:39
FILE_SECBOOT(FORBIDDEN)
struct ath5k_chan_pcal_info_rf5111 rf5111_info
Definition: eeprom.h:335
struct ath5k_chan_pcal_info ee_pwr_cal_g[AR5K_EEPROM_N_2GHZ_CHAN_MAX]
Definition: eeprom.h:430
static int ath5k_eeprom_read_pcal_info(struct ath5k_hw *ah)
static int ath5k_eeprom_init_11a_pcal_freq(struct ath5k_hw *ah, int offset)
Definition: ath5k_eeprom.c:550
#define AR5K_EEPROM_GROUP1_OFFSET
Definition: eeprom.h:140
static int ath5k_eeprom_convert_pcal_info_5112(struct ath5k_hw *ah, int mode, struct ath5k_chan_pcal_info *chinfo)
Definition: ath5k_eeprom.c:849
#define AR5K_EEPROM_REG_DOMAIN
Definition: eeprom.h:38
void udelay(unsigned long usecs)
Delay for a fixed number of microseconds.
Definition: timer.c:61
#define AR5K_EEPROM_VERSION_3_3
Definition: eeprom.h:49
static void *__malloc calloc(size_t nmemb, size_t size)
Allocate cleared memory.
Definition: stdlib.h:46
#define AR5K_EEPROM_CTL(_v)
Definition: eeprom.h:138
#define u8
Definition: igbvf_osdep.h:40
int ath5k_eeprom_is_hb63(struct ath5k_hw *ah)
#define AR5K_EEPROM_ANT_GAIN(_v)
Definition: eeprom.h:87
s8 pwr[AR5K_EEPROM_N_PD_GAINS][AR5K_EEPROM_N_PD_POINTS]
Definition: eeprom.h:309
#define AR5K_EEPROM_RFKILL_GPIO_SEL
Definition: eeprom.h:78
#define AR5K_EEPROM_HDR_11A(_v)
Definition: eeprom.h:69
#define AR5K_EEPROM_MISC4
Definition: eeprom.h:111
#define AR5K_EEPROM_GROUPS_START(_v)
Definition: eeprom.h:139
#define AR5K_EEPROM_N_CTLS(_v)
Definition: eeprom.h:204
#define AR5K_EEPROM_TARGET_PWR_OFF_11B(_v)
Definition: eeprom.h:151
static int ath5k_eeprom_read_freq_list(struct ath5k_hw *ah, int *offset, int max, struct ath5k_chan_pcal_info *pc, unsigned int mode)
Definition: ath5k_eeprom.c:511
u16 ee_xlna_gain[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:410
u8 ee_n_piers[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:427
int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac)
#define AR5K_EEPROM_VERSION_5_0
Definition: eeprom.h:60
#define AR5K_TUNE_REGISTER_TIMEOUT
Definition: ath5k.h:171
#define AR5K_EEPROM_HDR
Definition: eeprom.h:68
#define AR5K_EEPROM_VERSION_4_3
Definition: eeprom.h:54
static void(* free)(struct refcnt *refcnt))
Definition: refcnt.h:55
u16 ee_tx_end2xpa_disable[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:407
void ath5k_eeprom_detach(struct ath5k_hw *ah)
#define AR5K_EEPROM_EEMAP(_v)
Definition: eeprom.h:96
int ath5k_eeprom_init(struct ath5k_hw *ah)
u16 ee_margin_tx_rx_turbo[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:416
static int ath5k_eeprom_read_ctl_info(struct ath5k_hw *ah)
#define AR5K_EEPROM_N_PD_POINTS
Definition: eeprom.h:210
#define AR5K_EEPROM_MODES_11G(_v)
Definition: eeprom.h:137
#define AR5K_EEPROM_STATUS
Definition: reg.h:1079
#define AR5K_EEPROM_VERSION_4_1
Definition: eeprom.h:52
u16 ee_scaled_cck_delta
Definition: eeprom.h:393
#define AR5K_EEPROM_N_EDGES
Definition: eeprom.h:191
IP4_t ip
Destination IP address.
Definition: pxe_api.h:58
#define AR5K_EEPROM_MODE_11B
Definition: eeprom.h:65
#define ARRAY_SIZE(x)
Definition: efx_common.h:43
static void ath5k_get_pcdac_intercepts(struct ath5k_hw *ah, u8 min, u8 max, u8 *vp)
Definition: ath5k_eeprom.c:647
struct ath5k_rate_pcal_info ee_rate_tpwr_b[AR5K_EEPROM_N_2GHZ_CHAN_MAX]
Definition: eeprom.h:435
u16 ee_i_gain[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:413
#define AR5K_EEPROM_STAT_RDERR
Definition: reg.h:1081
#define AR5K_EEPROM_GROUP8_OFFSET
Definition: eeprom.h:147
static void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
Definition: ath5k.h:1224
u8 pddac_i[AR5K_EEPROM_N_PD_GAINS]
Definition: eeprom.h:305
#define AR5K_EEPROM_MODES_11B(_v)
Definition: eeprom.h:136
static int ath5k_eeprom_read_pcal_info_2413(struct ath5k_hw *ah, int mode)
u8 pcdac_x3[AR5K_EEPROM_N_XPD3_POINTS]
Definition: eeprom.h:299
#define ETH_ALEN
Definition: if_ether.h:9
static int ath5k_eeprom_read_modes(struct ath5k_hw *ah, u32 *offset, unsigned int mode)
Definition: ath5k_eeprom.c:231
#define AR5K_EEPROM_CHANNEL_DIS
Definition: eeprom.h:202
u16 ee_i_cal[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:396
u16 ee_tx_frm2xpa_enable[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:408
uint8_t status
Status.
Definition: ena.h:16
s8 ee_pga_desired_size[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:446
#define AR5K_SREV_AR2425
Definition: ath5k.h:306
struct ath5k_rate_pcal_info ee_rate_tpwr_a[AR5K_EEPROM_N_5GHZ_CHAN]
Definition: eeprom.h:434
struct ath5k_chan_pcal_info_rf5112 rf5112_info
Definition: eeprom.h:336
u16 ee_switch_settling_turbo[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:415
u16 ee_xpd[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:411
#define AR5K_PCICFG_EEAE
Definition: reg.h:883
#define AR5K_EEPROM_PCDAC_M
Definition: eeprom.h:194
#define AR5K_EEPROM_MISC3
Definition: eeprom.h:107
struct ath5k_chan_pcal_info ee_pwr_cal_a[AR5K_EEPROM_N_5GHZ_CHAN]
Definition: eeprom.h:428
static int ath5k_eeprom_read_pcal_info_5111(struct ath5k_hw *ah, int mode)
Definition: ath5k_eeprom.c:740
static int ath5k_eeprom_read_ants(struct ath5k_hw *ah, u32 *offset, unsigned int mode)
Definition: ath5k_eeprom.c:171
#define AR5K_EEPROM_VERSION_3_2
Definition: eeprom.h:48
#define AR5K_EEPROM_VERSION
Definition: eeprom.h:45
#define AR5K_EEPROM_MISC2
Definition: eeprom.h:103
#define AR5K_EEPROM_N_XPD0_POINTS
Definition: eeprom.h:207
#define AR5K_EEPROM_MISC1
Definition: eeprom.h:98
u8 pcdac_x0[AR5K_EEPROM_N_XPD0_POINTS]
Definition: eeprom.h:298
u16 ee_margin_tx_rx[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:414
u16 ee_cck_ofdm_power_delta
Definition: eeprom.h:392
#define AR5K_EEPROM_OBDB0_2GHZ
Definition: eeprom.h:157
#define EIO
Input/output error.
Definition: errno.h:434
static int ath5k_eeprom_init_header(struct ath5k_hw *ah)
Definition: ath5k_eeprom.c:104
struct ath5k_rate_pcal_info ee_rate_tpwr_g[AR5K_EEPROM_N_2GHZ_CHAN_MAX]
Definition: eeprom.h:436
#define AR5K_EEPROM_N_2GHZ_CHAN_2413
Definition: eeprom.h:184
#define AR5K_EEPROM_GROUP2_OFFSET
Definition: eeprom.h:141
u16 ee_atn_tx_rx[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:402
u16 ee_atn_tx_rx_turbo[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:417
uint8_t data[48]
Additional event data.
Definition: ena.h:22
FILE_LICENCE(MIT)
#define AR5K_EEPROM_DATA
Definition: reg.h:1063
#define AR5K_EEPROM_RFKILL
Definition: eeprom.h:32
uint8_t ah
Definition: registers.h:85
void timeout(int)
#define AR5K_EEPROM_VERSION_4_6
Definition: eeprom.h:57
u16 ee_ob[AR5K_EEPROM_N_MODES][AR5K_EEPROM_N_OBDB]
Definition: eeprom.h:404
u8 pcdac[AR5K_EEPROM_N_PWR_POINTS_5111]
Definition: eeprom.h:283
s8 pwr_i[AR5K_EEPROM_N_PD_GAINS]
Definition: eeprom.h:304
static u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
Definition: ath5k.h:1216
struct ath5k_chan_pcal_info_rf2413 rf2413_info
Definition: eeprom.h:337
#define AR5K_EEPROM_TARGET_PWR_OFF_11A(_v)
Definition: eeprom.h:149
#define AR5K_EEPROM_GROUP3_OFFSET
Definition: eeprom.h:142
uint16_t offset
Offset to command line.
Definition: bzimage.h:8
struct ath5k_edge_power ee_ctl_pwr[AR5K_EEPROM_N_EDGES *AR5K_EEPROM_MAX_CTLS]
Definition: eeprom.h:441
static int ath5k_eeprom_read_pcal_info_5112(struct ath5k_hw *ah, int mode)
Definition: ath5k_eeprom.c:955
#define AR5K_EEPROM_VERSION_3_0
Definition: eeprom.h:46
#define AR5K_EEPROM_MODES_11A(_v)
Definition: eeprom.h:135
static u16 ath5k_eeprom_bin2freq(struct ath5k_eeprom_info *ee, u16 bin, unsigned int mode)
Definition: ath5k_eeprom.c:76
static int ath5k_eeprom_init_11bg_2413(struct ath5k_hw *ah, unsigned int mode, int offset)
Definition: ath5k_eeprom.c:603
u16 ee_turbo_max_power[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:399
#define AR5K_EEPROM_READ(_o, _v)
Definition: eeprom.h:224
#define AR5K_EEPROM_MISC0
Definition: eeprom.h:92
#define AR5K_EEPROM_FREQ_M(_v)
Definition: eeprom.h:193
u16 ee_cck_ofdm_gain_delta
Definition: eeprom.h:391
u8 pddac[AR5K_EEPROM_N_PD_GAINS][AR5K_EEPROM_N_PD_POINTS]
Definition: eeprom.h:311
#define NULL
NULL pointer (VOID *)
Definition: Base.h:322
u16 ee_switch_settling[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:401
#define ETIMEDOUT
Connection timed out.
Definition: errno.h:670
u16 ee_fixed_bias[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:398
#define AR5K_EEPROM_HDR_11G(_v)
Definition: eeprom.h:71
#define AR5K_EEPROM_RFKILL_POLARITY
Definition: eeprom.h:80
static int ath5k_eeprom_init_modes(struct ath5k_hw *ah)
Definition: ath5k_eeprom.c:464
struct bofm_section_header done
Definition: bofm_test.c:46
uint8_t u8
Definition: stdint.h:20
#define AR5K_EEPROM_CCK_OFDM_DELTA
Definition: eeprom.h:221
uint32_t u32
Definition: stdint.h:24
u16 ee_q_cal[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:397
#define AR5K_EEPROM_READ_HDR(_o, _v)
Definition: eeprom.h:230
s8 ee_pga_desired_size_turbo[AR5K_EEPROM_N_MODES]
Definition: eeprom.h:448
#define AR5K_REG_ENABLE_BITS(ah, _reg, _flags)
Definition: ath5k.h:106
#define AR5K_EEPROM_I_GAIN
Definition: eeprom.h:220
#define AR5K_EEPROM_VERSION_3_4
Definition: eeprom.h:50
static int ath5k_eeprom_convert_pcal_info_5111(struct ath5k_hw *ah, int mode, struct ath5k_chan_pcal_info *chinfo)
Definition: ath5k_eeprom.c:668
#define AR5K_EEPROM_CMD
Definition: reg.h:1069
#define AR5K_EEPROM_VERSION_4_0
Definition: eeprom.h:51