diff options
Diffstat (limited to 'drivers/net/wireless/ath/ath5k/ath5k.h')
-rw-r--r-- | drivers/net/wireless/ath/ath5k/ath5k.h | 384 |
1 files changed, 234 insertions, 150 deletions
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index ea6362a8988d..bb50700436fe 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #include <linux/io.h> | 26 | #include <linux/io.h> |
27 | #include <linux/types.h> | 27 | #include <linux/types.h> |
28 | #include <linux/average.h> | ||
28 | #include <net/mac80211.h> | 29 | #include <net/mac80211.h> |
29 | 30 | ||
30 | /* RX/TX descriptor hw structs | 31 | /* RX/TX descriptor hw structs |
@@ -153,19 +154,6 @@ | |||
153 | udelay(1); \ | 154 | udelay(1); \ |
154 | } while (0) | 155 | } while (0) |
155 | 156 | ||
156 | /* Register dumps are done per operation mode */ | ||
157 | #define AR5K_INI_RFGAIN_5GHZ 0 | ||
158 | #define AR5K_INI_RFGAIN_2GHZ 1 | ||
159 | |||
160 | /* TODO: Clean this up */ | ||
161 | #define AR5K_INI_VAL_11A 0 | ||
162 | #define AR5K_INI_VAL_11A_TURBO 1 | ||
163 | #define AR5K_INI_VAL_11B 2 | ||
164 | #define AR5K_INI_VAL_11G 3 | ||
165 | #define AR5K_INI_VAL_11G_TURBO 4 | ||
166 | #define AR5K_INI_VAL_XR 0 | ||
167 | #define AR5K_INI_VAL_MAX 5 | ||
168 | |||
169 | /* | 157 | /* |
170 | * Some tuneable values (these should be changeable by the user) | 158 | * Some tuneable values (these should be changeable by the user) |
171 | * TODO: Make use of them and add more options OR use debug/configfs | 159 | * TODO: Make use of them and add more options OR use debug/configfs |
@@ -175,7 +163,7 @@ | |||
175 | #define AR5K_TUNE_ADDITIONAL_SWBA_BACKOFF 0 | 163 | #define AR5K_TUNE_ADDITIONAL_SWBA_BACKOFF 0 |
176 | #define AR5K_TUNE_RADAR_ALERT false | 164 | #define AR5K_TUNE_RADAR_ALERT false |
177 | #define AR5K_TUNE_MIN_TX_FIFO_THRES 1 | 165 | #define AR5K_TUNE_MIN_TX_FIFO_THRES 1 |
178 | #define AR5K_TUNE_MAX_TX_FIFO_THRES ((IEEE80211_MAX_LEN / 64) + 1) | 166 | #define AR5K_TUNE_MAX_TX_FIFO_THRES ((IEEE80211_MAX_FRAME_LEN / 64) + 1) |
179 | #define AR5K_TUNE_REGISTER_TIMEOUT 20000 | 167 | #define AR5K_TUNE_REGISTER_TIMEOUT 20000 |
180 | /* Register for RSSI threshold has a mask of 0xff, so 255 seems to | 168 | /* Register for RSSI threshold has a mask of 0xff, so 255 seems to |
181 | * be the max value. */ | 169 | * be the max value. */ |
@@ -206,6 +194,8 @@ | |||
206 | #define ATH5K_TUNE_CALIBRATION_INTERVAL_ANI 1000 /* 1 sec */ | 194 | #define ATH5K_TUNE_CALIBRATION_INTERVAL_ANI 1000 /* 1 sec */ |
207 | #define ATH5K_TUNE_CALIBRATION_INTERVAL_NF 60000 /* 60 sec */ | 195 | #define ATH5K_TUNE_CALIBRATION_INTERVAL_NF 60000 /* 60 sec */ |
208 | 196 | ||
197 | #define ATH5K_TX_COMPLETE_POLL_INT 3000 /* 3 sec */ | ||
198 | |||
209 | #define AR5K_INIT_CARR_SENSE_EN 1 | 199 | #define AR5K_INIT_CARR_SENSE_EN 1 |
210 | 200 | ||
211 | /*Swap RX/TX Descriptor for big endian archs*/ | 201 | /*Swap RX/TX Descriptor for big endian archs*/ |
@@ -219,45 +209,61 @@ | |||
219 | 209 | ||
220 | /* Initial values */ | 210 | /* Initial values */ |
221 | #define AR5K_INIT_CYCRSSI_THR1 2 | 211 | #define AR5K_INIT_CYCRSSI_THR1 2 |
222 | #define AR5K_INIT_TX_LATENCY 502 | ||
223 | #define AR5K_INIT_USEC 39 | ||
224 | #define AR5K_INIT_USEC_TURBO 79 | ||
225 | #define AR5K_INIT_USEC_32 31 | ||
226 | #define AR5K_INIT_SLOT_TIME 396 | ||
227 | #define AR5K_INIT_SLOT_TIME_TURBO 480 | ||
228 | #define AR5K_INIT_ACK_CTS_TIMEOUT 1024 | ||
229 | #define AR5K_INIT_ACK_CTS_TIMEOUT_TURBO 0x08000800 | ||
230 | #define AR5K_INIT_PROG_IFS 920 | ||
231 | #define AR5K_INIT_PROG_IFS_TURBO 960 | ||
232 | #define AR5K_INIT_EIFS 3440 | ||
233 | #define AR5K_INIT_EIFS_TURBO 6880 | ||
234 | #define AR5K_INIT_SIFS 560 | ||
235 | #define AR5K_INIT_SIFS_TURBO 480 | ||
236 | #define AR5K_INIT_SH_RETRY 10 | ||
237 | #define AR5K_INIT_LG_RETRY AR5K_INIT_SH_RETRY | ||
238 | #define AR5K_INIT_SSH_RETRY 32 | ||
239 | #define AR5K_INIT_SLG_RETRY AR5K_INIT_SSH_RETRY | ||
240 | #define AR5K_INIT_TX_RETRY 10 | ||
241 | |||
242 | #define AR5K_INIT_TRANSMIT_LATENCY ( \ | ||
243 | (AR5K_INIT_TX_LATENCY << 14) | (AR5K_INIT_USEC_32 << 7) | \ | ||
244 | (AR5K_INIT_USEC) \ | ||
245 | ) | ||
246 | #define AR5K_INIT_TRANSMIT_LATENCY_TURBO ( \ | ||
247 | (AR5K_INIT_TX_LATENCY << 14) | (AR5K_INIT_USEC_32 << 7) | \ | ||
248 | (AR5K_INIT_USEC_TURBO) \ | ||
249 | ) | ||
250 | #define AR5K_INIT_PROTO_TIME_CNTRL ( \ | ||
251 | (AR5K_INIT_CARR_SENSE_EN << 26) | (AR5K_INIT_EIFS << 12) | \ | ||
252 | (AR5K_INIT_PROG_IFS) \ | ||
253 | ) | ||
254 | #define AR5K_INIT_PROTO_TIME_CNTRL_TURBO ( \ | ||
255 | (AR5K_INIT_CARR_SENSE_EN << 26) | (AR5K_INIT_EIFS_TURBO << 12) | \ | ||
256 | (AR5K_INIT_PROG_IFS_TURBO) \ | ||
257 | ) | ||
258 | 212 | ||
259 | /* token to use for aifs, cwmin, cwmax in MadWiFi */ | 213 | /* Tx retry limit defaults from standard */ |
260 | #define AR5K_TXQ_USEDEFAULT ((u32) -1) | 214 | #define AR5K_INIT_RETRY_SHORT 7 |
215 | #define AR5K_INIT_RETRY_LONG 4 | ||
216 | |||
217 | /* Slot time */ | ||
218 | #define AR5K_INIT_SLOT_TIME_TURBO 6 | ||
219 | #define AR5K_INIT_SLOT_TIME_DEFAULT 9 | ||
220 | #define AR5K_INIT_SLOT_TIME_HALF_RATE 13 | ||
221 | #define AR5K_INIT_SLOT_TIME_QUARTER_RATE 21 | ||
222 | #define AR5K_INIT_SLOT_TIME_B 20 | ||
223 | #define AR5K_SLOT_TIME_MAX 0xffff | ||
224 | |||
225 | /* SIFS */ | ||
226 | #define AR5K_INIT_SIFS_TURBO 6 | ||
227 | #define AR5K_INIT_SIFS_DEFAULT_BG 10 | ||
228 | #define AR5K_INIT_SIFS_DEFAULT_A 16 | ||
229 | #define AR5K_INIT_SIFS_HALF_RATE 32 | ||
230 | #define AR5K_INIT_SIFS_QUARTER_RATE 64 | ||
231 | |||
232 | /* Used to calculate tx time for non 5/10/40MHz | ||
233 | * operation */ | ||
234 | /* It's preamble time + signal time (16 + 4) */ | ||
235 | #define AR5K_INIT_OFDM_PREAMPLE_TIME 20 | ||
236 | /* Preamble time for 40MHz (turbo) operation (min ?) */ | ||
237 | #define AR5K_INIT_OFDM_PREAMBLE_TIME_MIN 14 | ||
238 | #define AR5K_INIT_OFDM_SYMBOL_TIME 4 | ||
239 | #define AR5K_INIT_OFDM_PLCP_BITS 22 | ||
240 | |||
241 | /* Rx latency for 5 and 10MHz operation (max ?) */ | ||
242 | #define AR5K_INIT_RX_LAT_MAX 63 | ||
243 | /* Tx latencies from initvals (5212 only but no problem | ||
244 | * because we only tweak them on 5212) */ | ||
245 | #define AR5K_INIT_TX_LAT_A 54 | ||
246 | #define AR5K_INIT_TX_LAT_BG 384 | ||
247 | /* Tx latency for 40MHz (turbo) operation (min ?) */ | ||
248 | #define AR5K_INIT_TX_LAT_MIN 32 | ||
249 | /* Default Tx/Rx latencies (same for 5211)*/ | ||
250 | #define AR5K_INIT_TX_LATENCY_5210 54 | ||
251 | #define AR5K_INIT_RX_LATENCY_5210 29 | ||
252 | |||
253 | /* Tx frame to Tx data start delay */ | ||
254 | #define AR5K_INIT_TXF2TXD_START_DEFAULT 14 | ||
255 | #define AR5K_INIT_TXF2TXD_START_DELAY_10MHZ 12 | ||
256 | #define AR5K_INIT_TXF2TXD_START_DELAY_5MHZ 13 | ||
257 | |||
258 | /* We need to increase PHY switch and agc settling time | ||
259 | * on turbo mode */ | ||
260 | #define AR5K_SWITCH_SETTLING 5760 | ||
261 | #define AR5K_SWITCH_SETTLING_TURBO 7168 | ||
262 | |||
263 | #define AR5K_AGC_SETTLING 28 | ||
264 | /* 38 on 5210 but shouldn't matter */ | ||
265 | #define AR5K_AGC_SETTLING_TURBO 37 | ||
266 | |||
261 | 267 | ||
262 | /* GENERIC CHIPSET DEFINITIONS */ | 268 | /* GENERIC CHIPSET DEFINITIONS */ |
263 | 269 | ||
@@ -303,12 +309,19 @@ struct ath5k_srev_name { | |||
303 | #define AR5K_SREV_AR5311B 0x30 /* Spirit */ | 309 | #define AR5K_SREV_AR5311B 0x30 /* Spirit */ |
304 | #define AR5K_SREV_AR5211 0x40 /* Oahu */ | 310 | #define AR5K_SREV_AR5211 0x40 /* Oahu */ |
305 | #define AR5K_SREV_AR5212 0x50 /* Venice */ | 311 | #define AR5K_SREV_AR5212 0x50 /* Venice */ |
312 | #define AR5K_SREV_AR5312_R2 0x52 /* AP31 */ | ||
306 | #define AR5K_SREV_AR5212_V4 0x54 /* ??? */ | 313 | #define AR5K_SREV_AR5212_V4 0x54 /* ??? */ |
307 | #define AR5K_SREV_AR5213 0x55 /* ??? */ | 314 | #define AR5K_SREV_AR5213 0x55 /* ??? */ |
315 | #define AR5K_SREV_AR5312_R7 0x57 /* AP30 */ | ||
316 | #define AR5K_SREV_AR2313_R8 0x58 /* AP43 */ | ||
308 | #define AR5K_SREV_AR5213A 0x59 /* Hainan */ | 317 | #define AR5K_SREV_AR5213A 0x59 /* Hainan */ |
309 | #define AR5K_SREV_AR2413 0x78 /* Griffin lite */ | 318 | #define AR5K_SREV_AR2413 0x78 /* Griffin lite */ |
310 | #define AR5K_SREV_AR2414 0x70 /* Griffin */ | 319 | #define AR5K_SREV_AR2414 0x70 /* Griffin */ |
320 | #define AR5K_SREV_AR2315_R6 0x86 /* AP51-Light */ | ||
321 | #define AR5K_SREV_AR2315_R7 0x87 /* AP51-Full */ | ||
311 | #define AR5K_SREV_AR5424 0x90 /* Condor */ | 322 | #define AR5K_SREV_AR5424 0x90 /* Condor */ |
323 | #define AR5K_SREV_AR2317_R1 0x90 /* AP61-Light */ | ||
324 | #define AR5K_SREV_AR2317_R2 0x91 /* AP61-Full */ | ||
312 | #define AR5K_SREV_AR5413 0xa4 /* Eagle lite */ | 325 | #define AR5K_SREV_AR5413 0xa4 /* Eagle lite */ |
313 | #define AR5K_SREV_AR5414 0xa0 /* Eagle */ | 326 | #define AR5K_SREV_AR5414 0xa0 /* Eagle */ |
314 | #define AR5K_SREV_AR2415 0xb0 /* Talon */ | 327 | #define AR5K_SREV_AR2415 0xb0 /* Talon */ |
@@ -343,15 +356,12 @@ struct ath5k_srev_name { | |||
343 | #define AR5K_SREV_PHY_5413 0x61 | 356 | #define AR5K_SREV_PHY_5413 0x61 |
344 | #define AR5K_SREV_PHY_2425 0x70 | 357 | #define AR5K_SREV_PHY_2425 0x70 |
345 | 358 | ||
346 | /* IEEE defs */ | ||
347 | #define IEEE80211_MAX_LEN 2500 | ||
348 | |||
349 | /* TODO add support to mac80211 for vendor-specific rates and modes */ | 359 | /* TODO add support to mac80211 for vendor-specific rates and modes */ |
350 | 360 | ||
351 | /* | 361 | /* |
352 | * Some of this information is based on Documentation from: | 362 | * Some of this information is based on Documentation from: |
353 | * | 363 | * |
354 | * http://madwifi.org/wiki/ChipsetFeatures/SuperAG | 364 | * http://madwifi-project.org/wiki/ChipsetFeatures/SuperAG |
355 | * | 365 | * |
356 | * Modulation for Atheros' eXtended Range - range enhancing extension that is | 366 | * Modulation for Atheros' eXtended Range - range enhancing extension that is |
357 | * supposed to double the distance an Atheros client device can keep a | 367 | * supposed to double the distance an Atheros client device can keep a |
@@ -407,12 +417,10 @@ struct ath5k_srev_name { | |||
407 | 417 | ||
408 | enum ath5k_driver_mode { | 418 | enum ath5k_driver_mode { |
409 | AR5K_MODE_11A = 0, | 419 | AR5K_MODE_11A = 0, |
410 | AR5K_MODE_11A_TURBO = 1, | 420 | AR5K_MODE_11B = 1, |
411 | AR5K_MODE_11B = 2, | 421 | AR5K_MODE_11G = 2, |
412 | AR5K_MODE_11G = 3, | ||
413 | AR5K_MODE_11G_TURBO = 4, | ||
414 | AR5K_MODE_XR = 0, | 422 | AR5K_MODE_XR = 0, |
415 | AR5K_MODE_MAX = 5 | 423 | AR5K_MODE_MAX = 3 |
416 | }; | 424 | }; |
417 | 425 | ||
418 | enum ath5k_ant_mode { | 426 | enum ath5k_ant_mode { |
@@ -426,6 +434,12 @@ enum ath5k_ant_mode { | |||
426 | AR5K_ANTMODE_MAX, | 434 | AR5K_ANTMODE_MAX, |
427 | }; | 435 | }; |
428 | 436 | ||
437 | enum ath5k_bw_mode { | ||
438 | AR5K_BWMODE_DEFAULT = 0, /* 20MHz, default operation */ | ||
439 | AR5K_BWMODE_5MHZ = 1, /* Quarter rate */ | ||
440 | AR5K_BWMODE_10MHZ = 2, /* Half rate */ | ||
441 | AR5K_BWMODE_40MHZ = 3 /* Turbo */ | ||
442 | }; | ||
429 | 443 | ||
430 | /****************\ | 444 | /****************\ |
431 | TX DEFINITIONS | 445 | TX DEFINITIONS |
@@ -438,12 +452,10 @@ struct ath5k_tx_status { | |||
438 | u16 ts_seqnum; | 452 | u16 ts_seqnum; |
439 | u16 ts_tstamp; | 453 | u16 ts_tstamp; |
440 | u8 ts_status; | 454 | u8 ts_status; |
441 | u8 ts_rate[4]; | ||
442 | u8 ts_retry[4]; | ||
443 | u8 ts_final_idx; | 455 | u8 ts_final_idx; |
456 | u8 ts_final_retry; | ||
444 | s8 ts_rssi; | 457 | s8 ts_rssi; |
445 | u8 ts_shortretry; | 458 | u8 ts_shortretry; |
446 | u8 ts_longretry; | ||
447 | u8 ts_virtcol; | 459 | u8 ts_virtcol; |
448 | u8 ts_antenna; | 460 | u8 ts_antenna; |
449 | }; | 461 | }; |
@@ -498,7 +510,7 @@ enum ath5k_tx_queue_id { | |||
498 | AR5K_TX_QUEUE_ID_NOQCU_DATA = 0, | 510 | AR5K_TX_QUEUE_ID_NOQCU_DATA = 0, |
499 | AR5K_TX_QUEUE_ID_NOQCU_BEACON = 1, | 511 | AR5K_TX_QUEUE_ID_NOQCU_BEACON = 1, |
500 | AR5K_TX_QUEUE_ID_DATA_MIN = 0, /*IEEE80211_TX_QUEUE_DATA0*/ | 512 | AR5K_TX_QUEUE_ID_DATA_MIN = 0, /*IEEE80211_TX_QUEUE_DATA0*/ |
501 | AR5K_TX_QUEUE_ID_DATA_MAX = 4, /*IEEE80211_TX_QUEUE_DATA4*/ | 513 | AR5K_TX_QUEUE_ID_DATA_MAX = 3, /*IEEE80211_TX_QUEUE_DATA3*/ |
502 | AR5K_TX_QUEUE_ID_DATA_SVP = 5, /*IEEE80211_TX_QUEUE_SVP - Spectralink Voice Protocol*/ | 514 | AR5K_TX_QUEUE_ID_DATA_SVP = 5, /*IEEE80211_TX_QUEUE_SVP - Spectralink Voice Protocol*/ |
503 | AR5K_TX_QUEUE_ID_CAB = 6, /*IEEE80211_TX_QUEUE_AFTER_BEACON*/ | 515 | AR5K_TX_QUEUE_ID_CAB = 6, /*IEEE80211_TX_QUEUE_AFTER_BEACON*/ |
504 | AR5K_TX_QUEUE_ID_BEACON = 7, /*IEEE80211_TX_QUEUE_BEACON*/ | 516 | AR5K_TX_QUEUE_ID_BEACON = 7, /*IEEE80211_TX_QUEUE_BEACON*/ |
@@ -531,9 +543,9 @@ struct ath5k_txq_info { | |||
531 | enum ath5k_tx_queue tqi_type; | 543 | enum ath5k_tx_queue tqi_type; |
532 | enum ath5k_tx_queue_subtype tqi_subtype; | 544 | enum ath5k_tx_queue_subtype tqi_subtype; |
533 | u16 tqi_flags; /* Tx queue flags (see above) */ | 545 | u16 tqi_flags; /* Tx queue flags (see above) */ |
534 | u32 tqi_aifs; /* Arbitrated Interframe Space */ | 546 | u8 tqi_aifs; /* Arbitrated Interframe Space */ |
535 | s32 tqi_cw_min; /* Minimum Contention Window */ | 547 | u16 tqi_cw_min; /* Minimum Contention Window */ |
536 | s32 tqi_cw_max; /* Maximum Contention Window */ | 548 | u16 tqi_cw_max; /* Maximum Contention Window */ |
537 | u32 tqi_cbr_period; /* Constant bit rate period */ | 549 | u32 tqi_cbr_period; /* Constant bit rate period */ |
538 | u32 tqi_cbr_overflow_limit; | 550 | u32 tqi_cbr_overflow_limit; |
539 | u32 tqi_burst_time; | 551 | u32 tqi_burst_time; |
@@ -658,7 +670,6 @@ struct ath5k_gain { | |||
658 | 670 | ||
659 | /* channel_flags */ | 671 | /* channel_flags */ |
660 | #define CHANNEL_CW_INT 0x0008 /* Contention Window interference detected */ | 672 | #define CHANNEL_CW_INT 0x0008 /* Contention Window interference detected */ |
661 | #define CHANNEL_TURBO 0x0010 /* Turbo Channel */ | ||
662 | #define CHANNEL_CCK 0x0020 /* CCK channel */ | 673 | #define CHANNEL_CCK 0x0020 /* CCK channel */ |
663 | #define CHANNEL_OFDM 0x0040 /* OFDM channel */ | 674 | #define CHANNEL_OFDM 0x0040 /* OFDM channel */ |
664 | #define CHANNEL_2GHZ 0x0080 /* 2GHz channel. */ | 675 | #define CHANNEL_2GHZ 0x0080 /* 2GHz channel. */ |
@@ -670,16 +681,10 @@ struct ath5k_gain { | |||
670 | #define CHANNEL_A (CHANNEL_5GHZ|CHANNEL_OFDM) | 681 | #define CHANNEL_A (CHANNEL_5GHZ|CHANNEL_OFDM) |
671 | #define CHANNEL_B (CHANNEL_2GHZ|CHANNEL_CCK) | 682 | #define CHANNEL_B (CHANNEL_2GHZ|CHANNEL_CCK) |
672 | #define CHANNEL_G (CHANNEL_2GHZ|CHANNEL_OFDM) | 683 | #define CHANNEL_G (CHANNEL_2GHZ|CHANNEL_OFDM) |
673 | #define CHANNEL_T (CHANNEL_5GHZ|CHANNEL_OFDM|CHANNEL_TURBO) | ||
674 | #define CHANNEL_TG (CHANNEL_2GHZ|CHANNEL_OFDM|CHANNEL_TURBO) | ||
675 | #define CHANNEL_108A CHANNEL_T | ||
676 | #define CHANNEL_108G CHANNEL_TG | ||
677 | #define CHANNEL_X (CHANNEL_5GHZ|CHANNEL_OFDM|CHANNEL_XR) | 684 | #define CHANNEL_X (CHANNEL_5GHZ|CHANNEL_OFDM|CHANNEL_XR) |
678 | 685 | ||
679 | #define CHANNEL_ALL (CHANNEL_OFDM|CHANNEL_CCK|CHANNEL_2GHZ|CHANNEL_5GHZ| \ | 686 | #define CHANNEL_ALL (CHANNEL_OFDM|CHANNEL_CCK|CHANNEL_2GHZ|CHANNEL_5GHZ) |
680 | CHANNEL_TURBO) | ||
681 | 687 | ||
682 | #define CHANNEL_ALL_NOTURBO (CHANNEL_ALL & ~CHANNEL_TURBO) | ||
683 | #define CHANNEL_MODES CHANNEL_ALL | 688 | #define CHANNEL_MODES CHANNEL_ALL |
684 | 689 | ||
685 | /* | 690 | /* |
@@ -867,6 +872,19 @@ enum ath5k_int { | |||
867 | AR5K_INT_QTRIG = 0x40000000, /* Non common */ | 872 | AR5K_INT_QTRIG = 0x40000000, /* Non common */ |
868 | AR5K_INT_GLOBAL = 0x80000000, | 873 | AR5K_INT_GLOBAL = 0x80000000, |
869 | 874 | ||
875 | AR5K_INT_TX_ALL = AR5K_INT_TXOK | ||
876 | | AR5K_INT_TXDESC | ||
877 | | AR5K_INT_TXERR | ||
878 | | AR5K_INT_TXEOL | ||
879 | | AR5K_INT_TXURN, | ||
880 | |||
881 | AR5K_INT_RX_ALL = AR5K_INT_RXOK | ||
882 | | AR5K_INT_RXDESC | ||
883 | | AR5K_INT_RXERR | ||
884 | | AR5K_INT_RXNOFRM | ||
885 | | AR5K_INT_RXEOL | ||
886 | | AR5K_INT_RXORN, | ||
887 | |||
870 | AR5K_INT_COMMON = AR5K_INT_RXOK | 888 | AR5K_INT_COMMON = AR5K_INT_RXOK |
871 | | AR5K_INT_RXDESC | 889 | | AR5K_INT_RXDESC |
872 | | AR5K_INT_RXERR | 890 | | AR5K_INT_RXERR |
@@ -1028,17 +1046,15 @@ struct ath5k_hw { | |||
1028 | enum ath5k_int ah_imr; | 1046 | enum ath5k_int ah_imr; |
1029 | 1047 | ||
1030 | struct ieee80211_channel *ah_current_channel; | 1048 | struct ieee80211_channel *ah_current_channel; |
1031 | bool ah_turbo; | ||
1032 | bool ah_calibration; | 1049 | bool ah_calibration; |
1033 | bool ah_single_chip; | 1050 | bool ah_single_chip; |
1034 | bool ah_aes_support; | ||
1035 | bool ah_combined_mic; | ||
1036 | 1051 | ||
1037 | enum ath5k_version ah_version; | 1052 | enum ath5k_version ah_version; |
1038 | enum ath5k_radio ah_radio; | 1053 | enum ath5k_radio ah_radio; |
1039 | u32 ah_phy; | 1054 | u32 ah_phy; |
1040 | u32 ah_mac_srev; | 1055 | u32 ah_mac_srev; |
1041 | u16 ah_mac_version; | 1056 | u16 ah_mac_version; |
1057 | u16 ah_mac_revision; | ||
1042 | u16 ah_phy_revision; | 1058 | u16 ah_phy_revision; |
1043 | u16 ah_radio_5ghz_revision; | 1059 | u16 ah_radio_5ghz_revision; |
1044 | u16 ah_radio_2ghz_revision; | 1060 | u16 ah_radio_2ghz_revision; |
@@ -1046,19 +1062,19 @@ struct ath5k_hw { | |||
1046 | #define ah_modes ah_capabilities.cap_mode | 1062 | #define ah_modes ah_capabilities.cap_mode |
1047 | #define ah_ee_version ah_capabilities.cap_eeprom.ee_version | 1063 | #define ah_ee_version ah_capabilities.cap_eeprom.ee_version |
1048 | 1064 | ||
1049 | u32 ah_atim_window; | 1065 | u8 ah_retry_long; |
1050 | u32 ah_aifs; | 1066 | u8 ah_retry_short; |
1051 | u32 ah_cw_min; | 1067 | |
1052 | u32 ah_cw_max; | ||
1053 | u32 ah_limit_tx_retries; | ||
1054 | u8 ah_coverage_class; | 1068 | u8 ah_coverage_class; |
1069 | bool ah_ack_bitrate_high; | ||
1070 | u8 ah_bwmode; | ||
1071 | bool ah_short_slot; | ||
1055 | 1072 | ||
1056 | /* Antenna Control */ | 1073 | /* Antenna Control */ |
1057 | u32 ah_ant_ctl[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX]; | 1074 | u32 ah_ant_ctl[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX]; |
1058 | u8 ah_ant_mode; | 1075 | u8 ah_ant_mode; |
1059 | u8 ah_tx_ant; | 1076 | u8 ah_tx_ant; |
1060 | u8 ah_def_ant; | 1077 | u8 ah_def_ant; |
1061 | bool ah_software_retry; | ||
1062 | 1078 | ||
1063 | struct ath5k_capabilities ah_capabilities; | 1079 | struct ath5k_capabilities ah_capabilities; |
1064 | 1080 | ||
@@ -1094,12 +1110,14 @@ struct ath5k_hw { | |||
1094 | /* Values in 0.25dB units */ | 1110 | /* Values in 0.25dB units */ |
1095 | s16 txp_min_pwr; | 1111 | s16 txp_min_pwr; |
1096 | s16 txp_max_pwr; | 1112 | s16 txp_max_pwr; |
1113 | s16 txp_cur_pwr; | ||
1097 | /* Values in 0.5dB units */ | 1114 | /* Values in 0.5dB units */ |
1098 | s16 txp_offset; | 1115 | s16 txp_offset; |
1099 | s16 txp_ofdm; | 1116 | s16 txp_ofdm; |
1100 | s16 txp_cck_ofdm_gainf_delta; | 1117 | s16 txp_cck_ofdm_gainf_delta; |
1101 | /* Value in dB units */ | 1118 | /* Value in dB units */ |
1102 | s16 txp_cck_ofdm_pwr_delta; | 1119 | s16 txp_cck_ofdm_pwr_delta; |
1120 | bool txp_setup; | ||
1103 | } ah_txpower; | 1121 | } ah_txpower; |
1104 | 1122 | ||
1105 | struct { | 1123 | struct { |
@@ -1111,7 +1129,7 @@ struct ath5k_hw { | |||
1111 | struct ath5k_nfcal_hist ah_nfcal_hist; | 1129 | struct ath5k_nfcal_hist ah_nfcal_hist; |
1112 | 1130 | ||
1113 | /* average beacon RSSI in our BSS (used by ANI) */ | 1131 | /* average beacon RSSI in our BSS (used by ANI) */ |
1114 | struct ath5k_avg_val ah_beacon_rssi_avg; | 1132 | struct ewma ah_beacon_rssi_avg; |
1115 | 1133 | ||
1116 | /* noise floor from last periodic calibration */ | 1134 | /* noise floor from last periodic calibration */ |
1117 | s32 ah_noise_floor; | 1135 | s32 ah_noise_floor; |
@@ -1137,39 +1155,80 @@ struct ath5k_hw { | |||
1137 | struct ath5k_rx_status *); | 1155 | struct ath5k_rx_status *); |
1138 | }; | 1156 | }; |
1139 | 1157 | ||
1158 | struct ath_bus_ops { | ||
1159 | enum ath_bus_type ath_bus_type; | ||
1160 | void (*read_cachesize)(struct ath_common *common, int *csz); | ||
1161 | bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data); | ||
1162 | int (*eeprom_read_mac)(struct ath5k_hw *ah, u8 *mac); | ||
1163 | }; | ||
1164 | |||
1140 | /* | 1165 | /* |
1141 | * Prototypes | 1166 | * Prototypes |
1142 | */ | 1167 | */ |
1168 | extern const struct ieee80211_ops ath5k_hw_ops; | ||
1143 | 1169 | ||
1144 | /* Attach/Detach Functions */ | 1170 | /* Initialization and detach functions */ |
1145 | int ath5k_hw_attach(struct ath5k_softc *sc); | 1171 | int ath5k_init_softc(struct ath5k_softc *sc, const struct ath_bus_ops *bus_ops); |
1146 | void ath5k_hw_detach(struct ath5k_hw *ah); | 1172 | void ath5k_deinit_softc(struct ath5k_softc *sc); |
1173 | int ath5k_hw_init(struct ath5k_softc *sc); | ||
1174 | void ath5k_hw_deinit(struct ath5k_hw *ah); | ||
1147 | 1175 | ||
1148 | int ath5k_sysfs_register(struct ath5k_softc *sc); | 1176 | int ath5k_sysfs_register(struct ath5k_softc *sc); |
1149 | void ath5k_sysfs_unregister(struct ath5k_softc *sc); | 1177 | void ath5k_sysfs_unregister(struct ath5k_softc *sc); |
1150 | 1178 | ||
1179 | /* base.c */ | ||
1180 | struct ath5k_buf; | ||
1181 | struct ath5k_txq; | ||
1182 | |||
1183 | void set_beacon_filter(struct ieee80211_hw *hw, bool enable); | ||
1184 | bool ath_any_vif_assoc(struct ath5k_softc *sc); | ||
1185 | void ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb, | ||
1186 | struct ath5k_txq *txq); | ||
1187 | int ath5k_init_hw(struct ath5k_softc *sc); | ||
1188 | int ath5k_stop_hw(struct ath5k_softc *sc); | ||
1189 | void ath5k_mode_setup(struct ath5k_softc *sc, struct ieee80211_vif *vif); | ||
1190 | void ath5k_update_bssid_mask_and_opmode(struct ath5k_softc *sc, | ||
1191 | struct ieee80211_vif *vif); | ||
1192 | int ath5k_chan_set(struct ath5k_softc *sc, struct ieee80211_channel *chan); | ||
1193 | void ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf); | ||
1194 | int ath5k_beacon_update(struct ieee80211_hw *hw, struct ieee80211_vif *vif); | ||
1195 | void ath5k_beacon_config(struct ath5k_softc *sc); | ||
1196 | void ath5k_txbuf_free_skb(struct ath5k_softc *sc, struct ath5k_buf *bf); | ||
1197 | void ath5k_rxbuf_free_skb(struct ath5k_softc *sc, struct ath5k_buf *bf); | ||
1198 | |||
1199 | /*Chip id helper functions */ | ||
1200 | const char *ath5k_chip_name(enum ath5k_srev_type type, u_int16_t val); | ||
1201 | int ath5k_hw_read_srev(struct ath5k_hw *ah); | ||
1202 | |||
1151 | /* LED functions */ | 1203 | /* LED functions */ |
1152 | int ath5k_init_leds(struct ath5k_softc *sc); | 1204 | int ath5k_init_leds(struct ath5k_softc *sc); |
1153 | void ath5k_led_enable(struct ath5k_softc *sc); | 1205 | void ath5k_led_enable(struct ath5k_softc *sc); |
1154 | void ath5k_led_off(struct ath5k_softc *sc); | 1206 | void ath5k_led_off(struct ath5k_softc *sc); |
1155 | void ath5k_unregister_leds(struct ath5k_softc *sc); | 1207 | void ath5k_unregister_leds(struct ath5k_softc *sc); |
1156 | 1208 | ||
1209 | |||
1157 | /* Reset Functions */ | 1210 | /* Reset Functions */ |
1158 | int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial); | 1211 | int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial); |
1159 | int ath5k_hw_on_hold(struct ath5k_hw *ah); | 1212 | int ath5k_hw_on_hold(struct ath5k_hw *ah); |
1160 | int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, | 1213 | int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, |
1161 | struct ieee80211_channel *channel, bool change_channel); | 1214 | struct ieee80211_channel *channel, bool fast, bool skip_pcu); |
1162 | int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val, | 1215 | int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val, |
1163 | bool is_set); | 1216 | bool is_set); |
1164 | /* Power management functions */ | 1217 | /* Power management functions */ |
1165 | 1218 | ||
1219 | |||
1220 | /* Clock rate related functions */ | ||
1221 | unsigned int ath5k_hw_htoclock(struct ath5k_hw *ah, unsigned int usec); | ||
1222 | unsigned int ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock); | ||
1223 | void ath5k_hw_set_clockrate(struct ath5k_hw *ah); | ||
1224 | |||
1225 | |||
1166 | /* DMA Related Functions */ | 1226 | /* DMA Related Functions */ |
1167 | void ath5k_hw_start_rx_dma(struct ath5k_hw *ah); | 1227 | void ath5k_hw_start_rx_dma(struct ath5k_hw *ah); |
1168 | int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah); | ||
1169 | u32 ath5k_hw_get_rxdp(struct ath5k_hw *ah); | 1228 | u32 ath5k_hw_get_rxdp(struct ath5k_hw *ah); |
1170 | void ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr); | 1229 | int ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr); |
1171 | int ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue); | 1230 | int ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue); |
1172 | int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue); | 1231 | int ath5k_hw_stop_beacon_queue(struct ath5k_hw *ah, unsigned int queue); |
1173 | u32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue); | 1232 | u32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue); |
1174 | int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, | 1233 | int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, |
1175 | u32 phys_addr); | 1234 | u32 phys_addr); |
@@ -1179,42 +1238,42 @@ bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah); | |||
1179 | int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask); | 1238 | int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask); |
1180 | enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask); | 1239 | enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask); |
1181 | void ath5k_hw_update_mib_counters(struct ath5k_hw *ah); | 1240 | void ath5k_hw_update_mib_counters(struct ath5k_hw *ah); |
1241 | /* Init/Stop functions */ | ||
1242 | void ath5k_hw_dma_init(struct ath5k_hw *ah); | ||
1243 | int ath5k_hw_dma_stop(struct ath5k_hw *ah); | ||
1182 | 1244 | ||
1183 | /* EEPROM access functions */ | 1245 | /* EEPROM access functions */ |
1184 | int ath5k_eeprom_init(struct ath5k_hw *ah); | 1246 | int ath5k_eeprom_init(struct ath5k_hw *ah); |
1185 | void ath5k_eeprom_detach(struct ath5k_hw *ah); | 1247 | void ath5k_eeprom_detach(struct ath5k_hw *ah); |
1186 | int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac); | 1248 | |
1187 | 1249 | ||
1188 | /* Protocol Control Unit Functions */ | 1250 | /* Protocol Control Unit Functions */ |
1251 | /* Helpers */ | ||
1252 | int ath5k_hw_get_frame_duration(struct ath5k_hw *ah, | ||
1253 | int len, struct ieee80211_rate *rate, bool shortpre); | ||
1254 | unsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah); | ||
1255 | unsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah); | ||
1189 | extern int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype opmode); | 1256 | extern int ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype opmode); |
1190 | void ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class); | 1257 | void ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class); |
1191 | /* BSSID Functions */ | 1258 | /* RX filter control*/ |
1192 | int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac); | 1259 | int ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac); |
1193 | void ath5k_hw_set_associd(struct ath5k_hw *ah); | 1260 | void ath5k_hw_set_bssid(struct ath5k_hw *ah); |
1194 | void ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask); | 1261 | void ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask); |
1195 | /* Receive start/stop functions */ | ||
1196 | void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah); | ||
1197 | void ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah); | ||
1198 | /* RX Filter functions */ | ||
1199 | void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1); | 1262 | void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1); |
1200 | u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah); | 1263 | u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah); |
1201 | void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter); | 1264 | void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter); |
1265 | /* Receive (DRU) start/stop functions */ | ||
1266 | void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah); | ||
1267 | void ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah); | ||
1202 | /* Beacon control functions */ | 1268 | /* Beacon control functions */ |
1203 | u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah); | 1269 | u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah); |
1204 | void ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64); | 1270 | void ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64); |
1205 | void ath5k_hw_reset_tsf(struct ath5k_hw *ah); | 1271 | void ath5k_hw_reset_tsf(struct ath5k_hw *ah); |
1206 | void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval); | 1272 | void ath5k_hw_init_beacon(struct ath5k_hw *ah, u32 next_beacon, u32 interval); |
1207 | /* ACK bit rate */ | 1273 | bool ath5k_hw_check_beacon_timers(struct ath5k_hw *ah, int intval); |
1208 | void ath5k_hw_set_ack_bitrate_high(struct ath5k_hw *ah, bool high); | 1274 | /* Init function */ |
1209 | /* Clock rate related functions */ | 1275 | void ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode, |
1210 | unsigned int ath5k_hw_htoclock(struct ath5k_hw *ah, unsigned int usec); | 1276 | u8 mode); |
1211 | unsigned int ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock); | ||
1212 | unsigned int ath5k_hw_get_clockrate(struct ath5k_hw *ah); | ||
1213 | /* Key table (WEP) functions */ | ||
1214 | int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry); | ||
1215 | int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry, | ||
1216 | const struct ieee80211_key_conf *key, const u8 *mac); | ||
1217 | int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac); | ||
1218 | 1277 | ||
1219 | /* Queue Control Unit, DFS Control Unit Functions */ | 1278 | /* Queue Control Unit, DFS Control Unit Functions */ |
1220 | int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, | 1279 | int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, |
@@ -1224,10 +1283,14 @@ int ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue, | |||
1224 | int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, | 1283 | int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, |
1225 | enum ath5k_tx_queue queue_type, | 1284 | enum ath5k_tx_queue queue_type, |
1226 | struct ath5k_txq_info *queue_info); | 1285 | struct ath5k_txq_info *queue_info); |
1286 | void ath5k_hw_set_tx_retry_limits(struct ath5k_hw *ah, | ||
1287 | unsigned int queue); | ||
1227 | u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue); | 1288 | u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue); |
1228 | void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue); | 1289 | void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue); |
1229 | int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue); | 1290 | int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue); |
1230 | int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time); | 1291 | int ath5k_hw_set_ifs_intervals(struct ath5k_hw *ah, unsigned int slot_time); |
1292 | /* Init function */ | ||
1293 | int ath5k_hw_init_queues(struct ath5k_hw *ah); | ||
1231 | 1294 | ||
1232 | /* Hardware Descriptor Functions */ | 1295 | /* Hardware Descriptor Functions */ |
1233 | int ath5k_hw_init_desc_functions(struct ath5k_hw *ah); | 1296 | int ath5k_hw_init_desc_functions(struct ath5k_hw *ah); |
@@ -1237,6 +1300,7 @@ int ath5k_hw_setup_mrr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, | |||
1237 | unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2, | 1300 | unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2, |
1238 | u_int tx_tries2, unsigned int tx_rate3, u_int tx_tries3); | 1301 | u_int tx_tries2, unsigned int tx_rate3, u_int tx_tries3); |
1239 | 1302 | ||
1303 | |||
1240 | /* GPIO Functions */ | 1304 | /* GPIO Functions */ |
1241 | void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state); | 1305 | void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state); |
1242 | int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio); | 1306 | int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio); |
@@ -1246,11 +1310,13 @@ int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val); | |||
1246 | void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, | 1310 | void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, |
1247 | u32 interrupt_level); | 1311 | u32 interrupt_level); |
1248 | 1312 | ||
1249 | /* rfkill Functions */ | 1313 | |
1314 | /* RFkill Functions */ | ||
1250 | void ath5k_rfkill_hw_start(struct ath5k_hw *ah); | 1315 | void ath5k_rfkill_hw_start(struct ath5k_hw *ah); |
1251 | void ath5k_rfkill_hw_stop(struct ath5k_hw *ah); | 1316 | void ath5k_rfkill_hw_stop(struct ath5k_hw *ah); |
1252 | 1317 | ||
1253 | /* Misc functions */ | 1318 | |
1319 | /* Misc functions TODO: Cleanup */ | ||
1254 | int ath5k_hw_set_capabilities(struct ath5k_hw *ah); | 1320 | int ath5k_hw_set_capabilities(struct ath5k_hw *ah); |
1255 | int ath5k_hw_get_capability(struct ath5k_hw *ah, | 1321 | int ath5k_hw_get_capability(struct ath5k_hw *ah, |
1256 | enum ath5k_capability_type cap_type, u32 capability, | 1322 | enum ath5k_capability_type cap_type, u32 capability, |
@@ -1258,19 +1324,20 @@ int ath5k_hw_get_capability(struct ath5k_hw *ah, | |||
1258 | int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, u16 assoc_id); | 1324 | int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, u16 assoc_id); |
1259 | int ath5k_hw_disable_pspoll(struct ath5k_hw *ah); | 1325 | int ath5k_hw_disable_pspoll(struct ath5k_hw *ah); |
1260 | 1326 | ||
1327 | |||
1261 | /* Initial register settings functions */ | 1328 | /* Initial register settings functions */ |
1262 | int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel); | 1329 | int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel); |
1263 | 1330 | ||
1264 | /* Initialize RF */ | 1331 | |
1265 | int ath5k_hw_rfregs_init(struct ath5k_hw *ah, | 1332 | /* PHY functions */ |
1266 | struct ieee80211_channel *channel, | 1333 | /* Misc PHY functions */ |
1267 | unsigned int mode); | 1334 | u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan); |
1268 | int ath5k_hw_rfgain_init(struct ath5k_hw *ah, unsigned int freq); | 1335 | int ath5k_hw_phy_disable(struct ath5k_hw *ah); |
1336 | /* Gain_F optimization */ | ||
1269 | enum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah); | 1337 | enum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah); |
1270 | int ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah); | 1338 | int ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah); |
1271 | /* PHY/RF channel functions */ | 1339 | /* PHY/RF channel functions */ |
1272 | bool ath5k_channel_ok(struct ath5k_hw *ah, u16 freq, unsigned int flags); | 1340 | bool ath5k_channel_ok(struct ath5k_hw *ah, u16 freq, unsigned int flags); |
1273 | int ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel); | ||
1274 | /* PHY calibration */ | 1341 | /* PHY calibration */ |
1275 | void ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah); | 1342 | void ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah); |
1276 | int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, | 1343 | int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, |
@@ -1279,18 +1346,14 @@ void ath5k_hw_update_noise_floor(struct ath5k_hw *ah); | |||
1279 | /* Spur mitigation */ | 1346 | /* Spur mitigation */ |
1280 | bool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah, | 1347 | bool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah, |
1281 | struct ieee80211_channel *channel); | 1348 | struct ieee80211_channel *channel); |
1282 | void ath5k_hw_set_spur_mitigation_filter(struct ath5k_hw *ah, | ||
1283 | struct ieee80211_channel *channel); | ||
1284 | /* Misc PHY functions */ | ||
1285 | u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan); | ||
1286 | int ath5k_hw_phy_disable(struct ath5k_hw *ah); | ||
1287 | /* Antenna control */ | 1349 | /* Antenna control */ |
1288 | void ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode); | 1350 | void ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode); |
1289 | void ath5k_hw_set_antenna_switch(struct ath5k_hw *ah, u8 ee_mode); | 1351 | void ath5k_hw_set_antenna_switch(struct ath5k_hw *ah, u8 ee_mode); |
1290 | /* TX power setup */ | 1352 | /* TX power setup */ |
1291 | int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, | ||
1292 | u8 ee_mode, u8 txpower); | ||
1293 | int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower); | 1353 | int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower); |
1354 | /* Init function */ | ||
1355 | int ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel, | ||
1356 | u8 mode, bool fast); | ||
1294 | 1357 | ||
1295 | /* | 1358 | /* |
1296 | * Functions used internaly | 1359 | * Functions used internaly |
@@ -1306,6 +1369,32 @@ static inline struct ath_regulatory *ath5k_hw_regulatory(struct ath5k_hw *ah) | |||
1306 | return &(ath5k_hw_common(ah)->regulatory); | 1369 | return &(ath5k_hw_common(ah)->regulatory); |
1307 | } | 1370 | } |
1308 | 1371 | ||
1372 | #ifdef CONFIG_ATHEROS_AR231X | ||
1373 | #define AR5K_AR2315_PCI_BASE ((void __iomem *)0xb0100000) | ||
1374 | |||
1375 | static inline void __iomem *ath5k_ahb_reg(struct ath5k_hw *ah, u16 reg) | ||
1376 | { | ||
1377 | /* On AR2315 and AR2317 the PCI clock domain registers | ||
1378 | * are outside of the WMAC register space */ | ||
1379 | if (unlikely((reg >= 0x4000) && (reg < 0x5000) && | ||
1380 | (ah->ah_mac_srev >= AR5K_SREV_AR2315_R6))) | ||
1381 | return AR5K_AR2315_PCI_BASE + reg; | ||
1382 | |||
1383 | return ah->ah_iobase + reg; | ||
1384 | } | ||
1385 | |||
1386 | static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg) | ||
1387 | { | ||
1388 | return __raw_readl(ath5k_ahb_reg(ah, reg)); | ||
1389 | } | ||
1390 | |||
1391 | static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg) | ||
1392 | { | ||
1393 | __raw_writel(val, ath5k_ahb_reg(ah, reg)); | ||
1394 | } | ||
1395 | |||
1396 | #else | ||
1397 | |||
1309 | static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg) | 1398 | static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg) |
1310 | { | 1399 | { |
1311 | return ioread32(ah->ah_iobase + reg); | 1400 | return ioread32(ah->ah_iobase + reg); |
@@ -1316,6 +1405,24 @@ static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg) | |||
1316 | iowrite32(val, ah->ah_iobase + reg); | 1405 | iowrite32(val, ah->ah_iobase + reg); |
1317 | } | 1406 | } |
1318 | 1407 | ||
1408 | #endif | ||
1409 | |||
1410 | static inline enum ath_bus_type ath5k_get_bus_type(struct ath5k_hw *ah) | ||
1411 | { | ||
1412 | return ath5k_hw_common(ah)->bus_ops->ath_bus_type; | ||
1413 | } | ||
1414 | |||
1415 | static inline void ath5k_read_cachesize(struct ath_common *common, int *csz) | ||
1416 | { | ||
1417 | common->bus_ops->read_cachesize(common, csz); | ||
1418 | } | ||
1419 | |||
1420 | static inline bool ath5k_hw_nvram_read(struct ath5k_hw *ah, u32 off, u16 *data) | ||
1421 | { | ||
1422 | struct ath_common *common = ath5k_hw_common(ah); | ||
1423 | return common->bus_ops->eeprom_read(common, off, data); | ||
1424 | } | ||
1425 | |||
1319 | static inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits) | 1426 | static inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits) |
1320 | { | 1427 | { |
1321 | u32 retval = 0, bit, i; | 1428 | u32 retval = 0, bit, i; |
@@ -1328,27 +1435,4 @@ static inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits) | |||
1328 | return retval; | 1435 | return retval; |
1329 | } | 1436 | } |
1330 | 1437 | ||
1331 | #define AVG_SAMPLES 8 | ||
1332 | #define AVG_FACTOR 1000 | ||
1333 | |||
1334 | /** | ||
1335 | * ath5k_moving_average - Exponentially weighted moving average | ||
1336 | * @avg: average structure | ||
1337 | * @val: current value | ||
1338 | * | ||
1339 | * This implementation make use of a struct ath5k_avg_val to prevent rounding | ||
1340 | * errors. | ||
1341 | */ | ||
1342 | static inline struct ath5k_avg_val | ||
1343 | ath5k_moving_average(const struct ath5k_avg_val avg, const int val) | ||
1344 | { | ||
1345 | struct ath5k_avg_val new; | ||
1346 | new.avg_weight = avg.avg_weight ? | ||
1347 | (((avg.avg_weight * ((AVG_SAMPLES) - 1)) + | ||
1348 | (val * (AVG_FACTOR))) / (AVG_SAMPLES)) : | ||
1349 | (val * (AVG_FACTOR)); | ||
1350 | new.avg = new.avg_weight / (AVG_FACTOR); | ||
1351 | return new; | ||
1352 | } | ||
1353 | |||
1354 | #endif | 1438 | #endif |