blob: efb6a02be37760c8169aa6c1a416b2fd8350627d [file] [log] [blame]
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -04001#ifndef AR9003_EEPROM_H
2#define AR9003_EEPROM_H
3
4#include <linux/types.h>
5
6#define AR9300_EEP_VER 0xD000
7#define AR9300_EEP_VER_MINOR_MASK 0xFFF
8#define AR9300_EEP_MINOR_VER_1 0x1
9#define AR9300_EEP_MINOR_VER AR9300_EEP_MINOR_VER_1
10
11/* 16-bit offset location start of calibration struct */
12#define AR9300_EEP_START_LOC 256
13#define AR9300_NUM_5G_CAL_PIERS 8
14#define AR9300_NUM_2G_CAL_PIERS 3
15#define AR9300_NUM_5G_20_TARGET_POWERS 8
16#define AR9300_NUM_5G_40_TARGET_POWERS 8
17#define AR9300_NUM_2G_CCK_TARGET_POWERS 2
18#define AR9300_NUM_2G_20_TARGET_POWERS 3
19#define AR9300_NUM_2G_40_TARGET_POWERS 3
20/* #define AR9300_NUM_CTLS 21 */
21#define AR9300_NUM_CTLS_5G 9
22#define AR9300_NUM_CTLS_2G 12
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -040023#define AR9300_NUM_BAND_EDGES_5G 8
24#define AR9300_NUM_BAND_EDGES_2G 4
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -040025#define AR9300_EEPMISC_BIG_ENDIAN 0x01
26#define AR9300_EEPMISC_WOW 0x02
27#define AR9300_CUSTOMER_DATA_SIZE 20
28
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -040029#define FBIN2FREQ(x, y) ((y) ? (2300 + x) : (4800 + 5 * x))
30#define AR9300_MAX_CHAINS 3
31#define AR9300_ANT_16S 25
32#define AR9300_FUTURE_MODAL_SZ 6
33
Felix Fietkau17823522010-12-13 08:40:53 +010034#define AR9300_PAPRD_RATE_MASK 0x01ffffff
35#define AR9300_PAPRD_SCALE_1 0x0e000000
36#define AR9300_PAPRD_SCALE_1_S 25
37#define AR9300_PAPRD_SCALE_2 0x70000000
38#define AR9300_PAPRD_SCALE_2_S 28
39
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -040040/* Delta from which to start power to pdadc table */
41/* This offset is used in both open loop and closed loop power control
42 * schemes. In open loop power control, it is not really needed, but for
43 * the "sake of consistency" it was kept. For certain AP designs, this
44 * value is overwritten by the value in the flag "pwrTableOffset" just
45 * before writing the pdadc vs pwr into the chip registers.
46 */
47#define AR9300_PWR_TABLE_OFFSET 0
48
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -040049/* byte addressable */
50#define AR9300_EEPROM_SIZE (16*1024)
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -040051
Vasanthakumar Thiagarajan60e0c3a2010-12-06 04:27:39 -080052#define AR9300_BASE_ADDR_4K 0xfff
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -040053#define AR9300_BASE_ADDR 0x3ff
Felix Fietkau488f6ba2010-11-16 19:20:28 +010054#define AR9300_BASE_ADDR_512 0x1ff
55
56#define AR9300_OTP_BASE 0x14000
57#define AR9300_OTP_STATUS 0x15f18
58#define AR9300_OTP_STATUS_TYPE 0x7
59#define AR9300_OTP_STATUS_VALID 0x4
60#define AR9300_OTP_STATUS_ACCESS_BUSY 0x2
61#define AR9300_OTP_STATUS_SM_BUSY 0x1
62#define AR9300_OTP_READ_DATA 0x15f1c
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -040063
64enum targetPowerHTRates {
65 HT_TARGET_RATE_0_8_16,
66 HT_TARGET_RATE_1_3_9_11_17_19,
67 HT_TARGET_RATE_4,
68 HT_TARGET_RATE_5,
69 HT_TARGET_RATE_6,
70 HT_TARGET_RATE_7,
71 HT_TARGET_RATE_12,
72 HT_TARGET_RATE_13,
73 HT_TARGET_RATE_14,
74 HT_TARGET_RATE_15,
75 HT_TARGET_RATE_20,
76 HT_TARGET_RATE_21,
77 HT_TARGET_RATE_22,
78 HT_TARGET_RATE_23
79};
80
81enum targetPowerLegacyRates {
82 LEGACY_TARGET_RATE_6_24,
83 LEGACY_TARGET_RATE_36,
84 LEGACY_TARGET_RATE_48,
85 LEGACY_TARGET_RATE_54
86};
87
88enum targetPowerCckRates {
89 LEGACY_TARGET_RATE_1L_5L,
90 LEGACY_TARGET_RATE_5S,
91 LEGACY_TARGET_RATE_11L,
92 LEGACY_TARGET_RATE_11S
93};
94
95enum ar9300_Rates {
96 ALL_TARGET_LEGACY_6_24,
97 ALL_TARGET_LEGACY_36,
98 ALL_TARGET_LEGACY_48,
99 ALL_TARGET_LEGACY_54,
100 ALL_TARGET_LEGACY_1L_5L,
101 ALL_TARGET_LEGACY_5S,
102 ALL_TARGET_LEGACY_11L,
103 ALL_TARGET_LEGACY_11S,
104 ALL_TARGET_HT20_0_8_16,
105 ALL_TARGET_HT20_1_3_9_11_17_19,
106 ALL_TARGET_HT20_4,
107 ALL_TARGET_HT20_5,
108 ALL_TARGET_HT20_6,
109 ALL_TARGET_HT20_7,
110 ALL_TARGET_HT20_12,
111 ALL_TARGET_HT20_13,
112 ALL_TARGET_HT20_14,
113 ALL_TARGET_HT20_15,
114 ALL_TARGET_HT20_20,
115 ALL_TARGET_HT20_21,
116 ALL_TARGET_HT20_22,
117 ALL_TARGET_HT20_23,
118 ALL_TARGET_HT40_0_8_16,
119 ALL_TARGET_HT40_1_3_9_11_17_19,
120 ALL_TARGET_HT40_4,
121 ALL_TARGET_HT40_5,
122 ALL_TARGET_HT40_6,
123 ALL_TARGET_HT40_7,
124 ALL_TARGET_HT40_12,
125 ALL_TARGET_HT40_13,
126 ALL_TARGET_HT40_14,
127 ALL_TARGET_HT40_15,
128 ALL_TARGET_HT40_20,
129 ALL_TARGET_HT40_21,
130 ALL_TARGET_HT40_22,
131 ALL_TARGET_HT40_23,
132 ar9300RateSize,
133};
134
135
136struct eepFlags {
137 u8 opFlags;
138 u8 eepMisc;
139} __packed;
140
141enum CompressAlgorithm {
142 _CompressNone = 0,
143 _CompressLzma,
144 _CompressPairs,
145 _CompressBlock,
146 _Compress4,
147 _Compress5,
148 _Compress6,
149 _Compress7,
150};
151
152struct ar9300_base_eep_hdr {
Felix Fietkauffdc4cb2010-05-11 17:23:03 +0200153 __le16 regDmn[2];
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400154 /* 4 bits tx and 4 bits rx */
155 u8 txrxMask;
156 struct eepFlags opCapFlags;
157 u8 rfSilent;
158 u8 blueToothOptions;
159 u8 deviceCap;
160 /* takes lower byte in eeprom location */
161 u8 deviceType;
162 /* offset in dB to be added to beginning
163 * of pdadc table in calibration
164 */
165 int8_t pwrTableOffset;
166 u8 params_for_tuning_caps[2];
167 /*
168 * bit0 - enable tx temp comp
169 * bit1 - enable tx volt comp
170 * bit2 - enable fastClock - default to 1
171 * bit3 - enable doubling - default to 1
172 * bit4 - enable internal regulator - default to 1
173 */
174 u8 featureEnable;
175 /* misc flags: bit0 - turn down drivestrength */
176 u8 miscConfiguration;
177 u8 eepromWriteEnableGpio;
178 u8 wlanDisableGpio;
179 u8 wlanLedGpio;
180 u8 rxBandSelectGpio;
181 u8 txrxgain;
182 /* SW controlled internal regulator fields */
Felix Fietkauffdc4cb2010-05-11 17:23:03 +0200183 __le32 swreg;
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400184} __packed;
185
186struct ar9300_modal_eep_header {
187 /* 4 idle, t1, t2, b (4 bits per setting) */
Felix Fietkauffdc4cb2010-05-11 17:23:03 +0200188 __le32 antCtrlCommon;
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400189 /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */
Felix Fietkauffdc4cb2010-05-11 17:23:03 +0200190 __le32 antCtrlCommon2;
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400191 /* 6 idle, t, r, rx1, rx12, b (2 bits each) */
Felix Fietkauffdc4cb2010-05-11 17:23:03 +0200192 __le16 antCtrlChain[AR9300_MAX_CHAINS];
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400193 /* 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */
194 u8 xatten1DB[AR9300_MAX_CHAINS];
195 /* 3 xatten1_margin for merlin (0xa20c/b20c 16:12 */
196 u8 xatten1Margin[AR9300_MAX_CHAINS];
197 int8_t tempSlope;
198 int8_t voltSlope;
199 /* spur channels in usual fbin coding format */
Felix Fietkau4ddfcd72010-12-12 00:51:08 +0100200 u8 spurChans[AR_EEPROM_MODAL_SPURS];
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400201 /* 3 Check if the register is per chain */
202 int8_t noiseFloorThreshCh[AR9300_MAX_CHAINS];
203 u8 ob[AR9300_MAX_CHAINS];
204 u8 db_stage2[AR9300_MAX_CHAINS];
205 u8 db_stage3[AR9300_MAX_CHAINS];
206 u8 db_stage4[AR9300_MAX_CHAINS];
207 u8 xpaBiasLvl;
208 u8 txFrameToDataStart;
209 u8 txFrameToPaOn;
210 u8 txClip;
211 int8_t antennaGain;
212 u8 switchSettling;
213 int8_t adcDesiredSize;
214 u8 txEndToXpaOff;
215 u8 txEndToRxOn;
216 u8 txFrameToXpaOn;
217 u8 thresh62;
Felix Fietkau49352502010-06-12 00:33:59 -0400218 __le32 papdRateMaskHt20;
219 __le32 papdRateMaskHt40;
Senthil Balasubramanianb3dd6bc2010-11-10 05:03:07 -0800220 u8 futureModal[10];
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400221} __packed;
222
223struct ar9300_cal_data_per_freq_op_loop {
224 int8_t refPower;
225 /* pdadc voltage at power measurement */
226 u8 voltMeas;
227 /* pcdac used for power measurement */
228 u8 tempMeas;
229 /* range is -60 to -127 create a mapping equation 1db resolution */
230 int8_t rxNoisefloorCal;
231 /*range is same as noisefloor */
232 int8_t rxNoisefloorPower;
233 /* temp measured when noisefloor cal was performed */
234 u8 rxTempMeas;
235} __packed;
236
237struct cal_tgt_pow_legacy {
238 u8 tPow2x[4];
239} __packed;
240
241struct cal_tgt_pow_ht {
242 u8 tPow2x[14];
243} __packed;
244
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400245struct cal_ctl_data_2g {
Felix Fietkaue702ba12010-12-01 19:07:46 +0100246 u8 ctlEdges[AR9300_NUM_BAND_EDGES_2G];
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400247} __packed;
248
249struct cal_ctl_data_5g {
Felix Fietkaue702ba12010-12-01 19:07:46 +0100250 u8 ctlEdges[AR9300_NUM_BAND_EDGES_5G];
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400251} __packed;
252
Senthil Balasubramanianb3dd6bc2010-11-10 05:03:07 -0800253struct ar9300_BaseExtension_1 {
254 u8 ant_div_control;
255 u8 future[13];
256} __packed;
257
258struct ar9300_BaseExtension_2 {
259 int8_t tempSlopeLow;
260 int8_t tempSlopeHigh;
261 u8 xatten1DBLow[AR9300_MAX_CHAINS];
262 u8 xatten1MarginLow[AR9300_MAX_CHAINS];
263 u8 xatten1DBHigh[AR9300_MAX_CHAINS];
264 u8 xatten1MarginHigh[AR9300_MAX_CHAINS];
265} __packed;
266
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400267struct ar9300_eeprom {
268 u8 eepromVersion;
269 u8 templateVersion;
270 u8 macAddr[6];
271 u8 custData[AR9300_CUSTOMER_DATA_SIZE];
272
273 struct ar9300_base_eep_hdr baseEepHeader;
274
275 struct ar9300_modal_eep_header modalHeader2G;
Senthil Balasubramanianb3dd6bc2010-11-10 05:03:07 -0800276 struct ar9300_BaseExtension_1 base_ext1;
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400277 u8 calFreqPier2G[AR9300_NUM_2G_CAL_PIERS];
278 struct ar9300_cal_data_per_freq_op_loop
279 calPierData2G[AR9300_MAX_CHAINS][AR9300_NUM_2G_CAL_PIERS];
280 u8 calTarget_freqbin_Cck[AR9300_NUM_2G_CCK_TARGET_POWERS];
281 u8 calTarget_freqbin_2G[AR9300_NUM_2G_20_TARGET_POWERS];
282 u8 calTarget_freqbin_2GHT20[AR9300_NUM_2G_20_TARGET_POWERS];
283 u8 calTarget_freqbin_2GHT40[AR9300_NUM_2G_40_TARGET_POWERS];
284 struct cal_tgt_pow_legacy
285 calTargetPowerCck[AR9300_NUM_2G_CCK_TARGET_POWERS];
286 struct cal_tgt_pow_legacy
287 calTargetPower2G[AR9300_NUM_2G_20_TARGET_POWERS];
288 struct cal_tgt_pow_ht
289 calTargetPower2GHT20[AR9300_NUM_2G_20_TARGET_POWERS];
290 struct cal_tgt_pow_ht
291 calTargetPower2GHT40[AR9300_NUM_2G_40_TARGET_POWERS];
292 u8 ctlIndex_2G[AR9300_NUM_CTLS_2G];
293 u8 ctl_freqbin_2G[AR9300_NUM_CTLS_2G][AR9300_NUM_BAND_EDGES_2G];
294 struct cal_ctl_data_2g ctlPowerData_2G[AR9300_NUM_CTLS_2G];
295 struct ar9300_modal_eep_header modalHeader5G;
Senthil Balasubramanianb3dd6bc2010-11-10 05:03:07 -0800296 struct ar9300_BaseExtension_2 base_ext2;
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400297 u8 calFreqPier5G[AR9300_NUM_5G_CAL_PIERS];
298 struct ar9300_cal_data_per_freq_op_loop
299 calPierData5G[AR9300_MAX_CHAINS][AR9300_NUM_5G_CAL_PIERS];
300 u8 calTarget_freqbin_5G[AR9300_NUM_5G_20_TARGET_POWERS];
301 u8 calTarget_freqbin_5GHT20[AR9300_NUM_5G_20_TARGET_POWERS];
302 u8 calTarget_freqbin_5GHT40[AR9300_NUM_5G_40_TARGET_POWERS];
303 struct cal_tgt_pow_legacy
304 calTargetPower5G[AR9300_NUM_5G_20_TARGET_POWERS];
305 struct cal_tgt_pow_ht
306 calTargetPower5GHT20[AR9300_NUM_5G_20_TARGET_POWERS];
307 struct cal_tgt_pow_ht
308 calTargetPower5GHT40[AR9300_NUM_5G_40_TARGET_POWERS];
309 u8 ctlIndex_5G[AR9300_NUM_CTLS_5G];
310 u8 ctl_freqbin_5G[AR9300_NUM_CTLS_5G][AR9300_NUM_BAND_EDGES_5G];
311 struct cal_ctl_data_5g ctlPowerData_5G[AR9300_NUM_CTLS_5G];
312} __packed;
Luis R. Rodriguezc14a85d2010-04-15 17:39:21 -0400313
314s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah);
315s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah);
316
Vasanthakumar Thiagarajan272ceba2010-12-06 04:27:46 -0800317u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is_2ghz);
Senthil Balasubramanian15c9ee72010-04-15 17:39:14 -0400318#endif