28 #include <linux/types.h>
46 #define PCI_DEVICE_ID_ATHEROS_AR5210 0x0007
47 #define PCI_DEVICE_ID_ATHEROS_AR5311 0x0011
48 #define PCI_DEVICE_ID_ATHEROS_AR5211 0x0012
49 #define PCI_DEVICE_ID_ATHEROS_AR5212 0x0013
50 #define PCI_DEVICE_ID_3COM_3CRDAG675 0x0013
51 #define PCI_DEVICE_ID_3COM_2_3CRPAG175 0x0013
52 #define PCI_DEVICE_ID_ATHEROS_AR5210_AP 0x0207
53 #define PCI_DEVICE_ID_ATHEROS_AR5212_IBM 0x1014
54 #define PCI_DEVICE_ID_ATHEROS_AR5210_DEFAULT 0x1107
55 #define PCI_DEVICE_ID_ATHEROS_AR5212_DEFAULT 0x1113
56 #define PCI_DEVICE_ID_ATHEROS_AR5211_DEFAULT 0x1112
57 #define PCI_DEVICE_ID_ATHEROS_AR5212_FPGA 0xf013
58 #define PCI_DEVICE_ID_ATHEROS_AR5211_LEGACY 0xff12
59 #define PCI_DEVICE_ID_ATHEROS_AR5211_FPGA11B 0xf11b
60 #define PCI_DEVICE_ID_ATHEROS_AR5312_REV2 0x0052
61 #define PCI_DEVICE_ID_ATHEROS_AR5312_REV7 0x0057
62 #define PCI_DEVICE_ID_ATHEROS_AR5312_REV8 0x0058
63 #define PCI_DEVICE_ID_ATHEROS_AR5212_0014 0x0014
64 #define PCI_DEVICE_ID_ATHEROS_AR5212_0015 0x0015
65 #define PCI_DEVICE_ID_ATHEROS_AR5212_0016 0x0016
66 #define PCI_DEVICE_ID_ATHEROS_AR5212_0017 0x0017
67 #define PCI_DEVICE_ID_ATHEROS_AR5212_0018 0x0018
68 #define PCI_DEVICE_ID_ATHEROS_AR5212_0019 0x0019
69 #define PCI_DEVICE_ID_ATHEROS_AR2413 0x001a
70 #define PCI_DEVICE_ID_ATHEROS_AR5413 0x001b
71 #define PCI_DEVICE_ID_ATHEROS_AR5424 0x001c
72 #define PCI_DEVICE_ID_ATHEROS_AR5416 0x0023
73 #define PCI_DEVICE_ID_ATHEROS_AR5418 0x0024
79 #define ATH5K_PRINTF(fmt, ...) \
80 pr_warn("%s: " fmt, __func__, ##__VA_ARGS__)
86 #define ATH5K_PRINTK(_sc, _level, _fmt, ...) \
87 _ath5k_printk(_sc, _level, _fmt, ##__VA_ARGS__)
89 #define ATH5K_PRINTK_LIMIT(_sc, _level, _fmt, ...) \
91 if (net_ratelimit()) \
92 ATH5K_PRINTK(_sc, _level, _fmt, ##__VA_ARGS__); \
95 #define ATH5K_INFO(_sc, _fmt, ...) \
96 ATH5K_PRINTK(_sc, KERN_INFO, _fmt, ##__VA_ARGS__)
98 #define ATH5K_WARN(_sc, _fmt, ...) \
99 ATH5K_PRINTK_LIMIT(_sc, KERN_WARNING, _fmt, ##__VA_ARGS__)
101 #define ATH5K_ERR(_sc, _fmt, ...) \
102 ATH5K_PRINTK_LIMIT(_sc, KERN_ERR, _fmt, ##__VA_ARGS__)
111 #define AR5K_REG_SM(_val, _flags) \
112 (((_val) << _flags##_S) & (_flags))
115 #define AR5K_REG_MS(_val, _flags) \
116 (((_val) & (_flags)) >> _flags##_S)
123 #define AR5K_REG_WRITE_BITS(ah, _reg, _flags, _val) \
124 ath5k_hw_reg_write(ah, (ath5k_hw_reg_read(ah, _reg) & ~(_flags)) | \
125 (((_val) << _flags##_S) & (_flags)), _reg)
127 #define AR5K_REG_MASKED_BITS(ah, _reg, _flags, _mask) \
128 ath5k_hw_reg_write(ah, (ath5k_hw_reg_read(ah, _reg) & \
129 (_mask)) | (_flags), _reg)
131 #define AR5K_REG_ENABLE_BITS(ah, _reg, _flags) \
132 ath5k_hw_reg_write(ah, ath5k_hw_reg_read(ah, _reg) | (_flags), _reg)
134 #define AR5K_REG_DISABLE_BITS(ah, _reg, _flags) \
135 ath5k_hw_reg_write(ah, ath5k_hw_reg_read(ah, _reg) & ~(_flags), _reg)
138 #define AR5K_REG_READ_Q(ah, _reg, _queue) \
139 (ath5k_hw_reg_read(ah, _reg) & (1 << _queue)) \
141 #define AR5K_REG_WRITE_Q(ah, _reg, _queue) \
142 ath5k_hw_reg_write(ah, (1 << _queue), _reg)
144 #define AR5K_Q_ENABLE_BITS(_reg, _queue) do { \
145 _reg |= 1 << _queue; \
148 #define AR5K_Q_DISABLE_BITS(_reg, _queue) do { \
149 _reg &= ~(1 << _queue); \
153 #define AR5K_REG_WAIT(_i) do { \
162 #define AR5K_TUNE_DMA_BEACON_RESP 2
163 #define AR5K_TUNE_SW_BEACON_RESP 10
164 #define AR5K_TUNE_ADDITIONAL_SWBA_BACKOFF 0
165 #define AR5K_TUNE_MIN_TX_FIFO_THRES 1
166 #define AR5K_TUNE_MAX_TX_FIFO_THRES ((IEEE80211_MAX_FRAME_LEN / 64) + 1)
167 #define AR5K_TUNE_REGISTER_TIMEOUT 20000
170 #define AR5K_TUNE_RSSI_THRES 129
176 #define AR5K_TUNE_BMISS_THRES 7
177 #define AR5K_TUNE_REGISTER_DWELL_TIME 20000
178 #define AR5K_TUNE_BEACON_INTERVAL 100
179 #define AR5K_TUNE_AIFS 2
180 #define AR5K_TUNE_AIFS_11B 2
181 #define AR5K_TUNE_AIFS_XR 0
182 #define AR5K_TUNE_CWMIN 15
183 #define AR5K_TUNE_CWMIN_11B 31
184 #define AR5K_TUNE_CWMIN_XR 3
185 #define AR5K_TUNE_CWMAX 1023
186 #define AR5K_TUNE_CWMAX_11B 1023
187 #define AR5K_TUNE_CWMAX_XR 7
188 #define AR5K_TUNE_NOISE_FLOOR -72
189 #define AR5K_TUNE_CCA_MAX_GOOD_VALUE -95
190 #define AR5K_TUNE_MAX_TXPOWER 63
191 #define AR5K_TUNE_DEFAULT_TXPOWER 25
192 #define AR5K_TUNE_TPC_TXPOWER false
193 #define ATH5K_TUNE_CALIBRATION_INTERVAL_FULL 60000
194 #define ATH5K_TUNE_CALIBRATION_INTERVAL_SHORT 10000
195 #define ATH5K_TUNE_CALIBRATION_INTERVAL_ANI 1000
196 #define ATH5K_TX_COMPLETE_POLL_INT 3000
198 #define AR5K_INIT_CARR_SENSE_EN 1
201 #if defined(__BIG_ENDIAN)
202 #define AR5K_INIT_CFG ( \
203 AR5K_CFG_SWTD | AR5K_CFG_SWRD \
206 #define AR5K_INIT_CFG 0x00000000
210 #define AR5K_INIT_CYCRSSI_THR1 2
213 #define AR5K_INIT_RETRY_SHORT 7
214 #define AR5K_INIT_RETRY_LONG 4
217 #define AR5K_INIT_SLOT_TIME_TURBO 6
218 #define AR5K_INIT_SLOT_TIME_DEFAULT 9
219 #define AR5K_INIT_SLOT_TIME_HALF_RATE 13
220 #define AR5K_INIT_SLOT_TIME_QUARTER_RATE 21
221 #define AR5K_INIT_SLOT_TIME_B 20
222 #define AR5K_SLOT_TIME_MAX 0xffff
225 #define AR5K_INIT_SIFS_TURBO 6
226 #define AR5K_INIT_SIFS_DEFAULT_BG 10
227 #define AR5K_INIT_SIFS_DEFAULT_A 16
228 #define AR5K_INIT_SIFS_HALF_RATE 32
229 #define AR5K_INIT_SIFS_QUARTER_RATE 64
234 #define AR5K_INIT_OFDM_PREAMPLE_TIME 20
236 #define AR5K_INIT_OFDM_PREAMBLE_TIME_MIN 14
237 #define AR5K_INIT_OFDM_SYMBOL_TIME 4
238 #define AR5K_INIT_OFDM_PLCP_BITS 22
241 #define AR5K_INIT_RX_LAT_MAX 63
244 #define AR5K_INIT_TX_LAT_A 54
245 #define AR5K_INIT_TX_LAT_BG 384
247 #define AR5K_INIT_TX_LAT_MIN 32
249 #define AR5K_INIT_TX_LATENCY_5210 54
250 #define AR5K_INIT_RX_LATENCY_5210 29
253 #define AR5K_INIT_TXF2TXD_START_DEFAULT 14
254 #define AR5K_INIT_TXF2TXD_START_DELAY_10MHZ 12
255 #define AR5K_INIT_TXF2TXD_START_DELAY_5MHZ 13
259 #define AR5K_SWITCH_SETTLING 5760
260 #define AR5K_SWITCH_SETTLING_TURBO 7168
262 #define AR5K_AGC_SETTLING 28
264 #define AR5K_AGC_SETTLING_TURBO 37
310 #define AR5K_SREV_UNKNOWN 0xffff
312 #define AR5K_SREV_AR5210 0x00
313 #define AR5K_SREV_AR5311 0x10
314 #define AR5K_SREV_AR5311A 0x20
315 #define AR5K_SREV_AR5311B 0x30
316 #define AR5K_SREV_AR5211 0x40
317 #define AR5K_SREV_AR5212 0x50
318 #define AR5K_SREV_AR5312_R2 0x52
319 #define AR5K_SREV_AR5212_V4 0x54
320 #define AR5K_SREV_AR5213 0x55
321 #define AR5K_SREV_AR5312_R7 0x57
322 #define AR5K_SREV_AR2313_R8 0x58
323 #define AR5K_SREV_AR5213A 0x59
324 #define AR5K_SREV_AR2413 0x78
325 #define AR5K_SREV_AR2414 0x70
326 #define AR5K_SREV_AR2315_R6 0x86
327 #define AR5K_SREV_AR2315_R7 0x87
328 #define AR5K_SREV_AR5424 0x90
329 #define AR5K_SREV_AR2317_R1 0x90
330 #define AR5K_SREV_AR2317_R2 0x91
331 #define AR5K_SREV_AR5413 0xa4
332 #define AR5K_SREV_AR5414 0xa0
333 #define AR5K_SREV_AR2415 0xb0
334 #define AR5K_SREV_AR5416 0xc0
335 #define AR5K_SREV_AR5418 0xca
336 #define AR5K_SREV_AR2425 0xe0
337 #define AR5K_SREV_AR2417 0xf0
339 #define AR5K_SREV_RAD_5110 0x00
340 #define AR5K_SREV_RAD_5111 0x10
341 #define AR5K_SREV_RAD_5111A 0x15
342 #define AR5K_SREV_RAD_2111 0x20
343 #define AR5K_SREV_RAD_5112 0x30
344 #define AR5K_SREV_RAD_5112A 0x35
345 #define AR5K_SREV_RAD_5112B 0x36
346 #define AR5K_SREV_RAD_2112 0x40
347 #define AR5K_SREV_RAD_2112A 0x45
348 #define AR5K_SREV_RAD_2112B 0x46
349 #define AR5K_SREV_RAD_2413 0x50
350 #define AR5K_SREV_RAD_5413 0x60
351 #define AR5K_SREV_RAD_2316 0x70
352 #define AR5K_SREV_RAD_2317 0x80
353 #define AR5K_SREV_RAD_5424 0xa0
354 #define AR5K_SREV_RAD_2425 0xa2
355 #define AR5K_SREV_RAD_5133 0xc0
357 #define AR5K_SREV_PHY_5211 0x30
358 #define AR5K_SREV_PHY_5212 0x41
359 #define AR5K_SREV_PHY_5212A 0x42
360 #define AR5K_SREV_PHY_5212B 0x43
361 #define AR5K_SREV_PHY_2413 0x45
362 #define AR5K_SREV_PHY_5413 0x61
363 #define AR5K_SREV_PHY_2425 0x70
525 #define AR5K_TXSTAT_ALTRATE 0x80
526 #define AR5K_TXERR_XRETRY 0x01
527 #define AR5K_TXERR_FILT 0x02
528 #define AR5K_TXERR_FIFO 0x04
546 #define AR5K_NUM_TX_QUEUES 10
547 #define AR5K_NUM_TX_QUEUES_NOQCU 2
594 #define AR5K_TXQ_FLAG_TXOKINT_ENABLE 0x0001
595 #define AR5K_TXQ_FLAG_TXERRINT_ENABLE 0x0002
596 #define AR5K_TXQ_FLAG_TXEOLINT_ENABLE 0x0004
597 #define AR5K_TXQ_FLAG_TXDESCINT_ENABLE 0x0008
598 #define AR5K_TXQ_FLAG_TXURNINT_ENABLE 0x0010
599 #define AR5K_TXQ_FLAG_CBRORNINT_ENABLE 0x0020
600 #define AR5K_TXQ_FLAG_CBRURNINT_ENABLE 0x0040
601 #define AR5K_TXQ_FLAG_QTRIGINT_ENABLE 0x0080
602 #define AR5K_TXQ_FLAG_TXNOFRMINT_ENABLE 0x0100
603 #define AR5K_TXQ_FLAG_BACKOFF_DISABLE 0x0200
604 #define AR5K_TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE 0x0300
605 #define AR5K_TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE 0x0800
606 #define AR5K_TXQ_FLAG_POST_FR_BKOFF_DIS 0x1000
607 #define AR5K_TXQ_FLAG_COMPRESSION_ENABLE 0x2000
686 #define AR5K_TXPOWER_OFDM(_r, _v) ( \
687 ((0 & 1) << ((_v) + 6)) | \
688 (((ah->ah_txpower.txp_rates_power_table[(_r)]) & 0x3f) << (_v)) \
691 #define AR5K_TXPOWER_CCK(_r, _v) ( \
692 (ah->ah_txpower.txp_rates_power_table[(_r)] & 0x3f) << (_v) \
725 #define AR5K_RXERR_CRC 0x01
726 #define AR5K_RXERR_PHY 0x02
727 #define AR5K_RXERR_FIFO 0x04
728 #define AR5K_RXERR_DECRYPT 0x08
729 #define AR5K_RXERR_MIC 0x10
730 #define AR5K_RXKEYIX_INVALID ((u8) -1)
731 #define AR5K_TXKEYIX_INVALID ((u32) -1)
738 #define AR5K_BEACON_PERIOD 0x0000ffff
739 #define AR5K_BEACON_ENA 0x00800000
740 #define AR5K_BEACON_RESET_TSF 0x01000000
750 #define TSF_TO_TU(_tsf) (u32)((_tsf) >> 10)
798 #define AR5K_SLOT_TIME_9 396
799 #define AR5K_SLOT_TIME_20 880
800 #define AR5K_SLOT_TIME_MAX 0xffff
894 #define AR5K_MAX_RATES 32
897 #define ATH5K_RATE_CODE_1M 0x1B
898 #define ATH5K_RATE_CODE_2M 0x1A
899 #define ATH5K_RATE_CODE_5_5M 0x19
900 #define ATH5K_RATE_CODE_11M 0x18
902 #define ATH5K_RATE_CODE_6M 0x0B
903 #define ATH5K_RATE_CODE_9M 0x0F
904 #define ATH5K_RATE_CODE_12M 0x0A
905 #define ATH5K_RATE_CODE_18M 0x0E
906 #define ATH5K_RATE_CODE_24M 0x09
907 #define ATH5K_RATE_CODE_36M 0x0D
908 #define ATH5K_RATE_CODE_48M 0x08
909 #define ATH5K_RATE_CODE_54M 0x0C
913 #define AR5K_SET_SHORT_PREAMBLE 0x04
919 #define AR5K_KEYCACHE_SIZE 8
929 #define AR5K_RSSI_EP_MULTIPLIER (1 << 7)
931 #define AR5K_ASSERT_ENTRY(_e, _s) do { \
1120 #define AR5K_LED_INIT 0
1121 #define AR5K_LED_SCAN 1
1122 #define AR5K_LED_AUTH 2
1123 #define AR5K_LED_ASSOC 3
1124 #define AR5K_LED_RUN 4
1127 #define AR5K_SOFTLED_PIN 0
1128 #define AR5K_SOFTLED_ON 0
1129 #define AR5K_SOFTLED_OFF 1
1168 #define ATH5K_NF_CAL_HIST_MAX 8
1174 #define ATH5K_LED_MAX_NAME_LEN 31
1239 #define AR5K_MAX_GPIO 10
1240 #define AR5K_MAX_RF_BANKS 8
1243 #define ATH_CHAN_MAX (26 + 26 + 26 + 200 + 200)
1245 #define ATH_CHAN_MAX (14 + 14 + 14 + 252 + 20)
1248 #define ATH_RXBUF 40
1249 #define ATH_TXBUF 200
1251 #define ATH5K_TXQ_LEN_MAX (ATH_TXBUF / 4)
1252 #define ATH5K_TXQ_LEN_LOW (ATH5K_TXQ_LEN_MAX / 2)
1271 #ifdef CONFIG_ATH5K_DEBUG
1281 #define ATH_STAT_INVALID 0
1282 #define ATH_STAT_PROMISC 1
1283 #define ATH_STAT_LEDSOFT 2
1284 #define ATH_STAT_STARTED 3
1360 #define ah_modes ah_capabilities.cap_mode
1361 #define ah_ee_version ah_capabilities.cap_eeprom.ee_version
1451 unsigned int,
unsigned int,
unsigned int,
unsigned int,
1452 unsigned int,
unsigned int,
unsigned int,
unsigned int);
1565 unsigned int queue);
1578 unsigned int tx_rate1,
u_int tx_tries1,
u_int tx_rate2,
1579 u_int tx_tries2,
unsigned int tx_rate3,
u_int tx_tries3);
1589 u32 interrupt_level);
1644 return &(ath5k_hw_common(ah)->regulatory);
1647 #ifdef CONFIG_ATHEROS_AR231X
1648 #define AR5K_AR2315_PCI_BASE ((void __iomem *)0xb0100000)
1654 if (
unlikely((reg >= 0x4000) && (reg < 0x5000) &&
1656 return AR5K_AR2315_PCI_BASE +
reg;
1661 static inline u32 ath5k_hw_reg_read(
struct ath5k_hw *ah,
u16 reg)
1663 return ioread32(ath5k_ahb_reg(ah, reg));
1673 static inline u32 ath5k_hw_reg_read(
struct ath5k_hw *ah,
u16 reg)
1678 static inline void ath5k_hw_reg_write(
struct ath5k_hw *ah,
u32 val,
u16 reg)
1687 return ath5k_hw_common(ah)->bus_ops->ath_bus_type;
1690 static inline void ath5k_read_cachesize(
struct ath_common *
common,
int *csz)
1692 common->
bus_ops->read_cachesize(common, csz);
1697 struct ath_common *common = ath5k_hw_common(ah);
1698 return common->
bus_ops->eeprom_read(common, off, data);
1701 static inline u32 ath5k_hw_bitswap(
u32 val,
unsigned int bits)
1705 for (i = 0; i <
bits; i++) {
1706 bit = (val >>
i) & 1;
1707 retval = (retval << 1) |
bit;