Merge branch 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[deliverable/linux.git] / drivers / net / wireless / ath / ath9k / calib.h
CommitLineData
394cf0a1 1/*
5b68138e 2 * Copyright (c) 2008-2011 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 5
23
24#define NUM_NF_READINGS 6
25#define ATH9K_NF_CAL_HIST_MAX 5
26
27struct ar5416IniArray {
28 u32 *ia_array;
29 u32 ia_rows;
30 u32 ia_columns;
31};
32
33#define INIT_INI_ARRAY(iniarray, array, rows, columns) do { \
34 (iniarray)->ia_array = (u32 *)(array); \
35 (iniarray)->ia_rows = (rows); \
36 (iniarray)->ia_columns = (columns); \
37 } while (0)
38
39#define INI_RA(iniarray, row, column) \
40 (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])
41
42#define INIT_CAL(_perCal) do { \
43 (_perCal)->calState = CAL_WAITING; \
44 (_perCal)->calNext = NULL; \
45 } while (0)
46
47#define INSERT_CAL(_ahp, _perCal) \
48 do { \
2660b81a
S
49 if ((_ahp)->cal_list_last == NULL) { \
50 (_ahp)->cal_list = \
51 (_ahp)->cal_list_last = (_perCal); \
52 ((_ahp)->cal_list_last)->calNext = (_perCal); \
394cf0a1 53 } else { \
2660b81a
S
54 ((_ahp)->cal_list_last)->calNext = (_perCal); \
55 (_ahp)->cal_list_last = (_perCal); \
56 (_perCal)->calNext = (_ahp)->cal_list; \
394cf0a1
S
57 } \
58 } while (0)
59
cbfe9468 60enum ath9k_cal_state {
394cf0a1
S
61 CAL_INACTIVE,
62 CAL_WAITING,
63 CAL_RUNNING,
64 CAL_DONE
65};
66
67#define MIN_CAL_SAMPLES 1
68#define MAX_CAL_SAMPLES 64
69#define INIT_LOG_COUNT 5
70#define PER_MIN_LOG_COUNT 2
71#define PER_MAX_LOG_COUNT 10
72
cbfe9468 73struct ath9k_percal_data {
6497827f 74 u32 calType;
394cf0a1
S
75 u32 calNumSamples;
76 u32 calCountMax;
cbe61d8a
S
77 void (*calCollect) (struct ath_hw *);
78 void (*calPostProc) (struct ath_hw *, u8);
394cf0a1
S
79};
80
cbfe9468
S
81struct ath9k_cal_list {
82 const struct ath9k_percal_data *calData;
83 enum ath9k_cal_state calState;
84 struct ath9k_cal_list *calNext;
394cf0a1
S
85};
86
87struct ath9k_nfcal_hist {
88 int16_t nfCalBuffer[ATH9K_NF_CAL_HIST_MAX];
89 u8 currIndex;
90 int16_t privNF;
91 u8 invalidNFcount;
92};
93
a13883b0
S
94#define MAX_PACAL_SKIPCOUNT 8
95struct ath9k_pacal_info{
96 int32_t prev_offset; /* Previous value of PA offset value */
97 int8_t max_skipcount; /* Max No. of times PACAL can be skipped */
98 int8_t skipcount; /* No. of times the PACAL to be skipped */
99};
100
cbe61d8a 101bool ath9k_hw_reset_calvalid(struct ath_hw *ah);
00c86590 102void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update);
bbacee13 103void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan);
4254bc1c 104bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan);
20bd2a09
FF
105void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
106 struct ath9k_channel *chan);
70cf1533 107void ath9k_hw_bstuck_nfcal(struct ath_hw *ah);
795f5e2c
LR
108void ath9k_hw_reset_calibration(struct ath_hw *ah,
109 struct ath9k_cal_list *currCal);
f23fba49 110s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan);
795f5e2c 111
394cf0a1
S
112
113#endif /* CALIB_H */
This page took 0.398572 seconds and 5 git commands to generate.