162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright (c) 2004-2007 Reyk Floeter <reyk@openbsd.org>
362306a36Sopenharmony_ci * Copyright (c) 2006-2007 Nick Kossifidis <mickflemm@gmail.com>
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Permission to use, copy, modify, and distribute this software for any
662306a36Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above
762306a36Sopenharmony_ci * copyright notice and this permission notice appear in all copies.
862306a36Sopenharmony_ci *
962306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1062306a36Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1162306a36Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1262306a36Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1362306a36Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1462306a36Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1562306a36Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1662306a36Sopenharmony_ci */
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#ifndef _ATH5K_H
1962306a36Sopenharmony_ci#define _ATH5K_H
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci/* TODO: Clean up channel debugging (doesn't work anyway) and start
2262306a36Sopenharmony_ci * working on reg. control code using all available eeprom information
2362306a36Sopenharmony_ci * (rev. engineering needed) */
2462306a36Sopenharmony_ci#define CHAN_DEBUG	0
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#include <linux/io.h>
2762306a36Sopenharmony_ci#include <linux/interrupt.h>
2862306a36Sopenharmony_ci#include <linux/types.h>
2962306a36Sopenharmony_ci#include <linux/average.h>
3062306a36Sopenharmony_ci#include <linux/leds.h>
3162306a36Sopenharmony_ci#include <net/mac80211.h>
3262306a36Sopenharmony_ci#include <net/cfg80211.h>
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci/* RX/TX descriptor hw structs
3562306a36Sopenharmony_ci * TODO: Driver part should only see sw structs */
3662306a36Sopenharmony_ci#include "desc.h"
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci/* EEPROM structs/offsets
3962306a36Sopenharmony_ci * TODO: Make a more generic struct (eg. add more stuff to ath5k_capabilities)
4062306a36Sopenharmony_ci * and clean up common bits, then introduce set/get functions in eeprom.c */
4162306a36Sopenharmony_ci#include "eeprom.h"
4262306a36Sopenharmony_ci#include "debug.h"
4362306a36Sopenharmony_ci#include "../ath.h"
4462306a36Sopenharmony_ci#include "ani.h"
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ci/* PCI IDs */
4762306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5210		0x0007 /* AR5210 */
4862306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5311		0x0011 /* AR5311 */
4962306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5211		0x0012 /* AR5211 */
5062306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212		0x0013 /* AR5212 */
5162306a36Sopenharmony_ci#define PCI_DEVICE_ID_3COM_3CRDAG675		0x0013 /* 3CRDAG675 (Atheros AR5212) */
5262306a36Sopenharmony_ci#define PCI_DEVICE_ID_3COM_2_3CRPAG175		0x0013 /* 3CRPAG175 (Atheros AR5212) */
5362306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5210_AP		0x0207 /* AR5210 (Early) */
5462306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_IBM	0x1014 /* AR5212 (IBM MiniPCI) */
5562306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5210_DEFAULT	0x1107 /* AR5210 (no eeprom) */
5662306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_DEFAULT	0x1113 /* AR5212 (no eeprom) */
5762306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5211_DEFAULT	0x1112 /* AR5211 (no eeprom) */
5862306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_FPGA	0xf013 /* AR5212 (emulation board) */
5962306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5211_LEGACY	0xff12 /* AR5211 (emulation board) */
6062306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5211_FPGA11B	0xf11b /* AR5211 (emulation board) */
6162306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5312_REV2	0x0052 /* AR5312 WMAC (AP31) */
6262306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5312_REV7	0x0057 /* AR5312 WMAC (AP30-040) */
6362306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5312_REV8	0x0058 /* AR5312 WMAC (AP43-030) */
6462306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0014	0x0014 /* AR5212 compatible */
6562306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0015	0x0015 /* AR5212 compatible */
6662306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0016	0x0016 /* AR5212 compatible */
6762306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0017	0x0017 /* AR5212 compatible */
6862306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0018	0x0018 /* AR5212 compatible */
6962306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0019	0x0019 /* AR5212 compatible */
7062306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR2413		0x001a /* AR2413 (Griffin-lite) */
7162306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5413		0x001b /* AR5413 (Eagle) */
7262306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5424		0x001c /* AR5424 (Condor PCI-E) */
7362306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5416		0x0023 /* AR5416 */
7462306a36Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5418		0x0024 /* AR5418 */
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/****************************\
7762306a36Sopenharmony_ci  GENERIC DRIVER DEFINITIONS
7862306a36Sopenharmony_ci\****************************/
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ci#define ATH5K_PRINTF(fmt, ...)						\
8162306a36Sopenharmony_ci	pr_warn("%s: " fmt, __func__, ##__VA_ARGS__)
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_civoid __printf(3, 4)
8462306a36Sopenharmony_ci_ath5k_printk(const struct ath5k_hw *ah, const char *level,
8562306a36Sopenharmony_ci	      const char *fmt, ...);
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define ATH5K_PRINTK(_sc, _level, _fmt, ...)				\
8862306a36Sopenharmony_ci	_ath5k_printk(_sc, _level, _fmt, ##__VA_ARGS__)
8962306a36Sopenharmony_ci
9062306a36Sopenharmony_ci#define ATH5K_PRINTK_LIMIT(_sc, _level, _fmt, ...)			\
9162306a36Sopenharmony_cido {									\
9262306a36Sopenharmony_ci	if (net_ratelimit())						\
9362306a36Sopenharmony_ci		ATH5K_PRINTK(_sc, _level, _fmt, ##__VA_ARGS__); 	\
9462306a36Sopenharmony_ci} while (0)
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci#define ATH5K_INFO(_sc, _fmt, ...)					\
9762306a36Sopenharmony_ci	ATH5K_PRINTK(_sc, KERN_INFO, _fmt, ##__VA_ARGS__)
9862306a36Sopenharmony_ci
9962306a36Sopenharmony_ci#define ATH5K_WARN(_sc, _fmt, ...)					\
10062306a36Sopenharmony_ci	ATH5K_PRINTK_LIMIT(_sc, KERN_WARNING, _fmt, ##__VA_ARGS__)
10162306a36Sopenharmony_ci
10262306a36Sopenharmony_ci#define ATH5K_ERR(_sc, _fmt, ...)					\
10362306a36Sopenharmony_ci	ATH5K_PRINTK_LIMIT(_sc, KERN_ERR, _fmt, ##__VA_ARGS__)
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci/*
10662306a36Sopenharmony_ci * AR5K REGISTER ACCESS
10762306a36Sopenharmony_ci */
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci/* Some macros to read/write fields */
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci/* First shift, then mask */
11262306a36Sopenharmony_ci#define AR5K_REG_SM(_val, _flags)					\
11362306a36Sopenharmony_ci	(((_val) << _flags##_S) & (_flags))
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci/* First mask, then shift */
11662306a36Sopenharmony_ci#define AR5K_REG_MS(_val, _flags)					\
11762306a36Sopenharmony_ci	(((_val) & (_flags)) >> _flags##_S)
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci/* Some registers can hold multiple values of interest. For this
12062306a36Sopenharmony_ci * reason when we want to write to these registers we must first
12162306a36Sopenharmony_ci * retrieve the values which we do not want to clear (lets call this
12262306a36Sopenharmony_ci * old_data) and then set the register with this and our new_value:
12362306a36Sopenharmony_ci * ( old_data | new_value) */
12462306a36Sopenharmony_ci#define AR5K_REG_WRITE_BITS(ah, _reg, _flags, _val)			\
12562306a36Sopenharmony_ci	ath5k_hw_reg_write(ah, (ath5k_hw_reg_read(ah, _reg) & ~(_flags)) | \
12662306a36Sopenharmony_ci	    (((_val) << _flags##_S) & (_flags)), _reg)
12762306a36Sopenharmony_ci
12862306a36Sopenharmony_ci#define AR5K_REG_MASKED_BITS(ah, _reg, _flags, _mask)			\
12962306a36Sopenharmony_ci	ath5k_hw_reg_write(ah, (ath5k_hw_reg_read(ah, _reg) &		\
13062306a36Sopenharmony_ci			(_mask)) | (_flags), _reg)
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci#define AR5K_REG_ENABLE_BITS(ah, _reg, _flags)				\
13362306a36Sopenharmony_ci	ath5k_hw_reg_write(ah, ath5k_hw_reg_read(ah, _reg) | (_flags), _reg)
13462306a36Sopenharmony_ci
13562306a36Sopenharmony_ci#define AR5K_REG_DISABLE_BITS(ah, _reg, _flags)			\
13662306a36Sopenharmony_ci	ath5k_hw_reg_write(ah, ath5k_hw_reg_read(ah, _reg) & ~(_flags), _reg)
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci/* Access QCU registers per queue */
13962306a36Sopenharmony_ci#define AR5K_REG_READ_Q(ah, _reg, _queue)				\
14062306a36Sopenharmony_ci	(ath5k_hw_reg_read(ah, _reg) & (1 << _queue))			\
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#define AR5K_REG_WRITE_Q(ah, _reg, _queue)				\
14362306a36Sopenharmony_ci	ath5k_hw_reg_write(ah, (1 << _queue), _reg)
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci#define AR5K_Q_ENABLE_BITS(_reg, _queue) do {				\
14662306a36Sopenharmony_ci	_reg |= 1 << _queue;						\
14762306a36Sopenharmony_ci} while (0)
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ci#define AR5K_Q_DISABLE_BITS(_reg, _queue) do {				\
15062306a36Sopenharmony_ci	_reg &= ~(1 << _queue);						\
15162306a36Sopenharmony_ci} while (0)
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci/* Used while writing initvals */
15462306a36Sopenharmony_ci#define AR5K_REG_WAIT(_i) do {						\
15562306a36Sopenharmony_ci	if (_i % 64)							\
15662306a36Sopenharmony_ci		udelay(1);						\
15762306a36Sopenharmony_ci} while (0)
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci/*
16062306a36Sopenharmony_ci * Some tunable values (these should be changeable by the user)
16162306a36Sopenharmony_ci * TODO: Make use of them and add more options OR use debug/configfs
16262306a36Sopenharmony_ci */
16362306a36Sopenharmony_ci#define AR5K_TUNE_DMA_BEACON_RESP		2
16462306a36Sopenharmony_ci#define AR5K_TUNE_SW_BEACON_RESP		10
16562306a36Sopenharmony_ci#define AR5K_TUNE_ADDITIONAL_SWBA_BACKOFF	0
16662306a36Sopenharmony_ci#define AR5K_TUNE_MIN_TX_FIFO_THRES		1
16762306a36Sopenharmony_ci#define AR5K_TUNE_MAX_TX_FIFO_THRES	((IEEE80211_MAX_FRAME_LEN / 64) + 1)
16862306a36Sopenharmony_ci#define AR5K_TUNE_REGISTER_TIMEOUT		20000
16962306a36Sopenharmony_ci/* Register for RSSI threshold has a mask of 0xff, so 255 seems to
17062306a36Sopenharmony_ci * be the max value. */
17162306a36Sopenharmony_ci#define AR5K_TUNE_RSSI_THRES			129
17262306a36Sopenharmony_ci/* This must be set when setting the RSSI threshold otherwise it can
17362306a36Sopenharmony_ci * prevent a reset. If AR5K_RSSI_THR is read after writing to it
17462306a36Sopenharmony_ci * the BMISS_THRES will be seen as 0, seems hardware doesn't keep
17562306a36Sopenharmony_ci * track of it. Max value depends on hardware. For AR5210 this is just 7.
17662306a36Sopenharmony_ci * For AR5211+ this seems to be up to 255. */
17762306a36Sopenharmony_ci#define AR5K_TUNE_BMISS_THRES			7
17862306a36Sopenharmony_ci#define AR5K_TUNE_REGISTER_DWELL_TIME		20000
17962306a36Sopenharmony_ci#define AR5K_TUNE_BEACON_INTERVAL		100
18062306a36Sopenharmony_ci#define AR5K_TUNE_AIFS				2
18162306a36Sopenharmony_ci#define AR5K_TUNE_AIFS_11B			2
18262306a36Sopenharmony_ci#define AR5K_TUNE_AIFS_XR			0
18362306a36Sopenharmony_ci#define AR5K_TUNE_CWMIN				15
18462306a36Sopenharmony_ci#define AR5K_TUNE_CWMIN_11B			31
18562306a36Sopenharmony_ci#define AR5K_TUNE_CWMIN_XR			3
18662306a36Sopenharmony_ci#define AR5K_TUNE_CWMAX				1023
18762306a36Sopenharmony_ci#define AR5K_TUNE_CWMAX_11B			1023
18862306a36Sopenharmony_ci#define AR5K_TUNE_CWMAX_XR			7
18962306a36Sopenharmony_ci#define AR5K_TUNE_NOISE_FLOOR			-72
19062306a36Sopenharmony_ci#define AR5K_TUNE_CCA_MAX_GOOD_VALUE		-95
19162306a36Sopenharmony_ci#define AR5K_TUNE_MAX_TXPOWER			63
19262306a36Sopenharmony_ci#define AR5K_TUNE_DEFAULT_TXPOWER		25
19362306a36Sopenharmony_ci#define AR5K_TUNE_TPC_TXPOWER			false
19462306a36Sopenharmony_ci#define ATH5K_TUNE_CALIBRATION_INTERVAL_FULL    60000   /* 60 sec */
19562306a36Sopenharmony_ci#define	ATH5K_TUNE_CALIBRATION_INTERVAL_SHORT	10000	/* 10 sec */
19662306a36Sopenharmony_ci#define ATH5K_TUNE_CALIBRATION_INTERVAL_ANI	1000	/* 1 sec */
19762306a36Sopenharmony_ci#define ATH5K_TX_COMPLETE_POLL_INT		3000	/* 3 sec */
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci#define AR5K_INIT_CARR_SENSE_EN			1
20062306a36Sopenharmony_ci
20162306a36Sopenharmony_ci/*Swap RX/TX Descriptor for big endian archs*/
20262306a36Sopenharmony_ci#if defined(__BIG_ENDIAN)
20362306a36Sopenharmony_ci#define AR5K_INIT_CFG	(		\
20462306a36Sopenharmony_ci	AR5K_CFG_SWTD | AR5K_CFG_SWRD	\
20562306a36Sopenharmony_ci)
20662306a36Sopenharmony_ci#else
20762306a36Sopenharmony_ci#define AR5K_INIT_CFG	0x00000000
20862306a36Sopenharmony_ci#endif
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_ci/* Initial values */
21162306a36Sopenharmony_ci#define	AR5K_INIT_CYCRSSI_THR1			2
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci/* Tx retry limit defaults from standard */
21462306a36Sopenharmony_ci#define AR5K_INIT_RETRY_SHORT			7
21562306a36Sopenharmony_ci#define AR5K_INIT_RETRY_LONG			4
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_ci/* Slot time */
21862306a36Sopenharmony_ci#define AR5K_INIT_SLOT_TIME_TURBO		6
21962306a36Sopenharmony_ci#define AR5K_INIT_SLOT_TIME_DEFAULT		9
22062306a36Sopenharmony_ci#define	AR5K_INIT_SLOT_TIME_HALF_RATE		13
22162306a36Sopenharmony_ci#define	AR5K_INIT_SLOT_TIME_QUARTER_RATE	21
22262306a36Sopenharmony_ci#define	AR5K_INIT_SLOT_TIME_B			20
22362306a36Sopenharmony_ci#define AR5K_SLOT_TIME_MAX			0xffff
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci/* SIFS */
22662306a36Sopenharmony_ci#define	AR5K_INIT_SIFS_TURBO			6
22762306a36Sopenharmony_ci#define	AR5K_INIT_SIFS_DEFAULT_BG		10
22862306a36Sopenharmony_ci#define	AR5K_INIT_SIFS_DEFAULT_A		16
22962306a36Sopenharmony_ci#define	AR5K_INIT_SIFS_HALF_RATE		32
23062306a36Sopenharmony_ci#define AR5K_INIT_SIFS_QUARTER_RATE		64
23162306a36Sopenharmony_ci
23262306a36Sopenharmony_ci/* Used to calculate tx time for non 5/10/40MHz
23362306a36Sopenharmony_ci * operation */
23462306a36Sopenharmony_ci/* It's preamble time + signal time (16 + 4) */
23562306a36Sopenharmony_ci#define	AR5K_INIT_OFDM_PREAMPLE_TIME		20
23662306a36Sopenharmony_ci/* Preamble time for 40MHz (turbo) operation (min ?) */
23762306a36Sopenharmony_ci#define	AR5K_INIT_OFDM_PREAMBLE_TIME_MIN	14
23862306a36Sopenharmony_ci#define	AR5K_INIT_OFDM_SYMBOL_TIME		4
23962306a36Sopenharmony_ci#define	AR5K_INIT_OFDM_PLCP_BITS		22
24062306a36Sopenharmony_ci
24162306a36Sopenharmony_ci/* Rx latency for 5 and 10MHz operation (max ?) */
24262306a36Sopenharmony_ci#define AR5K_INIT_RX_LAT_MAX			63
24362306a36Sopenharmony_ci/* Tx latencies from initvals (5212 only but no problem
24462306a36Sopenharmony_ci * because we only tweak them on 5212) */
24562306a36Sopenharmony_ci#define	AR5K_INIT_TX_LAT_A			54
24662306a36Sopenharmony_ci#define	AR5K_INIT_TX_LAT_BG			384
24762306a36Sopenharmony_ci/* Tx latency for 40MHz (turbo) operation (min ?) */
24862306a36Sopenharmony_ci#define	AR5K_INIT_TX_LAT_MIN			32
24962306a36Sopenharmony_ci/* Default Tx/Rx latencies (same for 5211)*/
25062306a36Sopenharmony_ci#define AR5K_INIT_TX_LATENCY_5210		54
25162306a36Sopenharmony_ci#define	AR5K_INIT_RX_LATENCY_5210		29
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ci/* Tx frame to Tx data start delay */
25462306a36Sopenharmony_ci#define AR5K_INIT_TXF2TXD_START_DEFAULT		14
25562306a36Sopenharmony_ci#define AR5K_INIT_TXF2TXD_START_DELAY_10MHZ	12
25662306a36Sopenharmony_ci#define AR5K_INIT_TXF2TXD_START_DELAY_5MHZ	13
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_ci/* We need to increase PHY switch and agc settling time
25962306a36Sopenharmony_ci * on turbo mode */
26062306a36Sopenharmony_ci#define	AR5K_SWITCH_SETTLING			5760
26162306a36Sopenharmony_ci#define	AR5K_SWITCH_SETTLING_TURBO		7168
26262306a36Sopenharmony_ci
26362306a36Sopenharmony_ci#define	AR5K_AGC_SETTLING			28
26462306a36Sopenharmony_ci/* 38 on 5210 but shouldn't matter */
26562306a36Sopenharmony_ci#define	AR5K_AGC_SETTLING_TURBO			37
26662306a36Sopenharmony_ci
26762306a36Sopenharmony_ci
26862306a36Sopenharmony_ci
26962306a36Sopenharmony_ci/*****************************\
27062306a36Sopenharmony_ci* GENERIC CHIPSET DEFINITIONS *
27162306a36Sopenharmony_ci\*****************************/
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci/**
27462306a36Sopenharmony_ci * enum ath5k_version - MAC Chips
27562306a36Sopenharmony_ci * @AR5K_AR5210: AR5210 (Crete)
27662306a36Sopenharmony_ci * @AR5K_AR5211: AR5211 (Oahu/Maui)
27762306a36Sopenharmony_ci * @AR5K_AR5212: AR5212 (Venice) and newer
27862306a36Sopenharmony_ci */
27962306a36Sopenharmony_cienum ath5k_version {
28062306a36Sopenharmony_ci	AR5K_AR5210	= 0,
28162306a36Sopenharmony_ci	AR5K_AR5211	= 1,
28262306a36Sopenharmony_ci	AR5K_AR5212	= 2,
28362306a36Sopenharmony_ci};
28462306a36Sopenharmony_ci
28562306a36Sopenharmony_ci/**
28662306a36Sopenharmony_ci * enum ath5k_radio - PHY Chips
28762306a36Sopenharmony_ci * @AR5K_RF5110: RF5110 (Fez)
28862306a36Sopenharmony_ci * @AR5K_RF5111: RF5111 (Sombrero)
28962306a36Sopenharmony_ci * @AR5K_RF5112: RF2112/5112(A) (Derby/Derby2)
29062306a36Sopenharmony_ci * @AR5K_RF2413: RF2413/2414 (Griffin/Griffin-Lite)
29162306a36Sopenharmony_ci * @AR5K_RF5413: RF5413/5414/5424 (Eagle/Condor)
29262306a36Sopenharmony_ci * @AR5K_RF2316: RF2315/2316 (Cobra SoC)
29362306a36Sopenharmony_ci * @AR5K_RF2317: RF2317 (Spider SoC)
29462306a36Sopenharmony_ci * @AR5K_RF2425: RF2425/2417 (Swan/Nalla)
29562306a36Sopenharmony_ci */
29662306a36Sopenharmony_cienum ath5k_radio {
29762306a36Sopenharmony_ci	AR5K_RF5110	= 0,
29862306a36Sopenharmony_ci	AR5K_RF5111	= 1,
29962306a36Sopenharmony_ci	AR5K_RF5112	= 2,
30062306a36Sopenharmony_ci	AR5K_RF2413	= 3,
30162306a36Sopenharmony_ci	AR5K_RF5413	= 4,
30262306a36Sopenharmony_ci	AR5K_RF2316	= 5,
30362306a36Sopenharmony_ci	AR5K_RF2317	= 6,
30462306a36Sopenharmony_ci	AR5K_RF2425	= 7,
30562306a36Sopenharmony_ci};
30662306a36Sopenharmony_ci
30762306a36Sopenharmony_ci/*
30862306a36Sopenharmony_ci * Common silicon revision/version values
30962306a36Sopenharmony_ci */
31062306a36Sopenharmony_ci
31162306a36Sopenharmony_ci#define AR5K_SREV_UNKNOWN	0xffff
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_ci#define AR5K_SREV_AR5210	0x00 /* Crete */
31462306a36Sopenharmony_ci#define AR5K_SREV_AR5311	0x10 /* Maui 1 */
31562306a36Sopenharmony_ci#define AR5K_SREV_AR5311A	0x20 /* Maui 2 */
31662306a36Sopenharmony_ci#define AR5K_SREV_AR5311B	0x30 /* Spirit */
31762306a36Sopenharmony_ci#define AR5K_SREV_AR5211	0x40 /* Oahu */
31862306a36Sopenharmony_ci#define AR5K_SREV_AR5212	0x50 /* Venice */
31962306a36Sopenharmony_ci#define AR5K_SREV_AR5312_R2	0x52 /* AP31 */
32062306a36Sopenharmony_ci#define AR5K_SREV_AR5212_V4	0x54 /* ??? */
32162306a36Sopenharmony_ci#define AR5K_SREV_AR5213	0x55 /* ??? */
32262306a36Sopenharmony_ci#define AR5K_SREV_AR5312_R7	0x57 /* AP30 */
32362306a36Sopenharmony_ci#define AR5K_SREV_AR2313_R8	0x58 /* AP43 */
32462306a36Sopenharmony_ci#define AR5K_SREV_AR5213A	0x59 /* Hainan */
32562306a36Sopenharmony_ci#define AR5K_SREV_AR2413	0x78 /* Griffin lite */
32662306a36Sopenharmony_ci#define AR5K_SREV_AR2414	0x70 /* Griffin */
32762306a36Sopenharmony_ci#define AR5K_SREV_AR2315_R6	0x86 /* AP51-Light */
32862306a36Sopenharmony_ci#define AR5K_SREV_AR2315_R7	0x87 /* AP51-Full */
32962306a36Sopenharmony_ci#define AR5K_SREV_AR5424	0x90 /* Condor */
33062306a36Sopenharmony_ci#define AR5K_SREV_AR2317_R1	0x90 /* AP61-Light */
33162306a36Sopenharmony_ci#define AR5K_SREV_AR2317_R2	0x91 /* AP61-Full */
33262306a36Sopenharmony_ci#define AR5K_SREV_AR5413	0xa4 /* Eagle lite */
33362306a36Sopenharmony_ci#define AR5K_SREV_AR5414	0xa0 /* Eagle */
33462306a36Sopenharmony_ci#define AR5K_SREV_AR2415	0xb0 /* Talon */
33562306a36Sopenharmony_ci#define AR5K_SREV_AR5416	0xc0 /* PCI-E */
33662306a36Sopenharmony_ci#define AR5K_SREV_AR5418	0xca /* PCI-E */
33762306a36Sopenharmony_ci#define AR5K_SREV_AR2425	0xe0 /* Swan */
33862306a36Sopenharmony_ci#define AR5K_SREV_AR2417	0xf0 /* Nala */
33962306a36Sopenharmony_ci
34062306a36Sopenharmony_ci#define AR5K_SREV_RAD_5110	0x00
34162306a36Sopenharmony_ci#define AR5K_SREV_RAD_5111	0x10
34262306a36Sopenharmony_ci#define AR5K_SREV_RAD_5111A	0x15
34362306a36Sopenharmony_ci#define AR5K_SREV_RAD_2111	0x20
34462306a36Sopenharmony_ci#define AR5K_SREV_RAD_5112	0x30
34562306a36Sopenharmony_ci#define AR5K_SREV_RAD_5112A	0x35
34662306a36Sopenharmony_ci#define	AR5K_SREV_RAD_5112B	0x36
34762306a36Sopenharmony_ci#define AR5K_SREV_RAD_2112	0x40
34862306a36Sopenharmony_ci#define AR5K_SREV_RAD_2112A	0x45
34962306a36Sopenharmony_ci#define	AR5K_SREV_RAD_2112B	0x46
35062306a36Sopenharmony_ci#define AR5K_SREV_RAD_2413	0x50
35162306a36Sopenharmony_ci#define AR5K_SREV_RAD_5413	0x60
35262306a36Sopenharmony_ci#define AR5K_SREV_RAD_2316	0x70 /* Cobra SoC */
35362306a36Sopenharmony_ci#define AR5K_SREV_RAD_2317	0x80
35462306a36Sopenharmony_ci#define AR5K_SREV_RAD_5424	0xa0 /* Mostly same as 5413 */
35562306a36Sopenharmony_ci#define AR5K_SREV_RAD_2425	0xa2
35662306a36Sopenharmony_ci#define AR5K_SREV_RAD_5133	0xc0
35762306a36Sopenharmony_ci
35862306a36Sopenharmony_ci#define AR5K_SREV_PHY_5211	0x30
35962306a36Sopenharmony_ci#define AR5K_SREV_PHY_5212	0x41
36062306a36Sopenharmony_ci#define	AR5K_SREV_PHY_5212A	0x42
36162306a36Sopenharmony_ci#define AR5K_SREV_PHY_5212B	0x43
36262306a36Sopenharmony_ci#define AR5K_SREV_PHY_2413	0x45
36362306a36Sopenharmony_ci#define AR5K_SREV_PHY_5413	0x61
36462306a36Sopenharmony_ci#define AR5K_SREV_PHY_2425	0x70
36562306a36Sopenharmony_ci
36662306a36Sopenharmony_ci/* TODO add support to mac80211 for vendor-specific rates and modes */
36762306a36Sopenharmony_ci
36862306a36Sopenharmony_ci/**
36962306a36Sopenharmony_ci * DOC: Atheros XR
37062306a36Sopenharmony_ci *
37162306a36Sopenharmony_ci * Some of this information is based on Documentation from:
37262306a36Sopenharmony_ci *
37362306a36Sopenharmony_ci * http://madwifi-project.org/wiki/ChipsetFeatures/SuperAG
37462306a36Sopenharmony_ci *
37562306a36Sopenharmony_ci * Atheros' eXtended Range - range enhancing extension is a modulation scheme
37662306a36Sopenharmony_ci * that is supposed to double the link distance between an Atheros XR-enabled
37762306a36Sopenharmony_ci * client device with an Atheros XR-enabled access point. This is achieved
37862306a36Sopenharmony_ci * by increasing the receiver sensitivity up to, -105dBm, which is about 20dB
37962306a36Sopenharmony_ci * above what the 802.11 specifications demand. In addition, new (proprietary)
38062306a36Sopenharmony_ci * data rates are introduced: 3, 2, 1, 0.5 and 0.25 MBit/s.
38162306a36Sopenharmony_ci *
38262306a36Sopenharmony_ci * Please note that can you either use XR or TURBO but you cannot use both,
38362306a36Sopenharmony_ci * they are exclusive.
38462306a36Sopenharmony_ci *
38562306a36Sopenharmony_ci * Also note that we do not plan to support XR mode at least for now. You can
38662306a36Sopenharmony_ci * get a mode similar to XR by using 5MHz bwmode.
38762306a36Sopenharmony_ci */
38862306a36Sopenharmony_ci
38962306a36Sopenharmony_ci
39062306a36Sopenharmony_ci/**
39162306a36Sopenharmony_ci * DOC: Atheros SuperAG
39262306a36Sopenharmony_ci *
39362306a36Sopenharmony_ci * In addition to XR we have another modulation scheme called TURBO mode
39462306a36Sopenharmony_ci * that is supposed to provide a throughput transmission speed up to 40Mbit/s
39562306a36Sopenharmony_ci * -60Mbit/s at a 108Mbit/s signaling rate achieved through the bonding of two
39662306a36Sopenharmony_ci * 54Mbit/s 802.11g channels. To use this feature both ends must support it.
39762306a36Sopenharmony_ci * There is also a distinction between "static" and "dynamic" turbo modes:
39862306a36Sopenharmony_ci *
39962306a36Sopenharmony_ci * - Static: is the dumb version: devices set to this mode stick to it until
40062306a36Sopenharmony_ci *     the mode is turned off.
40162306a36Sopenharmony_ci *
40262306a36Sopenharmony_ci * - Dynamic: is the intelligent version, the network decides itself if it
40362306a36Sopenharmony_ci *     is ok to use turbo. As soon as traffic is detected on adjacent channels
40462306a36Sopenharmony_ci *     (which would get used in turbo mode), or when a non-turbo station joins
40562306a36Sopenharmony_ci *     the network, turbo mode won't be used until the situation changes again.
40662306a36Sopenharmony_ci *     Dynamic mode is achieved by Atheros' Adaptive Radio (AR) feature which
40762306a36Sopenharmony_ci *     monitors the used radio band in order to decide whether turbo mode may
40862306a36Sopenharmony_ci *     be used or not.
40962306a36Sopenharmony_ci *
41062306a36Sopenharmony_ci * This article claims Super G sticks to bonding of channels 5 and 6 for
41162306a36Sopenharmony_ci * USA:
41262306a36Sopenharmony_ci *
41362306a36Sopenharmony_ci * https://www.pcworld.com/article/id,113428-page,1/article.html
41462306a36Sopenharmony_ci *
41562306a36Sopenharmony_ci * The channel bonding seems to be driver specific though.
41662306a36Sopenharmony_ci *
41762306a36Sopenharmony_ci * In addition to TURBO modes we also have the following features for even
41862306a36Sopenharmony_ci * greater speed-up:
41962306a36Sopenharmony_ci *
42062306a36Sopenharmony_ci * - Bursting: allows multiple frames to be sent at once, rather than pausing
42162306a36Sopenharmony_ci *     after each frame. Bursting is a standards-compliant feature that can be
42262306a36Sopenharmony_ci *     used with any Access Point.
42362306a36Sopenharmony_ci *
42462306a36Sopenharmony_ci * - Fast frames: increases the amount of information that can be sent per
42562306a36Sopenharmony_ci *     frame, also resulting in a reduction of transmission overhead. It is a
42662306a36Sopenharmony_ci *     proprietary feature that needs to be supported by the Access Point.
42762306a36Sopenharmony_ci *
42862306a36Sopenharmony_ci * - Compression: data frames are compressed in real time using a Lempel Ziv
42962306a36Sopenharmony_ci *     algorithm. This is done transparently. Once this feature is enabled,
43062306a36Sopenharmony_ci *     compression and decompression takes place inside the chipset, without
43162306a36Sopenharmony_ci *     putting additional load on the host CPU.
43262306a36Sopenharmony_ci *
43362306a36Sopenharmony_ci * As with XR we also don't plan to support SuperAG features for now. You can
43462306a36Sopenharmony_ci * get a mode similar to TURBO by using 40MHz bwmode.
43562306a36Sopenharmony_ci */
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_ci
43862306a36Sopenharmony_ci/**
43962306a36Sopenharmony_ci * enum ath5k_driver_mode - PHY operation mode
44062306a36Sopenharmony_ci * @AR5K_MODE_11A: 802.11a
44162306a36Sopenharmony_ci * @AR5K_MODE_11B: 802.11b
44262306a36Sopenharmony_ci * @AR5K_MODE_11G: 801.11g
44362306a36Sopenharmony_ci * @AR5K_MODE_MAX: Used for boundary checks
44462306a36Sopenharmony_ci *
44562306a36Sopenharmony_ci * Do not change the order here, we use these as
44662306a36Sopenharmony_ci * array indices and it also maps EEPROM structures.
44762306a36Sopenharmony_ci */
44862306a36Sopenharmony_cienum ath5k_driver_mode {
44962306a36Sopenharmony_ci	AR5K_MODE_11A		=	0,
45062306a36Sopenharmony_ci	AR5K_MODE_11B		=	1,
45162306a36Sopenharmony_ci	AR5K_MODE_11G		=	2,
45262306a36Sopenharmony_ci	AR5K_MODE_MAX		=	3
45362306a36Sopenharmony_ci};
45462306a36Sopenharmony_ci
45562306a36Sopenharmony_ci/**
45662306a36Sopenharmony_ci * enum ath5k_ant_mode - Antenna operation mode
45762306a36Sopenharmony_ci * @AR5K_ANTMODE_DEFAULT: Default antenna setup
45862306a36Sopenharmony_ci * @AR5K_ANTMODE_FIXED_A: Only antenna A is present
45962306a36Sopenharmony_ci * @AR5K_ANTMODE_FIXED_B: Only antenna B is present
46062306a36Sopenharmony_ci * @AR5K_ANTMODE_SINGLE_AP: STA locked on a single ap
46162306a36Sopenharmony_ci * @AR5K_ANTMODE_SECTOR_AP: AP with tx antenna set on tx desc
46262306a36Sopenharmony_ci * @AR5K_ANTMODE_SECTOR_STA: STA with tx antenna set on tx desc
46362306a36Sopenharmony_ci * @AR5K_ANTMODE_DEBUG: Debug mode -A -> Rx, B-> Tx-
46462306a36Sopenharmony_ci * @AR5K_ANTMODE_MAX: Used for boundary checks
46562306a36Sopenharmony_ci *
46662306a36Sopenharmony_ci * For more infos on antenna control check out phy.c
46762306a36Sopenharmony_ci */
46862306a36Sopenharmony_cienum ath5k_ant_mode {
46962306a36Sopenharmony_ci	AR5K_ANTMODE_DEFAULT	= 0,
47062306a36Sopenharmony_ci	AR5K_ANTMODE_FIXED_A	= 1,
47162306a36Sopenharmony_ci	AR5K_ANTMODE_FIXED_B	= 2,
47262306a36Sopenharmony_ci	AR5K_ANTMODE_SINGLE_AP	= 3,
47362306a36Sopenharmony_ci	AR5K_ANTMODE_SECTOR_AP	= 4,
47462306a36Sopenharmony_ci	AR5K_ANTMODE_SECTOR_STA	= 5,
47562306a36Sopenharmony_ci	AR5K_ANTMODE_DEBUG	= 6,
47662306a36Sopenharmony_ci	AR5K_ANTMODE_MAX,
47762306a36Sopenharmony_ci};
47862306a36Sopenharmony_ci
47962306a36Sopenharmony_ci/**
48062306a36Sopenharmony_ci * enum ath5k_bw_mode - Bandwidth operation mode
48162306a36Sopenharmony_ci * @AR5K_BWMODE_DEFAULT: 20MHz, default operation
48262306a36Sopenharmony_ci * @AR5K_BWMODE_5MHZ: Quarter rate
48362306a36Sopenharmony_ci * @AR5K_BWMODE_10MHZ: Half rate
48462306a36Sopenharmony_ci * @AR5K_BWMODE_40MHZ: Turbo
48562306a36Sopenharmony_ci */
48662306a36Sopenharmony_cienum ath5k_bw_mode {
48762306a36Sopenharmony_ci	AR5K_BWMODE_DEFAULT	= 0,
48862306a36Sopenharmony_ci	AR5K_BWMODE_5MHZ	= 1,
48962306a36Sopenharmony_ci	AR5K_BWMODE_10MHZ	= 2,
49062306a36Sopenharmony_ci	AR5K_BWMODE_40MHZ	= 3
49162306a36Sopenharmony_ci};
49262306a36Sopenharmony_ci
49362306a36Sopenharmony_ci
49462306a36Sopenharmony_ci
49562306a36Sopenharmony_ci/****************\
49662306a36Sopenharmony_ci  TX DEFINITIONS
49762306a36Sopenharmony_ci\****************/
49862306a36Sopenharmony_ci
49962306a36Sopenharmony_ci/**
50062306a36Sopenharmony_ci * struct ath5k_tx_status - TX Status descriptor
50162306a36Sopenharmony_ci * @ts_seqnum: Sequence number
50262306a36Sopenharmony_ci * @ts_tstamp: Timestamp
50362306a36Sopenharmony_ci * @ts_status: Status code
50462306a36Sopenharmony_ci * @ts_final_idx: Final transmission series index
50562306a36Sopenharmony_ci * @ts_final_retry: Final retry count
50662306a36Sopenharmony_ci * @ts_rssi: RSSI for received ACK
50762306a36Sopenharmony_ci * @ts_shortretry: Short retry count
50862306a36Sopenharmony_ci * @ts_virtcol: Virtual collision count
50962306a36Sopenharmony_ci * @ts_antenna: Antenna used
51062306a36Sopenharmony_ci *
51162306a36Sopenharmony_ci * TX status descriptor gets filled by the hw
51262306a36Sopenharmony_ci * on each transmission attempt.
51362306a36Sopenharmony_ci */
51462306a36Sopenharmony_cistruct ath5k_tx_status {
51562306a36Sopenharmony_ci	u16	ts_seqnum;
51662306a36Sopenharmony_ci	u16	ts_tstamp;
51762306a36Sopenharmony_ci	u8	ts_status;
51862306a36Sopenharmony_ci	u8	ts_final_idx;
51962306a36Sopenharmony_ci	u8	ts_final_retry;
52062306a36Sopenharmony_ci	s8	ts_rssi;
52162306a36Sopenharmony_ci	u8	ts_shortretry;
52262306a36Sopenharmony_ci	u8	ts_virtcol;
52362306a36Sopenharmony_ci	u8	ts_antenna;
52462306a36Sopenharmony_ci};
52562306a36Sopenharmony_ci
52662306a36Sopenharmony_ci#define AR5K_TXSTAT_ALTRATE	0x80
52762306a36Sopenharmony_ci#define AR5K_TXERR_XRETRY	0x01
52862306a36Sopenharmony_ci#define AR5K_TXERR_FILT		0x02
52962306a36Sopenharmony_ci#define AR5K_TXERR_FIFO		0x04
53062306a36Sopenharmony_ci
53162306a36Sopenharmony_ci/**
53262306a36Sopenharmony_ci * enum ath5k_tx_queue - Queue types used to classify tx queues.
53362306a36Sopenharmony_ci * @AR5K_TX_QUEUE_INACTIVE: q is unused -- see ath5k_hw_release_tx_queue
53462306a36Sopenharmony_ci * @AR5K_TX_QUEUE_DATA: A normal data queue
53562306a36Sopenharmony_ci * @AR5K_TX_QUEUE_BEACON: The beacon queue
53662306a36Sopenharmony_ci * @AR5K_TX_QUEUE_CAB: The after-beacon queue
53762306a36Sopenharmony_ci * @AR5K_TX_QUEUE_UAPSD: Unscheduled Automatic Power Save Delivery queue
53862306a36Sopenharmony_ci */
53962306a36Sopenharmony_cienum ath5k_tx_queue {
54062306a36Sopenharmony_ci	AR5K_TX_QUEUE_INACTIVE = 0,
54162306a36Sopenharmony_ci	AR5K_TX_QUEUE_DATA,
54262306a36Sopenharmony_ci	AR5K_TX_QUEUE_BEACON,
54362306a36Sopenharmony_ci	AR5K_TX_QUEUE_CAB,
54462306a36Sopenharmony_ci	AR5K_TX_QUEUE_UAPSD,
54562306a36Sopenharmony_ci};
54662306a36Sopenharmony_ci
54762306a36Sopenharmony_ci#define	AR5K_NUM_TX_QUEUES		10
54862306a36Sopenharmony_ci#define	AR5K_NUM_TX_QUEUES_NOQCU	2
54962306a36Sopenharmony_ci
55062306a36Sopenharmony_ci/**
55162306a36Sopenharmony_ci * enum ath5k_tx_queue_subtype - Queue sub-types to classify normal data queues
55262306a36Sopenharmony_ci * @AR5K_WME_AC_BK: Background traffic
55362306a36Sopenharmony_ci * @AR5K_WME_AC_BE: Best-effort (normal) traffic
55462306a36Sopenharmony_ci * @AR5K_WME_AC_VI: Video traffic
55562306a36Sopenharmony_ci * @AR5K_WME_AC_VO: Voice traffic
55662306a36Sopenharmony_ci *
55762306a36Sopenharmony_ci * These are the 4 Access Categories as defined in
55862306a36Sopenharmony_ci * WME spec. 0 is the lowest priority and 4 is the
55962306a36Sopenharmony_ci * highest. Normal data that hasn't been classified
56062306a36Sopenharmony_ci * goes to the Best Effort AC.
56162306a36Sopenharmony_ci */
56262306a36Sopenharmony_cienum ath5k_tx_queue_subtype {
56362306a36Sopenharmony_ci	AR5K_WME_AC_BK = 0,
56462306a36Sopenharmony_ci	AR5K_WME_AC_BE,
56562306a36Sopenharmony_ci	AR5K_WME_AC_VI,
56662306a36Sopenharmony_ci	AR5K_WME_AC_VO,
56762306a36Sopenharmony_ci};
56862306a36Sopenharmony_ci
56962306a36Sopenharmony_ci/**
57062306a36Sopenharmony_ci * enum ath5k_tx_queue_id - Queue ID numbers as returned by the hw functions
57162306a36Sopenharmony_ci * @AR5K_TX_QUEUE_ID_NOQCU_DATA: Data queue on AR5210 (no QCU available)
57262306a36Sopenharmony_ci * @AR5K_TX_QUEUE_ID_NOQCU_BEACON: Beacon queue on AR5210 (no QCU available)
57362306a36Sopenharmony_ci * @AR5K_TX_QUEUE_ID_DATA_MIN: Data queue min index
57462306a36Sopenharmony_ci * @AR5K_TX_QUEUE_ID_DATA_MAX: Data queue max index
57562306a36Sopenharmony_ci * @AR5K_TX_QUEUE_ID_CAB: Content after beacon queue
57662306a36Sopenharmony_ci * @AR5K_TX_QUEUE_ID_BEACON: Beacon queue
57762306a36Sopenharmony_ci * @AR5K_TX_QUEUE_ID_UAPSD: Urgent Automatic Power Save Delivery,
57862306a36Sopenharmony_ci *
57962306a36Sopenharmony_ci * Each number represents a hw queue. If hw does not support hw queues
58062306a36Sopenharmony_ci * (eg 5210) all data goes in one queue.
58162306a36Sopenharmony_ci */
58262306a36Sopenharmony_cienum ath5k_tx_queue_id {
58362306a36Sopenharmony_ci	AR5K_TX_QUEUE_ID_NOQCU_DATA	= 0,
58462306a36Sopenharmony_ci	AR5K_TX_QUEUE_ID_NOQCU_BEACON	= 1,
58562306a36Sopenharmony_ci	AR5K_TX_QUEUE_ID_DATA_MIN	= 0,
58662306a36Sopenharmony_ci	AR5K_TX_QUEUE_ID_DATA_MAX	= 3,
58762306a36Sopenharmony_ci	AR5K_TX_QUEUE_ID_UAPSD		= 7,
58862306a36Sopenharmony_ci	AR5K_TX_QUEUE_ID_CAB		= 8,
58962306a36Sopenharmony_ci	AR5K_TX_QUEUE_ID_BEACON		= 9,
59062306a36Sopenharmony_ci};
59162306a36Sopenharmony_ci
59262306a36Sopenharmony_ci/*
59362306a36Sopenharmony_ci * Flags to set hw queue's parameters...
59462306a36Sopenharmony_ci */
59562306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_TXOKINT_ENABLE		0x0001	/* Enable TXOK interrupt */
59662306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_TXERRINT_ENABLE		0x0002	/* Enable TXERR interrupt */
59762306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_TXEOLINT_ENABLE		0x0004	/* Enable TXEOL interrupt -not used- */
59862306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_TXDESCINT_ENABLE		0x0008	/* Enable TXDESC interrupt -not used- */
59962306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_TXURNINT_ENABLE		0x0010	/* Enable TXURN interrupt */
60062306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_CBRORNINT_ENABLE		0x0020	/* Enable CBRORN interrupt */
60162306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_CBRURNINT_ENABLE		0x0040	/* Enable CBRURN interrupt */
60262306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_QTRIGINT_ENABLE		0x0080	/* Enable QTRIG interrupt */
60362306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_TXNOFRMINT_ENABLE		0x0100	/* Enable TXNOFRM interrupt */
60462306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_BACKOFF_DISABLE		0x0200	/* Disable random post-backoff */
60562306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE	0x0300	/* Enable ready time expiry policy (?)*/
60662306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE	0x0800	/* Enable backoff while bursting */
60762306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_POST_FR_BKOFF_DIS		0x1000	/* Disable backoff while bursting */
60862306a36Sopenharmony_ci#define AR5K_TXQ_FLAG_COMPRESSION_ENABLE	0x2000	/* Enable hw compression -not implemented-*/
60962306a36Sopenharmony_ci
61062306a36Sopenharmony_ci/**
61162306a36Sopenharmony_ci * struct ath5k_txq - Transmit queue state
61262306a36Sopenharmony_ci * @qnum: Hardware q number
61362306a36Sopenharmony_ci * @link: Link ptr in last TX desc
61462306a36Sopenharmony_ci * @q: Transmit queue (&struct list_head)
61562306a36Sopenharmony_ci * @lock: Lock on q and link
61662306a36Sopenharmony_ci * @setup: Is the queue configured
61762306a36Sopenharmony_ci * @txq_len:Number of queued buffers
61862306a36Sopenharmony_ci * @txq_max: Max allowed num of queued buffers
61962306a36Sopenharmony_ci * @txq_poll_mark: Used to check if queue got stuck
62062306a36Sopenharmony_ci * @txq_stuck: Queue stuck counter
62162306a36Sopenharmony_ci *
62262306a36Sopenharmony_ci * One of these exists for each hardware transmit queue.
62362306a36Sopenharmony_ci * Packets sent to us from above are assigned to queues based
62462306a36Sopenharmony_ci * on their priority.  Not all devices support a complete set
62562306a36Sopenharmony_ci * of hardware transmit queues. For those devices the array
62662306a36Sopenharmony_ci * sc_ac2q will map multiple priorities to fewer hardware queues
62762306a36Sopenharmony_ci * (typically all to one hardware queue).
62862306a36Sopenharmony_ci */
62962306a36Sopenharmony_cistruct ath5k_txq {
63062306a36Sopenharmony_ci	unsigned int		qnum;
63162306a36Sopenharmony_ci	u32			*link;
63262306a36Sopenharmony_ci	struct list_head	q;
63362306a36Sopenharmony_ci	spinlock_t		lock;
63462306a36Sopenharmony_ci	bool			setup;
63562306a36Sopenharmony_ci	int			txq_len;
63662306a36Sopenharmony_ci	int			txq_max;
63762306a36Sopenharmony_ci	bool			txq_poll_mark;
63862306a36Sopenharmony_ci	unsigned int		txq_stuck;
63962306a36Sopenharmony_ci};
64062306a36Sopenharmony_ci
64162306a36Sopenharmony_ci/**
64262306a36Sopenharmony_ci * struct ath5k_txq_info - A struct to hold TX queue's parameters
64362306a36Sopenharmony_ci * @tqi_type: One of enum ath5k_tx_queue
64462306a36Sopenharmony_ci * @tqi_subtype: One of enum ath5k_tx_queue_subtype
64562306a36Sopenharmony_ci * @tqi_flags: TX queue flags (see above)
64662306a36Sopenharmony_ci * @tqi_aifs: Arbitrated Inter-frame Space
64762306a36Sopenharmony_ci * @tqi_cw_min: Minimum Contention Window
64862306a36Sopenharmony_ci * @tqi_cw_max: Maximum Contention Window
64962306a36Sopenharmony_ci * @tqi_cbr_period: Constant bit rate period
65062306a36Sopenharmony_ci * @tqi_ready_time: Time queue waits after an event when RDYTIME is enabled
65162306a36Sopenharmony_ci */
65262306a36Sopenharmony_cistruct ath5k_txq_info {
65362306a36Sopenharmony_ci	enum ath5k_tx_queue tqi_type;
65462306a36Sopenharmony_ci	enum ath5k_tx_queue_subtype tqi_subtype;
65562306a36Sopenharmony_ci	u16	tqi_flags;
65662306a36Sopenharmony_ci	u8	tqi_aifs;
65762306a36Sopenharmony_ci	u16	tqi_cw_min;
65862306a36Sopenharmony_ci	u16	tqi_cw_max;
65962306a36Sopenharmony_ci	u32	tqi_cbr_period;
66062306a36Sopenharmony_ci	u32	tqi_cbr_overflow_limit;
66162306a36Sopenharmony_ci	u32	tqi_burst_time;
66262306a36Sopenharmony_ci	u32	tqi_ready_time;
66362306a36Sopenharmony_ci};
66462306a36Sopenharmony_ci
66562306a36Sopenharmony_ci/**
66662306a36Sopenharmony_ci * enum ath5k_pkt_type - Transmit packet types
66762306a36Sopenharmony_ci * @AR5K_PKT_TYPE_NORMAL: Normal data
66862306a36Sopenharmony_ci * @AR5K_PKT_TYPE_ATIM: ATIM
66962306a36Sopenharmony_ci * @AR5K_PKT_TYPE_PSPOLL: PS-Poll
67062306a36Sopenharmony_ci * @AR5K_PKT_TYPE_BEACON: Beacon
67162306a36Sopenharmony_ci * @AR5K_PKT_TYPE_PROBE_RESP: Probe response
67262306a36Sopenharmony_ci * @AR5K_PKT_TYPE_PIFS: PIFS
67362306a36Sopenharmony_ci * Used on tx control descriptor
67462306a36Sopenharmony_ci */
67562306a36Sopenharmony_cienum ath5k_pkt_type {
67662306a36Sopenharmony_ci	AR5K_PKT_TYPE_NORMAL		= 0,
67762306a36Sopenharmony_ci	AR5K_PKT_TYPE_ATIM		= 1,
67862306a36Sopenharmony_ci	AR5K_PKT_TYPE_PSPOLL		= 2,
67962306a36Sopenharmony_ci	AR5K_PKT_TYPE_BEACON		= 3,
68062306a36Sopenharmony_ci	AR5K_PKT_TYPE_PROBE_RESP	= 4,
68162306a36Sopenharmony_ci	AR5K_PKT_TYPE_PIFS		= 5,
68262306a36Sopenharmony_ci};
68362306a36Sopenharmony_ci
68462306a36Sopenharmony_ci/*
68562306a36Sopenharmony_ci * TX power and TPC settings
68662306a36Sopenharmony_ci */
68762306a36Sopenharmony_ci#define AR5K_TXPOWER_OFDM(_r, _v)	(			\
68862306a36Sopenharmony_ci	((0 & 1) << ((_v) + 6)) |				\
68962306a36Sopenharmony_ci	(((ah->ah_txpower.txp_rates_power_table[(_r)]) & 0x3f) << (_v))	\
69062306a36Sopenharmony_ci)
69162306a36Sopenharmony_ci
69262306a36Sopenharmony_ci#define AR5K_TXPOWER_CCK(_r, _v)	(			\
69362306a36Sopenharmony_ci	(ah->ah_txpower.txp_rates_power_table[(_r)] & 0x3f) << (_v)	\
69462306a36Sopenharmony_ci)
69562306a36Sopenharmony_ci
69662306a36Sopenharmony_ci
69762306a36Sopenharmony_ci
69862306a36Sopenharmony_ci/****************\
69962306a36Sopenharmony_ci  RX DEFINITIONS
70062306a36Sopenharmony_ci\****************/
70162306a36Sopenharmony_ci
70262306a36Sopenharmony_ci/**
70362306a36Sopenharmony_ci * struct ath5k_rx_status - RX Status descriptor
70462306a36Sopenharmony_ci * @rs_datalen: Data length
70562306a36Sopenharmony_ci * @rs_tstamp: Timestamp
70662306a36Sopenharmony_ci * @rs_status: Status code
70762306a36Sopenharmony_ci * @rs_phyerr: PHY error mask
70862306a36Sopenharmony_ci * @rs_rssi: RSSI in 0.5dbm units
70962306a36Sopenharmony_ci * @rs_keyix: Index to the key used for decrypting
71062306a36Sopenharmony_ci * @rs_rate: Rate used to decode the frame
71162306a36Sopenharmony_ci * @rs_antenna: Antenna used to receive the frame
71262306a36Sopenharmony_ci * @rs_more: Indicates this is a frame fragment (Fast frames)
71362306a36Sopenharmony_ci */
71462306a36Sopenharmony_cistruct ath5k_rx_status {
71562306a36Sopenharmony_ci	u16	rs_datalen;
71662306a36Sopenharmony_ci	u16	rs_tstamp;
71762306a36Sopenharmony_ci	u8	rs_status;
71862306a36Sopenharmony_ci	u8	rs_phyerr;
71962306a36Sopenharmony_ci	s8	rs_rssi;
72062306a36Sopenharmony_ci	u8	rs_keyix;
72162306a36Sopenharmony_ci	u8	rs_rate;
72262306a36Sopenharmony_ci	u8	rs_antenna;
72362306a36Sopenharmony_ci	u8	rs_more;
72462306a36Sopenharmony_ci};
72562306a36Sopenharmony_ci
72662306a36Sopenharmony_ci#define AR5K_RXERR_CRC		0x01
72762306a36Sopenharmony_ci#define AR5K_RXERR_PHY		0x02
72862306a36Sopenharmony_ci#define AR5K_RXERR_FIFO		0x04
72962306a36Sopenharmony_ci#define AR5K_RXERR_DECRYPT	0x08
73062306a36Sopenharmony_ci#define AR5K_RXERR_MIC		0x10
73162306a36Sopenharmony_ci#define AR5K_RXKEYIX_INVALID	((u8) -1)
73262306a36Sopenharmony_ci#define AR5K_TXKEYIX_INVALID	((u32) -1)
73362306a36Sopenharmony_ci
73462306a36Sopenharmony_ci
73562306a36Sopenharmony_ci/**************************\
73662306a36Sopenharmony_ci BEACON TIMERS DEFINITIONS
73762306a36Sopenharmony_ci\**************************/
73862306a36Sopenharmony_ci
73962306a36Sopenharmony_ci#define AR5K_BEACON_PERIOD	0x0000ffff
74062306a36Sopenharmony_ci#define AR5K_BEACON_ENA		0x00800000 /*enable beacon xmit*/
74162306a36Sopenharmony_ci#define AR5K_BEACON_RESET_TSF	0x01000000 /*force a TSF reset*/
74262306a36Sopenharmony_ci
74362306a36Sopenharmony_ci
74462306a36Sopenharmony_ci/*
74562306a36Sopenharmony_ci * TSF to TU conversion:
74662306a36Sopenharmony_ci *
74762306a36Sopenharmony_ci * TSF is a 64bit value in usec (microseconds).
74862306a36Sopenharmony_ci * TU is a 32bit value and defined by IEEE802.11 (page 6) as "A measurement of
74962306a36Sopenharmony_ci * time equal to 1024 usec", so it's roughly milliseconds (usec / 1024).
75062306a36Sopenharmony_ci */
75162306a36Sopenharmony_ci#define TSF_TO_TU(_tsf) (u32)((_tsf) >> 10)
75262306a36Sopenharmony_ci
75362306a36Sopenharmony_ci
75462306a36Sopenharmony_ci
75562306a36Sopenharmony_ci/*******************************\
75662306a36Sopenharmony_ci  GAIN OPTIMIZATION DEFINITIONS
75762306a36Sopenharmony_ci\*******************************/
75862306a36Sopenharmony_ci
75962306a36Sopenharmony_ci/**
76062306a36Sopenharmony_ci * enum ath5k_rfgain - RF Gain optimization engine state
76162306a36Sopenharmony_ci * @AR5K_RFGAIN_INACTIVE: Engine disabled
76262306a36Sopenharmony_ci * @AR5K_RFGAIN_ACTIVE: Probe active
76362306a36Sopenharmony_ci * @AR5K_RFGAIN_READ_REQUESTED: Probe requested
76462306a36Sopenharmony_ci * @AR5K_RFGAIN_NEED_CHANGE: Gain_F needs change
76562306a36Sopenharmony_ci */
76662306a36Sopenharmony_cienum ath5k_rfgain {
76762306a36Sopenharmony_ci	AR5K_RFGAIN_INACTIVE = 0,
76862306a36Sopenharmony_ci	AR5K_RFGAIN_ACTIVE,
76962306a36Sopenharmony_ci	AR5K_RFGAIN_READ_REQUESTED,
77062306a36Sopenharmony_ci	AR5K_RFGAIN_NEED_CHANGE,
77162306a36Sopenharmony_ci};
77262306a36Sopenharmony_ci
77362306a36Sopenharmony_ci/**
77462306a36Sopenharmony_ci * struct ath5k_gain - RF Gain optimization engine state data
77562306a36Sopenharmony_ci * @g_step_idx: Current step index
77662306a36Sopenharmony_ci * @g_current: Current gain
77762306a36Sopenharmony_ci * @g_target: Target gain
77862306a36Sopenharmony_ci * @g_low: Low gain boundary
77962306a36Sopenharmony_ci * @g_high: High gain boundary
78062306a36Sopenharmony_ci * @g_f_corr: Gain_F correction
78162306a36Sopenharmony_ci * @g_state: One of enum ath5k_rfgain
78262306a36Sopenharmony_ci */
78362306a36Sopenharmony_cistruct ath5k_gain {
78462306a36Sopenharmony_ci	u8			g_step_idx;
78562306a36Sopenharmony_ci	u8			g_current;
78662306a36Sopenharmony_ci	u8			g_target;
78762306a36Sopenharmony_ci	u8			g_low;
78862306a36Sopenharmony_ci	u8			g_high;
78962306a36Sopenharmony_ci	u8			g_f_corr;
79062306a36Sopenharmony_ci	u8			g_state;
79162306a36Sopenharmony_ci};
79262306a36Sopenharmony_ci
79362306a36Sopenharmony_ci
79462306a36Sopenharmony_ci
79562306a36Sopenharmony_ci/********************\
79662306a36Sopenharmony_ci  COMMON DEFINITIONS
79762306a36Sopenharmony_ci\********************/
79862306a36Sopenharmony_ci
79962306a36Sopenharmony_ci#define AR5K_SLOT_TIME_9	396
80062306a36Sopenharmony_ci#define AR5K_SLOT_TIME_20	880
80162306a36Sopenharmony_ci#define AR5K_SLOT_TIME_MAX	0xffff
80262306a36Sopenharmony_ci
80362306a36Sopenharmony_ci/**
80462306a36Sopenharmony_ci * struct ath5k_athchan_2ghz - 2GHz to 5GHZ map for RF5111
80562306a36Sopenharmony_ci * @a2_flags: Channel flags (internal)
80662306a36Sopenharmony_ci * @a2_athchan: HW channel number (internal)
80762306a36Sopenharmony_ci *
80862306a36Sopenharmony_ci * This structure is used to map 2GHz channels to
80962306a36Sopenharmony_ci * 5GHz Atheros channels on 2111 frequency converter
81062306a36Sopenharmony_ci * that comes together with RF5111
81162306a36Sopenharmony_ci * TODO: Clean up
81262306a36Sopenharmony_ci */
81362306a36Sopenharmony_cistruct ath5k_athchan_2ghz {
81462306a36Sopenharmony_ci	u32	a2_flags;
81562306a36Sopenharmony_ci	u16	a2_athchan;
81662306a36Sopenharmony_ci};
81762306a36Sopenharmony_ci
81862306a36Sopenharmony_ci/**
81962306a36Sopenharmony_ci * enum ath5k_dmasize -  DMA size definitions (2^(n+2))
82062306a36Sopenharmony_ci * @AR5K_DMASIZE_4B: 4Bytes
82162306a36Sopenharmony_ci * @AR5K_DMASIZE_8B: 8Bytes
82262306a36Sopenharmony_ci * @AR5K_DMASIZE_16B: 16Bytes
82362306a36Sopenharmony_ci * @AR5K_DMASIZE_32B: 32Bytes
82462306a36Sopenharmony_ci * @AR5K_DMASIZE_64B: 64Bytes (Default)
82562306a36Sopenharmony_ci * @AR5K_DMASIZE_128B: 128Bytes
82662306a36Sopenharmony_ci * @AR5K_DMASIZE_256B: 256Bytes
82762306a36Sopenharmony_ci * @AR5K_DMASIZE_512B: 512Bytes
82862306a36Sopenharmony_ci *
82962306a36Sopenharmony_ci * These are used to set DMA burst size on hw
83062306a36Sopenharmony_ci *
83162306a36Sopenharmony_ci * Note: Some platforms can't handle more than 4Bytes
83262306a36Sopenharmony_ci * be careful on embedded boards.
83362306a36Sopenharmony_ci */
83462306a36Sopenharmony_cienum ath5k_dmasize {
83562306a36Sopenharmony_ci	AR5K_DMASIZE_4B	= 0,
83662306a36Sopenharmony_ci	AR5K_DMASIZE_8B,
83762306a36Sopenharmony_ci	AR5K_DMASIZE_16B,
83862306a36Sopenharmony_ci	AR5K_DMASIZE_32B,
83962306a36Sopenharmony_ci	AR5K_DMASIZE_64B,
84062306a36Sopenharmony_ci	AR5K_DMASIZE_128B,
84162306a36Sopenharmony_ci	AR5K_DMASIZE_256B,
84262306a36Sopenharmony_ci	AR5K_DMASIZE_512B
84362306a36Sopenharmony_ci};
84462306a36Sopenharmony_ci
84562306a36Sopenharmony_ci
84662306a36Sopenharmony_ci
84762306a36Sopenharmony_ci/******************\
84862306a36Sopenharmony_ci  RATE DEFINITIONS
84962306a36Sopenharmony_ci\******************/
85062306a36Sopenharmony_ci
85162306a36Sopenharmony_ci/**
85262306a36Sopenharmony_ci * DOC: Rate codes
85362306a36Sopenharmony_ci *
85462306a36Sopenharmony_ci * Seems the ar5xxx hardware supports up to 32 rates, indexed by 1-32.
85562306a36Sopenharmony_ci *
85662306a36Sopenharmony_ci * The rate code is used to get the RX rate or set the TX rate on the
85762306a36Sopenharmony_ci * hardware descriptors. It is also used for internal modulation control
85862306a36Sopenharmony_ci * and settings.
85962306a36Sopenharmony_ci *
86062306a36Sopenharmony_ci * This is the hardware rate map we are aware of (html unfriendly):
86162306a36Sopenharmony_ci *
86262306a36Sopenharmony_ci * Rate code	Rate (Kbps)
86362306a36Sopenharmony_ci * ---------	-----------
86462306a36Sopenharmony_ci * 0x01		 3000 (XR)
86562306a36Sopenharmony_ci * 0x02		 1000 (XR)
86662306a36Sopenharmony_ci * 0x03		  250 (XR)
86762306a36Sopenharmony_ci * 0x04 - 05	-Reserved-
86862306a36Sopenharmony_ci * 0x06		 2000 (XR)
86962306a36Sopenharmony_ci * 0x07		  500 (XR)
87062306a36Sopenharmony_ci * 0x08		48000 (OFDM)
87162306a36Sopenharmony_ci * 0x09		24000 (OFDM)
87262306a36Sopenharmony_ci * 0x0A		12000 (OFDM)
87362306a36Sopenharmony_ci * 0x0B		 6000 (OFDM)
87462306a36Sopenharmony_ci * 0x0C		54000 (OFDM)
87562306a36Sopenharmony_ci * 0x0D		36000 (OFDM)
87662306a36Sopenharmony_ci * 0x0E		18000 (OFDM)
87762306a36Sopenharmony_ci * 0x0F		 9000 (OFDM)
87862306a36Sopenharmony_ci * 0x10 - 17	-Reserved-
87962306a36Sopenharmony_ci * 0x18		11000L (CCK)
88062306a36Sopenharmony_ci * 0x19		 5500L (CCK)
88162306a36Sopenharmony_ci * 0x1A		 2000L (CCK)
88262306a36Sopenharmony_ci * 0x1B		 1000L (CCK)
88362306a36Sopenharmony_ci * 0x1C		11000S (CCK)
88462306a36Sopenharmony_ci * 0x1D		 5500S (CCK)
88562306a36Sopenharmony_ci * 0x1E		 2000S (CCK)
88662306a36Sopenharmony_ci * 0x1F		-Reserved-
88762306a36Sopenharmony_ci *
88862306a36Sopenharmony_ci * "S" indicates CCK rates with short preamble and "L" with long preamble.
88962306a36Sopenharmony_ci *
89062306a36Sopenharmony_ci * AR5211 has different rate codes for CCK (802.11B) rates. It only uses the
89162306a36Sopenharmony_ci * lowest 4 bits, so they are the same as above with a 0xF mask.
89262306a36Sopenharmony_ci * (0xB, 0xA, 0x9 and 0x8 for 1M, 2M, 5.5M and 11M).
89362306a36Sopenharmony_ci * We handle this in ath5k_setup_bands().
89462306a36Sopenharmony_ci */
89562306a36Sopenharmony_ci#define AR5K_MAX_RATES 32
89662306a36Sopenharmony_ci
89762306a36Sopenharmony_ci/* B */
89862306a36Sopenharmony_ci#define ATH5K_RATE_CODE_1M	0x1B
89962306a36Sopenharmony_ci#define ATH5K_RATE_CODE_2M	0x1A
90062306a36Sopenharmony_ci#define ATH5K_RATE_CODE_5_5M	0x19
90162306a36Sopenharmony_ci#define ATH5K_RATE_CODE_11M	0x18
90262306a36Sopenharmony_ci/* A and G */
90362306a36Sopenharmony_ci#define ATH5K_RATE_CODE_6M	0x0B
90462306a36Sopenharmony_ci#define ATH5K_RATE_CODE_9M	0x0F
90562306a36Sopenharmony_ci#define ATH5K_RATE_CODE_12M	0x0A
90662306a36Sopenharmony_ci#define ATH5K_RATE_CODE_18M	0x0E
90762306a36Sopenharmony_ci#define ATH5K_RATE_CODE_24M	0x09
90862306a36Sopenharmony_ci#define ATH5K_RATE_CODE_36M	0x0D
90962306a36Sopenharmony_ci#define ATH5K_RATE_CODE_48M	0x08
91062306a36Sopenharmony_ci#define ATH5K_RATE_CODE_54M	0x0C
91162306a36Sopenharmony_ci
91262306a36Sopenharmony_ci/* Adding this flag to rate_code on B rates
91362306a36Sopenharmony_ci * enables short preamble */
91462306a36Sopenharmony_ci#define AR5K_SET_SHORT_PREAMBLE 0x04
91562306a36Sopenharmony_ci
91662306a36Sopenharmony_ci/*
91762306a36Sopenharmony_ci * Crypto definitions
91862306a36Sopenharmony_ci */
91962306a36Sopenharmony_ci
92062306a36Sopenharmony_ci#define AR5K_KEYCACHE_SIZE	8
92162306a36Sopenharmony_ciextern bool ath5k_modparam_nohwcrypt;
92262306a36Sopenharmony_ci
92362306a36Sopenharmony_ci/***********************\
92462306a36Sopenharmony_ci HW RELATED DEFINITIONS
92562306a36Sopenharmony_ci\***********************/
92662306a36Sopenharmony_ci
92762306a36Sopenharmony_ci/*
92862306a36Sopenharmony_ci * Misc definitions
92962306a36Sopenharmony_ci */
93062306a36Sopenharmony_ci#define	AR5K_RSSI_EP_MULTIPLIER	(1 << 7)
93162306a36Sopenharmony_ci
93262306a36Sopenharmony_ci#define AR5K_ASSERT_ENTRY(_e, _s) do {		\
93362306a36Sopenharmony_ci	if (_e >= _s)				\
93462306a36Sopenharmony_ci		return false;			\
93562306a36Sopenharmony_ci} while (0)
93662306a36Sopenharmony_ci
93762306a36Sopenharmony_ci/*
93862306a36Sopenharmony_ci * Hardware interrupt abstraction
93962306a36Sopenharmony_ci */
94062306a36Sopenharmony_ci
94162306a36Sopenharmony_ci/**
94262306a36Sopenharmony_ci * enum ath5k_int - Hardware interrupt masks helpers
94362306a36Sopenharmony_ci * @AR5K_INT_RXOK: Frame successfully received
94462306a36Sopenharmony_ci * @AR5K_INT_RXDESC: Request RX descriptor/Read RX descriptor
94562306a36Sopenharmony_ci * @AR5K_INT_RXERR: Frame reception failed
94662306a36Sopenharmony_ci * @AR5K_INT_RXNOFRM: No frame received within a specified time period
94762306a36Sopenharmony_ci * @AR5K_INT_RXEOL: Reached "End Of List", means we need more RX descriptors
94862306a36Sopenharmony_ci * @AR5K_INT_RXORN: Indicates we got RX FIFO overrun. Note that Rx overrun is
94962306a36Sopenharmony_ci *		not always fatal, on some chips we can continue operation
95062306a36Sopenharmony_ci *		without resetting the card, that's why %AR5K_INT_FATAL is not
95162306a36Sopenharmony_ci *		common for all chips.
95262306a36Sopenharmony_ci * @AR5K_INT_RX_ALL: Mask to identify all RX related interrupts
95362306a36Sopenharmony_ci *
95462306a36Sopenharmony_ci * @AR5K_INT_TXOK: Frame transmission success
95562306a36Sopenharmony_ci * @AR5K_INT_TXDESC: Request TX descriptor/Read TX status descriptor
95662306a36Sopenharmony_ci * @AR5K_INT_TXERR: Frame transmission failure
95762306a36Sopenharmony_ci * @AR5K_INT_TXEOL: Received End Of List for VEOL (Virtual End Of List). The
95862306a36Sopenharmony_ci *		Queue Control Unit (QCU) signals an EOL interrupt only if a
95962306a36Sopenharmony_ci *		descriptor's LinkPtr is NULL. For more details, refer to:
96062306a36Sopenharmony_ci *		"http://www.freepatentsonline.com/20030225739.html"
96162306a36Sopenharmony_ci * @AR5K_INT_TXNOFRM: No frame was transmitted within a specified time period
96262306a36Sopenharmony_ci * @AR5K_INT_TXURN: Indicates we got TX FIFO underrun. In such case we should
96362306a36Sopenharmony_ci *		increase the TX trigger threshold.
96462306a36Sopenharmony_ci * @AR5K_INT_TX_ALL: Mask to identify all TX related interrupts
96562306a36Sopenharmony_ci *
96662306a36Sopenharmony_ci * @AR5K_INT_MIB: Indicates the either Management Information Base counters or
96762306a36Sopenharmony_ci *		one of the PHY error counters reached the maximum value and
96862306a36Sopenharmony_ci *		should be read and cleared.
96962306a36Sopenharmony_ci * @AR5K_INT_SWI: Software triggered interrupt.
97062306a36Sopenharmony_ci * @AR5K_INT_RXPHY: RX PHY Error
97162306a36Sopenharmony_ci * @AR5K_INT_RXKCM: RX Key cache miss
97262306a36Sopenharmony_ci * @AR5K_INT_SWBA: SoftWare Beacon Alert - indicates its time to send a
97362306a36Sopenharmony_ci *		beacon that must be handled in software. The alternative is if
97462306a36Sopenharmony_ci *		you have VEOL support, in that case you let the hardware deal
97562306a36Sopenharmony_ci *		with things.
97662306a36Sopenharmony_ci * @AR5K_INT_BRSSI: Beacon received with an RSSI value below our threshold
97762306a36Sopenharmony_ci * @AR5K_INT_BMISS: If in STA mode this indicates we have stopped seeing
97862306a36Sopenharmony_ci *		beacons from the AP have associated with, we should probably
97962306a36Sopenharmony_ci *		try to reassociate. When in IBSS mode this might mean we have
98062306a36Sopenharmony_ci *		not received any beacons from any local stations. Note that
98162306a36Sopenharmony_ci *		every station in an IBSS schedules to send beacons at the
98262306a36Sopenharmony_ci *		Target Beacon Transmission Time (TBTT) with a random backoff.
98362306a36Sopenharmony_ci * @AR5K_INT_BNR: Beacon queue got triggered (DMA beacon alert) while empty.
98462306a36Sopenharmony_ci * @AR5K_INT_TIM: Beacon with local station's TIM bit set
98562306a36Sopenharmony_ci * @AR5K_INT_DTIM: Beacon with DTIM bit and zero DTIM count received
98662306a36Sopenharmony_ci * @AR5K_INT_DTIM_SYNC: DTIM sync lost
98762306a36Sopenharmony_ci * @AR5K_INT_GPIO: GPIO interrupt is used for RF Kill switches connected to
98862306a36Sopenharmony_ci *		our GPIO pins.
98962306a36Sopenharmony_ci * @AR5K_INT_BCN_TIMEOUT: Beacon timeout, we waited after TBTT but got noting
99062306a36Sopenharmony_ci * @AR5K_INT_CAB_TIMEOUT: We waited for CAB traffic after the beacon but got
99162306a36Sopenharmony_ci *		nothing or an incomplete CAB frame sequence.
99262306a36Sopenharmony_ci * @AR5K_INT_QCBRORN: A queue got it's CBR counter expired
99362306a36Sopenharmony_ci * @AR5K_INT_QCBRURN: A queue got triggered wile empty
99462306a36Sopenharmony_ci * @AR5K_INT_QTRIG: A queue got triggered
99562306a36Sopenharmony_ci *
99662306a36Sopenharmony_ci * @AR5K_INT_FATAL: Fatal errors were encountered, typically caused by bus/DMA
99762306a36Sopenharmony_ci *		errors. Indicates we need to reset the card.
99862306a36Sopenharmony_ci * @AR5K_INT_GLOBAL: Used to clear and set the IER
99962306a36Sopenharmony_ci * @AR5K_INT_NOCARD: Signals the card has been removed
100062306a36Sopenharmony_ci * @AR5K_INT_COMMON: Common interrupts shared among MACs with the same
100162306a36Sopenharmony_ci *		bit value
100262306a36Sopenharmony_ci *
100362306a36Sopenharmony_ci * These are mapped to take advantage of some common bits
100462306a36Sopenharmony_ci * between the MACs, to be able to set intr properties
100562306a36Sopenharmony_ci * easier. Some of them are not used yet inside hw.c. Most map
100662306a36Sopenharmony_ci * to the respective hw interrupt value as they are common among different
100762306a36Sopenharmony_ci * MACs.
100862306a36Sopenharmony_ci */
100962306a36Sopenharmony_cienum ath5k_int {
101062306a36Sopenharmony_ci	AR5K_INT_RXOK	= 0x00000001,
101162306a36Sopenharmony_ci	AR5K_INT_RXDESC	= 0x00000002,
101262306a36Sopenharmony_ci	AR5K_INT_RXERR	= 0x00000004,
101362306a36Sopenharmony_ci	AR5K_INT_RXNOFRM = 0x00000008,
101462306a36Sopenharmony_ci	AR5K_INT_RXEOL	= 0x00000010,
101562306a36Sopenharmony_ci	AR5K_INT_RXORN	= 0x00000020,
101662306a36Sopenharmony_ci	AR5K_INT_TXOK	= 0x00000040,
101762306a36Sopenharmony_ci	AR5K_INT_TXDESC	= 0x00000080,
101862306a36Sopenharmony_ci	AR5K_INT_TXERR	= 0x00000100,
101962306a36Sopenharmony_ci	AR5K_INT_TXNOFRM = 0x00000200,
102062306a36Sopenharmony_ci	AR5K_INT_TXEOL	= 0x00000400,
102162306a36Sopenharmony_ci	AR5K_INT_TXURN	= 0x00000800,
102262306a36Sopenharmony_ci	AR5K_INT_MIB	= 0x00001000,
102362306a36Sopenharmony_ci	AR5K_INT_SWI	= 0x00002000,
102462306a36Sopenharmony_ci	AR5K_INT_RXPHY	= 0x00004000,
102562306a36Sopenharmony_ci	AR5K_INT_RXKCM	= 0x00008000,
102662306a36Sopenharmony_ci	AR5K_INT_SWBA	= 0x00010000,
102762306a36Sopenharmony_ci	AR5K_INT_BRSSI	= 0x00020000,
102862306a36Sopenharmony_ci	AR5K_INT_BMISS	= 0x00040000,
102962306a36Sopenharmony_ci	AR5K_INT_FATAL	= 0x00080000, /* Non common */
103062306a36Sopenharmony_ci	AR5K_INT_BNR	= 0x00100000, /* Non common */
103162306a36Sopenharmony_ci	AR5K_INT_TIM	= 0x00200000, /* Non common */
103262306a36Sopenharmony_ci	AR5K_INT_DTIM	= 0x00400000, /* Non common */
103362306a36Sopenharmony_ci	AR5K_INT_DTIM_SYNC =	0x00800000, /* Non common */
103462306a36Sopenharmony_ci	AR5K_INT_GPIO	=	0x01000000,
103562306a36Sopenharmony_ci	AR5K_INT_BCN_TIMEOUT =	0x02000000, /* Non common */
103662306a36Sopenharmony_ci	AR5K_INT_CAB_TIMEOUT =	0x04000000, /* Non common */
103762306a36Sopenharmony_ci	AR5K_INT_QCBRORN =	0x08000000, /* Non common */
103862306a36Sopenharmony_ci	AR5K_INT_QCBRURN =	0x10000000, /* Non common */
103962306a36Sopenharmony_ci	AR5K_INT_QTRIG	=	0x20000000, /* Non common */
104062306a36Sopenharmony_ci	AR5K_INT_GLOBAL =	0x80000000,
104162306a36Sopenharmony_ci
104262306a36Sopenharmony_ci	AR5K_INT_TX_ALL = AR5K_INT_TXOK
104362306a36Sopenharmony_ci		| AR5K_INT_TXDESC
104462306a36Sopenharmony_ci		| AR5K_INT_TXERR
104562306a36Sopenharmony_ci		| AR5K_INT_TXNOFRM
104662306a36Sopenharmony_ci		| AR5K_INT_TXEOL
104762306a36Sopenharmony_ci		| AR5K_INT_TXURN,
104862306a36Sopenharmony_ci
104962306a36Sopenharmony_ci	AR5K_INT_RX_ALL = AR5K_INT_RXOK
105062306a36Sopenharmony_ci		| AR5K_INT_RXDESC
105162306a36Sopenharmony_ci		| AR5K_INT_RXERR
105262306a36Sopenharmony_ci		| AR5K_INT_RXNOFRM
105362306a36Sopenharmony_ci		| AR5K_INT_RXEOL
105462306a36Sopenharmony_ci		| AR5K_INT_RXORN,
105562306a36Sopenharmony_ci
105662306a36Sopenharmony_ci	AR5K_INT_COMMON  = AR5K_INT_RXOK
105762306a36Sopenharmony_ci		| AR5K_INT_RXDESC
105862306a36Sopenharmony_ci		| AR5K_INT_RXERR
105962306a36Sopenharmony_ci		| AR5K_INT_RXNOFRM
106062306a36Sopenharmony_ci		| AR5K_INT_RXEOL
106162306a36Sopenharmony_ci		| AR5K_INT_RXORN
106262306a36Sopenharmony_ci		| AR5K_INT_TXOK
106362306a36Sopenharmony_ci		| AR5K_INT_TXDESC
106462306a36Sopenharmony_ci		| AR5K_INT_TXERR
106562306a36Sopenharmony_ci		| AR5K_INT_TXNOFRM
106662306a36Sopenharmony_ci		| AR5K_INT_TXEOL
106762306a36Sopenharmony_ci		| AR5K_INT_TXURN
106862306a36Sopenharmony_ci		| AR5K_INT_MIB
106962306a36Sopenharmony_ci		| AR5K_INT_SWI
107062306a36Sopenharmony_ci		| AR5K_INT_RXPHY
107162306a36Sopenharmony_ci		| AR5K_INT_RXKCM
107262306a36Sopenharmony_ci		| AR5K_INT_SWBA
107362306a36Sopenharmony_ci		| AR5K_INT_BRSSI
107462306a36Sopenharmony_ci		| AR5K_INT_BMISS
107562306a36Sopenharmony_ci		| AR5K_INT_GPIO
107662306a36Sopenharmony_ci		| AR5K_INT_GLOBAL,
107762306a36Sopenharmony_ci
107862306a36Sopenharmony_ci	AR5K_INT_NOCARD	= 0xffffffff
107962306a36Sopenharmony_ci};
108062306a36Sopenharmony_ci
108162306a36Sopenharmony_ci/**
108262306a36Sopenharmony_ci * enum ath5k_calibration_mask - Mask which calibration is active at the moment
108362306a36Sopenharmony_ci * @AR5K_CALIBRATION_FULL: Full calibration (AGC + SHORT)
108462306a36Sopenharmony_ci * @AR5K_CALIBRATION_SHORT: Short calibration (NF + I/Q)
108562306a36Sopenharmony_ci * @AR5K_CALIBRATION_NF: Noise Floor calibration
108662306a36Sopenharmony_ci * @AR5K_CALIBRATION_ANI: Adaptive Noise Immunity
108762306a36Sopenharmony_ci */
108862306a36Sopenharmony_cienum ath5k_calibration_mask {
108962306a36Sopenharmony_ci	AR5K_CALIBRATION_FULL = 0x01,
109062306a36Sopenharmony_ci	AR5K_CALIBRATION_SHORT = 0x02,
109162306a36Sopenharmony_ci	AR5K_CALIBRATION_NF = 0x04,
109262306a36Sopenharmony_ci	AR5K_CALIBRATION_ANI = 0x08,
109362306a36Sopenharmony_ci};
109462306a36Sopenharmony_ci
109562306a36Sopenharmony_ci/**
109662306a36Sopenharmony_ci * enum ath5k_power_mode - Power management modes
109762306a36Sopenharmony_ci * @AR5K_PM_UNDEFINED: Undefined
109862306a36Sopenharmony_ci * @AR5K_PM_AUTO: Allow card to sleep if possible
109962306a36Sopenharmony_ci * @AR5K_PM_AWAKE: Force card to wake up
110062306a36Sopenharmony_ci * @AR5K_PM_FULL_SLEEP: Force card to full sleep (DANGEROUS)
110162306a36Sopenharmony_ci * @AR5K_PM_NETWORK_SLEEP: Allow to sleep for a specified duration
110262306a36Sopenharmony_ci *
110362306a36Sopenharmony_ci * Currently only PM_AWAKE is used, FULL_SLEEP and NETWORK_SLEEP/AUTO
110462306a36Sopenharmony_ci * are also known to have problems on some cards. This is not a big
110562306a36Sopenharmony_ci * problem though because we can have almost the same effect as
110662306a36Sopenharmony_ci * FULL_SLEEP by putting card on warm reset (it's almost powered down).
110762306a36Sopenharmony_ci */
110862306a36Sopenharmony_cienum ath5k_power_mode {
110962306a36Sopenharmony_ci	AR5K_PM_UNDEFINED = 0,
111062306a36Sopenharmony_ci	AR5K_PM_AUTO,
111162306a36Sopenharmony_ci	AR5K_PM_AWAKE,
111262306a36Sopenharmony_ci	AR5K_PM_FULL_SLEEP,
111362306a36Sopenharmony_ci	AR5K_PM_NETWORK_SLEEP,
111462306a36Sopenharmony_ci};
111562306a36Sopenharmony_ci
111662306a36Sopenharmony_ci/*
111762306a36Sopenharmony_ci * These match net80211 definitions (not used in
111862306a36Sopenharmony_ci * mac80211).
111962306a36Sopenharmony_ci * TODO: Clean this up
112062306a36Sopenharmony_ci */
112162306a36Sopenharmony_ci#define AR5K_LED_INIT	0 /*IEEE80211_S_INIT*/
112262306a36Sopenharmony_ci#define AR5K_LED_SCAN	1 /*IEEE80211_S_SCAN*/
112362306a36Sopenharmony_ci#define AR5K_LED_AUTH	2 /*IEEE80211_S_AUTH*/
112462306a36Sopenharmony_ci#define AR5K_LED_ASSOC	3 /*IEEE80211_S_ASSOC*/
112562306a36Sopenharmony_ci#define AR5K_LED_RUN	4 /*IEEE80211_S_RUN*/
112662306a36Sopenharmony_ci
112762306a36Sopenharmony_ci/* GPIO-controlled software LED */
112862306a36Sopenharmony_ci#define AR5K_SOFTLED_PIN	0
112962306a36Sopenharmony_ci#define AR5K_SOFTLED_ON		0
113062306a36Sopenharmony_ci#define AR5K_SOFTLED_OFF	1
113162306a36Sopenharmony_ci
113262306a36Sopenharmony_ci
113362306a36Sopenharmony_ci/* XXX: we *may* move cap_range stuff to struct wiphy */
113462306a36Sopenharmony_cistruct ath5k_capabilities {
113562306a36Sopenharmony_ci	/*
113662306a36Sopenharmony_ci	 * Supported PHY modes
113762306a36Sopenharmony_ci	 * (ie. AR5K_MODE_11A, AR5K_MODE_11B, ...)
113862306a36Sopenharmony_ci	 */
113962306a36Sopenharmony_ci	DECLARE_BITMAP(cap_mode, AR5K_MODE_MAX);
114062306a36Sopenharmony_ci
114162306a36Sopenharmony_ci	/*
114262306a36Sopenharmony_ci	 * Frequency range (without regulation restrictions)
114362306a36Sopenharmony_ci	 */
114462306a36Sopenharmony_ci	struct {
114562306a36Sopenharmony_ci		u16	range_2ghz_min;
114662306a36Sopenharmony_ci		u16	range_2ghz_max;
114762306a36Sopenharmony_ci		u16	range_5ghz_min;
114862306a36Sopenharmony_ci		u16	range_5ghz_max;
114962306a36Sopenharmony_ci	} cap_range;
115062306a36Sopenharmony_ci
115162306a36Sopenharmony_ci	/*
115262306a36Sopenharmony_ci	 * Values stored in the EEPROM (some of them...)
115362306a36Sopenharmony_ci	 */
115462306a36Sopenharmony_ci	struct ath5k_eeprom_info	cap_eeprom;
115562306a36Sopenharmony_ci
115662306a36Sopenharmony_ci	/*
115762306a36Sopenharmony_ci	 * Queue information
115862306a36Sopenharmony_ci	 */
115962306a36Sopenharmony_ci	struct {
116062306a36Sopenharmony_ci		u8	q_tx_num;
116162306a36Sopenharmony_ci	} cap_queues;
116262306a36Sopenharmony_ci
116362306a36Sopenharmony_ci	bool cap_has_phyerr_counters;
116462306a36Sopenharmony_ci	bool cap_has_mrr_support;
116562306a36Sopenharmony_ci	bool cap_needs_2GHz_ovr;
116662306a36Sopenharmony_ci};
116762306a36Sopenharmony_ci
116862306a36Sopenharmony_ci/* size of noise floor history (keep it a power of two) */
116962306a36Sopenharmony_ci#define ATH5K_NF_CAL_HIST_MAX	8
117062306a36Sopenharmony_cistruct ath5k_nfcal_hist {
117162306a36Sopenharmony_ci	s16 index;				/* current index into nfval */
117262306a36Sopenharmony_ci	s16 nfval[ATH5K_NF_CAL_HIST_MAX];	/* last few noise floors */
117362306a36Sopenharmony_ci};
117462306a36Sopenharmony_ci
117562306a36Sopenharmony_ci#define ATH5K_LED_MAX_NAME_LEN 31
117662306a36Sopenharmony_ci
117762306a36Sopenharmony_ci/*
117862306a36Sopenharmony_ci * State for LED triggers
117962306a36Sopenharmony_ci */
118062306a36Sopenharmony_cistruct ath5k_led {
118162306a36Sopenharmony_ci	char name[ATH5K_LED_MAX_NAME_LEN + 1];	/* name of the LED in sysfs */
118262306a36Sopenharmony_ci	struct ath5k_hw *ah;			/* driver state */
118362306a36Sopenharmony_ci	struct led_classdev led_dev;		/* led classdev */
118462306a36Sopenharmony_ci};
118562306a36Sopenharmony_ci
118662306a36Sopenharmony_ci/* Rfkill */
118762306a36Sopenharmony_cistruct ath5k_rfkill {
118862306a36Sopenharmony_ci	/* GPIO PIN for rfkill */
118962306a36Sopenharmony_ci	u16 gpio;
119062306a36Sopenharmony_ci	/* polarity of rfkill GPIO PIN */
119162306a36Sopenharmony_ci	bool polarity;
119262306a36Sopenharmony_ci	/* RFKILL toggle tasklet */
119362306a36Sopenharmony_ci	struct tasklet_struct toggleq;
119462306a36Sopenharmony_ci};
119562306a36Sopenharmony_ci
119662306a36Sopenharmony_ci/* statistics */
119762306a36Sopenharmony_cistruct ath5k_statistics {
119862306a36Sopenharmony_ci	/* antenna use */
119962306a36Sopenharmony_ci	unsigned int antenna_rx[5];	/* frames count per antenna RX */
120062306a36Sopenharmony_ci	unsigned int antenna_tx[5];	/* frames count per antenna TX */
120162306a36Sopenharmony_ci
120262306a36Sopenharmony_ci	/* frame errors */
120362306a36Sopenharmony_ci	unsigned int rx_all_count;	/* all RX frames, including errors */
120462306a36Sopenharmony_ci	unsigned int tx_all_count;	/* all TX frames, including errors */
120562306a36Sopenharmony_ci	unsigned int rx_bytes_count;	/* all RX bytes, including errored pkts
120662306a36Sopenharmony_ci					 * and the MAC headers for each packet
120762306a36Sopenharmony_ci					 */
120862306a36Sopenharmony_ci	unsigned int tx_bytes_count;	/* all TX bytes, including errored pkts
120962306a36Sopenharmony_ci					 * and the MAC headers and padding for
121062306a36Sopenharmony_ci					 * each packet.
121162306a36Sopenharmony_ci					 */
121262306a36Sopenharmony_ci	unsigned int rxerr_crc;
121362306a36Sopenharmony_ci	unsigned int rxerr_phy;
121462306a36Sopenharmony_ci	unsigned int rxerr_phy_code[32];
121562306a36Sopenharmony_ci	unsigned int rxerr_fifo;
121662306a36Sopenharmony_ci	unsigned int rxerr_decrypt;
121762306a36Sopenharmony_ci	unsigned int rxerr_mic;
121862306a36Sopenharmony_ci	unsigned int rxerr_proc;
121962306a36Sopenharmony_ci	unsigned int rxerr_jumbo;
122062306a36Sopenharmony_ci	unsigned int txerr_retry;
122162306a36Sopenharmony_ci	unsigned int txerr_fifo;
122262306a36Sopenharmony_ci	unsigned int txerr_filt;
122362306a36Sopenharmony_ci
122462306a36Sopenharmony_ci	/* MIB counters */
122562306a36Sopenharmony_ci	unsigned int ack_fail;
122662306a36Sopenharmony_ci	unsigned int rts_fail;
122762306a36Sopenharmony_ci	unsigned int rts_ok;
122862306a36Sopenharmony_ci	unsigned int fcs_error;
122962306a36Sopenharmony_ci	unsigned int beacons;
123062306a36Sopenharmony_ci
123162306a36Sopenharmony_ci	unsigned int mib_intr;
123262306a36Sopenharmony_ci	unsigned int rxorn_intr;
123362306a36Sopenharmony_ci	unsigned int rxeol_intr;
123462306a36Sopenharmony_ci};
123562306a36Sopenharmony_ci
123662306a36Sopenharmony_ci/*
123762306a36Sopenharmony_ci * Misc defines
123862306a36Sopenharmony_ci */
123962306a36Sopenharmony_ci
124062306a36Sopenharmony_ci#define AR5K_MAX_GPIO		10
124162306a36Sopenharmony_ci#define AR5K_MAX_RF_BANKS	8
124262306a36Sopenharmony_ci
124362306a36Sopenharmony_ci#if CHAN_DEBUG
124462306a36Sopenharmony_ci#define ATH_CHAN_MAX	(26 + 26 + 26 + 200 + 200)
124562306a36Sopenharmony_ci#else
124662306a36Sopenharmony_ci#define ATH_CHAN_MAX	(14 + 14 + 14 + 252 + 20)
124762306a36Sopenharmony_ci#endif
124862306a36Sopenharmony_ci
124962306a36Sopenharmony_ci#define	ATH_RXBUF	40		/* number of RX buffers */
125062306a36Sopenharmony_ci#define	ATH_TXBUF	200		/* number of TX buffers */
125162306a36Sopenharmony_ci#define ATH_BCBUF	4		/* number of beacon buffers */
125262306a36Sopenharmony_ci#define ATH5K_TXQ_LEN_MAX	(ATH_TXBUF / 4)		/* bufs per queue */
125362306a36Sopenharmony_ci#define ATH5K_TXQ_LEN_LOW	(ATH5K_TXQ_LEN_MAX / 2)	/* low mark */
125462306a36Sopenharmony_ci
125562306a36Sopenharmony_ciDECLARE_EWMA(beacon_rssi, 10, 8)
125662306a36Sopenharmony_ci
125762306a36Sopenharmony_ci/* Driver state associated with an instance of a device */
125862306a36Sopenharmony_cistruct ath5k_hw {
125962306a36Sopenharmony_ci	struct ath_common       common;
126062306a36Sopenharmony_ci
126162306a36Sopenharmony_ci	struct pci_dev		*pdev;
126262306a36Sopenharmony_ci	struct device		*dev;		/* for dma mapping */
126362306a36Sopenharmony_ci	int irq;
126462306a36Sopenharmony_ci	u16 devid;
126562306a36Sopenharmony_ci	void __iomem		*iobase;	/* address of the device */
126662306a36Sopenharmony_ci	struct mutex		lock;		/* dev-level lock */
126762306a36Sopenharmony_ci	struct ieee80211_hw	*hw;		/* IEEE 802.11 common */
126862306a36Sopenharmony_ci	struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
126962306a36Sopenharmony_ci	struct ieee80211_channel channels[ATH_CHAN_MAX];
127062306a36Sopenharmony_ci	struct ieee80211_rate	rates[NUM_NL80211_BANDS][AR5K_MAX_RATES];
127162306a36Sopenharmony_ci	s8			rate_idx[NUM_NL80211_BANDS][AR5K_MAX_RATES];
127262306a36Sopenharmony_ci	enum nl80211_iftype	opmode;
127362306a36Sopenharmony_ci
127462306a36Sopenharmony_ci#ifdef CONFIG_ATH5K_DEBUG
127562306a36Sopenharmony_ci	struct ath5k_dbg_info	debug;		/* debug info */
127662306a36Sopenharmony_ci#endif /* CONFIG_ATH5K_DEBUG */
127762306a36Sopenharmony_ci
127862306a36Sopenharmony_ci	struct ath5k_buf	*bufptr;	/* allocated buffer ptr */
127962306a36Sopenharmony_ci	struct ath5k_desc	*desc;		/* TX/RX descriptors */
128062306a36Sopenharmony_ci	dma_addr_t		desc_daddr;	/* DMA (physical) address */
128162306a36Sopenharmony_ci	size_t			desc_len;	/* size of TX/RX descriptors */
128262306a36Sopenharmony_ci
128362306a36Sopenharmony_ci	DECLARE_BITMAP(status, 4);
128462306a36Sopenharmony_ci#define ATH_STAT_INVALID	0		/* disable hardware accesses */
128562306a36Sopenharmony_ci#define ATH_STAT_LEDSOFT	2		/* enable LED gpio status */
128662306a36Sopenharmony_ci#define ATH_STAT_STARTED	3		/* opened & irqs enabled */
128762306a36Sopenharmony_ci#define ATH_STAT_RESET		4		/* hw reset */
128862306a36Sopenharmony_ci
128962306a36Sopenharmony_ci	unsigned int		filter_flags;	/* HW flags, AR5K_RX_FILTER_* */
129062306a36Sopenharmony_ci	unsigned int		fif_filter_flags; /* Current FIF_* filter flags */
129162306a36Sopenharmony_ci	struct ieee80211_channel *curchan;	/* current h/w channel */
129262306a36Sopenharmony_ci
129362306a36Sopenharmony_ci	u16			nvifs;
129462306a36Sopenharmony_ci
129562306a36Sopenharmony_ci	enum ath5k_int		imask;		/* interrupt mask copy */
129662306a36Sopenharmony_ci
129762306a36Sopenharmony_ci	spinlock_t		irqlock;
129862306a36Sopenharmony_ci	bool			rx_pending;	/* rx tasklet pending */
129962306a36Sopenharmony_ci	bool			tx_pending;	/* tx tasklet pending */
130062306a36Sopenharmony_ci
130162306a36Sopenharmony_ci	u8			bssidmask[ETH_ALEN];
130262306a36Sopenharmony_ci
130362306a36Sopenharmony_ci	unsigned int		led_pin,	/* GPIO pin for driving LED */
130462306a36Sopenharmony_ci				led_on;		/* pin setting for LED on */
130562306a36Sopenharmony_ci
130662306a36Sopenharmony_ci	struct work_struct	reset_work;	/* deferred chip reset */
130762306a36Sopenharmony_ci	struct work_struct	calib_work;	/* deferred phy calibration */
130862306a36Sopenharmony_ci
130962306a36Sopenharmony_ci	struct list_head	rxbuf;		/* receive buffer */
131062306a36Sopenharmony_ci	spinlock_t		rxbuflock;
131162306a36Sopenharmony_ci	u32			*rxlink;	/* link ptr in last RX desc */
131262306a36Sopenharmony_ci	struct tasklet_struct	rxtq;		/* rx intr tasklet */
131362306a36Sopenharmony_ci	struct ath5k_led	rx_led;		/* rx led */
131462306a36Sopenharmony_ci
131562306a36Sopenharmony_ci	struct list_head	txbuf;		/* transmit buffer */
131662306a36Sopenharmony_ci	spinlock_t		txbuflock;
131762306a36Sopenharmony_ci	unsigned int		txbuf_len;	/* buf count in txbuf list */
131862306a36Sopenharmony_ci	struct ath5k_txq	txqs[AR5K_NUM_TX_QUEUES];	/* tx queues */
131962306a36Sopenharmony_ci	struct tasklet_struct	txtq;		/* tx intr tasklet */
132062306a36Sopenharmony_ci	struct ath5k_led	tx_led;		/* tx led */
132162306a36Sopenharmony_ci
132262306a36Sopenharmony_ci	struct ath5k_rfkill	rf_kill;
132362306a36Sopenharmony_ci
132462306a36Sopenharmony_ci	spinlock_t		block;		/* protects beacon */
132562306a36Sopenharmony_ci	struct tasklet_struct	beacontq;	/* beacon intr tasklet */
132662306a36Sopenharmony_ci	struct list_head	bcbuf;		/* beacon buffer */
132762306a36Sopenharmony_ci	struct ieee80211_vif	*bslot[ATH_BCBUF];
132862306a36Sopenharmony_ci	u16			num_ap_vifs;
132962306a36Sopenharmony_ci	u16			num_adhoc_vifs;
133062306a36Sopenharmony_ci	u16			num_mesh_vifs;
133162306a36Sopenharmony_ci	unsigned int		bhalq,		/* SW q for outgoing beacons */
133262306a36Sopenharmony_ci				bmisscount,	/* missed beacon transmits */
133362306a36Sopenharmony_ci				bintval,	/* beacon interval in TU */
133462306a36Sopenharmony_ci				bsent;
133562306a36Sopenharmony_ci	unsigned int		nexttbtt;	/* next beacon time in TU */
133662306a36Sopenharmony_ci	struct ath5k_txq	*cabq;		/* content after beacon */
133762306a36Sopenharmony_ci
133862306a36Sopenharmony_ci	bool			assoc;		/* associate state */
133962306a36Sopenharmony_ci	bool			enable_beacon;	/* true if beacons are on */
134062306a36Sopenharmony_ci
134162306a36Sopenharmony_ci	struct ath5k_statistics	stats;
134262306a36Sopenharmony_ci
134362306a36Sopenharmony_ci	struct ath5k_ani_state	ani_state;
134462306a36Sopenharmony_ci	struct tasklet_struct	ani_tasklet;	/* ANI calibration */
134562306a36Sopenharmony_ci
134662306a36Sopenharmony_ci	struct delayed_work	tx_complete_work;
134762306a36Sopenharmony_ci
134862306a36Sopenharmony_ci	struct survey_info	survey;		/* collected survey info */
134962306a36Sopenharmony_ci
135062306a36Sopenharmony_ci	enum ath5k_int		ah_imr;
135162306a36Sopenharmony_ci
135262306a36Sopenharmony_ci	struct ieee80211_channel *ah_current_channel;
135362306a36Sopenharmony_ci	bool			ah_iq_cal_needed;
135462306a36Sopenharmony_ci	bool			ah_single_chip;
135562306a36Sopenharmony_ci
135662306a36Sopenharmony_ci	enum ath5k_version	ah_version;
135762306a36Sopenharmony_ci	enum ath5k_radio	ah_radio;
135862306a36Sopenharmony_ci	u32			ah_mac_srev;
135962306a36Sopenharmony_ci	u16			ah_mac_version;
136062306a36Sopenharmony_ci	u16			ah_phy_revision;
136162306a36Sopenharmony_ci	u16			ah_radio_5ghz_revision;
136262306a36Sopenharmony_ci	u16			ah_radio_2ghz_revision;
136362306a36Sopenharmony_ci
136462306a36Sopenharmony_ci#define ah_modes		ah_capabilities.cap_mode
136562306a36Sopenharmony_ci#define ah_ee_version		ah_capabilities.cap_eeprom.ee_version
136662306a36Sopenharmony_ci
136762306a36Sopenharmony_ci	u8			ah_retry_long;
136862306a36Sopenharmony_ci	u8			ah_retry_short;
136962306a36Sopenharmony_ci
137062306a36Sopenharmony_ci	bool			ah_use_32khz_clock;
137162306a36Sopenharmony_ci
137262306a36Sopenharmony_ci	u8			ah_coverage_class;
137362306a36Sopenharmony_ci	bool			ah_ack_bitrate_high;
137462306a36Sopenharmony_ci	u8			ah_bwmode;
137562306a36Sopenharmony_ci	bool			ah_short_slot;
137662306a36Sopenharmony_ci
137762306a36Sopenharmony_ci	/* Antenna Control */
137862306a36Sopenharmony_ci	u32			ah_ant_ctl[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX];
137962306a36Sopenharmony_ci	u8			ah_ant_mode;
138062306a36Sopenharmony_ci	u8			ah_tx_ant;
138162306a36Sopenharmony_ci	u8			ah_def_ant;
138262306a36Sopenharmony_ci
138362306a36Sopenharmony_ci	struct ath5k_capabilities ah_capabilities;
138462306a36Sopenharmony_ci
138562306a36Sopenharmony_ci	struct ath5k_txq_info	ah_txq[AR5K_NUM_TX_QUEUES];
138662306a36Sopenharmony_ci	u32			ah_txq_status;
138762306a36Sopenharmony_ci	u32			ah_txq_imr_txok;
138862306a36Sopenharmony_ci	u32			ah_txq_imr_txerr;
138962306a36Sopenharmony_ci	u32			ah_txq_imr_txurn;
139062306a36Sopenharmony_ci	u32			ah_txq_imr_txdesc;
139162306a36Sopenharmony_ci	u32			ah_txq_imr_txeol;
139262306a36Sopenharmony_ci	u32			ah_txq_imr_cbrorn;
139362306a36Sopenharmony_ci	u32			ah_txq_imr_cbrurn;
139462306a36Sopenharmony_ci	u32			ah_txq_imr_qtrig;
139562306a36Sopenharmony_ci	u32			ah_txq_imr_nofrm;
139662306a36Sopenharmony_ci
139762306a36Sopenharmony_ci	u32			ah_txq_isr_txok_all;
139862306a36Sopenharmony_ci
139962306a36Sopenharmony_ci	u32			*ah_rf_banks;
140062306a36Sopenharmony_ci	size_t			ah_rf_banks_size;
140162306a36Sopenharmony_ci	size_t			ah_rf_regs_count;
140262306a36Sopenharmony_ci	struct ath5k_gain	ah_gain;
140362306a36Sopenharmony_ci	u8			ah_offset[AR5K_MAX_RF_BANKS];
140462306a36Sopenharmony_ci
140562306a36Sopenharmony_ci
140662306a36Sopenharmony_ci	struct {
140762306a36Sopenharmony_ci		/* Temporary tables used for interpolation */
140862306a36Sopenharmony_ci		u8		tmpL[AR5K_EEPROM_N_PD_GAINS]
140962306a36Sopenharmony_ci					[AR5K_EEPROM_POWER_TABLE_SIZE];
141062306a36Sopenharmony_ci		u8		tmpR[AR5K_EEPROM_N_PD_GAINS]
141162306a36Sopenharmony_ci					[AR5K_EEPROM_POWER_TABLE_SIZE];
141262306a36Sopenharmony_ci		u8		txp_pd_table[AR5K_EEPROM_POWER_TABLE_SIZE * 2];
141362306a36Sopenharmony_ci		u16		txp_rates_power_table[AR5K_MAX_RATES];
141462306a36Sopenharmony_ci		u8		txp_min_idx;
141562306a36Sopenharmony_ci		bool		txp_tpc;
141662306a36Sopenharmony_ci		/* Values in 0.25dB units */
141762306a36Sopenharmony_ci		s16		txp_min_pwr;
141862306a36Sopenharmony_ci		s16		txp_max_pwr;
141962306a36Sopenharmony_ci		s16		txp_cur_pwr;
142062306a36Sopenharmony_ci		/* Values in 0.5dB units */
142162306a36Sopenharmony_ci		s16		txp_offset;
142262306a36Sopenharmony_ci		s16		txp_ofdm;
142362306a36Sopenharmony_ci		s16		txp_cck_ofdm_gainf_delta;
142462306a36Sopenharmony_ci		/* Value in dB units */
142562306a36Sopenharmony_ci		s16		txp_cck_ofdm_pwr_delta;
142662306a36Sopenharmony_ci		bool		txp_setup;
142762306a36Sopenharmony_ci		int		txp_requested;	/* Requested tx power in dBm */
142862306a36Sopenharmony_ci	} ah_txpower;
142962306a36Sopenharmony_ci
143062306a36Sopenharmony_ci	struct ath5k_nfcal_hist ah_nfcal_hist;
143162306a36Sopenharmony_ci
143262306a36Sopenharmony_ci	/* average beacon RSSI in our BSS (used by ANI) */
143362306a36Sopenharmony_ci	struct ewma_beacon_rssi	ah_beacon_rssi_avg;
143462306a36Sopenharmony_ci
143562306a36Sopenharmony_ci	/* noise floor from last periodic calibration */
143662306a36Sopenharmony_ci	s32			ah_noise_floor;
143762306a36Sopenharmony_ci
143862306a36Sopenharmony_ci	/* Calibration timestamp */
143962306a36Sopenharmony_ci	unsigned long		ah_cal_next_full;
144062306a36Sopenharmony_ci	unsigned long		ah_cal_next_short;
144162306a36Sopenharmony_ci	unsigned long		ah_cal_next_ani;
144262306a36Sopenharmony_ci
144362306a36Sopenharmony_ci	/* Calibration mask */
144462306a36Sopenharmony_ci	u8			ah_cal_mask;
144562306a36Sopenharmony_ci
144662306a36Sopenharmony_ci	/*
144762306a36Sopenharmony_ci	 * Function pointers
144862306a36Sopenharmony_ci	 */
144962306a36Sopenharmony_ci	int (*ah_setup_tx_desc)(struct ath5k_hw *, struct ath5k_desc *,
145062306a36Sopenharmony_ci		unsigned int, unsigned int, int, enum ath5k_pkt_type,
145162306a36Sopenharmony_ci		unsigned int, unsigned int, unsigned int, unsigned int,
145262306a36Sopenharmony_ci		unsigned int, unsigned int, unsigned int, unsigned int);
145362306a36Sopenharmony_ci	int (*ah_proc_tx_desc)(struct ath5k_hw *, struct ath5k_desc *,
145462306a36Sopenharmony_ci		struct ath5k_tx_status *);
145562306a36Sopenharmony_ci	int (*ah_proc_rx_desc)(struct ath5k_hw *, struct ath5k_desc *,
145662306a36Sopenharmony_ci		struct ath5k_rx_status *);
145762306a36Sopenharmony_ci};
145862306a36Sopenharmony_ci
145962306a36Sopenharmony_cistruct ath_bus_ops {
146062306a36Sopenharmony_ci	enum ath_bus_type ath_bus_type;
146162306a36Sopenharmony_ci	void (*read_cachesize)(struct ath_common *common, int *csz);
146262306a36Sopenharmony_ci	bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
146362306a36Sopenharmony_ci	int (*eeprom_read_mac)(struct ath5k_hw *ah, u8 *mac);
146462306a36Sopenharmony_ci};
146562306a36Sopenharmony_ci
146662306a36Sopenharmony_ci/*
146762306a36Sopenharmony_ci * Prototypes
146862306a36Sopenharmony_ci */
146962306a36Sopenharmony_ciextern const struct ieee80211_ops ath5k_hw_ops;
147062306a36Sopenharmony_ci
147162306a36Sopenharmony_ci/* Initialization and detach functions */
147262306a36Sopenharmony_ciint ath5k_hw_init(struct ath5k_hw *ah);
147362306a36Sopenharmony_civoid ath5k_hw_deinit(struct ath5k_hw *ah);
147462306a36Sopenharmony_ci
147562306a36Sopenharmony_ciint ath5k_sysfs_register(struct ath5k_hw *ah);
147662306a36Sopenharmony_civoid ath5k_sysfs_unregister(struct ath5k_hw *ah);
147762306a36Sopenharmony_ci
147862306a36Sopenharmony_ci/*Chip id helper functions */
147962306a36Sopenharmony_ciint ath5k_hw_read_srev(struct ath5k_hw *ah);
148062306a36Sopenharmony_ci
148162306a36Sopenharmony_ci/* LED functions */
148262306a36Sopenharmony_ciint ath5k_init_leds(struct ath5k_hw *ah);
148362306a36Sopenharmony_civoid ath5k_led_enable(struct ath5k_hw *ah);
148462306a36Sopenharmony_civoid ath5k_led_off(struct ath5k_hw *ah);
148562306a36Sopenharmony_civoid ath5k_unregister_leds(struct ath5k_hw *ah);
148662306a36Sopenharmony_ci
148762306a36Sopenharmony_ci
148862306a36Sopenharmony_ci/* Reset Functions */
148962306a36Sopenharmony_ciint ath5k_hw_nic_wakeup(struct ath5k_hw *ah, struct ieee80211_channel *channel);
149062306a36Sopenharmony_ciint ath5k_hw_on_hold(struct ath5k_hw *ah);
149162306a36Sopenharmony_ciint ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
149262306a36Sopenharmony_ci	   struct ieee80211_channel *channel, bool fast, bool skip_pcu);
149362306a36Sopenharmony_ciint ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val,
149462306a36Sopenharmony_ci			      bool is_set);
149562306a36Sopenharmony_ci/* Power management functions */
149662306a36Sopenharmony_ci
149762306a36Sopenharmony_ci
149862306a36Sopenharmony_ci/* Clock rate related functions */
149962306a36Sopenharmony_ciunsigned int ath5k_hw_htoclock(struct ath5k_hw *ah, unsigned int usec);
150062306a36Sopenharmony_ciunsigned int ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock);
150162306a36Sopenharmony_civoid ath5k_hw_set_clockrate(struct ath5k_hw *ah);
150262306a36Sopenharmony_ci
150362306a36Sopenharmony_ci
150462306a36Sopenharmony_ci/* DMA Related Functions */
150562306a36Sopenharmony_civoid ath5k_hw_start_rx_dma(struct ath5k_hw *ah);
150662306a36Sopenharmony_ciu32 ath5k_hw_get_rxdp(struct ath5k_hw *ah);
150762306a36Sopenharmony_ciint ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr);
150862306a36Sopenharmony_ciint ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue);
150962306a36Sopenharmony_ciint ath5k_hw_stop_beacon_queue(struct ath5k_hw *ah, unsigned int queue);
151062306a36Sopenharmony_ciu32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue);
151162306a36Sopenharmony_ciint ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue,
151262306a36Sopenharmony_ci				u32 phys_addr);
151362306a36Sopenharmony_ciint ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase);
151462306a36Sopenharmony_ci/* Interrupt handling */
151562306a36Sopenharmony_cibool ath5k_hw_is_intr_pending(struct ath5k_hw *ah);
151662306a36Sopenharmony_ciint ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask);
151762306a36Sopenharmony_cienum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask);
151862306a36Sopenharmony_civoid ath5k_hw_update_mib_counters(struct ath5k_hw *ah);
151962306a36Sopenharmony_ci/* Init/Stop functions */
152062306a36Sopenharmony_civoid ath5k_hw_dma_init(struct ath5k_hw *ah);
152162306a36Sopenharmony_ciint ath5k_hw_dma_stop(struct ath5k_hw *ah);
152262306a36Sopenharmony_ci
152362306a36Sopenharmony_ci/* EEPROM access functions */
152462306a36Sopenharmony_ciint ath5k_eeprom_init(struct ath5k_hw *ah);
152562306a36Sopenharmony_civoid ath5k_eeprom_detach(struct ath5k_hw *ah);
152662306a36Sopenharmony_ciint ath5k_eeprom_mode_from_channel(struct ath5k_hw *ah,
152762306a36Sopenharmony_ci		struct ieee80211_channel *channel);
152862306a36Sopenharmony_ci
152962306a36Sopenharmony_ci/* Protocol Control Unit Functions */
153062306a36Sopenharmony_ci/* Helpers */
153162306a36Sopenharmony_ciint ath5k_hw_get_frame_duration(struct ath5k_hw *ah, enum nl80211_band band,
153262306a36Sopenharmony_ci		int len, struct ieee80211_rate *rate, bool shortpre);
153362306a36Sopenharmony_ciunsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah);
153462306a36Sopenharmony_ciunsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah);
153562306a36Sopenharmony_ciint ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype opmode);
153662306a36Sopenharmony_civoid ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class);
153762306a36Sopenharmony_ci/* RX filter control*/
153862306a36Sopenharmony_ciint ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac);
153962306a36Sopenharmony_civoid ath5k_hw_set_bssid(struct ath5k_hw *ah);
154062306a36Sopenharmony_civoid ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask);
154162306a36Sopenharmony_civoid ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1);
154262306a36Sopenharmony_ciu32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah);
154362306a36Sopenharmony_civoid ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter);
154462306a36Sopenharmony_ci/* Receive (DRU) start/stop functions */
154562306a36Sopenharmony_civoid ath5k_hw_start_rx_pcu(struct ath5k_hw *ah);
154662306a36Sopenharmony_civoid ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah);
154762306a36Sopenharmony_ci/* Beacon control functions */
154862306a36Sopenharmony_ciu64 ath5k_hw_get_tsf64(struct ath5k_hw *ah);
154962306a36Sopenharmony_civoid ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64);
155062306a36Sopenharmony_civoid ath5k_hw_reset_tsf(struct ath5k_hw *ah);
155162306a36Sopenharmony_civoid ath5k_hw_init_beacon_timers(struct ath5k_hw *ah, u32 next_beacon,
155262306a36Sopenharmony_ci							u32 interval);
155362306a36Sopenharmony_cibool ath5k_hw_check_beacon_timers(struct ath5k_hw *ah, int intval);
155462306a36Sopenharmony_ci/* Init function */
155562306a36Sopenharmony_civoid ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode);
155662306a36Sopenharmony_ci
155762306a36Sopenharmony_ci/* Queue Control Unit, DFS Control Unit Functions */
155862306a36Sopenharmony_ciint ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue,
155962306a36Sopenharmony_ci			       struct ath5k_txq_info *queue_info);
156062306a36Sopenharmony_ciint ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue,
156162306a36Sopenharmony_ci			       const struct ath5k_txq_info *queue_info);
156262306a36Sopenharmony_ciint ath5k_hw_setup_tx_queue(struct ath5k_hw *ah,
156362306a36Sopenharmony_ci			    enum ath5k_tx_queue queue_type,
156462306a36Sopenharmony_ci			    struct ath5k_txq_info *queue_info);
156562306a36Sopenharmony_civoid ath5k_hw_set_tx_retry_limits(struct ath5k_hw *ah,
156662306a36Sopenharmony_ci				  unsigned int queue);
156762306a36Sopenharmony_ciu32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue);
156862306a36Sopenharmony_civoid ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue);
156962306a36Sopenharmony_ciint ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue);
157062306a36Sopenharmony_ciint ath5k_hw_set_ifs_intervals(struct ath5k_hw *ah, unsigned int slot_time);
157162306a36Sopenharmony_ci/* Init function */
157262306a36Sopenharmony_ciint ath5k_hw_init_queues(struct ath5k_hw *ah);
157362306a36Sopenharmony_ci
157462306a36Sopenharmony_ci/* Hardware Descriptor Functions */
157562306a36Sopenharmony_ciint ath5k_hw_init_desc_functions(struct ath5k_hw *ah);
157662306a36Sopenharmony_ciint ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
157762306a36Sopenharmony_ci			   u32 size, unsigned int flags);
157862306a36Sopenharmony_ciint ath5k_hw_setup_mrr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
157962306a36Sopenharmony_ci	unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2,
158062306a36Sopenharmony_ci	u_int tx_tries2, unsigned int tx_rate3, u_int tx_tries3);
158162306a36Sopenharmony_ci
158262306a36Sopenharmony_ci
158362306a36Sopenharmony_ci/* GPIO Functions */
158462306a36Sopenharmony_civoid ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state);
158562306a36Sopenharmony_ciint ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio);
158662306a36Sopenharmony_ciint ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio);
158762306a36Sopenharmony_ciu32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio);
158862306a36Sopenharmony_ciint ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val);
158962306a36Sopenharmony_civoid ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio,
159062306a36Sopenharmony_ci			    u32 interrupt_level);
159162306a36Sopenharmony_ci
159262306a36Sopenharmony_ci
159362306a36Sopenharmony_ci/* RFkill Functions */
159462306a36Sopenharmony_civoid ath5k_rfkill_hw_start(struct ath5k_hw *ah);
159562306a36Sopenharmony_civoid ath5k_rfkill_hw_stop(struct ath5k_hw *ah);
159662306a36Sopenharmony_ci
159762306a36Sopenharmony_ci
159862306a36Sopenharmony_ci/* Misc functions TODO: Cleanup */
159962306a36Sopenharmony_ciint ath5k_hw_set_capabilities(struct ath5k_hw *ah);
160062306a36Sopenharmony_ciint ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, u16 assoc_id);
160162306a36Sopenharmony_ciint ath5k_hw_disable_pspoll(struct ath5k_hw *ah);
160262306a36Sopenharmony_ci
160362306a36Sopenharmony_ci
160462306a36Sopenharmony_ci/* Initial register settings functions */
160562306a36Sopenharmony_ciint ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel);
160662306a36Sopenharmony_ci
160762306a36Sopenharmony_ci
160862306a36Sopenharmony_ci/* PHY functions */
160962306a36Sopenharmony_ci/* Misc PHY functions */
161062306a36Sopenharmony_ciu16 ath5k_hw_radio_revision(struct ath5k_hw *ah, enum nl80211_band band);
161162306a36Sopenharmony_ciint ath5k_hw_phy_disable(struct ath5k_hw *ah);
161262306a36Sopenharmony_ci/* Gain_F optimization */
161362306a36Sopenharmony_cienum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah);
161462306a36Sopenharmony_ciint ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah);
161562306a36Sopenharmony_ci/* PHY/RF channel functions */
161662306a36Sopenharmony_cibool ath5k_channel_ok(struct ath5k_hw *ah, struct ieee80211_channel *channel);
161762306a36Sopenharmony_ci/* PHY calibration */
161862306a36Sopenharmony_civoid ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah);
161962306a36Sopenharmony_ciint ath5k_hw_phy_calibrate(struct ath5k_hw *ah,
162062306a36Sopenharmony_ci			   struct ieee80211_channel *channel);
162162306a36Sopenharmony_civoid ath5k_hw_update_noise_floor(struct ath5k_hw *ah);
162262306a36Sopenharmony_ci/* Spur mitigation */
162362306a36Sopenharmony_cibool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah,
162462306a36Sopenharmony_ci				  struct ieee80211_channel *channel);
162562306a36Sopenharmony_ci/* Antenna control */
162662306a36Sopenharmony_civoid ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode);
162762306a36Sopenharmony_civoid ath5k_hw_set_antenna_switch(struct ath5k_hw *ah, u8 ee_mode);
162862306a36Sopenharmony_ci/* TX power setup */
162962306a36Sopenharmony_ciint ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower);
163062306a36Sopenharmony_ci/* Init function */
163162306a36Sopenharmony_ciint ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
163262306a36Sopenharmony_ci				u8 mode, bool fast);
163362306a36Sopenharmony_ci
163462306a36Sopenharmony_ci/*
163562306a36Sopenharmony_ci * Functions used internally
163662306a36Sopenharmony_ci */
163762306a36Sopenharmony_ci
163862306a36Sopenharmony_cistatic inline struct ath_common *ath5k_hw_common(struct ath5k_hw *ah)
163962306a36Sopenharmony_ci{
164062306a36Sopenharmony_ci	return &ah->common;
164162306a36Sopenharmony_ci}
164262306a36Sopenharmony_ci
164362306a36Sopenharmony_cistatic inline struct ath_regulatory *ath5k_hw_regulatory(struct ath5k_hw *ah)
164462306a36Sopenharmony_ci{
164562306a36Sopenharmony_ci	return &(ath5k_hw_common(ah)->regulatory);
164662306a36Sopenharmony_ci}
164762306a36Sopenharmony_ci
164862306a36Sopenharmony_ci#ifdef CONFIG_ATH5K_AHB
164962306a36Sopenharmony_ci#define AR5K_AR2315_PCI_BASE	((void __iomem *)0xb0100000)
165062306a36Sopenharmony_ci
165162306a36Sopenharmony_cistatic inline void __iomem *ath5k_ahb_reg(struct ath5k_hw *ah, u16 reg)
165262306a36Sopenharmony_ci{
165362306a36Sopenharmony_ci	/* On AR2315 and AR2317 the PCI clock domain registers
165462306a36Sopenharmony_ci	 * are outside of the WMAC register space */
165562306a36Sopenharmony_ci	if (unlikely((reg >= 0x4000) && (reg < 0x5000) &&
165662306a36Sopenharmony_ci	    (ah->ah_mac_srev >= AR5K_SREV_AR2315_R6)))
165762306a36Sopenharmony_ci		return AR5K_AR2315_PCI_BASE + reg;
165862306a36Sopenharmony_ci
165962306a36Sopenharmony_ci	return ah->iobase + reg;
166062306a36Sopenharmony_ci}
166162306a36Sopenharmony_ci
166262306a36Sopenharmony_cistatic inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
166362306a36Sopenharmony_ci{
166462306a36Sopenharmony_ci	return ioread32(ath5k_ahb_reg(ah, reg));
166562306a36Sopenharmony_ci}
166662306a36Sopenharmony_ci
166762306a36Sopenharmony_cistatic inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
166862306a36Sopenharmony_ci{
166962306a36Sopenharmony_ci	iowrite32(val, ath5k_ahb_reg(ah, reg));
167062306a36Sopenharmony_ci}
167162306a36Sopenharmony_ci
167262306a36Sopenharmony_ci#else
167362306a36Sopenharmony_ci
167462306a36Sopenharmony_cistatic inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
167562306a36Sopenharmony_ci{
167662306a36Sopenharmony_ci	return ioread32(ah->iobase + reg);
167762306a36Sopenharmony_ci}
167862306a36Sopenharmony_ci
167962306a36Sopenharmony_cistatic inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
168062306a36Sopenharmony_ci{
168162306a36Sopenharmony_ci	iowrite32(val, ah->iobase + reg);
168262306a36Sopenharmony_ci}
168362306a36Sopenharmony_ci
168462306a36Sopenharmony_ci#endif
168562306a36Sopenharmony_ci
168662306a36Sopenharmony_cistatic inline enum ath_bus_type ath5k_get_bus_type(struct ath5k_hw *ah)
168762306a36Sopenharmony_ci{
168862306a36Sopenharmony_ci	return ath5k_hw_common(ah)->bus_ops->ath_bus_type;
168962306a36Sopenharmony_ci}
169062306a36Sopenharmony_ci
169162306a36Sopenharmony_cistatic inline void ath5k_read_cachesize(struct ath_common *common, int *csz)
169262306a36Sopenharmony_ci{
169362306a36Sopenharmony_ci	common->bus_ops->read_cachesize(common, csz);
169462306a36Sopenharmony_ci}
169562306a36Sopenharmony_ci
169662306a36Sopenharmony_cistatic inline bool ath5k_hw_nvram_read(struct ath5k_hw *ah, u32 off, u16 *data)
169762306a36Sopenharmony_ci{
169862306a36Sopenharmony_ci	struct ath_common *common = ath5k_hw_common(ah);
169962306a36Sopenharmony_ci	return common->bus_ops->eeprom_read(common, off, data);
170062306a36Sopenharmony_ci}
170162306a36Sopenharmony_ci
170262306a36Sopenharmony_cistatic inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits)
170362306a36Sopenharmony_ci{
170462306a36Sopenharmony_ci	u32 retval = 0, bit, i;
170562306a36Sopenharmony_ci
170662306a36Sopenharmony_ci	for (i = 0; i < bits; i++) {
170762306a36Sopenharmony_ci		bit = (val >> i) & 1;
170862306a36Sopenharmony_ci		retval = (retval << 1) | bit;
170962306a36Sopenharmony_ci	}
171062306a36Sopenharmony_ci
171162306a36Sopenharmony_ci	return retval;
171262306a36Sopenharmony_ci}
171362306a36Sopenharmony_ci
171462306a36Sopenharmony_ci#endif
1715