Remove empty DragonFly CVS IDs.
[dragonfly.git] / sys / dev / netif / ath / hal / ath_hal / ar5416 / ar5416_cal.h
blob482b6eb8ab90962d7b1ae593c37d52a6a06c98be
1 /*
2 * Copyright (c) 2002-2009 Sam Leffler, Errno Consulting
3 * Copyright (c) 2002-2008 Atheros Communications, Inc.
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 * $FreeBSD: head/sys/dev/ath/ath_hal/ar5416/ar5416_cal.h 203882 2010-02-14 16:26:32Z rpaulo $
19 #ifndef _ATH_AR5416_CAL_H_
20 #define _ATH_AR5416_CAL_H_
22 typedef enum {
23 ADC_DC_INIT_CAL = 0x1,
24 ADC_GAIN_CAL = 0x2,
25 ADC_DC_CAL = 0x4,
26 IQ_MISMATCH_CAL = 0x8
27 } HAL_CAL_TYPE;
29 /* Calibrate state */
30 typedef enum {
31 CAL_INACTIVE,
32 CAL_WAITING,
33 CAL_RUNNING,
34 CAL_DONE
35 } HAL_CAL_STATE;
37 typedef union {
38 uint32_t u;
39 int32_t s;
40 } HAL_CAL_SAMPLE;
42 #define MIN_CAL_SAMPLES 1
43 #define MAX_CAL_SAMPLES 64
44 #define INIT_LOG_COUNT 5
45 #define PER_MIN_LOG_COUNT 2
46 #define PER_MAX_LOG_COUNT 10
48 /* Per Calibration data structure */
49 typedef struct per_cal_data {
50 const char *calName; /* for diagnostics */
51 HAL_CAL_TYPE calType; /* Type of calibration */
52 uint32_t calNumSamples; /* # SW samples to collect */
53 uint32_t calCountMax; /* # HW samples to collect */
54 void (*calCollect)(struct ath_hal *); /* Accumulator function */
55 /* Post-processing function */
56 void (*calPostProc)(struct ath_hal *, uint8_t);
57 } HAL_PERCAL_DATA;
59 /* List structure for calibration data */
60 typedef struct cal_list {
61 struct cal_list *calNext;
62 HAL_CAL_STATE calState;
63 const HAL_PERCAL_DATA *calData;
64 } HAL_CAL_LIST;
66 struct ar5416PerCal {
68 * Periodic calibration state.
70 HAL_CAL_TYPE suppCals;
71 HAL_CAL_LIST iqCalData;
72 HAL_CAL_LIST adcGainCalData;
73 HAL_CAL_LIST adcDcCalInitData;
74 HAL_CAL_LIST adcDcCalData;
75 HAL_CAL_LIST *cal_list;
76 HAL_CAL_LIST *cal_last;
77 HAL_CAL_LIST *cal_curr;
78 #define AR5416_MAX_CHAINS 3 /* XXX dup's eeprom def */
79 HAL_CAL_SAMPLE caldata[4][AR5416_MAX_CHAINS];
80 int calSamples;
82 * Noise floor cal histogram support.
83 * XXX be nice to re-use space in ar5212
85 #define AR5416_NUM_NF_READINGS 6 /* (3 chains * (ctl + ext) */
86 struct ar5212NfCalHist nfCalHist[AR5416_NUM_NF_READINGS];
89 #define INIT_CAL(_perCal) do { \
90 (_perCal)->calState = CAL_WAITING; \
91 (_perCal)->calNext = AH_NULL; \
92 } while (0)
94 #define INSERT_CAL(_cal, _perCal) do { \
95 if ((_cal)->cal_last == AH_NULL) { \
96 (_cal)->cal_list = (_cal)->cal_last = (_perCal); \
97 ((_cal)->cal_last)->calNext = (_perCal); \
98 } else { \
99 ((_cal)->cal_last)->calNext = (_perCal); \
100 (_cal)->cal_last = (_perCal); \
101 (_perCal)->calNext = (_cal)->cal_list; \
103 } while (0)
105 HAL_BOOL ar5416InitCal(struct ath_hal *, const struct ieee80211_channel *);
106 HAL_BOOL ar5416PerCalibration(struct ath_hal *, struct ieee80211_channel *,
107 HAL_BOOL *isIQdone);
108 HAL_BOOL ar5416PerCalibrationN(struct ath_hal *, struct ieee80211_channel *,
109 u_int chainMask, HAL_BOOL longCal, HAL_BOOL *isCalDone);
110 HAL_BOOL ar5416ResetCalValid(struct ath_hal *,
111 const struct ieee80211_channel *);
113 void ar5416IQCalCollect(struct ath_hal *ah);
114 void ar5416IQCalibration(struct ath_hal *ah, uint8_t numChains);
115 void ar5416AdcGainCalCollect(struct ath_hal *ah);
116 void ar5416AdcGainCalibration(struct ath_hal *ah, uint8_t numChains);
117 void ar5416AdcDcCalCollect(struct ath_hal *ah);
118 void ar5416AdcDcCalibration(struct ath_hal *ah, uint8_t numChains);
119 void ar5416InitNfHistBuff(struct ar5212NfCalHist *h);
120 #endif /* _ATH_AR5416_CAL_H_ */