18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2004-2007 Reyk Floeter <reyk@openbsd.org>
38c2ecf20Sopenharmony_ci * Copyright (c) 2006-2007 Nick Kossifidis <mickflemm@gmail.com>
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and distribute this software for any
68c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above
78c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies.
88c2ecf20Sopenharmony_ci *
98c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
108c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
118c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
128c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
138c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
148c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
158c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#ifndef _ATH5K_H
198c2ecf20Sopenharmony_ci#define _ATH5K_H
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci/* TODO: Clean up channel debugging (doesn't work anyway) and start
228c2ecf20Sopenharmony_ci * working on reg. control code using all available eeprom information
238c2ecf20Sopenharmony_ci * (rev. engineering needed) */
248c2ecf20Sopenharmony_ci#define CHAN_DEBUG	0
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci#include <linux/io.h>
278c2ecf20Sopenharmony_ci#include <linux/interrupt.h>
288c2ecf20Sopenharmony_ci#include <linux/types.h>
298c2ecf20Sopenharmony_ci#include <linux/average.h>
308c2ecf20Sopenharmony_ci#include <linux/leds.h>
318c2ecf20Sopenharmony_ci#include <net/mac80211.h>
328c2ecf20Sopenharmony_ci#include <net/cfg80211.h>
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci/* RX/TX descriptor hw structs
358c2ecf20Sopenharmony_ci * TODO: Driver part should only see sw structs */
368c2ecf20Sopenharmony_ci#include "desc.h"
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/* EEPROM structs/offsets
398c2ecf20Sopenharmony_ci * TODO: Make a more generic struct (eg. add more stuff to ath5k_capabilities)
408c2ecf20Sopenharmony_ci * and clean up common bits, then introduce set/get functions in eeprom.c */
418c2ecf20Sopenharmony_ci#include "eeprom.h"
428c2ecf20Sopenharmony_ci#include "debug.h"
438c2ecf20Sopenharmony_ci#include "../ath.h"
448c2ecf20Sopenharmony_ci#include "ani.h"
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_ci/* PCI IDs */
478c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5210		0x0007 /* AR5210 */
488c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5311		0x0011 /* AR5311 */
498c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5211		0x0012 /* AR5211 */
508c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212		0x0013 /* AR5212 */
518c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_3COM_3CRDAG675		0x0013 /* 3CRDAG675 (Atheros AR5212) */
528c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_3COM_2_3CRPAG175		0x0013 /* 3CRPAG175 (Atheros AR5212) */
538c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5210_AP		0x0207 /* AR5210 (Early) */
548c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_IBM	0x1014 /* AR5212 (IBM MiniPCI) */
558c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5210_DEFAULT	0x1107 /* AR5210 (no eeprom) */
568c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_DEFAULT	0x1113 /* AR5212 (no eeprom) */
578c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5211_DEFAULT	0x1112 /* AR5211 (no eeprom) */
588c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_FPGA	0xf013 /* AR5212 (emulation board) */
598c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5211_LEGACY	0xff12 /* AR5211 (emulation board) */
608c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5211_FPGA11B	0xf11b /* AR5211 (emulation board) */
618c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5312_REV2	0x0052 /* AR5312 WMAC (AP31) */
628c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5312_REV7	0x0057 /* AR5312 WMAC (AP30-040) */
638c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5312_REV8	0x0058 /* AR5312 WMAC (AP43-030) */
648c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0014	0x0014 /* AR5212 compatible */
658c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0015	0x0015 /* AR5212 compatible */
668c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0016	0x0016 /* AR5212 compatible */
678c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0017	0x0017 /* AR5212 compatible */
688c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0018	0x0018 /* AR5212 compatible */
698c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5212_0019	0x0019 /* AR5212 compatible */
708c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR2413		0x001a /* AR2413 (Griffin-lite) */
718c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5413		0x001b /* AR5413 (Eagle) */
728c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5424		0x001c /* AR5424 (Condor PCI-E) */
738c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5416		0x0023 /* AR5416 */
748c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_ATHEROS_AR5418		0x0024 /* AR5418 */
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/****************************\
778c2ecf20Sopenharmony_ci  GENERIC DRIVER DEFINITIONS
788c2ecf20Sopenharmony_ci\****************************/
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci#define ATH5K_PRINTF(fmt, ...)						\
818c2ecf20Sopenharmony_ci	pr_warn("%s: " fmt, __func__, ##__VA_ARGS__)
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_civoid __printf(3, 4)
848c2ecf20Sopenharmony_ci_ath5k_printk(const struct ath5k_hw *ah, const char *level,
858c2ecf20Sopenharmony_ci	      const char *fmt, ...);
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci#define ATH5K_PRINTK(_sc, _level, _fmt, ...)				\
888c2ecf20Sopenharmony_ci	_ath5k_printk(_sc, _level, _fmt, ##__VA_ARGS__)
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci#define ATH5K_PRINTK_LIMIT(_sc, _level, _fmt, ...)			\
918c2ecf20Sopenharmony_cido {									\
928c2ecf20Sopenharmony_ci	if (net_ratelimit())						\
938c2ecf20Sopenharmony_ci		ATH5K_PRINTK(_sc, _level, _fmt, ##__VA_ARGS__); 	\
948c2ecf20Sopenharmony_ci} while (0)
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci#define ATH5K_INFO(_sc, _fmt, ...)					\
978c2ecf20Sopenharmony_ci	ATH5K_PRINTK(_sc, KERN_INFO, _fmt, ##__VA_ARGS__)
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ci#define ATH5K_WARN(_sc, _fmt, ...)					\
1008c2ecf20Sopenharmony_ci	ATH5K_PRINTK_LIMIT(_sc, KERN_WARNING, _fmt, ##__VA_ARGS__)
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define ATH5K_ERR(_sc, _fmt, ...)					\
1038c2ecf20Sopenharmony_ci	ATH5K_PRINTK_LIMIT(_sc, KERN_ERR, _fmt, ##__VA_ARGS__)
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci/*
1068c2ecf20Sopenharmony_ci * AR5K REGISTER ACCESS
1078c2ecf20Sopenharmony_ci */
1088c2ecf20Sopenharmony_ci
1098c2ecf20Sopenharmony_ci/* Some macros to read/write fields */
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci/* First shift, then mask */
1128c2ecf20Sopenharmony_ci#define AR5K_REG_SM(_val, _flags)					\
1138c2ecf20Sopenharmony_ci	(((_val) << _flags##_S) & (_flags))
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/* First mask, then shift */
1168c2ecf20Sopenharmony_ci#define AR5K_REG_MS(_val, _flags)					\
1178c2ecf20Sopenharmony_ci	(((_val) & (_flags)) >> _flags##_S)
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci/* Some registers can hold multiple values of interest. For this
1208c2ecf20Sopenharmony_ci * reason when we want to write to these registers we must first
1218c2ecf20Sopenharmony_ci * retrieve the values which we do not want to clear (lets call this
1228c2ecf20Sopenharmony_ci * old_data) and then set the register with this and our new_value:
1238c2ecf20Sopenharmony_ci * ( old_data | new_value) */
1248c2ecf20Sopenharmony_ci#define AR5K_REG_WRITE_BITS(ah, _reg, _flags, _val)			\
1258c2ecf20Sopenharmony_ci	ath5k_hw_reg_write(ah, (ath5k_hw_reg_read(ah, _reg) & ~(_flags)) | \
1268c2ecf20Sopenharmony_ci	    (((_val) << _flags##_S) & (_flags)), _reg)
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ci#define AR5K_REG_MASKED_BITS(ah, _reg, _flags, _mask)			\
1298c2ecf20Sopenharmony_ci	ath5k_hw_reg_write(ah, (ath5k_hw_reg_read(ah, _reg) &		\
1308c2ecf20Sopenharmony_ci			(_mask)) | (_flags), _reg)
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#define AR5K_REG_ENABLE_BITS(ah, _reg, _flags)				\
1338c2ecf20Sopenharmony_ci	ath5k_hw_reg_write(ah, ath5k_hw_reg_read(ah, _reg) | (_flags), _reg)
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#define AR5K_REG_DISABLE_BITS(ah, _reg, _flags)			\
1368c2ecf20Sopenharmony_ci	ath5k_hw_reg_write(ah, ath5k_hw_reg_read(ah, _reg) & ~(_flags), _reg)
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci/* Access QCU registers per queue */
1398c2ecf20Sopenharmony_ci#define AR5K_REG_READ_Q(ah, _reg, _queue)				\
1408c2ecf20Sopenharmony_ci	(ath5k_hw_reg_read(ah, _reg) & (1 << _queue))			\
1418c2ecf20Sopenharmony_ci
1428c2ecf20Sopenharmony_ci#define AR5K_REG_WRITE_Q(ah, _reg, _queue)				\
1438c2ecf20Sopenharmony_ci	ath5k_hw_reg_write(ah, (1 << _queue), _reg)
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci#define AR5K_Q_ENABLE_BITS(_reg, _queue) do {				\
1468c2ecf20Sopenharmony_ci	_reg |= 1 << _queue;						\
1478c2ecf20Sopenharmony_ci} while (0)
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ci#define AR5K_Q_DISABLE_BITS(_reg, _queue) do {				\
1508c2ecf20Sopenharmony_ci	_reg &= ~(1 << _queue);						\
1518c2ecf20Sopenharmony_ci} while (0)
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci/* Used while writing initvals */
1548c2ecf20Sopenharmony_ci#define AR5K_REG_WAIT(_i) do {						\
1558c2ecf20Sopenharmony_ci	if (_i % 64)							\
1568c2ecf20Sopenharmony_ci		udelay(1);						\
1578c2ecf20Sopenharmony_ci} while (0)
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ci/*
1608c2ecf20Sopenharmony_ci * Some tunable values (these should be changeable by the user)
1618c2ecf20Sopenharmony_ci * TODO: Make use of them and add more options OR use debug/configfs
1628c2ecf20Sopenharmony_ci */
1638c2ecf20Sopenharmony_ci#define AR5K_TUNE_DMA_BEACON_RESP		2
1648c2ecf20Sopenharmony_ci#define AR5K_TUNE_SW_BEACON_RESP		10
1658c2ecf20Sopenharmony_ci#define AR5K_TUNE_ADDITIONAL_SWBA_BACKOFF	0
1668c2ecf20Sopenharmony_ci#define AR5K_TUNE_MIN_TX_FIFO_THRES		1
1678c2ecf20Sopenharmony_ci#define AR5K_TUNE_MAX_TX_FIFO_THRES	((IEEE80211_MAX_FRAME_LEN / 64) + 1)
1688c2ecf20Sopenharmony_ci#define AR5K_TUNE_REGISTER_TIMEOUT		20000
1698c2ecf20Sopenharmony_ci/* Register for RSSI threshold has a mask of 0xff, so 255 seems to
1708c2ecf20Sopenharmony_ci * be the max value. */
1718c2ecf20Sopenharmony_ci#define AR5K_TUNE_RSSI_THRES			129
1728c2ecf20Sopenharmony_ci/* This must be set when setting the RSSI threshold otherwise it can
1738c2ecf20Sopenharmony_ci * prevent a reset. If AR5K_RSSI_THR is read after writing to it
1748c2ecf20Sopenharmony_ci * the BMISS_THRES will be seen as 0, seems hardware doesn't keep
1758c2ecf20Sopenharmony_ci * track of it. Max value depends on hardware. For AR5210 this is just 7.
1768c2ecf20Sopenharmony_ci * For AR5211+ this seems to be up to 255. */
1778c2ecf20Sopenharmony_ci#define AR5K_TUNE_BMISS_THRES			7
1788c2ecf20Sopenharmony_ci#define AR5K_TUNE_REGISTER_DWELL_TIME		20000
1798c2ecf20Sopenharmony_ci#define AR5K_TUNE_BEACON_INTERVAL		100
1808c2ecf20Sopenharmony_ci#define AR5K_TUNE_AIFS				2
1818c2ecf20Sopenharmony_ci#define AR5K_TUNE_AIFS_11B			2
1828c2ecf20Sopenharmony_ci#define AR5K_TUNE_AIFS_XR			0
1838c2ecf20Sopenharmony_ci#define AR5K_TUNE_CWMIN				15
1848c2ecf20Sopenharmony_ci#define AR5K_TUNE_CWMIN_11B			31
1858c2ecf20Sopenharmony_ci#define AR5K_TUNE_CWMIN_XR			3
1868c2ecf20Sopenharmony_ci#define AR5K_TUNE_CWMAX				1023
1878c2ecf20Sopenharmony_ci#define AR5K_TUNE_CWMAX_11B			1023
1888c2ecf20Sopenharmony_ci#define AR5K_TUNE_CWMAX_XR			7
1898c2ecf20Sopenharmony_ci#define AR5K_TUNE_NOISE_FLOOR			-72
1908c2ecf20Sopenharmony_ci#define AR5K_TUNE_CCA_MAX_GOOD_VALUE		-95
1918c2ecf20Sopenharmony_ci#define AR5K_TUNE_MAX_TXPOWER			63
1928c2ecf20Sopenharmony_ci#define AR5K_TUNE_DEFAULT_TXPOWER		25
1938c2ecf20Sopenharmony_ci#define AR5K_TUNE_TPC_TXPOWER			false
1948c2ecf20Sopenharmony_ci#define ATH5K_TUNE_CALIBRATION_INTERVAL_FULL    60000   /* 60 sec */
1958c2ecf20Sopenharmony_ci#define	ATH5K_TUNE_CALIBRATION_INTERVAL_SHORT	10000	/* 10 sec */
1968c2ecf20Sopenharmony_ci#define ATH5K_TUNE_CALIBRATION_INTERVAL_ANI	1000	/* 1 sec */
1978c2ecf20Sopenharmony_ci#define ATH5K_TX_COMPLETE_POLL_INT		3000	/* 3 sec */
1988c2ecf20Sopenharmony_ci
1998c2ecf20Sopenharmony_ci#define AR5K_INIT_CARR_SENSE_EN			1
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci/*Swap RX/TX Descriptor for big endian archs*/
2028c2ecf20Sopenharmony_ci#if defined(__BIG_ENDIAN)
2038c2ecf20Sopenharmony_ci#define AR5K_INIT_CFG	(		\
2048c2ecf20Sopenharmony_ci	AR5K_CFG_SWTD | AR5K_CFG_SWRD	\
2058c2ecf20Sopenharmony_ci)
2068c2ecf20Sopenharmony_ci#else
2078c2ecf20Sopenharmony_ci#define AR5K_INIT_CFG	0x00000000
2088c2ecf20Sopenharmony_ci#endif
2098c2ecf20Sopenharmony_ci
2108c2ecf20Sopenharmony_ci/* Initial values */
2118c2ecf20Sopenharmony_ci#define	AR5K_INIT_CYCRSSI_THR1			2
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci/* Tx retry limit defaults from standard */
2148c2ecf20Sopenharmony_ci#define AR5K_INIT_RETRY_SHORT			7
2158c2ecf20Sopenharmony_ci#define AR5K_INIT_RETRY_LONG			4
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci/* Slot time */
2188c2ecf20Sopenharmony_ci#define AR5K_INIT_SLOT_TIME_TURBO		6
2198c2ecf20Sopenharmony_ci#define AR5K_INIT_SLOT_TIME_DEFAULT		9
2208c2ecf20Sopenharmony_ci#define	AR5K_INIT_SLOT_TIME_HALF_RATE		13
2218c2ecf20Sopenharmony_ci#define	AR5K_INIT_SLOT_TIME_QUARTER_RATE	21
2228c2ecf20Sopenharmony_ci#define	AR5K_INIT_SLOT_TIME_B			20
2238c2ecf20Sopenharmony_ci#define AR5K_SLOT_TIME_MAX			0xffff
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci/* SIFS */
2268c2ecf20Sopenharmony_ci#define	AR5K_INIT_SIFS_TURBO			6
2278c2ecf20Sopenharmony_ci#define	AR5K_INIT_SIFS_DEFAULT_BG		10
2288c2ecf20Sopenharmony_ci#define	AR5K_INIT_SIFS_DEFAULT_A		16
2298c2ecf20Sopenharmony_ci#define	AR5K_INIT_SIFS_HALF_RATE		32
2308c2ecf20Sopenharmony_ci#define AR5K_INIT_SIFS_QUARTER_RATE		64
2318c2ecf20Sopenharmony_ci
2328c2ecf20Sopenharmony_ci/* Used to calculate tx time for non 5/10/40MHz
2338c2ecf20Sopenharmony_ci * operation */
2348c2ecf20Sopenharmony_ci/* It's preamble time + signal time (16 + 4) */
2358c2ecf20Sopenharmony_ci#define	AR5K_INIT_OFDM_PREAMPLE_TIME		20
2368c2ecf20Sopenharmony_ci/* Preamble time for 40MHz (turbo) operation (min ?) */
2378c2ecf20Sopenharmony_ci#define	AR5K_INIT_OFDM_PREAMBLE_TIME_MIN	14
2388c2ecf20Sopenharmony_ci#define	AR5K_INIT_OFDM_SYMBOL_TIME		4
2398c2ecf20Sopenharmony_ci#define	AR5K_INIT_OFDM_PLCP_BITS		22
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci/* Rx latency for 5 and 10MHz operation (max ?) */
2428c2ecf20Sopenharmony_ci#define AR5K_INIT_RX_LAT_MAX			63
2438c2ecf20Sopenharmony_ci/* Tx latencies from initvals (5212 only but no problem
2448c2ecf20Sopenharmony_ci * because we only tweak them on 5212) */
2458c2ecf20Sopenharmony_ci#define	AR5K_INIT_TX_LAT_A			54
2468c2ecf20Sopenharmony_ci#define	AR5K_INIT_TX_LAT_BG			384
2478c2ecf20Sopenharmony_ci/* Tx latency for 40MHz (turbo) operation (min ?) */
2488c2ecf20Sopenharmony_ci#define	AR5K_INIT_TX_LAT_MIN			32
2498c2ecf20Sopenharmony_ci/* Default Tx/Rx latencies (same for 5211)*/
2508c2ecf20Sopenharmony_ci#define AR5K_INIT_TX_LATENCY_5210		54
2518c2ecf20Sopenharmony_ci#define	AR5K_INIT_RX_LATENCY_5210		29
2528c2ecf20Sopenharmony_ci
2538c2ecf20Sopenharmony_ci/* Tx frame to Tx data start delay */
2548c2ecf20Sopenharmony_ci#define AR5K_INIT_TXF2TXD_START_DEFAULT		14
2558c2ecf20Sopenharmony_ci#define AR5K_INIT_TXF2TXD_START_DELAY_10MHZ	12
2568c2ecf20Sopenharmony_ci#define AR5K_INIT_TXF2TXD_START_DELAY_5MHZ	13
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_ci/* We need to increase PHY switch and agc settling time
2598c2ecf20Sopenharmony_ci * on turbo mode */
2608c2ecf20Sopenharmony_ci#define	AR5K_SWITCH_SETTLING			5760
2618c2ecf20Sopenharmony_ci#define	AR5K_SWITCH_SETTLING_TURBO		7168
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci#define	AR5K_AGC_SETTLING			28
2648c2ecf20Sopenharmony_ci/* 38 on 5210 but shouldn't matter */
2658c2ecf20Sopenharmony_ci#define	AR5K_AGC_SETTLING_TURBO			37
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ci/*****************************\
2708c2ecf20Sopenharmony_ci* GENERIC CHIPSET DEFINITIONS *
2718c2ecf20Sopenharmony_ci\*****************************/
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ci/**
2748c2ecf20Sopenharmony_ci * enum ath5k_version - MAC Chips
2758c2ecf20Sopenharmony_ci * @AR5K_AR5210: AR5210 (Crete)
2768c2ecf20Sopenharmony_ci * @AR5K_AR5211: AR5211 (Oahu/Maui)
2778c2ecf20Sopenharmony_ci * @AR5K_AR5212: AR5212 (Venice) and newer
2788c2ecf20Sopenharmony_ci */
2798c2ecf20Sopenharmony_cienum ath5k_version {
2808c2ecf20Sopenharmony_ci	AR5K_AR5210	= 0,
2818c2ecf20Sopenharmony_ci	AR5K_AR5211	= 1,
2828c2ecf20Sopenharmony_ci	AR5K_AR5212	= 2,
2838c2ecf20Sopenharmony_ci};
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_ci/**
2868c2ecf20Sopenharmony_ci * enum ath5k_radio - PHY Chips
2878c2ecf20Sopenharmony_ci * @AR5K_RF5110: RF5110 (Fez)
2888c2ecf20Sopenharmony_ci * @AR5K_RF5111: RF5111 (Sombrero)
2898c2ecf20Sopenharmony_ci * @AR5K_RF5112: RF2112/5112(A) (Derby/Derby2)
2908c2ecf20Sopenharmony_ci * @AR5K_RF2413: RF2413/2414 (Griffin/Griffin-Lite)
2918c2ecf20Sopenharmony_ci * @AR5K_RF5413: RF5413/5414/5424 (Eagle/Condor)
2928c2ecf20Sopenharmony_ci * @AR5K_RF2316: RF2315/2316 (Cobra SoC)
2938c2ecf20Sopenharmony_ci * @AR5K_RF2317: RF2317 (Spider SoC)
2948c2ecf20Sopenharmony_ci * @AR5K_RF2425: RF2425/2417 (Swan/Nalla)
2958c2ecf20Sopenharmony_ci */
2968c2ecf20Sopenharmony_cienum ath5k_radio {
2978c2ecf20Sopenharmony_ci	AR5K_RF5110	= 0,
2988c2ecf20Sopenharmony_ci	AR5K_RF5111	= 1,
2998c2ecf20Sopenharmony_ci	AR5K_RF5112	= 2,
3008c2ecf20Sopenharmony_ci	AR5K_RF2413	= 3,
3018c2ecf20Sopenharmony_ci	AR5K_RF5413	= 4,
3028c2ecf20Sopenharmony_ci	AR5K_RF2316	= 5,
3038c2ecf20Sopenharmony_ci	AR5K_RF2317	= 6,
3048c2ecf20Sopenharmony_ci	AR5K_RF2425	= 7,
3058c2ecf20Sopenharmony_ci};
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci/*
3088c2ecf20Sopenharmony_ci * Common silicon revision/version values
3098c2ecf20Sopenharmony_ci */
3108c2ecf20Sopenharmony_ci
3118c2ecf20Sopenharmony_ci#define AR5K_SREV_UNKNOWN	0xffff
3128c2ecf20Sopenharmony_ci
3138c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5210	0x00 /* Crete */
3148c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5311	0x10 /* Maui 1 */
3158c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5311A	0x20 /* Maui 2 */
3168c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5311B	0x30 /* Spirit */
3178c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5211	0x40 /* Oahu */
3188c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5212	0x50 /* Venice */
3198c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5312_R2	0x52 /* AP31 */
3208c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5212_V4	0x54 /* ??? */
3218c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5213	0x55 /* ??? */
3228c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5312_R7	0x57 /* AP30 */
3238c2ecf20Sopenharmony_ci#define AR5K_SREV_AR2313_R8	0x58 /* AP43 */
3248c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5213A	0x59 /* Hainan */
3258c2ecf20Sopenharmony_ci#define AR5K_SREV_AR2413	0x78 /* Griffin lite */
3268c2ecf20Sopenharmony_ci#define AR5K_SREV_AR2414	0x70 /* Griffin */
3278c2ecf20Sopenharmony_ci#define AR5K_SREV_AR2315_R6	0x86 /* AP51-Light */
3288c2ecf20Sopenharmony_ci#define AR5K_SREV_AR2315_R7	0x87 /* AP51-Full */
3298c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5424	0x90 /* Condor */
3308c2ecf20Sopenharmony_ci#define AR5K_SREV_AR2317_R1	0x90 /* AP61-Light */
3318c2ecf20Sopenharmony_ci#define AR5K_SREV_AR2317_R2	0x91 /* AP61-Full */
3328c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5413	0xa4 /* Eagle lite */
3338c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5414	0xa0 /* Eagle */
3348c2ecf20Sopenharmony_ci#define AR5K_SREV_AR2415	0xb0 /* Talon */
3358c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5416	0xc0 /* PCI-E */
3368c2ecf20Sopenharmony_ci#define AR5K_SREV_AR5418	0xca /* PCI-E */
3378c2ecf20Sopenharmony_ci#define AR5K_SREV_AR2425	0xe0 /* Swan */
3388c2ecf20Sopenharmony_ci#define AR5K_SREV_AR2417	0xf0 /* Nala */
3398c2ecf20Sopenharmony_ci
3408c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_5110	0x00
3418c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_5111	0x10
3428c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_5111A	0x15
3438c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_2111	0x20
3448c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_5112	0x30
3458c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_5112A	0x35
3468c2ecf20Sopenharmony_ci#define	AR5K_SREV_RAD_5112B	0x36
3478c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_2112	0x40
3488c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_2112A	0x45
3498c2ecf20Sopenharmony_ci#define	AR5K_SREV_RAD_2112B	0x46
3508c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_2413	0x50
3518c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_5413	0x60
3528c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_2316	0x70 /* Cobra SoC */
3538c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_2317	0x80
3548c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_5424	0xa0 /* Mostly same as 5413 */
3558c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_2425	0xa2
3568c2ecf20Sopenharmony_ci#define AR5K_SREV_RAD_5133	0xc0
3578c2ecf20Sopenharmony_ci
3588c2ecf20Sopenharmony_ci#define AR5K_SREV_PHY_5211	0x30
3598c2ecf20Sopenharmony_ci#define AR5K_SREV_PHY_5212	0x41
3608c2ecf20Sopenharmony_ci#define	AR5K_SREV_PHY_5212A	0x42
3618c2ecf20Sopenharmony_ci#define AR5K_SREV_PHY_5212B	0x43
3628c2ecf20Sopenharmony_ci#define AR5K_SREV_PHY_2413	0x45
3638c2ecf20Sopenharmony_ci#define AR5K_SREV_PHY_5413	0x61
3648c2ecf20Sopenharmony_ci#define AR5K_SREV_PHY_2425	0x70
3658c2ecf20Sopenharmony_ci
3668c2ecf20Sopenharmony_ci/* TODO add support to mac80211 for vendor-specific rates and modes */
3678c2ecf20Sopenharmony_ci
3688c2ecf20Sopenharmony_ci/**
3698c2ecf20Sopenharmony_ci * DOC: Atheros XR
3708c2ecf20Sopenharmony_ci *
3718c2ecf20Sopenharmony_ci * Some of this information is based on Documentation from:
3728c2ecf20Sopenharmony_ci *
3738c2ecf20Sopenharmony_ci * http://madwifi-project.org/wiki/ChipsetFeatures/SuperAG
3748c2ecf20Sopenharmony_ci *
3758c2ecf20Sopenharmony_ci * Atheros' eXtended Range - range enhancing extension is a modulation scheme
3768c2ecf20Sopenharmony_ci * that is supposed to double the link distance between an Atheros XR-enabled
3778c2ecf20Sopenharmony_ci * client device with an Atheros XR-enabled access point. This is achieved
3788c2ecf20Sopenharmony_ci * by increasing the receiver sensitivity up to, -105dBm, which is about 20dB
3798c2ecf20Sopenharmony_ci * above what the 802.11 specifications demand. In addition, new (proprietary)
3808c2ecf20Sopenharmony_ci * data rates are introduced: 3, 2, 1, 0.5 and 0.25 MBit/s.
3818c2ecf20Sopenharmony_ci *
3828c2ecf20Sopenharmony_ci * Please note that can you either use XR or TURBO but you cannot use both,
3838c2ecf20Sopenharmony_ci * they are exclusive.
3848c2ecf20Sopenharmony_ci *
3858c2ecf20Sopenharmony_ci * Also note that we do not plan to support XR mode at least for now. You can
3868c2ecf20Sopenharmony_ci * get a mode similar to XR by using 5MHz bwmode.
3878c2ecf20Sopenharmony_ci */
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_ci
3908c2ecf20Sopenharmony_ci/**
3918c2ecf20Sopenharmony_ci * DOC: Atheros SuperAG
3928c2ecf20Sopenharmony_ci *
3938c2ecf20Sopenharmony_ci * In addition to XR we have another modulation scheme called TURBO mode
3948c2ecf20Sopenharmony_ci * that is supposed to provide a throughput transmission speed up to 40Mbit/s
3958c2ecf20Sopenharmony_ci * -60Mbit/s at a 108Mbit/s signaling rate achieved through the bonding of two
3968c2ecf20Sopenharmony_ci * 54Mbit/s 802.11g channels. To use this feature both ends must support it.
3978c2ecf20Sopenharmony_ci * There is also a distinction between "static" and "dynamic" turbo modes:
3988c2ecf20Sopenharmony_ci *
3998c2ecf20Sopenharmony_ci * - Static: is the dumb version: devices set to this mode stick to it until
4008c2ecf20Sopenharmony_ci *     the mode is turned off.
4018c2ecf20Sopenharmony_ci *
4028c2ecf20Sopenharmony_ci * - Dynamic: is the intelligent version, the network decides itself if it
4038c2ecf20Sopenharmony_ci *     is ok to use turbo. As soon as traffic is detected on adjacent channels
4048c2ecf20Sopenharmony_ci *     (which would get used in turbo mode), or when a non-turbo station joins
4058c2ecf20Sopenharmony_ci *     the network, turbo mode won't be used until the situation changes again.
4068c2ecf20Sopenharmony_ci *     Dynamic mode is achieved by Atheros' Adaptive Radio (AR) feature which
4078c2ecf20Sopenharmony_ci *     monitors the used radio band in order to decide whether turbo mode may
4088c2ecf20Sopenharmony_ci *     be used or not.
4098c2ecf20Sopenharmony_ci *
4108c2ecf20Sopenharmony_ci * This article claims Super G sticks to bonding of channels 5 and 6 for
4118c2ecf20Sopenharmony_ci * USA:
4128c2ecf20Sopenharmony_ci *
4138c2ecf20Sopenharmony_ci * https://www.pcworld.com/article/id,113428-page,1/article.html
4148c2ecf20Sopenharmony_ci *
4158c2ecf20Sopenharmony_ci * The channel bonding seems to be driver specific though.
4168c2ecf20Sopenharmony_ci *
4178c2ecf20Sopenharmony_ci * In addition to TURBO modes we also have the following features for even
4188c2ecf20Sopenharmony_ci * greater speed-up:
4198c2ecf20Sopenharmony_ci *
4208c2ecf20Sopenharmony_ci * - Bursting: allows multiple frames to be sent at once, rather than pausing
4218c2ecf20Sopenharmony_ci *     after each frame. Bursting is a standards-compliant feature that can be
4228c2ecf20Sopenharmony_ci *     used with any Access Point.
4238c2ecf20Sopenharmony_ci *
4248c2ecf20Sopenharmony_ci * - Fast frames: increases the amount of information that can be sent per
4258c2ecf20Sopenharmony_ci *     frame, also resulting in a reduction of transmission overhead. It is a
4268c2ecf20Sopenharmony_ci *     proprietary feature that needs to be supported by the Access Point.
4278c2ecf20Sopenharmony_ci *
4288c2ecf20Sopenharmony_ci * - Compression: data frames are compressed in real time using a Lempel Ziv
4298c2ecf20Sopenharmony_ci *     algorithm. This is done transparently. Once this feature is enabled,
4308c2ecf20Sopenharmony_ci *     compression and decompression takes place inside the chipset, without
4318c2ecf20Sopenharmony_ci *     putting additional load on the host CPU.
4328c2ecf20Sopenharmony_ci *
4338c2ecf20Sopenharmony_ci * As with XR we also don't plan to support SuperAG features for now. You can
4348c2ecf20Sopenharmony_ci * get a mode similar to TURBO by using 40MHz bwmode.
4358c2ecf20Sopenharmony_ci */
4368c2ecf20Sopenharmony_ci
4378c2ecf20Sopenharmony_ci
4388c2ecf20Sopenharmony_ci/**
4398c2ecf20Sopenharmony_ci * enum ath5k_driver_mode - PHY operation mode
4408c2ecf20Sopenharmony_ci * @AR5K_MODE_11A: 802.11a
4418c2ecf20Sopenharmony_ci * @AR5K_MODE_11B: 802.11b
4428c2ecf20Sopenharmony_ci * @AR5K_MODE_11G: 801.11g
4438c2ecf20Sopenharmony_ci * @AR5K_MODE_MAX: Used for boundary checks
4448c2ecf20Sopenharmony_ci *
4458c2ecf20Sopenharmony_ci * Do not change the order here, we use these as
4468c2ecf20Sopenharmony_ci * array indices and it also maps EEPROM structures.
4478c2ecf20Sopenharmony_ci */
4488c2ecf20Sopenharmony_cienum ath5k_driver_mode {
4498c2ecf20Sopenharmony_ci	AR5K_MODE_11A		=	0,
4508c2ecf20Sopenharmony_ci	AR5K_MODE_11B		=	1,
4518c2ecf20Sopenharmony_ci	AR5K_MODE_11G		=	2,
4528c2ecf20Sopenharmony_ci	AR5K_MODE_MAX		=	3
4538c2ecf20Sopenharmony_ci};
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ci/**
4568c2ecf20Sopenharmony_ci * enum ath5k_ant_mode - Antenna operation mode
4578c2ecf20Sopenharmony_ci * @AR5K_ANTMODE_DEFAULT: Default antenna setup
4588c2ecf20Sopenharmony_ci * @AR5K_ANTMODE_FIXED_A: Only antenna A is present
4598c2ecf20Sopenharmony_ci * @AR5K_ANTMODE_FIXED_B: Only antenna B is present
4608c2ecf20Sopenharmony_ci * @AR5K_ANTMODE_SINGLE_AP: STA locked on a single ap
4618c2ecf20Sopenharmony_ci * @AR5K_ANTMODE_SECTOR_AP: AP with tx antenna set on tx desc
4628c2ecf20Sopenharmony_ci * @AR5K_ANTMODE_SECTOR_STA: STA with tx antenna set on tx desc
4638c2ecf20Sopenharmony_ci * @AR5K_ANTMODE_DEBUG: Debug mode -A -> Rx, B-> Tx-
4648c2ecf20Sopenharmony_ci * @AR5K_ANTMODE_MAX: Used for boundary checks
4658c2ecf20Sopenharmony_ci *
4668c2ecf20Sopenharmony_ci * For more infos on antenna control check out phy.c
4678c2ecf20Sopenharmony_ci */
4688c2ecf20Sopenharmony_cienum ath5k_ant_mode {
4698c2ecf20Sopenharmony_ci	AR5K_ANTMODE_DEFAULT	= 0,
4708c2ecf20Sopenharmony_ci	AR5K_ANTMODE_FIXED_A	= 1,
4718c2ecf20Sopenharmony_ci	AR5K_ANTMODE_FIXED_B	= 2,
4728c2ecf20Sopenharmony_ci	AR5K_ANTMODE_SINGLE_AP	= 3,
4738c2ecf20Sopenharmony_ci	AR5K_ANTMODE_SECTOR_AP	= 4,
4748c2ecf20Sopenharmony_ci	AR5K_ANTMODE_SECTOR_STA	= 5,
4758c2ecf20Sopenharmony_ci	AR5K_ANTMODE_DEBUG	= 6,
4768c2ecf20Sopenharmony_ci	AR5K_ANTMODE_MAX,
4778c2ecf20Sopenharmony_ci};
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_ci/**
4808c2ecf20Sopenharmony_ci * enum ath5k_bw_mode - Bandwidth operation mode
4818c2ecf20Sopenharmony_ci * @AR5K_BWMODE_DEFAULT: 20MHz, default operation
4828c2ecf20Sopenharmony_ci * @AR5K_BWMODE_5MHZ: Quarter rate
4838c2ecf20Sopenharmony_ci * @AR5K_BWMODE_10MHZ: Half rate
4848c2ecf20Sopenharmony_ci * @AR5K_BWMODE_40MHZ: Turbo
4858c2ecf20Sopenharmony_ci */
4868c2ecf20Sopenharmony_cienum ath5k_bw_mode {
4878c2ecf20Sopenharmony_ci	AR5K_BWMODE_DEFAULT	= 0,
4888c2ecf20Sopenharmony_ci	AR5K_BWMODE_5MHZ	= 1,
4898c2ecf20Sopenharmony_ci	AR5K_BWMODE_10MHZ	= 2,
4908c2ecf20Sopenharmony_ci	AR5K_BWMODE_40MHZ	= 3
4918c2ecf20Sopenharmony_ci};
4928c2ecf20Sopenharmony_ci
4938c2ecf20Sopenharmony_ci
4948c2ecf20Sopenharmony_ci
4958c2ecf20Sopenharmony_ci/****************\
4968c2ecf20Sopenharmony_ci  TX DEFINITIONS
4978c2ecf20Sopenharmony_ci\****************/
4988c2ecf20Sopenharmony_ci
4998c2ecf20Sopenharmony_ci/**
5008c2ecf20Sopenharmony_ci * struct ath5k_tx_status - TX Status descriptor
5018c2ecf20Sopenharmony_ci * @ts_seqnum: Sequence number
5028c2ecf20Sopenharmony_ci * @ts_tstamp: Timestamp
5038c2ecf20Sopenharmony_ci * @ts_status: Status code
5048c2ecf20Sopenharmony_ci * @ts_final_idx: Final transmission series index
5058c2ecf20Sopenharmony_ci * @ts_final_retry: Final retry count
5068c2ecf20Sopenharmony_ci * @ts_rssi: RSSI for received ACK
5078c2ecf20Sopenharmony_ci * @ts_shortretry: Short retry count
5088c2ecf20Sopenharmony_ci * @ts_virtcol: Virtual collision count
5098c2ecf20Sopenharmony_ci * @ts_antenna: Antenna used
5108c2ecf20Sopenharmony_ci *
5118c2ecf20Sopenharmony_ci * TX status descriptor gets filled by the hw
5128c2ecf20Sopenharmony_ci * on each transmission attempt.
5138c2ecf20Sopenharmony_ci */
5148c2ecf20Sopenharmony_cistruct ath5k_tx_status {
5158c2ecf20Sopenharmony_ci	u16	ts_seqnum;
5168c2ecf20Sopenharmony_ci	u16	ts_tstamp;
5178c2ecf20Sopenharmony_ci	u8	ts_status;
5188c2ecf20Sopenharmony_ci	u8	ts_final_idx;
5198c2ecf20Sopenharmony_ci	u8	ts_final_retry;
5208c2ecf20Sopenharmony_ci	s8	ts_rssi;
5218c2ecf20Sopenharmony_ci	u8	ts_shortretry;
5228c2ecf20Sopenharmony_ci	u8	ts_virtcol;
5238c2ecf20Sopenharmony_ci	u8	ts_antenna;
5248c2ecf20Sopenharmony_ci};
5258c2ecf20Sopenharmony_ci
5268c2ecf20Sopenharmony_ci#define AR5K_TXSTAT_ALTRATE	0x80
5278c2ecf20Sopenharmony_ci#define AR5K_TXERR_XRETRY	0x01
5288c2ecf20Sopenharmony_ci#define AR5K_TXERR_FILT		0x02
5298c2ecf20Sopenharmony_ci#define AR5K_TXERR_FIFO		0x04
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_ci/**
5328c2ecf20Sopenharmony_ci * enum ath5k_tx_queue - Queue types used to classify tx queues.
5338c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_INACTIVE: q is unused -- see ath5k_hw_release_tx_queue
5348c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_DATA: A normal data queue
5358c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_BEACON: The beacon queue
5368c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_CAB: The after-beacon queue
5378c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_UAPSD: Unscheduled Automatic Power Save Delivery queue
5388c2ecf20Sopenharmony_ci */
5398c2ecf20Sopenharmony_cienum ath5k_tx_queue {
5408c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_INACTIVE = 0,
5418c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_DATA,
5428c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_BEACON,
5438c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_CAB,
5448c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_UAPSD,
5458c2ecf20Sopenharmony_ci};
5468c2ecf20Sopenharmony_ci
5478c2ecf20Sopenharmony_ci#define	AR5K_NUM_TX_QUEUES		10
5488c2ecf20Sopenharmony_ci#define	AR5K_NUM_TX_QUEUES_NOQCU	2
5498c2ecf20Sopenharmony_ci
5508c2ecf20Sopenharmony_ci/**
5518c2ecf20Sopenharmony_ci * enum ath5k_tx_queue_subtype - Queue sub-types to classify normal data queues
5528c2ecf20Sopenharmony_ci * @AR5K_WME_AC_BK: Background traffic
5538c2ecf20Sopenharmony_ci * @AR5K_WME_AC_BE: Best-effort (normal) traffic
5548c2ecf20Sopenharmony_ci * @AR5K_WME_AC_VI: Video traffic
5558c2ecf20Sopenharmony_ci * @AR5K_WME_AC_VO: Voice traffic
5568c2ecf20Sopenharmony_ci *
5578c2ecf20Sopenharmony_ci * These are the 4 Access Categories as defined in
5588c2ecf20Sopenharmony_ci * WME spec. 0 is the lowest priority and 4 is the
5598c2ecf20Sopenharmony_ci * highest. Normal data that hasn't been classified
5608c2ecf20Sopenharmony_ci * goes to the Best Effort AC.
5618c2ecf20Sopenharmony_ci */
5628c2ecf20Sopenharmony_cienum ath5k_tx_queue_subtype {
5638c2ecf20Sopenharmony_ci	AR5K_WME_AC_BK = 0,
5648c2ecf20Sopenharmony_ci	AR5K_WME_AC_BE,
5658c2ecf20Sopenharmony_ci	AR5K_WME_AC_VI,
5668c2ecf20Sopenharmony_ci	AR5K_WME_AC_VO,
5678c2ecf20Sopenharmony_ci};
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ci/**
5708c2ecf20Sopenharmony_ci * enum ath5k_tx_queue_id - Queue ID numbers as returned by the hw functions
5718c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_ID_NOQCU_DATA: Data queue on AR5210 (no QCU available)
5728c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_ID_NOQCU_BEACON: Beacon queue on AR5210 (no QCU available)
5738c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_ID_DATA_MIN: Data queue min index
5748c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_ID_DATA_MAX: Data queue max index
5758c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_ID_CAB: Content after beacon queue
5768c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_ID_BEACON: Beacon queue
5778c2ecf20Sopenharmony_ci * @AR5K_TX_QUEUE_ID_UAPSD: Urgent Automatic Power Save Delivery,
5788c2ecf20Sopenharmony_ci *
5798c2ecf20Sopenharmony_ci * Each number represents a hw queue. If hw does not support hw queues
5808c2ecf20Sopenharmony_ci * (eg 5210) all data goes in one queue.
5818c2ecf20Sopenharmony_ci */
5828c2ecf20Sopenharmony_cienum ath5k_tx_queue_id {
5838c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_ID_NOQCU_DATA	= 0,
5848c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_ID_NOQCU_BEACON	= 1,
5858c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_ID_DATA_MIN	= 0,
5868c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_ID_DATA_MAX	= 3,
5878c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_ID_UAPSD		= 7,
5888c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_ID_CAB		= 8,
5898c2ecf20Sopenharmony_ci	AR5K_TX_QUEUE_ID_BEACON		= 9,
5908c2ecf20Sopenharmony_ci};
5918c2ecf20Sopenharmony_ci
5928c2ecf20Sopenharmony_ci/*
5938c2ecf20Sopenharmony_ci * Flags to set hw queue's parameters...
5948c2ecf20Sopenharmony_ci */
5958c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_TXOKINT_ENABLE		0x0001	/* Enable TXOK interrupt */
5968c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_TXERRINT_ENABLE		0x0002	/* Enable TXERR interrupt */
5978c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_TXEOLINT_ENABLE		0x0004	/* Enable TXEOL interrupt -not used- */
5988c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_TXDESCINT_ENABLE		0x0008	/* Enable TXDESC interrupt -not used- */
5998c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_TXURNINT_ENABLE		0x0010	/* Enable TXURN interrupt */
6008c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_CBRORNINT_ENABLE		0x0020	/* Enable CBRORN interrupt */
6018c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_CBRURNINT_ENABLE		0x0040	/* Enable CBRURN interrupt */
6028c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_QTRIGINT_ENABLE		0x0080	/* Enable QTRIG interrupt */
6038c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_TXNOFRMINT_ENABLE		0x0100	/* Enable TXNOFRM interrupt */
6048c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_BACKOFF_DISABLE		0x0200	/* Disable random post-backoff */
6058c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_RDYTIME_EXP_POLICY_ENABLE	0x0300	/* Enable ready time expiry policy (?)*/
6068c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_FRAG_BURST_BACKOFF_ENABLE	0x0800	/* Enable backoff while bursting */
6078c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_POST_FR_BKOFF_DIS		0x1000	/* Disable backoff while bursting */
6088c2ecf20Sopenharmony_ci#define AR5K_TXQ_FLAG_COMPRESSION_ENABLE	0x2000	/* Enable hw compression -not implemented-*/
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_ci/**
6118c2ecf20Sopenharmony_ci * struct ath5k_txq - Transmit queue state
6128c2ecf20Sopenharmony_ci * @qnum: Hardware q number
6138c2ecf20Sopenharmony_ci * @link: Link ptr in last TX desc
6148c2ecf20Sopenharmony_ci * @q: Transmit queue (&struct list_head)
6158c2ecf20Sopenharmony_ci * @lock: Lock on q and link
6168c2ecf20Sopenharmony_ci * @setup: Is the queue configured
6178c2ecf20Sopenharmony_ci * @txq_len:Number of queued buffers
6188c2ecf20Sopenharmony_ci * @txq_max: Max allowed num of queued buffers
6198c2ecf20Sopenharmony_ci * @txq_poll_mark: Used to check if queue got stuck
6208c2ecf20Sopenharmony_ci * @txq_stuck: Queue stuck counter
6218c2ecf20Sopenharmony_ci *
6228c2ecf20Sopenharmony_ci * One of these exists for each hardware transmit queue.
6238c2ecf20Sopenharmony_ci * Packets sent to us from above are assigned to queues based
6248c2ecf20Sopenharmony_ci * on their priority.  Not all devices support a complete set
6258c2ecf20Sopenharmony_ci * of hardware transmit queues. For those devices the array
6268c2ecf20Sopenharmony_ci * sc_ac2q will map multiple priorities to fewer hardware queues
6278c2ecf20Sopenharmony_ci * (typically all to one hardware queue).
6288c2ecf20Sopenharmony_ci */
6298c2ecf20Sopenharmony_cistruct ath5k_txq {
6308c2ecf20Sopenharmony_ci	unsigned int		qnum;
6318c2ecf20Sopenharmony_ci	u32			*link;
6328c2ecf20Sopenharmony_ci	struct list_head	q;
6338c2ecf20Sopenharmony_ci	spinlock_t		lock;
6348c2ecf20Sopenharmony_ci	bool			setup;
6358c2ecf20Sopenharmony_ci	int			txq_len;
6368c2ecf20Sopenharmony_ci	int			txq_max;
6378c2ecf20Sopenharmony_ci	bool			txq_poll_mark;
6388c2ecf20Sopenharmony_ci	unsigned int		txq_stuck;
6398c2ecf20Sopenharmony_ci};
6408c2ecf20Sopenharmony_ci
6418c2ecf20Sopenharmony_ci/**
6428c2ecf20Sopenharmony_ci * struct ath5k_txq_info - A struct to hold TX queue's parameters
6438c2ecf20Sopenharmony_ci * @tqi_type: One of enum ath5k_tx_queue
6448c2ecf20Sopenharmony_ci * @tqi_subtype: One of enum ath5k_tx_queue_subtype
6458c2ecf20Sopenharmony_ci * @tqi_flags: TX queue flags (see above)
6468c2ecf20Sopenharmony_ci * @tqi_aifs: Arbitrated Inter-frame Space
6478c2ecf20Sopenharmony_ci * @tqi_cw_min: Minimum Contention Window
6488c2ecf20Sopenharmony_ci * @tqi_cw_max: Maximum Contention Window
6498c2ecf20Sopenharmony_ci * @tqi_cbr_period: Constant bit rate period
6508c2ecf20Sopenharmony_ci * @tqi_ready_time: Time queue waits after an event when RDYTIME is enabled
6518c2ecf20Sopenharmony_ci */
6528c2ecf20Sopenharmony_cistruct ath5k_txq_info {
6538c2ecf20Sopenharmony_ci	enum ath5k_tx_queue tqi_type;
6548c2ecf20Sopenharmony_ci	enum ath5k_tx_queue_subtype tqi_subtype;
6558c2ecf20Sopenharmony_ci	u16	tqi_flags;
6568c2ecf20Sopenharmony_ci	u8	tqi_aifs;
6578c2ecf20Sopenharmony_ci	u16	tqi_cw_min;
6588c2ecf20Sopenharmony_ci	u16	tqi_cw_max;
6598c2ecf20Sopenharmony_ci	u32	tqi_cbr_period;
6608c2ecf20Sopenharmony_ci	u32	tqi_cbr_overflow_limit;
6618c2ecf20Sopenharmony_ci	u32	tqi_burst_time;
6628c2ecf20Sopenharmony_ci	u32	tqi_ready_time;
6638c2ecf20Sopenharmony_ci};
6648c2ecf20Sopenharmony_ci
6658c2ecf20Sopenharmony_ci/**
6668c2ecf20Sopenharmony_ci * enum ath5k_pkt_type - Transmit packet types
6678c2ecf20Sopenharmony_ci * @AR5K_PKT_TYPE_NORMAL: Normal data
6688c2ecf20Sopenharmony_ci * @AR5K_PKT_TYPE_ATIM: ATIM
6698c2ecf20Sopenharmony_ci * @AR5K_PKT_TYPE_PSPOLL: PS-Poll
6708c2ecf20Sopenharmony_ci * @AR5K_PKT_TYPE_BEACON: Beacon
6718c2ecf20Sopenharmony_ci * @AR5K_PKT_TYPE_PROBE_RESP: Probe response
6728c2ecf20Sopenharmony_ci * @AR5K_PKT_TYPE_PIFS: PIFS
6738c2ecf20Sopenharmony_ci * Used on tx control descriptor
6748c2ecf20Sopenharmony_ci */
6758c2ecf20Sopenharmony_cienum ath5k_pkt_type {
6768c2ecf20Sopenharmony_ci	AR5K_PKT_TYPE_NORMAL		= 0,
6778c2ecf20Sopenharmony_ci	AR5K_PKT_TYPE_ATIM		= 1,
6788c2ecf20Sopenharmony_ci	AR5K_PKT_TYPE_PSPOLL		= 2,
6798c2ecf20Sopenharmony_ci	AR5K_PKT_TYPE_BEACON		= 3,
6808c2ecf20Sopenharmony_ci	AR5K_PKT_TYPE_PROBE_RESP	= 4,
6818c2ecf20Sopenharmony_ci	AR5K_PKT_TYPE_PIFS		= 5,
6828c2ecf20Sopenharmony_ci};
6838c2ecf20Sopenharmony_ci
6848c2ecf20Sopenharmony_ci/*
6858c2ecf20Sopenharmony_ci * TX power and TPC settings
6868c2ecf20Sopenharmony_ci */
6878c2ecf20Sopenharmony_ci#define AR5K_TXPOWER_OFDM(_r, _v)	(			\
6888c2ecf20Sopenharmony_ci	((0 & 1) << ((_v) + 6)) |				\
6898c2ecf20Sopenharmony_ci	(((ah->ah_txpower.txp_rates_power_table[(_r)]) & 0x3f) << (_v))	\
6908c2ecf20Sopenharmony_ci)
6918c2ecf20Sopenharmony_ci
6928c2ecf20Sopenharmony_ci#define AR5K_TXPOWER_CCK(_r, _v)	(			\
6938c2ecf20Sopenharmony_ci	(ah->ah_txpower.txp_rates_power_table[(_r)] & 0x3f) << (_v)	\
6948c2ecf20Sopenharmony_ci)
6958c2ecf20Sopenharmony_ci
6968c2ecf20Sopenharmony_ci
6978c2ecf20Sopenharmony_ci
6988c2ecf20Sopenharmony_ci/****************\
6998c2ecf20Sopenharmony_ci  RX DEFINITIONS
7008c2ecf20Sopenharmony_ci\****************/
7018c2ecf20Sopenharmony_ci
7028c2ecf20Sopenharmony_ci/**
7038c2ecf20Sopenharmony_ci * struct ath5k_rx_status - RX Status descriptor
7048c2ecf20Sopenharmony_ci * @rs_datalen: Data length
7058c2ecf20Sopenharmony_ci * @rs_tstamp: Timestamp
7068c2ecf20Sopenharmony_ci * @rs_status: Status code
7078c2ecf20Sopenharmony_ci * @rs_phyerr: PHY error mask
7088c2ecf20Sopenharmony_ci * @rs_rssi: RSSI in 0.5dbm units
7098c2ecf20Sopenharmony_ci * @rs_keyix: Index to the key used for decrypting
7108c2ecf20Sopenharmony_ci * @rs_rate: Rate used to decode the frame
7118c2ecf20Sopenharmony_ci * @rs_antenna: Antenna used to receive the frame
7128c2ecf20Sopenharmony_ci * @rs_more: Indicates this is a frame fragment (Fast frames)
7138c2ecf20Sopenharmony_ci */
7148c2ecf20Sopenharmony_cistruct ath5k_rx_status {
7158c2ecf20Sopenharmony_ci	u16	rs_datalen;
7168c2ecf20Sopenharmony_ci	u16	rs_tstamp;
7178c2ecf20Sopenharmony_ci	u8	rs_status;
7188c2ecf20Sopenharmony_ci	u8	rs_phyerr;
7198c2ecf20Sopenharmony_ci	s8	rs_rssi;
7208c2ecf20Sopenharmony_ci	u8	rs_keyix;
7218c2ecf20Sopenharmony_ci	u8	rs_rate;
7228c2ecf20Sopenharmony_ci	u8	rs_antenna;
7238c2ecf20Sopenharmony_ci	u8	rs_more;
7248c2ecf20Sopenharmony_ci};
7258c2ecf20Sopenharmony_ci
7268c2ecf20Sopenharmony_ci#define AR5K_RXERR_CRC		0x01
7278c2ecf20Sopenharmony_ci#define AR5K_RXERR_PHY		0x02
7288c2ecf20Sopenharmony_ci#define AR5K_RXERR_FIFO		0x04
7298c2ecf20Sopenharmony_ci#define AR5K_RXERR_DECRYPT	0x08
7308c2ecf20Sopenharmony_ci#define AR5K_RXERR_MIC		0x10
7318c2ecf20Sopenharmony_ci#define AR5K_RXKEYIX_INVALID	((u8) -1)
7328c2ecf20Sopenharmony_ci#define AR5K_TXKEYIX_INVALID	((u32) -1)
7338c2ecf20Sopenharmony_ci
7348c2ecf20Sopenharmony_ci
7358c2ecf20Sopenharmony_ci/**************************\
7368c2ecf20Sopenharmony_ci BEACON TIMERS DEFINITIONS
7378c2ecf20Sopenharmony_ci\**************************/
7388c2ecf20Sopenharmony_ci
7398c2ecf20Sopenharmony_ci#define AR5K_BEACON_PERIOD	0x0000ffff
7408c2ecf20Sopenharmony_ci#define AR5K_BEACON_ENA		0x00800000 /*enable beacon xmit*/
7418c2ecf20Sopenharmony_ci#define AR5K_BEACON_RESET_TSF	0x01000000 /*force a TSF reset*/
7428c2ecf20Sopenharmony_ci
7438c2ecf20Sopenharmony_ci
7448c2ecf20Sopenharmony_ci/*
7458c2ecf20Sopenharmony_ci * TSF to TU conversion:
7468c2ecf20Sopenharmony_ci *
7478c2ecf20Sopenharmony_ci * TSF is a 64bit value in usec (microseconds).
7488c2ecf20Sopenharmony_ci * TU is a 32bit value and defined by IEEE802.11 (page 6) as "A measurement of
7498c2ecf20Sopenharmony_ci * time equal to 1024 usec", so it's roughly milliseconds (usec / 1024).
7508c2ecf20Sopenharmony_ci */
7518c2ecf20Sopenharmony_ci#define TSF_TO_TU(_tsf) (u32)((_tsf) >> 10)
7528c2ecf20Sopenharmony_ci
7538c2ecf20Sopenharmony_ci
7548c2ecf20Sopenharmony_ci
7558c2ecf20Sopenharmony_ci/*******************************\
7568c2ecf20Sopenharmony_ci  GAIN OPTIMIZATION DEFINITIONS
7578c2ecf20Sopenharmony_ci\*******************************/
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_ci/**
7608c2ecf20Sopenharmony_ci * enum ath5k_rfgain - RF Gain optimization engine state
7618c2ecf20Sopenharmony_ci * @AR5K_RFGAIN_INACTIVE: Engine disabled
7628c2ecf20Sopenharmony_ci * @AR5K_RFGAIN_ACTIVE: Probe active
7638c2ecf20Sopenharmony_ci * @AR5K_RFGAIN_READ_REQUESTED: Probe requested
7648c2ecf20Sopenharmony_ci * @AR5K_RFGAIN_NEED_CHANGE: Gain_F needs change
7658c2ecf20Sopenharmony_ci */
7668c2ecf20Sopenharmony_cienum ath5k_rfgain {
7678c2ecf20Sopenharmony_ci	AR5K_RFGAIN_INACTIVE = 0,
7688c2ecf20Sopenharmony_ci	AR5K_RFGAIN_ACTIVE,
7698c2ecf20Sopenharmony_ci	AR5K_RFGAIN_READ_REQUESTED,
7708c2ecf20Sopenharmony_ci	AR5K_RFGAIN_NEED_CHANGE,
7718c2ecf20Sopenharmony_ci};
7728c2ecf20Sopenharmony_ci
7738c2ecf20Sopenharmony_ci/**
7748c2ecf20Sopenharmony_ci * struct ath5k_gain - RF Gain optimization engine state data
7758c2ecf20Sopenharmony_ci * @g_step_idx: Current step index
7768c2ecf20Sopenharmony_ci * @g_current: Current gain
7778c2ecf20Sopenharmony_ci * @g_target: Target gain
7788c2ecf20Sopenharmony_ci * @g_low: Low gain boundary
7798c2ecf20Sopenharmony_ci * @g_high: High gain boundary
7808c2ecf20Sopenharmony_ci * @g_f_corr: Gain_F correction
7818c2ecf20Sopenharmony_ci * @g_state: One of enum ath5k_rfgain
7828c2ecf20Sopenharmony_ci */
7838c2ecf20Sopenharmony_cistruct ath5k_gain {
7848c2ecf20Sopenharmony_ci	u8			g_step_idx;
7858c2ecf20Sopenharmony_ci	u8			g_current;
7868c2ecf20Sopenharmony_ci	u8			g_target;
7878c2ecf20Sopenharmony_ci	u8			g_low;
7888c2ecf20Sopenharmony_ci	u8			g_high;
7898c2ecf20Sopenharmony_ci	u8			g_f_corr;
7908c2ecf20Sopenharmony_ci	u8			g_state;
7918c2ecf20Sopenharmony_ci};
7928c2ecf20Sopenharmony_ci
7938c2ecf20Sopenharmony_ci
7948c2ecf20Sopenharmony_ci
7958c2ecf20Sopenharmony_ci/********************\
7968c2ecf20Sopenharmony_ci  COMMON DEFINITIONS
7978c2ecf20Sopenharmony_ci\********************/
7988c2ecf20Sopenharmony_ci
7998c2ecf20Sopenharmony_ci#define AR5K_SLOT_TIME_9	396
8008c2ecf20Sopenharmony_ci#define AR5K_SLOT_TIME_20	880
8018c2ecf20Sopenharmony_ci#define AR5K_SLOT_TIME_MAX	0xffff
8028c2ecf20Sopenharmony_ci
8038c2ecf20Sopenharmony_ci/**
8048c2ecf20Sopenharmony_ci * struct ath5k_athchan_2ghz - 2GHz to 5GHZ map for RF5111
8058c2ecf20Sopenharmony_ci * @a2_flags: Channel flags (internal)
8068c2ecf20Sopenharmony_ci * @a2_athchan: HW channel number (internal)
8078c2ecf20Sopenharmony_ci *
8088c2ecf20Sopenharmony_ci * This structure is used to map 2GHz channels to
8098c2ecf20Sopenharmony_ci * 5GHz Atheros channels on 2111 frequency converter
8108c2ecf20Sopenharmony_ci * that comes together with RF5111
8118c2ecf20Sopenharmony_ci * TODO: Clean up
8128c2ecf20Sopenharmony_ci */
8138c2ecf20Sopenharmony_cistruct ath5k_athchan_2ghz {
8148c2ecf20Sopenharmony_ci	u32	a2_flags;
8158c2ecf20Sopenharmony_ci	u16	a2_athchan;
8168c2ecf20Sopenharmony_ci};
8178c2ecf20Sopenharmony_ci
8188c2ecf20Sopenharmony_ci/**
8198c2ecf20Sopenharmony_ci * enum ath5k_dmasize -  DMA size definitions (2^(n+2))
8208c2ecf20Sopenharmony_ci * @AR5K_DMASIZE_4B: 4Bytes
8218c2ecf20Sopenharmony_ci * @AR5K_DMASIZE_8B: 8Bytes
8228c2ecf20Sopenharmony_ci * @AR5K_DMASIZE_16B: 16Bytes
8238c2ecf20Sopenharmony_ci * @AR5K_DMASIZE_32B: 32Bytes
8248c2ecf20Sopenharmony_ci * @AR5K_DMASIZE_64B: 64Bytes (Default)
8258c2ecf20Sopenharmony_ci * @AR5K_DMASIZE_128B: 128Bytes
8268c2ecf20Sopenharmony_ci * @AR5K_DMASIZE_256B: 256Bytes
8278c2ecf20Sopenharmony_ci * @AR5K_DMASIZE_512B: 512Bytes
8288c2ecf20Sopenharmony_ci *
8298c2ecf20Sopenharmony_ci * These are used to set DMA burst size on hw
8308c2ecf20Sopenharmony_ci *
8318c2ecf20Sopenharmony_ci * Note: Some platforms can't handle more than 4Bytes
8328c2ecf20Sopenharmony_ci * be careful on embedded boards.
8338c2ecf20Sopenharmony_ci */
8348c2ecf20Sopenharmony_cienum ath5k_dmasize {
8358c2ecf20Sopenharmony_ci	AR5K_DMASIZE_4B	= 0,
8368c2ecf20Sopenharmony_ci	AR5K_DMASIZE_8B,
8378c2ecf20Sopenharmony_ci	AR5K_DMASIZE_16B,
8388c2ecf20Sopenharmony_ci	AR5K_DMASIZE_32B,
8398c2ecf20Sopenharmony_ci	AR5K_DMASIZE_64B,
8408c2ecf20Sopenharmony_ci	AR5K_DMASIZE_128B,
8418c2ecf20Sopenharmony_ci	AR5K_DMASIZE_256B,
8428c2ecf20Sopenharmony_ci	AR5K_DMASIZE_512B
8438c2ecf20Sopenharmony_ci};
8448c2ecf20Sopenharmony_ci
8458c2ecf20Sopenharmony_ci
8468c2ecf20Sopenharmony_ci
8478c2ecf20Sopenharmony_ci/******************\
8488c2ecf20Sopenharmony_ci  RATE DEFINITIONS
8498c2ecf20Sopenharmony_ci\******************/
8508c2ecf20Sopenharmony_ci
8518c2ecf20Sopenharmony_ci/**
8528c2ecf20Sopenharmony_ci * DOC: Rate codes
8538c2ecf20Sopenharmony_ci *
8548c2ecf20Sopenharmony_ci * Seems the ar5xxx hardware supports up to 32 rates, indexed by 1-32.
8558c2ecf20Sopenharmony_ci *
8568c2ecf20Sopenharmony_ci * The rate code is used to get the RX rate or set the TX rate on the
8578c2ecf20Sopenharmony_ci * hardware descriptors. It is also used for internal modulation control
8588c2ecf20Sopenharmony_ci * and settings.
8598c2ecf20Sopenharmony_ci *
8608c2ecf20Sopenharmony_ci * This is the hardware rate map we are aware of (html unfriendly):
8618c2ecf20Sopenharmony_ci *
8628c2ecf20Sopenharmony_ci * Rate code	Rate (Kbps)
8638c2ecf20Sopenharmony_ci * ---------	-----------
8648c2ecf20Sopenharmony_ci * 0x01		 3000 (XR)
8658c2ecf20Sopenharmony_ci * 0x02		 1000 (XR)
8668c2ecf20Sopenharmony_ci * 0x03		  250 (XR)
8678c2ecf20Sopenharmony_ci * 0x04 - 05	-Reserved-
8688c2ecf20Sopenharmony_ci * 0x06		 2000 (XR)
8698c2ecf20Sopenharmony_ci * 0x07		  500 (XR)
8708c2ecf20Sopenharmony_ci * 0x08		48000 (OFDM)
8718c2ecf20Sopenharmony_ci * 0x09		24000 (OFDM)
8728c2ecf20Sopenharmony_ci * 0x0A		12000 (OFDM)
8738c2ecf20Sopenharmony_ci * 0x0B		 6000 (OFDM)
8748c2ecf20Sopenharmony_ci * 0x0C		54000 (OFDM)
8758c2ecf20Sopenharmony_ci * 0x0D		36000 (OFDM)
8768c2ecf20Sopenharmony_ci * 0x0E		18000 (OFDM)
8778c2ecf20Sopenharmony_ci * 0x0F		 9000 (OFDM)
8788c2ecf20Sopenharmony_ci * 0x10 - 17	-Reserved-
8798c2ecf20Sopenharmony_ci * 0x18		11000L (CCK)
8808c2ecf20Sopenharmony_ci * 0x19		 5500L (CCK)
8818c2ecf20Sopenharmony_ci * 0x1A		 2000L (CCK)
8828c2ecf20Sopenharmony_ci * 0x1B		 1000L (CCK)
8838c2ecf20Sopenharmony_ci * 0x1C		11000S (CCK)
8848c2ecf20Sopenharmony_ci * 0x1D		 5500S (CCK)
8858c2ecf20Sopenharmony_ci * 0x1E		 2000S (CCK)
8868c2ecf20Sopenharmony_ci * 0x1F		-Reserved-
8878c2ecf20Sopenharmony_ci *
8888c2ecf20Sopenharmony_ci * "S" indicates CCK rates with short preamble and "L" with long preamble.
8898c2ecf20Sopenharmony_ci *
8908c2ecf20Sopenharmony_ci * AR5211 has different rate codes for CCK (802.11B) rates. It only uses the
8918c2ecf20Sopenharmony_ci * lowest 4 bits, so they are the same as above with a 0xF mask.
8928c2ecf20Sopenharmony_ci * (0xB, 0xA, 0x9 and 0x8 for 1M, 2M, 5.5M and 11M).
8938c2ecf20Sopenharmony_ci * We handle this in ath5k_setup_bands().
8948c2ecf20Sopenharmony_ci */
8958c2ecf20Sopenharmony_ci#define AR5K_MAX_RATES 32
8968c2ecf20Sopenharmony_ci
8978c2ecf20Sopenharmony_ci/* B */
8988c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_1M	0x1B
8998c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_2M	0x1A
9008c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_5_5M	0x19
9018c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_11M	0x18
9028c2ecf20Sopenharmony_ci/* A and G */
9038c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_6M	0x0B
9048c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_9M	0x0F
9058c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_12M	0x0A
9068c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_18M	0x0E
9078c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_24M	0x09
9088c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_36M	0x0D
9098c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_48M	0x08
9108c2ecf20Sopenharmony_ci#define ATH5K_RATE_CODE_54M	0x0C
9118c2ecf20Sopenharmony_ci
9128c2ecf20Sopenharmony_ci/* Adding this flag to rate_code on B rates
9138c2ecf20Sopenharmony_ci * enables short preamble */
9148c2ecf20Sopenharmony_ci#define AR5K_SET_SHORT_PREAMBLE 0x04
9158c2ecf20Sopenharmony_ci
9168c2ecf20Sopenharmony_ci/*
9178c2ecf20Sopenharmony_ci * Crypto definitions
9188c2ecf20Sopenharmony_ci */
9198c2ecf20Sopenharmony_ci
9208c2ecf20Sopenharmony_ci#define AR5K_KEYCACHE_SIZE	8
9218c2ecf20Sopenharmony_ciextern bool ath5k_modparam_nohwcrypt;
9228c2ecf20Sopenharmony_ci
9238c2ecf20Sopenharmony_ci/***********************\
9248c2ecf20Sopenharmony_ci HW RELATED DEFINITIONS
9258c2ecf20Sopenharmony_ci\***********************/
9268c2ecf20Sopenharmony_ci
9278c2ecf20Sopenharmony_ci/*
9288c2ecf20Sopenharmony_ci * Misc definitions
9298c2ecf20Sopenharmony_ci */
9308c2ecf20Sopenharmony_ci#define	AR5K_RSSI_EP_MULTIPLIER	(1 << 7)
9318c2ecf20Sopenharmony_ci
9328c2ecf20Sopenharmony_ci#define AR5K_ASSERT_ENTRY(_e, _s) do {		\
9338c2ecf20Sopenharmony_ci	if (_e >= _s)				\
9348c2ecf20Sopenharmony_ci		return false;			\
9358c2ecf20Sopenharmony_ci} while (0)
9368c2ecf20Sopenharmony_ci
9378c2ecf20Sopenharmony_ci/*
9388c2ecf20Sopenharmony_ci * Hardware interrupt abstraction
9398c2ecf20Sopenharmony_ci */
9408c2ecf20Sopenharmony_ci
9418c2ecf20Sopenharmony_ci/**
9428c2ecf20Sopenharmony_ci * enum ath5k_int - Hardware interrupt masks helpers
9438c2ecf20Sopenharmony_ci * @AR5K_INT_RXOK: Frame successfully received
9448c2ecf20Sopenharmony_ci * @AR5K_INT_RXDESC: Request RX descriptor/Read RX descriptor
9458c2ecf20Sopenharmony_ci * @AR5K_INT_RXERR: Frame reception failed
9468c2ecf20Sopenharmony_ci * @AR5K_INT_RXNOFRM: No frame received within a specified time period
9478c2ecf20Sopenharmony_ci * @AR5K_INT_RXEOL: Reached "End Of List", means we need more RX descriptors
9488c2ecf20Sopenharmony_ci * @AR5K_INT_RXORN: Indicates we got RX FIFO overrun. Note that Rx overrun is
9498c2ecf20Sopenharmony_ci *		not always fatal, on some chips we can continue operation
9508c2ecf20Sopenharmony_ci *		without resetting the card, that's why %AR5K_INT_FATAL is not
9518c2ecf20Sopenharmony_ci *		common for all chips.
9528c2ecf20Sopenharmony_ci * @AR5K_INT_RX_ALL: Mask to identify all RX related interrupts
9538c2ecf20Sopenharmony_ci *
9548c2ecf20Sopenharmony_ci * @AR5K_INT_TXOK: Frame transmission success
9558c2ecf20Sopenharmony_ci * @AR5K_INT_TXDESC: Request TX descriptor/Read TX status descriptor
9568c2ecf20Sopenharmony_ci * @AR5K_INT_TXERR: Frame transmission failure
9578c2ecf20Sopenharmony_ci * @AR5K_INT_TXEOL: Received End Of List for VEOL (Virtual End Of List). The
9588c2ecf20Sopenharmony_ci *		Queue Control Unit (QCU) signals an EOL interrupt only if a
9598c2ecf20Sopenharmony_ci *		descriptor's LinkPtr is NULL. For more details, refer to:
9608c2ecf20Sopenharmony_ci *		"http://www.freepatentsonline.com/20030225739.html"
9618c2ecf20Sopenharmony_ci * @AR5K_INT_TXNOFRM: No frame was transmitted within a specified time period
9628c2ecf20Sopenharmony_ci * @AR5K_INT_TXURN: Indicates we got TX FIFO underrun. In such case we should
9638c2ecf20Sopenharmony_ci *		increase the TX trigger threshold.
9648c2ecf20Sopenharmony_ci * @AR5K_INT_TX_ALL: Mask to identify all TX related interrupts
9658c2ecf20Sopenharmony_ci *
9668c2ecf20Sopenharmony_ci * @AR5K_INT_MIB: Indicates the either Management Information Base counters or
9678c2ecf20Sopenharmony_ci *		one of the PHY error counters reached the maximum value and
9688c2ecf20Sopenharmony_ci *		should be read and cleared.
9698c2ecf20Sopenharmony_ci * @AR5K_INT_SWI: Software triggered interrupt.
9708c2ecf20Sopenharmony_ci * @AR5K_INT_RXPHY: RX PHY Error
9718c2ecf20Sopenharmony_ci * @AR5K_INT_RXKCM: RX Key cache miss
9728c2ecf20Sopenharmony_ci * @AR5K_INT_SWBA: SoftWare Beacon Alert - indicates its time to send a
9738c2ecf20Sopenharmony_ci *		beacon that must be handled in software. The alternative is if
9748c2ecf20Sopenharmony_ci *		you have VEOL support, in that case you let the hardware deal
9758c2ecf20Sopenharmony_ci *		with things.
9768c2ecf20Sopenharmony_ci * @AR5K_INT_BRSSI: Beacon received with an RSSI value below our threshold
9778c2ecf20Sopenharmony_ci * @AR5K_INT_BMISS: If in STA mode this indicates we have stopped seeing
9788c2ecf20Sopenharmony_ci *		beacons from the AP have associated with, we should probably
9798c2ecf20Sopenharmony_ci *		try to reassociate. When in IBSS mode this might mean we have
9808c2ecf20Sopenharmony_ci *		not received any beacons from any local stations. Note that
9818c2ecf20Sopenharmony_ci *		every station in an IBSS schedules to send beacons at the
9828c2ecf20Sopenharmony_ci *		Target Beacon Transmission Time (TBTT) with a random backoff.
9838c2ecf20Sopenharmony_ci * @AR5K_INT_BNR: Beacon queue got triggered (DMA beacon alert) while empty.
9848c2ecf20Sopenharmony_ci * @AR5K_INT_TIM: Beacon with local station's TIM bit set
9858c2ecf20Sopenharmony_ci * @AR5K_INT_DTIM: Beacon with DTIM bit and zero DTIM count received
9868c2ecf20Sopenharmony_ci * @AR5K_INT_DTIM_SYNC: DTIM sync lost
9878c2ecf20Sopenharmony_ci * @AR5K_INT_GPIO: GPIO interrupt is used for RF Kill switches connected to
9888c2ecf20Sopenharmony_ci *		our GPIO pins.
9898c2ecf20Sopenharmony_ci * @AR5K_INT_BCN_TIMEOUT: Beacon timeout, we waited after TBTT but got noting
9908c2ecf20Sopenharmony_ci * @AR5K_INT_CAB_TIMEOUT: We waited for CAB traffic after the beacon but got
9918c2ecf20Sopenharmony_ci *		nothing or an incomplete CAB frame sequence.
9928c2ecf20Sopenharmony_ci * @AR5K_INT_QCBRORN: A queue got it's CBR counter expired
9938c2ecf20Sopenharmony_ci * @AR5K_INT_QCBRURN: A queue got triggered wile empty
9948c2ecf20Sopenharmony_ci * @AR5K_INT_QTRIG: A queue got triggered
9958c2ecf20Sopenharmony_ci *
9968c2ecf20Sopenharmony_ci * @AR5K_INT_FATAL: Fatal errors were encountered, typically caused by bus/DMA
9978c2ecf20Sopenharmony_ci *		errors. Indicates we need to reset the card.
9988c2ecf20Sopenharmony_ci * @AR5K_INT_GLOBAL: Used to clear and set the IER
9998c2ecf20Sopenharmony_ci * @AR5K_INT_NOCARD: Signals the card has been removed
10008c2ecf20Sopenharmony_ci * @AR5K_INT_COMMON: Common interrupts shared among MACs with the same
10018c2ecf20Sopenharmony_ci *		bit value
10028c2ecf20Sopenharmony_ci *
10038c2ecf20Sopenharmony_ci * These are mapped to take advantage of some common bits
10048c2ecf20Sopenharmony_ci * between the MACs, to be able to set intr properties
10058c2ecf20Sopenharmony_ci * easier. Some of them are not used yet inside hw.c. Most map
10068c2ecf20Sopenharmony_ci * to the respective hw interrupt value as they are common among different
10078c2ecf20Sopenharmony_ci * MACs.
10088c2ecf20Sopenharmony_ci */
10098c2ecf20Sopenharmony_cienum ath5k_int {
10108c2ecf20Sopenharmony_ci	AR5K_INT_RXOK	= 0x00000001,
10118c2ecf20Sopenharmony_ci	AR5K_INT_RXDESC	= 0x00000002,
10128c2ecf20Sopenharmony_ci	AR5K_INT_RXERR	= 0x00000004,
10138c2ecf20Sopenharmony_ci	AR5K_INT_RXNOFRM = 0x00000008,
10148c2ecf20Sopenharmony_ci	AR5K_INT_RXEOL	= 0x00000010,
10158c2ecf20Sopenharmony_ci	AR5K_INT_RXORN	= 0x00000020,
10168c2ecf20Sopenharmony_ci	AR5K_INT_TXOK	= 0x00000040,
10178c2ecf20Sopenharmony_ci	AR5K_INT_TXDESC	= 0x00000080,
10188c2ecf20Sopenharmony_ci	AR5K_INT_TXERR	= 0x00000100,
10198c2ecf20Sopenharmony_ci	AR5K_INT_TXNOFRM = 0x00000200,
10208c2ecf20Sopenharmony_ci	AR5K_INT_TXEOL	= 0x00000400,
10218c2ecf20Sopenharmony_ci	AR5K_INT_TXURN	= 0x00000800,
10228c2ecf20Sopenharmony_ci	AR5K_INT_MIB	= 0x00001000,
10238c2ecf20Sopenharmony_ci	AR5K_INT_SWI	= 0x00002000,
10248c2ecf20Sopenharmony_ci	AR5K_INT_RXPHY	= 0x00004000,
10258c2ecf20Sopenharmony_ci	AR5K_INT_RXKCM	= 0x00008000,
10268c2ecf20Sopenharmony_ci	AR5K_INT_SWBA	= 0x00010000,
10278c2ecf20Sopenharmony_ci	AR5K_INT_BRSSI	= 0x00020000,
10288c2ecf20Sopenharmony_ci	AR5K_INT_BMISS	= 0x00040000,
10298c2ecf20Sopenharmony_ci	AR5K_INT_FATAL	= 0x00080000, /* Non common */
10308c2ecf20Sopenharmony_ci	AR5K_INT_BNR	= 0x00100000, /* Non common */
10318c2ecf20Sopenharmony_ci	AR5K_INT_TIM	= 0x00200000, /* Non common */
10328c2ecf20Sopenharmony_ci	AR5K_INT_DTIM	= 0x00400000, /* Non common */
10338c2ecf20Sopenharmony_ci	AR5K_INT_DTIM_SYNC =	0x00800000, /* Non common */
10348c2ecf20Sopenharmony_ci	AR5K_INT_GPIO	=	0x01000000,
10358c2ecf20Sopenharmony_ci	AR5K_INT_BCN_TIMEOUT =	0x02000000, /* Non common */
10368c2ecf20Sopenharmony_ci	AR5K_INT_CAB_TIMEOUT =	0x04000000, /* Non common */
10378c2ecf20Sopenharmony_ci	AR5K_INT_QCBRORN =	0x08000000, /* Non common */
10388c2ecf20Sopenharmony_ci	AR5K_INT_QCBRURN =	0x10000000, /* Non common */
10398c2ecf20Sopenharmony_ci	AR5K_INT_QTRIG	=	0x20000000, /* Non common */
10408c2ecf20Sopenharmony_ci	AR5K_INT_GLOBAL =	0x80000000,
10418c2ecf20Sopenharmony_ci
10428c2ecf20Sopenharmony_ci	AR5K_INT_TX_ALL = AR5K_INT_TXOK
10438c2ecf20Sopenharmony_ci		| AR5K_INT_TXDESC
10448c2ecf20Sopenharmony_ci		| AR5K_INT_TXERR
10458c2ecf20Sopenharmony_ci		| AR5K_INT_TXNOFRM
10468c2ecf20Sopenharmony_ci		| AR5K_INT_TXEOL
10478c2ecf20Sopenharmony_ci		| AR5K_INT_TXURN,
10488c2ecf20Sopenharmony_ci
10498c2ecf20Sopenharmony_ci	AR5K_INT_RX_ALL = AR5K_INT_RXOK
10508c2ecf20Sopenharmony_ci		| AR5K_INT_RXDESC
10518c2ecf20Sopenharmony_ci		| AR5K_INT_RXERR
10528c2ecf20Sopenharmony_ci		| AR5K_INT_RXNOFRM
10538c2ecf20Sopenharmony_ci		| AR5K_INT_RXEOL
10548c2ecf20Sopenharmony_ci		| AR5K_INT_RXORN,
10558c2ecf20Sopenharmony_ci
10568c2ecf20Sopenharmony_ci	AR5K_INT_COMMON  = AR5K_INT_RXOK
10578c2ecf20Sopenharmony_ci		| AR5K_INT_RXDESC
10588c2ecf20Sopenharmony_ci		| AR5K_INT_RXERR
10598c2ecf20Sopenharmony_ci		| AR5K_INT_RXNOFRM
10608c2ecf20Sopenharmony_ci		| AR5K_INT_RXEOL
10618c2ecf20Sopenharmony_ci		| AR5K_INT_RXORN
10628c2ecf20Sopenharmony_ci		| AR5K_INT_TXOK
10638c2ecf20Sopenharmony_ci		| AR5K_INT_TXDESC
10648c2ecf20Sopenharmony_ci		| AR5K_INT_TXERR
10658c2ecf20Sopenharmony_ci		| AR5K_INT_TXNOFRM
10668c2ecf20Sopenharmony_ci		| AR5K_INT_TXEOL
10678c2ecf20Sopenharmony_ci		| AR5K_INT_TXURN
10688c2ecf20Sopenharmony_ci		| AR5K_INT_MIB
10698c2ecf20Sopenharmony_ci		| AR5K_INT_SWI
10708c2ecf20Sopenharmony_ci		| AR5K_INT_RXPHY
10718c2ecf20Sopenharmony_ci		| AR5K_INT_RXKCM
10728c2ecf20Sopenharmony_ci		| AR5K_INT_SWBA
10738c2ecf20Sopenharmony_ci		| AR5K_INT_BRSSI
10748c2ecf20Sopenharmony_ci		| AR5K_INT_BMISS
10758c2ecf20Sopenharmony_ci		| AR5K_INT_GPIO
10768c2ecf20Sopenharmony_ci		| AR5K_INT_GLOBAL,
10778c2ecf20Sopenharmony_ci
10788c2ecf20Sopenharmony_ci	AR5K_INT_NOCARD	= 0xffffffff
10798c2ecf20Sopenharmony_ci};
10808c2ecf20Sopenharmony_ci
10818c2ecf20Sopenharmony_ci/**
10828c2ecf20Sopenharmony_ci * enum ath5k_calibration_mask - Mask which calibration is active at the moment
10838c2ecf20Sopenharmony_ci * @AR5K_CALIBRATION_FULL: Full calibration (AGC + SHORT)
10848c2ecf20Sopenharmony_ci * @AR5K_CALIBRATION_SHORT: Short calibration (NF + I/Q)
10858c2ecf20Sopenharmony_ci * @AR5K_CALIBRATION_NF: Noise Floor calibration
10868c2ecf20Sopenharmony_ci * @AR5K_CALIBRATION_ANI: Adaptive Noise Immunity
10878c2ecf20Sopenharmony_ci */
10888c2ecf20Sopenharmony_cienum ath5k_calibration_mask {
10898c2ecf20Sopenharmony_ci	AR5K_CALIBRATION_FULL = 0x01,
10908c2ecf20Sopenharmony_ci	AR5K_CALIBRATION_SHORT = 0x02,
10918c2ecf20Sopenharmony_ci	AR5K_CALIBRATION_NF = 0x04,
10928c2ecf20Sopenharmony_ci	AR5K_CALIBRATION_ANI = 0x08,
10938c2ecf20Sopenharmony_ci};
10948c2ecf20Sopenharmony_ci
10958c2ecf20Sopenharmony_ci/**
10968c2ecf20Sopenharmony_ci * enum ath5k_power_mode - Power management modes
10978c2ecf20Sopenharmony_ci * @AR5K_PM_UNDEFINED: Undefined
10988c2ecf20Sopenharmony_ci * @AR5K_PM_AUTO: Allow card to sleep if possible
10998c2ecf20Sopenharmony_ci * @AR5K_PM_AWAKE: Force card to wake up
11008c2ecf20Sopenharmony_ci * @AR5K_PM_FULL_SLEEP: Force card to full sleep (DANGEROUS)
11018c2ecf20Sopenharmony_ci * @AR5K_PM_NETWORK_SLEEP: Allow to sleep for a specified duration
11028c2ecf20Sopenharmony_ci *
11038c2ecf20Sopenharmony_ci * Currently only PM_AWAKE is used, FULL_SLEEP and NETWORK_SLEEP/AUTO
11048c2ecf20Sopenharmony_ci * are also known to have problems on some cards. This is not a big
11058c2ecf20Sopenharmony_ci * problem though because we can have almost the same effect as
11068c2ecf20Sopenharmony_ci * FULL_SLEEP by putting card on warm reset (it's almost powered down).
11078c2ecf20Sopenharmony_ci */
11088c2ecf20Sopenharmony_cienum ath5k_power_mode {
11098c2ecf20Sopenharmony_ci	AR5K_PM_UNDEFINED = 0,
11108c2ecf20Sopenharmony_ci	AR5K_PM_AUTO,
11118c2ecf20Sopenharmony_ci	AR5K_PM_AWAKE,
11128c2ecf20Sopenharmony_ci	AR5K_PM_FULL_SLEEP,
11138c2ecf20Sopenharmony_ci	AR5K_PM_NETWORK_SLEEP,
11148c2ecf20Sopenharmony_ci};
11158c2ecf20Sopenharmony_ci
11168c2ecf20Sopenharmony_ci/*
11178c2ecf20Sopenharmony_ci * These match net80211 definitions (not used in
11188c2ecf20Sopenharmony_ci * mac80211).
11198c2ecf20Sopenharmony_ci * TODO: Clean this up
11208c2ecf20Sopenharmony_ci */
11218c2ecf20Sopenharmony_ci#define AR5K_LED_INIT	0 /*IEEE80211_S_INIT*/
11228c2ecf20Sopenharmony_ci#define AR5K_LED_SCAN	1 /*IEEE80211_S_SCAN*/
11238c2ecf20Sopenharmony_ci#define AR5K_LED_AUTH	2 /*IEEE80211_S_AUTH*/
11248c2ecf20Sopenharmony_ci#define AR5K_LED_ASSOC	3 /*IEEE80211_S_ASSOC*/
11258c2ecf20Sopenharmony_ci#define AR5K_LED_RUN	4 /*IEEE80211_S_RUN*/
11268c2ecf20Sopenharmony_ci
11278c2ecf20Sopenharmony_ci/* GPIO-controlled software LED */
11288c2ecf20Sopenharmony_ci#define AR5K_SOFTLED_PIN	0
11298c2ecf20Sopenharmony_ci#define AR5K_SOFTLED_ON		0
11308c2ecf20Sopenharmony_ci#define AR5K_SOFTLED_OFF	1
11318c2ecf20Sopenharmony_ci
11328c2ecf20Sopenharmony_ci
11338c2ecf20Sopenharmony_ci/* XXX: we *may* move cap_range stuff to struct wiphy */
11348c2ecf20Sopenharmony_cistruct ath5k_capabilities {
11358c2ecf20Sopenharmony_ci	/*
11368c2ecf20Sopenharmony_ci	 * Supported PHY modes
11378c2ecf20Sopenharmony_ci	 * (ie. AR5K_MODE_11A, AR5K_MODE_11B, ...)
11388c2ecf20Sopenharmony_ci	 */
11398c2ecf20Sopenharmony_ci	DECLARE_BITMAP(cap_mode, AR5K_MODE_MAX);
11408c2ecf20Sopenharmony_ci
11418c2ecf20Sopenharmony_ci	/*
11428c2ecf20Sopenharmony_ci	 * Frequency range (without regulation restrictions)
11438c2ecf20Sopenharmony_ci	 */
11448c2ecf20Sopenharmony_ci	struct {
11458c2ecf20Sopenharmony_ci		u16	range_2ghz_min;
11468c2ecf20Sopenharmony_ci		u16	range_2ghz_max;
11478c2ecf20Sopenharmony_ci		u16	range_5ghz_min;
11488c2ecf20Sopenharmony_ci		u16	range_5ghz_max;
11498c2ecf20Sopenharmony_ci	} cap_range;
11508c2ecf20Sopenharmony_ci
11518c2ecf20Sopenharmony_ci	/*
11528c2ecf20Sopenharmony_ci	 * Values stored in the EEPROM (some of them...)
11538c2ecf20Sopenharmony_ci	 */
11548c2ecf20Sopenharmony_ci	struct ath5k_eeprom_info	cap_eeprom;
11558c2ecf20Sopenharmony_ci
11568c2ecf20Sopenharmony_ci	/*
11578c2ecf20Sopenharmony_ci	 * Queue information
11588c2ecf20Sopenharmony_ci	 */
11598c2ecf20Sopenharmony_ci	struct {
11608c2ecf20Sopenharmony_ci		u8	q_tx_num;
11618c2ecf20Sopenharmony_ci	} cap_queues;
11628c2ecf20Sopenharmony_ci
11638c2ecf20Sopenharmony_ci	bool cap_has_phyerr_counters;
11648c2ecf20Sopenharmony_ci	bool cap_has_mrr_support;
11658c2ecf20Sopenharmony_ci	bool cap_needs_2GHz_ovr;
11668c2ecf20Sopenharmony_ci};
11678c2ecf20Sopenharmony_ci
11688c2ecf20Sopenharmony_ci/* size of noise floor history (keep it a power of two) */
11698c2ecf20Sopenharmony_ci#define ATH5K_NF_CAL_HIST_MAX	8
11708c2ecf20Sopenharmony_cistruct ath5k_nfcal_hist {
11718c2ecf20Sopenharmony_ci	s16 index;				/* current index into nfval */
11728c2ecf20Sopenharmony_ci	s16 nfval[ATH5K_NF_CAL_HIST_MAX];	/* last few noise floors */
11738c2ecf20Sopenharmony_ci};
11748c2ecf20Sopenharmony_ci
11758c2ecf20Sopenharmony_ci#define ATH5K_LED_MAX_NAME_LEN 31
11768c2ecf20Sopenharmony_ci
11778c2ecf20Sopenharmony_ci/*
11788c2ecf20Sopenharmony_ci * State for LED triggers
11798c2ecf20Sopenharmony_ci */
11808c2ecf20Sopenharmony_cistruct ath5k_led {
11818c2ecf20Sopenharmony_ci	char name[ATH5K_LED_MAX_NAME_LEN + 1];	/* name of the LED in sysfs */
11828c2ecf20Sopenharmony_ci	struct ath5k_hw *ah;			/* driver state */
11838c2ecf20Sopenharmony_ci	struct led_classdev led_dev;		/* led classdev */
11848c2ecf20Sopenharmony_ci};
11858c2ecf20Sopenharmony_ci
11868c2ecf20Sopenharmony_ci/* Rfkill */
11878c2ecf20Sopenharmony_cistruct ath5k_rfkill {
11888c2ecf20Sopenharmony_ci	/* GPIO PIN for rfkill */
11898c2ecf20Sopenharmony_ci	u16 gpio;
11908c2ecf20Sopenharmony_ci	/* polarity of rfkill GPIO PIN */
11918c2ecf20Sopenharmony_ci	bool polarity;
11928c2ecf20Sopenharmony_ci	/* RFKILL toggle tasklet */
11938c2ecf20Sopenharmony_ci	struct tasklet_struct toggleq;
11948c2ecf20Sopenharmony_ci};
11958c2ecf20Sopenharmony_ci
11968c2ecf20Sopenharmony_ci/* statistics */
11978c2ecf20Sopenharmony_cistruct ath5k_statistics {
11988c2ecf20Sopenharmony_ci	/* antenna use */
11998c2ecf20Sopenharmony_ci	unsigned int antenna_rx[5];	/* frames count per antenna RX */
12008c2ecf20Sopenharmony_ci	unsigned int antenna_tx[5];	/* frames count per antenna TX */
12018c2ecf20Sopenharmony_ci
12028c2ecf20Sopenharmony_ci	/* frame errors */
12038c2ecf20Sopenharmony_ci	unsigned int rx_all_count;	/* all RX frames, including errors */
12048c2ecf20Sopenharmony_ci	unsigned int tx_all_count;	/* all TX frames, including errors */
12058c2ecf20Sopenharmony_ci	unsigned int rx_bytes_count;	/* all RX bytes, including errored pkts
12068c2ecf20Sopenharmony_ci					 * and the MAC headers for each packet
12078c2ecf20Sopenharmony_ci					 */
12088c2ecf20Sopenharmony_ci	unsigned int tx_bytes_count;	/* all TX bytes, including errored pkts
12098c2ecf20Sopenharmony_ci					 * and the MAC headers and padding for
12108c2ecf20Sopenharmony_ci					 * each packet.
12118c2ecf20Sopenharmony_ci					 */
12128c2ecf20Sopenharmony_ci	unsigned int rxerr_crc;
12138c2ecf20Sopenharmony_ci	unsigned int rxerr_phy;
12148c2ecf20Sopenharmony_ci	unsigned int rxerr_phy_code[32];
12158c2ecf20Sopenharmony_ci	unsigned int rxerr_fifo;
12168c2ecf20Sopenharmony_ci	unsigned int rxerr_decrypt;
12178c2ecf20Sopenharmony_ci	unsigned int rxerr_mic;
12188c2ecf20Sopenharmony_ci	unsigned int rxerr_proc;
12198c2ecf20Sopenharmony_ci	unsigned int rxerr_jumbo;
12208c2ecf20Sopenharmony_ci	unsigned int txerr_retry;
12218c2ecf20Sopenharmony_ci	unsigned int txerr_fifo;
12228c2ecf20Sopenharmony_ci	unsigned int txerr_filt;
12238c2ecf20Sopenharmony_ci
12248c2ecf20Sopenharmony_ci	/* MIB counters */
12258c2ecf20Sopenharmony_ci	unsigned int ack_fail;
12268c2ecf20Sopenharmony_ci	unsigned int rts_fail;
12278c2ecf20Sopenharmony_ci	unsigned int rts_ok;
12288c2ecf20Sopenharmony_ci	unsigned int fcs_error;
12298c2ecf20Sopenharmony_ci	unsigned int beacons;
12308c2ecf20Sopenharmony_ci
12318c2ecf20Sopenharmony_ci	unsigned int mib_intr;
12328c2ecf20Sopenharmony_ci	unsigned int rxorn_intr;
12338c2ecf20Sopenharmony_ci	unsigned int rxeol_intr;
12348c2ecf20Sopenharmony_ci};
12358c2ecf20Sopenharmony_ci
12368c2ecf20Sopenharmony_ci/*
12378c2ecf20Sopenharmony_ci * Misc defines
12388c2ecf20Sopenharmony_ci */
12398c2ecf20Sopenharmony_ci
12408c2ecf20Sopenharmony_ci#define AR5K_MAX_GPIO		10
12418c2ecf20Sopenharmony_ci#define AR5K_MAX_RF_BANKS	8
12428c2ecf20Sopenharmony_ci
12438c2ecf20Sopenharmony_ci#if CHAN_DEBUG
12448c2ecf20Sopenharmony_ci#define ATH_CHAN_MAX	(26 + 26 + 26 + 200 + 200)
12458c2ecf20Sopenharmony_ci#else
12468c2ecf20Sopenharmony_ci#define ATH_CHAN_MAX	(14 + 14 + 14 + 252 + 20)
12478c2ecf20Sopenharmony_ci#endif
12488c2ecf20Sopenharmony_ci
12498c2ecf20Sopenharmony_ci#define	ATH_RXBUF	40		/* number of RX buffers */
12508c2ecf20Sopenharmony_ci#define	ATH_TXBUF	200		/* number of TX buffers */
12518c2ecf20Sopenharmony_ci#define ATH_BCBUF	4		/* number of beacon buffers */
12528c2ecf20Sopenharmony_ci#define ATH5K_TXQ_LEN_MAX	(ATH_TXBUF / 4)		/* bufs per queue */
12538c2ecf20Sopenharmony_ci#define ATH5K_TXQ_LEN_LOW	(ATH5K_TXQ_LEN_MAX / 2)	/* low mark */
12548c2ecf20Sopenharmony_ci
12558c2ecf20Sopenharmony_ciDECLARE_EWMA(beacon_rssi, 10, 8)
12568c2ecf20Sopenharmony_ci
12578c2ecf20Sopenharmony_ci/* Driver state associated with an instance of a device */
12588c2ecf20Sopenharmony_cistruct ath5k_hw {
12598c2ecf20Sopenharmony_ci	struct ath_common       common;
12608c2ecf20Sopenharmony_ci
12618c2ecf20Sopenharmony_ci	struct pci_dev		*pdev;
12628c2ecf20Sopenharmony_ci	struct device		*dev;		/* for dma mapping */
12638c2ecf20Sopenharmony_ci	int irq;
12648c2ecf20Sopenharmony_ci	u16 devid;
12658c2ecf20Sopenharmony_ci	void __iomem		*iobase;	/* address of the device */
12668c2ecf20Sopenharmony_ci	struct mutex		lock;		/* dev-level lock */
12678c2ecf20Sopenharmony_ci	struct ieee80211_hw	*hw;		/* IEEE 802.11 common */
12688c2ecf20Sopenharmony_ci	struct ieee80211_supported_band sbands[NUM_NL80211_BANDS];
12698c2ecf20Sopenharmony_ci	struct ieee80211_channel channels[ATH_CHAN_MAX];
12708c2ecf20Sopenharmony_ci	struct ieee80211_rate	rates[NUM_NL80211_BANDS][AR5K_MAX_RATES];
12718c2ecf20Sopenharmony_ci	s8			rate_idx[NUM_NL80211_BANDS][AR5K_MAX_RATES];
12728c2ecf20Sopenharmony_ci	enum nl80211_iftype	opmode;
12738c2ecf20Sopenharmony_ci
12748c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH5K_DEBUG
12758c2ecf20Sopenharmony_ci	struct ath5k_dbg_info	debug;		/* debug info */
12768c2ecf20Sopenharmony_ci#endif /* CONFIG_ATH5K_DEBUG */
12778c2ecf20Sopenharmony_ci
12788c2ecf20Sopenharmony_ci	struct ath5k_buf	*bufptr;	/* allocated buffer ptr */
12798c2ecf20Sopenharmony_ci	struct ath5k_desc	*desc;		/* TX/RX descriptors */
12808c2ecf20Sopenharmony_ci	dma_addr_t		desc_daddr;	/* DMA (physical) address */
12818c2ecf20Sopenharmony_ci	size_t			desc_len;	/* size of TX/RX descriptors */
12828c2ecf20Sopenharmony_ci
12838c2ecf20Sopenharmony_ci	DECLARE_BITMAP(status, 4);
12848c2ecf20Sopenharmony_ci#define ATH_STAT_INVALID	0		/* disable hardware accesses */
12858c2ecf20Sopenharmony_ci#define ATH_STAT_LEDSOFT	2		/* enable LED gpio status */
12868c2ecf20Sopenharmony_ci#define ATH_STAT_STARTED	3		/* opened & irqs enabled */
12878c2ecf20Sopenharmony_ci#define ATH_STAT_RESET		4		/* hw reset */
12888c2ecf20Sopenharmony_ci
12898c2ecf20Sopenharmony_ci	unsigned int		filter_flags;	/* HW flags, AR5K_RX_FILTER_* */
12908c2ecf20Sopenharmony_ci	unsigned int		fif_filter_flags; /* Current FIF_* filter flags */
12918c2ecf20Sopenharmony_ci	struct ieee80211_channel *curchan;	/* current h/w channel */
12928c2ecf20Sopenharmony_ci
12938c2ecf20Sopenharmony_ci	u16			nvifs;
12948c2ecf20Sopenharmony_ci
12958c2ecf20Sopenharmony_ci	enum ath5k_int		imask;		/* interrupt mask copy */
12968c2ecf20Sopenharmony_ci
12978c2ecf20Sopenharmony_ci	spinlock_t		irqlock;
12988c2ecf20Sopenharmony_ci	bool			rx_pending;	/* rx tasklet pending */
12998c2ecf20Sopenharmony_ci	bool			tx_pending;	/* tx tasklet pending */
13008c2ecf20Sopenharmony_ci
13018c2ecf20Sopenharmony_ci	u8			bssidmask[ETH_ALEN];
13028c2ecf20Sopenharmony_ci
13038c2ecf20Sopenharmony_ci	unsigned int		led_pin,	/* GPIO pin for driving LED */
13048c2ecf20Sopenharmony_ci				led_on;		/* pin setting for LED on */
13058c2ecf20Sopenharmony_ci
13068c2ecf20Sopenharmony_ci	struct work_struct	reset_work;	/* deferred chip reset */
13078c2ecf20Sopenharmony_ci	struct work_struct	calib_work;	/* deferred phy calibration */
13088c2ecf20Sopenharmony_ci
13098c2ecf20Sopenharmony_ci	struct list_head	rxbuf;		/* receive buffer */
13108c2ecf20Sopenharmony_ci	spinlock_t		rxbuflock;
13118c2ecf20Sopenharmony_ci	u32			*rxlink;	/* link ptr in last RX desc */
13128c2ecf20Sopenharmony_ci	struct tasklet_struct	rxtq;		/* rx intr tasklet */
13138c2ecf20Sopenharmony_ci	struct ath5k_led	rx_led;		/* rx led */
13148c2ecf20Sopenharmony_ci
13158c2ecf20Sopenharmony_ci	struct list_head	txbuf;		/* transmit buffer */
13168c2ecf20Sopenharmony_ci	spinlock_t		txbuflock;
13178c2ecf20Sopenharmony_ci	unsigned int		txbuf_len;	/* buf count in txbuf list */
13188c2ecf20Sopenharmony_ci	struct ath5k_txq	txqs[AR5K_NUM_TX_QUEUES];	/* tx queues */
13198c2ecf20Sopenharmony_ci	struct tasklet_struct	txtq;		/* tx intr tasklet */
13208c2ecf20Sopenharmony_ci	struct ath5k_led	tx_led;		/* tx led */
13218c2ecf20Sopenharmony_ci
13228c2ecf20Sopenharmony_ci	struct ath5k_rfkill	rf_kill;
13238c2ecf20Sopenharmony_ci
13248c2ecf20Sopenharmony_ci	spinlock_t		block;		/* protects beacon */
13258c2ecf20Sopenharmony_ci	struct tasklet_struct	beacontq;	/* beacon intr tasklet */
13268c2ecf20Sopenharmony_ci	struct list_head	bcbuf;		/* beacon buffer */
13278c2ecf20Sopenharmony_ci	struct ieee80211_vif	*bslot[ATH_BCBUF];
13288c2ecf20Sopenharmony_ci	u16			num_ap_vifs;
13298c2ecf20Sopenharmony_ci	u16			num_adhoc_vifs;
13308c2ecf20Sopenharmony_ci	u16			num_mesh_vifs;
13318c2ecf20Sopenharmony_ci	unsigned int		bhalq,		/* SW q for outgoing beacons */
13328c2ecf20Sopenharmony_ci				bmisscount,	/* missed beacon transmits */
13338c2ecf20Sopenharmony_ci				bintval,	/* beacon interval in TU */
13348c2ecf20Sopenharmony_ci				bsent;
13358c2ecf20Sopenharmony_ci	unsigned int		nexttbtt;	/* next beacon time in TU */
13368c2ecf20Sopenharmony_ci	struct ath5k_txq	*cabq;		/* content after beacon */
13378c2ecf20Sopenharmony_ci
13388c2ecf20Sopenharmony_ci	bool			assoc;		/* associate state */
13398c2ecf20Sopenharmony_ci	bool			enable_beacon;	/* true if beacons are on */
13408c2ecf20Sopenharmony_ci
13418c2ecf20Sopenharmony_ci	struct ath5k_statistics	stats;
13428c2ecf20Sopenharmony_ci
13438c2ecf20Sopenharmony_ci	struct ath5k_ani_state	ani_state;
13448c2ecf20Sopenharmony_ci	struct tasklet_struct	ani_tasklet;	/* ANI calibration */
13458c2ecf20Sopenharmony_ci
13468c2ecf20Sopenharmony_ci	struct delayed_work	tx_complete_work;
13478c2ecf20Sopenharmony_ci
13488c2ecf20Sopenharmony_ci	struct survey_info	survey;		/* collected survey info */
13498c2ecf20Sopenharmony_ci
13508c2ecf20Sopenharmony_ci	enum ath5k_int		ah_imr;
13518c2ecf20Sopenharmony_ci
13528c2ecf20Sopenharmony_ci	struct ieee80211_channel *ah_current_channel;
13538c2ecf20Sopenharmony_ci	bool			ah_iq_cal_needed;
13548c2ecf20Sopenharmony_ci	bool			ah_single_chip;
13558c2ecf20Sopenharmony_ci
13568c2ecf20Sopenharmony_ci	enum ath5k_version	ah_version;
13578c2ecf20Sopenharmony_ci	enum ath5k_radio	ah_radio;
13588c2ecf20Sopenharmony_ci	u32			ah_mac_srev;
13598c2ecf20Sopenharmony_ci	u16			ah_mac_version;
13608c2ecf20Sopenharmony_ci	u16			ah_phy_revision;
13618c2ecf20Sopenharmony_ci	u16			ah_radio_5ghz_revision;
13628c2ecf20Sopenharmony_ci	u16			ah_radio_2ghz_revision;
13638c2ecf20Sopenharmony_ci
13648c2ecf20Sopenharmony_ci#define ah_modes		ah_capabilities.cap_mode
13658c2ecf20Sopenharmony_ci#define ah_ee_version		ah_capabilities.cap_eeprom.ee_version
13668c2ecf20Sopenharmony_ci
13678c2ecf20Sopenharmony_ci	u8			ah_retry_long;
13688c2ecf20Sopenharmony_ci	u8			ah_retry_short;
13698c2ecf20Sopenharmony_ci
13708c2ecf20Sopenharmony_ci	bool			ah_use_32khz_clock;
13718c2ecf20Sopenharmony_ci
13728c2ecf20Sopenharmony_ci	u8			ah_coverage_class;
13738c2ecf20Sopenharmony_ci	bool			ah_ack_bitrate_high;
13748c2ecf20Sopenharmony_ci	u8			ah_bwmode;
13758c2ecf20Sopenharmony_ci	bool			ah_short_slot;
13768c2ecf20Sopenharmony_ci
13778c2ecf20Sopenharmony_ci	/* Antenna Control */
13788c2ecf20Sopenharmony_ci	u32			ah_ant_ctl[AR5K_EEPROM_N_MODES][AR5K_ANT_MAX];
13798c2ecf20Sopenharmony_ci	u8			ah_ant_mode;
13808c2ecf20Sopenharmony_ci	u8			ah_tx_ant;
13818c2ecf20Sopenharmony_ci	u8			ah_def_ant;
13828c2ecf20Sopenharmony_ci
13838c2ecf20Sopenharmony_ci	struct ath5k_capabilities ah_capabilities;
13848c2ecf20Sopenharmony_ci
13858c2ecf20Sopenharmony_ci	struct ath5k_txq_info	ah_txq[AR5K_NUM_TX_QUEUES];
13868c2ecf20Sopenharmony_ci	u32			ah_txq_status;
13878c2ecf20Sopenharmony_ci	u32			ah_txq_imr_txok;
13888c2ecf20Sopenharmony_ci	u32			ah_txq_imr_txerr;
13898c2ecf20Sopenharmony_ci	u32			ah_txq_imr_txurn;
13908c2ecf20Sopenharmony_ci	u32			ah_txq_imr_txdesc;
13918c2ecf20Sopenharmony_ci	u32			ah_txq_imr_txeol;
13928c2ecf20Sopenharmony_ci	u32			ah_txq_imr_cbrorn;
13938c2ecf20Sopenharmony_ci	u32			ah_txq_imr_cbrurn;
13948c2ecf20Sopenharmony_ci	u32			ah_txq_imr_qtrig;
13958c2ecf20Sopenharmony_ci	u32			ah_txq_imr_nofrm;
13968c2ecf20Sopenharmony_ci
13978c2ecf20Sopenharmony_ci	u32			ah_txq_isr_txok_all;
13988c2ecf20Sopenharmony_ci	u32			ah_txq_isr_txurn;
13998c2ecf20Sopenharmony_ci	u32			ah_txq_isr_qcborn;
14008c2ecf20Sopenharmony_ci	u32			ah_txq_isr_qcburn;
14018c2ecf20Sopenharmony_ci	u32			ah_txq_isr_qtrig;
14028c2ecf20Sopenharmony_ci
14038c2ecf20Sopenharmony_ci	u32			*ah_rf_banks;
14048c2ecf20Sopenharmony_ci	size_t			ah_rf_banks_size;
14058c2ecf20Sopenharmony_ci	size_t			ah_rf_regs_count;
14068c2ecf20Sopenharmony_ci	struct ath5k_gain	ah_gain;
14078c2ecf20Sopenharmony_ci	u8			ah_offset[AR5K_MAX_RF_BANKS];
14088c2ecf20Sopenharmony_ci
14098c2ecf20Sopenharmony_ci
14108c2ecf20Sopenharmony_ci	struct {
14118c2ecf20Sopenharmony_ci		/* Temporary tables used for interpolation */
14128c2ecf20Sopenharmony_ci		u8		tmpL[AR5K_EEPROM_N_PD_GAINS]
14138c2ecf20Sopenharmony_ci					[AR5K_EEPROM_POWER_TABLE_SIZE];
14148c2ecf20Sopenharmony_ci		u8		tmpR[AR5K_EEPROM_N_PD_GAINS]
14158c2ecf20Sopenharmony_ci					[AR5K_EEPROM_POWER_TABLE_SIZE];
14168c2ecf20Sopenharmony_ci		u8		txp_pd_table[AR5K_EEPROM_POWER_TABLE_SIZE * 2];
14178c2ecf20Sopenharmony_ci		u16		txp_rates_power_table[AR5K_MAX_RATES];
14188c2ecf20Sopenharmony_ci		u8		txp_min_idx;
14198c2ecf20Sopenharmony_ci		bool		txp_tpc;
14208c2ecf20Sopenharmony_ci		/* Values in 0.25dB units */
14218c2ecf20Sopenharmony_ci		s16		txp_min_pwr;
14228c2ecf20Sopenharmony_ci		s16		txp_max_pwr;
14238c2ecf20Sopenharmony_ci		s16		txp_cur_pwr;
14248c2ecf20Sopenharmony_ci		/* Values in 0.5dB units */
14258c2ecf20Sopenharmony_ci		s16		txp_offset;
14268c2ecf20Sopenharmony_ci		s16		txp_ofdm;
14278c2ecf20Sopenharmony_ci		s16		txp_cck_ofdm_gainf_delta;
14288c2ecf20Sopenharmony_ci		/* Value in dB units */
14298c2ecf20Sopenharmony_ci		s16		txp_cck_ofdm_pwr_delta;
14308c2ecf20Sopenharmony_ci		bool		txp_setup;
14318c2ecf20Sopenharmony_ci		int		txp_requested;	/* Requested tx power in dBm */
14328c2ecf20Sopenharmony_ci	} ah_txpower;
14338c2ecf20Sopenharmony_ci
14348c2ecf20Sopenharmony_ci	struct ath5k_nfcal_hist ah_nfcal_hist;
14358c2ecf20Sopenharmony_ci
14368c2ecf20Sopenharmony_ci	/* average beacon RSSI in our BSS (used by ANI) */
14378c2ecf20Sopenharmony_ci	struct ewma_beacon_rssi	ah_beacon_rssi_avg;
14388c2ecf20Sopenharmony_ci
14398c2ecf20Sopenharmony_ci	/* noise floor from last periodic calibration */
14408c2ecf20Sopenharmony_ci	s32			ah_noise_floor;
14418c2ecf20Sopenharmony_ci
14428c2ecf20Sopenharmony_ci	/* Calibration timestamp */
14438c2ecf20Sopenharmony_ci	unsigned long		ah_cal_next_full;
14448c2ecf20Sopenharmony_ci	unsigned long		ah_cal_next_short;
14458c2ecf20Sopenharmony_ci	unsigned long		ah_cal_next_ani;
14468c2ecf20Sopenharmony_ci
14478c2ecf20Sopenharmony_ci	/* Calibration mask */
14488c2ecf20Sopenharmony_ci	u8			ah_cal_mask;
14498c2ecf20Sopenharmony_ci
14508c2ecf20Sopenharmony_ci	/*
14518c2ecf20Sopenharmony_ci	 * Function pointers
14528c2ecf20Sopenharmony_ci	 */
14538c2ecf20Sopenharmony_ci	int (*ah_setup_tx_desc)(struct ath5k_hw *, struct ath5k_desc *,
14548c2ecf20Sopenharmony_ci		unsigned int, unsigned int, int, enum ath5k_pkt_type,
14558c2ecf20Sopenharmony_ci		unsigned int, unsigned int, unsigned int, unsigned int,
14568c2ecf20Sopenharmony_ci		unsigned int, unsigned int, unsigned int, unsigned int);
14578c2ecf20Sopenharmony_ci	int (*ah_proc_tx_desc)(struct ath5k_hw *, struct ath5k_desc *,
14588c2ecf20Sopenharmony_ci		struct ath5k_tx_status *);
14598c2ecf20Sopenharmony_ci	int (*ah_proc_rx_desc)(struct ath5k_hw *, struct ath5k_desc *,
14608c2ecf20Sopenharmony_ci		struct ath5k_rx_status *);
14618c2ecf20Sopenharmony_ci};
14628c2ecf20Sopenharmony_ci
14638c2ecf20Sopenharmony_cistruct ath_bus_ops {
14648c2ecf20Sopenharmony_ci	enum ath_bus_type ath_bus_type;
14658c2ecf20Sopenharmony_ci	void (*read_cachesize)(struct ath_common *common, int *csz);
14668c2ecf20Sopenharmony_ci	bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data);
14678c2ecf20Sopenharmony_ci	int (*eeprom_read_mac)(struct ath5k_hw *ah, u8 *mac);
14688c2ecf20Sopenharmony_ci};
14698c2ecf20Sopenharmony_ci
14708c2ecf20Sopenharmony_ci/*
14718c2ecf20Sopenharmony_ci * Prototypes
14728c2ecf20Sopenharmony_ci */
14738c2ecf20Sopenharmony_ciextern const struct ieee80211_ops ath5k_hw_ops;
14748c2ecf20Sopenharmony_ci
14758c2ecf20Sopenharmony_ci/* Initialization and detach functions */
14768c2ecf20Sopenharmony_ciint ath5k_hw_init(struct ath5k_hw *ah);
14778c2ecf20Sopenharmony_civoid ath5k_hw_deinit(struct ath5k_hw *ah);
14788c2ecf20Sopenharmony_ci
14798c2ecf20Sopenharmony_ciint ath5k_sysfs_register(struct ath5k_hw *ah);
14808c2ecf20Sopenharmony_civoid ath5k_sysfs_unregister(struct ath5k_hw *ah);
14818c2ecf20Sopenharmony_ci
14828c2ecf20Sopenharmony_ci/*Chip id helper functions */
14838c2ecf20Sopenharmony_ciint ath5k_hw_read_srev(struct ath5k_hw *ah);
14848c2ecf20Sopenharmony_ci
14858c2ecf20Sopenharmony_ci/* LED functions */
14868c2ecf20Sopenharmony_ciint ath5k_init_leds(struct ath5k_hw *ah);
14878c2ecf20Sopenharmony_civoid ath5k_led_enable(struct ath5k_hw *ah);
14888c2ecf20Sopenharmony_civoid ath5k_led_off(struct ath5k_hw *ah);
14898c2ecf20Sopenharmony_civoid ath5k_unregister_leds(struct ath5k_hw *ah);
14908c2ecf20Sopenharmony_ci
14918c2ecf20Sopenharmony_ci
14928c2ecf20Sopenharmony_ci/* Reset Functions */
14938c2ecf20Sopenharmony_ciint ath5k_hw_nic_wakeup(struct ath5k_hw *ah, struct ieee80211_channel *channel);
14948c2ecf20Sopenharmony_ciint ath5k_hw_on_hold(struct ath5k_hw *ah);
14958c2ecf20Sopenharmony_ciint ath5k_hw_reset(struct ath5k_hw *ah, enum nl80211_iftype op_mode,
14968c2ecf20Sopenharmony_ci	   struct ieee80211_channel *channel, bool fast, bool skip_pcu);
14978c2ecf20Sopenharmony_ciint ath5k_hw_register_timeout(struct ath5k_hw *ah, u32 reg, u32 flag, u32 val,
14988c2ecf20Sopenharmony_ci			      bool is_set);
14998c2ecf20Sopenharmony_ci/* Power management functions */
15008c2ecf20Sopenharmony_ci
15018c2ecf20Sopenharmony_ci
15028c2ecf20Sopenharmony_ci/* Clock rate related functions */
15038c2ecf20Sopenharmony_ciunsigned int ath5k_hw_htoclock(struct ath5k_hw *ah, unsigned int usec);
15048c2ecf20Sopenharmony_ciunsigned int ath5k_hw_clocktoh(struct ath5k_hw *ah, unsigned int clock);
15058c2ecf20Sopenharmony_civoid ath5k_hw_set_clockrate(struct ath5k_hw *ah);
15068c2ecf20Sopenharmony_ci
15078c2ecf20Sopenharmony_ci
15088c2ecf20Sopenharmony_ci/* DMA Related Functions */
15098c2ecf20Sopenharmony_civoid ath5k_hw_start_rx_dma(struct ath5k_hw *ah);
15108c2ecf20Sopenharmony_ciu32 ath5k_hw_get_rxdp(struct ath5k_hw *ah);
15118c2ecf20Sopenharmony_ciint ath5k_hw_set_rxdp(struct ath5k_hw *ah, u32 phys_addr);
15128c2ecf20Sopenharmony_ciint ath5k_hw_start_tx_dma(struct ath5k_hw *ah, unsigned int queue);
15138c2ecf20Sopenharmony_ciint ath5k_hw_stop_beacon_queue(struct ath5k_hw *ah, unsigned int queue);
15148c2ecf20Sopenharmony_ciu32 ath5k_hw_get_txdp(struct ath5k_hw *ah, unsigned int queue);
15158c2ecf20Sopenharmony_ciint ath5k_hw_set_txdp(struct ath5k_hw *ah, unsigned int queue,
15168c2ecf20Sopenharmony_ci				u32 phys_addr);
15178c2ecf20Sopenharmony_ciint ath5k_hw_update_tx_triglevel(struct ath5k_hw *ah, bool increase);
15188c2ecf20Sopenharmony_ci/* Interrupt handling */
15198c2ecf20Sopenharmony_cibool ath5k_hw_is_intr_pending(struct ath5k_hw *ah);
15208c2ecf20Sopenharmony_ciint ath5k_hw_get_isr(struct ath5k_hw *ah, enum ath5k_int *interrupt_mask);
15218c2ecf20Sopenharmony_cienum ath5k_int ath5k_hw_set_imr(struct ath5k_hw *ah, enum ath5k_int new_mask);
15228c2ecf20Sopenharmony_civoid ath5k_hw_update_mib_counters(struct ath5k_hw *ah);
15238c2ecf20Sopenharmony_ci/* Init/Stop functions */
15248c2ecf20Sopenharmony_civoid ath5k_hw_dma_init(struct ath5k_hw *ah);
15258c2ecf20Sopenharmony_ciint ath5k_hw_dma_stop(struct ath5k_hw *ah);
15268c2ecf20Sopenharmony_ci
15278c2ecf20Sopenharmony_ci/* EEPROM access functions */
15288c2ecf20Sopenharmony_ciint ath5k_eeprom_init(struct ath5k_hw *ah);
15298c2ecf20Sopenharmony_civoid ath5k_eeprom_detach(struct ath5k_hw *ah);
15308c2ecf20Sopenharmony_ciint ath5k_eeprom_mode_from_channel(struct ath5k_hw *ah,
15318c2ecf20Sopenharmony_ci		struct ieee80211_channel *channel);
15328c2ecf20Sopenharmony_ci
15338c2ecf20Sopenharmony_ci/* Protocol Control Unit Functions */
15348c2ecf20Sopenharmony_ci/* Helpers */
15358c2ecf20Sopenharmony_ciint ath5k_hw_get_frame_duration(struct ath5k_hw *ah, enum nl80211_band band,
15368c2ecf20Sopenharmony_ci		int len, struct ieee80211_rate *rate, bool shortpre);
15378c2ecf20Sopenharmony_ciunsigned int ath5k_hw_get_default_slottime(struct ath5k_hw *ah);
15388c2ecf20Sopenharmony_ciunsigned int ath5k_hw_get_default_sifs(struct ath5k_hw *ah);
15398c2ecf20Sopenharmony_ciint ath5k_hw_set_opmode(struct ath5k_hw *ah, enum nl80211_iftype opmode);
15408c2ecf20Sopenharmony_civoid ath5k_hw_set_coverage_class(struct ath5k_hw *ah, u8 coverage_class);
15418c2ecf20Sopenharmony_ci/* RX filter control*/
15428c2ecf20Sopenharmony_ciint ath5k_hw_set_lladdr(struct ath5k_hw *ah, const u8 *mac);
15438c2ecf20Sopenharmony_civoid ath5k_hw_set_bssid(struct ath5k_hw *ah);
15448c2ecf20Sopenharmony_civoid ath5k_hw_set_bssid_mask(struct ath5k_hw *ah, const u8 *mask);
15458c2ecf20Sopenharmony_civoid ath5k_hw_set_mcast_filter(struct ath5k_hw *ah, u32 filter0, u32 filter1);
15468c2ecf20Sopenharmony_ciu32 ath5k_hw_get_rx_filter(struct ath5k_hw *ah);
15478c2ecf20Sopenharmony_civoid ath5k_hw_set_rx_filter(struct ath5k_hw *ah, u32 filter);
15488c2ecf20Sopenharmony_ci/* Receive (DRU) start/stop functions */
15498c2ecf20Sopenharmony_civoid ath5k_hw_start_rx_pcu(struct ath5k_hw *ah);
15508c2ecf20Sopenharmony_civoid ath5k_hw_stop_rx_pcu(struct ath5k_hw *ah);
15518c2ecf20Sopenharmony_ci/* Beacon control functions */
15528c2ecf20Sopenharmony_ciu64 ath5k_hw_get_tsf64(struct ath5k_hw *ah);
15538c2ecf20Sopenharmony_civoid ath5k_hw_set_tsf64(struct ath5k_hw *ah, u64 tsf64);
15548c2ecf20Sopenharmony_civoid ath5k_hw_reset_tsf(struct ath5k_hw *ah);
15558c2ecf20Sopenharmony_civoid ath5k_hw_init_beacon_timers(struct ath5k_hw *ah, u32 next_beacon,
15568c2ecf20Sopenharmony_ci							u32 interval);
15578c2ecf20Sopenharmony_cibool ath5k_hw_check_beacon_timers(struct ath5k_hw *ah, int intval);
15588c2ecf20Sopenharmony_ci/* Init function */
15598c2ecf20Sopenharmony_civoid ath5k_hw_pcu_init(struct ath5k_hw *ah, enum nl80211_iftype op_mode);
15608c2ecf20Sopenharmony_ci
15618c2ecf20Sopenharmony_ci/* Queue Control Unit, DFS Control Unit Functions */
15628c2ecf20Sopenharmony_ciint ath5k_hw_get_tx_queueprops(struct ath5k_hw *ah, int queue,
15638c2ecf20Sopenharmony_ci			       struct ath5k_txq_info *queue_info);
15648c2ecf20Sopenharmony_ciint ath5k_hw_set_tx_queueprops(struct ath5k_hw *ah, int queue,
15658c2ecf20Sopenharmony_ci			       const struct ath5k_txq_info *queue_info);
15668c2ecf20Sopenharmony_ciint ath5k_hw_setup_tx_queue(struct ath5k_hw *ah,
15678c2ecf20Sopenharmony_ci			    enum ath5k_tx_queue queue_type,
15688c2ecf20Sopenharmony_ci			    struct ath5k_txq_info *queue_info);
15698c2ecf20Sopenharmony_civoid ath5k_hw_set_tx_retry_limits(struct ath5k_hw *ah,
15708c2ecf20Sopenharmony_ci				  unsigned int queue);
15718c2ecf20Sopenharmony_ciu32 ath5k_hw_num_tx_pending(struct ath5k_hw *ah, unsigned int queue);
15728c2ecf20Sopenharmony_civoid ath5k_hw_release_tx_queue(struct ath5k_hw *ah, unsigned int queue);
15738c2ecf20Sopenharmony_ciint ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue);
15748c2ecf20Sopenharmony_ciint ath5k_hw_set_ifs_intervals(struct ath5k_hw *ah, unsigned int slot_time);
15758c2ecf20Sopenharmony_ci/* Init function */
15768c2ecf20Sopenharmony_ciint ath5k_hw_init_queues(struct ath5k_hw *ah);
15778c2ecf20Sopenharmony_ci
15788c2ecf20Sopenharmony_ci/* Hardware Descriptor Functions */
15798c2ecf20Sopenharmony_ciint ath5k_hw_init_desc_functions(struct ath5k_hw *ah);
15808c2ecf20Sopenharmony_ciint ath5k_hw_setup_rx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
15818c2ecf20Sopenharmony_ci			   u32 size, unsigned int flags);
15828c2ecf20Sopenharmony_ciint ath5k_hw_setup_mrr_tx_desc(struct ath5k_hw *ah, struct ath5k_desc *desc,
15838c2ecf20Sopenharmony_ci	unsigned int tx_rate1, u_int tx_tries1, u_int tx_rate2,
15848c2ecf20Sopenharmony_ci	u_int tx_tries2, unsigned int tx_rate3, u_int tx_tries3);
15858c2ecf20Sopenharmony_ci
15868c2ecf20Sopenharmony_ci
15878c2ecf20Sopenharmony_ci/* GPIO Functions */
15888c2ecf20Sopenharmony_civoid ath5k_hw_set_ledstate(struct ath5k_hw *ah, unsigned int state);
15898c2ecf20Sopenharmony_ciint ath5k_hw_set_gpio_input(struct ath5k_hw *ah, u32 gpio);
15908c2ecf20Sopenharmony_ciint ath5k_hw_set_gpio_output(struct ath5k_hw *ah, u32 gpio);
15918c2ecf20Sopenharmony_ciu32 ath5k_hw_get_gpio(struct ath5k_hw *ah, u32 gpio);
15928c2ecf20Sopenharmony_ciint ath5k_hw_set_gpio(struct ath5k_hw *ah, u32 gpio, u32 val);
15938c2ecf20Sopenharmony_civoid ath5k_hw_set_gpio_intr(struct ath5k_hw *ah, unsigned int gpio,
15948c2ecf20Sopenharmony_ci			    u32 interrupt_level);
15958c2ecf20Sopenharmony_ci
15968c2ecf20Sopenharmony_ci
15978c2ecf20Sopenharmony_ci/* RFkill Functions */
15988c2ecf20Sopenharmony_civoid ath5k_rfkill_hw_start(struct ath5k_hw *ah);
15998c2ecf20Sopenharmony_civoid ath5k_rfkill_hw_stop(struct ath5k_hw *ah);
16008c2ecf20Sopenharmony_ci
16018c2ecf20Sopenharmony_ci
16028c2ecf20Sopenharmony_ci/* Misc functions TODO: Cleanup */
16038c2ecf20Sopenharmony_ciint ath5k_hw_set_capabilities(struct ath5k_hw *ah);
16048c2ecf20Sopenharmony_ciint ath5k_hw_enable_pspoll(struct ath5k_hw *ah, u8 *bssid, u16 assoc_id);
16058c2ecf20Sopenharmony_ciint ath5k_hw_disable_pspoll(struct ath5k_hw *ah);
16068c2ecf20Sopenharmony_ci
16078c2ecf20Sopenharmony_ci
16088c2ecf20Sopenharmony_ci/* Initial register settings functions */
16098c2ecf20Sopenharmony_ciint ath5k_hw_write_initvals(struct ath5k_hw *ah, u8 mode, bool change_channel);
16108c2ecf20Sopenharmony_ci
16118c2ecf20Sopenharmony_ci
16128c2ecf20Sopenharmony_ci/* PHY functions */
16138c2ecf20Sopenharmony_ci/* Misc PHY functions */
16148c2ecf20Sopenharmony_ciu16 ath5k_hw_radio_revision(struct ath5k_hw *ah, enum nl80211_band band);
16158c2ecf20Sopenharmony_ciint ath5k_hw_phy_disable(struct ath5k_hw *ah);
16168c2ecf20Sopenharmony_ci/* Gain_F optimization */
16178c2ecf20Sopenharmony_cienum ath5k_rfgain ath5k_hw_gainf_calibrate(struct ath5k_hw *ah);
16188c2ecf20Sopenharmony_ciint ath5k_hw_rfgain_opt_init(struct ath5k_hw *ah);
16198c2ecf20Sopenharmony_ci/* PHY/RF channel functions */
16208c2ecf20Sopenharmony_cibool ath5k_channel_ok(struct ath5k_hw *ah, struct ieee80211_channel *channel);
16218c2ecf20Sopenharmony_ci/* PHY calibration */
16228c2ecf20Sopenharmony_civoid ath5k_hw_init_nfcal_hist(struct ath5k_hw *ah);
16238c2ecf20Sopenharmony_ciint ath5k_hw_phy_calibrate(struct ath5k_hw *ah,
16248c2ecf20Sopenharmony_ci			   struct ieee80211_channel *channel);
16258c2ecf20Sopenharmony_civoid ath5k_hw_update_noise_floor(struct ath5k_hw *ah);
16268c2ecf20Sopenharmony_ci/* Spur mitigation */
16278c2ecf20Sopenharmony_cibool ath5k_hw_chan_has_spur_noise(struct ath5k_hw *ah,
16288c2ecf20Sopenharmony_ci				  struct ieee80211_channel *channel);
16298c2ecf20Sopenharmony_ci/* Antenna control */
16308c2ecf20Sopenharmony_civoid ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode);
16318c2ecf20Sopenharmony_civoid ath5k_hw_set_antenna_switch(struct ath5k_hw *ah, u8 ee_mode);
16328c2ecf20Sopenharmony_ci/* TX power setup */
16338c2ecf20Sopenharmony_ciint ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower);
16348c2ecf20Sopenharmony_ci/* Init function */
16358c2ecf20Sopenharmony_ciint ath5k_hw_phy_init(struct ath5k_hw *ah, struct ieee80211_channel *channel,
16368c2ecf20Sopenharmony_ci				u8 mode, bool fast);
16378c2ecf20Sopenharmony_ci
16388c2ecf20Sopenharmony_ci/*
16398c2ecf20Sopenharmony_ci * Functions used internally
16408c2ecf20Sopenharmony_ci */
16418c2ecf20Sopenharmony_ci
16428c2ecf20Sopenharmony_cistatic inline struct ath_common *ath5k_hw_common(struct ath5k_hw *ah)
16438c2ecf20Sopenharmony_ci{
16448c2ecf20Sopenharmony_ci	return &ah->common;
16458c2ecf20Sopenharmony_ci}
16468c2ecf20Sopenharmony_ci
16478c2ecf20Sopenharmony_cistatic inline struct ath_regulatory *ath5k_hw_regulatory(struct ath5k_hw *ah)
16488c2ecf20Sopenharmony_ci{
16498c2ecf20Sopenharmony_ci	return &(ath5k_hw_common(ah)->regulatory);
16508c2ecf20Sopenharmony_ci}
16518c2ecf20Sopenharmony_ci
16528c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH5K_AHB
16538c2ecf20Sopenharmony_ci#define AR5K_AR2315_PCI_BASE	((void __iomem *)0xb0100000)
16548c2ecf20Sopenharmony_ci
16558c2ecf20Sopenharmony_cistatic inline void __iomem *ath5k_ahb_reg(struct ath5k_hw *ah, u16 reg)
16568c2ecf20Sopenharmony_ci{
16578c2ecf20Sopenharmony_ci	/* On AR2315 and AR2317 the PCI clock domain registers
16588c2ecf20Sopenharmony_ci	 * are outside of the WMAC register space */
16598c2ecf20Sopenharmony_ci	if (unlikely((reg >= 0x4000) && (reg < 0x5000) &&
16608c2ecf20Sopenharmony_ci	    (ah->ah_mac_srev >= AR5K_SREV_AR2315_R6)))
16618c2ecf20Sopenharmony_ci		return AR5K_AR2315_PCI_BASE + reg;
16628c2ecf20Sopenharmony_ci
16638c2ecf20Sopenharmony_ci	return ah->iobase + reg;
16648c2ecf20Sopenharmony_ci}
16658c2ecf20Sopenharmony_ci
16668c2ecf20Sopenharmony_cistatic inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
16678c2ecf20Sopenharmony_ci{
16688c2ecf20Sopenharmony_ci	return ioread32(ath5k_ahb_reg(ah, reg));
16698c2ecf20Sopenharmony_ci}
16708c2ecf20Sopenharmony_ci
16718c2ecf20Sopenharmony_cistatic inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
16728c2ecf20Sopenharmony_ci{
16738c2ecf20Sopenharmony_ci	iowrite32(val, ath5k_ahb_reg(ah, reg));
16748c2ecf20Sopenharmony_ci}
16758c2ecf20Sopenharmony_ci
16768c2ecf20Sopenharmony_ci#else
16778c2ecf20Sopenharmony_ci
16788c2ecf20Sopenharmony_cistatic inline u32 ath5k_hw_reg_read(struct ath5k_hw *ah, u16 reg)
16798c2ecf20Sopenharmony_ci{
16808c2ecf20Sopenharmony_ci	return ioread32(ah->iobase + reg);
16818c2ecf20Sopenharmony_ci}
16828c2ecf20Sopenharmony_ci
16838c2ecf20Sopenharmony_cistatic inline void ath5k_hw_reg_write(struct ath5k_hw *ah, u32 val, u16 reg)
16848c2ecf20Sopenharmony_ci{
16858c2ecf20Sopenharmony_ci	iowrite32(val, ah->iobase + reg);
16868c2ecf20Sopenharmony_ci}
16878c2ecf20Sopenharmony_ci
16888c2ecf20Sopenharmony_ci#endif
16898c2ecf20Sopenharmony_ci
16908c2ecf20Sopenharmony_cistatic inline enum ath_bus_type ath5k_get_bus_type(struct ath5k_hw *ah)
16918c2ecf20Sopenharmony_ci{
16928c2ecf20Sopenharmony_ci	return ath5k_hw_common(ah)->bus_ops->ath_bus_type;
16938c2ecf20Sopenharmony_ci}
16948c2ecf20Sopenharmony_ci
16958c2ecf20Sopenharmony_cistatic inline void ath5k_read_cachesize(struct ath_common *common, int *csz)
16968c2ecf20Sopenharmony_ci{
16978c2ecf20Sopenharmony_ci	common->bus_ops->read_cachesize(common, csz);
16988c2ecf20Sopenharmony_ci}
16998c2ecf20Sopenharmony_ci
17008c2ecf20Sopenharmony_cistatic inline bool ath5k_hw_nvram_read(struct ath5k_hw *ah, u32 off, u16 *data)
17018c2ecf20Sopenharmony_ci{
17028c2ecf20Sopenharmony_ci	struct ath_common *common = ath5k_hw_common(ah);
17038c2ecf20Sopenharmony_ci	return common->bus_ops->eeprom_read(common, off, data);
17048c2ecf20Sopenharmony_ci}
17058c2ecf20Sopenharmony_ci
17068c2ecf20Sopenharmony_cistatic inline u32 ath5k_hw_bitswap(u32 val, unsigned int bits)
17078c2ecf20Sopenharmony_ci{
17088c2ecf20Sopenharmony_ci	u32 retval = 0, bit, i;
17098c2ecf20Sopenharmony_ci
17108c2ecf20Sopenharmony_ci	for (i = 0; i < bits; i++) {
17118c2ecf20Sopenharmony_ci		bit = (val >> i) & 1;
17128c2ecf20Sopenharmony_ci		retval = (retval << 1) | bit;
17138c2ecf20Sopenharmony_ci	}
17148c2ecf20Sopenharmony_ci
17158c2ecf20Sopenharmony_ci	return retval;
17168c2ecf20Sopenharmony_ci}
17178c2ecf20Sopenharmony_ci
17188c2ecf20Sopenharmony_ci#endif
1719