aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/ath5k/ath5k.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless/ath5k/ath5k.h')
-rw-r--r--drivers/net/wireless/ath5k/ath5k.h556
1 files changed, 350 insertions, 206 deletions
diff --git a/drivers/net/wireless/ath5k/ath5k.h b/drivers/net/wireless/ath5k/ath5k.h
index 9102eea3c8bf..20018869051d 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
@@ -196,7 +335,6 @@ struct ath5k_srev_name {
196#define AR5K_SREV_RAD_5133 0xc0 /* MIMO found on 5418 */ 335#define AR5K_SREV_RAD_5133 0xc0 /* MIMO found on 5418 */
197 336
198/* IEEE defs */ 337/* IEEE defs */
199
200#define IEEE80211_MAX_LEN 2500 338#define IEEE80211_MAX_LEN 2500
201 339
202/* TODO add support to mac80211 for vendor-specific rates and modes */ 340/* TODO add support to mac80211 for vendor-specific rates and modes */
@@ -268,21 +406,13 @@ enum ath5k_driver_mode {
268 AR5K_MODE_MAX = 5 406 AR5K_MODE_MAX = 5
269}; 407};
270 408
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 409
280/****************\ 410/****************\
281 TX DEFINITIONS 411 TX DEFINITIONS
282\****************/ 412\****************/
283 413
284/* 414/*
285 * TX Status 415 * TX Status descriptor
286 */ 416 */
287struct ath5k_tx_status { 417struct ath5k_tx_status {
288 u16 ts_seqnum; 418 u16 ts_seqnum;
@@ -354,7 +484,6 @@ enum ath5k_tx_queue_id {
354 AR5K_TX_QUEUE_ID_XR_DATA = 9, 484 AR5K_TX_QUEUE_ID_XR_DATA = 9,
355}; 485};
356 486
357
358/* 487/*
359 * Flags to set hw queue's parameters... 488 * Flags to set hw queue's parameters...
360 */ 489 */
@@ -387,7 +516,8 @@ struct ath5k_txq_info {
387 516
388/* 517/*
389 * Transmit packet types. 518 * Transmit packet types.
390 * These are not fully used inside OpenHAL yet 519 * used on tx control descriptor
520 * TODO: Use them inside base.c corectly
391 */ 521 */
392enum ath5k_pkt_type { 522enum ath5k_pkt_type {
393 AR5K_PKT_TYPE_NORMAL = 0, 523 AR5K_PKT_TYPE_NORMAL = 0,
@@ -430,7 +560,7 @@ enum ath5k_dmasize {
430\****************/ 560\****************/
431 561
432/* 562/*
433 * RX Status 563 * RX Status descriptor
434 */ 564 */
435struct ath5k_rx_status { 565struct ath5k_rx_status {
436 u16 rs_datalen; 566 u16 rs_datalen;
@@ -494,34 +624,59 @@ struct ath5k_beacon_state {
494#define TSF_TO_TU(_tsf) (u32)((_tsf) >> 10) 624#define TSF_TO_TU(_tsf) (u32)((_tsf) >> 10)
495 625
496 626
627/*******************************\
628 GAIN OPTIMIZATION DEFINITIONS
629\*******************************/
630
631enum ath5k_rfgain {
632 AR5K_RFGAIN_INACTIVE = 0,
633 AR5K_RFGAIN_READ_REQUESTED,
634 AR5K_RFGAIN_NEED_CHANGE,
635};
636
637#define AR5K_GAIN_CRN_FIX_BITS_5111 4
638#define AR5K_GAIN_CRN_FIX_BITS_5112 7
639#define AR5K_GAIN_CRN_MAX_FIX_BITS AR5K_GAIN_CRN_FIX_BITS_5112
640#define AR5K_GAIN_DYN_ADJUST_HI_MARGIN 15
641#define AR5K_GAIN_DYN_ADJUST_LO_MARGIN 20
642#define AR5K_GAIN_CCK_PROBE_CORR 5
643#define AR5K_GAIN_CCK_OFDM_GAIN_DELTA 15
644#define AR5K_GAIN_STEP_COUNT 10
645#define AR5K_GAIN_PARAM_TX_CLIP 0
646#define AR5K_GAIN_PARAM_PD_90 1
647#define AR5K_GAIN_PARAM_PD_84 2
648#define AR5K_GAIN_PARAM_GAIN_SEL 3
649#define AR5K_GAIN_PARAM_MIX_ORN 0
650#define AR5K_GAIN_PARAM_PD_138 1
651#define AR5K_GAIN_PARAM_PD_137 2
652#define AR5K_GAIN_PARAM_PD_136 3
653#define AR5K_GAIN_PARAM_PD_132 4
654#define AR5K_GAIN_PARAM_PD_131 5
655#define AR5K_GAIN_PARAM_PD_130 6
656#define AR5K_GAIN_CHECK_ADJUST(_g) \
657 ((_g)->g_current <= (_g)->g_low || (_g)->g_current >= (_g)->g_high)
658
659struct ath5k_gain_opt_step {
660 s16 gos_param[AR5K_GAIN_CRN_MAX_FIX_BITS];
661 s32 gos_gain;
662};
663
664struct ath5k_gain {
665 u32 g_step_idx;
666 u32 g_current;
667 u32 g_target;
668 u32 g_low;
669 u32 g_high;
670 u32 g_f_corr;
671 u32 g_active;
672 const struct ath5k_gain_opt_step *g_step;
673};
674
675
497/********************\ 676/********************\
498 COMMON DEFINITIONS 677 COMMON DEFINITIONS
499\********************/ 678\********************/
500 679
501/*
502 * Atheros hardware descriptor
503 * This is read and written to by the hardware
504 */
505struct 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 680#define AR5K_SLOT_TIME_9 396
526#define AR5K_SLOT_TIME_20 880 681#define AR5K_SLOT_TIME_20 880
527#define AR5K_SLOT_TIME_MAX 0xffff 682#define AR5K_SLOT_TIME_MAX 0xffff
@@ -553,167 +708,79 @@ struct ath5k_desc {
553#define CHANNEL_MODES CHANNEL_ALL 708#define CHANNEL_MODES CHANNEL_ALL
554 709
555/* 710/*
556 * Used internaly in OpenHAL (ar5211.c/ar5212.c 711 * Used internaly for reset_tx_queue).
557 * for reset_tx_queue). Also see struct struct ieee80211_channel. 712 * Also see struct struct ieee80211_channel.
558 */ 713 */
559#define IS_CHAN_XR(_c) ((_c.hw_value & CHANNEL_XR) != 0) 714#define IS_CHAN_XR(_c) ((_c.hw_value & CHANNEL_XR) != 0)
560#define IS_CHAN_B(_c) ((_c.hw_value & CHANNEL_B) != 0) 715#define IS_CHAN_B(_c) ((_c.hw_value & CHANNEL_B) != 0)
561 716
562/* 717/*
563 * The following structure will be used to map 2GHz channels to 718 * The following structure is used to map 2GHz channels to
564 * 5GHz Atheros channels. 719 * 5GHz Atheros channels.
720 * TODO: Clean up
565 */ 721 */
566struct ath5k_athchan_2ghz { 722struct ath5k_athchan_2ghz {
567 u32 a2_flags; 723 u32 a2_flags;
568 u16 a2_athchan; 724 u16 a2_athchan;
569}; 725};
570 726
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 727
577/* Max number of rates on the rate table and what it seems 728/******************\
578 * Atheros hardware supports */ 729 RATE DEFINITIONS
579#define AR5K_MAX_RATES 32 730\******************/
580 731
581/** 732/**
582 * struct ath5k_rate - rate structure 733 * 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 * 734 *
600 * This structure is used to get the RX rate or set the TX rate on the 735 * 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 736 * hardware descriptors. It is also used for internal modulation control
602 * and settings. 737 * and settings.
603 * 738 *
604 * On RX after the &struct ath5k_desc is parsed by the appropriate 739 * 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 * 740 *
611 * rate_code 1 2 3 4 5 6 7 8 741 * rate_code 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08
612 * rate_kbps 3000 1000 ? ? ? 2000 500 48000 742 * rate_kbps 3000 1000 ? ? ? 2000 500 48000
613 * 743 *
614 * rate_code 9 10 11 12 13 14 15 16 744 * rate_code 0x09 0x0A 0x0B 0x0C 0x0D 0x0E 0x0F 0x10
615 * rate_kbps 24000 12000 6000 54000 36000 18000 9000 ? 745 * rate_kbps 24000 12000 6000 54000 36000 18000 9000 ?
616 * 746 *
617 * rate_code 17 18 19 20 21 22 23 24 747 * rate_code 17 18 19 20 21 22 23 24
618 * rate_kbps ? ? ? ? ? ? ? 11000 748 * rate_kbps ? ? ? ? ? ? ? 11000
619 * 749 *
620 * rate_code 25 26 27 28 29 30 31 32 750 * rate_code 25 26 27 28 29 30 31 32
621 * rate_kbps 5500 2000 1000 ? ? ? ? ? 751 * rate_kbps 5500 2000 1000 11000S 5500S 2000S ? ?
622 * 752 *
753 * "S" indicates CCK rates with short preamble.
754 *
755 * AR5211 has different rate codes for CCK (802.11B) rates. It only uses the
756 * lowest 4 bits, so they are the same as below with a 0xF mask.
757 * (0xB, 0xA, 0x9 and 0x8 for 1M, 2M, 5.5M and 11M).
758 * We handle this in ath5k_setup_bands().
623 */ 759 */
624struct ath5k_rate { 760#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) */
634struct 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 761
700#define AR5K_RATES_XR { 12, { \ 762/* B */
701 255, 3, 1, 255, 255, 255, 2, 0, 10, 8, 6, 4, \ 763#define ATH5K_RATE_CODE_1M 0x1B
702 11, 9, 7, 5, 255, 255, 255, 255, 255, 255, 255, 255, \ 764#define ATH5K_RATE_CODE_2M 0x1A
703 255, 255, 255, 255, 255, 255, 255, 255 }, { \ 765#define ATH5K_RATE_CODE_5_5M 0x19
704 { 1, MODULATION_XR, 500, 7, 129, 0 }, \ 766#define ATH5K_RATE_CODE_11M 0x18
705 { 1, MODULATION_XR, 1000, 2, 139, 1 }, \ 767/* A and G */
706 { 1, MODULATION_XR, 2000, 6, 150, 2 }, \ 768#define ATH5K_RATE_CODE_6M 0x0B
707 { 1, MODULATION_XR, 3000, 1, 150, 3 }, \ 769#define ATH5K_RATE_CODE_9M 0x0F
708 { 1, 0, 6000, 11, 140, 4 }, \ 770#define ATH5K_RATE_CODE_12M 0x0A
709 { 1, 0, 9000, 15, 18, 4 }, \ 771#define ATH5K_RATE_CODE_18M 0x0E
710 { 1, 0, 12000, 10, 152, 6 }, \ 772#define ATH5K_RATE_CODE_24M 0x09
711 { 1, 0, 18000, 14, 36, 6 }, \ 773#define ATH5K_RATE_CODE_36M 0x0D
712 { 1, 0, 24000, 9, 176, 8 }, \ 774#define ATH5K_RATE_CODE_48M 0x08
713 { 1, 0, 36000, 13, 72, 8 }, \ 775#define ATH5K_RATE_CODE_54M 0x0C
714 { 1, 0, 48000, 8, 96, 8 }, \ 776/* XR */
715 { 1, 0, 54000, 12, 108, 8 } } \ 777#define ATH5K_RATE_CODE_XR_500K 0x07
716} 778#define ATH5K_RATE_CODE_XR_1M 0x02
779#define ATH5K_RATE_CODE_XR_2M 0x06
780#define ATH5K_RATE_CODE_XR_3M 0x01
781
782/* adding this flag to rate_code enables short preamble */
783#define AR5K_SET_SHORT_PREAMBLE 0x04
717 784
718/* 785/*
719 * Crypto definitions 786 * Crypto definitions
@@ -735,7 +802,6 @@ struct ath5k_rate_table {
735 return (false); \ 802 return (false); \
736} while (0) 803} while (0)
737 804
738
739enum ath5k_ant_setting { 805enum ath5k_ant_setting {
740 AR5K_ANT_VARIABLE = 0, /* variable by programming */ 806 AR5K_ANT_VARIABLE = 0, /* variable by programming */
741 AR5K_ANT_FIXED_A = 1, /* fixed to 11a frequencies */ 807 AR5K_ANT_FIXED_A = 1, /* fixed to 11a frequencies */
@@ -846,7 +912,8 @@ enum ath5k_power_mode {
846 912
847/* 913/*
848 * These match net80211 definitions (not used in 914 * These match net80211 definitions (not used in
849 * d80211). 915 * mac80211).
916 * TODO: Clean this up
850 */ 917 */
851#define AR5K_LED_INIT 0 /*IEEE80211_S_INIT*/ 918#define AR5K_LED_INIT 0 /*IEEE80211_S_INIT*/
852#define AR5K_LED_SCAN 1 /*IEEE80211_S_SCAN*/ 919#define AR5K_LED_SCAN 1 /*IEEE80211_S_SCAN*/
@@ -862,7 +929,8 @@ enum ath5k_power_mode {
862/* 929/*
863 * Chipset capabilities -see ath5k_hw_get_capability- 930 * Chipset capabilities -see ath5k_hw_get_capability-
864 * get_capability function is not yet fully implemented 931 * get_capability function is not yet fully implemented
865 * in OpenHAL so most of these don't work yet... 932 * in ath5k so most of these don't work yet...
933 * TODO: Implement these & merge with _TUNE_ stuff above
866 */ 934 */
867enum ath5k_capability_type { 935enum ath5k_capability_type {
868 AR5K_CAP_REG_DMN = 0, /* Used to get current reg. domain id */ 936 AR5K_CAP_REG_DMN = 0, /* Used to get current reg. domain id */
@@ -931,6 +999,7 @@ struct ath5k_capabilities {
931#define AR5K_MAX_GPIO 10 999#define AR5K_MAX_GPIO 10
932#define AR5K_MAX_RF_BANKS 8 1000#define AR5K_MAX_RF_BANKS 8
933 1001
1002/* TODO: Clean up and merge with ath5k_softc */
934struct ath5k_hw { 1003struct ath5k_hw {
935 u32 ah_magic; 1004 u32 ah_magic;
936 1005
@@ -939,7 +1008,7 @@ struct ath5k_hw {
939 1008
940 enum ath5k_int ah_imr; 1009 enum ath5k_int ah_imr;
941 1010
942 enum ieee80211_if_types ah_op_mode; 1011 enum nl80211_iftype ah_op_mode;
943 enum ath5k_power_mode ah_power_mode; 1012 enum ath5k_power_mode ah_power_mode;
944 struct ieee80211_channel ah_current_channel; 1013 struct ieee80211_channel ah_current_channel;
945 bool ah_turbo; 1014 bool ah_turbo;
@@ -1023,11 +1092,13 @@ struct ath5k_hw {
1023 /* 1092 /*
1024 * Function pointers 1093 * Function pointers
1025 */ 1094 */
1095 int (*ah_setup_rx_desc)(struct ath5k_hw *ah, struct ath5k_desc *desc,
1096 u32 size, unsigned int flags);
1026 int (*ah_setup_tx_desc)(struct ath5k_hw *, struct ath5k_desc *, 1097 int (*ah_setup_tx_desc)(struct ath5k_hw *, struct ath5k_desc *,
1027 unsigned int, unsigned int, enum ath5k_pkt_type, unsigned int, 1098 unsigned int, unsigned int, enum ath5k_pkt_type, unsigned int,
1028 unsigned int, unsigned int, unsigned int, unsigned int, 1099 unsigned int, unsigned int, unsigned int, unsigned int,
1029 unsigned int, unsigned int, unsigned int); 1100 unsigned int, unsigned int, unsigned int);
1030 int (*ah_setup_xtx_desc)(struct ath5k_hw *, struct ath5k_desc *, 1101 int (*ah_setup_mrr_tx_desc)(struct ath5k_hw *, struct ath5k_desc *,
1031 unsigned int, unsigned int, unsigned int, unsigned int, 1102 unsigned int, unsigned int, unsigned int, unsigned int,
1032 unsigned int, unsigned int); 1103 unsigned int, unsigned int);
1033 int (*ah_proc_tx_desc)(struct ath5k_hw *, struct ath5k_desc *, 1104 int (*ah_proc_tx_desc)(struct ath5k_hw *, struct ath5k_desc *,
@@ -1040,33 +1111,38 @@ struct ath5k_hw {
1040 * Prototypes 1111 * Prototypes
1041 */ 1112 */
1042 1113
1043/* General Functions */
1044extern int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val, bool is_set);
1045/* Attach/Detach Functions */ 1114/* Attach/Detach Functions */
1046extern struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version); 1115extern struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version);
1047extern const struct ath5k_rate_table *ath5k_hw_get_rate_table(struct ath5k_hw *ah, unsigned int mode);
1048extern void ath5k_hw_detach(struct ath5k_hw *ah); 1116extern void ath5k_hw_detach(struct ath5k_hw *ah);
1117
1049/* Reset Functions */ 1118/* Reset Functions */
1050extern int ath5k_hw_reset(struct ath5k_hw *ah, enum ieee80211_if_types op_mode, struct ieee80211_channel *channel, bool change_channel); 1119extern int ath5k_hw_nic_wakeup(struct ath5k_hw *ah, int flags, bool initial);
1120extern int ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode, struct ieee80211_channel *channel, bool change_channel);
1051/* Power management functions */ 1121/* Power management functions */
1052extern int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, bool set_chip, u16 sleep_duration); 1122extern int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, bool set_chip, u16 sleep_duration);
1123
1053/* DMA Related Functions */ 1124/* DMA Related Functions */
1054extern void ath5k_hw_start_rx(struct ath5k_hw *ah); 1125extern void ath5k_hw_start_rx_dma(struct ath5k_hw *ah);
1055extern int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah); 1126extern int ath5k_hw_stop_rx_dma(struct ath5k_hw *ah);
1056extern u32 ath5k_hw_get_rx_buf(struct ath5k_hw *ah); 1127extern u32 ath5k_hw_get_rxdp(struct ath5k_hw *ah);
1057extern void ath5k_hw_put_rx_buf(struct ath5k_hw *ah, u32 phys_addr); 1128extern void ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr);
1058extern int ath5k_hw_tx_start(struct ath5k_hw *ah, unsigned int queue); 1129extern int ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue);
1059extern int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue); 1130extern int ath5k_hw_stop_tx_dma(struct ath5k_hw *ah, unsigned int queue);
1060extern u32 ath5k_hw_get_tx_buf(struct ath5k_hw *ah, unsigned int queue); 1131extern u32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue);
1061extern int ath5k_hw_put_tx_buf(struct ath5k_hw *ah, unsigned int queue, u32 phys_addr); 1132extern int ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue,
1133 u32 phys_addr);
1062extern int ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase); 1134extern int ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase);
1063/* Interrupt handling */ 1135/* Interrupt handling */
1064extern bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah); 1136extern bool ath5k_hw_is_intr_pending(struct ath5k_hw *ah);
1065extern int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask); 1137extern int ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask);
1066extern enum ath5k_int ath5k_hw_set_intr(struct ath5k_hw *ah, enum ath5k_int new_mask); 1138extern enum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum
1139ath5k_int new_mask);
1067extern void ath5k_hw_update_mib_counters(struct ath5k_hw *ah, struct ieee80211_low_level_stats *stats); 1140extern void ath5k_hw_update_mib_counters(struct ath5k_hw *ah, struct ieee80211_low_level_stats *stats);
1141
1068/* EEPROM access functions */ 1142/* EEPROM access functions */
1069extern int ath5k_hw_set_regdomain(struct ath5k_hw *ah, u16 regdomain); 1143extern int ath5k_eeprom_init(struct ath5k_hw *ah);
1144extern int ath5k_eeprom_read_mac(struct ath5k_hw *ah, u8 *mac);
1145
1070/* Protocol Control Unit Functions */ 1146/* Protocol Control Unit Functions */
1071extern int ath5k_hw_set_opmode(struct ath5k_hw *ah); 1147extern int ath5k_hw_set_opmode(struct ath5k_hw *ah);
1072/* BSSID Functions */ 1148/* BSSID Functions */
@@ -1076,14 +1152,14 @@ extern void ath5k_hw_set_associd(struct ath5k_hw *ah, const u8 *bssid, u16 assoc
1076extern int ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask); 1152extern int ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask);
1077/* Receive start/stop functions */ 1153/* Receive start/stop functions */
1078extern void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah); 1154extern void ath5k_hw_start_rx_pcu(struct ath5k_hw *ah);
1079extern void ath5k_hw_stop_pcu_recv(struct ath5k_hw *ah); 1155extern void ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah);
1080/* RX Filter functions */ 1156/* RX Filter functions */
1081extern void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1); 1157extern void ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1);
1082extern int ath5k_hw_set_mcast_filterindex(struct ath5k_hw *ah, u32 index); 1158extern int ath5k_hw_set_mcast_filter_idx(struct ath5k_hw *ah, u32 index);
1083extern int ath5k_hw_clear_mcast_filter_idx(struct ath5k_hw *ah, u32 index); 1159extern int ath5k_hw_clear_mcast_filter_idx(struct ath5k_hw *ah, u32 index);
1084extern u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah); 1160extern u32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah);
1085extern void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter); 1161extern void ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter);
1086/* Beacon related functions */ 1162/* Beacon control functions */
1087extern u32 ath5k_hw_get_tsf32(struct ath5k_hw *ah); 1163extern u32 ath5k_hw_get_tsf32(struct ath5k_hw *ah);
1088extern u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah); 1164extern u64 ath5k_hw_get_tsf64(struct ath5k_hw *ah);
1089extern void ath5k_hw_reset_tsf(struct ath5k_hw *ah); 1165extern void ath5k_hw_reset_tsf(struct ath5k_hw *ah);
@@ -1105,61 +1181,129 @@ extern int ath5k_hw_reset_key(struct ath5k_hw *ah, u16 entry);
1105extern int ath5k_hw_is_key_valid(struct ath5k_hw *ah, u16 entry); 1181extern int ath5k_hw_is_key_valid(struct ath5k_hw *ah, u16 entry);
1106extern int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry, const struct ieee80211_key_conf *key, const u8 *mac); 1182extern int ath5k_hw_set_key(struct ath5k_hw *ah, u16 entry, const struct ieee80211_key_conf *key, const u8 *mac);
1107extern int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac); 1183extern int ath5k_hw_set_key_lladdr(struct ath5k_hw *ah, u16 entry, const u8 *mac);
1184
1108/* Queue Control Unit, DFS Control Unit Functions */ 1185/* Queue Control Unit, DFS Control Unit Functions */
1109extern int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah, enum ath5k_tx_queue queue_type, struct ath5k_txq_info *queue_info);
1110extern int ath5k_hw_setup_tx_queueprops(struct ath5k_hw *ah, int queue, const struct ath5k_txq_info *queue_info);
1111extern int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, struct ath5k_txq_info *queue_info); 1186extern int ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue, struct ath5k_txq_info *queue_info);
1187extern int ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue,
1188 const struct ath5k_txq_info *queue_info);
1189extern int ath5k_hw_setup_tx_queue(struct ath5k_hw *ah,
1190 enum ath5k_tx_queue queue_type,
1191 struct ath5k_txq_info *queue_info);
1192extern u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue);
1112extern void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue); 1193extern void ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue);
1113extern int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue); 1194extern int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue);
1114extern u32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue);
1115extern int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time);
1116extern unsigned int ath5k_hw_get_slot_time(struct ath5k_hw *ah); 1195extern unsigned int ath5k_hw_get_slot_time(struct ath5k_hw *ah);
1196extern int ath5k_hw_set_slot_time(struct ath5k_hw *ah, unsigned int slot_time);
1197
1117/* Hardware Descriptor Functions */ 1198/* Hardware Descriptor Functions */
1118extern int ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc, u32 size, unsigned int flags); 1199extern int ath5k_hw_init_desc_functions(struct ath5k_hw *ah);
1200
1119/* GPIO Functions */ 1201/* GPIO Functions */
1120extern void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state); 1202extern void ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state);
1121extern int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio);
1122extern int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio); 1203extern int ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio);
1204extern int ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio);
1123extern u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio); 1205extern u32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio);
1124extern int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val); 1206extern int ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val);
1125extern void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, u32 interrupt_level); 1207extern void ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio, u32 interrupt_level);
1208
1126/* Misc functions */ 1209/* Misc functions */
1210int ath5k_hw_set_capabilities(struct ath5k_hw *ah);
1127extern int ath5k_hw_get_capability(struct ath5k_hw *ah, enum ath5k_capability_type cap_type, u32 capability, u32 *result); 1211extern int ath5k_hw_get_capability(struct ath5k_hw *ah, enum ath5k_capability_type cap_type, u32 capability, u32 *result);
1128 1212extern int ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, u16 assoc_id);
1213extern int ath5k_hw_disable_pspoll(struct ath5k_hw *ah);
1129 1214
1130/* Initial register settings functions */ 1215/* Initial register settings functions */
1131extern int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel); 1216extern int ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel);
1217
1132/* Initialize RF */ 1218/* Initialize RF */
1133extern int ath5k_hw_rfregs(struct ath5k_hw *ah, struct ieee80211_channel *channel, unsigned int mode); 1219extern int ath5k_hw_rfregs(struct ath5k_hw *ah, struct ieee80211_channel *channel, unsigned int mode);
1134extern int ath5k_hw_rfgain(struct ath5k_hw *ah, unsigned int freq); 1220extern int ath5k_hw_rfgain(struct ath5k_hw *ah, unsigned int freq);
1135extern enum ath5k_rfgain ath5k_hw_get_rf_gain(struct ath5k_hw *ah); 1221extern enum ath5k_rfgain ath5k_hw_get_rf_gain(struct ath5k_hw *ah);
1136extern int ath5k_hw_set_rfgain_opt(struct ath5k_hw *ah); 1222extern int ath5k_hw_set_rfgain_opt(struct ath5k_hw *ah);
1137
1138
1139/* PHY/RF channel functions */ 1223/* PHY/RF channel functions */
1140extern bool ath5k_channel_ok(struct ath5k_hw *ah, u16 freq, unsigned int flags); 1224extern bool ath5k_channel_ok(struct ath5k_hw *ah, u16 freq, unsigned int flags);
1141extern int ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel); 1225extern int ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel);
1142/* PHY calibration */ 1226/* PHY calibration */
1143extern int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, struct ieee80211_channel *channel); 1227extern int ath5k_hw_phy_calibrate(struct ath5k_hw *ah, struct ieee80211_channel *channel);
1144extern int ath5k_hw_phy_disable(struct ath5k_hw *ah); 1228extern int ath5k_hw_noise_floor_calibration(struct ath5k_hw *ah, short freq);
1145/* Misc PHY functions */ 1229/* Misc PHY functions */
1146extern u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan); 1230extern u16 ath5k_hw_radio_revision(struct ath5k_hw *ah, unsigned int chan);
1147extern void ath5k_hw_set_def_antenna(struct ath5k_hw *ah, unsigned int ant); 1231extern void ath5k_hw_set_def_antenna(struct ath5k_hw *ah, unsigned int ant);
1148extern unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah); 1232extern unsigned int ath5k_hw_get_def_antenna(struct ath5k_hw *ah);
1149extern int ath5k_hw_noise_floor_calibration(struct ath5k_hw *ah, short freq); 1233extern int ath5k_hw_phy_disable(struct ath5k_hw *ah);
1150/* TX power setup */ 1234/* TX power setup */
1151extern int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, unsigned int txpower); 1235extern int ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, unsigned int txpower);
1152extern int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, unsigned int power); 1236extern int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, unsigned int power);
1153 1237
1238/*
1239 * Functions used internaly
1240 */
1154 1241
1242/*
1243 * Translate usec to hw clock units
1244 */
1245static inline unsigned int ath5k_hw_htoclock(unsigned int usec, bool turbo)
1246{
1247 return turbo ? (usec * 80) : (usec * 40);
1248}
1249
1250/*
1251 * Translate hw clock units to usec
1252 */
1253static inline unsigned int ath5k_hw_clocktoh(unsigned int clock, bool turbo)
1254{
1255 return turbo ? (clock / 80) : (clock / 40);
1256}
1257
1258/*
1259 * Read from a register
1260 */
1155static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg) 1261static inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
1156{ 1262{
1157 return ioread32(ah->ah_iobase + reg); 1263 return ioread32(ah->ah_iobase + reg);
1158} 1264}
1159 1265
1266/*
1267 * Write to a register
1268 */
1160static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg) 1269static inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
1161{ 1270{
1162 iowrite32(val, ah->ah_iobase + reg); 1271 iowrite32(val, ah->ah_iobase + reg);
1163} 1272}
1164 1273
1274#if defined(_ATH5K_RESET) || defined(_ATH5K_PHY)
1275/*
1276 * Check if a register write has been completed
1277 */
1278static int ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag,
1279 u32 val, bool is_set)
1280{
1281 int i;
1282 u32 data;
1283
1284 for (i = AR5K_TUNE_REGISTER_TIMEOUT; i > 0; i--) {
1285 data = ath5k_hw_reg_read(ah, reg);
1286 if (is_set && (data & flag))
1287 break;
1288 else if ((data & flag) == val)
1289 break;
1290 udelay(15);
1291 }
1292
1293 return (i <= 0) ? -EAGAIN : 0;
1294}
1295#endif
1296
1297static inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits)
1298{
1299 u32 retval = 0, bit, i;
1300
1301 for (i = 0; i < bits; i++) {
1302 bit = (val >> i) & 1;
1303 retval = (retval << 1) | bit;
1304 }
1305
1306 return retval;
1307}
1308
1165#endif 1309#endif