Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
eeprom.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2011 Atheros Communications Inc.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef EEPROM_H
18 #define EEPROM_H
19 
20 #define AR_EEPROM_MODAL_SPURS 5
21 
22 #include "../ath.h"
23 #include <net/cfg80211.h>
24 #include "ar9003_eeprom.h"
25 
26 #ifdef __BIG_ENDIAN
27 #define AR5416_EEPROM_MAGIC 0x5aa5
28 #else
29 #define AR5416_EEPROM_MAGIC 0xa55a
30 #endif
31 
32 #define CTRY_DEBUG 0x1ff
33 #define CTRY_DEFAULT 0
34 
35 #define AR_EEPROM_EEPCAP_COMPRESS_DIS 0x0001
36 #define AR_EEPROM_EEPCAP_AES_DIS 0x0002
37 #define AR_EEPROM_EEPCAP_FASTFRAME_DIS 0x0004
38 #define AR_EEPROM_EEPCAP_BURST_DIS 0x0008
39 #define AR_EEPROM_EEPCAP_MAXQCU 0x01F0
40 #define AR_EEPROM_EEPCAP_MAXQCU_S 4
41 #define AR_EEPROM_EEPCAP_HEAVY_CLIP_EN 0x0200
42 #define AR_EEPROM_EEPCAP_KC_ENTRIES 0xF000
43 #define AR_EEPROM_EEPCAP_KC_ENTRIES_S 12
44 
45 #define AR_EEPROM_EEREGCAP_EN_FCC_MIDBAND 0x0040
46 #define AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN 0x0080
47 #define AR_EEPROM_EEREGCAP_EN_KK_U2 0x0100
48 #define AR_EEPROM_EEREGCAP_EN_KK_MIDBAND 0x0200
49 #define AR_EEPROM_EEREGCAP_EN_KK_U1_ODD 0x0400
50 #define AR_EEPROM_EEREGCAP_EN_KK_NEW_11A 0x0800
51 
52 #define AR_EEPROM_EEREGCAP_EN_KK_U1_ODD_PRE4_0 0x4000
53 #define AR_EEPROM_EEREGCAP_EN_KK_NEW_11A_PRE4_0 0x8000
54 
55 #define AR5416_EEPROM_MAGIC_OFFSET 0x0
56 #define AR5416_EEPROM_S 2
57 #define AR5416_EEPROM_OFFSET 0x2000
58 #define AR5416_EEPROM_MAX 0xae0
59 
60 #define AR5416_EEPROM_START_ADDR \
61  (AR_SREV_9100(ah)) ? 0x1fff1000 : 0x503f1200
62 
63 #define SD_NO_CTL 0xE0
64 #define NO_CTL 0xff
65 #define CTL_MODE_M 0xf
66 #define CTL_11A 0
67 #define CTL_11B 1
68 #define CTL_11G 2
69 #define CTL_2GHT20 5
70 #define CTL_5GHT20 6
71 #define CTL_2GHT40 7
72 #define CTL_5GHT40 8
73 
74 #define EXT_ADDITIVE (0x8000)
75 #define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
76 #define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
77 #define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
78 
79 #define SUB_NUM_CTL_MODES_AT_5G_40 2
80 #define SUB_NUM_CTL_MODES_AT_2G_40 3
81 
82 #define POWER_CORRECTION_FOR_TWO_CHAIN 6 /* 10*log10(2)*2 */
83 #define POWER_CORRECTION_FOR_THREE_CHAIN 10 /* 10*log10(3)*2 */
84 
85 /*
86  * For AR9285 and later chipsets, the following bits are not being programmed
87  * in EEPROM and so need to be enabled always.
88  *
89  * Bit 0: en_fcc_mid
90  * Bit 1: en_jap_mid
91  * Bit 2: en_fcc_dfs_ht40
92  * Bit 3: en_jap_ht40
93  * Bit 4: en_jap_dfs_ht40
94  */
95 #define AR9285_RDEXT_DEFAULT 0x1F
96 
97 #define ATH9K_POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
98 #define FREQ2FBIN(x, y) ((y) ? ((x) - 2300) : (((x) - 4800) / 5))
99 #define FBIN2FREQ(x, y) ((y) ? (2300 + x) : (4800 + 5 * x))
100 #define ath9k_hw_use_flash(_ah) (!(_ah->ah_flags & AH_USE_EEPROM))
101 
102 #define AR5416_VER_MASK (eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK)
103 #define OLC_FOR_AR9280_20_LATER (AR_SREV_9280_20_OR_LATER(ah) && \
104  ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
105 #define OLC_FOR_AR9287_10_LATER (AR_SREV_9287_11_OR_LATER(ah) && \
106  ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
107 
108 #define EEP_RFSILENT_ENABLED 0x0001
109 #define EEP_RFSILENT_ENABLED_S 0
110 #define EEP_RFSILENT_POLARITY 0x0002
111 #define EEP_RFSILENT_POLARITY_S 1
112 #define EEP_RFSILENT_GPIO_SEL ((AR_SREV_9462(ah) || AR_SREV_9565(ah)) ? 0x00fc : 0x001c)
113 #define EEP_RFSILENT_GPIO_SEL_S 2
114 
115 #define AR5416_OPFLAGS_11A 0x01
116 #define AR5416_OPFLAGS_11G 0x02
117 #define AR5416_OPFLAGS_N_5G_HT40 0x04
118 #define AR5416_OPFLAGS_N_2G_HT40 0x08
119 #define AR5416_OPFLAGS_N_5G_HT20 0x10
120 #define AR5416_OPFLAGS_N_2G_HT20 0x20
121 
122 #define AR5416_EEP_NO_BACK_VER 0x1
123 #define AR5416_EEP_VER 0xE
124 #define AR5416_EEP_VER_MINOR_MASK 0x0FFF
125 #define AR5416_EEP_MINOR_VER_2 0x2
126 #define AR5416_EEP_MINOR_VER_3 0x3
127 #define AR5416_EEP_MINOR_VER_7 0x7
128 #define AR5416_EEP_MINOR_VER_9 0x9
129 #define AR5416_EEP_MINOR_VER_16 0x10
130 #define AR5416_EEP_MINOR_VER_17 0x11
131 #define AR5416_EEP_MINOR_VER_19 0x13
132 #define AR5416_EEP_MINOR_VER_20 0x14
133 #define AR5416_EEP_MINOR_VER_21 0x15
134 #define AR5416_EEP_MINOR_VER_22 0x16
135 
136 #define AR5416_NUM_5G_CAL_PIERS 8
137 #define AR5416_NUM_2G_CAL_PIERS 4
138 #define AR5416_NUM_5G_20_TARGET_POWERS 8
139 #define AR5416_NUM_5G_40_TARGET_POWERS 8
140 #define AR5416_NUM_2G_CCK_TARGET_POWERS 3
141 #define AR5416_NUM_2G_20_TARGET_POWERS 4
142 #define AR5416_NUM_2G_40_TARGET_POWERS 4
143 #define AR5416_NUM_CTLS 24
144 #define AR5416_NUM_BAND_EDGES 8
145 #define AR5416_NUM_PD_GAINS 4
146 #define AR5416_PD_GAINS_IN_MASK 4
147 #define AR5416_PD_GAIN_ICEPTS 5
148 #define AR5416_NUM_PDADC_VALUES 128
149 #define AR5416_BCHAN_UNUSED 0xFF
150 #define AR5416_MAX_PWR_RANGE_IN_HALF_DB 64
151 #define AR5416_MAX_CHAINS 3
152 #define AR9300_MAX_CHAINS 3
153 #define AR5416_PWR_TABLE_OFFSET_DB -5
154 
155 /* Rx gain type values */
156 #define AR5416_EEP_RXGAIN_23DB_BACKOFF 0
157 #define AR5416_EEP_RXGAIN_13DB_BACKOFF 1
158 #define AR5416_EEP_RXGAIN_ORIG 2
159 
160 /* Tx gain type values */
161 #define AR5416_EEP_TXGAIN_ORIGINAL 0
162 #define AR5416_EEP_TXGAIN_HIGH_POWER 1
163 
164 #define AR5416_EEP4K_START_LOC 64
165 #define AR5416_EEP4K_NUM_2G_CAL_PIERS 3
166 #define AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS 3
167 #define AR5416_EEP4K_NUM_2G_20_TARGET_POWERS 3
168 #define AR5416_EEP4K_NUM_2G_40_TARGET_POWERS 3
169 #define AR5416_EEP4K_NUM_CTLS 12
170 #define AR5416_EEP4K_NUM_BAND_EDGES 4
171 #define AR5416_EEP4K_NUM_PD_GAINS 2
172 #define AR5416_EEP4K_MAX_CHAINS 1
173 
174 #define AR9280_TX_GAIN_TABLE_SIZE 22
175 
176 #define AR9287_EEP_VER 0xE
177 #define AR9287_EEP_VER_MINOR_MASK 0xFFF
178 #define AR9287_EEP_MINOR_VER_1 0x1
179 #define AR9287_EEP_MINOR_VER_2 0x2
180 #define AR9287_EEP_MINOR_VER_3 0x3
181 #define AR9287_EEP_MINOR_VER AR9287_EEP_MINOR_VER_3
182 #define AR9287_EEP_MINOR_VER_b AR9287_EEP_MINOR_VER
183 #define AR9287_EEP_NO_BACK_VER AR9287_EEP_MINOR_VER_1
184 
185 #define AR9287_EEP_START_LOC 128
186 #define AR9287_HTC_EEP_START_LOC 256
187 #define AR9287_NUM_2G_CAL_PIERS 3
188 #define AR9287_NUM_2G_CCK_TARGET_POWERS 3
189 #define AR9287_NUM_2G_20_TARGET_POWERS 3
190 #define AR9287_NUM_2G_40_TARGET_POWERS 3
191 #define AR9287_NUM_CTLS 12
192 #define AR9287_NUM_BAND_EDGES 4
193 #define AR9287_PD_GAIN_ICEPTS 1
194 #define AR9287_EEPMISC_BIG_ENDIAN 0x01
195 #define AR9287_EEPMISC_WOW 0x02
196 #define AR9287_MAX_CHAINS 2
197 #define AR9287_ANT_16S 32
198 
199 #define AR9287_DATA_SZ 32
200 
201 #define AR9287_PWR_TABLE_OFFSET_DB -5
202 
203 #define AR9287_CHECKSUM_LOCATION (AR9287_EEP_START_LOC + 1)
204 
205 #define CTL_EDGE_TPOWER(_ctl) ((_ctl) & 0x3f)
206 #define CTL_EDGE_FLAGS(_ctl) (((_ctl) >> 6) & 0x03)
207 
208 #define LNA_CTL_BUF_MODE BIT(0)
209 #define LNA_CTL_ISEL_LO BIT(1)
210 #define LNA_CTL_ISEL_HI BIT(2)
211 #define LNA_CTL_BUF_IN BIT(3)
212 #define LNA_CTL_FEM_BAND BIT(4)
213 #define LNA_CTL_LOCAL_BIAS BIT(5)
214 #define LNA_CTL_FORCE_XPA BIT(6)
215 #define LNA_CTL_USE_ANT1 BIT(7)
216 
251 };
252 
264 };
265 
269 };
270 
299 } __packed;
300 
317 } __packed;
318 
319 
320 struct spur_chan {
324 } __packed;
325 
365 
367 } __packed;
368 
370  u8 pwrPdg[2][5];
371  u8 vpdPdg[2][5];
372  u8 pcdac[2][5];
373  u8 empty[2][5];
374 } __packed;
375 
396 #ifdef __BIG_ENDIAN_BITFIELD
397  u8 ob_1:4, ob_0:4;
398  u8 db1_1:4, db1_0:4;
399 #else
400  u8 ob_0:4, ob_1:4;
401  u8 db1_0:4, db1_1:4;
402 #endif
412 #ifdef __BIG_ENDIAN_BITFIELD
413  u8 db2_1:4, db2_0:4;
414 #else
415  u8 db2_0:4, db2_1:4;
416 #endif
418 #ifdef __BIG_ENDIAN_BITFIELD
419  u8 ob_3:4, ob_2:4;
420  u8 antdiv_ctl1:4, ob_4:4;
421  u8 db1_3:4, db1_2:4;
422  u8 antdiv_ctl2:4, db1_4:4;
423  u8 db2_2:4, db2_3:4;
424  u8 reserved:4, db2_4:4;
425 #else
426  u8 ob_2:4, ob_3:4;
428  u8 db1_2:4, db1_3:4;
430  u8 db2_2:4, db2_3:4;
432 #endif
436 #define EEP_4K_BB_DESIRED_SCALE_MASK 0x1f
439 } __packed;
440 
461 } __packed;
462 
497 } __packed;
498 
502 } __packed;
503 
507 } __packed;
508 
511  u8 tPow2x[4];
512 } __packed;
513 
516  u8 tPow2x[8];
517 } __packed;
518 
522 } __packed;
523 
525  u8 pwrPdg[2][5];
526  u8 vpdPdg[2][5];
527  u8 pcdac[2][5];
528  u8 empty[2][5];
529 } __packed;
530 
534 } __packed;
535 
539 } __packed;
540 
544 } __packed;
545 
546 struct cal_ctl_data {
549 } __packed;
550 
554 } __packed;
555 
583 } __packed;
584 
603 } __packed;
604 
623 } __packed;
624 
631 };
632 
639  u8 iso[3];
640 };
641 
642 struct eeprom_ops {
643  int (*check_eeprom)(struct ath_hw *hw);
645  bool (*fill_eeprom)(struct ath_hw *hw);
646  u32 (*dump_eeprom)(struct ath_hw *hw, bool dump_base_hdr, u8 *buf,
647  u32 len, u32 size);
651  void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan);
653  u16 cfgCtl, u8 twiceAntennaReduction,
654  u8 powerLimit, bool test);
655  u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz);
656 };
657 
660  u32 shift, u32 val);
661 int16_t ath9k_hw_interpolate(u16 target, u16 srcLeft, u16 srcRight,
662  int16_t targetLeft,
663  int16_t targetRight);
664 bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize,
665  u16 *indexL, u16 *indexR);
666 bool ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data);
667 void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data,
668  int eep_start_loc, int size);
669 void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList,
670  u8 *pVpdList, u16 numIntercepts,
671  u8 *pRetVpdList);
673  struct ath9k_channel *chan,
674  struct cal_target_power_leg *powInfo,
675  u16 numChannels,
676  struct cal_target_power_leg *pNewPower,
677  u16 numRates, bool isExtTarget);
679  struct ath9k_channel *chan,
680  struct cal_target_power_ht *powInfo,
681  u16 numChannels,
682  struct cal_target_power_ht *pNewPower,
683  u16 numRates, bool isHt40Target);
684 u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower,
685  bool is2GHz, int num_band_edges);
686 u16 ath9k_hw_get_scaled_power(struct ath_hw *ah, u16 power_limit,
687  u8 antenna_reduction);
689 int ath9k_hw_eeprom_init(struct ath_hw *ah);
690 
692  struct ath9k_channel *chan,
693  void *pRawDataSet,
694  u8 *bChans, u16 availPiers,
695  u16 tPdGainOverlap,
696  u16 *pPdGainBoundaries, u8 *pPDADCValues,
697  u16 numXpdGains);
698 
699 static inline u16 ath9k_hw_fbin2freq(u8 fbin, bool is2GHz)
700 {
701  if (fbin == AR5416_BCHAN_UNUSED)
702  return fbin;
703 
704  return (u16) ((is2GHz) ? (2300 + fbin) : (4800 + 5 * fbin));
705 }
706 
707 #define ar5416_get_ntxchains(_txchainmask) \
708  (((_txchainmask >> 2) & 1) + \
709  ((_txchainmask >> 1) & 1) + (_txchainmask & 1))
710 
711 extern const struct eeprom_ops eep_def_ops;
712 extern const struct eeprom_ops eep_4k_ops;
713 extern const struct eeprom_ops eep_ar9287_ops;
714 extern const struct eeprom_ops eep_ar9287_ops;
715 extern const struct eeprom_ops eep_ar9300_ops;
716 
717 #endif /* EEPROM_H */