calib.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) 2008-2011 Atheros Communications Inc.
  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. #ifndef CALIB_H
  17. #define CALIB_H
  18. #include "hw.h"
  19. #define AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT 3
  20. #define AR_PHY_CCA_FILTERWINDOW_LENGTH 5
  21. #define NUM_NF_READINGS 6
  22. #define ATH9K_NF_CAL_HIST_MAX 5
  23. struct ar5416IniArray {
  24. u32 *ia_array;
  25. u32 ia_rows;
  26. u32 ia_columns;
  27. };
  28. #define INIT_INI_ARRAY(iniarray, array, rows, columns) do { \
  29. (iniarray)->ia_array = (u32 *)(array); \
  30. (iniarray)->ia_rows = (rows); \
  31. (iniarray)->ia_columns = (columns); \
  32. } while (0)
  33. #define INI_RA(iniarray, row, column) \
  34. (((iniarray)->ia_array)[(row) * ((iniarray)->ia_columns) + (column)])
  35. #define INIT_CAL(_perCal) do { \
  36. (_perCal)->calState = CAL_WAITING; \
  37. (_perCal)->calNext = NULL; \
  38. } while (0)
  39. #define INSERT_CAL(_ahp, _perCal) \
  40. do { \
  41. if ((_ahp)->cal_list_last == NULL) { \
  42. (_ahp)->cal_list = \
  43. (_ahp)->cal_list_last = (_perCal); \
  44. ((_ahp)->cal_list_last)->calNext = (_perCal); \
  45. } else { \
  46. ((_ahp)->cal_list_last)->calNext = (_perCal); \
  47. (_ahp)->cal_list_last = (_perCal); \
  48. (_perCal)->calNext = (_ahp)->cal_list; \
  49. } \
  50. } while (0)
  51. enum ath9k_cal_state {
  52. CAL_INACTIVE,
  53. CAL_WAITING,
  54. CAL_RUNNING,
  55. CAL_DONE
  56. };
  57. #define MIN_CAL_SAMPLES 1
  58. #define MAX_CAL_SAMPLES 64
  59. #define INIT_LOG_COUNT 5
  60. #define PER_MIN_LOG_COUNT 2
  61. #define PER_MAX_LOG_COUNT 10
  62. struct ath9k_percal_data {
  63. u32 calType;
  64. u32 calNumSamples;
  65. u32 calCountMax;
  66. void (*calCollect) (struct ath_hw *);
  67. void (*calPostProc) (struct ath_hw *, u8);
  68. };
  69. struct ath9k_cal_list {
  70. const struct ath9k_percal_data *calData;
  71. enum ath9k_cal_state calState;
  72. struct ath9k_cal_list *calNext;
  73. };
  74. struct ath9k_nfcal_hist {
  75. int16_t nfCalBuffer[ATH9K_NF_CAL_HIST_MAX];
  76. u8 currIndex;
  77. int16_t privNF;
  78. u8 invalidNFcount;
  79. };
  80. #define MAX_PACAL_SKIPCOUNT 8
  81. struct ath9k_pacal_info{
  82. int32_t prev_offset; /* Previous value of PA offset value */
  83. int8_t max_skipcount; /* Max No. of times PACAL can be skipped */
  84. int8_t skipcount; /* No. of times the PACAL to be skipped */
  85. };
  86. bool ath9k_hw_reset_calvalid(struct ath_hw *ah);
  87. void ath9k_hw_start_nfcal(struct ath_hw *ah, bool update);
  88. void ath9k_hw_loadnf(struct ath_hw *ah, struct ath9k_channel *chan);
  89. bool ath9k_hw_getnf(struct ath_hw *ah, struct ath9k_channel *chan);
  90. void ath9k_init_nfcal_hist_buffer(struct ath_hw *ah,
  91. struct ath9k_channel *chan);
  92. void ath9k_hw_bstuck_nfcal(struct ath_hw *ah);
  93. void ath9k_hw_reset_calibration(struct ath_hw *ah,
  94. struct ath9k_cal_list *currCal);
  95. #endif /* CALIB_H */