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