]> bbs.cooldavid.org Git - net-next-2.6.git/blame - drivers/net/wireless/ath/ath9k/calib.h
ath9k: merge noisefloor load implementations
[net-next-2.6.git] / drivers / net / wireless / ath / ath9k / calib.h
CommitLineData
394cf0a1 1/*
cee075a2 2 * Copyright (c) 2008-2009 Atheros Communications Inc.
394cf0a1
S
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17#ifndef CALIB_H
18#define CALIB_H
19
c46917bb
LR
20#include "hw.h"
21
394cf0a1
S
22#define AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT 3
23#define AR_PHY_CCA_FILTERWINDOW_LENGTH 5
24
25#define NUM_NF_READINGS 6
26#define ATH9K_NF_CAL_HIST_MAX 5
27
28struct ar5416IniArray {
29 u32 *ia_array;
30 u32 ia_rows;
31 u32 ia_columns;
32};
33
34#define INIT_INI_ARRAY(iniarray, array, rows, columns) do { \
35 (iniarray)->ia_array = (u32 *)(array); \
36 (iniarray)->ia_rows = (rows); \
37 (iniarray)->ia_columns = (columns); \
38 } while (0)
39
40#define INI_RA(iniarray, row, column) \
41 (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])
42
43#define INIT_CAL(_perCal) do { \
44 (_perCal)->calState = CAL_WAITING; \
45 (_perCal)->calNext = NULL; \
46 } while (0)
47
48#define INSERT_CAL(_ahp, _perCal) \
49 do { \
2660b81a
S
50 if ((_ahp)->cal_list_last == NULL) { \
51 (_ahp)->cal_list = \
52 (_ahp)->cal_list_last = (_perCal); \
53 ((_ahp)->cal_list_last)->calNext = (_perCal); \
394cf0a1 54 } else { \
2660b81a
S
55 ((_ahp)->cal_list_last)->calNext = (_perCal); \
56 (_ahp)->cal_list_last = (_perCal); \
57 (_perCal)->calNext = (_ahp)->cal_list; \
394cf0a1
S
58 } \
59 } while (0)
60
cbfe9468 61enum ath9k_cal_types {
394cf0a1
S
62 ADC_DC_INIT_CAL = 0x1,
63 ADC_GAIN_CAL = 0x2,
64 ADC_DC_CAL = 0x4,
4b01931e
LR
65 IQ_MISMATCH_CAL = 0x8,
66 TEMP_COMP_CAL = 0x10,
394cf0a1
S
67};
68
cbfe9468 69enum ath9k_cal_state {
394cf0a1
S
70 CAL_INACTIVE,
71 CAL_WAITING,
72 CAL_RUNNING,
73 CAL_DONE
74};
75
76#define MIN_CAL_SAMPLES 1
77#define MAX_CAL_SAMPLES 64
78#define INIT_LOG_COUNT 5
79#define PER_MIN_LOG_COUNT 2
80#define PER_MAX_LOG_COUNT 10
81
cbfe9468
S
82struct ath9k_percal_data {
83 enum ath9k_cal_types calType;
394cf0a1
S
84 u32 calNumSamples;
85 u32 calCountMax;
cbe61d8a
S
86 void (*calCollect) (struct ath_hw *);
87 void (*calPostProc) (struct ath_hw *, u8);
394cf0a1
S
88};
89
cbfe9468
S
90struct ath9k_cal_list {
91 const struct ath9k_percal_data *calData;
92 enum ath9k_cal_state calState;
93 struct ath9k_cal_list *calNext;
394cf0a1
S
94};
95
96struct ath9k_nfcal_hist {
97 int16_t nfCalBuffer[ATH9K_NF_CAL_HIST_MAX];
98 u8 currIndex;
99 int16_t privNF;
100 u8 invalidNFcount;
101};
102
a13883b0
S
103#define MAX_PACAL_SKIPCOUNT 8
104struct ath9k_pacal_info{
105 int32_t prev_offset; /* Previous value of PA offset value */
106 int8_t max_skipcount; /* Max No. of times PACAL can be skipped */
107 int8_t skipcount; /* No. of times the PACAL to be skipped */
108};
109
cbe61d8a
S
110bool ath9k_hw_reset_calvalid(struct ath_hw *ah);
111void ath9k_hw_start_nfcal(struct ath_hw *ah);
bbacee13 112void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan);
cbe61d8a 113int16_t ath9k_hw_getnf(struct ath_hw *ah,
394cf0a1 114 struct ath9k_channel *chan);
cbe61d8a
S
115void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah);
116s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan);
795f5e2c
LR
117void ath9k_hw_reset_calibration(struct ath_hw *ah,
118 struct ath9k_cal_list *currCal);
119
394cf0a1
S
120
121#endif /* CALIB_H */