Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 1 | /* |
Sujith | cee075a | 2009-03-13 09:07:23 +0530 | [diff] [blame] | 2 | * Copyright (c) 2008-2009 Atheros Communications Inc. |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 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 | |
Luis R. Rodriguez | c46917b | 2009-09-13 02:42:02 -0700 | [diff] [blame] | 20 | #include "hw.h" |
| 21 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 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 | |
| 28 | struct 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 { \ |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 50 | if ((_ahp)->cal_list_last == NULL) { \ |
| 51 | (_ahp)->cal_list = \ |
| 52 | (_ahp)->cal_list_last = (_perCal); \ |
| 53 | ((_ahp)->cal_list_last)->calNext = (_perCal); \ |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 54 | } else { \ |
Sujith | 2660b81 | 2009-02-09 13:27:26 +0530 | [diff] [blame] | 55 | ((_ahp)->cal_list_last)->calNext = (_perCal); \ |
| 56 | (_ahp)->cal_list_last = (_perCal); \ |
| 57 | (_perCal)->calNext = (_ahp)->cal_list; \ |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 58 | } \ |
| 59 | } while (0) |
| 60 | |
Sujith | cbfe946 | 2009-04-13 21:56:56 +0530 | [diff] [blame] | 61 | enum ath9k_cal_state { |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 62 | CAL_INACTIVE, |
| 63 | CAL_WAITING, |
| 64 | CAL_RUNNING, |
| 65 | CAL_DONE |
| 66 | }; |
| 67 | |
| 68 | #define MIN_CAL_SAMPLES 1 |
| 69 | #define MAX_CAL_SAMPLES 64 |
| 70 | #define INIT_LOG_COUNT 5 |
| 71 | #define PER_MIN_LOG_COUNT 2 |
| 72 | #define PER_MAX_LOG_COUNT 10 |
| 73 | |
Sujith | cbfe946 | 2009-04-13 21:56:56 +0530 | [diff] [blame] | 74 | struct ath9k_percal_data { |
Felix Fietkau | 6497827 | 2010-10-03 19:07:16 +0200 | [diff] [blame] | 75 | u32 calType; |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 76 | u32 calNumSamples; |
| 77 | u32 calCountMax; |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 78 | void (*calCollect) (struct ath_hw *); |
| 79 | void (*calPostProc) (struct ath_hw *, u8); |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 80 | }; |
| 81 | |
Sujith | cbfe946 | 2009-04-13 21:56:56 +0530 | [diff] [blame] | 82 | struct ath9k_cal_list { |
| 83 | const struct ath9k_percal_data *calData; |
| 84 | enum ath9k_cal_state calState; |
| 85 | struct ath9k_cal_list *calNext; |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | struct ath9k_nfcal_hist { |
| 89 | int16_t nfCalBuffer[ATH9K_NF_CAL_HIST_MAX]; |
| 90 | u8 currIndex; |
| 91 | int16_t privNF; |
| 92 | u8 invalidNFcount; |
| 93 | }; |
| 94 | |
Sujith | a13883b | 2009-08-26 08:39:40 +0530 | [diff] [blame] | 95 | #define MAX_PACAL_SKIPCOUNT 8 |
| 96 | struct ath9k_pacal_info{ |
| 97 | int32_t prev_offset; /* Previous value of PA offset value */ |
| 98 | int8_t max_skipcount; /* Max No. of times PACAL can be skipped */ |
| 99 | int8_t skipcount; /* No. of times the PACAL to be skipped */ |
| 100 | }; |
| 101 | |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 102 | bool ath9k_hw_reset_calvalid(struct ath_hw *ah); |
Felix Fietkau | 00c8659 | 2010-07-30 21:02:09 +0200 | [diff] [blame] | 103 | void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update); |
Felix Fietkau | bbacee1 | 2010-07-11 15:44:42 +0200 | [diff] [blame] | 104 | void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan); |
Felix Fietkau | 4254bc1 | 2010-07-31 00:12:01 +0200 | [diff] [blame] | 105 | bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan); |
Felix Fietkau | 20bd2a0 | 2010-07-31 00:12:00 +0200 | [diff] [blame] | 106 | void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah, |
| 107 | struct ath9k_channel *chan); |
Felix Fietkau | 70cf153 | 2010-08-02 15:53:14 +0200 | [diff] [blame] | 108 | void ath9k_hw_bstuck_nfcal(struct ath_hw *ah); |
Sujith | cbe61d8 | 2009-02-09 13:27:12 +0530 | [diff] [blame] | 109 | s16 ath9k_hw_getchan_noise(struct ath_hw *ah, struct ath9k_channel *chan); |
Luis R. Rodriguez | 795f5e2 | 2010-04-15 17:39:00 -0400 | [diff] [blame] | 110 | void ath9k_hw_reset_calibration(struct ath_hw *ah, |
| 111 | struct ath9k_cal_list *currCal); |
| 112 | |
Sujith | 394cf0a | 2009-02-09 13:26:54 +0530 | [diff] [blame] | 113 | |
| 114 | #endif /* CALIB_H */ |