Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Copyright (c) 2008-2011 Atheros Communications Inc.
0003  *
0004  * Permission to use, copy, modify, and/or distribute this software for any
0005  * purpose with or without fee is hereby granted, provided that the above
0006  * copyright notice and this permission notice appear in all copies.
0007  *
0008  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
0009  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
0010  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
0011  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
0012  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
0013  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
0014  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
0015  */
0016 
0017 #ifndef CALIB_H
0018 #define CALIB_H
0019 
0020 #include "hw.h"
0021 
0022 #define AR_PHY_CCA_FILTERWINDOW_LENGTH          5
0023 
0024 /* Internal noise floor can vary by about 6db depending on the frequency */
0025 #define ATH9K_NF_CAL_NOISE_THRESH       6
0026 
0027 #define NUM_NF_READINGS       6
0028 #define ATH9K_NF_CAL_HIST_MAX 5
0029 
0030 struct ar5416IniArray {
0031     u32 *ia_array;
0032     u32 ia_rows;
0033     u32 ia_columns;
0034 };
0035 
0036 #define STATIC_INI_ARRAY(array) {           \
0037         .ia_array = (u32 *)(array),     \
0038         .ia_rows = ARRAY_SIZE(array),       \
0039         .ia_columns = ARRAY_SIZE(array[0]), \
0040     }
0041 
0042 #define INIT_INI_ARRAY(iniarray, array) do {    \
0043         (iniarray)->ia_array = (u32 *)(array);      \
0044         (iniarray)->ia_rows = ARRAY_SIZE(array);    \
0045         (iniarray)->ia_columns = ARRAY_SIZE(array[0]);  \
0046     } while (0)
0047 
0048 #define INI_RA(iniarray, row, column) \
0049     (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])
0050 
0051 #define INIT_CAL(_perCal) do {              \
0052         (_perCal)->calState = CAL_WAITING;  \
0053         (_perCal)->calNext = NULL;      \
0054     } while (0)
0055 
0056 #define INSERT_CAL(_ahp, _perCal)                   \
0057     do {                                \
0058         if ((_ahp)->cal_list_last == NULL) {            \
0059             (_ahp)->cal_list =              \
0060                 (_ahp)->cal_list_last = (_perCal);  \
0061             ((_ahp)->cal_list_last)->calNext = (_perCal); \
0062         } else {                        \
0063             ((_ahp)->cal_list_last)->calNext = (_perCal); \
0064             (_ahp)->cal_list_last = (_perCal);      \
0065             (_perCal)->calNext = (_ahp)->cal_list;  \
0066         }                           \
0067     } while (0)
0068 
0069 enum ath9k_cal_state {
0070     CAL_INACTIVE,
0071     CAL_WAITING,
0072     CAL_RUNNING,
0073     CAL_DONE
0074 };
0075 
0076 #define MIN_CAL_SAMPLES     1
0077 #define MAX_CAL_SAMPLES    64
0078 #define INIT_LOG_COUNT      5
0079 #define PER_MIN_LOG_COUNT   2
0080 #define PER_MAX_LOG_COUNT  10
0081 
0082 struct ath9k_percal_data {
0083     u32 calType;
0084     u32 calNumSamples;
0085     u32 calCountMax;
0086     void (*calCollect) (struct ath_hw *);
0087     void (*calPostProc) (struct ath_hw *, u8);
0088 };
0089 
0090 struct ath9k_cal_list {
0091     const struct ath9k_percal_data *calData;
0092     enum ath9k_cal_state calState;
0093     struct ath9k_cal_list *calNext;
0094 };
0095 
0096 struct ath9k_nfcal_hist {
0097     int16_t nfCalBuffer[ATH9K_NF_CAL_HIST_MAX];
0098     u8 currIndex;
0099     int16_t privNF;
0100     u8 invalidNFcount;
0101 };
0102 
0103 #define MAX_PACAL_SKIPCOUNT 8
0104 struct ath9k_pacal_info{
0105     int32_t prev_offset;    /* Previous value of PA offset value */
0106     int8_t max_skipcount;   /* Max No. of times PACAL can be skipped */
0107     int8_t skipcount;   /* No. of times the PACAL to be skipped */
0108 };
0109 
0110 bool ath9k_hw_reset_calvalid(struct ath_hw *ah);
0111 void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update);
0112 int ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan);
0113 bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan);
0114 void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
0115                   struct ath9k_channel *chan);
0116 void ath9k_hw_bstuck_nfcal(struct ath_hw *ah);
0117 void ath9k_hw_reset_calibration(struct ath_hw *ah,
0118                 struct ath9k_cal_list *currCal);
0119 s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan,
0120                s16 nf);
0121 
0122 
0123 #endif /* CALIB_H */