blob: 4cb83926dd46faca0e28e2fc0edb136fa732ac09 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
42#ifndef WLAN_PHY_H
43#define WLAN_PHY_H
44/*============================================================================
45@file wlan_phy.h
46
47Contains definitions of all PHY related structures that aree needed by FTM/PTT
48
49Copyright (c) 2007 QUALCOMM Incorporated.
50All Rights Reserved.
51Qualcomm Confidential and Proprietary
52============================================================================*/
53#include <wlan_nv.h>
54
55/* Currently this structure holds the information about the current calibration mode.
56In future, if anymore info is needed, that can be added here */
57typedef PACKED_PRE struct PACKED_POST
58{
59 tANI_U8 currentCalibration;
60} sCalibrationInfo;
61
62typedef PACKED_PRE struct PACKED_POST {
63 tANI_S16 I; //ADC sample of PHY_I_RAIL
64 tANI_S16 Q; //ADC sample of PHY_Q_RAIL
65}tIQSamples;
66
67typedef tIQSamples tIQAdc;
68typedef tIQSamples tIQDac;
69
70typedef PACKED_PRE struct PACKED_POST
71{
72 tANI_U8 maxGainIndex;
73 tANI_U8 topGainDb;
74 tANI_U8 bottomGainDb;
75 tANI_U8 unused[1];
76}tAsicAgc;
77
78#define TXFIR_MEM QWLAN_TXFIR_TXCAL_MEM0_MREG
79#define TXFIR_MEM_GAIN_MULT (16) //bytes per gain
80#define TXFIR_MEM_PER_CHAIN (16 * TXFIR_MEM_GAIN_MULT) //# of gains per chain * bytes per gain
81
82typedef tIQAdc tTxCarrierError;
83
84#define ONE_MICROSECOND (160)
85#define DEFAULT_INTERFRAME_SPACE (ONE_MICROSECOND * 10) //10 microseconds
86
87typedef enum {
88 PHYDBG_TX_IDLE = 0,
89 PHYDBG_TX_START = 1,
90 PHYDBG_TX_WARMUP = 2,
91 PHYDBG_TX_INFD = 3,
92 PHYDBG_TX_CMD = 4,
93 PHYDBG_TX_SVC = 5,
94 PHYDBG_TX_PYLDF = 6,
95 PHYDBG_TX_PYLDR = 7,
96 PHYDBG_TX_CRC = 8,
97 PHYDBG_TX_FLUSH = 9,
98 PHYDBG_TX_TXDONEWAIT = 10,
99 PHYDBG_TX_TIFWAIT = 11
100} ePhyDbgTxStatus;
101
102typedef enum {
103 PHYDBG_PREAMBLE_OFDM,
104 PHYDBG_PREAMBLE_GREENFIELD,
105 PHYDBG_PREAMBLE_MIXED,
106 PHYDBG_PREAMBLE_SHORTB,
107 PHYDBG_PREAMBLE_LONGB
108} ePhyDbgPreamble;
109
110
111//grab ram
112#ifdef VERIFY_HALPHY_SIMV_MODEL
113#define GRAB_RAM_DBLOCK_SIZE (256) //number of samples in full capture
114#else
115#define GRAB_RAM_DBLOCK_SIZE (1024) //number of samples in full capture
116#endif
117
118#define MAX_REQUESTED_GRAB_RAM_SAMPLES 256 //only allow 256 samples at a time
119#define GRAB_RAM_BUFFER_DEPTH (4*1024) //maximum grab ram size in full capture
120#define LAST_GRAB_RAM_SAMPLE_INDEX (GRAB_RAM_BUFFER_DEPTH - 1)
121
122
123typedef PACKED_PRE struct PACKED_POST {
124 tIQAdc rx0;
125} tGrabRamSample;
126
127
128enum {
129 GRABRAM_RAWADC = 0,
130 GRABRAM_POSTIQ
131};
132typedef tANI_U32 eGrabRamSampleType;
133
134typedef tANI_S8 tANI_S6;
135typedef tANI_S16 tANI_S9;
136typedef tANI_S16 tANI_S10;
137typedef tANI_S16 tANI_S12;
138typedef tANI_U16 tANI_U10;
139
140
141
142//convert float to a format that preserves enough accuracy to be used by driver
143typedef tANI_S16 t2Decimal;
144#define CONVERT_TO_2DECIMAL_PLACES(x) (x * 100)
145#define CONVERT_FROM_2DECIMAL_PLACES(x) (x / 100)
146
147#ifndef PTT_FLOAT
148#define PTT_FLOAT tANI_U32 // driver code can't include float,
149//so this reserves space in our structures to allow floating point measurements
150#endif
151
152typedef enum
153{
154 PHY_RX_CHAIN_0 = 0,
155
156 PHY_MAX_RX_CHAINS = 1,
157 PHY_ALL_RX_CHAINS,
158 PHY_NO_RX_CHAINS
159}ePhyRxChains;
160
161typedef enum
162{
163 PHY_I_RAIL = 0,
164 PHY_Q_RAIL = 1,
165 PHY_NUM_IQ_RAILS
166}ePhyIQ;
167
168//[RY] extend total gain steps to 24
169
170enum
171{
172 TX_GAIN_STEP_0,
173 TX_GAIN_STEP_1,
174 TX_GAIN_STEP_2,
175 TX_GAIN_STEP_3,
176 TX_GAIN_STEP_4,
177 TX_GAIN_STEP_5,
178 TX_GAIN_STEP_6,
179 TX_GAIN_STEP_7,
180 TX_GAIN_STEP_8,
181 TX_GAIN_STEP_9,
182 TX_GAIN_STEP_10,
183 TX_GAIN_STEP_11,
184 TX_GAIN_STEP_12,
185 TX_GAIN_STEP_13,
186 TX_GAIN_STEP_14,
187 TX_GAIN_STEP_15,
188 TX_GAIN_STEP_16,
189 TX_GAIN_STEP_17,
190 TX_GAIN_STEP_18,
191 TX_GAIN_STEP_19,
192 TX_GAIN_STEP_20,
193 TX_GAIN_STEP_21,
194 TX_GAIN_STEP_22,
195 TX_GAIN_STEP_23,
196 TX_GAIN_STEP_24,
197 TX_GAIN_STEP_25,
198 TX_GAIN_STEP_26,
199 TX_GAIN_STEP_27,
200 TX_GAIN_STEP_28,
201 TX_GAIN_STEP_29,
202 TX_GAIN_STEP_30,
203 TX_GAIN_STEP_31,
204
205 RX_GAIN_STEP_0 = 0,
206 RX_GAIN_STEP_1,
207 RX_GAIN_STEP_2,
208 RX_GAIN_STEP_3,
209 RX_GAIN_STEP_4,
210 RX_GAIN_STEP_5,
211 RX_GAIN_STEP_6,
212 RX_GAIN_STEP_7,
213 RX_GAIN_STEP_8,
214 RX_GAIN_STEP_9,
215 RX_GAIN_STEP_10,
216 RX_GAIN_STEP_11,
217 RX_GAIN_STEP_12,
218 RX_GAIN_STEP_13,
219 RX_GAIN_STEP_14,
220 RX_GAIN_STEP_15,
221
222 NUM_TX_GAIN_STEPS = 32,
223 MAX_TX_GAIN_STEP = TX_GAIN_STEP_31,
224
225 NUM_RX_GAIN_STEPS = 16,
226 MAX_RX_GAIN_STEP = RX_GAIN_STEP_15,
227};
228typedef tANI_U32 eGainSteps;
229
230
231//[RY] new for PRIMA
232#define DPD_RESPONSE_SIZE 128
233typedef PACKED_PRE struct PACKED_POST {
Sanoop K05588fc2012-12-12 13:51:22 -0800234 tANI_U8 dpdCalFailCnt; //Count for number of times DPD cal failed.
235 tANI_U8 dpdCalSuccessCnt; //Count for number of times DPD cal passed.
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 tANI_S16 dpd_threshold[DPD_RESPONSE_SIZE];
237 tANI_S16 dpd_aoffset[DPD_RESPONSE_SIZE];
238 tANI_S16 dpd_again[DPD_RESPONSE_SIZE];
239 tANI_S16 dpd_poffset[DPD_RESPONSE_SIZE];
240 tANI_S16 dpd_pgain[DPD_RESPONSE_SIZE];
241}sDPDcorrectionCalValues;
242
243typedef PACKED_PRE struct PACKED_POST {
244 sDPDcorrectionCalValues dpd[PHY_MAX_TX_CHAINS];
245}sTxChainsDPDCalValues;
246
247
248//[RY] RX IQ correction coefficients Memory
249typedef PACKED_PRE struct PACKED_POST {
250 tANI_S9 coeff_i[5];
251 tANI_S9 coeff_q[5];
252}sIQCalValues;
253
254//[RY], added for RIVA
255typedef PACKED_PRE struct PACKED_POST {
256 tANI_S9 iq_ampimb_coeff;
257 tANI_S16 txloleakage_i; // raw data is 6-bit 2's compliment
258 tANI_S16 txloleakage_q; // raw data is 6-bit 2's compliment
259}sTXIQCalValues;
260
261//[RY], added for RIVA
262typedef PACKED_PRE struct PACKED_POST {
263 tANI_S9 iqphaseimb_coeff_i[5];
264 tANI_S9 iqphaseimb_coeff_q[5];
265}sTXIQPhaseImbCalValues;
266
267typedef PACKED_PRE struct PACKED_POST {
268 sIQCalValues iq[PHY_MAX_RX_CHAINS];
269}sRxChainsIQCalValues;
270
271//[RY] change for PRIMA
272typedef PACKED_PRE struct PACKED_POST {
273 sTXIQCalValues iq[PHY_MAX_TX_CHAINS];
274 sTXIQPhaseImbCalValues iqImb[PHY_MAX_TX_CHAINS];
275}sTxChainsIQCalValues;
276
277typedef PACKED_PRE struct PACKED_POST {
278 tANI_S9 co_i[3];
279 tANI_S9 co_q[3];
280}sHKIQCalValues;
281
282typedef PACKED_PRE struct PACKED_POST {
283 sHKIQCalValues co[PHY_MAX_TX_CHAINS];
284}sTxChainsHKIQCalValues;
285
286typedef PACKED_PRE struct PACKED_POST {
287 tANI_U8 lna_code; //wlan_lna_5g_control1,wl_5g_lna_load_ctune
288 tANI_U8 gm_code; //wlan_rxgm_5g_control4,wlgm_ctune
289}sLnaBandCalValues;
290
291typedef PACKED_PRE struct PACKED_POST {
292 sLnaBandCalValues lnaCode[PHY_MAX_RX_CHAINS];
293}sTxChainsLnaBandCalValues;
294
295typedef tANI_U16 t_mW; //milliWatts
296typedef tANI_U8 tPwrTemplateIndex; //5-bit number used as the index into the tx gain tables
297
298typedef PACKED_PRE struct PACKED_POST {
299 tANI_U8 txPowerAdc[PHY_MAX_TX_CHAINS];
300}sTxChainsPowerAdcReadings;
301
302typedef PACKED_PRE struct PACKED_POST
303{
304 tANI_U8 agcGain;
305}tRxGain;
306
307typedef PACKED_PRE struct PACKED_POST {
308 tANI_U8 rx[PHY_MAX_RX_CHAINS];
309}sRxChainsData;
310
311typedef sRxChainsData sRxChainsRssi;
312typedef sRxChainsData sRxChainsAgcDisable;
313
314typedef PACKED_PRE struct PACKED_POST {
315 tANI_BOOLEAN rx[PHY_MAX_RX_CHAINS];
316}sRxChainsBoolean;
317
318typedef sRxChainsBoolean sRxChainsAgcEnable;
319
320#define NUM_AGC_GAINS 64
321typedef tRxGain sAgcGainLut[NUM_AGC_GAINS];
322
323
324typedef PACKED_PRE struct PACKED_POST
325{
326 tANI_S6 iLo;
327 tANI_S6 qLo;
328}sTxFirLoCorrect;
329
330typedef tIQAdc sTxLoCorrectBB[PHY_MAX_TX_CHAINS][NUM_TX_GAIN_STEPS];
331
332typedef PACKED_PRE struct PACKED_POST
333{
334 tANI_U32 txIqLoCache[PHY_MAX_TX_CHAINS][NUM_TX_GAIN_STEPS][4];
335 tANI_U32 spatialRotation;
336}tAsicTxFir;
337
338//Tx Power Config
339//A collection of selected calibrated power points at selected frequencies.
340//The algorithm does not need to know any particulars about which frequencies or cal points,
341// just the linearized adjustments at the selected calibration points
342#define MAX_TPC_CHANNELS (NUM_RF_CHANNELS)
343#define START_TPC_CHANNEL (2412)
344#define END_TPC_CHANNEL (2484)
345
346#define MAX_PWR_LUT_DBM (24)
347#define MIN_PWR_LUT_DBM (8)
348
349
350/* The reason that MAX_PWR_LUT_DBM_2DEC_PLACES is not simply (MAX_PWR_LUT_DBM * 100) is due to the fact
351 that we are interpolating the 5-bit power template index from this range compared to a LUT range of 0 to 127.
352 There is an expectation that this power range is evenly divided in 0.5dBm steps.
353 We expect that a commanded 13dBm would yield a power template index of 10, where a power template index of 0 would represent 8dBm.
354 If we used an even 2400 to represent the max power, then the calculation for 13dBm actually returns 9:
355 (127 - 0)*((1300 - 800)/(2400 - 800))+0 = 39.6875 = 39. When shifted to 5 bits, =9. Not what we wanted.
356 What we need to do is find the 2-decimal place power that corresponds as closely as possible to the 127 in the 0 to 127 range.
357 For the 800 to 2400 range, that comes out to 2386.5, so 2386. So again for a commanded power of 13dBm:
358 (127 - 0)*((1300 - 800)/(2386 - 800))+0 = 40.0378 = 40. When shifted to 5-bits, = 10, which is what we wanted.
359
360*/
361
362#define MIN_PWR_LUT_DBM_2DEC_PLACES (MIN_PWR_LUT_DBM * 100)
363#define MAX_PWR_LUT_DBM_2DEC_PLACES ((MAX_PWR_LUT_DBM * 100) - (1 + (100 * (MAX_PWR_LUT_DBM - MIN_PWR_LUT_DBM))/TPC_MEM_POWER_LUT_DEPTH))
364
365//macro provides a quick conversion of dbm value between MIN_PWR_LUT_DBM and MAX_PWR_LUT_DBM to a power template index(0 to 31)
366//based on convention, which may not hold true in the future.
367#define CONVERT_DBM_GINDEX(dbm) (((dbm - MIN_PWR_LUT_DBM) * 32) / (MAX_PWR_LUT_DBM - MIN_PWR_LUT_DBM))
368
369typedef tANI_U8 tTxGainCombo; //7-bit gain value used to get the power measurement
370
371typedef PACKED_PRE struct PACKED_POST
372{
373 tPowerDetect min;
374 tPowerDetect max;
375}tPwrTemplateRange;
376
377
378
379/*
380 The following union affords backward compatibility with txGain usage with band-specific tTpcConfig tables.
381 Due to my finding that 7-bits is not enough precision, we need to reuse the txGain space as extra precision bits
382 for the adjustedPwrDet. My spreadsheet shows that we need at least 4 bits more precision.
383 To know which usage, the MSB of adjustedPwrDet can be set to signify the extra precision in place of the txGain, which isn't used anyway.
384 We just need to be careful not to interpret a pre-existing table's txGain as extra precision.
385*/
386
387 typedef union
388 {
389 tTxGainCombo txGain; //7-bit gain used to measure the pwrDetAdc value
390 tANI_U8 hi8_adjustedPwrDet; //if the MSB is set in adjustedPwrDet, then these are extra bits of precision
391 }uExtraLutBits;
392
393
394typedef PACKED_PRE struct PACKED_POST
395{
396 t2Decimal min; //sometimes used for comparing chain powers
397 t2Decimal max; //sometimes used for comparing chain powers
398}tPowerdBmRange; //absolute power measurement precision maintained to two decimal places
399
400
401typedef tANI_U16 tRfADCVal;
402typedef tRfADCVal tTempADCVal;
403
404typedef PACKED_PRE struct PACKED_POST
405{
406 tRfADCVal pdadc_offset;
407 tANI_U8 reserved[2];
408}tTpcParams;
409
410
411//these definitions used as indexing to power per channel per rate table stored in NV
412#define CB_RATE_POWER_OFFSET 0
413#define CB_RATE_POWER_OFFSET_LAST_INDEX 60 //last index where we would apply the CB_RATE_POWER_OFFSET
414
415/* TX Power Calibration & Report Types */
416
417
418 typedef PACKED_PRE struct PACKED_POST
419 {
420 tANI_U8 temperatureAdc; //= 5 bit temperature measured at time sample was taken
421 tANI_U8 txGain; //= 7 bit gain value used to get the power measurement
422 tANI_U8 pwrDetAdc; //= 8 bit ADC power detect value
423 tANI_U8 reserved;
424 uAbsPwrPrecision absPowerMeasured; //= dBm measurement, will be truncated to two decimal places
425 }tTpcCalPoint;
426
427
428 typedef PACKED_PRE struct PACKED_POST
429 {
430 tANI_U16 numTpcCalPoints;
431 tANI_U16 reserved;
432 tTpcCalPoint chain[MAX_TPC_CAL_POINTS];
433 }tTpcChainData;
434
435
436 typedef PACKED_PRE struct PACKED_POST
437 {
438 tANI_U16 freq; //frequency in MHz
439 tANI_U16 reserved;
440 tTpcChainData empirical[PHY_MAX_TX_CHAINS]; //TPC samples passed in
441 }tTpcFreqData;
442
443 typedef PACKED_PRE struct PACKED_POST
444 {
445 tANI_U8 numChannels;
446 tANI_U8 reserved[3];
447 tTpcFreqData calValues[MAX_TPC_CHANNELS];
448 }sTpcFreqCalTable;
449
450
451typedef PACKED_PRE struct PACKED_POST {
452 tPowerDetect lut; //7-bit value in the power Lookup Table
453 tANI_U8 reserved[3];
454
455 uAbsPwrPrecision abs; //LUT value conversion to absolute dBm
456}tTxPowerLutOutput;
457
458typedef PACKED_PRE struct PACKED_POST {
459 tANI_U8 gain; //8-bit coarse(bits 4-7) & fine(bits 0-3) gain commanded for the current index
460 tPowerDetect adc; //8-bit power ADC sampled during the packet preamble
461 tANI_U16 rawAdc; //11-bit power raw ADC sampled
462
463 tTxPowerLutOutput indexMinMatch; //minimum LUT matching power that satisfies the power template index setting
464 tTxPowerLutOutput indexMaxMatch; //maximum LUT matching power that satisfies the power template index setting
465 tTxPowerLutOutput output; //output power values corresponding to power ADC index
466}tTxChainPower;
467
468extern const tRfChannelProps rfChannels[NUM_RF_CHANNELS];
469
470typedef enum
471{
472 RF_CAL_TONE_28NEG,
473 RF_CAL_TONE_24NEG,
474 RF_CAL_TONE_20NEG,
475 RF_CAL_TONE_16NEG,
476 RF_CAL_TONE_12NEG,
477 RF_CAL_TONE_8NEG,
478 RF_CAL_TONE_4NEG,
479 RF_CAL_TONE_4POS,
480 RF_CAL_TONE_8POS,
481 RF_CAL_TONE_12POS,
482 RF_CAL_TONE_16POS,
483 RF_CAL_TONE_20POS,
484 RF_CAL_TONE_24POS,
485 RF_CAL_TONE_28POS,
486
487 NUM_RF_TONES,
488
489 MIN_RF_TONE = RF_CAL_TONE_28NEG,
490 MAX_RF_TONE = RF_CAL_TONE_28POS
491}eRfTones;
492
493typedef tANI_U8 tDcoCorrect;
494typedef tANI_S8 tIm2Correct;
495
496typedef PACKED_PRE struct PACKED_POST {
497 tDcoCorrect IDcoCorrect;
498 tDcoCorrect QDcoCorrect;
499 tANI_U8 dcRange;
500}tRxDcoCorrect;
501
502typedef PACKED_PRE struct PACKED_POST {
503 tRxDcoCorrect dco[PHY_MAX_RX_CHAINS];
504}tRxChainsDcoCorrections;
505
506typedef PACKED_PRE struct PACKED_POST {
507 tIm2Correct ICorrect;
508 tIm2Correct QCorrect;
509}tRxIm2Correct;
510
511typedef PACKED_PRE struct PACKED_POST {
512 tRxIm2Correct dco[PHY_MAX_RX_CHAINS];
513}tRxChainsIm2Corrections;
514
515typedef PACKED_PRE struct PACKED_POST {
516 tDcoCorrect IDcoCorrect;
517 tDcoCorrect QDcoCorrect;
518}tTxLoCorrect;
519
520typedef PACKED_PRE struct PACKED_POST {
521 tTxLoCorrect txLo[PHY_MAX_TX_CHAINS];
522}sTxChainsLoCorrections;
523
524
525//tDcoCorrect is needed to define rf specific structures
526
527#define NUM_RF_RX_GAIN_STEPS (128)
528#define MAX_RF_RX_GAIN_STEP (NUM_RF_RX_GAIN_STEPS - 1)
529
530#define NUM_RF_TX_GAIN_STEPS (16)
531#define MAX_RF_TX_GAIN_STEP (NUM_RF_TX_GAIN_STEPS - 1)
532
533#define RF_AGC_GAIN_LUT_DEPTH (128)
534#define NUM_RF_DCO_VALUES (128) //There are only 32 DCO values, but our algorithm it makes more sense for us to access these by AGC gain index
535#define MAX_RF_DCO_VALUE (NUM_RF_DCO_VALUES - 1)
536
537
538typedef PACKED_PRE struct PACKED_POST
539{
540 tANI_U16 gainReg1; //GEMINI_REG_RX_GC_0 (lna + mix + tia + bq1 + bq2 + pga)
541}tRfRxGain;
542
543
544typedef PACKED_PRE struct PACKED_POST
545{
546 tANI_U16 bbf_gain_cnt;
547 tANI_U16 bbf_lin_adj;
548 tANI_U16 lo_mix_da_gain_cntl;
549 tANI_U16 pa_gain_cntl;
550 tANI_U16 da_pa_bias_1_cnt;
551 tANI_U16 da_pa_bias_2_cntl;
552}tRfTxGain;
553
554typedef PACKED_PRE struct PACKED_POST
555{
556 //TODO:define this struct for Gemini
557 tANI_U8 rxIf;
558 tANI_U8 txIf;
559 tANI_U8 txRf;
560 tANI_U8 reserved;
561}sRfSpecificFilterSettings;
562
563typedef sRfSpecificFilterSettings sRfChannelFilterSettings[NUM_RF_CHANNELS];
564
565
566typedef PACKED_PRE struct PACKED_POST
567{
568 tANI_U8 hdet_ctl_ext_atten;
569 tANI_U8 hdet_dcoc_code;
570 tANI_U8 hdet_dcoc_ib_rcal_en;
571 tANI_U8 hdet_dcoc_ib_scal_en;
572}sRfNvCalValues; //stored in QFUSE
573
574
575
576typedef enum
577{
578 SYNTH_UNLOCKED,
579 SYNTH_LOCK
580}eRfSynthLock;
581
582typedef enum
583{
584 TEMP_SENSOR_PA,
585 TEMP_SENSOR_RX
586}eRfTempSensor;
587
588typedef enum
589{
590 TEMPERATURE_BIN_0, //-30 to 5 C
591 TEMPERATURE_BIN_1, //5 to 45 C
592 TEMPERATURE_BIN_2, //45 to 85 C
593 TEMPERATURE_BIN_3, //85 to 125 C
594 NUM_TEMPERATURE_BINS
595}eTemperatureBins;
596
597typedef PACKED_PRE struct PACKED_POST {
598 tANI_U16 hdetDcocCode;
599 tANI_U16 hdetDcoOffset;
600}sRfHdetCalValues;
601
602#define TPC_TXPWR_ENABLE_MASK QWLAN_TPC_TXPWR_ENABLE_EN_MASK
603
604
605#define TPC_MEM_TX0_PWR_LUT_OFFSET QWLAN_TPC_POWERDET0_RAM_MREG
606#define TPC_MEM_TX1_PWR_LUT_OFFSET QWLAN_TPC_POWERDET1_RAM_MREG
607#define TPC_MEM_TX2_PWR_LUT_OFFSET QWLAN_TPC_POWERDET2_RAM_MREG
608#define TPC_MEM_TX3_PWR_LUT_OFFSET QWLAN_TPC_POWERDET3_RAM_MREG
609#define TPC_MEM_TX0_GAIN_LUT_OFFSET QWLAN_TPC_GAIN_LUT0_MREG
610#define TPC_MEM_TX1_GAIN_LUT_OFFSET QWLAN_TPC_GAIN_LUT1_MREG
611#define TPC_MEM_TX2_GAIN_LUT_OFFSET QWLAN_TPC_GAIN_LUT2_MREG
612#define TPC_MEM_TX3_GAIN_LUT_OFFSET QWLAN_TPC_GAIN_LUT3_MREG
613
614//these masks are the same for both chains
615#define TPC_POWERDET_MASK QWLAN_TPC_POWERDET0_RAM_POWER_MASK
616#define TPC_GAIN_RF_MASK QWLAN_TPC_GAIN_LUT0_RF_GAIN_MASK
617#define TPC_GAIN_RF_OFFSET QWLAN_TPC_GAIN_LUT0_RF_GAIN_OFFSET
618#define TPC_GAIN_DIG_MASK QWLAN_TPC_GAIN_LUT0_DIG_GAIN_MASK
619
620
621#define TPC_MEM_GAIN_LUT_DEPTH 32
622
623
624#define TPC_ADC_CTRL_REG QWLAN_TPC_ADC_CTRL_GET_ADC_REG
625#define TPC_ADC_GET_MASK QWLAN_TPC_ADC_CTRL_GET_ADC_GET_ADC_MASK
626
627#define TPC_ADC_FAILED_MASK QWLAN_TPC_ADC_STATUS_FAILED_MASK
628#define TPC_ADC_BUSY_P_MASK QWLAN_TPC_ADC_STATUS_BUSY_P_MASK
629#define TPC_ADC_BUSY_T_MASK QWLAN_TPC_ADC_STATUS_BUSY_T_MASK
630
631
632#define MSK_1 0x1
633#define MSK_2 0x3
634#define MSK_3 0x7
635#define MSK_4 0xF
636#define MSK_5 0x1F
637#define MSK_6 0x3F
638#define MSK_7 0x7F
639#define MSK_8 0xFF
640#define MSK_9 0x1FF
641#define MSK_10 0x3FF
642#define MSK_11 0x7FF
643#define MSK_12 0xFFF
644#define MSK_13 0x1FFF
645#define MSK_14 0x3FFF
646#define MSK_15 0x7FFF
647#define MSK_16 0xFFFF
648#define MSK_17 0x1FFFF
649#define MSK_18 0x3FFFF
650#define MSK_19 0x7FFFF
651#define MSK_20 0xFFFFF
652#define MSK_21 0x1FFFFF
653#define MSK_22 0x3FFFFF
654#define MSK_23 0x7FFFFF
655#define MSK_24 0xFFFFFF
656#define MSK_25 0x1FFFFFF
657#define MSK_26 0x3FFFFFF
658#define MSK_27 0x7FFFFFF
659#define MSK_28 0xFFFFFFF
660#define MSK_29 0x1FFFFFFF
661#define MSK_30 0x3FFFFFFF
662#define MSK_31 0x7FFFFFFF
663#define MSK_32 0xFFFFFFFF
664
665
666#define COARSE_GAIN_MASK MSK_4
667#define COARSE_GAIN_OFFSET 4
668#define FINE_GAIN_MASK MSK_4 //the upper most bit overlaps the coarse gain and should not be used for TPC LUT data
669#define FINE_GAIN_OFFSET 0
670
671typedef enum
672{
673 TPC_COARSE_TXPWR_0,
674 TPC_COARSE_TXPWR_1,
675 TPC_COARSE_TXPWR_2,
676 TPC_COARSE_TXPWR_3,
677 TPC_COARSE_TXPWR_4,
678 TPC_COARSE_TXPWR_5,
679 TPC_COARSE_TXPWR_6,
680 TPC_COARSE_TXPWR_7,
681 TPC_COARSE_TXPWR_8,
682 TPC_COARSE_TXPWR_9,
683 TPC_COARSE_TXPWR_10,
684 TPC_COARSE_TXPWR_11,
685 TPC_COARSE_TXPWR_12,
686 TPC_COARSE_TXPWR_13,
687 TPC_COARSE_TXPWR_14,
688 TPC_COARSE_TXPWR_15,
689 TPC_COARSE_TXPWR_16,
690 TPC_COARSE_TXPWR_17,
691 TPC_COARSE_TXPWR_18,
692 TPC_COARSE_TXPWR_19,
693 TPC_COARSE_TXPWR_20,
694 TPC_COARSE_TXPWR_21,
695 TPC_COARSE_TXPWR_22,
696 TPC_COARSE_TXPWR_23,
697 TPC_COARSE_TXPWR_24,
698 TPC_COARSE_TXPWR_25,
699 TPC_COARSE_TXPWR_26,
700 TPC_COARSE_TXPWR_27,
701 TPC_COARSE_TXPWR_28,
702 TPC_COARSE_TXPWR_29,
703 TPC_COARSE_TXPWR_30,
704 TPC_COARSE_TXPWR_31,
705 NUM_TPC_COARSE_STEPS = TPC_COARSE_TXPWR_31 - TPC_COARSE_TXPWR_0 + 1,
706 MIN_TPC_COARSE_TXPWR = TPC_COARSE_TXPWR_0,
707 MAX_TPC_COARSE_TXPWR = TPC_COARSE_TXPWR_31
708}eTxCoarseGain; //refers to the external RF power adjustment
709
710typedef enum
711{
712 TPC_FINE_TXPWR_0,
713 TPC_FINE_TXPWR_1,
714 TPC_FINE_TXPWR_2,
715 TPC_FINE_TXPWR_3,
716 TPC_FINE_TXPWR_4,
717 TPC_FINE_TXPWR_5,
718 TPC_FINE_TXPWR_6,
719 TPC_FINE_TXPWR_7,
720 TPC_FINE_TXPWR_8,
721 TPC_FINE_TXPWR_9,
722 TPC_FINE_TXPWR_10,
723 TPC_FINE_TXPWR_11,
724 TPC_FINE_TXPWR_12,
725 TPC_FINE_TXPWR_13,
726 TPC_FINE_TXPWR_14,
727 TPC_FINE_TXPWR_15,
728 MIN_TPC_FINE_TXPWR = TPC_FINE_TXPWR_0,
729 MAX_TPC_FINE_TXPWR = TPC_FINE_TXPWR_15
730}eTxFineGain; //refers to the internal TxFIR power adjustment
731
732typedef PACKED_PRE struct PACKED_POST {
733 eTxCoarseGain coarsePwr;
734 eTxFineGain finePwr;
735}tTxGain;
736
737//for 30second periodic interrupt, do this every 5 minutes
738#define HAL_PHY_PERIODIC_CAL_ITER_LIMIT 10
739
740typedef enum
741{
742 //these show which rx and tx chains are enabled, other chains are disable accordingly
743 //Production modes
744 PHY_CHAIN_SEL_R0_T0_ON,
745
746 PHY_CHAIN_SEL_BT_R0_T0_ON, //simultaneous bluetooth receive enabled
747
748
749 //test modes
750 PHY_CHAIN_SEL_R0_ON,
751 PHY_CHAIN_SEL_T0_ON,
752 PHY_CHAIN_SEL_NO_RX_TX,
753
754 MAX_PHY_CHAIN_SEL,
755 INVALID_PHY_CHAIN_SEL,
756 PHY_MAX_CHAIN_SELECT = 0x7FFFFFFF /* define as 4 bytes data */
757}ePhyChainSelect;
758
759typedef enum
760{
761#ifdef CHANNEL_BONDED_CAPABLE
762
763 PHY_CCA_40MHZ_SOURCE = 0,
764#endif
765
766 PHY_CCA_20MHZ_SOURCE = 1
767}ePhyCCASource;
768
769typedef enum
770{
771 PHY_CCA_FORCED_ON = 0,
772 PHY_CCA_ED = 1,
773 PHY_CCA_CD = 2,
774 PHY_CCA_CD_AND_CS = 3,
775 PHY_CCA_ED_AND_CD = 4,
776 PHY_CCA_ED_OR_CD = 5,
777 PHY_CCA_ED_AND_CD_AND_CS = 6,
778 PHY_CCA_ED_OR_CD_AND_CS = 7,
779 PHY_CCA_SEC_ED40_AND_NOR_PKTDET40_PKTDET20 = 8,
780 PHY_CCA_SEC_BUSY = 9
781}ePhyCCAMode;
782
783typedef enum
784{
785 PHY_RX_DISABLE_NONE = 0,
786 PHY_RX_DISABLE_11AG = 0x00000001,
787 PHY_RX_DISABLE_11B = 0x00000002,
788 PHY_RX_DISABLE_11N40 = 0x00000004,
789 PHY_RX_DISABLE_11AC80 = 0x00000008,
790
791 PHY_RX_DISABLE_11ABG = (PHY_RX_DISABLE_11AG | PHY_RX_DISABLE_11B),
792 PHY_RX_DISABLE_ALL_TYPES = (PHY_RX_DISABLE_11B | PHY_RX_DISABLE_11AG |
793 PHY_RX_DISABLE_11N40 | PHY_RX_DISABLE_11AC80),
794}ePhyRxDisabledPktTypes;
795
796
797// Enum for network density setting.
798typedef enum
799{
800 PHY_NW_DENSITY_LOW = 0,
801 PHY_NW_DENSITY_MED,
802 PHY_NW_DENSITY_HIGH,
803 PHY_NW_DENSITY_ADAPTIVE
804} ePhyNwDensity;
805
806
807typedef enum
808{
809 ALL_CALS, //RxDco 1st, TxLO 2nd
810 RX_DCO_CAL_ONLY,
811 RX_IM2_CAL_ONLY,
812 RX_DCO_IM2_CAL,
813 TX_LO_CAL_ONLY,
814 RX_IQ_CAL_ONLY,
815 TX_IQ_CAL_ONLY,
816 HKDAC_TX_IQ_CAL_ONLY,
817 NO_CALS = 0xFF
818}eCalSelection;
819
820
821//supports testing of closed-loop power control
822typedef enum
823{
824 FORCE_CLOSED_LOOP_GAIN = 0, //phyDbg pkt gen only uses gain index 0 when we are taking measurements with the closed-loop gain
825 FORCE_POWER_TEMPLATE_INDEX = 1, //only use forced power template index
826 FIXED_POWER_DBM = 2, //only use to specify fixed power, ignoring rate/channel/reg limits
827 REGULATORY_POWER_LIMITS = 3, //use production power Lut settings limited by power limit table per channel
828 RATE_POWER_NON_LIMITED = 4, //use power specified per rate and channel group, but don't limit power by channel
829 POWER_INDX_SRC_MAX_VAL = 0x7FFFFFFF, //dummy val to set enum to 4 bytes
830}ePowerTempIndexSource;
831
832#define BIT_0 0x00000001
833#define BIT_1 0x00000002
834#define BIT_2 0x00000004
835#define BIT_3 0x00000008
836#define BIT_4 0x00000010
837#define BIT_5 0x00000020
838#define BIT_6 0x00000040
839#define BIT_7 0x00000080
840#define BIT_8 0x00000100
841#define BIT_9 0x00000200
842#define BIT_10 0x00000400
843#define BIT_11 0x00000800
844#define BIT_12 0x00001000
845#define BIT_13 0x00002000
846#define BIT_14 0x00004000
847#define BIT_15 0x00008000
848#define BIT_16 0x00010000
849#define BIT_17 0x00020000
850#define BIT_18 0x00040000
851#define BIT_19 0x00080000
852#define BIT_20 0x00100000
853#define BIT_21 0x00200000
854#define BIT_22 0x00400000
855#define BIT_23 0x00800000
856#define BIT_24 0x01000000
857#define BIT_25 0x02000000
858#define BIT_26 0x04000000
859#define BIT_27 0x08000000
860#define BIT_28 0x10000000
861#define BIT_29 0x20000000
862#define BIT_30 0x40000000
863#define BIT_31 0x80000000
864
865#define WFM_CLK_80 BIT_3
866#define WFM_START BIT_0
867#define WFM_STOP BIT_1
868
869#define WFM_MEM_I_DATA_MASK (0x7FF)
870#define WFM_MEM_Q_DATA_OFFSET (0xB)
871#define WFM_MEM_Q_DATA_MASK (0x3FF800)
872
873typedef enum
874{
875 WAVE_SINGLE_SHOT = 0,
876 WAVE_CONTINUOUS = BIT_2
877}eWaveMode;
878
879typedef enum
880{
881 RATE_240 = 0,
882 RATE_160 = 1,
883 RATE_120 = 2,
884 RATE_80 = 3,
885 RATE_40 = 4,
886 RATE_20 = 5,
887}eWaveRate;
888
889#define MAX_TONE_AMPLITUDE (2^11) // peak to peak
890
891#define MAX_TEST_WAVEFORM_SAMPLES 500
892
893#define NUM_RX_IMB_CAL_TONES 4
894
895#define CAL_WFM_TX_TONE_8_START_IDX 0
896#define CAL_WFM_TX_TONE_8_STOP_IDX 255
897#define CAL_WFM_TX_TONE_MINUS_8_START_IDX 256
898#define CAL_WFM_TX_TONE_MINUS_8_STOP_IDX 511
899#define CAL_WFM_RX_TONE_START_IDX 512
900#define CAL_WFM_RX_TONE_STOP_IDX 767
901
902#define B_RATE_CAL_ADJUSTMENT -150
903#define GN_RATE_BANDEDGE_ADJUSTMENT -100
904
905#define TPC_INDEX_WIFI_DIRECT 0
906#define TPC_INDEX_LOW_POWER 1
907#define MIN_TPC_GAIN_INDEX 0 //Index 0 used for Wifi Direct
908#define TPC_GAIN_LUT_PWR_SLOPE 2
909#define MAX_TPC_GAIN_LUT_DBM (22)
910#define MIN_TPC_GAIN_LUT_DBM (6)
911
912#define MAX_TPC_GAIN_LUT_DBM_2DEC_PLACES (MAX_TPC_GAIN_LUT_DBM * 100)
913#define MIN_TPC_GAIN_LUT_DBM_2DEC_PLACES (MIN_TPC_GAIN_LUT_DBM * 100)
914
915#endif /* WLAN_PHY_H */