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