iPXE
calib.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008-2011 Atheros Communications Inc.
00003  *
00004  * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
00005  * Original from Linux kernel 3.0.1
00006  *
00007  * Permission to use, copy, modify, and/or distribute this software for any
00008  * purpose with or without fee is hereby granted, provided that the above
00009  * copyright notice and this permission notice appear in all copies.
00010  *
00011  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
00012  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
00013  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
00014  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
00015  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
00016  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
00017  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00018  */
00019 
00020 #ifndef CALIB_H
00021 #define CALIB_H
00022 
00023 FILE_LICENCE ( BSD2 );
00024 
00025 #include "hw.h"
00026 
00027 #define AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT     3
00028 #define AR_PHY_CCA_FILTERWINDOW_LENGTH          5
00029 
00030 #define NUM_NF_READINGS       6
00031 #define ATH9K_NF_CAL_HIST_MAX 5
00032 
00033 struct ar5416IniArray {
00034         u32 *ia_array;
00035         u32 ia_rows;
00036         u32 ia_columns;
00037 };
00038 
00039 #define INIT_INI_ARRAY(iniarray, array, rows, columns) do {     \
00040                 (iniarray)->ia_array = (u32 *)(array);          \
00041                 (iniarray)->ia_rows = (rows);                   \
00042                 (iniarray)->ia_columns = (columns);             \
00043         } while (0)
00044 
00045 #define INI_RA(iniarray, row, column) \
00046         (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])
00047 
00048 #define INIT_CAL(_perCal) do {                          \
00049                 (_perCal)->calState = CAL_WAITING;      \
00050                 (_perCal)->calNext = NULL;              \
00051         } while (0)
00052 
00053 #define INSERT_CAL(_ahp, _perCal)                                       \
00054         do {                                                            \
00055                 if ((_ahp)->cal_list_last == NULL) {                    \
00056                         (_ahp)->cal_list =                              \
00057                                 (_ahp)->cal_list_last = (_perCal);      \
00058                         ((_ahp)->cal_list_last)->calNext = (_perCal); \
00059                 } else {                                                \
00060                         ((_ahp)->cal_list_last)->calNext = (_perCal); \
00061                         (_ahp)->cal_list_last = (_perCal);              \
00062                         (_perCal)->calNext = (_ahp)->cal_list;  \
00063                 }                                                       \
00064         } while (0)
00065 
00066 enum ath9k_cal_state {
00067         CAL_INACTIVE,
00068         CAL_WAITING,
00069         CAL_RUNNING,
00070         CAL_DONE
00071 };
00072 
00073 #define MIN_CAL_SAMPLES     1
00074 #define MAX_CAL_SAMPLES    64
00075 #define INIT_LOG_COUNT      5
00076 #define PER_MIN_LOG_COUNT   2
00077 #define PER_MAX_LOG_COUNT  10
00078 
00079 struct ath9k_percal_data {
00080         u32 calType;
00081         u32 calNumSamples;
00082         u32 calCountMax;
00083         void (*calCollect) (struct ath_hw *);
00084         void (*calPostProc) (struct ath_hw *, u8);
00085 };
00086 
00087 struct ath9k_cal_list {
00088         const struct ath9k_percal_data *calData;
00089         enum ath9k_cal_state calState;
00090         struct ath9k_cal_list *calNext;
00091 };
00092 
00093 struct ath9k_nfcal_hist {
00094         int16_t nfCalBuffer[ATH9K_NF_CAL_HIST_MAX];
00095         u8 currIndex;
00096         int16_t privNF;
00097         u8 invalidNFcount;
00098 };
00099 
00100 #define MAX_PACAL_SKIPCOUNT 8
00101 struct ath9k_pacal_info{
00102         int32_t prev_offset;    /* Previous value of PA offset value */
00103         int8_t max_skipcount;   /* Max No. of times PACAL can be skipped */
00104         int8_t skipcount;       /* No. of times the PACAL to be skipped */
00105 };
00106 
00107 int ath9k_hw_reset_calvalid(struct ath_hw *ah);
00108 void ath9k_hw_start_nfcal(struct ath_hw *ah, int update);
00109 void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan);
00110 int ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan);
00111 void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
00112                                   struct ath9k_channel *chan);
00113 void ath9k_hw_reset_calibration(struct ath_hw *ah,
00114                                 struct ath9k_cal_list *currCal);
00115 
00116 
00117 #endif /* CALIB_H */