2 * Copyright (c) 2008 Atheros Communications Inc.
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.
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.
20 #define AH_USE_EEPROM 0x1
23 #define AR5416_EEPROM_MAGIC 0x5aa5
25 #define AR5416_EEPROM_MAGIC 0xa55a
28 #define CTRY_DEBUG 0x1ff
29 #define CTRY_DEFAULT 0
31 #define AR_EEPROM_EEPCAP_COMPRESS_DIS 0x0001
32 #define AR_EEPROM_EEPCAP_AES_DIS 0x0002
33 #define AR_EEPROM_EEPCAP_FASTFRAME_DIS 0x0004
34 #define AR_EEPROM_EEPCAP_BURST_DIS 0x0008
35 #define AR_EEPROM_EEPCAP_MAXQCU 0x01F0
36 #define AR_EEPROM_EEPCAP_MAXQCU_S 4
37 #define AR_EEPROM_EEPCAP_HEAVY_CLIP_EN 0x0200
38 #define AR_EEPROM_EEPCAP_KC_ENTRIES 0xF000
39 #define AR_EEPROM_EEPCAP_KC_ENTRIES_S 12
41 #define AR_EEPROM_EEREGCAP_EN_FCC_MIDBAND 0x0040
42 #define AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN 0x0080
43 #define AR_EEPROM_EEREGCAP_EN_KK_U2 0x0100
44 #define AR_EEPROM_EEREGCAP_EN_KK_MIDBAND 0x0200
45 #define AR_EEPROM_EEREGCAP_EN_KK_U1_ODD 0x0400
46 #define AR_EEPROM_EEREGCAP_EN_KK_NEW_11A 0x0800
48 #define AR_EEPROM_EEREGCAP_EN_KK_U1_ODD_PRE4_0 0x4000
49 #define AR_EEPROM_EEREGCAP_EN_KK_NEW_11A_PRE4_0 0x8000
51 #define AR5416_EEPROM_MAGIC_OFFSET 0x0
52 #define AR5416_EEPROM_S 2
53 #define AR5416_EEPROM_OFFSET 0x2000
54 #define AR5416_EEPROM_MAX 0xae0
56 #define AR5416_EEPROM_START_ADDR \
57 (AR_SREV_9100(ah)) ? 0x1fff1000 : 0x503f1200
59 #define SD_NO_CTL 0xE0
70 #define EXT_ADDITIVE (0x8000)
71 #define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
72 #define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
73 #define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
75 #define SUB_NUM_CTL_MODES_AT_5G_40 2
76 #define SUB_NUM_CTL_MODES_AT_2G_40 3
78 #define INCREASE_MAXPOW_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */
79 #define INCREASE_MAXPOW_BY_THREE_CHAIN 10 /* 10*log10(3)*2 */
82 * For AR9285 and later chipsets, the following bits are not being programmed
83 * in EEPROM and so need to be enabled always.
87 * Bit 2: en_fcc_dfs_ht40
89 * Bit 4: en_jap_dfs_ht40
91 #define AR9285_RDEXT_DEFAULT 0x1F
93 #define AR_EEPROM_MAC(i) (0x1d+(i))
94 #define ATH9K_POW_SM(_r, _s) (((_r) & 0x3f) << (_s))
95 #define FREQ2FBIN(x, y) ((y) ? ((x) - 2300) : (((x) - 4800) / 5))
96 #define ath9k_hw_use_flash(_ah) (!(_ah->ah_flags & AH_USE_EEPROM))
98 #define OLC_FOR_AR9280_20_LATER (AR_SREV_9280_20_OR_LATER(ah) && \
99 ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
101 #define AR_EEPROM_RFSILENT_GPIO_SEL 0x001c
102 #define AR_EEPROM_RFSILENT_GPIO_SEL_S 2
103 #define AR_EEPROM_RFSILENT_POLARITY 0x0002
104 #define AR_EEPROM_RFSILENT_POLARITY_S 1
106 #define EEP_RFSILENT_ENABLED 0x0001
107 #define EEP_RFSILENT_ENABLED_S 0
108 #define EEP_RFSILENT_POLARITY 0x0002
109 #define EEP_RFSILENT_POLARITY_S 1
110 #define EEP_RFSILENT_GPIO_SEL 0x001c
111 #define EEP_RFSILENT_GPIO_SEL_S 2
113 #define AR5416_OPFLAGS_11A 0x01
114 #define AR5416_OPFLAGS_11G 0x02
115 #define AR5416_OPFLAGS_N_5G_HT40 0x04
116 #define AR5416_OPFLAGS_N_2G_HT40 0x08
117 #define AR5416_OPFLAGS_N_5G_HT20 0x10
118 #define AR5416_OPFLAGS_N_2G_HT20 0x20
120 #define AR5416_EEP_NO_BACK_VER 0x1
121 #define AR5416_EEP_VER 0xE
122 #define AR5416_EEP_VER_MINOR_MASK 0x0FFF
123 #define AR5416_EEP_MINOR_VER_2 0x2
124 #define AR5416_EEP_MINOR_VER_3 0x3
125 #define AR5416_EEP_MINOR_VER_7 0x7
126 #define AR5416_EEP_MINOR_VER_9 0x9
127 #define AR5416_EEP_MINOR_VER_16 0x10
128 #define AR5416_EEP_MINOR_VER_17 0x11
129 #define AR5416_EEP_MINOR_VER_19 0x13
130 #define AR5416_EEP_MINOR_VER_20 0x14
131 #define AR5416_EEP_MINOR_VER_22 0x16
133 #define AR5416_NUM_5G_CAL_PIERS 8
134 #define AR5416_NUM_2G_CAL_PIERS 4
135 #define AR5416_NUM_5G_20_TARGET_POWERS 8
136 #define AR5416_NUM_5G_40_TARGET_POWERS 8
137 #define AR5416_NUM_2G_CCK_TARGET_POWERS 3
138 #define AR5416_NUM_2G_20_TARGET_POWERS 4
139 #define AR5416_NUM_2G_40_TARGET_POWERS 4
140 #define AR5416_NUM_CTLS 24
141 #define AR5416_NUM_BAND_EDGES 8
142 #define AR5416_NUM_PD_GAINS 4
143 #define AR5416_PD_GAINS_IN_MASK 4
144 #define AR5416_PD_GAIN_ICEPTS 5
145 #define AR5416_EEPROM_MODAL_SPURS 5
146 #define AR5416_MAX_RATE_POWER 63
147 #define AR5416_NUM_PDADC_VALUES 128
148 #define AR5416_BCHAN_UNUSED 0xFF
149 #define AR5416_MAX_PWR_RANGE_IN_HALF_DB 64
150 #define AR5416_MAX_CHAINS 3
151 #define AR5416_PWR_TABLE_OFFSET -5
153 /* Rx gain type values */
154 #define AR5416_EEP_RXGAIN_23DB_BACKOFF 0
155 #define AR5416_EEP_RXGAIN_13DB_BACKOFF 1
156 #define AR5416_EEP_RXGAIN_ORIG 2
158 /* Tx gain type values */
159 #define AR5416_EEP_TXGAIN_ORIGINAL 0
160 #define AR5416_EEP_TXGAIN_HIGH_POWER 1
162 #define AR5416_EEP4K_START_LOC 64
163 #define AR5416_EEP4K_NUM_2G_CAL_PIERS 3
164 #define AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS 3
165 #define AR5416_EEP4K_NUM_2G_20_TARGET_POWERS 3
166 #define AR5416_EEP4K_NUM_2G_40_TARGET_POWERS 3
167 #define AR5416_EEP4K_NUM_CTLS 12
168 #define AR5416_EEP4K_NUM_BAND_EDGES 4
169 #define AR5416_EEP4K_NUM_PD_GAINS 2
170 #define AR5416_EEP4K_PD_GAINS_IN_MASK 4
171 #define AR5416_EEP4K_PD_GAIN_ICEPTS 5
172 #define AR5416_EEP4K_MAX_CHAINS 1
174 #define AR9280_TX_GAIN_TABLE_SIZE 22
203 rate6mb, rate9mb, rate12mb, rate18mb,
204 rate24mb, rate36mb, rate48mb, rate54mb,
205 rate1l, rate2l, rate2s, rate5_5l,
206 rate5_5s, rate11l, rate11s, rateXr,
207 rateHt20_0, rateHt20_1, rateHt20_2, rateHt20_3,
208 rateHt20_4, rateHt20_5, rateHt20_6, rateHt20_7,
209 rateHt40_0, rateHt40_1, rateHt40_2, rateHt40_3,
210 rateHt40_4, rateHt40_5, rateHt40_6, rateHt40_7,
211 rateDupCck, rateDupOfdm, rateExtCck, rateExtOfdm,
215 enum ath9k_hal_freq_band {
216 ATH9K_HAL_FREQ_BAND_5GHZ = 0,
217 ATH9K_HAL_FREQ_BAND_2GHZ = 1
220 struct base_eep_header {
231 u16 blueToothOptions;
244 u8 power_table_offset;
249 struct base_eep_header_4k {
260 u16 blueToothOptions;
274 struct modal_eep_header {
275 u32 antCtrlChain[AR5416_MAX_CHAINS];
277 u8 antennaGainCh[AR5416_MAX_CHAINS];
279 u8 txRxAttenCh[AR5416_MAX_CHAINS];
280 u8 rxTxMarginCh[AR5416_MAX_CHAINS];
283 u8 xlnaGainCh[AR5416_MAX_CHAINS];
288 u8 noiseFloorThreshCh[AR5416_MAX_CHAINS];
291 u8 iqCalICh[AR5416_MAX_CHAINS];
292 u8 iqCalQCh[AR5416_MAX_CHAINS];
297 u8 pwrDecreaseFor2Chain;
298 u8 pwrDecreaseFor3Chain;
299 u8 txFrameToDataStart;
301 u8 ht40PowerIncForPdadc;
302 u8 bswAtten[AR5416_MAX_CHAINS];
303 u8 bswMargin[AR5416_MAX_CHAINS];
305 u8 xatten2Db[AR5416_MAX_CHAINS];
306 u8 xatten2Margin[AR5416_MAX_CHAINS];
312 femBandSelectUsed:1, xlnabufin:1, xlnaisel:2, xlnabufmode:1;
314 u16 xpaBiasLvlFreq[3];
317 struct spur_chan spurChans[AR5416_EEPROM_MODAL_SPURS];
320 struct calDataPerFreqOpLoop {
327 struct modal_eep_4k_header {
328 u32 antCtrlChain[AR5416_EEP4K_MAX_CHAINS];
330 u8 antennaGainCh[AR5416_EEP4K_MAX_CHAINS];
332 u8 txRxAttenCh[AR5416_EEP4K_MAX_CHAINS];
333 u8 rxTxMarginCh[AR5416_EEP4K_MAX_CHAINS];
336 u8 xlnaGainCh[AR5416_EEP4K_MAX_CHAINS];
341 u8 noiseFloorThreshCh[AR5416_EEP4K_MAX_CHAINS];
344 u8 iqCalICh[AR5416_EEP4K_MAX_CHAINS];
345 u8 iqCalQCh[AR5416_EEP4K_MAX_CHAINS];
350 u8 txFrameToDataStart;
352 u8 ht40PowerIncForPdadc;
353 u8 bswAtten[AR5416_EEP4K_MAX_CHAINS];
354 u8 bswMargin[AR5416_EEP4K_MAX_CHAINS];
356 u8 xatten2Db[AR5416_EEP4K_MAX_CHAINS];
357 u8 xatten2Margin[AR5416_EEP4K_MAX_CHAINS];
365 struct spur_chan spurChans[AR5416_EEPROM_MODAL_SPURS];
369 struct cal_data_per_freq {
370 u8 pwrPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
371 u8 vpdPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
374 struct cal_data_per_freq_4k {
375 u8 pwrPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_EEP4K_PD_GAIN_ICEPTS];
376 u8 vpdPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_EEP4K_PD_GAIN_ICEPTS];
379 struct cal_target_power_leg {
384 struct cal_target_power_ht {
390 #ifdef __BIG_ENDIAN_BITFIELD
391 struct cal_ctl_edges {
396 struct cal_ctl_edges {
402 struct cal_ctl_data {
404 ctlEdges[AR5416_MAX_CHAINS][AR5416_NUM_BAND_EDGES];
407 struct cal_ctl_data_4k {
409 ctlEdges[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_BAND_EDGES];
412 struct ar5416_eeprom_def {
413 struct base_eep_header baseEepHeader;
415 struct modal_eep_header modalHeader[2];
416 u8 calFreqPier5G[AR5416_NUM_5G_CAL_PIERS];
417 u8 calFreqPier2G[AR5416_NUM_2G_CAL_PIERS];
418 struct cal_data_per_freq
419 calPierData5G[AR5416_MAX_CHAINS][AR5416_NUM_5G_CAL_PIERS];
420 struct cal_data_per_freq
421 calPierData2G[AR5416_MAX_CHAINS][AR5416_NUM_2G_CAL_PIERS];
422 struct cal_target_power_leg
423 calTargetPower5G[AR5416_NUM_5G_20_TARGET_POWERS];
424 struct cal_target_power_ht
425 calTargetPower5GHT20[AR5416_NUM_5G_20_TARGET_POWERS];
426 struct cal_target_power_ht
427 calTargetPower5GHT40[AR5416_NUM_5G_40_TARGET_POWERS];
428 struct cal_target_power_leg
429 calTargetPowerCck[AR5416_NUM_2G_CCK_TARGET_POWERS];
430 struct cal_target_power_leg
431 calTargetPower2G[AR5416_NUM_2G_20_TARGET_POWERS];
432 struct cal_target_power_ht
433 calTargetPower2GHT20[AR5416_NUM_2G_20_TARGET_POWERS];
434 struct cal_target_power_ht
435 calTargetPower2GHT40[AR5416_NUM_2G_40_TARGET_POWERS];
436 u8 ctlIndex[AR5416_NUM_CTLS];
437 struct cal_ctl_data ctlData[AR5416_NUM_CTLS];
441 struct ar5416_eeprom_4k {
442 struct base_eep_header_4k baseEepHeader;
444 struct modal_eep_4k_header modalHeader;
445 u8 calFreqPier2G[AR5416_EEP4K_NUM_2G_CAL_PIERS];
446 struct cal_data_per_freq_4k
447 calPierData2G[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_2G_CAL_PIERS];
448 struct cal_target_power_leg
449 calTargetPowerCck[AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS];
450 struct cal_target_power_leg
451 calTargetPower2G[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS];
452 struct cal_target_power_ht
453 calTargetPower2GHT20[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS];
454 struct cal_target_power_ht
455 calTargetPower2GHT40[AR5416_EEP4K_NUM_2G_40_TARGET_POWERS];
456 u8 ctlIndex[AR5416_EEP4K_NUM_CTLS];
457 struct cal_ctl_data_4k ctlData[AR5416_EEP4K_NUM_CTLS];
461 enum reg_ext_bitmap {
462 REG_EXT_JAPAN_MIDBAND = 1,
463 REG_EXT_FCC_DFS_HT40 = 2,
464 REG_EXT_JAPAN_NONDFS_HT40 = 3,
465 REG_EXT_JAPAN_DFS_HT40 = 4
468 struct ath9k_country_entry {
478 EEP_MAP_DEFAULT = 0x0,
484 int (*check_eeprom)(struct ath_hw *hw);
485 u32 (*get_eeprom)(struct ath_hw *hw, enum eeprom_param param);
486 bool (*fill_eeprom)(struct ath_hw *hw);
487 int (*get_eeprom_ver)(struct ath_hw *hw);
488 int (*get_eeprom_rev)(struct ath_hw *hw);
489 u8 (*get_num_ant_config)(struct ath_hw *hw, enum ieee80211_band band);
490 u16 (*get_eeprom_antenna_cfg)(struct ath_hw *hw,
491 struct ath9k_channel *chan);
492 bool (*set_board_values)(struct ath_hw *hw, struct ath9k_channel *chan);
493 void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan);
494 int (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan,
495 u16 cfgCtl, u8 twiceAntennaReduction,
496 u8 twiceMaxRegulatoryPower, u8 powerLimit);
497 u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz);
500 #define ar5416_get_ntxchains(_txchainmask) \
501 (((_txchainmask >> 2) & 1) + \
502 ((_txchainmask >> 1) & 1) + (_txchainmask & 1))
504 int ath9k_hw_eeprom_attach(struct ath_hw *ah);
506 #endif /* EEPROM_H */