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