1203c4805SLuis R. Rodriguez /* 2b3950e6aSLuis R. Rodriguez * Copyright (c) 2008-2010 Atheros Communications Inc. 3203c4805SLuis R. Rodriguez * 4203c4805SLuis R. Rodriguez * Permission to use, copy, modify, and/or distribute this software for any 5203c4805SLuis R. Rodriguez * purpose with or without fee is hereby granted, provided that the above 6203c4805SLuis R. Rodriguez * copyright notice and this permission notice appear in all copies. 7203c4805SLuis R. Rodriguez * 8203c4805SLuis R. Rodriguez * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 9203c4805SLuis R. Rodriguez * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 10203c4805SLuis R. Rodriguez * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 11203c4805SLuis R. Rodriguez * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 12203c4805SLuis R. Rodriguez * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 13203c4805SLuis R. Rodriguez * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 14203c4805SLuis R. Rodriguez * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15203c4805SLuis R. Rodriguez */ 16203c4805SLuis R. Rodriguez 17203c4805SLuis R. Rodriguez #ifndef HW_H 18203c4805SLuis R. Rodriguez #define HW_H 19203c4805SLuis R. Rodriguez 20203c4805SLuis R. Rodriguez #include <linux/if_ether.h> 21203c4805SLuis R. Rodriguez #include <linux/delay.h> 22203c4805SLuis R. Rodriguez #include <linux/io.h> 23203c4805SLuis R. Rodriguez 24203c4805SLuis R. Rodriguez #include "mac.h" 25203c4805SLuis R. Rodriguez #include "ani.h" 26203c4805SLuis R. Rodriguez #include "eeprom.h" 27203c4805SLuis R. Rodriguez #include "calib.h" 28203c4805SLuis R. Rodriguez #include "reg.h" 29203c4805SLuis R. Rodriguez #include "phy.h" 30af03abecSLuis R. Rodriguez #include "btcoex.h" 31203c4805SLuis R. Rodriguez 32203c4805SLuis R. Rodriguez #include "../regd.h" 33203c4805SLuis R. Rodriguez 34203c4805SLuis R. Rodriguez #define ATHEROS_VENDOR_ID 0x168c 357976b426SLuis R. Rodriguez 36203c4805SLuis R. Rodriguez #define AR5416_DEVID_PCI 0x0023 37203c4805SLuis R. Rodriguez #define AR5416_DEVID_PCIE 0x0024 38203c4805SLuis R. Rodriguez #define AR9160_DEVID_PCI 0x0027 39203c4805SLuis R. Rodriguez #define AR9280_DEVID_PCI 0x0029 40203c4805SLuis R. Rodriguez #define AR9280_DEVID_PCIE 0x002a 41203c4805SLuis R. Rodriguez #define AR9285_DEVID_PCIE 0x002b 425ffaf8a3SLuis R. Rodriguez #define AR2427_DEVID_PCIE 0x002c 43db3cc53aSSenthil Balasubramanian #define AR9287_DEVID_PCI 0x002d 44db3cc53aSSenthil Balasubramanian #define AR9287_DEVID_PCIE 0x002e 45db3cc53aSSenthil Balasubramanian #define AR9300_DEVID_PCIE 0x0030 463050c914SVasanthakumar Thiagarajan #define AR9300_DEVID_AR9485_PCIE 0x0032 477976b426SLuis R. Rodriguez 48203c4805SLuis R. Rodriguez #define AR5416_AR9100_DEVID 0x000b 497976b426SLuis R. Rodriguez 50203c4805SLuis R. Rodriguez #define AR_SUBVENDOR_ID_NOG 0x0e11 51203c4805SLuis R. Rodriguez #define AR_SUBVENDOR_ID_NEW_A 0x7065 52203c4805SLuis R. Rodriguez #define AR5416_MAGIC 0x19641014 53203c4805SLuis R. Rodriguez 54fe12946eSVasanthakumar Thiagarajan #define AR9280_COEX2WIRE_SUBSYSID 0x309b 55fe12946eSVasanthakumar Thiagarajan #define AT9285_COEX3WIRE_SA_SUBSYSID 0x30aa 56fe12946eSVasanthakumar Thiagarajan #define AT9285_COEX3WIRE_DA_SUBSYSID 0x30ab 57fe12946eSVasanthakumar Thiagarajan 58e3d01bfcSLuis R. Rodriguez #define ATH_AMPDU_LIMIT_MAX (64 * 1024 - 1) 59e3d01bfcSLuis R. Rodriguez 60cfe8cba9SLuis R. Rodriguez #define ATH_DEFAULT_NOISE_FLOOR -95 61cfe8cba9SLuis R. Rodriguez 6204658fbaSJohn W. Linville #define ATH9K_RSSI_BAD -128 63990b70abSLuis R. Rodriguez 64cac4220bSFelix Fietkau #define ATH9K_NUM_CHANNELS 38 65cac4220bSFelix Fietkau 66203c4805SLuis R. Rodriguez /* Register read/write primitives */ 679e4bffd2SLuis R. Rodriguez #define REG_WRITE(_ah, _reg, _val) \ 68f9f84e96SFelix Fietkau (_ah)->reg_ops.write((_ah), (_val), (_reg)) 699e4bffd2SLuis R. Rodriguez 709e4bffd2SLuis R. Rodriguez #define REG_READ(_ah, _reg) \ 71f9f84e96SFelix Fietkau (_ah)->reg_ops.read((_ah), (_reg)) 72203c4805SLuis R. Rodriguez 7309a525d3SSujith Manoharan #define REG_READ_MULTI(_ah, _addr, _val, _cnt) \ 74f9f84e96SFelix Fietkau (_ah)->reg_ops.multi_read((_ah), (_addr), (_val), (_cnt)) 7509a525d3SSujith Manoharan 76845e03c9SFelix Fietkau #define REG_RMW(_ah, _reg, _set, _clr) \ 77845e03c9SFelix Fietkau (_ah)->reg_ops.rmw((_ah), (_reg), (_set), (_clr)) 78845e03c9SFelix Fietkau 7920b3efd9SSujith #define ENABLE_REGWRITE_BUFFER(_ah) \ 8020b3efd9SSujith do { \ 81f9f84e96SFelix Fietkau if ((_ah)->reg_ops.enable_write_buffer) \ 82f9f84e96SFelix Fietkau (_ah)->reg_ops.enable_write_buffer((_ah)); \ 8320b3efd9SSujith } while (0) 8420b3efd9SSujith 8520b3efd9SSujith #define REGWRITE_BUFFER_FLUSH(_ah) \ 8620b3efd9SSujith do { \ 87f9f84e96SFelix Fietkau if ((_ah)->reg_ops.write_flush) \ 88f9f84e96SFelix Fietkau (_ah)->reg_ops.write_flush((_ah)); \ 8920b3efd9SSujith } while (0) 9020b3efd9SSujith 91203c4805SLuis R. Rodriguez #define SM(_v, _f) (((_v) << _f##_S) & _f) 92203c4805SLuis R. Rodriguez #define MS(_v, _f) (((_v) & _f) >> _f##_S) 93203c4805SLuis R. Rodriguez #define REG_RMW_FIELD(_a, _r, _f, _v) \ 94845e03c9SFelix Fietkau REG_RMW(_a, _r, (((_v) << _f##_S) & _f), (_f)) 951547da37SLuis R. Rodriguez #define REG_READ_FIELD(_a, _r, _f) \ 961547da37SLuis R. Rodriguez (((REG_READ(_a, _r) & _f) >> _f##_S)) 97203c4805SLuis R. Rodriguez #define REG_SET_BIT(_a, _r, _f) \ 98845e03c9SFelix Fietkau REG_RMW(_a, _r, (_f), 0) 99203c4805SLuis R. Rodriguez #define REG_CLR_BIT(_a, _r, _f) \ 100845e03c9SFelix Fietkau REG_RMW(_a, _r, 0, (_f)) 101203c4805SLuis R. Rodriguez 102203c4805SLuis R. Rodriguez #define DO_DELAY(x) do { \ 103e7fc6338SRajkumar Manoharan if (((++(x) % 64) == 0) && \ 104e7fc6338SRajkumar Manoharan (ath9k_hw_common(ah)->bus_ops->ath_bus_type \ 105e7fc6338SRajkumar Manoharan != ATH_USB)) \ 106203c4805SLuis R. Rodriguez udelay(1); \ 107203c4805SLuis R. Rodriguez } while (0) 108203c4805SLuis R. Rodriguez 109a9b6b256SFelix Fietkau #define REG_WRITE_ARRAY(iniarray, column, regWr) \ 110a9b6b256SFelix Fietkau ath9k_hw_write_array(ah, iniarray, column, &(regWr)) 111203c4805SLuis R. Rodriguez 112203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_OUTPUT 0 113203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED 1 114203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_PCIE_POWER_LED 2 115203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_TX_FRAME 3 1161773912bSVasanthakumar Thiagarajan #define AR_GPIO_OUTPUT_MUX_AS_RX_CLEAR_EXTERNAL 4 117203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_MAC_NETWORK_LED 5 118203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_MAC_POWER_LED 6 119203c4805SLuis R. Rodriguez 120203c4805SLuis R. Rodriguez #define AR_GPIOD_MASK 0x00001FFF 121203c4805SLuis R. Rodriguez #define AR_GPIO_BIT(_gpio) (1 << (_gpio)) 122203c4805SLuis R. Rodriguez 123203c4805SLuis R. Rodriguez #define BASE_ACTIVATE_DELAY 100 12463a75b91SSenthil Balasubramanian #define RTC_PLL_SETTLE_DELAY 100 125203c4805SLuis R. Rodriguez #define COEF_SCALE_S 24 126203c4805SLuis R. Rodriguez #define HT40_CHANNEL_CENTER_SHIFT 10 127203c4805SLuis R. Rodriguez 128203c4805SLuis R. Rodriguez #define ATH9K_ANTENNA0_CHAINMASK 0x1 129203c4805SLuis R. Rodriguez #define ATH9K_ANTENNA1_CHAINMASK 0x2 130203c4805SLuis R. Rodriguez 131203c4805SLuis R. Rodriguez #define ATH9K_NUM_DMA_DEBUG_REGS 8 132203c4805SLuis R. Rodriguez #define ATH9K_NUM_QUEUES 10 133203c4805SLuis R. Rodriguez 134203c4805SLuis R. Rodriguez #define MAX_RATE_POWER 63 135203c4805SLuis R. Rodriguez #define AH_WAIT_TIMEOUT 100000 /* (us) */ 136f9b604f6SGabor Juhos #define AH_TSF_WRITE_TIMEOUT 100 /* (us) */ 137203c4805SLuis R. Rodriguez #define AH_TIME_QUANTUM 10 138203c4805SLuis R. Rodriguez #define AR_KEYTABLE_SIZE 128 139d8caa839SSujith #define POWER_UP_TIME 10000 140203c4805SLuis R. Rodriguez #define SPUR_RSSI_THRESH 40 141203c4805SLuis R. Rodriguez 142203c4805SLuis R. Rodriguez #define CAB_TIMEOUT_VAL 10 143203c4805SLuis R. Rodriguez #define BEACON_TIMEOUT_VAL 10 144203c4805SLuis R. Rodriguez #define MIN_BEACON_TIMEOUT_VAL 1 145203c4805SLuis R. Rodriguez #define SLEEP_SLOP 3 146203c4805SLuis R. Rodriguez 147203c4805SLuis R. Rodriguez #define INIT_CONFIG_STATUS 0x00000000 148203c4805SLuis R. Rodriguez #define INIT_RSSI_THR 0x00000700 149203c4805SLuis R. Rodriguez #define INIT_BCON_CNTRL_REG 0x00000000 150203c4805SLuis R. Rodriguez 151203c4805SLuis R. Rodriguez #define TU_TO_USEC(_tu) ((_tu) << 10) 152203c4805SLuis R. Rodriguez 153ceb26445SVasanthakumar Thiagarajan #define ATH9K_HW_RX_HP_QDEPTH 16 154ceb26445SVasanthakumar Thiagarajan #define ATH9K_HW_RX_LP_QDEPTH 128 155ceb26445SVasanthakumar Thiagarajan 156717f6bedSFelix Fietkau #define PAPRD_GAIN_TABLE_ENTRIES 32 157717f6bedSFelix Fietkau #define PAPRD_TABLE_SZ 24 158717f6bedSFelix Fietkau 159066dae93SFelix Fietkau enum ath_hw_txq_subtype { 160066dae93SFelix Fietkau ATH_TXQ_AC_BE = 0, 161066dae93SFelix Fietkau ATH_TXQ_AC_BK = 1, 162066dae93SFelix Fietkau ATH_TXQ_AC_VI = 2, 163066dae93SFelix Fietkau ATH_TXQ_AC_VO = 3, 164066dae93SFelix Fietkau }; 165066dae93SFelix Fietkau 16613ce3e99SLuis R. Rodriguez enum ath_ini_subsys { 16713ce3e99SLuis R. Rodriguez ATH_INI_PRE = 0, 16813ce3e99SLuis R. Rodriguez ATH_INI_CORE, 16913ce3e99SLuis R. Rodriguez ATH_INI_POST, 17013ce3e99SLuis R. Rodriguez ATH_INI_NUM_SPLIT, 17113ce3e99SLuis R. Rodriguez }; 17213ce3e99SLuis R. Rodriguez 173203c4805SLuis R. Rodriguez enum ath9k_hw_caps { 174364734faSFelix Fietkau ATH9K_HW_CAP_HT = BIT(0), 175364734faSFelix Fietkau ATH9K_HW_CAP_RFSILENT = BIT(1), 176364734faSFelix Fietkau ATH9K_HW_CAP_CST = BIT(2), 177364734faSFelix Fietkau ATH9K_HW_CAP_AUTOSLEEP = BIT(4), 178364734faSFelix Fietkau ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(5), 179364734faSFelix Fietkau ATH9K_HW_CAP_EDMA = BIT(6), 180364734faSFelix Fietkau ATH9K_HW_CAP_RAC_SUPPORTED = BIT(7), 181364734faSFelix Fietkau ATH9K_HW_CAP_LDPC = BIT(8), 182364734faSFelix Fietkau ATH9K_HW_CAP_FASTCLOCK = BIT(9), 183364734faSFelix Fietkau ATH9K_HW_CAP_SGI_20 = BIT(10), 184364734faSFelix Fietkau ATH9K_HW_CAP_PAPRD = BIT(11), 185364734faSFelix Fietkau ATH9K_HW_CAP_ANT_DIV_COMB = BIT(12), 186d4659912SFelix Fietkau ATH9K_HW_CAP_2GHZ = BIT(13), 187d4659912SFelix Fietkau ATH9K_HW_CAP_5GHZ = BIT(14), 188ea066d5aSMohammed Shafi Shajakhan ATH9K_HW_CAP_APM = BIT(15), 189203c4805SLuis R. Rodriguez }; 190203c4805SLuis R. Rodriguez 191203c4805SLuis R. Rodriguez struct ath9k_hw_capabilities { 192203c4805SLuis R. Rodriguez u32 hw_caps; /* ATH9K_HW_CAP_* from ath9k_hw_caps */ 193203c4805SLuis R. Rodriguez u16 rts_aggr_limit; 194203c4805SLuis R. Rodriguez u8 tx_chainmask; 195203c4805SLuis R. Rodriguez u8 rx_chainmask; 19647c80de6SVasanthakumar Thiagarajan u8 max_txchains; 19747c80de6SVasanthakumar Thiagarajan u8 max_rxchains; 198203c4805SLuis R. Rodriguez u8 num_gpio_pins; 199ceb26445SVasanthakumar Thiagarajan u8 rx_hp_qdepth; 200ceb26445SVasanthakumar Thiagarajan u8 rx_lp_qdepth; 201ceb26445SVasanthakumar Thiagarajan u8 rx_status_len; 202162c3be3SVasanthakumar Thiagarajan u8 tx_desc_len; 2035088c2f1SVasanthakumar Thiagarajan u8 txs_len; 2048060e169SVasanthakumar Thiagarajan u16 pcie_lcr_offset; 2058060e169SVasanthakumar Thiagarajan bool pcie_lcr_extsync_en; 206203c4805SLuis R. Rodriguez }; 207203c4805SLuis R. Rodriguez 208203c4805SLuis R. Rodriguez struct ath9k_ops_config { 209203c4805SLuis R. Rodriguez int dma_beacon_response_time; 210203c4805SLuis R. Rodriguez int sw_beacon_response_time; 211203c4805SLuis R. Rodriguez int additional_swba_backoff; 212203c4805SLuis R. Rodriguez int ack_6mb; 21341f3e54dSFelix Fietkau u32 cwm_ignore_extcca; 214203c4805SLuis R. Rodriguez u8 pcie_powersave_enable; 2156a0ec30aSLuis R. Rodriguez bool pcieSerDesWrite; 216203c4805SLuis R. Rodriguez u8 pcie_clock_req; 217203c4805SLuis R. Rodriguez u32 pcie_waen; 218203c4805SLuis R. Rodriguez u8 analog_shiftreg; 2196f481010SLuis R. Rodriguez u8 paprd_disable; 220203c4805SLuis R. Rodriguez u32 ofdm_trig_low; 221203c4805SLuis R. Rodriguez u32 ofdm_trig_high; 222203c4805SLuis R. Rodriguez u32 cck_trig_high; 223203c4805SLuis R. Rodriguez u32 cck_trig_low; 224203c4805SLuis R. Rodriguez u32 enable_ani; 225203c4805SLuis R. Rodriguez int serialize_regmode; 2260ce024cbSSujith bool rx_intr_mitigation; 22755e82df4SVasanthakumar Thiagarajan bool tx_intr_mitigation; 228203c4805SLuis R. Rodriguez #define SPUR_DISABLE 0 229203c4805SLuis R. Rodriguez #define SPUR_ENABLE_IOCTL 1 230203c4805SLuis R. Rodriguez #define SPUR_ENABLE_EEPROM 2 231203c4805SLuis R. Rodriguez #define AR_SPUR_5413_1 1640 232203c4805SLuis R. Rodriguez #define AR_SPUR_5413_2 1200 233203c4805SLuis R. Rodriguez #define AR_NO_SPUR 0x8000 234203c4805SLuis R. Rodriguez #define AR_BASE_FREQ_2GHZ 2300 235203c4805SLuis R. Rodriguez #define AR_BASE_FREQ_5GHZ 4900 236203c4805SLuis R. Rodriguez #define AR_SPUR_FEEQ_BOUND_HT40 19 237203c4805SLuis R. Rodriguez #define AR_SPUR_FEEQ_BOUND_HT20 10 238203c4805SLuis R. Rodriguez int spurmode; 239203c4805SLuis R. Rodriguez u16 spurchans[AR_EEPROM_MODAL_SPURS][2]; 240f4709fdfSLuis R. Rodriguez u8 max_txtrig_level; 241e36b27afSLuis R. Rodriguez u16 ani_poll_interval; /* ANI poll interval in ms */ 242203c4805SLuis R. Rodriguez }; 243203c4805SLuis R. Rodriguez 244203c4805SLuis R. Rodriguez enum ath9k_int { 245203c4805SLuis R. Rodriguez ATH9K_INT_RX = 0x00000001, 246203c4805SLuis R. Rodriguez ATH9K_INT_RXDESC = 0x00000002, 247b5c80475SFelix Fietkau ATH9K_INT_RXHP = 0x00000001, 248b5c80475SFelix Fietkau ATH9K_INT_RXLP = 0x00000002, 249203c4805SLuis R. Rodriguez ATH9K_INT_RXNOFRM = 0x00000008, 250203c4805SLuis R. Rodriguez ATH9K_INT_RXEOL = 0x00000010, 251203c4805SLuis R. Rodriguez ATH9K_INT_RXORN = 0x00000020, 252203c4805SLuis R. Rodriguez ATH9K_INT_TX = 0x00000040, 253203c4805SLuis R. Rodriguez ATH9K_INT_TXDESC = 0x00000080, 254203c4805SLuis R. Rodriguez ATH9K_INT_TIM_TIMER = 0x00000100, 255aea702b7SLuis R. Rodriguez ATH9K_INT_BB_WATCHDOG = 0x00000400, 256203c4805SLuis R. Rodriguez ATH9K_INT_TXURN = 0x00000800, 257203c4805SLuis R. Rodriguez ATH9K_INT_MIB = 0x00001000, 258203c4805SLuis R. Rodriguez ATH9K_INT_RXPHY = 0x00004000, 259203c4805SLuis R. Rodriguez ATH9K_INT_RXKCM = 0x00008000, 260203c4805SLuis R. Rodriguez ATH9K_INT_SWBA = 0x00010000, 261203c4805SLuis R. Rodriguez ATH9K_INT_BMISS = 0x00040000, 262203c4805SLuis R. Rodriguez ATH9K_INT_BNR = 0x00100000, 263203c4805SLuis R. Rodriguez ATH9K_INT_TIM = 0x00200000, 264203c4805SLuis R. Rodriguez ATH9K_INT_DTIM = 0x00400000, 265203c4805SLuis R. Rodriguez ATH9K_INT_DTIMSYNC = 0x00800000, 266203c4805SLuis R. Rodriguez ATH9K_INT_GPIO = 0x01000000, 267203c4805SLuis R. Rodriguez ATH9K_INT_CABEND = 0x02000000, 268203c4805SLuis R. Rodriguez ATH9K_INT_TSFOOR = 0x04000000, 269ff155a45SVasanthakumar Thiagarajan ATH9K_INT_GENTIMER = 0x08000000, 270203c4805SLuis R. Rodriguez ATH9K_INT_CST = 0x10000000, 271203c4805SLuis R. Rodriguez ATH9K_INT_GTT = 0x20000000, 272203c4805SLuis R. Rodriguez ATH9K_INT_FATAL = 0x40000000, 273203c4805SLuis R. Rodriguez ATH9K_INT_GLOBAL = 0x80000000, 274203c4805SLuis R. Rodriguez ATH9K_INT_BMISC = ATH9K_INT_TIM | 275203c4805SLuis R. Rodriguez ATH9K_INT_DTIM | 276203c4805SLuis R. Rodriguez ATH9K_INT_DTIMSYNC | 277203c4805SLuis R. Rodriguez ATH9K_INT_TSFOOR | 278203c4805SLuis R. Rodriguez ATH9K_INT_CABEND, 279203c4805SLuis R. Rodriguez ATH9K_INT_COMMON = ATH9K_INT_RXNOFRM | 280203c4805SLuis R. Rodriguez ATH9K_INT_RXDESC | 281203c4805SLuis R. Rodriguez ATH9K_INT_RXEOL | 282203c4805SLuis R. Rodriguez ATH9K_INT_RXORN | 283203c4805SLuis R. Rodriguez ATH9K_INT_TXURN | 284203c4805SLuis R. Rodriguez ATH9K_INT_TXDESC | 285203c4805SLuis R. Rodriguez ATH9K_INT_MIB | 286203c4805SLuis R. Rodriguez ATH9K_INT_RXPHY | 287203c4805SLuis R. Rodriguez ATH9K_INT_RXKCM | 288203c4805SLuis R. Rodriguez ATH9K_INT_SWBA | 289203c4805SLuis R. Rodriguez ATH9K_INT_BMISS | 290203c4805SLuis R. Rodriguez ATH9K_INT_GPIO, 291203c4805SLuis R. Rodriguez ATH9K_INT_NOCARD = 0xffffffff 292203c4805SLuis R. Rodriguez }; 293203c4805SLuis R. Rodriguez 294203c4805SLuis R. Rodriguez #define CHANNEL_CW_INT 0x00002 295203c4805SLuis R. Rodriguez #define CHANNEL_CCK 0x00020 296203c4805SLuis R. Rodriguez #define CHANNEL_OFDM 0x00040 297203c4805SLuis R. Rodriguez #define CHANNEL_2GHZ 0x00080 298203c4805SLuis R. Rodriguez #define CHANNEL_5GHZ 0x00100 299203c4805SLuis R. Rodriguez #define CHANNEL_PASSIVE 0x00200 300203c4805SLuis R. Rodriguez #define CHANNEL_DYN 0x00400 301203c4805SLuis R. Rodriguez #define CHANNEL_HALF 0x04000 302203c4805SLuis R. Rodriguez #define CHANNEL_QUARTER 0x08000 303203c4805SLuis R. Rodriguez #define CHANNEL_HT20 0x10000 304203c4805SLuis R. Rodriguez #define CHANNEL_HT40PLUS 0x20000 305203c4805SLuis R. Rodriguez #define CHANNEL_HT40MINUS 0x40000 306203c4805SLuis R. Rodriguez 307203c4805SLuis R. Rodriguez #define CHANNEL_A (CHANNEL_5GHZ|CHANNEL_OFDM) 308203c4805SLuis R. Rodriguez #define CHANNEL_B (CHANNEL_2GHZ|CHANNEL_CCK) 309203c4805SLuis R. Rodriguez #define CHANNEL_G (CHANNEL_2GHZ|CHANNEL_OFDM) 310203c4805SLuis R. Rodriguez #define CHANNEL_G_HT20 (CHANNEL_2GHZ|CHANNEL_HT20) 311203c4805SLuis R. Rodriguez #define CHANNEL_A_HT20 (CHANNEL_5GHZ|CHANNEL_HT20) 312203c4805SLuis R. Rodriguez #define CHANNEL_G_HT40PLUS (CHANNEL_2GHZ|CHANNEL_HT40PLUS) 313203c4805SLuis R. Rodriguez #define CHANNEL_G_HT40MINUS (CHANNEL_2GHZ|CHANNEL_HT40MINUS) 314203c4805SLuis R. Rodriguez #define CHANNEL_A_HT40PLUS (CHANNEL_5GHZ|CHANNEL_HT40PLUS) 315203c4805SLuis R. Rodriguez #define CHANNEL_A_HT40MINUS (CHANNEL_5GHZ|CHANNEL_HT40MINUS) 316203c4805SLuis R. Rodriguez #define CHANNEL_ALL \ 317203c4805SLuis R. Rodriguez (CHANNEL_OFDM| \ 318203c4805SLuis R. Rodriguez CHANNEL_CCK| \ 319203c4805SLuis R. Rodriguez CHANNEL_2GHZ | \ 320203c4805SLuis R. Rodriguez CHANNEL_5GHZ | \ 321203c4805SLuis R. Rodriguez CHANNEL_HT20 | \ 322203c4805SLuis R. Rodriguez CHANNEL_HT40PLUS | \ 323203c4805SLuis R. Rodriguez CHANNEL_HT40MINUS) 324203c4805SLuis R. Rodriguez 32520bd2a09SFelix Fietkau struct ath9k_hw_cal_data { 326203c4805SLuis R. Rodriguez u16 channel; 327203c4805SLuis R. Rodriguez u32 channelFlags; 328203c4805SLuis R. Rodriguez int32_t CalValid; 329203c4805SLuis R. Rodriguez int8_t iCoff; 330203c4805SLuis R. Rodriguez int8_t qCoff; 331717f6bedSFelix Fietkau bool paprd_done; 3324254bc1cSFelix Fietkau bool nfcal_pending; 33370cf1533SFelix Fietkau bool nfcal_interference; 334717f6bedSFelix Fietkau u16 small_signal_gain[AR9300_MAX_CHAINS]; 335717f6bedSFelix Fietkau u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ]; 33620bd2a09SFelix Fietkau struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; 33720bd2a09SFelix Fietkau }; 33820bd2a09SFelix Fietkau 33920bd2a09SFelix Fietkau struct ath9k_channel { 34020bd2a09SFelix Fietkau struct ieee80211_channel *chan; 341093115b7SFelix Fietkau struct ar5416AniState ani; 34220bd2a09SFelix Fietkau u16 channel; 34320bd2a09SFelix Fietkau u32 channelFlags; 34420bd2a09SFelix Fietkau u32 chanmode; 345d9891c78SFelix Fietkau s16 noisefloor; 346203c4805SLuis R. Rodriguez }; 347203c4805SLuis R. Rodriguez 348203c4805SLuis R. Rodriguez #define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \ 349203c4805SLuis R. Rodriguez (((_c)->channelFlags & CHANNEL_G_HT20) == CHANNEL_G_HT20) || \ 350203c4805SLuis R. Rodriguez (((_c)->channelFlags & CHANNEL_G_HT40PLUS) == CHANNEL_G_HT40PLUS) || \ 351203c4805SLuis R. Rodriguez (((_c)->channelFlags & CHANNEL_G_HT40MINUS) == CHANNEL_G_HT40MINUS)) 352203c4805SLuis R. Rodriguez #define IS_CHAN_OFDM(_c) (((_c)->channelFlags & CHANNEL_OFDM) != 0) 353203c4805SLuis R. Rodriguez #define IS_CHAN_5GHZ(_c) (((_c)->channelFlags & CHANNEL_5GHZ) != 0) 354203c4805SLuis R. Rodriguez #define IS_CHAN_2GHZ(_c) (((_c)->channelFlags & CHANNEL_2GHZ) != 0) 355203c4805SLuis R. Rodriguez #define IS_CHAN_HALF_RATE(_c) (((_c)->channelFlags & CHANNEL_HALF) != 0) 356203c4805SLuis R. Rodriguez #define IS_CHAN_QUARTER_RATE(_c) (((_c)->channelFlags & CHANNEL_QUARTER) != 0) 3576b42e8d0SFelix Fietkau #define IS_CHAN_A_FAST_CLOCK(_ah, _c) \ 358203c4805SLuis R. Rodriguez ((((_c)->channelFlags & CHANNEL_5GHZ) != 0) && \ 3596b42e8d0SFelix Fietkau ((_ah)->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK)) 360203c4805SLuis R. Rodriguez 361203c4805SLuis R. Rodriguez /* These macros check chanmode and not channelFlags */ 362203c4805SLuis R. Rodriguez #define IS_CHAN_B(_c) ((_c)->chanmode == CHANNEL_B) 363203c4805SLuis R. Rodriguez #define IS_CHAN_HT20(_c) (((_c)->chanmode == CHANNEL_A_HT20) || \ 364203c4805SLuis R. Rodriguez ((_c)->chanmode == CHANNEL_G_HT20)) 365203c4805SLuis R. Rodriguez #define IS_CHAN_HT40(_c) (((_c)->chanmode == CHANNEL_A_HT40PLUS) || \ 366203c4805SLuis R. Rodriguez ((_c)->chanmode == CHANNEL_A_HT40MINUS) || \ 367203c4805SLuis R. Rodriguez ((_c)->chanmode == CHANNEL_G_HT40PLUS) || \ 368203c4805SLuis R. Rodriguez ((_c)->chanmode == CHANNEL_G_HT40MINUS)) 369203c4805SLuis R. Rodriguez #define IS_CHAN_HT(_c) (IS_CHAN_HT20((_c)) || IS_CHAN_HT40((_c))) 370203c4805SLuis R. Rodriguez 371203c4805SLuis R. Rodriguez enum ath9k_power_mode { 372203c4805SLuis R. Rodriguez ATH9K_PM_AWAKE = 0, 373203c4805SLuis R. Rodriguez ATH9K_PM_FULL_SLEEP, 374203c4805SLuis R. Rodriguez ATH9K_PM_NETWORK_SLEEP, 375203c4805SLuis R. Rodriguez ATH9K_PM_UNDEFINED 376203c4805SLuis R. Rodriguez }; 377203c4805SLuis R. Rodriguez 378203c4805SLuis R. Rodriguez enum ath9k_tp_scale { 379203c4805SLuis R. Rodriguez ATH9K_TP_SCALE_MAX = 0, 380203c4805SLuis R. Rodriguez ATH9K_TP_SCALE_50, 381203c4805SLuis R. Rodriguez ATH9K_TP_SCALE_25, 382203c4805SLuis R. Rodriguez ATH9K_TP_SCALE_12, 383203c4805SLuis R. Rodriguez ATH9K_TP_SCALE_MIN 384203c4805SLuis R. Rodriguez }; 385203c4805SLuis R. Rodriguez 386203c4805SLuis R. Rodriguez enum ser_reg_mode { 387203c4805SLuis R. Rodriguez SER_REG_MODE_OFF = 0, 388203c4805SLuis R. Rodriguez SER_REG_MODE_ON = 1, 389203c4805SLuis R. Rodriguez SER_REG_MODE_AUTO = 2, 390203c4805SLuis R. Rodriguez }; 391203c4805SLuis R. Rodriguez 392ad7b8060SVasanthakumar Thiagarajan enum ath9k_rx_qtype { 393ad7b8060SVasanthakumar Thiagarajan ATH9K_RX_QUEUE_HP, 394ad7b8060SVasanthakumar Thiagarajan ATH9K_RX_QUEUE_LP, 395ad7b8060SVasanthakumar Thiagarajan ATH9K_RX_QUEUE_MAX, 396ad7b8060SVasanthakumar Thiagarajan }; 397ad7b8060SVasanthakumar Thiagarajan 398203c4805SLuis R. Rodriguez struct ath9k_beacon_state { 399203c4805SLuis R. Rodriguez u32 bs_nexttbtt; 400203c4805SLuis R. Rodriguez u32 bs_nextdtim; 401203c4805SLuis R. Rodriguez u32 bs_intval; 402203c4805SLuis R. Rodriguez #define ATH9K_BEACON_PERIOD 0x0000ffff 403203c4805SLuis R. Rodriguez #define ATH9K_TSFOOR_THRESHOLD 0x00004240 /* 16k us */ 404203c4805SLuis R. Rodriguez u32 bs_dtimperiod; 405203c4805SLuis R. Rodriguez u16 bs_cfpperiod; 406203c4805SLuis R. Rodriguez u16 bs_cfpmaxduration; 407203c4805SLuis R. Rodriguez u32 bs_cfpnext; 408203c4805SLuis R. Rodriguez u16 bs_timoffset; 409203c4805SLuis R. Rodriguez u16 bs_bmissthreshold; 410203c4805SLuis R. Rodriguez u32 bs_sleepduration; 411203c4805SLuis R. Rodriguez u32 bs_tsfoor_threshold; 412203c4805SLuis R. Rodriguez }; 413203c4805SLuis R. Rodriguez 414203c4805SLuis R. Rodriguez struct chan_centers { 415203c4805SLuis R. Rodriguez u16 synth_center; 416203c4805SLuis R. Rodriguez u16 ctl_center; 417203c4805SLuis R. Rodriguez u16 ext_center; 418203c4805SLuis R. Rodriguez }; 419203c4805SLuis R. Rodriguez 420203c4805SLuis R. Rodriguez enum { 421203c4805SLuis R. Rodriguez ATH9K_RESET_POWER_ON, 422203c4805SLuis R. Rodriguez ATH9K_RESET_WARM, 423203c4805SLuis R. Rodriguez ATH9K_RESET_COLD, 424203c4805SLuis R. Rodriguez }; 425203c4805SLuis R. Rodriguez 426203c4805SLuis R. Rodriguez struct ath9k_hw_version { 427203c4805SLuis R. Rodriguez u32 magic; 428203c4805SLuis R. Rodriguez u16 devid; 429203c4805SLuis R. Rodriguez u16 subvendorid; 430203c4805SLuis R. Rodriguez u32 macVersion; 431203c4805SLuis R. Rodriguez u16 macRev; 432203c4805SLuis R. Rodriguez u16 phyRev; 433203c4805SLuis R. Rodriguez u16 analog5GhzRev; 434203c4805SLuis R. Rodriguez u16 analog2GhzRev; 435aeac355dSVasanthakumar Thiagarajan u16 subsysid; 4360b5ead91SSujith Manoharan enum ath_usb_dev usbdev; 437203c4805SLuis R. Rodriguez }; 438203c4805SLuis R. Rodriguez 439ff155a45SVasanthakumar Thiagarajan /* Generic TSF timer definitions */ 440ff155a45SVasanthakumar Thiagarajan 441ff155a45SVasanthakumar Thiagarajan #define ATH_MAX_GEN_TIMER 16 442ff155a45SVasanthakumar Thiagarajan 443ff155a45SVasanthakumar Thiagarajan #define AR_GENTMR_BIT(_index) (1 << (_index)) 444ff155a45SVasanthakumar Thiagarajan 445ff155a45SVasanthakumar Thiagarajan /* 44677c2061dSWalter Goldens * Using de Bruijin sequence to look up 1's index in a 32 bit number 447ff155a45SVasanthakumar Thiagarajan * debruijn32 = 0000 0111 0111 1100 1011 0101 0011 0001 448ff155a45SVasanthakumar Thiagarajan */ 449c90017ddSVasanthakumar Thiagarajan #define debruijn32 0x077CB531U 450ff155a45SVasanthakumar Thiagarajan 451ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer_configuration { 452ff155a45SVasanthakumar Thiagarajan u32 next_addr; 453ff155a45SVasanthakumar Thiagarajan u32 period_addr; 454ff155a45SVasanthakumar Thiagarajan u32 mode_addr; 455ff155a45SVasanthakumar Thiagarajan u32 mode_mask; 456ff155a45SVasanthakumar Thiagarajan }; 457ff155a45SVasanthakumar Thiagarajan 458ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer { 459ff155a45SVasanthakumar Thiagarajan void (*trigger)(void *arg); 460ff155a45SVasanthakumar Thiagarajan void (*overflow)(void *arg); 461ff155a45SVasanthakumar Thiagarajan void *arg; 462ff155a45SVasanthakumar Thiagarajan u8 index; 463ff155a45SVasanthakumar Thiagarajan }; 464ff155a45SVasanthakumar Thiagarajan 465ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer_table { 466ff155a45SVasanthakumar Thiagarajan u32 gen_timer_index[32]; 467ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer *timers[ATH_MAX_GEN_TIMER]; 468ff155a45SVasanthakumar Thiagarajan union { 469ff155a45SVasanthakumar Thiagarajan unsigned long timer_bits; 470ff155a45SVasanthakumar Thiagarajan u16 val; 471ff155a45SVasanthakumar Thiagarajan } timer_mask; 472ff155a45SVasanthakumar Thiagarajan }; 473ff155a45SVasanthakumar Thiagarajan 47421cc630fSVasanthakumar Thiagarajan struct ath_hw_antcomb_conf { 47521cc630fSVasanthakumar Thiagarajan u8 main_lna_conf; 47621cc630fSVasanthakumar Thiagarajan u8 alt_lna_conf; 47721cc630fSVasanthakumar Thiagarajan u8 fast_div_bias; 47821cc630fSVasanthakumar Thiagarajan }; 47921cc630fSVasanthakumar Thiagarajan 480d70357d5SLuis R. Rodriguez /** 4814e8c14e9SFelix Fietkau * struct ath_hw_radar_conf - radar detection initialization parameters 4824e8c14e9SFelix Fietkau * 4834e8c14e9SFelix Fietkau * @pulse_inband: threshold for checking the ratio of in-band power 4844e8c14e9SFelix Fietkau * to total power for short radar pulses (half dB steps) 4854e8c14e9SFelix Fietkau * @pulse_inband_step: threshold for checking an in-band power to total 4864e8c14e9SFelix Fietkau * power ratio increase for short radar pulses (half dB steps) 4874e8c14e9SFelix Fietkau * @pulse_height: threshold for detecting the beginning of a short 4884e8c14e9SFelix Fietkau * radar pulse (dB step) 4894e8c14e9SFelix Fietkau * @pulse_rssi: threshold for detecting if a short radar pulse is 4904e8c14e9SFelix Fietkau * gone (dB step) 4914e8c14e9SFelix Fietkau * @pulse_maxlen: maximum pulse length (0.8 us steps) 4924e8c14e9SFelix Fietkau * 4934e8c14e9SFelix Fietkau * @radar_rssi: RSSI threshold for starting long radar detection (dB steps) 4944e8c14e9SFelix Fietkau * @radar_inband: threshold for checking the ratio of in-band power 4954e8c14e9SFelix Fietkau * to total power for long radar pulses (half dB steps) 4964e8c14e9SFelix Fietkau * @fir_power: threshold for detecting the end of a long radar pulse (dB) 4974e8c14e9SFelix Fietkau * 4984e8c14e9SFelix Fietkau * @ext_channel: enable extension channel radar detection 4994e8c14e9SFelix Fietkau */ 5004e8c14e9SFelix Fietkau struct ath_hw_radar_conf { 5014e8c14e9SFelix Fietkau unsigned int pulse_inband; 5024e8c14e9SFelix Fietkau unsigned int pulse_inband_step; 5034e8c14e9SFelix Fietkau unsigned int pulse_height; 5044e8c14e9SFelix Fietkau unsigned int pulse_rssi; 5054e8c14e9SFelix Fietkau unsigned int pulse_maxlen; 5064e8c14e9SFelix Fietkau 5074e8c14e9SFelix Fietkau unsigned int radar_rssi; 5084e8c14e9SFelix Fietkau unsigned int radar_inband; 5094e8c14e9SFelix Fietkau int fir_power; 5104e8c14e9SFelix Fietkau 5114e8c14e9SFelix Fietkau bool ext_channel; 5124e8c14e9SFelix Fietkau }; 5134e8c14e9SFelix Fietkau 5144e8c14e9SFelix Fietkau /** 515d70357d5SLuis R. Rodriguez * struct ath_hw_private_ops - callbacks used internally by hardware code 516d70357d5SLuis R. Rodriguez * 517d70357d5SLuis R. Rodriguez * This structure contains private callbacks designed to only be used internally 518d70357d5SLuis R. Rodriguez * by the hardware core. 519d70357d5SLuis R. Rodriguez * 520795f5e2cSLuis R. Rodriguez * @init_cal_settings: setup types of calibrations supported 521795f5e2cSLuis R. Rodriguez * @init_cal: starts actual calibration 522795f5e2cSLuis R. Rodriguez * 523d70357d5SLuis R. Rodriguez * @init_mode_regs: Initializes mode registers 524991312d8SLuis R. Rodriguez * @init_mode_gain_regs: Initialize TX/RX gain registers 5258fe65368SLuis R. Rodriguez * 5268fe65368SLuis R. Rodriguez * @rf_set_freq: change frequency 5278fe65368SLuis R. Rodriguez * @spur_mitigate_freq: spur mitigation 5288fe65368SLuis R. Rodriguez * @rf_alloc_ext_banks: 5298fe65368SLuis R. Rodriguez * @rf_free_ext_banks: 5308fe65368SLuis R. Rodriguez * @set_rf_regs: 53164773964SLuis R. Rodriguez * @compute_pll_control: compute the PLL control value to use for 53264773964SLuis R. Rodriguez * AR_RTC_PLL_CONTROL for a given channel 533795f5e2cSLuis R. Rodriguez * @setup_calibration: set up calibration 534795f5e2cSLuis R. Rodriguez * @iscal_supported: used to query if a type of calibration is supported 535ac0bb767SLuis R. Rodriguez * 536e36b27afSLuis R. Rodriguez * @ani_cache_ini_regs: cache the values for ANI from the initial 537e36b27afSLuis R. Rodriguez * register settings through the register initialization. 538d70357d5SLuis R. Rodriguez */ 539d70357d5SLuis R. Rodriguez struct ath_hw_private_ops { 540795f5e2cSLuis R. Rodriguez /* Calibration ops */ 541d70357d5SLuis R. Rodriguez void (*init_cal_settings)(struct ath_hw *ah); 542795f5e2cSLuis R. Rodriguez bool (*init_cal)(struct ath_hw *ah, struct ath9k_channel *chan); 543795f5e2cSLuis R. Rodriguez 544d70357d5SLuis R. Rodriguez void (*init_mode_regs)(struct ath_hw *ah); 545991312d8SLuis R. Rodriguez void (*init_mode_gain_regs)(struct ath_hw *ah); 546795f5e2cSLuis R. Rodriguez void (*setup_calibration)(struct ath_hw *ah, 547795f5e2cSLuis R. Rodriguez struct ath9k_cal_list *currCal); 5488fe65368SLuis R. Rodriguez 5498fe65368SLuis R. Rodriguez /* PHY ops */ 5508fe65368SLuis R. Rodriguez int (*rf_set_freq)(struct ath_hw *ah, 5518fe65368SLuis R. Rodriguez struct ath9k_channel *chan); 5528fe65368SLuis R. Rodriguez void (*spur_mitigate_freq)(struct ath_hw *ah, 5538fe65368SLuis R. Rodriguez struct ath9k_channel *chan); 5548fe65368SLuis R. Rodriguez int (*rf_alloc_ext_banks)(struct ath_hw *ah); 5558fe65368SLuis R. Rodriguez void (*rf_free_ext_banks)(struct ath_hw *ah); 5568fe65368SLuis R. Rodriguez bool (*set_rf_regs)(struct ath_hw *ah, 5578fe65368SLuis R. Rodriguez struct ath9k_channel *chan, 5588fe65368SLuis R. Rodriguez u16 modesIndex); 5598fe65368SLuis R. Rodriguez void (*set_channel_regs)(struct ath_hw *ah, struct ath9k_channel *chan); 5608fe65368SLuis R. Rodriguez void (*init_bb)(struct ath_hw *ah, 5618fe65368SLuis R. Rodriguez struct ath9k_channel *chan); 5628fe65368SLuis R. Rodriguez int (*process_ini)(struct ath_hw *ah, struct ath9k_channel *chan); 5638fe65368SLuis R. Rodriguez void (*olc_init)(struct ath_hw *ah); 5648fe65368SLuis R. Rodriguez void (*set_rfmode)(struct ath_hw *ah, struct ath9k_channel *chan); 5658fe65368SLuis R. Rodriguez void (*mark_phy_inactive)(struct ath_hw *ah); 5668fe65368SLuis R. Rodriguez void (*set_delta_slope)(struct ath_hw *ah, struct ath9k_channel *chan); 5678fe65368SLuis R. Rodriguez bool (*rfbus_req)(struct ath_hw *ah); 5688fe65368SLuis R. Rodriguez void (*rfbus_done)(struct ath_hw *ah); 5698fe65368SLuis R. Rodriguez void (*restore_chainmask)(struct ath_hw *ah); 5708fe65368SLuis R. Rodriguez void (*set_diversity)(struct ath_hw *ah, bool value); 57164773964SLuis R. Rodriguez u32 (*compute_pll_control)(struct ath_hw *ah, 57264773964SLuis R. Rodriguez struct ath9k_channel *chan); 573c16fcb49SFelix Fietkau bool (*ani_control)(struct ath_hw *ah, enum ath9k_ani_cmd cmd, 574c16fcb49SFelix Fietkau int param); 575641d9921SFelix Fietkau void (*do_getnf)(struct ath_hw *ah, int16_t nfarray[NUM_NF_READINGS]); 5764e8c14e9SFelix Fietkau void (*set_radar_params)(struct ath_hw *ah, 5774e8c14e9SFelix Fietkau struct ath_hw_radar_conf *conf); 578ac0bb767SLuis R. Rodriguez 579ac0bb767SLuis R. Rodriguez /* ANI */ 580e36b27afSLuis R. Rodriguez void (*ani_cache_ini_regs)(struct ath_hw *ah); 581d70357d5SLuis R. Rodriguez }; 582d70357d5SLuis R. Rodriguez 583d70357d5SLuis R. Rodriguez /** 584d70357d5SLuis R. Rodriguez * struct ath_hw_ops - callbacks used by hardware code and driver code 585d70357d5SLuis R. Rodriguez * 586d70357d5SLuis R. Rodriguez * This structure contains callbacks designed to to be used internally by 587d70357d5SLuis R. Rodriguez * hardware code and also by the lower level driver. 588d70357d5SLuis R. Rodriguez * 589d70357d5SLuis R. Rodriguez * @config_pci_powersave: 590795f5e2cSLuis R. Rodriguez * @calibrate: periodic calibration for NF, ANI, IQ, ADC gain, ADC-DC 591d70357d5SLuis R. Rodriguez */ 592d70357d5SLuis R. Rodriguez struct ath_hw_ops { 593d70357d5SLuis R. Rodriguez void (*config_pci_powersave)(struct ath_hw *ah, 594d70357d5SLuis R. Rodriguez int restore, 595d70357d5SLuis R. Rodriguez int power_off); 596cee1f625SVasanthakumar Thiagarajan void (*rx_enable)(struct ath_hw *ah); 59787d5efbbSVasanthakumar Thiagarajan void (*set_desc_link)(void *ds, u32 link); 59887d5efbbSVasanthakumar Thiagarajan void (*get_desc_link)(void *ds, u32 **link); 599795f5e2cSLuis R. Rodriguez bool (*calibrate)(struct ath_hw *ah, 600795f5e2cSLuis R. Rodriguez struct ath9k_channel *chan, 601795f5e2cSLuis R. Rodriguez u8 rxchainmask, 602795f5e2cSLuis R. Rodriguez bool longcal); 60355e82df4SVasanthakumar Thiagarajan bool (*get_isr)(struct ath_hw *ah, enum ath9k_int *masked); 604cc610ac0SVasanthakumar Thiagarajan void (*fill_txdesc)(struct ath_hw *ah, void *ds, u32 seglen, 605cc610ac0SVasanthakumar Thiagarajan bool is_firstseg, bool is_is_lastseg, 606cc610ac0SVasanthakumar Thiagarajan const void *ds0, dma_addr_t buf_addr, 607cc610ac0SVasanthakumar Thiagarajan unsigned int qcu); 608cc610ac0SVasanthakumar Thiagarajan int (*proc_txdesc)(struct ath_hw *ah, void *ds, 609cc610ac0SVasanthakumar Thiagarajan struct ath_tx_status *ts); 610cc610ac0SVasanthakumar Thiagarajan void (*set11n_txdesc)(struct ath_hw *ah, void *ds, 611cc610ac0SVasanthakumar Thiagarajan u32 pktLen, enum ath9k_pkt_type type, 612cc610ac0SVasanthakumar Thiagarajan u32 txPower, u32 keyIx, 613cc610ac0SVasanthakumar Thiagarajan enum ath9k_key_type keyType, 614cc610ac0SVasanthakumar Thiagarajan u32 flags); 615cc610ac0SVasanthakumar Thiagarajan void (*set11n_ratescenario)(struct ath_hw *ah, void *ds, 616cc610ac0SVasanthakumar Thiagarajan void *lastds, 617cc610ac0SVasanthakumar Thiagarajan u32 durUpdateEn, u32 rtsctsRate, 618cc610ac0SVasanthakumar Thiagarajan u32 rtsctsDuration, 619cc610ac0SVasanthakumar Thiagarajan struct ath9k_11n_rate_series series[], 620cc610ac0SVasanthakumar Thiagarajan u32 nseries, u32 flags); 621cc610ac0SVasanthakumar Thiagarajan void (*set11n_aggr_first)(struct ath_hw *ah, void *ds, 622cc610ac0SVasanthakumar Thiagarajan u32 aggrLen); 623cc610ac0SVasanthakumar Thiagarajan void (*set11n_aggr_middle)(struct ath_hw *ah, void *ds, 624cc610ac0SVasanthakumar Thiagarajan u32 numDelims); 625cc610ac0SVasanthakumar Thiagarajan void (*set11n_aggr_last)(struct ath_hw *ah, void *ds); 626cc610ac0SVasanthakumar Thiagarajan void (*clr11n_aggr)(struct ath_hw *ah, void *ds); 627cc610ac0SVasanthakumar Thiagarajan void (*set11n_burstduration)(struct ath_hw *ah, void *ds, 628cc610ac0SVasanthakumar Thiagarajan u32 burstDuration); 629*5519541dSFelix Fietkau void (*set_clrdmask)(struct ath_hw *ah, void *ds, bool val); 630d70357d5SLuis R. Rodriguez }; 631d70357d5SLuis R. Rodriguez 632f2552e28SFelix Fietkau struct ath_nf_limits { 633f2552e28SFelix Fietkau s16 max; 634f2552e28SFelix Fietkau s16 min; 635f2552e28SFelix Fietkau s16 nominal; 636f2552e28SFelix Fietkau }; 637f2552e28SFelix Fietkau 63897dcec57SSujith Manoharan /* ah_flags */ 63997dcec57SSujith Manoharan #define AH_USE_EEPROM 0x1 64097dcec57SSujith Manoharan #define AH_UNPLUGGED 0x2 /* The card has been physically removed. */ 64197dcec57SSujith Manoharan 642203c4805SLuis R. Rodriguez struct ath_hw { 643f9f84e96SFelix Fietkau struct ath_ops reg_ops; 644f9f84e96SFelix Fietkau 645b002a4a9SLuis R. Rodriguez struct ieee80211_hw *hw; 64627c51f1aSLuis R. Rodriguez struct ath_common common; 647203c4805SLuis R. Rodriguez struct ath9k_hw_version hw_version; 648203c4805SLuis R. Rodriguez struct ath9k_ops_config config; 649203c4805SLuis R. Rodriguez struct ath9k_hw_capabilities caps; 650cac4220bSFelix Fietkau struct ath9k_channel channels[ATH9K_NUM_CHANNELS]; 651203c4805SLuis R. Rodriguez struct ath9k_channel *curchan; 652203c4805SLuis R. Rodriguez 653203c4805SLuis R. Rodriguez union { 654203c4805SLuis R. Rodriguez struct ar5416_eeprom_def def; 655203c4805SLuis R. Rodriguez struct ar5416_eeprom_4k map4k; 656475f5989SLuis R. Rodriguez struct ar9287_eeprom map9287; 65715c9ee7aSSenthil Balasubramanian struct ar9300_eeprom ar9300_eep; 658203c4805SLuis R. Rodriguez } eeprom; 659203c4805SLuis R. Rodriguez const struct eeprom_ops *eep_ops; 660203c4805SLuis R. Rodriguez 661203c4805SLuis R. Rodriguez bool sw_mgmt_crypto; 662203c4805SLuis R. Rodriguez bool is_pciexpress; 6635f841b41SRajkumar Manoharan bool is_monitoring; 6642eb46d9bSPavel Roskin bool need_an_top2_fixup; 665203c4805SLuis R. Rodriguez u16 tx_trig_level; 666f2552e28SFelix Fietkau 667bbacee13SFelix Fietkau u32 nf_regs[6]; 668f2552e28SFelix Fietkau struct ath_nf_limits nf_2g; 669f2552e28SFelix Fietkau struct ath_nf_limits nf_5g; 670203c4805SLuis R. Rodriguez u16 rfsilent; 671203c4805SLuis R. Rodriguez u32 rfkill_gpio; 672203c4805SLuis R. Rodriguez u32 rfkill_polarity; 673203c4805SLuis R. Rodriguez u32 ah_flags; 674203c4805SLuis R. Rodriguez 675d7e7d229SLuis R. Rodriguez bool htc_reset_init; 676d7e7d229SLuis R. Rodriguez 677203c4805SLuis R. Rodriguez enum nl80211_iftype opmode; 678203c4805SLuis R. Rodriguez enum ath9k_power_mode power_mode; 679203c4805SLuis R. Rodriguez 68020bd2a09SFelix Fietkau struct ath9k_hw_cal_data *caldata; 681a13883b0SSujith struct ath9k_pacal_info pacal_info; 682203c4805SLuis R. Rodriguez struct ar5416Stats stats; 683203c4805SLuis R. Rodriguez struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES]; 684203c4805SLuis R. Rodriguez 685203c4805SLuis R. Rodriguez int16_t curchan_rad_index; 6863069168cSPavel Roskin enum ath9k_int imask; 68774bad5cbSPavel Roskin u32 imrs2_reg; 688203c4805SLuis R. Rodriguez u32 txok_interrupt_mask; 689203c4805SLuis R. Rodriguez u32 txerr_interrupt_mask; 690203c4805SLuis R. Rodriguez u32 txdesc_interrupt_mask; 691203c4805SLuis R. Rodriguez u32 txeol_interrupt_mask; 692203c4805SLuis R. Rodriguez u32 txurn_interrupt_mask; 693203c4805SLuis R. Rodriguez bool chip_fullsleep; 694203c4805SLuis R. Rodriguez u32 atim_window; 695203c4805SLuis R. Rodriguez 696203c4805SLuis R. Rodriguez /* Calibration */ 6976497827fSFelix Fietkau u32 supp_cals; 698cbfe9468SSujith struct ath9k_cal_list iq_caldata; 699cbfe9468SSujith struct ath9k_cal_list adcgain_caldata; 700cbfe9468SSujith struct ath9k_cal_list adcdc_caldata; 701df23acaaSLuis R. Rodriguez struct ath9k_cal_list tempCompCalData; 702cbfe9468SSujith struct ath9k_cal_list *cal_list; 703cbfe9468SSujith struct ath9k_cal_list *cal_list_last; 704cbfe9468SSujith struct ath9k_cal_list *cal_list_curr; 705203c4805SLuis R. Rodriguez #define totalPowerMeasI meas0.unsign 706203c4805SLuis R. Rodriguez #define totalPowerMeasQ meas1.unsign 707203c4805SLuis R. Rodriguez #define totalIqCorrMeas meas2.sign 708203c4805SLuis R. Rodriguez #define totalAdcIOddPhase meas0.unsign 709203c4805SLuis R. Rodriguez #define totalAdcIEvenPhase meas1.unsign 710203c4805SLuis R. Rodriguez #define totalAdcQOddPhase meas2.unsign 711203c4805SLuis R. Rodriguez #define totalAdcQEvenPhase meas3.unsign 712203c4805SLuis R. Rodriguez #define totalAdcDcOffsetIOddPhase meas0.sign 713203c4805SLuis R. Rodriguez #define totalAdcDcOffsetIEvenPhase meas1.sign 714203c4805SLuis R. Rodriguez #define totalAdcDcOffsetQOddPhase meas2.sign 715203c4805SLuis R. Rodriguez #define totalAdcDcOffsetQEvenPhase meas3.sign 716203c4805SLuis R. Rodriguez union { 717203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 718203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 719203c4805SLuis R. Rodriguez } meas0; 720203c4805SLuis R. Rodriguez union { 721203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 722203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 723203c4805SLuis R. Rodriguez } meas1; 724203c4805SLuis R. Rodriguez union { 725203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 726203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 727203c4805SLuis R. Rodriguez } meas2; 728203c4805SLuis R. Rodriguez union { 729203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 730203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 731203c4805SLuis R. Rodriguez } meas3; 732203c4805SLuis R. Rodriguez u16 cal_samples; 733203c4805SLuis R. Rodriguez 734203c4805SLuis R. Rodriguez u32 sta_id1_defaults; 735203c4805SLuis R. Rodriguez u32 misc_mode; 736203c4805SLuis R. Rodriguez enum { 737203c4805SLuis R. Rodriguez AUTO_32KHZ, 738203c4805SLuis R. Rodriguez USE_32KHZ, 739203c4805SLuis R. Rodriguez DONT_USE_32KHZ, 740203c4805SLuis R. Rodriguez } enable_32kHz_clock; 741203c4805SLuis R. Rodriguez 742d70357d5SLuis R. Rodriguez /* Private to hardware code */ 743d70357d5SLuis R. Rodriguez struct ath_hw_private_ops private_ops; 744d70357d5SLuis R. Rodriguez /* Accessed by the lower level driver */ 745d70357d5SLuis R. Rodriguez struct ath_hw_ops ops; 746d70357d5SLuis R. Rodriguez 747e68a060bSLuis R. Rodriguez /* Used to program the radio on non single-chip devices */ 748203c4805SLuis R. Rodriguez u32 *analogBank0Data; 749203c4805SLuis R. Rodriguez u32 *analogBank1Data; 750203c4805SLuis R. Rodriguez u32 *analogBank2Data; 751203c4805SLuis R. Rodriguez u32 *analogBank3Data; 752203c4805SLuis R. Rodriguez u32 *analogBank6Data; 753203c4805SLuis R. Rodriguez u32 *analogBank6TPCData; 754203c4805SLuis R. Rodriguez u32 *analogBank7Data; 755203c4805SLuis R. Rodriguez u32 *addac5416_21; 756203c4805SLuis R. Rodriguez u32 *bank6Temp; 757203c4805SLuis R. Rodriguez 758597a94b3SFelix Fietkau u8 txpower_limit; 759e239d859SFelix Fietkau int coverage_class; 760203c4805SLuis R. Rodriguez u32 slottime; 761203c4805SLuis R. Rodriguez u32 globaltxtimeout; 762203c4805SLuis R. Rodriguez 763203c4805SLuis R. Rodriguez /* ANI */ 764203c4805SLuis R. Rodriguez u32 proc_phyerr; 765203c4805SLuis R. Rodriguez u32 aniperiod; 766203c4805SLuis R. Rodriguez int totalSizeDesired[5]; 767203c4805SLuis R. Rodriguez int coarse_high[5]; 768203c4805SLuis R. Rodriguez int coarse_low[5]; 769203c4805SLuis R. Rodriguez int firpwr[5]; 770203c4805SLuis R. Rodriguez enum ath9k_ani_cmd ani_function; 771203c4805SLuis R. Rodriguez 772af03abecSLuis R. Rodriguez /* Bluetooth coexistance */ 773766ec4a9SLuis R. Rodriguez struct ath_btcoex_hw btcoex_hw; 774af03abecSLuis R. Rodriguez 775203c4805SLuis R. Rodriguez u32 intr_txqs; 776203c4805SLuis R. Rodriguez u8 txchainmask; 777203c4805SLuis R. Rodriguez u8 rxchainmask; 778203c4805SLuis R. Rodriguez 779c5d0855aSFelix Fietkau struct ath_hw_radar_conf radar_conf; 780c5d0855aSFelix Fietkau 781203c4805SLuis R. Rodriguez u32 originalGain[22]; 782203c4805SLuis R. Rodriguez int initPDADC; 783203c4805SLuis R. Rodriguez int PDADCdelta; 7846de66dd9SFelix Fietkau int led_pin; 785691680b8SFelix Fietkau u32 gpio_mask; 786691680b8SFelix Fietkau u32 gpio_val; 787203c4805SLuis R. Rodriguez 788203c4805SLuis R. Rodriguez struct ar5416IniArray iniModes; 789203c4805SLuis R. Rodriguez struct ar5416IniArray iniCommon; 790203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank0; 791203c4805SLuis R. Rodriguez struct ar5416IniArray iniBB_RfGain; 792203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank1; 793203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank2; 794203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank3; 795203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank6; 796203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank6TPC; 797203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank7; 798203c4805SLuis R. Rodriguez struct ar5416IniArray iniAddac; 799203c4805SLuis R. Rodriguez struct ar5416IniArray iniPcieSerdes; 80013ce3e99SLuis R. Rodriguez struct ar5416IniArray iniPcieSerdesLowPower; 801203c4805SLuis R. Rodriguez struct ar5416IniArray iniModesAdditional; 802203c4805SLuis R. Rodriguez struct ar5416IniArray iniModesRxGain; 803203c4805SLuis R. Rodriguez struct ar5416IniArray iniModesTxGain; 8048564328dSLuis R. Rodriguez struct ar5416IniArray iniModes_9271_1_0_only; 805193cd458SSujith struct ar5416IniArray iniCckfirNormal; 806193cd458SSujith struct ar5416IniArray iniCckfirJapan2484; 80770807e99SSujith struct ar5416IniArray iniCommon_normal_cck_fir_coeff_9271; 80870807e99SSujith struct ar5416IniArray iniCommon_japan_2484_cck_fir_coeff_9271; 80970807e99SSujith struct ar5416IniArray iniModes_9271_ANI_reg; 81070807e99SSujith struct ar5416IniArray iniModes_high_power_tx_gain_9271; 81170807e99SSujith struct ar5416IniArray iniModes_normal_power_tx_gain_9271; 812ff155a45SVasanthakumar Thiagarajan 81313ce3e99SLuis R. Rodriguez struct ar5416IniArray iniMac[ATH_INI_NUM_SPLIT]; 81413ce3e99SLuis R. Rodriguez struct ar5416IniArray iniBB[ATH_INI_NUM_SPLIT]; 81513ce3e99SLuis R. Rodriguez struct ar5416IniArray iniRadio[ATH_INI_NUM_SPLIT]; 81613ce3e99SLuis R. Rodriguez struct ar5416IniArray iniSOC[ATH_INI_NUM_SPLIT]; 81713ce3e99SLuis R. Rodriguez 818ff155a45SVasanthakumar Thiagarajan u32 intr_gen_timer_trigger; 819ff155a45SVasanthakumar Thiagarajan u32 intr_gen_timer_thresh; 820ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer_table hw_gen_timers; 821744d4025SVasanthakumar Thiagarajan 822744d4025SVasanthakumar Thiagarajan struct ar9003_txs *ts_ring; 823744d4025SVasanthakumar Thiagarajan void *ts_start; 824744d4025SVasanthakumar Thiagarajan u32 ts_paddr_start; 825744d4025SVasanthakumar Thiagarajan u32 ts_paddr_end; 826744d4025SVasanthakumar Thiagarajan u16 ts_tail; 827744d4025SVasanthakumar Thiagarajan u8 ts_size; 828aea702b7SLuis R. Rodriguez 829aea702b7SLuis R. Rodriguez u32 bb_watchdog_last_status; 830aea702b7SLuis R. Rodriguez u32 bb_watchdog_timeout_ms; /* in ms, 0 to disable */ 831717f6bedSFelix Fietkau 8321bf38661SFelix Fietkau unsigned int paprd_target_power; 8331bf38661SFelix Fietkau unsigned int paprd_training_power; 8347072bf62SVasanthakumar Thiagarajan unsigned int paprd_ratemask; 835f1a8abb0SFelix Fietkau unsigned int paprd_ratemask_ht40; 83645ef6a0bSVasanthakumar Thiagarajan bool paprd_table_write_done; 837717f6bedSFelix Fietkau u32 paprd_gain_table_entries[PAPRD_GAIN_TABLE_ENTRIES]; 838717f6bedSFelix Fietkau u8 paprd_gain_table_index[PAPRD_GAIN_TABLE_ENTRIES]; 8399a658d2bSLuis R. Rodriguez /* 8409a658d2bSLuis R. Rodriguez * Store the permanent value of Reg 0x4004in WARegVal 8419a658d2bSLuis R. Rodriguez * so we dont have to R/M/W. We should not be reading 8429a658d2bSLuis R. Rodriguez * this register when in sleep states. 8439a658d2bSLuis R. Rodriguez */ 8449a658d2bSLuis R. Rodriguez u32 WARegVal; 8456ee63f55SSenthil Balasubramanian 8466ee63f55SSenthil Balasubramanian /* Enterprise mode cap */ 8476ee63f55SSenthil Balasubramanian u32 ent_mode; 848203c4805SLuis R. Rodriguez }; 849203c4805SLuis R. Rodriguez 8500cb9e06bSFelix Fietkau struct ath_bus_ops { 8510cb9e06bSFelix Fietkau enum ath_bus_type ath_bus_type; 8520cb9e06bSFelix Fietkau void (*read_cachesize)(struct ath_common *common, int *csz); 8530cb9e06bSFelix Fietkau bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data); 8540cb9e06bSFelix Fietkau void (*bt_coex_prep)(struct ath_common *common); 8550cb9e06bSFelix Fietkau void (*extn_synch_en)(struct ath_common *common); 8560cb9e06bSFelix Fietkau }; 8570cb9e06bSFelix Fietkau 8589e4bffd2SLuis R. Rodriguez static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah) 8599e4bffd2SLuis R. Rodriguez { 8609e4bffd2SLuis R. Rodriguez return &ah->common; 8619e4bffd2SLuis R. Rodriguez } 8629e4bffd2SLuis R. Rodriguez 8639e4bffd2SLuis R. Rodriguez static inline struct ath_regulatory *ath9k_hw_regulatory(struct ath_hw *ah) 8649e4bffd2SLuis R. Rodriguez { 8659e4bffd2SLuis R. Rodriguez return &(ath9k_hw_common(ah)->regulatory); 8669e4bffd2SLuis R. Rodriguez } 8679e4bffd2SLuis R. Rodriguez 868d70357d5SLuis R. Rodriguez static inline struct ath_hw_private_ops *ath9k_hw_private_ops(struct ath_hw *ah) 869d70357d5SLuis R. Rodriguez { 870d70357d5SLuis R. Rodriguez return &ah->private_ops; 871d70357d5SLuis R. Rodriguez } 872d70357d5SLuis R. Rodriguez 873d70357d5SLuis R. Rodriguez static inline struct ath_hw_ops *ath9k_hw_ops(struct ath_hw *ah) 874d70357d5SLuis R. Rodriguez { 875d70357d5SLuis R. Rodriguez return &ah->ops; 876d70357d5SLuis R. Rodriguez } 877d70357d5SLuis R. Rodriguez 878895ad7ebSVasanthakumar Thiagarajan static inline u8 get_streams(int mask) 879895ad7ebSVasanthakumar Thiagarajan { 880895ad7ebSVasanthakumar Thiagarajan return !!(mask & BIT(0)) + !!(mask & BIT(1)) + !!(mask & BIT(2)); 881895ad7ebSVasanthakumar Thiagarajan } 882895ad7ebSVasanthakumar Thiagarajan 883f637cfd6SLuis R. Rodriguez /* Initialization, Detach, Reset */ 884203c4805SLuis R. Rodriguez const char *ath9k_hw_probe(u16 vendorid, u16 devid); 885285f2ddaSSujith void ath9k_hw_deinit(struct ath_hw *ah); 886f637cfd6SLuis R. Rodriguez int ath9k_hw_init(struct ath_hw *ah); 887203c4805SLuis R. Rodriguez int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, 88820bd2a09SFelix Fietkau struct ath9k_hw_cal_data *caldata, bool bChannelChange); 889a9a29ce6SGabor Juhos int ath9k_hw_fill_cap_info(struct ath_hw *ah); 8908fe65368SLuis R. Rodriguez u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan); 891203c4805SLuis R. Rodriguez 892203c4805SLuis R. Rodriguez /* GPIO / RFKILL / Antennae */ 893203c4805SLuis R. Rodriguez void ath9k_hw_cfg_gpio_input(struct ath_hw *ah, u32 gpio); 894203c4805SLuis R. Rodriguez u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio); 895203c4805SLuis R. Rodriguez void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio, 896203c4805SLuis R. Rodriguez u32 ah_signal_type); 897203c4805SLuis R. Rodriguez void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val); 898203c4805SLuis R. Rodriguez u32 ath9k_hw_getdefantenna(struct ath_hw *ah); 899203c4805SLuis R. Rodriguez void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna); 90021cc630fSVasanthakumar Thiagarajan void ath9k_hw_antdiv_comb_conf_get(struct ath_hw *ah, 90121cc630fSVasanthakumar Thiagarajan struct ath_hw_antcomb_conf *antconf); 90221cc630fSVasanthakumar Thiagarajan void ath9k_hw_antdiv_comb_conf_set(struct ath_hw *ah, 90321cc630fSVasanthakumar Thiagarajan struct ath_hw_antcomb_conf *antconf); 904203c4805SLuis R. Rodriguez 905203c4805SLuis R. Rodriguez /* General Operation */ 906203c4805SLuis R. Rodriguez bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout); 907a9b6b256SFelix Fietkau void ath9k_hw_write_array(struct ath_hw *ah, struct ar5416IniArray *array, 908a9b6b256SFelix Fietkau int column, unsigned int *writecnt); 909203c4805SLuis R. Rodriguez u32 ath9k_hw_reverse_bits(u32 val, u32 n); 9104f0fc7c3SLuis R. Rodriguez u16 ath9k_hw_computetxtime(struct ath_hw *ah, 911545750d3SFelix Fietkau u8 phy, int kbps, 912203c4805SLuis R. Rodriguez u32 frameLen, u16 rateix, bool shortPreamble); 913203c4805SLuis R. Rodriguez void ath9k_hw_get_channel_centers(struct ath_hw *ah, 914203c4805SLuis R. Rodriguez struct ath9k_channel *chan, 915203c4805SLuis R. Rodriguez struct chan_centers *centers); 916203c4805SLuis R. Rodriguez u32 ath9k_hw_getrxfilter(struct ath_hw *ah); 917203c4805SLuis R. Rodriguez void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits); 918203c4805SLuis R. Rodriguez bool ath9k_hw_phy_disable(struct ath_hw *ah); 919203c4805SLuis R. Rodriguez bool ath9k_hw_disable(struct ath_hw *ah); 920de40f316SFelix Fietkau void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test); 921203c4805SLuis R. Rodriguez void ath9k_hw_setopmode(struct ath_hw *ah); 922203c4805SLuis R. Rodriguez void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1); 923f2b2143eSLuis R. Rodriguez void ath9k_hw_setbssidmask(struct ath_hw *ah); 924f2b2143eSLuis R. Rodriguez void ath9k_hw_write_associd(struct ath_hw *ah); 925dd347f2fSFelix Fietkau u32 ath9k_hw_gettsf32(struct ath_hw *ah); 926203c4805SLuis R. Rodriguez u64 ath9k_hw_gettsf64(struct ath_hw *ah); 927203c4805SLuis R. Rodriguez void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64); 928203c4805SLuis R. Rodriguez void ath9k_hw_reset_tsf(struct ath_hw *ah); 92954e4cec6SSujith void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting); 9300005baf4SFelix Fietkau void ath9k_hw_init_global_settings(struct ath_hw *ah); 931b1415819SVivek Natarajan unsigned long ar9003_get_pll_sqsum_dvc(struct ath_hw *ah); 93225c56eecSLuis R. Rodriguez void ath9k_hw_set11nmac2040(struct ath_hw *ah); 933203c4805SLuis R. Rodriguez void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period); 934203c4805SLuis R. Rodriguez void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, 935203c4805SLuis R. Rodriguez const struct ath9k_beacon_state *bs); 936c9c99e5eSFelix Fietkau bool ath9k_hw_check_alive(struct ath_hw *ah); 937a91d75aeSLuis R. Rodriguez 9389ecdef4bSLuis R. Rodriguez bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode); 939a91d75aeSLuis R. Rodriguez 940ff155a45SVasanthakumar Thiagarajan /* Generic hw timer primitives */ 941ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah, 942ff155a45SVasanthakumar Thiagarajan void (*trigger)(void *), 943ff155a45SVasanthakumar Thiagarajan void (*overflow)(void *), 944ff155a45SVasanthakumar Thiagarajan void *arg, 945ff155a45SVasanthakumar Thiagarajan u8 timer_index); 946cd9bf689SLuis R. Rodriguez void ath9k_hw_gen_timer_start(struct ath_hw *ah, 947cd9bf689SLuis R. Rodriguez struct ath_gen_timer *timer, 948cd9bf689SLuis R. Rodriguez u32 timer_next, 949cd9bf689SLuis R. Rodriguez u32 timer_period); 950cd9bf689SLuis R. Rodriguez void ath9k_hw_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer); 951cd9bf689SLuis R. Rodriguez 952ff155a45SVasanthakumar Thiagarajan void ath_gen_timer_free(struct ath_hw *ah, struct ath_gen_timer *timer); 953ff155a45SVasanthakumar Thiagarajan void ath_gen_timer_isr(struct ath_hw *hw); 954ff155a45SVasanthakumar Thiagarajan 955f934c4d9SLuis R. Rodriguez void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len); 9562da4f01aSLuis R. Rodriguez 95705020d23SSujith /* HTC */ 95805020d23SSujith void ath9k_hw_htc_resetinit(struct ath_hw *ah); 95905020d23SSujith 9608fe65368SLuis R. Rodriguez /* PHY */ 9618fe65368SLuis R. Rodriguez void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled, 9628fe65368SLuis R. Rodriguez u32 *coef_mantissa, u32 *coef_exponent); 9638fe65368SLuis R. Rodriguez 964ebd5a14aSLuis R. Rodriguez /* 965ebd5a14aSLuis R. Rodriguez * Code Specific to AR5008, AR9001 or AR9002, 966ebd5a14aSLuis R. Rodriguez * we stuff these here to avoid callbacks for AR9003. 967ebd5a14aSLuis R. Rodriguez */ 968d8f492b7SLuis R. Rodriguez void ar9002_hw_cck_chan14_spread(struct ath_hw *ah); 969ebd5a14aSLuis R. Rodriguez int ar9002_hw_rf_claim(struct ath_hw *ah); 97078ec2677SLuis R. Rodriguez void ar9002_hw_enable_async_fifo(struct ath_hw *ah); 971e9141f71SSujith void ar9002_hw_update_async_fifo(struct ath_hw *ah); 9726c94fdc9SLuis R. Rodriguez void ar9002_hw_enable_wep_aggregation(struct ath_hw *ah); 973d8f492b7SLuis R. Rodriguez 974641d9921SFelix Fietkau /* 975aea702b7SLuis R. Rodriguez * Code specific to AR9003, we stuff these here to avoid callbacks 976641d9921SFelix Fietkau * for older families 977641d9921SFelix Fietkau */ 978aea702b7SLuis R. Rodriguez void ar9003_hw_bb_watchdog_config(struct ath_hw *ah); 979aea702b7SLuis R. Rodriguez void ar9003_hw_bb_watchdog_read(struct ath_hw *ah); 980aea702b7SLuis R. Rodriguez void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah); 981717f6bedSFelix Fietkau void ar9003_paprd_enable(struct ath_hw *ah, bool val); 982717f6bedSFelix Fietkau void ar9003_paprd_populate_single_table(struct ath_hw *ah, 98320bd2a09SFelix Fietkau struct ath9k_hw_cal_data *caldata, 984717f6bedSFelix Fietkau int chain); 98520bd2a09SFelix Fietkau int ar9003_paprd_create_curve(struct ath_hw *ah, 98620bd2a09SFelix Fietkau struct ath9k_hw_cal_data *caldata, int chain); 987717f6bedSFelix Fietkau int ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain); 988717f6bedSFelix Fietkau int ar9003_paprd_init_table(struct ath_hw *ah); 989717f6bedSFelix Fietkau bool ar9003_paprd_is_done(struct ath_hw *ah); 990717f6bedSFelix Fietkau void ar9003_hw_set_paprd_txdesc(struct ath_hw *ah, void *ds, u8 chains); 991641d9921SFelix Fietkau 992641d9921SFelix Fietkau /* Hardware family op attach helpers */ 9938fe65368SLuis R. Rodriguez void ar5008_hw_attach_phy_ops(struct ath_hw *ah); 9948525f280SLuis R. Rodriguez void ar9002_hw_attach_phy_ops(struct ath_hw *ah); 9958525f280SLuis R. Rodriguez void ar9003_hw_attach_phy_ops(struct ath_hw *ah); 9968fe65368SLuis R. Rodriguez 997795f5e2cSLuis R. Rodriguez void ar9002_hw_attach_calib_ops(struct ath_hw *ah); 998795f5e2cSLuis R. Rodriguez void ar9003_hw_attach_calib_ops(struct ath_hw *ah); 999795f5e2cSLuis R. Rodriguez 1000b3950e6aSLuis R. Rodriguez void ar9002_hw_attach_ops(struct ath_hw *ah); 1001b3950e6aSLuis R. Rodriguez void ar9003_hw_attach_ops(struct ath_hw *ah); 1002b3950e6aSLuis R. Rodriguez 1003c2ba3342SRajkumar Manoharan void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan); 1004ac0bb767SLuis R. Rodriguez /* 1005ac0bb767SLuis R. Rodriguez * ANI work can be shared between all families but a next 1006ac0bb767SLuis R. Rodriguez * generation implementation of ANI will be used only for AR9003 only 1007ac0bb767SLuis R. Rodriguez * for now as the other families still need to be tested with the same 1008e36b27afSLuis R. Rodriguez * next generation ANI. Feel free to start testing it though for the 1009e36b27afSLuis R. Rodriguez * older families (AR5008, AR9001, AR9002) by using modparam_force_new_ani. 1010ac0bb767SLuis R. Rodriguez */ 1011e36b27afSLuis R. Rodriguez extern int modparam_force_new_ani; 10128eb4980cSFelix Fietkau void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning); 1013bfc472bbSFelix Fietkau void ath9k_hw_proc_mib_event(struct ath_hw *ah); 101495792178SFelix Fietkau void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan); 1015ac0bb767SLuis R. Rodriguez 10167b6840abSVasanthakumar Thiagarajan #define ATH_PCIE_CAP_LINK_CTRL 0x70 10177b6840abSVasanthakumar Thiagarajan #define ATH_PCIE_CAP_LINK_L0S 1 10187b6840abSVasanthakumar Thiagarajan #define ATH_PCIE_CAP_LINK_L1 2 10197b6840abSVasanthakumar Thiagarajan 102073377256SLuis R. Rodriguez #define ATH9K_CLOCK_RATE_CCK 22 102173377256SLuis R. Rodriguez #define ATH9K_CLOCK_RATE_5GHZ_OFDM 40 102273377256SLuis R. Rodriguez #define ATH9K_CLOCK_RATE_2GHZ_OFDM 44 102373377256SLuis R. Rodriguez #define ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM 44 102473377256SLuis R. Rodriguez 1025203c4805SLuis R. Rodriguez #endif 1026