162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright (c) 2008-2011 Atheros Communications Inc.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any
562306a36Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above
662306a36Sopenharmony_ci * copyright notice and this permission notice appear in all copies.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
962306a36Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1062306a36Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1162306a36Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1262306a36Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1362306a36Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1462306a36Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1562306a36Sopenharmony_ci */
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#ifndef ANI_H
1862306a36Sopenharmony_ci#define ANI_H
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define BEACON_RSSI(ahp) (ahp->stats.avgbrssi)
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci/* units are errors per second */
2362306a36Sopenharmony_ci#define ATH9K_ANI_OFDM_TRIG_HIGH           3500
2462306a36Sopenharmony_ci#define ATH9K_ANI_OFDM_TRIG_HIGH_BELOW_INI 1000
2562306a36Sopenharmony_ci#define ATH9K_ANI_OFDM_TRIG_HIGH_OLD       500
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#define ATH9K_ANI_OFDM_TRIG_LOW           400
2862306a36Sopenharmony_ci#define ATH9K_ANI_OFDM_TRIG_LOW_ABOVE_INI 900
2962306a36Sopenharmony_ci#define ATH9K_ANI_OFDM_TRIG_LOW_OLD       200
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_ci#define ATH9K_ANI_CCK_TRIG_HIGH           600
3262306a36Sopenharmony_ci#define ATH9K_ANI_CCK_TRIG_HIGH_OLD       200
3362306a36Sopenharmony_ci#define ATH9K_ANI_CCK_TRIG_LOW            300
3462306a36Sopenharmony_ci#define ATH9K_ANI_CCK_TRIG_LOW_OLD        100
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci#define ATH9K_ANI_SPUR_IMMUNE_LVL         3
3762306a36Sopenharmony_ci#define ATH9K_ANI_FIRSTEP_LVL             2
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#define ATH9K_ANI_RSSI_THR_HIGH           40
4062306a36Sopenharmony_ci#define ATH9K_ANI_RSSI_THR_LOW            7
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ci#define ATH9K_ANI_PERIOD                  300
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci/* in ms */
4562306a36Sopenharmony_ci#define ATH9K_ANI_POLLINTERVAL            1000
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci#define ATH9K_SIG_FIRSTEP_SETTING_MIN     0
4862306a36Sopenharmony_ci#define ATH9K_SIG_FIRSTEP_SETTING_MAX     20
4962306a36Sopenharmony_ci#define ATH9K_SIG_SPUR_IMM_SETTING_MIN    0
5062306a36Sopenharmony_ci#define ATH9K_SIG_SPUR_IMM_SETTING_MAX    22
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci/* values here are relative to the INI */
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_cienum ath9k_ani_cmd {
5562306a36Sopenharmony_ci	ATH9K_ANI_OFDM_WEAK_SIGNAL_DETECTION = 0x1,
5662306a36Sopenharmony_ci	ATH9K_ANI_FIRSTEP_LEVEL = 0x2,
5762306a36Sopenharmony_ci	ATH9K_ANI_SPUR_IMMUNITY_LEVEL = 0x4,
5862306a36Sopenharmony_ci	ATH9K_ANI_MRC_CCK = 0x8,
5962306a36Sopenharmony_ci	ATH9K_ANI_ALL = 0xfff
6062306a36Sopenharmony_ci};
6162306a36Sopenharmony_ci
6262306a36Sopenharmony_cistruct ath9k_mib_stats {
6362306a36Sopenharmony_ci	u32 ackrcv_bad;
6462306a36Sopenharmony_ci	u32 rts_bad;
6562306a36Sopenharmony_ci	u32 rts_good;
6662306a36Sopenharmony_ci	u32 fcs_bad;
6762306a36Sopenharmony_ci	u32 beacons;
6862306a36Sopenharmony_ci};
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci/* INI default values for ANI registers */
7162306a36Sopenharmony_cistruct ath9k_ani_default {
7262306a36Sopenharmony_ci	u16 m1ThreshLow;
7362306a36Sopenharmony_ci	u16 m2ThreshLow;
7462306a36Sopenharmony_ci	u16 m1Thresh;
7562306a36Sopenharmony_ci	u16 m2Thresh;
7662306a36Sopenharmony_ci	u16 m2CountThr;
7762306a36Sopenharmony_ci	u16 m2CountThrLow;
7862306a36Sopenharmony_ci	u16 m1ThreshLowExt;
7962306a36Sopenharmony_ci	u16 m2ThreshLowExt;
8062306a36Sopenharmony_ci	u16 m1ThreshExt;
8162306a36Sopenharmony_ci	u16 m2ThreshExt;
8262306a36Sopenharmony_ci	u16 firstep;
8362306a36Sopenharmony_ci	u16 firstepLow;
8462306a36Sopenharmony_ci	u16 cycpwrThr1;
8562306a36Sopenharmony_ci	u16 cycpwrThr1Ext;
8662306a36Sopenharmony_ci};
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_cistruct ar5416AniState {
8962306a36Sopenharmony_ci	u8 noiseImmunityLevel;
9062306a36Sopenharmony_ci	u8 ofdmNoiseImmunityLevel;
9162306a36Sopenharmony_ci	u8 cckNoiseImmunityLevel;
9262306a36Sopenharmony_ci	bool ofdmsTurn;
9362306a36Sopenharmony_ci	u8 mrcCCK;
9462306a36Sopenharmony_ci	u8 spurImmunityLevel;
9562306a36Sopenharmony_ci	u8 firstepLevel;
9662306a36Sopenharmony_ci	bool ofdmWeakSigDetect;
9762306a36Sopenharmony_ci	u32 listenTime;
9862306a36Sopenharmony_ci	u32 ofdmPhyErrCount;
9962306a36Sopenharmony_ci	u32 cckPhyErrCount;
10062306a36Sopenharmony_ci	struct ath9k_ani_default iniDef;
10162306a36Sopenharmony_ci};
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_cistruct ar5416Stats {
10462306a36Sopenharmony_ci	u32 ast_ani_spurup;
10562306a36Sopenharmony_ci	u32 ast_ani_spurdown;
10662306a36Sopenharmony_ci	u32 ast_ani_ofdmon;
10762306a36Sopenharmony_ci	u32 ast_ani_ofdmoff;
10862306a36Sopenharmony_ci	u32 ast_ani_cckhigh;
10962306a36Sopenharmony_ci	u32 ast_ani_ccklow;
11062306a36Sopenharmony_ci	u32 ast_ani_stepup;
11162306a36Sopenharmony_ci	u32 ast_ani_stepdown;
11262306a36Sopenharmony_ci	u32 ast_ani_ofdmerrs;
11362306a36Sopenharmony_ci	u32 ast_ani_cckerrs;
11462306a36Sopenharmony_ci	u32 ast_ani_reset;
11562306a36Sopenharmony_ci	u32 ast_ani_lneg_or_lzero;
11662306a36Sopenharmony_ci	u32 avgbrssi;
11762306a36Sopenharmony_ci	struct ath9k_mib_stats ast_mibstats;
11862306a36Sopenharmony_ci};
11962306a36Sopenharmony_ci#define ah_mibStats stats.ast_mibstats
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_civoid ath9k_enable_mib_counters(struct ath_hw *ah);
12262306a36Sopenharmony_civoid ath9k_hw_disable_mib_counters(struct ath_hw *ah);
12362306a36Sopenharmony_civoid ath9k_hw_ani_init(struct ath_hw *ah);
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci#endif /* ANI_H */
126