diff options
Diffstat (limited to 'drivers/net/wireless/ath5k/ath5k.h')
-rw-r--r-- | drivers/net/wireless/ath5k/ath5k.h | 619 |
1 files changed, 389 insertions, 230 deletions
diff --git a/drivers/net/wireless/ath5k/ath5k.h b/drivers/net/wireless/ath5k/ath5k.h index 9102eea3c8bf..53ea439aff48 100644 --- a/drivers/net/wireless/ath5k/ath5k.h +++ b/drivers/net/wireless/ath5k/ath5k.h | |||
@@ -18,18 +18,23 @@ | |||
18 | #ifndef _ATH5K_H | 18 | #ifndef _ATH5K_H |
19 | #define _ATH5K_H | 19 | #define _ATH5K_H |
20 | 20 | ||
21 | /* Set this to 1 to disable regulatory domain restrictions for channel tests. | 21 | /* TODO: Clean up channel debuging -doesn't work anyway- and start |
22 | * WARNING: This is for debuging only and has side effects (eg. scan takes too | 22 | * working on reg. control code using all available eeprom information |
23 | * long and results timeouts). It's also illegal to tune to some of the | 23 | * -rev. engineering needed- */ |
24 | * supported frequencies in some countries, so use this at your own risk, | ||
25 | * you've been warned. */ | ||
26 | #define CHAN_DEBUG 0 | 24 | #define CHAN_DEBUG 0 |
27 | 25 | ||
28 | #include <linux/io.h> | 26 | #include <linux/io.h> |
29 | #include <linux/types.h> | 27 | #include <linux/types.h> |
30 | #include <net/mac80211.h> | 28 | #include <net/mac80211.h> |
31 | 29 | ||
32 | #include "hw.h" | 30 | /* RX/TX descriptor hw structs |
31 | * TODO: Driver part should only see sw structs */ | ||
32 | #include "desc.h" | ||
33 | |||
34 | /* EEPROM structs/offsets | ||
35 | * TODO: Make a more generic struct (eg. add more stuff to ath5k_capabilities) | ||
36 | * and clean up common bits, then introduce set/get functions in eeprom.c */ | ||
37 | #include "eeprom.h" | ||
33 | 38 | ||
34 | /* PCI IDs */ | 39 | /* PCI IDs */ |
35 | #define PCI_DEVICE_ID_ATHEROS_AR5210 0x0007 /* AR5210 */ | 40 | #define PCI_DEVICE_ID_ATHEROS_AR5210 0x0007 /* AR5210 */ |
@@ -87,7 +92,92 @@ | |||
87 | ATH5K_PRINTK_LIMIT(_sc, KERN_ERR, _fmt, ##__VA_ARGS__) | 92 | ATH5K_PRINTK_LIMIT(_sc, KERN_ERR, _fmt, ##__VA_ARGS__) |
88 | 93 | ||
89 | /* | 94 | /* |
95 | * AR5K REGISTER ACCESS | ||
96 | */ | ||
97 | |||
98 | /* Some macros to read/write fields */ | ||
99 | |||
100 | /* First shift, then mask */ | ||
101 | #define AR5K_REG_SM(_val, _flags) \ | ||
102 | (((_val) << _flags##_S) & (_flags)) | ||
103 | |||
104 | /* First mask, then shift */ | ||
105 | #define AR5K_REG_MS(_val, _flags) \ | ||
106 | (((_val) & (_flags)) >> _flags##_S) | ||
107 | |||
108 | /* Some registers can hold multiple values of interest. For this | ||
109 | * reason when we want to write to these registers we must first | ||
110 | * retrieve the values which we do not want to clear (lets call this | ||
111 | * old_data) and then set the register with this and our new_value: | ||
112 | * ( old_data | new_value) */ | ||
113 | #define AR5K_REG_WRITE_BITS(ah, _reg, _flags, _val) \ | ||
114 | ath5k_hw_reg_write(ah, (ath5k_hw_reg_read(ah, _reg) & ~(_flags)) | \ | ||
115 | (((_val) << _flags##_S) & (_flags)), _reg) | ||
116 | |||
117 | #define AR5K_REG_MASKED_BITS(ah, _reg, _flags, _mask) \ | ||
118 | ath5k_hw_reg_write(ah, (ath5k_hw_reg_read(ah, _reg) & \ | ||
119 | (_mask)) | (_flags), _reg) | ||
120 | |||
121 | #define AR5K_REG_ENABLE_BITS(ah, _reg, _flags) \ | ||
122 | ath5k_hw_reg_write(ah, ath5k_hw_reg_read(ah, _reg) | (_flags), _reg) | ||
123 | |||
124 | #define AR5K_REG_DISABLE_BITS(ah, _reg, _flags) \ | ||
125 | ath5k_hw_reg_write(ah, ath5k_hw_reg_read(ah, _reg) & ~(_flags), _reg) | ||
126 | |||
127 | /* Access to PHY registers */ | ||
128 | #define AR5K_PHY_READ(ah, _reg) \ | ||
129 | ath5k_hw_reg_read(ah, (ah)->ah_phy + ((_reg) << 2)) | ||
130 | |||
131 | #define AR5K_PHY_WRITE(ah, _reg, _val) \ | ||
132 | ath5k_hw_reg_write(ah, _val, (ah)->ah_phy + ((_reg) << 2)) | ||
133 | |||
134 | /* Access QCU registers per queue */ | ||
135 | #define AR5K_REG_READ_Q(ah, _reg, _queue) \ | ||
136 | (ath5k_hw_reg_read(ah, _reg) & (1 << _queue)) \ | ||
137 | |||
138 | #define AR5K_REG_WRITE_Q(ah, _reg, _queue) \ | ||
139 | ath5k_hw_reg_write(ah, (1 << _queue), _reg) | ||
140 | |||
141 | #define AR5K_Q_ENABLE_BITS(_reg, _queue) do { \ | ||
142 | _reg |= 1 << _queue; \ | ||
143 | } while (0) | ||
144 | |||
145 | #define AR5K_Q_DISABLE_BITS(_reg, _queue) do { \ | ||
146 | _reg &= ~(1 << _queue); \ | ||
147 | } while (0) | ||
148 | |||
149 | /* Used while writing initvals */ | ||
150 | #define AR5K_REG_WAIT(_i) do { \ | ||
151 | if (_i % 64) \ | ||
152 | udelay(1); \ | ||
153 | } while (0) | ||
154 | |||
155 | /* Register dumps are done per operation mode */ | ||
156 | #define AR5K_INI_RFGAIN_5GHZ 0 | ||
157 | #define AR5K_INI_RFGAIN_2GHZ 1 | ||
158 | |||
159 | /* TODO: Clean this up */ | ||
160 | #define AR5K_INI_VAL_11A 0 | ||
161 | #define AR5K_INI_VAL_11A_TURBO 1 | ||
162 | #define AR5K_INI_VAL_11B 2 | ||
163 | #define AR5K_INI_VAL_11G 3 | ||
164 | #define AR5K_INI_VAL_11G_TURBO 4 | ||
165 | #define AR5K_INI_VAL_XR 0 | ||
166 | #define AR5K_INI_VAL_MAX 5 | ||
167 | |||
168 | #define AR5K_RF5111_INI_RF_MAX_BANKS AR5K_MAX_RF_BANKS | ||
169 | #define AR5K_RF5112_INI_RF_MAX_BANKS AR5K_MAX_RF_BANKS | ||
170 | |||
171 | /* Used for BSSID etc manipulation */ | ||
172 | #define AR5K_LOW_ID(_a)( \ | ||
173 | (_a)[0] | (_a)[1] << 8 | (_a)[2] << 16 | (_a)[3] << 24 \ | ||
174 | ) | ||
175 | |||
176 | #define AR5K_HIGH_ID(_a) ((_a)[4] | (_a)[5] << 8) | ||
177 | |||
178 | /* | ||
90 | * Some tuneable values (these should be changeable by the user) | 179 | * Some tuneable values (these should be changeable by the user) |
180 | * TODO: Make use of them and add more options OR use debug/configfs | ||
91 | */ | 181 | */ |
92 | #define AR5K_TUNE_DMA_BEACON_RESP 2 | 182 | #define AR5K_TUNE_DMA_BEACON_RESP 2 |
93 | #define AR5K_TUNE_SW_BEACON_RESP 10 | 183 | #define AR5K_TUNE_SW_BEACON_RESP 10 |
@@ -98,13 +188,13 @@ | |||
98 | #define AR5K_TUNE_REGISTER_TIMEOUT 20000 | 188 | #define AR5K_TUNE_REGISTER_TIMEOUT 20000 |
99 | /* Register for RSSI threshold has a mask of 0xff, so 255 seems to | 189 | /* Register for RSSI threshold has a mask of 0xff, so 255 seems to |
100 | * be the max value. */ | 190 | * be the max value. */ |
101 | #define AR5K_TUNE_RSSI_THRES 129 | 191 | #define AR5K_TUNE_RSSI_THRES 129 |
102 | /* This must be set when setting the RSSI threshold otherwise it can | 192 | /* This must be set when setting the RSSI threshold otherwise it can |
103 | * prevent a reset. If AR5K_RSSI_THR is read after writing to it | 193 | * prevent a reset. If AR5K_RSSI_THR is read after writing to it |
104 | * the BMISS_THRES will be seen as 0, seems harware doesn't keep | 194 | * the BMISS_THRES will be seen as 0, seems harware doesn't keep |
105 | * track of it. Max value depends on harware. For AR5210 this is just 7. | 195 | * track of it. Max value depends on harware. For AR5210 this is just 7. |
106 | * For AR5211+ this seems to be up to 255. */ | 196 | * For AR5211+ this seems to be up to 255. */ |
107 | #define AR5K_TUNE_BMISS_THRES 7 | 197 | #define AR5K_TUNE_BMISS_THRES 7 |
108 | #define AR5K_TUNE_REGISTER_DWELL_TIME 20000 | 198 | #define AR5K_TUNE_REGISTER_DWELL_TIME 20000 |
109 | #define AR5K_TUNE_BEACON_INTERVAL 100 | 199 | #define AR5K_TUNE_BEACON_INTERVAL 100 |
110 | #define AR5K_TUNE_AIFS 2 | 200 | #define AR5K_TUNE_AIFS 2 |
@@ -123,6 +213,55 @@ | |||
123 | #define AR5K_TUNE_ANT_DIVERSITY true | 213 | #define AR5K_TUNE_ANT_DIVERSITY true |
124 | #define AR5K_TUNE_HWTXTRIES 4 | 214 | #define AR5K_TUNE_HWTXTRIES 4 |
125 | 215 | ||
216 | #define AR5K_INIT_CARR_SENSE_EN 1 | ||
217 | |||
218 | /*Swap RX/TX Descriptor for big endian archs*/ | ||
219 | #if defined(__BIG_ENDIAN) | ||
220 | #define AR5K_INIT_CFG ( \ | ||
221 | AR5K_CFG_SWTD | AR5K_CFG_SWRD \ | ||
222 | ) | ||
223 | #else | ||
224 | #define AR5K_INIT_CFG 0x00000000 | ||
225 | #endif | ||
226 | |||
227 | /* Initial values */ | ||
228 | #define AR5K_INIT_TX_LATENCY 502 | ||
229 | #define AR5K_INIT_USEC 39 | ||
230 | #define AR5K_INIT_USEC_TURBO 79 | ||
231 | #define AR5K_INIT_USEC_32 31 | ||
232 | #define AR5K_INIT_SLOT_TIME 396 | ||
233 | #define AR5K_INIT_SLOT_TIME_TURBO 480 | ||
234 | #define AR5K_INIT_ACK_CTS_TIMEOUT 1024 | ||
235 | #define AR5K_INIT_ACK_CTS_TIMEOUT_TURBO 0x08000800 | ||
236 | #define AR5K_INIT_PROG_IFS 920 | ||
237 | #define AR5K_INIT_PROG_IFS_TURBO 960 | ||
238 | #define AR5K_INIT_EIFS 3440 | ||
239 | #define AR5K_INIT_EIFS_TURBO 6880 | ||
240 | #define AR5K_INIT_SIFS 560 | ||
241 | #define AR5K_INIT_SIFS_TURBO 480 | ||
242 | #define AR5K_INIT_SH_RETRY 10 | ||
243 | #define AR5K_INIT_LG_RETRY AR5K_INIT_SH_RETRY | ||
244 | #define AR5K_INIT_SSH_RETRY 32 | ||
245 | #define AR5K_INIT_SLG_RETRY AR5K_INIT_SSH_RETRY | ||
246 | #define AR5K_INIT_TX_RETRY 10 | ||
247 | |||
248 | #define AR5K_INIT_TRANSMIT_LATENCY ( \ | ||
249 | (AR5K_INIT_TX_LATENCY << 14) | (AR5K_INIT_USEC_32 << 7) | \ | ||
250 | (AR5K_INIT_USEC) \ | ||
251 | ) | ||
252 | #define AR5K_INIT_TRANSMIT_LATENCY_TURBO ( \ | ||
253 | (AR5K_INIT_TX_LATENCY << 14) | (AR5K_INIT_USEC_32 << 7) | \ | ||
254 | (AR5K_INIT_USEC_TURBO) \ | ||
255 | ) | ||
256 | #define AR5K_INIT_PROTO_TIME_CNTRL ( \ | ||
257 | (AR5K_INIT_CARR_SENSE_EN << 26) | (AR5K_INIT_EIFS << 12) | \ | ||
258 | (AR5K_INIT_PROG_IFS) \ | ||
259 | ) | ||
260 | #define AR5K_INIT_PROTO_TIME_CNTRL_TURBO ( \ | ||
261 | (AR5K_INIT_CARR_SENSE_EN << 26) | (AR5K_INIT_EIFS_TURBO << 12) | \ | ||
262 | (AR5K_INIT_PROG_IFS_TURBO) \ | ||
263 | ) | ||
264 | |||
126 | /* token to use for aifs, cwmin, cwmax in MadWiFi */ | 265 | /* token to use for aifs, cwmin, cwmax in MadWiFi */ |
127 | #define AR5K_TXQ_USEDEFAULT ((u32) -1) | 266 | #define AR5K_TXQ_USEDEFAULT ((u32) -1) |
128 | 267 | ||
@@ -142,7 +281,9 @@ enum ath5k_radio { | |||
142 | AR5K_RF5112 = 2, | 281 | AR5K_RF5112 = 2, |
143 | AR5K_RF2413 = 3, | 282 | AR5K_RF2413 = 3, |
144 | AR5K_RF5413 = 4, | 283 | AR5K_RF5413 = 4, |
145 | AR5K_RF2425 = 5, | 284 | AR5K_RF2316 = 5, |
285 | AR5K_RF2317 = 6, | ||
286 | AR5K_RF2425 = 7, | ||
146 | }; | 287 | }; |
147 | 288 | ||
148 | /* | 289 | /* |
@@ -150,7 +291,7 @@ enum ath5k_radio { | |||
150 | */ | 291 | */ |
151 | 292 | ||
152 | enum ath5k_srev_type { | 293 | enum ath5k_srev_type { |
153 | AR5K_VERSION_VER, | 294 | AR5K_VERSION_MAC, |
154 | AR5K_VERSION_RAD, | 295 | AR5K_VERSION_RAD, |
155 | }; | 296 | }; |
156 | 297 | ||
@@ -162,23 +303,24 @@ struct ath5k_srev_name { | |||
162 | 303 | ||
163 | #define AR5K_SREV_UNKNOWN 0xffff | 304 | #define AR5K_SREV_UNKNOWN 0xffff |
164 | 305 | ||
165 | #define AR5K_SREV_VER_AR5210 0x00 | 306 | #define AR5K_SREV_AR5210 0x00 /* Crete */ |
166 | #define AR5K_SREV_VER_AR5311 0x10 | 307 | #define AR5K_SREV_AR5311 0x10 /* Maui 1 */ |
167 | #define AR5K_SREV_VER_AR5311A 0x20 | 308 | #define AR5K_SREV_AR5311A 0x20 /* Maui 2 */ |
168 | #define AR5K_SREV_VER_AR5311B 0x30 | 309 | #define AR5K_SREV_AR5311B 0x30 /* Spirit */ |
169 | #define AR5K_SREV_VER_AR5211 0x40 | 310 | #define AR5K_SREV_AR5211 0x40 /* Oahu */ |
170 | #define AR5K_SREV_VER_AR5212 0x50 | 311 | #define AR5K_SREV_AR5212 0x50 /* Venice */ |
171 | #define AR5K_SREV_VER_AR5213 0x55 | 312 | #define AR5K_SREV_AR5213 0x55 /* ??? */ |
172 | #define AR5K_SREV_VER_AR5213A 0x59 | 313 | #define AR5K_SREV_AR5213A 0x59 /* Hainan */ |
173 | #define AR5K_SREV_VER_AR2413 0x78 | 314 | #define AR5K_SREV_AR2413 0x78 /* Griffin lite */ |
174 | #define AR5K_SREV_VER_AR2414 0x79 | 315 | #define AR5K_SREV_AR2414 0x70 /* Griffin */ |
175 | #define AR5K_SREV_VER_AR2424 0xa0 /* PCI-E */ | 316 | #define AR5K_SREV_AR5424 0x90 /* Condor */ |
176 | #define AR5K_SREV_VER_AR5424 0xa3 /* PCI-E */ | 317 | #define AR5K_SREV_AR5413 0xa4 /* Eagle lite */ |
177 | #define AR5K_SREV_VER_AR5413 0xa4 | 318 | #define AR5K_SREV_AR5414 0xa0 /* Eagle */ |
178 | #define AR5K_SREV_VER_AR5414 0xa5 | 319 | #define AR5K_SREV_AR2415 0xb0 /* Cobra */ |
179 | #define AR5K_SREV_VER_AR5416 0xc0 /* PCI-E */ | 320 | #define AR5K_SREV_AR5416 0xc0 /* PCI-E */ |
180 | #define AR5K_SREV_VER_AR5418 0xca /* PCI-E */ | 321 | #define AR5K_SREV_AR5418 0xca /* PCI-E */ |
181 | #define AR5K_SREV_VER_AR2425 0xe2 /* PCI-E */ | 322 | #define AR5K_SREV_AR2425 0xe0 /* Swan */ |
323 | #define AR5K_SREV_AR2417 0xf0 /* Nala */ | ||
182 | 324 | ||
183 | #define AR5K_SREV_RAD_5110 0x00 | 325 | #define AR5K_SREV_RAD_5110 0x00 |
184 | #define AR5K_SREV_RAD_5111 0x10 | 326 | #define AR5K_SREV_RAD_5111 0x10 |
@@ -190,13 +332,22 @@ struct ath5k_srev_name { | |||
190 | #define AR5K_SREV_RAD_2112 0x40 | 332 | #define AR5K_SREV_RAD_2112 0x40 |
191 | #define AR5K_SREV_RAD_2112A 0x45 | 333 | #define AR5K_SREV_RAD_2112A 0x45 |
192 | #define AR5K_SREV_RAD_2112B 0x46 | 334 | #define AR5K_SREV_RAD_2112B 0x46 |
193 | #define AR5K_SREV_RAD_SC0 0x50 /* Found on 2413/2414 */ | 335 | #define AR5K_SREV_RAD_2413 0x50 |
194 | #define AR5K_SREV_RAD_SC1 0x60 /* Found on 5413/5414 */ | 336 | #define AR5K_SREV_RAD_5413 0x60 |
195 | #define AR5K_SREV_RAD_SC2 0xa0 /* Found on 2424-5/5424 */ | 337 | #define AR5K_SREV_RAD_2316 0x70 |
196 | #define AR5K_SREV_RAD_5133 0xc0 /* MIMO found on 5418 */ | 338 | #define AR5K_SREV_RAD_2317 0x80 |
339 | #define AR5K_SREV_RAD_5424 0xa0 /* Mostly same as 5413 */ | ||
340 | #define AR5K_SREV_RAD_2425 0xa2 | ||
341 | #define AR5K_SREV_RAD_5133 0xc0 | ||
342 | |||
343 | #define AR5K_SREV_PHY_5211 0x30 | ||
344 | #define AR5K_SREV_PHY_5212 0x41 | ||
345 | #define AR5K_SREV_PHY_2112B 0x43 | ||
346 | #define AR5K_SREV_PHY_2413 0x45 | ||
347 | #define AR5K_SREV_PHY_5413 0x61 | ||
348 | #define AR5K_SREV_PHY_2425 0x70 | ||
197 | 349 | ||
198 | /* IEEE defs */ | 350 | /* IEEE defs */ |
199 | |||
200 | #define IEEE80211_MAX_LEN 2500 | 351 | #define IEEE80211_MAX_LEN 2500 |
201 | 352 | ||
202 | /* TODO add support to mac80211 for vendor-specific rates and modes */ | 353 | /* TODO add support to mac80211 for vendor-specific rates and modes */ |
@@ -268,27 +419,21 @@ enum ath5k_driver_mode { | |||
268 | AR5K_MODE_MAX = 5 | 419 | AR5K_MODE_MAX = 5 |
269 | }; | 420 | }; |
270 | 421 | ||
271 | /* adding this flag to rate_code enables short preamble, see ar5212_reg.h */ | ||
272 | #define AR5K_SET_SHORT_PREAMBLE 0x04 | ||
273 | |||
274 | #define HAS_SHPREAMBLE(_ix) \ | ||
275 | (rt->rates[_ix].modulation == IEEE80211_RATE_SHORT_PREAMBLE) | ||
276 | #define SHPREAMBLE_FLAG(_ix) \ | ||
277 | (HAS_SHPREAMBLE(_ix) ? AR5K_SET_SHORT_PREAMBLE : 0) | ||
278 | |||
279 | 422 | ||
280 | /****************\ | 423 | /****************\ |
281 | TX DEFINITIONS | 424 | TX DEFINITIONS |
282 | \****************/ | 425 | \****************/ |
283 | 426 | ||
284 | /* | 427 | /* |
285 | * TX Status | 428 | * TX Status descriptor |
286 | */ | 429 | */ |
287 | struct ath5k_tx_status { | 430 | struct ath5k_tx_status { |
288 | u16 ts_seqnum; | 431 | u16 ts_seqnum; |
289 | u16 ts_tstamp; | 432 | u16 ts_tstamp; |
290 | u8 ts_status; | 433 | u8 ts_status; |
291 | u8 ts_rate; | 434 | u8 ts_rate[4]; |
435 | u8 ts_retry[4]; | ||
436 | u8 ts_final_idx; | ||
292 | s8 ts_rssi; | 437 | s8 ts_rssi; |
293 | u8 ts_shortretry; | 438 | u8 ts_shortretry; |
294 | u8 ts_longretry; | 439 | u8 ts_longretry; |
@@ -354,7 +499,6 @@ enum ath5k_tx_queue_id { | |||
354 | AR5K_TX_QUEUE_ID_XR_DATA = 9, | 499 | AR5K_TX_QUEUE_ID_XR_DATA = 9, |
355 | }; | 500 | }; |
356 | 501 | ||
357 | |||
358 | /* | 502 | /* |
359 | * Flags to set hw queue's parameters... | 503 | * Flags to set hw queue's parameters... |
360 | */ | 504 | */ |
@@ -387,7 +531,8 @@ struct ath5k_txq_info { | |||
387 | 531 | ||
388 | /* | 532 | /* |
389 | * Transmit packet types. | 533 | * Transmit packet types. |
390 | * These are not fully used inside OpenHAL yet | 534 | * used on tx control descriptor |
535 | * TODO: Use them inside base.c corectly | ||
391 | */ | 536 | */ |
392 | enum ath5k_pkt_type { | 537 | enum ath5k_pkt_type { |
393 | AR5K_PKT_TYPE_NORMAL = 0, | 538 | AR5K_PKT_TYPE_NORMAL = 0, |
@@ -430,7 +575,7 @@ enum ath5k_dmasize { | |||
430 | \****************/ | 575 | \****************/ |
431 | 576 | ||
432 | /* | 577 | /* |
433 | * RX Status | 578 | * RX Status descriptor |
434 | */ | 579 | */ |
435 | struct ath5k_rx_status { | 580 | struct ath5k_rx_status { |
436 | u16 rs_datalen; | 581 | u16 rs_datalen; |
@@ -494,34 +639,59 @@ struct ath5k_beacon_state { | |||
494 | #define TSF_TO_TU(_tsf) (u32)((_tsf) >> 10) | 639 | #define TSF_TO_TU(_tsf) (u32)((_tsf) >> 10) |
495 | 640 | ||
496 | 641 | ||
642 | /*******************************\ | ||
643 | GAIN OPTIMIZATION DEFINITIONS | ||
644 | \*******************************/ | ||
645 | |||
646 | enum ath5k_rfgain { | ||
647 | AR5K_RFGAIN_INACTIVE = 0, | ||
648 | AR5K_RFGAIN_READ_REQUESTED, | ||
649 | AR5K_RFGAIN_NEED_CHANGE, | ||
650 | }; | ||
651 | |||
652 | #define AR5K_GAIN_CRN_FIX_BITS_5111 4 | ||
653 | #define AR5K_GAIN_CRN_FIX_BITS_5112 7 | ||
654 | #define AR5K_GAIN_CRN_MAX_FIX_BITS AR5K_GAIN_CRN_FIX_BITS_5112 | ||
655 | #define AR5K_GAIN_DYN_ADJUST_HI_MARGIN 15 | ||
656 | #define AR5K_GAIN_DYN_ADJUST_LO_MARGIN 20 | ||
657 | #define AR5K_GAIN_CCK_PROBE_CORR 5 | ||
658 | #define AR5K_GAIN_CCK_OFDM_GAIN_DELTA 15 | ||
659 | #define AR5K_GAIN_STEP_COUNT 10 | ||
660 | #define AR5K_GAIN_PARAM_TX_CLIP 0 | ||
661 | #define AR5K_GAIN_PARAM_PD_90 1 | ||
662 | #define AR5K_GAIN_PARAM_PD_84 2 | ||
663 | #define AR5K_GAIN_PARAM_GAIN_SEL 3 | ||
664 | #define AR5K_GAIN_PARAM_MIX_ORN 0 | ||
665 | #define AR5K_GAIN_PARAM_PD_138 1 | ||
666 | #define AR5K_GAIN_PARAM_PD_137 2 | ||
667 | #define AR5K_GAIN_PARAM_PD_136 3 | ||
668 | #define AR5K_GAIN_PARAM_PD_132 4 | ||
669 | #define AR5K_GAIN_PARAM_PD_131 5 | ||
670 | #define AR5K_GAIN_PARAM_PD_130 6 | ||
671 | #define AR5K_GAIN_CHECK_ADJUST(_g) \ | ||
672 | ((_g)->g_current <= (_g)->g_low || (_g)->g_current >= (_g)->g_high) | ||
673 | |||
674 | struct ath5k_gain_opt_step { | ||
675 | s16 gos_param[AR5K_GAIN_CRN_MAX_FIX_BITS]; | ||
676 | s32 gos_gain; | ||
677 | }; | ||
678 | |||
679 | struct ath5k_gain { | ||
680 | u32 g_step_idx; | ||
681 | u32 g_current; | ||
682 | u32 g_target; | ||
683 | u32 g_low; | ||
684 | u32 g_high; | ||
685 | u32 g_f_corr; | ||
686 | u32 g_active; | ||
687 | const struct ath5k_gain_opt_step *g_step; | ||
688 | }; | ||
689 | |||
690 | |||
497 | /********************\ | 691 | /********************\ |
498 | COMMON DEFINITIONS | 692 | COMMON DEFINITIONS |
499 | \********************/ | 693 | \********************/ |
500 | 694 | ||
501 | /* | ||
502 | * Atheros hardware descriptor | ||
503 | * This is read and written to by the hardware | ||
504 | */ | ||
505 | struct ath5k_desc { | ||
506 | u32 ds_link; /* physical address of the next descriptor */ | ||
507 | u32 ds_data; /* physical address of data buffer (skb) */ | ||
508 | |||
509 | union { | ||
510 | struct ath5k_hw_5210_tx_desc ds_tx5210; | ||
511 | struct ath5k_hw_5212_tx_desc ds_tx5212; | ||
512 | struct ath5k_hw_all_rx_desc ds_rx; | ||
513 | } ud; | ||
514 | } __packed; | ||
515 | |||
516 | #define AR5K_RXDESC_INTREQ 0x0020 | ||
517 | |||
518 | #define AR5K_TXDESC_CLRDMASK 0x0001 | ||
519 | #define AR5K_TXDESC_NOACK 0x0002 /*[5211+]*/ | ||
520 | #define AR5K_TXDESC_RTSENA 0x0004 | ||
521 | #define AR5K_TXDESC_CTSENA 0x0008 | ||
522 | #define AR5K_TXDESC_INTREQ 0x0010 | ||
523 | #define AR5K_TXDESC_VEOL 0x0020 /*[5211+]*/ | ||
524 | |||
525 | #define AR5K_SLOT_TIME_9 396 | 695 | #define AR5K_SLOT_TIME_9 396 |
526 | #define AR5K_SLOT_TIME_20 880 | 696 | #define AR5K_SLOT_TIME_20 880 |
527 | #define AR5K_SLOT_TIME_MAX 0xffff | 697 | #define AR5K_SLOT_TIME_MAX 0xffff |
@@ -553,167 +723,79 @@ struct ath5k_desc { | |||
553 | #define CHANNEL_MODES CHANNEL_ALL | 723 | #define CHANNEL_MODES CHANNEL_ALL |
554 | 724 | ||
555 | /* | 725 | /* |
556 | * Used internaly in OpenHAL (ar5211.c/ar5212.c | 726 | * Used internaly for reset_tx_queue). |
557 | * for reset_tx_queue). Also see struct struct ieee80211_channel. | 727 | * Also see struct struct ieee80211_channel. |
558 | */ | 728 | */ |
559 | #define IS_CHAN_XR(_c) ((_c.hw_value & CHANNEL_XR) != 0) | 729 | #define IS_CHAN_XR(_c) ((_c.hw_value & CHANNEL_XR) != 0) |
560 | #define IS_CHAN_B(_c) ((_c.hw_value & CHANNEL_B) != 0) | 730 | #define IS_CHAN_B(_c) ((_c.hw_value & CHANNEL_B) != 0) |
561 | 731 | ||
562 | /* | 732 | /* |
563 | * The following structure will be used to map 2GHz channels to | 733 | * The following structure is used to map 2GHz channels to |
564 | * 5GHz Atheros channels. | 734 | * 5GHz Atheros channels. |
735 | * TODO: Clean up | ||
565 | */ | 736 | */ |
566 | struct ath5k_athchan_2ghz { | 737 | struct ath5k_athchan_2ghz { |
567 | u32 a2_flags; | 738 | u32 a2_flags; |
568 | u16 a2_athchan; | 739 | u16 a2_athchan; |
569 | }; | 740 | }; |
570 | 741 | ||
571 | /* | ||
572 | * Rate definitions | ||
573 | * TODO: Clean them up or move them on mac80211 -most of these infos are | ||
574 | * used by the rate control algorytm on MadWiFi. | ||
575 | */ | ||
576 | 742 | ||
577 | /* Max number of rates on the rate table and what it seems | 743 | /******************\ |
578 | * Atheros hardware supports */ | 744 | RATE DEFINITIONS |
579 | #define AR5K_MAX_RATES 32 | 745 | \******************/ |
580 | 746 | ||
581 | /** | 747 | /** |
582 | * struct ath5k_rate - rate structure | 748 | * Seems the ar5xxx harware supports up to 32 rates, indexed by 1-32. |
583 | * @valid: is this a valid rate for rate control (remove) | ||
584 | * @modulation: respective mac80211 modulation | ||
585 | * @rate_kbps: rate in kbit/s | ||
586 | * @rate_code: hardware rate value, used in &struct ath5k_desc, on RX on | ||
587 | * &struct ath5k_rx_status.rs_rate and on TX on | ||
588 | * &struct ath5k_tx_status.ts_rate. Seems the ar5xxx harware supports | ||
589 | * up to 32 rates, indexed by 1-32. This means we really only need | ||
590 | * 6 bits for the rate_code. | ||
591 | * @dot11_rate: respective IEEE-802.11 rate value | ||
592 | * @control_rate: index of rate assumed to be used to send control frames. | ||
593 | * This can be used to set override the value on the rate duration | ||
594 | * registers. This is only useful if we can override in the harware at | ||
595 | * what rate we want to send control frames at. Note that IEEE-802.11 | ||
596 | * Ch. 9.6 (after IEEE 802.11g changes) defines the rate at which we | ||
597 | * should send ACK/CTS, if we change this value we can be breaking | ||
598 | * the spec. | ||
599 | * | 749 | * |
600 | * This structure is used to get the RX rate or set the TX rate on the | 750 | * The rate code is used to get the RX rate or set the TX rate on the |
601 | * hardware descriptors. It is also used for internal modulation control | 751 | * hardware descriptors. It is also used for internal modulation control |
602 | * and settings. | 752 | * and settings. |
603 | * | 753 | * |
604 | * On RX after the &struct ath5k_desc is parsed by the appropriate | 754 | * This is the hardware rate map we are aware of: |
605 | * ah_proc_rx_desc() the respective hardware rate value is set in | ||
606 | * &struct ath5k_rx_status.rs_rate. On TX the desired rate is set in | ||
607 | * &struct ath5k_tx_status.ts_rate which is later used to setup the | ||
608 | * &struct ath5k_desc correctly. This is the hardware rate map we are | ||
609 | * aware of: | ||
610 | * | 755 | * |
611 | * rate_code 1 2 3 4 5 6 7 8 | 756 | * rate_code 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 |
612 | * rate_kbps 3000 1000 ? ? ? 2000 500 48000 | 757 | * rate_kbps 3000 1000 ? ? ? 2000 500 48000 |
613 | * | 758 | * |
614 | * rate_code 9 10 11 12 13 14 15 16 | 759 | * rate_code 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10 |
615 | * rate_kbps 24000 12000 6000 54000 36000 18000 9000 ? | 760 | * rate_kbps 24000 12000 6000 54000 36000 18000 9000 ? |
616 | * | 761 | * |
617 | * rate_code 17 18 19 20 21 22 23 24 | 762 | * rate_code 17 18 19 20 21 22 23 24 |
618 | * rate_kbps ? ? ? ? ? ? ? 11000 | 763 | * rate_kbps ? ? ? ? ? ? ? 11000 |
619 | * | 764 | * |
620 | * rate_code 25 26 27 28 29 30 31 32 | 765 | * rate_code 25 26 27 28 29 30 31 32 |
621 | * rate_kbps 5500 2000 1000 ? ? ? ? ? | 766 | * rate_kbps 5500 2000 1000 11000S 5500S 2000S ? ? |
622 | * | 767 | * |
768 | * "S" indicates CCK rates with short preamble. | ||
769 | * | ||
770 | * AR5211 has different rate codes for CCK (802.11B) rates. It only uses the | ||
771 | * lowest 4 bits, so they are the same as below with a 0xF mask. | ||
772 | * (0xB, 0xA, 0x9 and 0x8 for 1M, 2M, 5.5M and 11M). | ||
773 | * We handle this in ath5k_setup_bands(). | ||
623 | */ | 774 | */ |
624 | struct ath5k_rate { | 775 | #define AR5K_MAX_RATES 32 |
625 | u8 valid; | ||
626 | u32 modulation; | ||
627 | u16 rate_kbps; | ||
628 | u8 rate_code; | ||
629 | u8 dot11_rate; | ||
630 | u8 control_rate; | ||
631 | }; | ||
632 | |||
633 | /* XXX: GRR all this stuff to get leds blinking ??? (check out setcurmode) */ | ||
634 | struct ath5k_rate_table { | ||
635 | u16 rate_count; | ||
636 | u8 rate_code_to_index[AR5K_MAX_RATES]; /* Back-mapping */ | ||
637 | struct ath5k_rate rates[AR5K_MAX_RATES]; | ||
638 | }; | ||
639 | |||
640 | /* | ||
641 | * Rate tables... | ||
642 | * TODO: CLEAN THIS !!! | ||
643 | */ | ||
644 | #define AR5K_RATES_11A { 8, { \ | ||
645 | 255, 255, 255, 255, 255, 255, 255, 255, 6, 4, 2, 0, \ | ||
646 | 7, 5, 3, 1, 255, 255, 255, 255, 255, 255, 255, 255, \ | ||
647 | 255, 255, 255, 255, 255, 255, 255, 255 }, { \ | ||
648 | { 1, 0, 6000, 11, 140, 0 }, \ | ||
649 | { 1, 0, 9000, 15, 18, 0 }, \ | ||
650 | { 1, 0, 12000, 10, 152, 2 }, \ | ||
651 | { 1, 0, 18000, 14, 36, 2 }, \ | ||
652 | { 1, 0, 24000, 9, 176, 4 }, \ | ||
653 | { 1, 0, 36000, 13, 72, 4 }, \ | ||
654 | { 1, 0, 48000, 8, 96, 4 }, \ | ||
655 | { 1, 0, 54000, 12, 108, 4 } } \ | ||
656 | } | ||
657 | |||
658 | #define AR5K_RATES_11B { 4, { \ | ||
659 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, \ | ||
660 | 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, \ | ||
661 | 3, 2, 1, 0, 255, 255, 255, 255 }, { \ | ||
662 | { 1, 0, 1000, 27, 130, 0 }, \ | ||
663 | { 1, IEEE80211_RATE_SHORT_PREAMBLE, 2000, 26, 132, 1 }, \ | ||
664 | { 1, IEEE80211_RATE_SHORT_PREAMBLE, 5500, 25, 139, 1 }, \ | ||
665 | { 1, IEEE80211_RATE_SHORT_PREAMBLE, 11000, 24, 150, 1 } } \ | ||
666 | } | ||
667 | |||
668 | #define AR5K_RATES_11G { 12, { \ | ||
669 | 255, 255, 255, 255, 255, 255, 255, 255, 10, 8, 6, 4, \ | ||
670 | 11, 9, 7, 5, 255, 255, 255, 255, 255, 255, 255, 255, \ | ||
671 | 3, 2, 1, 0, 255, 255, 255, 255 }, { \ | ||
672 | { 1, 0, 1000, 27, 2, 0 }, \ | ||
673 | { 1, IEEE80211_RATE_SHORT_PREAMBLE, 2000, 26, 4, 1 }, \ | ||
674 | { 1, IEEE80211_RATE_SHORT_PREAMBLE, 5500, 25, 11, 1 }, \ | ||
675 | { 1, IEEE80211_RATE_SHORT_PREAMBLE, 11000, 24, 22, 1 }, \ | ||
676 | { 0, 0, 6000, 11, 12, 4 }, \ | ||
677 | { 0, 0, 9000, 15, 18, 4 }, \ | ||
678 | { 1, 0, 12000, 10, 24, 6 }, \ | ||
679 | { 1, 0, 18000, 14, 36, 6 }, \ | ||
680 | { 1, 0, 24000, 9, 48, 8 }, \ | ||
681 | { 1, 0, 36000, 13, 72, 8 }, \ | ||
682 | { 1, 0, 48000, 8, 96, 8 }, \ | ||
683 | { 1, 0, 54000, 12, 108, 8 } } \ | ||
684 | } | ||
685 | |||
686 | #define AR5K_RATES_TURBO { 8, { \ | ||
687 | 255, 255, 255, 255, 255, 255, 255, 255, 6, 4, 2, 0, \ | ||
688 | 7, 5, 3, 1, 255, 255, 255, 255, 255, 255, 255, 255, \ | ||
689 | 255, 255, 255, 255, 255, 255, 255, 255 }, { \ | ||
690 | { 1, MODULATION_TURBO, 6000, 11, 140, 0 }, \ | ||
691 | { 1, MODULATION_TURBO, 9000, 15, 18, 0 }, \ | ||
692 | { 1, MODULATION_TURBO, 12000, 10, 152, 2 }, \ | ||
693 | { 1, MODULATION_TURBO, 18000, 14, 36, 2 }, \ | ||
694 | { 1, MODULATION_TURBO, 24000, 9, 176, 4 }, \ | ||
695 | { 1, MODULATION_TURBO, 36000, 13, 72, 4 }, \ | ||
696 | { 1, MODULATION_TURBO, 48000, 8, 96, 4 }, \ | ||
697 | { 1, MODULATION_TURBO, 54000, 12, 108, 4 } } \ | ||
698 | } | ||
699 | 776 | ||
700 | #define AR5K_RATES_XR { 12, { \ | 777 | /* B */ |
701 | 255, 3, 1, 255, 255, 255, 2, 0, 10, 8, 6, 4, \ | 778 | #define ATH5K_RATE_CODE_1M 0x1B |
702 | 11, 9, 7, 5, 255, 255, 255, 255, 255, 255, 255, 255, \ | 779 | #define ATH5K_RATE_CODE_2M 0x1A |
703 | 255, 255, 255, 255, 255, 255, 255, 255 }, { \ | 780 | #define ATH5K_RATE_CODE_5_5M 0x19 |
704 | { 1, MODULATION_XR, 500, 7, 129, 0 }, \ | 781 | #define ATH5K_RATE_CODE_11M 0x18 |
705 | { 1, MODULATION_XR, 1000, 2, 139, 1 }, \ | 782 | /* A and G */ |
706 | { 1, MODULATION_XR, 2000, 6, 150, 2 }, \ | 783 | #define ATH5K_RATE_CODE_6M 0x0B |
707 | { 1, MODULATION_XR, 3000, 1, 150, 3 }, \ | 784 | #define ATH5K_RATE_CODE_9M 0x0F |
708 | { 1, 0, 6000, 11, 140, 4 }, \ | 785 | #define ATH5K_RATE_CODE_12M 0x0A |
709 | { 1, 0, 9000, 15, 18, 4 }, \ | 786 | #define ATH5K_RATE_CODE_18M 0x0E |
710 | { 1, 0, 12000, 10, 152, 6 }, \ | 787 | #define ATH5K_RATE_CODE_24M 0x09 |
711 | { 1, 0, 18000, 14, 36, 6 }, \ | 788 | #define ATH5K_RATE_CODE_36M 0x0D |
712 | { 1, 0, 24000, 9, 176, 8 }, \ | 789 | #define ATH5K_RATE_CODE_48M 0x08 |
713 | { 1, 0, 36000, 13, 72, 8 }, \ | 790 | #define ATH5K_RATE_CODE_54M 0x0C |
714 | { 1, 0, 48000, 8, 96, 8 }, \ | 791 | /* XR */ |
715 | { 1, 0, 54000, 12, 108, 8 } } \ | 792 | #define ATH5K_RATE_CODE_XR_500K 0x07 |
716 | } | 793 | #define ATH5K_RATE_CODE_XR_1M 0x02 |
794 | #define ATH5K_RATE_CODE_XR_2M 0x06 | ||
795 | #define ATH5K_RATE_CODE_XR_3M 0x01 | ||
796 | |||
797 | /* adding this flag to rate_code enables short preamble */ | ||
798 | #define AR5K_SET_SHORT_PREAMBLE 0x04 | ||
717 | 799 | ||
718 | /* | 800 | /* |
719 | * Crypto definitions | 801 | * Crypto definitions |
@@ -735,7 +817,6 @@ struct ath5k_rate_table { | |||
735 | return (false); \ | 817 | return (false); \ |
736 | } while (0) | 818 | } while (0) |
737 | 819 | ||
738 | |||
739 | enum ath5k_ant_setting { | 820 | enum ath5k_ant_setting { |
740 | AR5K_ANT_VARIABLE = 0, /* variable by programming */ | 821 | AR5K_ANT_VARIABLE = 0, /* variable by programming */ |
741 | AR5K_ANT_FIXED_A = 1, /* fixed to 11a frequencies */ | 822 | AR5K_ANT_FIXED_A = 1, /* fixed to 11a frequencies */ |
@@ -846,7 +927,8 @@ enum ath5k_power_mode { | |||
846 | 927 | ||
847 | /* | 928 | /* |
848 | * These match net80211 definitions (not used in | 929 | * These match net80211 definitions (not used in |
849 | * d80211). | 930 | * mac80211). |
931 | * TODO: Clean this up | ||
850 | */ | 932 | */ |
851 | #define AR5K_LED_INIT 0 /*IEEE80211_S_INIT*/ | 933 | #define AR5K_LED_INIT 0 /*IEEE80211_S_INIT*/ |
852 | #define AR5K_LED_SCAN 1 /*IEEE80211_S_SCAN*/ | 934 | #define AR5K_LED_SCAN 1 /*IEEE80211_S_SCAN*/ |
@@ -862,7 +944,8 @@ enum ath5k_power_mode { | |||
862 | /* | 944 | /* |
863 | * Chipset capabilities -see ath5k_hw_get_capability- | 945 | * Chipset capabilities -see ath5k_hw_get_capability- |
864 | * get_capability function is not yet fully implemented | 946 | * get_capability function is not yet fully implemented |
865 | * in OpenHAL so most of these don't work yet... | 947 | * in ath5k so most of these don't work yet... |
948 | * TODO: Implement these & merge with _TUNE_ stuff above | ||
866 | */ | 949 | */ |
867 | enum ath5k_capability_type { | 950 | enum ath5k_capability_type { |
868 | AR5K_CAP_REG_DMN = 0, /* Used to get current reg. domain id */ | 951 | AR5K_CAP_REG_DMN = 0, /* Used to get current reg. domain id */ |
@@ -931,6 +1014,7 @@ struct ath5k_capabilities { | |||
931 | #define AR5K_MAX_GPIO 10 | 1014 | #define AR5K_MAX_GPIO 10 |
932 | #define AR5K_MAX_RF_BANKS 8 | 1015 | #define AR5K_MAX_RF_BANKS 8 |
933 | 1016 | ||
1017 | /* TODO: Clean up and merge with ath5k_softc */ | ||
934 | struct ath5k_hw { | 1018 | struct ath5k_hw { |
935 | u32 ah_magic; | 1019 | u32 ah_magic; |
936 | 1020 | ||
@@ -939,7 +1023,7 @@ struct ath5k_hw { | |||
939 | 1023 | ||
940 | enum ath5k_int ah_imr; | 1024 | enum ath5k_int ah_imr; |
941 | 1025 | ||
942 | enum ieee80211_if_types ah_op_mode; | 1026 | enum nl80211_iftype ah_op_mode; |
943 | enum ath5k_power_mode ah_power_mode; | 1027 | enum ath5k_power_mode ah_power_mode; |
944 | struct ieee80211_channel ah_current_channel; | 1028 | struct ieee80211_channel ah_current_channel; |
945 | bool ah_turbo; | 1029 | bool ah_turbo; |
@@ -1023,11 +1107,13 @@ struct ath5k_hw { | |||
1023 | /* | 1107 | /* |
1024 | * Function pointers | 1108 | * Function pointers |
1025 | */ | 1109 | */ |
1110 | int (*ah_setup_rx_desc)(struct ath5k_hw *ah, struct ath5k_desc *desc, | ||
1111 | u32 size, unsigned int flags); | ||
1026 | int (*ah_setup_tx_desc)(struct ath5k_hw *, struct ath5k_desc *, | 1112 | int (*ah_setup_tx_desc)(struct ath5k_hw *, struct ath5k_desc *, |
1027 | unsigned int, unsigned int, enum ath5k_pkt_type, unsigned int, | 1113 | unsigned int, unsigned int, enum ath5k_pkt_type, unsigned int, |
1028 | unsigned int, unsigned int, unsigned int, unsigned int, | 1114 | unsigned int, unsigned int, unsigned int, unsigned int, |
1029 | unsigned int, unsigned int, unsigned int); | 1115 | unsigned int, unsigned int, unsigned int); |
1030 | int (*ah_setup_xtx_desc)(struct ath5k_hw *, struct ath5k_desc *, | 1116 | int (*ah_setup_mrr_tx_desc)(struct ath5k_hw *, struct ath5k_desc *, |
1031 | unsigned int, unsigned int, unsigned int, unsigned int, | 1117 | unsigned int, unsigned int, unsigned int, unsigned int, |
1032 | unsigned int, unsigned int); | 1118 | unsigned int, unsigned int); |
1033 | int (*ah_proc_tx_desc)(struct ath5k_hw *, struct ath5k_desc *, | 1119 | int (*ah_proc_tx_desc)(struct ath5k_hw *, struct ath5k_desc *, |
@@ -1040,33 +1126,38 @@ struct ath5k_hw { | |||
1040 | * Prototypes | 1126 | * Prototypes |
1041 | */ | 1127 | */ |
1042 | 1128 | ||
1043 | /* General Functions */ | ||
1044 | extern int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val, bool is_set); | ||
1045 | /* Attach/Detach Functions */ | 1129 | /* Attach/Detach Functions */ |
1046 | extern struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version); | 1130 | extern struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version); |
1047 | extern const struct ath5k_rate_table *ath5k_hw_get_rate_table(struct ath5k_hw *ah, unsigned int mode); | ||
1048 | extern void ath5k_hw_detach(struct ath5k_hw *ah); | 1131 | extern void ath5k_hw_detach(struct ath5k_hw *ah); |
1132 | |||
1049 | /* Reset Functions */ | 1133 | /* Reset Functions */ |
1050 | extern int ath5k_hw_reset(struct ath5k_hw *ah, enum ieee80211_if_types op_mode, struct ieee80211_channel *channel, bool change_channel); | 1134 | extern int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial); |
1135 | extern int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, struct ieee80211_channel *channel, bool change_channel); | ||
1051 | /* Power management functions */ | 1136 | /* Power management functions */ |
1052 | extern int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, bool set_chip, u16 sleep_duration); | 1137 | extern int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, bool set_chip, u16 sleep_duration); |
1138 | |||
1053 | /* DMA Related Functions */ | 1139 | /* DMA Related Functions */ |
1054 | extern void ath5k_hw_start_rx(struct ath5k_hw *ah); | 1140 | extern void ath5k_hw_start_rx_dma(struct ath5k_hw *ah); |
1055 | extern int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah); | 1141 | extern int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah); |
1056 | extern u32 ath5k_hw_get_rx_buf(struct ath5k_hw *ah); | 1142 | extern u32 ath5k_hw_get_rxdp(struct ath5k_hw *ah); |
1057 | extern void ath5k_hw_put_rx_buf(struct ath5k_hw *ah, u32 phys_addr); | 1143 | extern void ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr); |
1058 | extern int ath5k_hw_tx_start(struct ath5k_hw *ah, unsigned int queue); | 1144 | extern int ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue); |
1059 | extern int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue); | 1145 | extern int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue); |
1060 | extern u32 ath5k_hw_get_tx_buf(struct ath5k_hw *ah, unsigned int queue); | 1146 | extern u32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue); |
1061 | extern int ath5k_hw_put_tx_buf(struct ath5k_hw *ah, unsigned int queue, u32 phys_addr); | 1147 | extern int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue, |
1148 | u32 phys_addr); | ||
1062 | extern int ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase); | 1149 | extern int ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase); |
1063 | /* Interrupt handling */ | 1150 | /* Interrupt handling */ |
1064 | extern bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah); | 1151 | extern bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah); |
1065 | extern int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask); | 1152 | extern int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask); |
1066 | extern enum ath5k_int ath5k_hw_set_intr(struct ath5k_hw *ah, enum ath5k_int new_mask); | 1153 | extern enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum |
1154 | ath5k_int new_mask); | ||
1067 | extern void ath5k_hw_update_mib_counters(struct ath5k_hw *ah, struct ieee80211_low_level_stats *stats); | 1155 | extern void ath5k_hw_update_mib_counters(struct ath5k_hw *ah, struct ieee80211_low_level_stats *stats); |
1156 | |||
1068 | /* EEPROM access functions */ | 1157 | /* EEPROM access functions */ |
1069 | extern int ath5k_hw_set_regdomain(struct ath5k_hw *ah, u16 regdomain); | 1158 | extern int ath5k_eeprom_init(struct ath5k_hw *ah); |
1159 | extern int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac); | ||
1160 | |||
1070 | /* Protocol Control Unit Functions */ | 1161 | /* Protocol Control Unit Functions */ |
1071 | extern int ath5k_hw_set_opmode(struct ath5k_hw *ah); | 1162 | extern int ath5k_hw_set_opmode(struct ath5k_hw *ah); |
1072 | /* BSSID Functions */ | 1163 | /* BSSID Functions */ |
@@ -1076,14 +1167,14 @@ extern void ath5k_hw_set_associd(struct ath5k_hw *ah, const u8 *bssid, u16 assoc | |||
1076 | extern int ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask); | 1167 | extern int ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask); |
1077 | /* Receive start/stop functions */ | 1168 | /* Receive start/stop functions */ |
1078 | extern void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah); | 1169 | extern void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah); |
1079 | extern void ath5k_hw_stop_pcu_recv(struct ath5k_hw *ah); | 1170 | extern void ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah); |
1080 | /* RX Filter functions */ | 1171 | /* RX Filter functions */ |
1081 | extern void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1); | 1172 | extern void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1); |
1082 | extern int ath5k_hw_set_mcast_filterindex(struct ath5k_hw *ah, u32 index); | 1173 | extern int ath5k_hw_set_mcast_filter_idx(struct ath5k_hw *ah, u32 index); |
1083 | extern int ath5k_hw_clear_mcast_filter_idx(struct ath5k_hw *ah, u32 index); | 1174 | extern int ath5k_hw_clear_mcast_filter_idx(struct ath5k_hw *ah, u32 index); |
1084 | extern u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah); | 1175 | extern u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah); |
1085 | extern void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter); | 1176 | extern void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter); |
1086 | /* Beacon related functions */ | 1177 | /* Beacon control functions */ |
1087 | extern u32 ath5k_hw_get_tsf32(struct ath5k_hw *ah); | 1178 | extern u32 ath5k_hw_get_tsf32(struct ath5k_hw *ah); |
1088 | extern u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah); | 1179 | extern u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah); |
1089 | extern void ath5k_hw_reset_tsf(struct ath5k_hw *ah); | 1180 | extern void ath5k_hw_reset_tsf(struct ath5k_hw *ah); |
@@ -1105,61 +1196,129 @@ extern int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry); | |||
1105 | extern int ath5k_hw_is_key_valid(struct ath5k_hw *ah, u16 entry); | 1196 | extern int ath5k_hw_is_key_valid(struct ath5k_hw *ah, u16 entry); |
1106 | extern int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry, const struct ieee80211_key_conf *key, const u8 *mac); | 1197 | extern int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry, const struct ieee80211_key_conf *key, const u8 *mac); |
1107 | extern int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac); | 1198 | extern int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac); |
1199 | |||
1108 | /* Queue Control Unit, DFS Control Unit Functions */ | 1200 | /* Queue Control Unit, DFS Control Unit Functions */ |
1109 | extern int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, enum ath5k_tx_queue queue_type, struct ath5k_txq_info *queue_info); | ||
1110 | extern int ath5k_hw_setup_tx_queueprops(struct ath5k_hw *ah, int queue, const struct ath5k_txq_info *queue_info); | ||
1111 | extern int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, struct ath5k_txq_info *queue_info); | 1201 | extern int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, struct ath5k_txq_info *queue_info); |
1202 | extern int ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue, | ||
1203 | const struct ath5k_txq_info *queue_info); | ||
1204 | extern int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, | ||
1205 | enum ath5k_tx_queue queue_type, | ||
1206 | struct ath5k_txq_info *queue_info); | ||
1207 | extern u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue); | ||
1112 | extern void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue); | 1208 | extern void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue); |
1113 | extern int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue); | 1209 | extern int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue); |
1114 | extern u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue); | ||
1115 | extern int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time); | ||
1116 | extern unsigned int ath5k_hw_get_slot_time(struct ath5k_hw *ah); | 1210 | extern unsigned int ath5k_hw_get_slot_time(struct ath5k_hw *ah); |
1211 | extern int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time); | ||
1212 | |||
1117 | /* Hardware Descriptor Functions */ | 1213 | /* Hardware Descriptor Functions */ |
1118 | extern int ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, u32 size, unsigned int flags); | 1214 | extern int ath5k_hw_init_desc_functions(struct ath5k_hw *ah); |
1215 | |||
1119 | /* GPIO Functions */ | 1216 | /* GPIO Functions */ |
1120 | extern void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state); | 1217 | extern void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state); |
1121 | extern int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio); | ||
1122 | extern int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio); | 1218 | extern int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio); |
1219 | extern int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio); | ||
1123 | extern u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio); | 1220 | extern u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio); |
1124 | extern int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val); | 1221 | extern int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val); |
1125 | extern void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, u32 interrupt_level); | 1222 | extern void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, u32 interrupt_level); |
1223 | |||
1126 | /* Misc functions */ | 1224 | /* Misc functions */ |
1225 | int ath5k_hw_set_capabilities(struct ath5k_hw *ah); | ||
1127 | extern int ath5k_hw_get_capability(struct ath5k_hw *ah, enum ath5k_capability_type cap_type, u32 capability, u32 *result); | 1226 | extern int ath5k_hw_get_capability(struct ath5k_hw *ah, enum ath5k_capability_type cap_type, u32 capability, u32 *result); |
1128 | 1227 | extern int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, u16 assoc_id); | |
1228 | extern int ath5k_hw_disable_pspoll(struct ath5k_hw *ah); | ||
1129 | 1229 | ||
1130 | /* Initial register settings functions */ | 1230 | /* Initial register settings functions */ |
1131 | extern int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel); | 1231 | extern int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel); |
1232 | |||
1132 | /* Initialize RF */ | 1233 | /* Initialize RF */ |
1133 | extern int ath5k_hw_rfregs(struct ath5k_hw *ah, struct ieee80211_channel *channel, unsigned int mode); | 1234 | extern int ath5k_hw_rfregs(struct ath5k_hw *ah, struct ieee80211_channel *channel, unsigned int mode); |
1134 | extern int ath5k_hw_rfgain(struct ath5k_hw *ah, unsigned int freq); | 1235 | extern int ath5k_hw_rfgain(struct ath5k_hw *ah, unsigned int freq); |
1135 | extern enum ath5k_rfgain ath5k_hw_get_rf_gain(struct ath5k_hw *ah); | 1236 | extern enum ath5k_rfgain ath5k_hw_get_rf_gain(struct ath5k_hw *ah); |
1136 | extern int ath5k_hw_set_rfgain_opt(struct ath5k_hw *ah); | 1237 | extern int ath5k_hw_set_rfgain_opt(struct ath5k_hw *ah); |
1137 | |||
1138 | |||
1139 | /* PHY/RF channel functions */ | 1238 | /* PHY/RF channel functions */ |
1140 | extern bool ath5k_channel_ok(struct ath5k_hw *ah, u16 freq, unsigned int flags); | 1239 | extern bool ath5k_channel_ok(struct ath5k_hw *ah, u16 freq, unsigned int flags); |
1141 | extern int ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel); | 1240 | extern int ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel); |
1142 | /* PHY calibration */ | 1241 | /* PHY calibration */ |
1143 | extern int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, struct ieee80211_channel *channel); | 1242 | extern int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, struct ieee80211_channel *channel); |
1144 | extern int ath5k_hw_phy_disable(struct ath5k_hw *ah); | 1243 | extern int ath5k_hw_noise_floor_calibration(struct ath5k_hw *ah, short freq); |
1145 | /* Misc PHY functions */ | 1244 | /* Misc PHY functions */ |
1146 | extern u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan); | 1245 | extern u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan); |
1147 | extern void ath5k_hw_set_def_antenna(struct ath5k_hw *ah, unsigned int ant); | 1246 | extern void ath5k_hw_set_def_antenna(struct ath5k_hw *ah, unsigned int ant); |
1148 | extern unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah); | 1247 | extern unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah); |
1149 | extern int ath5k_hw_noise_floor_calibration(struct ath5k_hw *ah, short freq); | 1248 | extern int ath5k_hw_phy_disable(struct ath5k_hw *ah); |
1150 | /* TX power setup */ | 1249 | /* TX power setup */ |
1151 | extern int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, unsigned int txpower); | 1250 | extern int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, unsigned int txpower); |
1152 | extern int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, unsigned int power); | 1251 | extern int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, unsigned int power); |
1153 | 1252 | ||
1253 | /* | ||
1254 | * Functions used internaly | ||
1255 | */ | ||
1154 | 1256 | ||
1257 | /* | ||
1258 | * Translate usec to hw clock units | ||
1259 | */ | ||
1260 | static inline unsigned int ath5k_hw_htoclock(unsigned int usec, bool turbo) | ||
1261 | { | ||
1262 | return turbo ? (usec * 80) : (usec * 40); | ||
1263 | } | ||
1264 | |||
1265 | /* | ||
1266 | * Translate hw clock units to usec | ||
1267 | */ | ||
1268 | static inline unsigned int ath5k_hw_clocktoh(unsigned int clock, bool turbo) | ||
1269 | { | ||
1270 | return turbo ? (clock / 80) : (clock / 40); | ||
1271 | } | ||
1272 | |||
1273 | /* | ||
1274 | * Read from a register | ||
1275 | */ | ||
1155 | static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg) | 1276 | static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg) |
1156 | { | 1277 | { |
1157 | return ioread32(ah->ah_iobase + reg); | 1278 | return ioread32(ah->ah_iobase + reg); |
1158 | } | 1279 | } |
1159 | 1280 | ||
1281 | /* | ||
1282 | * Write to a register | ||
1283 | */ | ||
1160 | static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg) | 1284 | static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg) |
1161 | { | 1285 | { |
1162 | iowrite32(val, ah->ah_iobase + reg); | 1286 | iowrite32(val, ah->ah_iobase + reg); |
1163 | } | 1287 | } |
1164 | 1288 | ||
1289 | #if defined(_ATH5K_RESET) || defined(_ATH5K_PHY) | ||
1290 | /* | ||
1291 | * Check if a register write has been completed | ||
1292 | */ | ||
1293 | static int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, | ||
1294 | u32 val, bool is_set) | ||
1295 | { | ||
1296 | int i; | ||
1297 | u32 data; | ||
1298 | |||
1299 | for (i = AR5K_TUNE_REGISTER_TIMEOUT; i > 0; i--) { | ||
1300 | data = ath5k_hw_reg_read(ah, reg); | ||
1301 | if (is_set && (data & flag)) | ||
1302 | break; | ||
1303 | else if ((data & flag) == val) | ||
1304 | break; | ||
1305 | udelay(15); | ||
1306 | } | ||
1307 | |||
1308 | return (i <= 0) ? -EAGAIN : 0; | ||
1309 | } | ||
1310 | #endif | ||
1311 | |||
1312 | static inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits) | ||
1313 | { | ||
1314 | u32 retval = 0, bit, i; | ||
1315 | |||
1316 | for (i = 0; i < bits; i++) { | ||
1317 | bit = (val >> i) & 1; | ||
1318 | retval = (retval << 1) | bit; | ||
1319 | } | ||
1320 | |||
1321 | return retval; | ||
1322 | } | ||
1323 | |||
1165 | #endif | 1324 | #endif |