aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath/ath9k/hw.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath/ath9k/hw.h')
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.h290
1 files changed, 161 insertions, 129 deletions
diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
index 399f7c1283cd..4b157c53d1a8 100644
--- a/drivers/net/wireless/ath/ath9k/hw.h
+++ b/drivers/net/wireless/ath/ath9k/hw.h
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2008-2010 Atheros Communications Inc. 2 * Copyright (c) 2008-2011 Atheros Communications Inc.
3 * 3 *
4 * Permission to use, copy, modify, and/or distribute this software for any 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 5 * purpose with or without fee is hereby granted, provided that the above
@@ -30,7 +30,6 @@
30#include "btcoex.h" 30#include "btcoex.h"
31 31
32#include "../regd.h" 32#include "../regd.h"
33#include "../debug.h"
34 33
35#define ATHEROS_VENDOR_ID 0x168c 34#define ATHEROS_VENDOR_ID 0x168c
36 35
@@ -44,6 +43,8 @@
44#define AR9287_DEVID_PCI 0x002d 43#define AR9287_DEVID_PCI 0x002d
45#define AR9287_DEVID_PCIE 0x002e 44#define AR9287_DEVID_PCIE 0x002e
46#define AR9300_DEVID_PCIE 0x0030 45#define AR9300_DEVID_PCIE 0x0030
46#define AR9300_DEVID_AR9340 0x0031
47#define AR9300_DEVID_AR9485_PCIE 0x0032
47 48
48#define AR5416_AR9100_DEVID 0x000b 49#define AR5416_AR9100_DEVID 0x000b
49 50
@@ -55,64 +56,62 @@
55#define AT9285_COEX3WIRE_SA_SUBSYSID 0x30aa 56#define AT9285_COEX3WIRE_SA_SUBSYSID 0x30aa
56#define AT9285_COEX3WIRE_DA_SUBSYSID 0x30ab 57#define AT9285_COEX3WIRE_DA_SUBSYSID 0x30ab
57 58
59#define AR9300_NUM_BT_WEIGHTS 4
60#define AR9300_NUM_WLAN_WEIGHTS 4
61
58#define ATH_AMPDU_LIMIT_MAX (64 * 1024 - 1) 62#define ATH_AMPDU_LIMIT_MAX (64 * 1024 - 1)
59 63
60#define ATH_DEFAULT_NOISE_FLOOR -95 64#define ATH_DEFAULT_NOISE_FLOOR -95
61 65
62#define ATH9K_RSSI_BAD -128 66#define ATH9K_RSSI_BAD -128
63 67
68#define ATH9K_NUM_CHANNELS 38
69
64/* Register read/write primitives */ 70/* Register read/write primitives */
65#define REG_WRITE(_ah, _reg, _val) \ 71#define REG_WRITE(_ah, _reg, _val) \
66 ath9k_hw_common(_ah)->ops->write((_ah), (_val), (_reg)) 72 (_ah)->reg_ops.write((_ah), (_val), (_reg))
67 73
68#define REG_READ(_ah, _reg) \ 74#define REG_READ(_ah, _reg) \
69 ath9k_hw_common(_ah)->ops->read((_ah), (_reg)) 75 (_ah)->reg_ops.read((_ah), (_reg))
70 76
71#define ENABLE_REGWRITE_BUFFER(_ah) \ 77#define REG_READ_MULTI(_ah, _addr, _val, _cnt) \
72 do { \ 78 (_ah)->reg_ops.multi_read((_ah), (_addr), (_val), (_cnt))
73 if (AR_SREV_9271(_ah)) \ 79
74 ath9k_hw_common(_ah)->ops->enable_write_buffer((_ah)); \ 80#define REG_RMW(_ah, _reg, _set, _clr) \
75 } while (0) 81 (_ah)->reg_ops.rmw((_ah), (_reg), (_set), (_clr))
76 82
77#define DISABLE_REGWRITE_BUFFER(_ah) \ 83#define ENABLE_REGWRITE_BUFFER(_ah) \
78 do { \ 84 do { \
79 if (AR_SREV_9271(_ah)) \ 85 if ((_ah)->reg_ops.enable_write_buffer) \
80 ath9k_hw_common(_ah)->ops->disable_write_buffer((_ah)); \ 86 (_ah)->reg_ops.enable_write_buffer((_ah)); \
81 } while (0) 87 } while (0)
82 88
83#define REGWRITE_BUFFER_FLUSH(_ah) \ 89#define REGWRITE_BUFFER_FLUSH(_ah) \
84 do { \ 90 do { \
85 if (AR_SREV_9271(_ah)) \ 91 if ((_ah)->reg_ops.write_flush) \
86 ath9k_hw_common(_ah)->ops->write_flush((_ah)); \ 92 (_ah)->reg_ops.write_flush((_ah)); \
87 } while (0) 93 } while (0)
88 94
89#define SM(_v, _f) (((_v) << _f##_S) & _f) 95#define SM(_v, _f) (((_v) << _f##_S) & _f)
90#define MS(_v, _f) (((_v) & _f) >> _f##_S) 96#define MS(_v, _f) (((_v) & _f) >> _f##_S)
91#define REG_RMW(_a, _r, _set, _clr) \
92 REG_WRITE(_a, _r, (REG_READ(_a, _r) & ~(_clr)) | (_set))
93#define REG_RMW_FIELD(_a, _r, _f, _v) \ 97#define REG_RMW_FIELD(_a, _r, _f, _v) \
94 REG_WRITE(_a, _r, \ 98 REG_RMW(_a, _r, (((_v) << _f##_S) & _f), (_f))
95 (REG_READ(_a, _r) & ~_f) | (((_v) << _f##_S) & _f))
96#define REG_READ_FIELD(_a, _r, _f) \ 99#define REG_READ_FIELD(_a, _r, _f) \
97 (((REG_READ(_a, _r) & _f) >> _f##_S)) 100 (((REG_READ(_a, _r) & _f) >> _f##_S))
98#define REG_SET_BIT(_a, _r, _f) \ 101#define REG_SET_BIT(_a, _r, _f) \
99 REG_WRITE(_a, _r, REG_READ(_a, _r) | _f) 102 REG_RMW(_a, _r, (_f), 0)
100#define REG_CLR_BIT(_a, _r, _f) \ 103#define REG_CLR_BIT(_a, _r, _f) \
101 REG_WRITE(_a, _r, REG_READ(_a, _r) & ~_f) 104 REG_RMW(_a, _r, 0, (_f))
102 105
103#define DO_DELAY(x) do { \ 106#define DO_DELAY(x) do { \
104 if ((++(x) % 64) == 0) \ 107 if (((++(x) % 64) == 0) && \
105 udelay(1); \ 108 (ath9k_hw_common(ah)->bus_ops->ath_bus_type \
109 != ATH_USB)) \
110 udelay(1); \
106 } while (0) 111 } while (0)
107 112
108#define REG_WRITE_ARRAY(iniarray, column, regWr) do { \ 113#define REG_WRITE_ARRAY(iniarray, column, regWr) \
109 int r; \ 114 ath9k_hw_write_array(ah, iniarray, column, &(regWr))
110 for (r = 0; r < ((iniarray)->ia_rows); r++) { \
111 REG_WRITE(ah, INI_RA((iniarray), (r), 0), \
112 INI_RA((iniarray), r, (column))); \
113 DO_DELAY(regWr); \
114 } \
115 } while (0)
116 115
117#define AR_GPIO_OUTPUT_MUX_AS_OUTPUT 0 116#define AR_GPIO_OUTPUT_MUX_AS_OUTPUT 0
118#define AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED 1 117#define AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED 1
@@ -126,7 +125,7 @@
126#define AR_GPIO_BIT(_gpio) (1 << (_gpio)) 125#define AR_GPIO_BIT(_gpio) (1 << (_gpio))
127 126
128#define BASE_ACTIVATE_DELAY 100 127#define BASE_ACTIVATE_DELAY 100
129#define RTC_PLL_SETTLE_DELAY 100 128#define RTC_PLL_SETTLE_DELAY (AR_SREV_9340(ah) ? 1000 : 100)
130#define COEF_SCALE_S 24 129#define COEF_SCALE_S 24
131#define HT40_CHANNEL_CENTER_SHIFT 10 130#define HT40_CHANNEL_CENTER_SHIFT 10
132 131
@@ -161,6 +160,13 @@
161#define PAPRD_GAIN_TABLE_ENTRIES 32 160#define PAPRD_GAIN_TABLE_ENTRIES 32
162#define PAPRD_TABLE_SZ 24 161#define PAPRD_TABLE_SZ 24
163 162
163enum ath_hw_txq_subtype {
164 ATH_TXQ_AC_BE = 0,
165 ATH_TXQ_AC_BK = 1,
166 ATH_TXQ_AC_VI = 2,
167 ATH_TXQ_AC_VO = 3,
168};
169
164enum ath_ini_subsys { 170enum ath_ini_subsys {
165 ATH_INI_PRE = 0, 171 ATH_INI_PRE = 0,
166 ATH_INI_CORE, 172 ATH_INI_CORE,
@@ -168,64 +174,39 @@ enum ath_ini_subsys {
168 ATH_INI_NUM_SPLIT, 174 ATH_INI_NUM_SPLIT,
169}; 175};
170 176
171enum wireless_mode {
172 ATH9K_MODE_11A = 0,
173 ATH9K_MODE_11G,
174 ATH9K_MODE_11NA_HT20,
175 ATH9K_MODE_11NG_HT20,
176 ATH9K_MODE_11NA_HT40PLUS,
177 ATH9K_MODE_11NA_HT40MINUS,
178 ATH9K_MODE_11NG_HT40PLUS,
179 ATH9K_MODE_11NG_HT40MINUS,
180 ATH9K_MODE_MAX,
181};
182
183enum ath9k_hw_caps { 177enum ath9k_hw_caps {
184 ATH9K_HW_CAP_MIC_AESCCM = BIT(0), 178 ATH9K_HW_CAP_HT = BIT(0),
185 ATH9K_HW_CAP_MIC_CKIP = BIT(1), 179 ATH9K_HW_CAP_RFSILENT = BIT(1),
186 ATH9K_HW_CAP_MIC_TKIP = BIT(2), 180 ATH9K_HW_CAP_CST = BIT(2),
187 ATH9K_HW_CAP_CIPHER_AESCCM = BIT(3), 181 ATH9K_HW_CAP_AUTOSLEEP = BIT(4),
188 ATH9K_HW_CAP_CIPHER_CKIP = BIT(4), 182 ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(5),
189 ATH9K_HW_CAP_CIPHER_TKIP = BIT(5), 183 ATH9K_HW_CAP_EDMA = BIT(6),
190 ATH9K_HW_CAP_VEOL = BIT(6), 184 ATH9K_HW_CAP_RAC_SUPPORTED = BIT(7),
191 ATH9K_HW_CAP_BSSIDMASK = BIT(7), 185 ATH9K_HW_CAP_LDPC = BIT(8),
192 ATH9K_HW_CAP_MCAST_KEYSEARCH = BIT(8), 186 ATH9K_HW_CAP_FASTCLOCK = BIT(9),
193 ATH9K_HW_CAP_HT = BIT(9), 187 ATH9K_HW_CAP_SGI_20 = BIT(10),
194 ATH9K_HW_CAP_GTT = BIT(10), 188 ATH9K_HW_CAP_PAPRD = BIT(11),
195 ATH9K_HW_CAP_FASTCC = BIT(11), 189 ATH9K_HW_CAP_ANT_DIV_COMB = BIT(12),
196 ATH9K_HW_CAP_RFSILENT = BIT(12), 190 ATH9K_HW_CAP_2GHZ = BIT(13),
197 ATH9K_HW_CAP_CST = BIT(13), 191 ATH9K_HW_CAP_5GHZ = BIT(14),
198 ATH9K_HW_CAP_ENHANCEDPM = BIT(14), 192 ATH9K_HW_CAP_APM = BIT(15),
199 ATH9K_HW_CAP_AUTOSLEEP = BIT(15),
200 ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(16),
201 ATH9K_HW_CAP_EDMA = BIT(17),
202 ATH9K_HW_CAP_RAC_SUPPORTED = BIT(18),
203 ATH9K_HW_CAP_LDPC = BIT(19),
204 ATH9K_HW_CAP_FASTCLOCK = BIT(20),
205 ATH9K_HW_CAP_SGI_20 = BIT(21),
206 ATH9K_HW_CAP_PAPRD = BIT(22),
207}; 193};
208 194
209struct ath9k_hw_capabilities { 195struct ath9k_hw_capabilities {
210 u32 hw_caps; /* ATH9K_HW_CAP_* from ath9k_hw_caps */ 196 u32 hw_caps; /* ATH9K_HW_CAP_* from ath9k_hw_caps */
211 DECLARE_BITMAP(wireless_modes, ATH9K_MODE_MAX); /* ATH9K_MODE_* */
212 u16 total_queues;
213 u16 keycache_size;
214 u16 low_5ghz_chan, high_5ghz_chan;
215 u16 low_2ghz_chan, high_2ghz_chan;
216 u16 rts_aggr_limit; 197 u16 rts_aggr_limit;
217 u8 tx_chainmask; 198 u8 tx_chainmask;
218 u8 rx_chainmask; 199 u8 rx_chainmask;
219 u16 tx_triglevel_max; 200 u8 max_txchains;
220 u16 reg_cap; 201 u8 max_rxchains;
221 u8 num_gpio_pins; 202 u8 num_gpio_pins;
222 u8 num_antcfg_2ghz;
223 u8 num_antcfg_5ghz;
224 u8 rx_hp_qdepth; 203 u8 rx_hp_qdepth;
225 u8 rx_lp_qdepth; 204 u8 rx_lp_qdepth;
226 u8 rx_status_len; 205 u8 rx_status_len;
227 u8 tx_desc_len; 206 u8 tx_desc_len;
228 u8 txs_len; 207 u8 txs_len;
208 u16 pcie_lcr_offset;
209 bool pcie_lcr_extsync_en;
229}; 210};
230 211
231struct ath9k_ops_config { 212struct ath9k_ops_config {
@@ -239,7 +220,7 @@ struct ath9k_ops_config {
239 u8 pcie_clock_req; 220 u8 pcie_clock_req;
240 u32 pcie_waen; 221 u32 pcie_waen;
241 u8 analog_shiftreg; 222 u8 analog_shiftreg;
242 u8 ht_enable; 223 u8 paprd_disable;
243 u32 ofdm_trig_low; 224 u32 ofdm_trig_low;
244 u32 ofdm_trig_high; 225 u32 ofdm_trig_high;
245 u32 cck_trig_high; 226 u32 cck_trig_high;
@@ -251,7 +232,6 @@ struct ath9k_ops_config {
251#define SPUR_DISABLE 0 232#define SPUR_DISABLE 0
252#define SPUR_ENABLE_IOCTL 1 233#define SPUR_ENABLE_IOCTL 1
253#define SPUR_ENABLE_EEPROM 2 234#define SPUR_ENABLE_EEPROM 2
254#define AR_EEPROM_MODAL_SPURS 5
255#define AR_SPUR_5413_1 1640 235#define AR_SPUR_5413_1 1640
256#define AR_SPUR_5413_2 1200 236#define AR_SPUR_5413_2 1200
257#define AR_NO_SPUR 0x8000 237#define AR_NO_SPUR 0x8000
@@ -352,9 +332,9 @@ struct ath9k_hw_cal_data {
352 int32_t CalValid; 332 int32_t CalValid;
353 int8_t iCoff; 333 int8_t iCoff;
354 int8_t qCoff; 334 int8_t qCoff;
355 int16_t rawNoiseFloor;
356 bool paprd_done; 335 bool paprd_done;
357 bool nfcal_pending; 336 bool nfcal_pending;
337 bool nfcal_interference;
358 u16 small_signal_gain[AR9300_MAX_CHAINS]; 338 u16 small_signal_gain[AR9300_MAX_CHAINS];
359 u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ]; 339 u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ];
360 struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; 340 struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS];
@@ -362,9 +342,11 @@ struct ath9k_hw_cal_data {
362 342
363struct ath9k_channel { 343struct ath9k_channel {
364 struct ieee80211_channel *chan; 344 struct ieee80211_channel *chan;
345 struct ar5416AniState ani;
365 u16 channel; 346 u16 channel;
366 u32 channelFlags; 347 u32 channelFlags;
367 u32 chanmode; 348 u32 chanmode;
349 s16 noisefloor;
368}; 350};
369 351
370#define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \ 352#define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \
@@ -422,8 +404,6 @@ struct ath9k_beacon_state {
422 u32 bs_nextdtim; 404 u32 bs_nextdtim;
423 u32 bs_intval; 405 u32 bs_intval;
424#define ATH9K_BEACON_PERIOD 0x0000ffff 406#define ATH9K_BEACON_PERIOD 0x0000ffff
425#define ATH9K_BEACON_ENA 0x00800000
426#define ATH9K_BEACON_RESET_TSF 0x01000000
427#define ATH9K_TSFOOR_THRESHOLD 0x00004240 /* 16k us */ 407#define ATH9K_TSFOOR_THRESHOLD 0x00004240 /* 16k us */
428 u32 bs_dtimperiod; 408 u32 bs_dtimperiod;
429 u16 bs_cfpperiod; 409 u16 bs_cfpperiod;
@@ -457,6 +437,7 @@ struct ath9k_hw_version {
457 u16 analog5GhzRev; 437 u16 analog5GhzRev;
458 u16 analog2GhzRev; 438 u16 analog2GhzRev;
459 u16 subsysid; 439 u16 subsysid;
440 enum ath_usb_dev usbdev;
460}; 441};
461 442
462/* Generic TSF timer definitions */ 443/* Generic TSF timer definitions */
@@ -494,6 +475,50 @@ struct ath_gen_timer_table {
494 } timer_mask; 475 } timer_mask;
495}; 476};
496 477
478struct ath_hw_antcomb_conf {
479 u8 main_lna_conf;
480 u8 alt_lna_conf;
481 u8 fast_div_bias;
482 u8 main_gaintb;
483 u8 alt_gaintb;
484 int lna1_lna2_delta;
485 u8 div_group;
486};
487
488/**
489 * struct ath_hw_radar_conf - radar detection initialization parameters
490 *
491 * @pulse_inband: threshold for checking the ratio of in-band power
492 * to total power for short radar pulses (half dB steps)
493 * @pulse_inband_step: threshold for checking an in-band power to total
494 * power ratio increase for short radar pulses (half dB steps)
495 * @pulse_height: threshold for detecting the beginning of a short
496 * radar pulse (dB step)
497 * @pulse_rssi: threshold for detecting if a short radar pulse is
498 * gone (dB step)
499 * @pulse_maxlen: maximum pulse length (0.8 us steps)
500 *
501 * @radar_rssi: RSSI threshold for starting long radar detection (dB steps)
502 * @radar_inband: threshold for checking the ratio of in-band power
503 * to total power for long radar pulses (half dB steps)
504 * @fir_power: threshold for detecting the end of a long radar pulse (dB)
505 *
506 * @ext_channel: enable extension channel radar detection
507 */
508struct ath_hw_radar_conf {
509 unsigned int pulse_inband;
510 unsigned int pulse_inband_step;
511 unsigned int pulse_height;
512 unsigned int pulse_rssi;
513 unsigned int pulse_maxlen;
514
515 unsigned int radar_rssi;
516 unsigned int radar_inband;
517 int fir_power;
518
519 bool ext_channel;
520};
521
497/** 522/**
498 * struct ath_hw_private_ops - callbacks used internally by hardware code 523 * struct ath_hw_private_ops - callbacks used internally by hardware code
499 * 524 *
@@ -505,7 +530,6 @@ struct ath_gen_timer_table {
505 * 530 *
506 * @init_mode_regs: Initializes mode registers 531 * @init_mode_regs: Initializes mode registers
507 * @init_mode_gain_regs: Initialize TX/RX gain registers 532 * @init_mode_gain_regs: Initialize TX/RX gain registers
508 * @macversion_supported: If this specific mac revision is supported
509 * 533 *
510 * @rf_set_freq: change frequency 534 * @rf_set_freq: change frequency
511 * @spur_mitigate_freq: spur mitigation 535 * @spur_mitigate_freq: spur mitigation
@@ -517,14 +541,6 @@ struct ath_gen_timer_table {
517 * @setup_calibration: set up calibration 541 * @setup_calibration: set up calibration
518 * @iscal_supported: used to query if a type of calibration is supported 542 * @iscal_supported: used to query if a type of calibration is supported
519 * 543 *
520 * @ani_reset: reset ANI parameters to default values
521 * @ani_lower_immunity: lower the noise immunity level. The level controls
522 * the power-based packet detection on hardware. If a power jump is
523 * detected the adapter takes it as an indication that a packet has
524 * arrived. The level ranges from 0-5. Each level corresponds to a
525 * few dB more of noise immunity. If you have a strong time-varying
526 * interference that is causing false detections (OFDM timing errors or
527 * CCK timing errors) the level can be increased.
528 * @ani_cache_ini_regs: cache the values for ANI from the initial 544 * @ani_cache_ini_regs: cache the values for ANI from the initial
529 * register settings through the register initialization. 545 * register settings through the register initialization.
530 */ 546 */
@@ -535,11 +551,8 @@ struct ath_hw_private_ops {
535 551
536 void (*init_mode_regs)(struct ath_hw *ah); 552 void (*init_mode_regs)(struct ath_hw *ah);
537 void (*init_mode_gain_regs)(struct ath_hw *ah); 553 void (*init_mode_gain_regs)(struct ath_hw *ah);
538 bool (*macversion_supported)(u32 macversion);
539 void (*setup_calibration)(struct ath_hw *ah, 554 void (*setup_calibration)(struct ath_hw *ah,
540 struct ath9k_cal_list *currCal); 555 struct ath9k_cal_list *currCal);
541 bool (*iscal_supported)(struct ath_hw *ah,
542 enum ath9k_cal_types calType);
543 556
544 /* PHY ops */ 557 /* PHY ops */
545 int (*rf_set_freq)(struct ath_hw *ah, 558 int (*rf_set_freq)(struct ath_hw *ah,
@@ -561,7 +574,6 @@ struct ath_hw_private_ops {
561 void (*set_delta_slope)(struct ath_hw *ah, struct ath9k_channel *chan); 574 void (*set_delta_slope)(struct ath_hw *ah, struct ath9k_channel *chan);
562 bool (*rfbus_req)(struct ath_hw *ah); 575 bool (*rfbus_req)(struct ath_hw *ah);
563 void (*rfbus_done)(struct ath_hw *ah); 576 void (*rfbus_done)(struct ath_hw *ah);
564 void (*enable_rfkill)(struct ath_hw *ah);
565 void (*restore_chainmask)(struct ath_hw *ah); 577 void (*restore_chainmask)(struct ath_hw *ah);
566 void (*set_diversity)(struct ath_hw *ah, bool value); 578 void (*set_diversity)(struct ath_hw *ah, bool value);
567 u32 (*compute_pll_control)(struct ath_hw *ah, 579 u32 (*compute_pll_control)(struct ath_hw *ah,
@@ -569,10 +581,10 @@ struct ath_hw_private_ops {
569 bool (*ani_control)(struct ath_hw *ah, enum ath9k_ani_cmd cmd, 581 bool (*ani_control)(struct ath_hw *ah, enum ath9k_ani_cmd cmd,
570 int param); 582 int param);
571 void (*do_getnf)(struct ath_hw *ah, int16_t nfarray[NUM_NF_READINGS]); 583 void (*do_getnf)(struct ath_hw *ah, int16_t nfarray[NUM_NF_READINGS]);
584 void (*set_radar_params)(struct ath_hw *ah,
585 struct ath_hw_radar_conf *conf);
572 586
573 /* ANI */ 587 /* ANI */
574 void (*ani_reset)(struct ath_hw *ah, bool is_scanning);
575 void (*ani_lower_immunity)(struct ath_hw *ah);
576 void (*ani_cache_ini_regs)(struct ath_hw *ah); 588 void (*ani_cache_ini_regs)(struct ath_hw *ah);
577}; 589};
578 590
@@ -584,11 +596,6 @@ struct ath_hw_private_ops {
584 * 596 *
585 * @config_pci_powersave: 597 * @config_pci_powersave:
586 * @calibrate: periodic calibration for NF, ANI, IQ, ADC gain, ADC-DC 598 * @calibrate: periodic calibration for NF, ANI, IQ, ADC gain, ADC-DC
587 *
588 * @ani_proc_mib_event: process MIB events, this would happen upon specific ANI
589 * thresholds being reached or having overflowed.
590 * @ani_monitor: called periodically by the core driver to collect
591 * MIB stats and adjust ANI if specific thresholds have been reached.
592 */ 599 */
593struct ath_hw_ops { 600struct ath_hw_ops {
594 void (*config_pci_powersave)(struct ath_hw *ah, 601 void (*config_pci_powersave)(struct ath_hw *ah,
@@ -625,13 +632,12 @@ struct ath_hw_ops {
625 u32 numDelims); 632 u32 numDelims);
626 void (*set11n_aggr_last)(struct ath_hw *ah, void *ds); 633 void (*set11n_aggr_last)(struct ath_hw *ah, void *ds);
627 void (*clr11n_aggr)(struct ath_hw *ah, void *ds); 634 void (*clr11n_aggr)(struct ath_hw *ah, void *ds);
628 void (*set11n_burstduration)(struct ath_hw *ah, void *ds, 635 void (*set_clrdmask)(struct ath_hw *ah, void *ds, bool val);
629 u32 burstDuration); 636 void (*antdiv_comb_conf_get)(struct ath_hw *ah,
630 void (*set11n_virtualmorefrag)(struct ath_hw *ah, void *ds, 637 struct ath_hw_antcomb_conf *antconf);
631 u32 vmf); 638 void (*antdiv_comb_conf_set)(struct ath_hw *ah,
639 struct ath_hw_antcomb_conf *antconf);
632 640
633 void (*ani_proc_mib_event)(struct ath_hw *ah);
634 void (*ani_monitor)(struct ath_hw *ah, struct ath9k_channel *chan);
635}; 641};
636 642
637struct ath_nf_limits { 643struct ath_nf_limits {
@@ -640,13 +646,19 @@ struct ath_nf_limits {
640 s16 nominal; 646 s16 nominal;
641}; 647};
642 648
649/* ah_flags */
650#define AH_USE_EEPROM 0x1
651#define AH_UNPLUGGED 0x2 /* The card has been physically removed. */
652
643struct ath_hw { 653struct ath_hw {
654 struct ath_ops reg_ops;
655
644 struct ieee80211_hw *hw; 656 struct ieee80211_hw *hw;
645 struct ath_common common; 657 struct ath_common common;
646 struct ath9k_hw_version hw_version; 658 struct ath9k_hw_version hw_version;
647 struct ath9k_ops_config config; 659 struct ath9k_ops_config config;
648 struct ath9k_hw_capabilities caps; 660 struct ath9k_hw_capabilities caps;
649 struct ath9k_channel channels[38]; 661 struct ath9k_channel channels[ATH9K_NUM_CHANNELS];
650 struct ath9k_channel *curchan; 662 struct ath9k_channel *curchan;
651 663
652 union { 664 union {
@@ -659,6 +671,7 @@ struct ath_hw {
659 671
660 bool sw_mgmt_crypto; 672 bool sw_mgmt_crypto;
661 bool is_pciexpress; 673 bool is_pciexpress;
674 bool is_monitoring;
662 bool need_an_top2_fixup; 675 bool need_an_top2_fixup;
663 u16 tx_trig_level; 676 u16 tx_trig_level;
664 677
@@ -692,10 +705,9 @@ struct ath_hw {
692 u32 atim_window; 705 u32 atim_window;
693 706
694 /* Calibration */ 707 /* Calibration */
695 enum ath9k_cal_types supp_cals; 708 u32 supp_cals;
696 struct ath9k_cal_list iq_caldata; 709 struct ath9k_cal_list iq_caldata;
697 struct ath9k_cal_list adcgain_caldata; 710 struct ath9k_cal_list adcgain_caldata;
698 struct ath9k_cal_list adcdc_calinitdata;
699 struct ath9k_cal_list adcdc_caldata; 711 struct ath9k_cal_list adcdc_caldata;
700 struct ath9k_cal_list tempCompCalData; 712 struct ath9k_cal_list tempCompCalData;
701 struct ath9k_cal_list *cal_list; 713 struct ath9k_cal_list *cal_list;
@@ -755,17 +767,13 @@ struct ath_hw {
755 u32 *bank6Temp; 767 u32 *bank6Temp;
756 768
757 u8 txpower_limit; 769 u8 txpower_limit;
758 int16_t txpower_indexoffset;
759 int coverage_class; 770 int coverage_class;
760 u32 beacon_interval;
761 u32 slottime; 771 u32 slottime;
762 u32 globaltxtimeout; 772 u32 globaltxtimeout;
763 773
764 /* ANI */ 774 /* ANI */
765 u32 proc_phyerr; 775 u32 proc_phyerr;
766 u32 aniperiod; 776 u32 aniperiod;
767 struct ar5416AniState *curani;
768 struct ar5416AniState ani[255];
769 int totalSizeDesired[5]; 777 int totalSizeDesired[5];
770 int coarse_high[5]; 778 int coarse_high[5];
771 int coarse_low[5]; 779 int coarse_low[5];
@@ -774,15 +782,21 @@ struct ath_hw {
774 782
775 /* Bluetooth coexistance */ 783 /* Bluetooth coexistance */
776 struct ath_btcoex_hw btcoex_hw; 784 struct ath_btcoex_hw btcoex_hw;
785 u32 bt_coex_bt_weight[AR9300_NUM_BT_WEIGHTS];
786 u32 bt_coex_wlan_weight[AR9300_NUM_WLAN_WEIGHTS];
777 787
778 u32 intr_txqs; 788 u32 intr_txqs;
779 u8 txchainmask; 789 u8 txchainmask;
780 u8 rxchainmask; 790 u8 rxchainmask;
781 791
792 struct ath_hw_radar_conf radar_conf;
793
782 u32 originalGain[22]; 794 u32 originalGain[22];
783 int initPDADC; 795 int initPDADC;
784 int PDADCdelta; 796 int PDADCdelta;
785 u8 led_pin; 797 int led_pin;
798 u32 gpio_mask;
799 u32 gpio_val;
786 800
787 struct ar5416IniArray iniModes; 801 struct ar5416IniArray iniModes;
788 struct ar5416IniArray iniCommon; 802 struct ar5416IniArray iniCommon;
@@ -798,6 +812,7 @@ struct ath_hw {
798 struct ar5416IniArray iniPcieSerdes; 812 struct ar5416IniArray iniPcieSerdes;
799 struct ar5416IniArray iniPcieSerdesLowPower; 813 struct ar5416IniArray iniPcieSerdesLowPower;
800 struct ar5416IniArray iniModesAdditional; 814 struct ar5416IniArray iniModesAdditional;
815 struct ar5416IniArray iniModesAdditional_40M;
801 struct ar5416IniArray iniModesRxGain; 816 struct ar5416IniArray iniModesRxGain;
802 struct ar5416IniArray iniModesTxGain; 817 struct ar5416IniArray iniModesTxGain;
803 struct ar5416IniArray iniModes_9271_1_0_only; 818 struct ar5416IniArray iniModes_9271_1_0_only;
@@ -827,7 +842,13 @@ struct ath_hw {
827 842
828 u32 bb_watchdog_last_status; 843 u32 bb_watchdog_last_status;
829 u32 bb_watchdog_timeout_ms; /* in ms, 0 to disable */ 844 u32 bb_watchdog_timeout_ms; /* in ms, 0 to disable */
845 u8 bb_hang_rx_ofdm; /* true if bb hang due to rx_ofdm */
830 846
847 unsigned int paprd_target_power;
848 unsigned int paprd_training_power;
849 unsigned int paprd_ratemask;
850 unsigned int paprd_ratemask_ht40;
851 bool paprd_table_write_done;
831 u32 paprd_gain_table_entries[PAPRD_GAIN_TABLE_ENTRIES]; 852 u32 paprd_gain_table_entries[PAPRD_GAIN_TABLE_ENTRIES];
832 u8 paprd_gain_table_index[PAPRD_GAIN_TABLE_ENTRIES]; 853 u8 paprd_gain_table_index[PAPRD_GAIN_TABLE_ENTRIES];
833 /* 854 /*
@@ -836,6 +857,19 @@ struct ath_hw {
836 * this register when in sleep states. 857 * this register when in sleep states.
837 */ 858 */
838 u32 WARegVal; 859 u32 WARegVal;
860
861 /* Enterprise mode cap */
862 u32 ent_mode;
863
864 bool is_clk_25mhz;
865};
866
867struct ath_bus_ops {
868 enum ath_bus_type ath_bus_type;
869 void (*read_cachesize)(struct ath_common *common, int *csz);
870 bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
871 void (*bt_coex_prep)(struct ath_common *common);
872 void (*extn_synch_en)(struct ath_common *common);
839}; 873};
840 874
841static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah) 875static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah)
@@ -858,10 +892,9 @@ static inline struct ath_hw_ops *ath9k_hw_ops(struct ath_hw *ah)
858 return &ah->ops; 892 return &ah->ops;
859} 893}
860 894
861static inline int sign_extend(int val, const int nbits) 895static inline u8 get_streams(int mask)
862{ 896{
863 int order = BIT(nbits-1); 897 return !!(mask & BIT(0)) + !!(mask & BIT(1)) + !!(mask & BIT(2));
864 return (val ^ order) - order;
865} 898}
866 899
867/* Initialization, Detach, Reset */ 900/* Initialization, Detach, Reset */
@@ -873,12 +906,6 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan,
873int ath9k_hw_fill_cap_info(struct ath_hw *ah); 906int ath9k_hw_fill_cap_info(struct ath_hw *ah);
874u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan); 907u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan);
875 908
876/* Key Cache Management */
877bool ath9k_hw_keyreset(struct ath_hw *ah, u16 entry);
878bool ath9k_hw_set_keycache_entry(struct ath_hw *ah, u16 entry,
879 const struct ath9k_keyval *k,
880 const u8 *mac);
881
882/* GPIO / RFKILL / Antennae */ 909/* GPIO / RFKILL / Antennae */
883void ath9k_hw_cfg_gpio_input(struct ath_hw *ah, u32 gpio); 910void ath9k_hw_cfg_gpio_input(struct ath_hw *ah, u32 gpio);
884u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio); 911u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio);
@@ -890,8 +917,9 @@ void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna);
890 917
891/* General Operation */ 918/* General Operation */
892bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout); 919bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout);
920void ath9k_hw_write_array(struct ath_hw *ah, struct ar5416IniArray *array,
921 int column, unsigned int *writecnt);
893u32 ath9k_hw_reverse_bits(u32 val, u32 n); 922u32 ath9k_hw_reverse_bits(u32 val, u32 n);
894bool ath9k_get_channel_edges(struct ath_hw *ah, u16 flags, u16 *low, u16 *high);
895u16 ath9k_hw_computetxtime(struct ath_hw *ah, 923u16 ath9k_hw_computetxtime(struct ath_hw *ah,
896 u8 phy, int kbps, 924 u8 phy, int kbps,
897 u32 frameLen, u16 rateix, bool shortPreamble); 925 u32 frameLen, u16 rateix, bool shortPreamble);
@@ -902,16 +930,18 @@ u32 ath9k_hw_getrxfilter(struct ath_hw *ah);
902void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits); 930void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits);
903bool ath9k_hw_phy_disable(struct ath_hw *ah); 931bool ath9k_hw_phy_disable(struct ath_hw *ah);
904bool ath9k_hw_disable(struct ath_hw *ah); 932bool ath9k_hw_disable(struct ath_hw *ah);
905void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit); 933void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test);
906void ath9k_hw_setopmode(struct ath_hw *ah); 934void ath9k_hw_setopmode(struct ath_hw *ah);
907void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1); 935void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1);
908void ath9k_hw_setbssidmask(struct ath_hw *ah); 936void ath9k_hw_setbssidmask(struct ath_hw *ah);
909void ath9k_hw_write_associd(struct ath_hw *ah); 937void ath9k_hw_write_associd(struct ath_hw *ah);
938u32 ath9k_hw_gettsf32(struct ath_hw *ah);
910u64 ath9k_hw_gettsf64(struct ath_hw *ah); 939u64 ath9k_hw_gettsf64(struct ath_hw *ah);
911void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64); 940void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64);
912void ath9k_hw_reset_tsf(struct ath_hw *ah); 941void ath9k_hw_reset_tsf(struct ath_hw *ah);
913void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting); 942void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting);
914void ath9k_hw_init_global_settings(struct ath_hw *ah); 943void ath9k_hw_init_global_settings(struct ath_hw *ah);
944u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah);
915void ath9k_hw_set11nmac2040(struct ath_hw *ah); 945void ath9k_hw_set11nmac2040(struct ath_hw *ah);
916void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period); 946void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period);
917void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, 947void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah,
@@ -934,7 +964,6 @@ void ath9k_hw_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer);
934 964
935void ath_gen_timer_free(struct ath_hw *ah, struct ath_gen_timer *timer); 965void ath_gen_timer_free(struct ath_hw *ah, struct ath_gen_timer *timer);
936void ath_gen_timer_isr(struct ath_hw *hw); 966void ath_gen_timer_isr(struct ath_hw *hw);
937u32 ath9k_hw_gettsf32(struct ath_hw *ah);
938 967
939void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len); 968void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len);
940 969
@@ -962,6 +991,7 @@ void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah);
962void ar9003_hw_bb_watchdog_config(struct ath_hw *ah); 991void ar9003_hw_bb_watchdog_config(struct ath_hw *ah);
963void ar9003_hw_bb_watchdog_read(struct ath_hw *ah); 992void ar9003_hw_bb_watchdog_read(struct ath_hw *ah);
964void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah); 993void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah);
994void ar9003_hw_disable_phy_restart(struct ath_hw *ah);
965void ar9003_paprd_enable(struct ath_hw *ah, bool val); 995void ar9003_paprd_enable(struct ath_hw *ah, bool val);
966void ar9003_paprd_populate_single_table(struct ath_hw *ah, 996void ar9003_paprd_populate_single_table(struct ath_hw *ah,
967 struct ath9k_hw_cal_data *caldata, 997 struct ath9k_hw_cal_data *caldata,
@@ -984,6 +1014,7 @@ void ar9003_hw_attach_calib_ops(struct ath_hw *ah);
984void ar9002_hw_attach_ops(struct ath_hw *ah); 1014void ar9002_hw_attach_ops(struct ath_hw *ah);
985void ar9003_hw_attach_ops(struct ath_hw *ah); 1015void ar9003_hw_attach_ops(struct ath_hw *ah);
986 1016
1017void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan);
987/* 1018/*
988 * ANI work can be shared between all families but a next 1019 * ANI work can be shared between all families but a next
989 * generation implementation of ANI will be used only for AR9003 only 1020 * generation implementation of ANI will be used only for AR9003 only
@@ -992,8 +1023,9 @@ void ar9003_hw_attach_ops(struct ath_hw *ah);
992 * older families (AR5008, AR9001, AR9002) by using modparam_force_new_ani. 1023 * older families (AR5008, AR9001, AR9002) by using modparam_force_new_ani.
993 */ 1024 */
994extern int modparam_force_new_ani; 1025extern int modparam_force_new_ani;
995void ath9k_hw_attach_ani_ops_old(struct ath_hw *ah); 1026void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning);
996void ath9k_hw_attach_ani_ops_new(struct ath_hw *ah); 1027void ath9k_hw_proc_mib_event(struct ath_hw *ah);
1028void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan);
997 1029
998#define ATH_PCIE_CAP_LINK_CTRL 0x70 1030#define ATH_PCIE_CAP_LINK_CTRL 0x70
999#define ATH_PCIE_CAP_LINK_L0S 1 1031#define ATH_PCIE_CAP_LINK_L0S 1