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