xref: /openbmc/linux/drivers/net/wireless/ath/ath9k/eeprom.h (revision 23bd7cedf1f1c97a5019de6f7736ab935d7cc6a3)
1203c4805SLuis R. Rodriguez /*
25b68138eSSujith Manoharan  * Copyright (c) 2008-2011 Atheros Communications Inc.
3203c4805SLuis R. Rodriguez  *
4203c4805SLuis R. Rodriguez  * Permission to use, copy, modify, and/or distribute this software for any
5203c4805SLuis R. Rodriguez  * purpose with or without fee is hereby granted, provided that the above
6203c4805SLuis R. Rodriguez  * copyright notice and this permission notice appear in all copies.
7203c4805SLuis R. Rodriguez  *
8203c4805SLuis R. Rodriguez  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9203c4805SLuis R. Rodriguez  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10203c4805SLuis R. Rodriguez  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11203c4805SLuis R. Rodriguez  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12203c4805SLuis R. Rodriguez  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13203c4805SLuis R. Rodriguez  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14203c4805SLuis R. Rodriguez  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15203c4805SLuis R. Rodriguez  */
16203c4805SLuis R. Rodriguez 
17203c4805SLuis R. Rodriguez #ifndef EEPROM_H
18203c4805SLuis R. Rodriguez #define EEPROM_H
19203c4805SLuis R. Rodriguez 
204ddfcd7dSFelix Fietkau #define AR_EEPROM_MODAL_SPURS   5
214ddfcd7dSFelix Fietkau 
225bb12791SLuis R. Rodriguez #include "../ath.h"
23d3236553SJohannes Berg #include <net/cfg80211.h>
2415c9ee7aSSenthil Balasubramanian #include "ar9003_eeprom.h"
25203c4805SLuis R. Rodriguez 
26203c4805SLuis R. Rodriguez #ifdef __BIG_ENDIAN
27203c4805SLuis R. Rodriguez #define AR5416_EEPROM_MAGIC 0x5aa5
28203c4805SLuis R. Rodriguez #else
29203c4805SLuis R. Rodriguez #define AR5416_EEPROM_MAGIC 0xa55a
30203c4805SLuis R. Rodriguez #endif
31203c4805SLuis R. Rodriguez 
32203c4805SLuis R. Rodriguez #define CTRY_DEBUG   0x1ff
33203c4805SLuis R. Rodriguez #define	CTRY_DEFAULT 0
34203c4805SLuis R. Rodriguez 
35203c4805SLuis R. Rodriguez #define AR_EEPROM_EEPCAP_COMPRESS_DIS   0x0001
36203c4805SLuis R. Rodriguez #define AR_EEPROM_EEPCAP_AES_DIS        0x0002
37203c4805SLuis R. Rodriguez #define AR_EEPROM_EEPCAP_FASTFRAME_DIS  0x0004
38203c4805SLuis R. Rodriguez #define AR_EEPROM_EEPCAP_BURST_DIS      0x0008
39203c4805SLuis R. Rodriguez #define AR_EEPROM_EEPCAP_MAXQCU         0x01F0
40203c4805SLuis R. Rodriguez #define AR_EEPROM_EEPCAP_MAXQCU_S       4
41203c4805SLuis R. Rodriguez #define AR_EEPROM_EEPCAP_HEAVY_CLIP_EN  0x0200
42203c4805SLuis R. Rodriguez #define AR_EEPROM_EEPCAP_KC_ENTRIES     0xF000
43203c4805SLuis R. Rodriguez #define AR_EEPROM_EEPCAP_KC_ENTRIES_S   12
44203c4805SLuis R. Rodriguez 
45203c4805SLuis R. Rodriguez #define AR_EEPROM_EEREGCAP_EN_FCC_MIDBAND   0x0040
46203c4805SLuis R. Rodriguez #define AR_EEPROM_EEREGCAP_EN_KK_U1_EVEN    0x0080
47203c4805SLuis R. Rodriguez #define AR_EEPROM_EEREGCAP_EN_KK_U2         0x0100
48203c4805SLuis R. Rodriguez #define AR_EEPROM_EEREGCAP_EN_KK_MIDBAND    0x0200
49203c4805SLuis R. Rodriguez #define AR_EEPROM_EEREGCAP_EN_KK_U1_ODD     0x0400
50203c4805SLuis R. Rodriguez #define AR_EEPROM_EEREGCAP_EN_KK_NEW_11A    0x0800
51203c4805SLuis R. Rodriguez 
52203c4805SLuis R. Rodriguez #define AR_EEPROM_EEREGCAP_EN_KK_U1_ODD_PRE4_0  0x4000
53203c4805SLuis R. Rodriguez #define AR_EEPROM_EEREGCAP_EN_KK_NEW_11A_PRE4_0 0x8000
54203c4805SLuis R. Rodriguez 
55203c4805SLuis R. Rodriguez #define AR5416_EEPROM_MAGIC_OFFSET  0x0
56203c4805SLuis R. Rodriguez #define AR5416_EEPROM_S             2
57203c4805SLuis R. Rodriguez #define AR5416_EEPROM_OFFSET        0x2000
58203c4805SLuis R. Rodriguez #define AR5416_EEPROM_MAX           0xae0
59203c4805SLuis R. Rodriguez 
60203c4805SLuis R. Rodriguez #define AR5416_EEPROM_START_ADDR \
61203c4805SLuis R. Rodriguez 	(AR_SREV_9100(ah)) ? 0x1fff1000 : 0x503f1200
62203c4805SLuis R. Rodriguez 
63203c4805SLuis R. Rodriguez #define SD_NO_CTL               0xE0
64203c4805SLuis R. Rodriguez #define NO_CTL                  0xff
6590487974SLuis R. Rodriguez #define CTL_MODE_M              0xf
66203c4805SLuis R. Rodriguez #define CTL_11A                 0
67203c4805SLuis R. Rodriguez #define CTL_11B                 1
68203c4805SLuis R. Rodriguez #define CTL_11G                 2
69203c4805SLuis R. Rodriguez #define CTL_2GHT20              5
70203c4805SLuis R. Rodriguez #define CTL_5GHT20              6
71203c4805SLuis R. Rodriguez #define CTL_2GHT40              7
72203c4805SLuis R. Rodriguez #define CTL_5GHT40              8
73203c4805SLuis R. Rodriguez 
74203c4805SLuis R. Rodriguez #define EXT_ADDITIVE (0x8000)
75203c4805SLuis R. Rodriguez #define CTL_11A_EXT (CTL_11A | EXT_ADDITIVE)
76203c4805SLuis R. Rodriguez #define CTL_11G_EXT (CTL_11G | EXT_ADDITIVE)
77203c4805SLuis R. Rodriguez #define CTL_11B_EXT (CTL_11B | EXT_ADDITIVE)
78203c4805SLuis R. Rodriguez 
79203c4805SLuis R. Rodriguez #define SUB_NUM_CTL_MODES_AT_5G_40 2
80203c4805SLuis R. Rodriguez #define SUB_NUM_CTL_MODES_AT_2G_40 3
81203c4805SLuis R. Rodriguez 
826010e72cSGabor Juhos #define POWER_CORRECTION_FOR_TWO_CHAIN		6  /* 10*log10(2)*2 */
836010e72cSGabor Juhos #define POWER_CORRECTION_FOR_THREE_CHAIN	10 /* 10*log10(3)*2 */
84ea6f792bSGabor Juhos 
85203c4805SLuis R. Rodriguez /*
86203c4805SLuis R. Rodriguez  * For AR9285 and later chipsets, the following bits are not being programmed
87203c4805SLuis R. Rodriguez  * in EEPROM and so need to be enabled always.
88203c4805SLuis R. Rodriguez  *
89203c4805SLuis R. Rodriguez  * Bit 0: en_fcc_mid
90203c4805SLuis R. Rodriguez  * Bit 1: en_jap_mid
91203c4805SLuis R. Rodriguez  * Bit 2: en_fcc_dfs_ht40
92203c4805SLuis R. Rodriguez  * Bit 3: en_jap_ht40
93203c4805SLuis R. Rodriguez  * Bit 4: en_jap_dfs_ht40
94203c4805SLuis R. Rodriguez  */
95203c4805SLuis R. Rodriguez #define AR9285_RDEXT_DEFAULT    0x1F
96203c4805SLuis R. Rodriguez 
97203c4805SLuis R. Rodriguez #define ATH9K_POW_SM(_r, _s)	(((_r) & 0x3f) << (_s))
98203c4805SLuis R. Rodriguez #define FREQ2FBIN(x, y)		((y) ? ((x) - 2300) : (((x) - 4800) / 5))
99203c4805SLuis R. Rodriguez #define ath9k_hw_use_flash(_ah)	(!(_ah->ah_flags & AH_USE_EEPROM))
100203c4805SLuis R. Rodriguez 
101203c4805SLuis R. Rodriguez #define AR5416_VER_MASK (eep->baseEepHeader.version & AR5416_EEP_VER_MINOR_MASK)
102203c4805SLuis R. Rodriguez #define OLC_FOR_AR9280_20_LATER (AR_SREV_9280_20_OR_LATER(ah) && \
103203c4805SLuis R. Rodriguez 				 ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
104a42acef0SFelix Fietkau #define OLC_FOR_AR9287_10_LATER (AR_SREV_9287_11_OR_LATER(ah) && \
105ac88b6ecSVivek Natarajan 				 ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
106203c4805SLuis R. Rodriguez 
107203c4805SLuis R. Rodriguez #define EEP_RFSILENT_ENABLED        0x0001
108203c4805SLuis R. Rodriguez #define EEP_RFSILENT_ENABLED_S      0
109203c4805SLuis R. Rodriguez #define EEP_RFSILENT_POLARITY       0x0002
110203c4805SLuis R. Rodriguez #define EEP_RFSILENT_POLARITY_S     1
111423e38e8SRajkumar Manoharan #define EEP_RFSILENT_GPIO_SEL       (AR_SREV_9462(ah) ? 0x00fc : 0x001c)
112203c4805SLuis R. Rodriguez #define EEP_RFSILENT_GPIO_SEL_S     2
113203c4805SLuis R. Rodriguez 
114203c4805SLuis R. Rodriguez #define AR5416_OPFLAGS_11A           0x01
115203c4805SLuis R. Rodriguez #define AR5416_OPFLAGS_11G           0x02
116203c4805SLuis R. Rodriguez #define AR5416_OPFLAGS_N_5G_HT40     0x04
117203c4805SLuis R. Rodriguez #define AR5416_OPFLAGS_N_2G_HT40     0x08
118203c4805SLuis R. Rodriguez #define AR5416_OPFLAGS_N_5G_HT20     0x10
119203c4805SLuis R. Rodriguez #define AR5416_OPFLAGS_N_2G_HT20     0x20
120203c4805SLuis R. Rodriguez 
121203c4805SLuis R. Rodriguez #define AR5416_EEP_NO_BACK_VER       0x1
122203c4805SLuis R. Rodriguez #define AR5416_EEP_VER               0xE
123203c4805SLuis R. Rodriguez #define AR5416_EEP_VER_MINOR_MASK    0x0FFF
124203c4805SLuis R. Rodriguez #define AR5416_EEP_MINOR_VER_2       0x2
125203c4805SLuis R. Rodriguez #define AR5416_EEP_MINOR_VER_3       0x3
126203c4805SLuis R. Rodriguez #define AR5416_EEP_MINOR_VER_7       0x7
127203c4805SLuis R. Rodriguez #define AR5416_EEP_MINOR_VER_9       0x9
128203c4805SLuis R. Rodriguez #define AR5416_EEP_MINOR_VER_16      0x10
129203c4805SLuis R. Rodriguez #define AR5416_EEP_MINOR_VER_17      0x11
130203c4805SLuis R. Rodriguez #define AR5416_EEP_MINOR_VER_19      0x13
131203c4805SLuis R. Rodriguez #define AR5416_EEP_MINOR_VER_20      0x14
132e41f0bfcSSenthil Balasubramanian #define AR5416_EEP_MINOR_VER_21      0x15
133203c4805SLuis R. Rodriguez #define AR5416_EEP_MINOR_VER_22      0x16
134203c4805SLuis R. Rodriguez 
135203c4805SLuis R. Rodriguez #define AR5416_NUM_5G_CAL_PIERS         8
136203c4805SLuis R. Rodriguez #define AR5416_NUM_2G_CAL_PIERS         4
137203c4805SLuis R. Rodriguez #define AR5416_NUM_5G_20_TARGET_POWERS  8
138203c4805SLuis R. Rodriguez #define AR5416_NUM_5G_40_TARGET_POWERS  8
139203c4805SLuis R. Rodriguez #define AR5416_NUM_2G_CCK_TARGET_POWERS 3
140203c4805SLuis R. Rodriguez #define AR5416_NUM_2G_20_TARGET_POWERS  4
141203c4805SLuis R. Rodriguez #define AR5416_NUM_2G_40_TARGET_POWERS  4
142203c4805SLuis R. Rodriguez #define AR5416_NUM_CTLS                 24
143203c4805SLuis R. Rodriguez #define AR5416_NUM_BAND_EDGES           8
144203c4805SLuis R. Rodriguez #define AR5416_NUM_PD_GAINS             4
145203c4805SLuis R. Rodriguez #define AR5416_PD_GAINS_IN_MASK         4
146203c4805SLuis R. Rodriguez #define AR5416_PD_GAIN_ICEPTS           5
147203c4805SLuis R. Rodriguez #define AR5416_NUM_PDADC_VALUES         128
148203c4805SLuis R. Rodriguez #define AR5416_BCHAN_UNUSED             0xFF
149203c4805SLuis R. Rodriguez #define AR5416_MAX_PWR_RANGE_IN_HALF_DB 64
150203c4805SLuis R. Rodriguez #define AR5416_MAX_CHAINS               3
151df23acaaSLuis R. Rodriguez #define AR9300_MAX_CHAINS		3
152e41f0bfcSSenthil Balasubramanian #define AR5416_PWR_TABLE_OFFSET_DB     -5
153203c4805SLuis R. Rodriguez 
154203c4805SLuis R. Rodriguez /* Rx gain type values */
155203c4805SLuis R. Rodriguez #define AR5416_EEP_RXGAIN_23DB_BACKOFF     0
156203c4805SLuis R. Rodriguez #define AR5416_EEP_RXGAIN_13DB_BACKOFF     1
157203c4805SLuis R. Rodriguez #define AR5416_EEP_RXGAIN_ORIG             2
158203c4805SLuis R. Rodriguez 
159203c4805SLuis R. Rodriguez /* Tx gain type values */
160203c4805SLuis R. Rodriguez #define AR5416_EEP_TXGAIN_ORIGINAL         0
161203c4805SLuis R. Rodriguez #define AR5416_EEP_TXGAIN_HIGH_POWER       1
162203c4805SLuis R. Rodriguez 
163203c4805SLuis R. Rodriguez #define AR5416_EEP4K_START_LOC                64
164203c4805SLuis R. Rodriguez #define AR5416_EEP4K_NUM_2G_CAL_PIERS         3
165203c4805SLuis R. Rodriguez #define AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS 3
166203c4805SLuis R. Rodriguez #define AR5416_EEP4K_NUM_2G_20_TARGET_POWERS  3
167203c4805SLuis R. Rodriguez #define AR5416_EEP4K_NUM_2G_40_TARGET_POWERS  3
168203c4805SLuis R. Rodriguez #define AR5416_EEP4K_NUM_CTLS                 12
169203c4805SLuis R. Rodriguez #define AR5416_EEP4K_NUM_BAND_EDGES           4
170203c4805SLuis R. Rodriguez #define AR5416_EEP4K_NUM_PD_GAINS             2
171203c4805SLuis R. Rodriguez #define AR5416_EEP4K_MAX_CHAINS               1
172203c4805SLuis R. Rodriguez 
173203c4805SLuis R. Rodriguez #define AR9280_TX_GAIN_TABLE_SIZE 22
174203c4805SLuis R. Rodriguez 
175ac88b6ecSVivek Natarajan #define AR9287_EEP_VER               0xE
176ac88b6ecSVivek Natarajan #define AR9287_EEP_VER_MINOR_MASK    0xFFF
177ac88b6ecSVivek Natarajan #define AR9287_EEP_MINOR_VER_1       0x1
178ac88b6ecSVivek Natarajan #define AR9287_EEP_MINOR_VER_2       0x2
179ac88b6ecSVivek Natarajan #define AR9287_EEP_MINOR_VER_3       0x3
180ac88b6ecSVivek Natarajan #define AR9287_EEP_MINOR_VER         AR9287_EEP_MINOR_VER_3
181ac88b6ecSVivek Natarajan #define AR9287_EEP_MINOR_VER_b       AR9287_EEP_MINOR_VER
182ac88b6ecSVivek Natarajan #define AR9287_EEP_NO_BACK_VER       AR9287_EEP_MINOR_VER_1
183ac88b6ecSVivek Natarajan 
184ac88b6ecSVivek Natarajan #define AR9287_EEP_START_LOC            128
185ca6cff1fSRajkumar Manoharan #define AR9287_HTC_EEP_START_LOC        256
186ac88b6ecSVivek Natarajan #define AR9287_NUM_2G_CAL_PIERS         3
187ac88b6ecSVivek Natarajan #define AR9287_NUM_2G_CCK_TARGET_POWERS 3
188ac88b6ecSVivek Natarajan #define AR9287_NUM_2G_20_TARGET_POWERS  3
189ac88b6ecSVivek Natarajan #define AR9287_NUM_2G_40_TARGET_POWERS  3
190ac88b6ecSVivek Natarajan #define AR9287_NUM_CTLS              	12
191ac88b6ecSVivek Natarajan #define AR9287_NUM_BAND_EDGES        	4
192ac88b6ecSVivek Natarajan #define AR9287_PD_GAIN_ICEPTS           1
193ac88b6ecSVivek Natarajan #define AR9287_EEPMISC_BIG_ENDIAN       0x01
194ac88b6ecSVivek Natarajan #define AR9287_EEPMISC_WOW              0x02
195ac88b6ecSVivek Natarajan #define AR9287_MAX_CHAINS               2
196ac88b6ecSVivek Natarajan #define AR9287_ANT_16S                  32
197ac88b6ecSVivek Natarajan 
198ac88b6ecSVivek Natarajan #define AR9287_DATA_SZ                  32
199ac88b6ecSVivek Natarajan 
200ac88b6ecSVivek Natarajan #define AR9287_PWR_TABLE_OFFSET_DB  -5
201ac88b6ecSVivek Natarajan 
202ac88b6ecSVivek Natarajan #define AR9287_CHECKSUM_LOCATION (AR9287_EEP_START_LOC + 1)
203ac88b6ecSVivek Natarajan 
204e702ba18SFelix Fietkau #define CTL_EDGE_TPOWER(_ctl) ((_ctl) & 0x3f)
205e702ba18SFelix Fietkau #define CTL_EDGE_FLAGS(_ctl) (((_ctl) >> 6) & 0x03)
206e702ba18SFelix Fietkau 
207f67e07ebSFelix Fietkau #define LNA_CTL_BUF_MODE	BIT(0)
208f67e07ebSFelix Fietkau #define LNA_CTL_ISEL_LO		BIT(1)
209f67e07ebSFelix Fietkau #define LNA_CTL_ISEL_HI		BIT(2)
210f67e07ebSFelix Fietkau #define LNA_CTL_BUF_IN		BIT(3)
211f67e07ebSFelix Fietkau #define LNA_CTL_FEM_BAND	BIT(4)
212f67e07ebSFelix Fietkau #define LNA_CTL_LOCAL_BIAS	BIT(5)
213f67e07ebSFelix Fietkau #define LNA_CTL_FORCE_XPA	BIT(6)
214f67e07ebSFelix Fietkau #define LNA_CTL_USE_ANT1	BIT(7)
215f67e07ebSFelix Fietkau 
216203c4805SLuis R. Rodriguez enum eeprom_param {
217203c4805SLuis R. Rodriguez 	EEP_NFTHRESH_5,
218203c4805SLuis R. Rodriguez 	EEP_NFTHRESH_2,
219203c4805SLuis R. Rodriguez 	EEP_MAC_MSW,
220203c4805SLuis R. Rodriguez 	EEP_MAC_MID,
221203c4805SLuis R. Rodriguez 	EEP_MAC_LSW,
222203c4805SLuis R. Rodriguez 	EEP_REG_0,
223203c4805SLuis R. Rodriguez 	EEP_OP_CAP,
224203c4805SLuis R. Rodriguez 	EEP_OP_MODE,
225203c4805SLuis R. Rodriguez 	EEP_RF_SILENT,
226203c4805SLuis R. Rodriguez 	EEP_OB_5,
227203c4805SLuis R. Rodriguez 	EEP_DB_5,
228203c4805SLuis R. Rodriguez 	EEP_OB_2,
229203c4805SLuis R. Rodriguez 	EEP_DB_2,
230203c4805SLuis R. Rodriguez 	EEP_MINOR_REV,
231203c4805SLuis R. Rodriguez 	EEP_TX_MASK,
232203c4805SLuis R. Rodriguez 	EEP_RX_MASK,
23315c9ee7aSSenthil Balasubramanian 	EEP_FSTCLK_5G,
234203c4805SLuis R. Rodriguez 	EEP_RXGAIN_TYPE,
235203c4805SLuis R. Rodriguez 	EEP_OL_PWRCTRL,
23615c9ee7aSSenthil Balasubramanian 	EEP_TXGAIN_TYPE,
237203c4805SLuis R. Rodriguez 	EEP_RC_CHAIN_MASK,
238203c4805SLuis R. Rodriguez 	EEP_DAC_HPWR_5G,
239ac88b6ecSVivek Natarajan 	EEP_FRAC_N_5G,
240ac88b6ecSVivek Natarajan 	EEP_DEV_TYPE,
241ac88b6ecSVivek Natarajan 	EEP_TEMPSENSE_SLOPE,
242ac88b6ecSVivek Natarajan 	EEP_TEMPSENSE_SLOPE_PAL_ON,
24315c9ee7aSSenthil Balasubramanian 	EEP_PWR_TABLE_OFFSET,
24415c9ee7aSSenthil Balasubramanian 	EEP_DRIVE_STRENGTH,
24515c9ee7aSSenthil Balasubramanian 	EEP_INTERNAL_REGULATOR,
2464935250aSFelix Fietkau 	EEP_SWREG,
2474935250aSFelix Fietkau 	EEP_PAPRD,
248754dc536SVasanthakumar Thiagarajan 	EEP_MODAL_VER,
249754dc536SVasanthakumar Thiagarajan 	EEP_ANT_DIV_CTL1,
250ca2c68ccSFelix Fietkau 	EEP_CHAIN_MASK_REDUCE,
251ca2c68ccSFelix Fietkau 	EEP_ANTENNA_GAIN_2G,
252df222edcSRajkumar Manoharan 	EEP_ANTENNA_GAIN_5G,
253df222edcSRajkumar Manoharan 	EEP_QUICK_DROP
254203c4805SLuis R. Rodriguez };
255203c4805SLuis R. Rodriguez 
256203c4805SLuis R. Rodriguez enum ar5416_rates {
257203c4805SLuis R. Rodriguez 	rate6mb, rate9mb, rate12mb, rate18mb,
258203c4805SLuis R. Rodriguez 	rate24mb, rate36mb, rate48mb, rate54mb,
259203c4805SLuis R. Rodriguez 	rate1l, rate2l, rate2s, rate5_5l,
260203c4805SLuis R. Rodriguez 	rate5_5s, rate11l, rate11s, rateXr,
261203c4805SLuis R. Rodriguez 	rateHt20_0, rateHt20_1, rateHt20_2, rateHt20_3,
262203c4805SLuis R. Rodriguez 	rateHt20_4, rateHt20_5, rateHt20_6, rateHt20_7,
263203c4805SLuis R. Rodriguez 	rateHt40_0, rateHt40_1, rateHt40_2, rateHt40_3,
264203c4805SLuis R. Rodriguez 	rateHt40_4, rateHt40_5, rateHt40_6, rateHt40_7,
265203c4805SLuis R. Rodriguez 	rateDupCck, rateDupOfdm, rateExtCck, rateExtOfdm,
266203c4805SLuis R. Rodriguez 	Ar5416RateSize
267203c4805SLuis R. Rodriguez };
268203c4805SLuis R. Rodriguez 
269203c4805SLuis R. Rodriguez enum ath9k_hal_freq_band {
270203c4805SLuis R. Rodriguez 	ATH9K_HAL_FREQ_BAND_5GHZ = 0,
271203c4805SLuis R. Rodriguez 	ATH9K_HAL_FREQ_BAND_2GHZ = 1
272203c4805SLuis R. Rodriguez };
273203c4805SLuis R. Rodriguez 
274203c4805SLuis R. Rodriguez struct base_eep_header {
275203c4805SLuis R. Rodriguez 	u16 length;
276203c4805SLuis R. Rodriguez 	u16 checksum;
277203c4805SLuis R. Rodriguez 	u16 version;
278203c4805SLuis R. Rodriguez 	u8 opCapFlags;
279203c4805SLuis R. Rodriguez 	u8 eepMisc;
280203c4805SLuis R. Rodriguez 	u16 regDmn[2];
281203c4805SLuis R. Rodriguez 	u8 macAddr[6];
282203c4805SLuis R. Rodriguez 	u8 rxMask;
283203c4805SLuis R. Rodriguez 	u8 txMask;
284203c4805SLuis R. Rodriguez 	u16 rfSilent;
285203c4805SLuis R. Rodriguez 	u16 blueToothOptions;
286203c4805SLuis R. Rodriguez 	u16 deviceCap;
287203c4805SLuis R. Rodriguez 	u32 binBuildNumber;
288203c4805SLuis R. Rodriguez 	u8 deviceType;
289203c4805SLuis R. Rodriguez 	u8 pwdclkind;
2905b75d0fcSFelix Fietkau 	u8 fastClk5g;
2915b75d0fcSFelix Fietkau 	u8 divChain;
292203c4805SLuis R. Rodriguez 	u8 rxGainType;
293203c4805SLuis R. Rodriguez 	u8 dacHiPwrMode_5G;
294203c4805SLuis R. Rodriguez 	u8 openLoopPwrCntl;
295203c4805SLuis R. Rodriguez 	u8 dacLpMode;
296203c4805SLuis R. Rodriguez 	u8 txGainType;
297203c4805SLuis R. Rodriguez 	u8 rcChainMask;
298203c4805SLuis R. Rodriguez 	u8 desiredScaleCCK;
299e41f0bfcSSenthil Balasubramanian 	u8 pwr_table_offset;
300203c4805SLuis R. Rodriguez 	u8 frac_n_5g;
301203c4805SLuis R. Rodriguez 	u8 futureBase_3[21];
302203c4805SLuis R. Rodriguez } __packed;
303203c4805SLuis R. Rodriguez 
304203c4805SLuis R. Rodriguez struct base_eep_header_4k {
305203c4805SLuis R. Rodriguez 	u16 length;
306203c4805SLuis R. Rodriguez 	u16 checksum;
307203c4805SLuis R. Rodriguez 	u16 version;
308203c4805SLuis R. Rodriguez 	u8 opCapFlags;
309203c4805SLuis R. Rodriguez 	u8 eepMisc;
310203c4805SLuis R. Rodriguez 	u16 regDmn[2];
311203c4805SLuis R. Rodriguez 	u8 macAddr[6];
312203c4805SLuis R. Rodriguez 	u8 rxMask;
313203c4805SLuis R. Rodriguez 	u8 txMask;
314203c4805SLuis R. Rodriguez 	u16 rfSilent;
315203c4805SLuis R. Rodriguez 	u16 blueToothOptions;
316203c4805SLuis R. Rodriguez 	u16 deviceCap;
317203c4805SLuis R. Rodriguez 	u32 binBuildNumber;
318203c4805SLuis R. Rodriguez 	u8 deviceType;
319203c4805SLuis R. Rodriguez 	u8 txGainType;
320203c4805SLuis R. Rodriguez } __packed;
321203c4805SLuis R. Rodriguez 
322203c4805SLuis R. Rodriguez 
323203c4805SLuis R. Rodriguez struct spur_chan {
324203c4805SLuis R. Rodriguez 	u16 spurChan;
325203c4805SLuis R. Rodriguez 	u8 spurRangeLow;
326203c4805SLuis R. Rodriguez 	u8 spurRangeHigh;
327203c4805SLuis R. Rodriguez } __packed;
328203c4805SLuis R. Rodriguez 
329203c4805SLuis R. Rodriguez struct modal_eep_header {
330203c4805SLuis R. Rodriguez 	u32 antCtrlChain[AR5416_MAX_CHAINS];
331203c4805SLuis R. Rodriguez 	u32 antCtrlCommon;
332203c4805SLuis R. Rodriguez 	u8 antennaGainCh[AR5416_MAX_CHAINS];
333203c4805SLuis R. Rodriguez 	u8 switchSettling;
334203c4805SLuis R. Rodriguez 	u8 txRxAttenCh[AR5416_MAX_CHAINS];
335203c4805SLuis R. Rodriguez 	u8 rxTxMarginCh[AR5416_MAX_CHAINS];
336203c4805SLuis R. Rodriguez 	u8 adcDesiredSize;
337203c4805SLuis R. Rodriguez 	u8 pgaDesiredSize;
338203c4805SLuis R. Rodriguez 	u8 xlnaGainCh[AR5416_MAX_CHAINS];
339203c4805SLuis R. Rodriguez 	u8 txEndToXpaOff;
340203c4805SLuis R. Rodriguez 	u8 txEndToRxOn;
341203c4805SLuis R. Rodriguez 	u8 txFrameToXpaOn;
342203c4805SLuis R. Rodriguez 	u8 thresh62;
343203c4805SLuis R. Rodriguez 	u8 noiseFloorThreshCh[AR5416_MAX_CHAINS];
344203c4805SLuis R. Rodriguez 	u8 xpdGain;
345203c4805SLuis R. Rodriguez 	u8 xpd;
346203c4805SLuis R. Rodriguez 	u8 iqCalICh[AR5416_MAX_CHAINS];
347203c4805SLuis R. Rodriguez 	u8 iqCalQCh[AR5416_MAX_CHAINS];
348203c4805SLuis R. Rodriguez 	u8 pdGainOverlap;
349203c4805SLuis R. Rodriguez 	u8 ob;
350203c4805SLuis R. Rodriguez 	u8 db;
351203c4805SLuis R. Rodriguez 	u8 xpaBiasLvl;
352203c4805SLuis R. Rodriguez 	u8 pwrDecreaseFor2Chain;
353203c4805SLuis R. Rodriguez 	u8 pwrDecreaseFor3Chain;
354203c4805SLuis R. Rodriguez 	u8 txFrameToDataStart;
355203c4805SLuis R. Rodriguez 	u8 txFrameToPaOn;
356203c4805SLuis R. Rodriguez 	u8 ht40PowerIncForPdadc;
357203c4805SLuis R. Rodriguez 	u8 bswAtten[AR5416_MAX_CHAINS];
358203c4805SLuis R. Rodriguez 	u8 bswMargin[AR5416_MAX_CHAINS];
359203c4805SLuis R. Rodriguez 	u8 swSettleHt40;
360203c4805SLuis R. Rodriguez 	u8 xatten2Db[AR5416_MAX_CHAINS];
361203c4805SLuis R. Rodriguez 	u8 xatten2Margin[AR5416_MAX_CHAINS];
362203c4805SLuis R. Rodriguez 	u8 ob_ch1;
363203c4805SLuis R. Rodriguez 	u8 db_ch1;
364f67e07ebSFelix Fietkau 	u8 lna_ctl;
365203c4805SLuis R. Rodriguez 	u8 miscBits;
366203c4805SLuis R. Rodriguez 	u16 xpaBiasLvlFreq[3];
367203c4805SLuis R. Rodriguez 	u8 futureModal[6];
368203c4805SLuis R. Rodriguez 
3694ddfcd7dSFelix Fietkau 	struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS];
370203c4805SLuis R. Rodriguez } __packed;
371203c4805SLuis R. Rodriguez 
372203c4805SLuis R. Rodriguez struct calDataPerFreqOpLoop {
373203c4805SLuis R. Rodriguez 	u8 pwrPdg[2][5];
374203c4805SLuis R. Rodriguez 	u8 vpdPdg[2][5];
375203c4805SLuis R. Rodriguez 	u8 pcdac[2][5];
376203c4805SLuis R. Rodriguez 	u8 empty[2][5];
377203c4805SLuis R. Rodriguez } __packed;
378203c4805SLuis R. Rodriguez 
379203c4805SLuis R. Rodriguez struct modal_eep_4k_header {
380203c4805SLuis R. Rodriguez 	u32 antCtrlChain[AR5416_EEP4K_MAX_CHAINS];
381203c4805SLuis R. Rodriguez 	u32 antCtrlCommon;
382203c4805SLuis R. Rodriguez 	u8 antennaGainCh[AR5416_EEP4K_MAX_CHAINS];
383203c4805SLuis R. Rodriguez 	u8 switchSettling;
384203c4805SLuis R. Rodriguez 	u8 txRxAttenCh[AR5416_EEP4K_MAX_CHAINS];
385203c4805SLuis R. Rodriguez 	u8 rxTxMarginCh[AR5416_EEP4K_MAX_CHAINS];
386203c4805SLuis R. Rodriguez 	u8 adcDesiredSize;
387203c4805SLuis R. Rodriguez 	u8 pgaDesiredSize;
388203c4805SLuis R. Rodriguez 	u8 xlnaGainCh[AR5416_EEP4K_MAX_CHAINS];
389203c4805SLuis R. Rodriguez 	u8 txEndToXpaOff;
390203c4805SLuis R. Rodriguez 	u8 txEndToRxOn;
391203c4805SLuis R. Rodriguez 	u8 txFrameToXpaOn;
392203c4805SLuis R. Rodriguez 	u8 thresh62;
393203c4805SLuis R. Rodriguez 	u8 noiseFloorThreshCh[AR5416_EEP4K_MAX_CHAINS];
394203c4805SLuis R. Rodriguez 	u8 xpdGain;
395203c4805SLuis R. Rodriguez 	u8 xpd;
396203c4805SLuis R. Rodriguez 	u8 iqCalICh[AR5416_EEP4K_MAX_CHAINS];
397203c4805SLuis R. Rodriguez 	u8 iqCalQCh[AR5416_EEP4K_MAX_CHAINS];
398203c4805SLuis R. Rodriguez 	u8 pdGainOverlap;
3997f63845fSSujith #ifdef __BIG_ENDIAN_BITFIELD
4007f63845fSSujith 	u8 ob_1:4, ob_0:4;
4017f63845fSSujith 	u8 db1_1:4, db1_0:4;
4027f63845fSSujith #else
4037f63845fSSujith 	u8 ob_0:4, ob_1:4;
4047f63845fSSujith 	u8 db1_0:4, db1_1:4;
4057f63845fSSujith #endif
406203c4805SLuis R. Rodriguez 	u8 xpaBiasLvl;
407203c4805SLuis R. Rodriguez 	u8 txFrameToDataStart;
408203c4805SLuis R. Rodriguez 	u8 txFrameToPaOn;
409203c4805SLuis R. Rodriguez 	u8 ht40PowerIncForPdadc;
410203c4805SLuis R. Rodriguez 	u8 bswAtten[AR5416_EEP4K_MAX_CHAINS];
411203c4805SLuis R. Rodriguez 	u8 bswMargin[AR5416_EEP4K_MAX_CHAINS];
412203c4805SLuis R. Rodriguez 	u8 swSettleHt40;
413203c4805SLuis R. Rodriguez 	u8 xatten2Db[AR5416_EEP4K_MAX_CHAINS];
414203c4805SLuis R. Rodriguez 	u8 xatten2Margin[AR5416_EEP4K_MAX_CHAINS];
4157f63845fSSujith #ifdef __BIG_ENDIAN_BITFIELD
4167f63845fSSujith 	u8 db2_1:4, db2_0:4;
4177f63845fSSujith #else
4187f63845fSSujith 	u8 db2_0:4, db2_1:4;
4197f63845fSSujith #endif
420203c4805SLuis R. Rodriguez 	u8 version;
4217f63845fSSujith #ifdef __BIG_ENDIAN_BITFIELD
4227f63845fSSujith 	u8 ob_3:4, ob_2:4;
4237f63845fSSujith 	u8 antdiv_ctl1:4, ob_4:4;
4247f63845fSSujith 	u8 db1_3:4, db1_2:4;
4257f63845fSSujith 	u8 antdiv_ctl2:4, db1_4:4;
4267f63845fSSujith 	u8 db2_2:4, db2_3:4;
4277f63845fSSujith 	u8 reserved:4, db2_4:4;
4287f63845fSSujith #else
4297f63845fSSujith 	u8 ob_2:4, ob_3:4;
4307f63845fSSujith 	u8 ob_4:4, antdiv_ctl1:4;
4317f63845fSSujith 	u8 db1_2:4, db1_3:4;
4327f63845fSSujith 	u8 db1_4:4, antdiv_ctl2:4;
4337f63845fSSujith 	u8 db2_2:4, db2_3:4;
4347f63845fSSujith 	u8 db2_4:4, reserved:4;
4357f63845fSSujith #endif
436d88525e8SRajkumar Manoharan 	u8 tx_diversity;
437d88525e8SRajkumar Manoharan 	u8 flc_pwr_thresh;
438d88525e8SRajkumar Manoharan 	u8 bb_scale_smrt_antenna;
439d88525e8SRajkumar Manoharan #define EEP_4K_BB_DESIRED_SCALE_MASK	0x1f
440d88525e8SRajkumar Manoharan 	u8 futureModal[1];
4414ddfcd7dSFelix Fietkau 	struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS];
442203c4805SLuis R. Rodriguez } __packed;
443203c4805SLuis R. Rodriguez 
444ac88b6ecSVivek Natarajan struct base_eep_ar9287_header {
445ac88b6ecSVivek Natarajan 	u16 length;
446ac88b6ecSVivek Natarajan 	u16 checksum;
447ac88b6ecSVivek Natarajan 	u16 version;
448ac88b6ecSVivek Natarajan 	u8 opCapFlags;
449ac88b6ecSVivek Natarajan 	u8 eepMisc;
450ac88b6ecSVivek Natarajan 	u16 regDmn[2];
451ac88b6ecSVivek Natarajan 	u8 macAddr[6];
452ac88b6ecSVivek Natarajan 	u8 rxMask;
453ac88b6ecSVivek Natarajan 	u8 txMask;
454ac88b6ecSVivek Natarajan 	u16 rfSilent;
455ac88b6ecSVivek Natarajan 	u16 blueToothOptions;
456ac88b6ecSVivek Natarajan 	u16 deviceCap;
457ac88b6ecSVivek Natarajan 	u32 binBuildNumber;
458ac88b6ecSVivek Natarajan 	u8 deviceType;
459ac88b6ecSVivek Natarajan 	u8 openLoopPwrCntl;
460ac88b6ecSVivek Natarajan 	int8_t pwrTableOffset;
461ac88b6ecSVivek Natarajan 	int8_t tempSensSlope;
462ac88b6ecSVivek Natarajan 	int8_t tempSensSlopePalOn;
463ac88b6ecSVivek Natarajan 	u8 futureBase[29];
464ac88b6ecSVivek Natarajan } __packed;
465ac88b6ecSVivek Natarajan 
466ac88b6ecSVivek Natarajan struct modal_eep_ar9287_header {
467ac88b6ecSVivek Natarajan 	u32 antCtrlChain[AR9287_MAX_CHAINS];
468ac88b6ecSVivek Natarajan 	u32 antCtrlCommon;
469ac88b6ecSVivek Natarajan 	int8_t antennaGainCh[AR9287_MAX_CHAINS];
470ac88b6ecSVivek Natarajan 	u8 switchSettling;
471ac88b6ecSVivek Natarajan 	u8 txRxAttenCh[AR9287_MAX_CHAINS];
472ac88b6ecSVivek Natarajan 	u8 rxTxMarginCh[AR9287_MAX_CHAINS];
473ac88b6ecSVivek Natarajan 	int8_t adcDesiredSize;
474ac88b6ecSVivek Natarajan 	u8 txEndToXpaOff;
475ac88b6ecSVivek Natarajan 	u8 txEndToRxOn;
476ac88b6ecSVivek Natarajan 	u8 txFrameToXpaOn;
477ac88b6ecSVivek Natarajan 	u8 thresh62;
478ac88b6ecSVivek Natarajan 	int8_t noiseFloorThreshCh[AR9287_MAX_CHAINS];
479ac88b6ecSVivek Natarajan 	u8 xpdGain;
480ac88b6ecSVivek Natarajan 	u8 xpd;
481ac88b6ecSVivek Natarajan 	int8_t iqCalICh[AR9287_MAX_CHAINS];
482ac88b6ecSVivek Natarajan 	int8_t iqCalQCh[AR9287_MAX_CHAINS];
483ac88b6ecSVivek Natarajan 	u8 pdGainOverlap;
484ac88b6ecSVivek Natarajan 	u8 xpaBiasLvl;
485ac88b6ecSVivek Natarajan 	u8 txFrameToDataStart;
486ac88b6ecSVivek Natarajan 	u8 txFrameToPaOn;
487ac88b6ecSVivek Natarajan 	u8 ht40PowerIncForPdadc;
488ac88b6ecSVivek Natarajan 	u8 bswAtten[AR9287_MAX_CHAINS];
489ac88b6ecSVivek Natarajan 	u8 bswMargin[AR9287_MAX_CHAINS];
490ac88b6ecSVivek Natarajan 	u8 swSettleHt40;
491ac88b6ecSVivek Natarajan 	u8 version;
492ac88b6ecSVivek Natarajan 	u8 db1;
493ac88b6ecSVivek Natarajan 	u8 db2;
494ac88b6ecSVivek Natarajan 	u8 ob_cck;
495ac88b6ecSVivek Natarajan 	u8 ob_psk;
496ac88b6ecSVivek Natarajan 	u8 ob_qam;
497ac88b6ecSVivek Natarajan 	u8 ob_pal_off;
498ac88b6ecSVivek Natarajan 	u8 futureModal[30];
4994ddfcd7dSFelix Fietkau 	struct spur_chan spurChans[AR_EEPROM_MODAL_SPURS];
500ac88b6ecSVivek Natarajan } __packed;
501ac88b6ecSVivek Natarajan 
502203c4805SLuis R. Rodriguez struct cal_data_per_freq {
503203c4805SLuis R. Rodriguez 	u8 pwrPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
504203c4805SLuis R. Rodriguez 	u8 vpdPdg[AR5416_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
505203c4805SLuis R. Rodriguez } __packed;
506203c4805SLuis R. Rodriguez 
507203c4805SLuis R. Rodriguez struct cal_data_per_freq_4k {
5084ddfcd7dSFelix Fietkau 	u8 pwrPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
5094ddfcd7dSFelix Fietkau 	u8 vpdPdg[AR5416_EEP4K_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS];
510203c4805SLuis R. Rodriguez } __packed;
511203c4805SLuis R. Rodriguez 
512203c4805SLuis R. Rodriguez struct cal_target_power_leg {
513203c4805SLuis R. Rodriguez 	u8 bChannel;
514203c4805SLuis R. Rodriguez 	u8 tPow2x[4];
515203c4805SLuis R. Rodriguez } __packed;
516203c4805SLuis R. Rodriguez 
517203c4805SLuis R. Rodriguez struct cal_target_power_ht {
518203c4805SLuis R. Rodriguez 	u8 bChannel;
519203c4805SLuis R. Rodriguez 	u8 tPow2x[8];
520203c4805SLuis R. Rodriguez } __packed;
521203c4805SLuis R. Rodriguez 
522203c4805SLuis R. Rodriguez struct cal_ctl_edges {
523203c4805SLuis R. Rodriguez 	u8 bChannel;
524e702ba18SFelix Fietkau 	u8 ctl;
525203c4805SLuis R. Rodriguez } __packed;
526203c4805SLuis R. Rodriguez 
527ac88b6ecSVivek Natarajan struct cal_data_op_loop_ar9287 {
528ac88b6ecSVivek Natarajan 	u8 pwrPdg[2][5];
529ac88b6ecSVivek Natarajan 	u8 vpdPdg[2][5];
530ac88b6ecSVivek Natarajan 	u8 pcdac[2][5];
531ac88b6ecSVivek Natarajan 	u8 empty[2][5];
532ac88b6ecSVivek Natarajan } __packed;
533ac88b6ecSVivek Natarajan 
534ac88b6ecSVivek Natarajan struct cal_data_per_freq_ar9287 {
5354ddfcd7dSFelix Fietkau 	u8 pwrPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
5364ddfcd7dSFelix Fietkau 	u8 vpdPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
537ac88b6ecSVivek Natarajan } __packed;
538ac88b6ecSVivek Natarajan 
539ac88b6ecSVivek Natarajan union cal_data_per_freq_ar9287_u {
540ac88b6ecSVivek Natarajan 	struct cal_data_op_loop_ar9287 calDataOpen;
541ac88b6ecSVivek Natarajan 	struct cal_data_per_freq_ar9287 calDataClose;
542ac88b6ecSVivek Natarajan } __packed;
543ac88b6ecSVivek Natarajan 
544ac88b6ecSVivek Natarajan struct cal_ctl_data_ar9287 {
545ac88b6ecSVivek Natarajan 	struct cal_ctl_edges
546ac88b6ecSVivek Natarajan 	ctlEdges[AR9287_MAX_CHAINS][AR9287_NUM_BAND_EDGES];
547ac88b6ecSVivek Natarajan } __packed;
548ac88b6ecSVivek Natarajan 
549203c4805SLuis R. Rodriguez struct cal_ctl_data {
550203c4805SLuis R. Rodriguez 	struct cal_ctl_edges
551203c4805SLuis R. Rodriguez 	ctlEdges[AR5416_MAX_CHAINS][AR5416_NUM_BAND_EDGES];
552203c4805SLuis R. Rodriguez } __packed;
553203c4805SLuis R. Rodriguez 
554203c4805SLuis R. Rodriguez struct cal_ctl_data_4k {
555203c4805SLuis R. Rodriguez 	struct cal_ctl_edges
556203c4805SLuis R. Rodriguez 	ctlEdges[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_BAND_EDGES];
557203c4805SLuis R. Rodriguez } __packed;
558203c4805SLuis R. Rodriguez 
559203c4805SLuis R. Rodriguez struct ar5416_eeprom_def {
560203c4805SLuis R. Rodriguez 	struct base_eep_header baseEepHeader;
561203c4805SLuis R. Rodriguez 	u8 custData[64];
562203c4805SLuis R. Rodriguez 	struct modal_eep_header modalHeader[2];
563203c4805SLuis R. Rodriguez 	u8 calFreqPier5G[AR5416_NUM_5G_CAL_PIERS];
564203c4805SLuis R. Rodriguez 	u8 calFreqPier2G[AR5416_NUM_2G_CAL_PIERS];
565203c4805SLuis R. Rodriguez 	struct cal_data_per_freq
566203c4805SLuis R. Rodriguez 	 calPierData5G[AR5416_MAX_CHAINS][AR5416_NUM_5G_CAL_PIERS];
567203c4805SLuis R. Rodriguez 	struct cal_data_per_freq
568203c4805SLuis R. Rodriguez 	 calPierData2G[AR5416_MAX_CHAINS][AR5416_NUM_2G_CAL_PIERS];
569203c4805SLuis R. Rodriguez 	struct cal_target_power_leg
570203c4805SLuis R. Rodriguez 	 calTargetPower5G[AR5416_NUM_5G_20_TARGET_POWERS];
571203c4805SLuis R. Rodriguez 	struct cal_target_power_ht
572203c4805SLuis R. Rodriguez 	 calTargetPower5GHT20[AR5416_NUM_5G_20_TARGET_POWERS];
573203c4805SLuis R. Rodriguez 	struct cal_target_power_ht
574203c4805SLuis R. Rodriguez 	 calTargetPower5GHT40[AR5416_NUM_5G_40_TARGET_POWERS];
575203c4805SLuis R. Rodriguez 	struct cal_target_power_leg
576203c4805SLuis R. Rodriguez 	 calTargetPowerCck[AR5416_NUM_2G_CCK_TARGET_POWERS];
577203c4805SLuis R. Rodriguez 	struct cal_target_power_leg
578203c4805SLuis R. Rodriguez 	 calTargetPower2G[AR5416_NUM_2G_20_TARGET_POWERS];
579203c4805SLuis R. Rodriguez 	struct cal_target_power_ht
580203c4805SLuis R. Rodriguez 	 calTargetPower2GHT20[AR5416_NUM_2G_20_TARGET_POWERS];
581203c4805SLuis R. Rodriguez 	struct cal_target_power_ht
582203c4805SLuis R. Rodriguez 	 calTargetPower2GHT40[AR5416_NUM_2G_40_TARGET_POWERS];
583203c4805SLuis R. Rodriguez 	u8 ctlIndex[AR5416_NUM_CTLS];
584203c4805SLuis R. Rodriguez 	struct cal_ctl_data ctlData[AR5416_NUM_CTLS];
585203c4805SLuis R. Rodriguez 	u8 padding;
586203c4805SLuis R. Rodriguez } __packed;
587203c4805SLuis R. Rodriguez 
588203c4805SLuis R. Rodriguez struct ar5416_eeprom_4k {
589203c4805SLuis R. Rodriguez 	struct base_eep_header_4k baseEepHeader;
590203c4805SLuis R. Rodriguez 	u8 custData[20];
591203c4805SLuis R. Rodriguez 	struct modal_eep_4k_header modalHeader;
592203c4805SLuis R. Rodriguez 	u8 calFreqPier2G[AR5416_EEP4K_NUM_2G_CAL_PIERS];
593203c4805SLuis R. Rodriguez 	struct cal_data_per_freq_4k
594203c4805SLuis R. Rodriguez 	calPierData2G[AR5416_EEP4K_MAX_CHAINS][AR5416_EEP4K_NUM_2G_CAL_PIERS];
595203c4805SLuis R. Rodriguez 	struct cal_target_power_leg
596203c4805SLuis R. Rodriguez 	calTargetPowerCck[AR5416_EEP4K_NUM_2G_CCK_TARGET_POWERS];
597203c4805SLuis R. Rodriguez 	struct cal_target_power_leg
598203c4805SLuis R. Rodriguez 	calTargetPower2G[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS];
599203c4805SLuis R. Rodriguez 	struct cal_target_power_ht
600203c4805SLuis R. Rodriguez 	calTargetPower2GHT20[AR5416_EEP4K_NUM_2G_20_TARGET_POWERS];
601203c4805SLuis R. Rodriguez 	struct cal_target_power_ht
602203c4805SLuis R. Rodriguez 	calTargetPower2GHT40[AR5416_EEP4K_NUM_2G_40_TARGET_POWERS];
603203c4805SLuis R. Rodriguez 	u8 ctlIndex[AR5416_EEP4K_NUM_CTLS];
604203c4805SLuis R. Rodriguez 	struct cal_ctl_data_4k ctlData[AR5416_EEP4K_NUM_CTLS];
605203c4805SLuis R. Rodriguez 	u8 padding;
606203c4805SLuis R. Rodriguez } __packed;
607203c4805SLuis R. Rodriguez 
608475f5989SLuis R. Rodriguez struct ar9287_eeprom {
609ac88b6ecSVivek Natarajan 	struct base_eep_ar9287_header baseEepHeader;
610ac88b6ecSVivek Natarajan 	u8 custData[AR9287_DATA_SZ];
611ac88b6ecSVivek Natarajan 	struct modal_eep_ar9287_header modalHeader;
612ac88b6ecSVivek Natarajan 	u8 calFreqPier2G[AR9287_NUM_2G_CAL_PIERS];
613ac88b6ecSVivek Natarajan 	union cal_data_per_freq_ar9287_u
614ac88b6ecSVivek Natarajan 	calPierData2G[AR9287_MAX_CHAINS][AR9287_NUM_2G_CAL_PIERS];
615ac88b6ecSVivek Natarajan 	struct cal_target_power_leg
616ac88b6ecSVivek Natarajan 	calTargetPowerCck[AR9287_NUM_2G_CCK_TARGET_POWERS];
617ac88b6ecSVivek Natarajan 	struct cal_target_power_leg
618ac88b6ecSVivek Natarajan 	calTargetPower2G[AR9287_NUM_2G_20_TARGET_POWERS];
619ac88b6ecSVivek Natarajan 	struct cal_target_power_ht
620ac88b6ecSVivek Natarajan 	calTargetPower2GHT20[AR9287_NUM_2G_20_TARGET_POWERS];
621ac88b6ecSVivek Natarajan 	struct cal_target_power_ht
622ac88b6ecSVivek Natarajan 	calTargetPower2GHT40[AR9287_NUM_2G_40_TARGET_POWERS];
623ac88b6ecSVivek Natarajan 	u8 ctlIndex[AR9287_NUM_CTLS];
624ac88b6ecSVivek Natarajan 	struct cal_ctl_data_ar9287 ctlData[AR9287_NUM_CTLS];
625ac88b6ecSVivek Natarajan 	u8 padding;
626ac88b6ecSVivek Natarajan } __packed;
627ac88b6ecSVivek Natarajan 
628203c4805SLuis R. Rodriguez enum reg_ext_bitmap {
629ebb90cfcSSenthil Balasubramanian 	REG_EXT_FCC_MIDBAND = 0,
630203c4805SLuis R. Rodriguez 	REG_EXT_JAPAN_MIDBAND = 1,
631203c4805SLuis R. Rodriguez 	REG_EXT_FCC_DFS_HT40 = 2,
632203c4805SLuis R. Rodriguez 	REG_EXT_JAPAN_NONDFS_HT40 = 3,
633203c4805SLuis R. Rodriguez 	REG_EXT_JAPAN_DFS_HT40 = 4
634203c4805SLuis R. Rodriguez };
635203c4805SLuis R. Rodriguez 
636203c4805SLuis R. Rodriguez struct ath9k_country_entry {
637203c4805SLuis R. Rodriguez 	u16 countryCode;
638203c4805SLuis R. Rodriguez 	u16 regDmnEnum;
639203c4805SLuis R. Rodriguez 	u16 regDmn5G;
640203c4805SLuis R. Rodriguez 	u16 regDmn2G;
641203c4805SLuis R. Rodriguez 	u8 isMultidomain;
642203c4805SLuis R. Rodriguez 	u8 iso[3];
643203c4805SLuis R. Rodriguez };
644203c4805SLuis R. Rodriguez 
645203c4805SLuis R. Rodriguez struct eeprom_ops {
646203c4805SLuis R. Rodriguez 	int (*check_eeprom)(struct ath_hw *hw);
647203c4805SLuis R. Rodriguez 	u32 (*get_eeprom)(struct ath_hw *hw, enum eeprom_param param);
648203c4805SLuis R. Rodriguez 	bool (*fill_eeprom)(struct ath_hw *hw);
64926526202SRajkumar Manoharan 	u32 (*dump_eeprom)(struct ath_hw *hw, bool dump_base_hdr, u8 *buf,
65026526202SRajkumar Manoharan 			   u32 len, u32 size);
651203c4805SLuis R. Rodriguez 	int (*get_eeprom_ver)(struct ath_hw *hw);
652203c4805SLuis R. Rodriguez 	int (*get_eeprom_rev)(struct ath_hw *hw);
653203c4805SLuis R. Rodriguez 	void (*set_board_values)(struct ath_hw *hw, struct ath9k_channel *chan);
654203c4805SLuis R. Rodriguez 	void (*set_addac)(struct ath_hw *hw, struct ath9k_channel *chan);
6558fbff4b8SVasanthakumar Thiagarajan 	void (*set_txpower)(struct ath_hw *hw, struct ath9k_channel *chan,
656203c4805SLuis R. Rodriguez 			   u16 cfgCtl, u8 twiceAntennaReduction,
657ca2c68ccSFelix Fietkau 			   u8 powerLimit, bool test);
658203c4805SLuis R. Rodriguez 	u16 (*get_spur_channel)(struct ath_hw *ah, u16 i, bool is2GHz);
659203c4805SLuis R. Rodriguez };
660203c4805SLuis R. Rodriguez 
66179d7f4bcSSujith void ath9k_hw_analog_shift_regwrite(struct ath_hw *ah, u32 reg, u32 val);
662b5aec950SSujith void ath9k_hw_analog_shift_rmw(struct ath_hw *ah, u32 reg, u32 mask,
663b5aec950SSujith 			       u32 shift, u32 val);
664b5aec950SSujith int16_t ath9k_hw_interpolate(u16 target, u16 srcLeft, u16 srcRight,
665b5aec950SSujith 			     int16_t targetLeft,
666b5aec950SSujith 			     int16_t targetRight);
667b5aec950SSujith bool ath9k_hw_get_lower_upper_index(u8 target, u8 *pList, u16 listSize,
668b5aec950SSujith 				    u16 *indexL, u16 *indexR);
6695bb12791SLuis R. Rodriguez bool ath9k_hw_nvram_read(struct ath_common *common, u32 off, u16 *data);
67004cf53f4SSujith Manoharan void ath9k_hw_usb_gen_fill_eeprom(struct ath_hw *ah, u16 *eep_data,
67104cf53f4SSujith Manoharan 				  int eep_start_loc, int size);
672b5aec950SSujith void ath9k_hw_fill_vpd_table(u8 pwrMin, u8 pwrMax, u8 *pPwrList,
673b5aec950SSujith 			     u8 *pVpdList, u16 numIntercepts,
674b5aec950SSujith 			     u8 *pRetVpdList);
675b5aec950SSujith void ath9k_hw_get_legacy_target_powers(struct ath_hw *ah,
676b5aec950SSujith 				       struct ath9k_channel *chan,
677b5aec950SSujith 				       struct cal_target_power_leg *powInfo,
678b5aec950SSujith 				       u16 numChannels,
679b5aec950SSujith 				       struct cal_target_power_leg *pNewPower,
680b5aec950SSujith 				       u16 numRates, bool isExtTarget);
681b5aec950SSujith void ath9k_hw_get_target_powers(struct ath_hw *ah,
682b5aec950SSujith 				struct ath9k_channel *chan,
683b5aec950SSujith 				struct cal_target_power_ht *powInfo,
684b5aec950SSujith 				u16 numChannels,
685b5aec950SSujith 				struct cal_target_power_ht *pNewPower,
686b5aec950SSujith 				u16 numRates, bool isHt40Target);
687b5aec950SSujith u16 ath9k_hw_get_max_edge_power(u16 freq, struct cal_ctl_edges *pRdEdgesPower,
688b5aec950SSujith 				bool is2GHz, int num_band_edges);
689ea6f792bSGabor Juhos u16 ath9k_hw_get_scaled_power(struct ath_hw *ah, u16 power_limit,
690ea6f792bSGabor Juhos 			      u8 antenna_reduction);
691a55f8588SSujith void ath9k_hw_update_regulatory_maxpower(struct ath_hw *ah);
692b5aec950SSujith int ath9k_hw_eeprom_init(struct ath_hw *ah);
693b5aec950SSujith 
694115277a3SFelix Fietkau void ath9k_hw_get_gain_boundaries_pdadcs(struct ath_hw *ah,
695115277a3SFelix Fietkau 				struct ath9k_channel *chan,
696115277a3SFelix Fietkau 				void *pRawDataSet,
697115277a3SFelix Fietkau 				u8 *bChans, u16 availPiers,
698115277a3SFelix Fietkau 				u16 tPdGainOverlap,
699115277a3SFelix Fietkau 				u16 *pPdGainBoundaries, u8 *pPDADCValues,
700115277a3SFelix Fietkau 				u16 numXpdGains);
701115277a3SFelix Fietkau 
702*23bd7cedSGabor Juhos static inline u16 ath9k_hw_fbin2freq(u8 fbin, bool is2GHz)
703*23bd7cedSGabor Juhos {
704*23bd7cedSGabor Juhos 	if (fbin == AR5416_BCHAN_UNUSED)
705*23bd7cedSGabor Juhos 		return fbin;
706*23bd7cedSGabor Juhos 
707*23bd7cedSGabor Juhos 	return (u16) ((is2GHz) ? (2300 + fbin) : (4800 + 5 * fbin));
708*23bd7cedSGabor Juhos }
709*23bd7cedSGabor Juhos 
710203c4805SLuis R. Rodriguez #define ar5416_get_ntxchains(_txchainmask)			\
711203c4805SLuis R. Rodriguez 	(((_txchainmask >> 2) & 1) +                            \
712203c4805SLuis R. Rodriguez 	 ((_txchainmask >> 1) & 1) + (_txchainmask & 1))
713203c4805SLuis R. Rodriguez 
714b5aec950SSujith extern const struct eeprom_ops eep_def_ops;
715b5aec950SSujith extern const struct eeprom_ops eep_4k_ops;
7160b8f6f2bSLuis R. Rodriguez extern const struct eeprom_ops eep_ar9287_ops;
71715c9ee7aSSenthil Balasubramanian extern const struct eeprom_ops eep_ar9287_ops;
71815c9ee7aSSenthil Balasubramanian extern const struct eeprom_ops eep_ar9300_ops;
719203c4805SLuis R. Rodriguez 
720203c4805SLuis R. Rodriguez #endif /* EEPROM_H */
721