1203c4805SLuis R. Rodriguez /* 25b68138eSSujith Manoharan * Copyright (c) 2008-2011 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 46b99a7be4SVasanthakumar Thiagarajan #define AR9300_DEVID_AR9340 0x0031 473050c914SVasanthakumar Thiagarajan #define AR9300_DEVID_AR9485_PCIE 0x0032 485a63ef0fSLuis R. Rodriguez #define AR9300_DEVID_AR9580 0x0033 49423e38e8SRajkumar Manoharan #define AR9300_DEVID_AR9462 0x0034 5003689301SGabor Juhos #define AR9300_DEVID_AR9330 0x0035 517976b426SLuis R. Rodriguez 52203c4805SLuis R. Rodriguez #define AR5416_AR9100_DEVID 0x000b 537976b426SLuis R. Rodriguez 54203c4805SLuis R. Rodriguez #define AR_SUBVENDOR_ID_NOG 0x0e11 55203c4805SLuis R. Rodriguez #define AR_SUBVENDOR_ID_NEW_A 0x7065 56203c4805SLuis R. Rodriguez #define AR5416_MAGIC 0x19641014 57203c4805SLuis R. Rodriguez 58fe12946eSVasanthakumar Thiagarajan #define AR9280_COEX2WIRE_SUBSYSID 0x309b 59fe12946eSVasanthakumar Thiagarajan #define AT9285_COEX3WIRE_SA_SUBSYSID 0x30aa 60fe12946eSVasanthakumar Thiagarajan #define AT9285_COEX3WIRE_DA_SUBSYSID 0x30ab 61fe12946eSVasanthakumar Thiagarajan 62e3d01bfcSLuis R. Rodriguez #define ATH_AMPDU_LIMIT_MAX (64 * 1024 - 1) 63e3d01bfcSLuis R. Rodriguez 64cfe8cba9SLuis R. Rodriguez #define ATH_DEFAULT_NOISE_FLOOR -95 65cfe8cba9SLuis R. Rodriguez 6604658fbaSJohn W. Linville #define ATH9K_RSSI_BAD -128 67990b70abSLuis R. Rodriguez 68cac4220bSFelix Fietkau #define ATH9K_NUM_CHANNELS 38 69cac4220bSFelix Fietkau 70203c4805SLuis R. Rodriguez /* Register read/write primitives */ 719e4bffd2SLuis R. Rodriguez #define REG_WRITE(_ah, _reg, _val) \ 72f9f84e96SFelix Fietkau (_ah)->reg_ops.write((_ah), (_val), (_reg)) 739e4bffd2SLuis R. Rodriguez 749e4bffd2SLuis R. Rodriguez #define REG_READ(_ah, _reg) \ 75f9f84e96SFelix Fietkau (_ah)->reg_ops.read((_ah), (_reg)) 76203c4805SLuis R. Rodriguez 7709a525d3SSujith Manoharan #define REG_READ_MULTI(_ah, _addr, _val, _cnt) \ 78f9f84e96SFelix Fietkau (_ah)->reg_ops.multi_read((_ah), (_addr), (_val), (_cnt)) 7909a525d3SSujith Manoharan 80845e03c9SFelix Fietkau #define REG_RMW(_ah, _reg, _set, _clr) \ 81845e03c9SFelix Fietkau (_ah)->reg_ops.rmw((_ah), (_reg), (_set), (_clr)) 82845e03c9SFelix Fietkau 8320b3efd9SSujith #define ENABLE_REGWRITE_BUFFER(_ah) \ 8420b3efd9SSujith do { \ 85f9f84e96SFelix Fietkau if ((_ah)->reg_ops.enable_write_buffer) \ 86f9f84e96SFelix Fietkau (_ah)->reg_ops.enable_write_buffer((_ah)); \ 8720b3efd9SSujith } while (0) 8820b3efd9SSujith 8920b3efd9SSujith #define REGWRITE_BUFFER_FLUSH(_ah) \ 9020b3efd9SSujith do { \ 91f9f84e96SFelix Fietkau if ((_ah)->reg_ops.write_flush) \ 92f9f84e96SFelix Fietkau (_ah)->reg_ops.write_flush((_ah)); \ 9320b3efd9SSujith } while (0) 9420b3efd9SSujith 9526526202SRajkumar Manoharan #define PR_EEP(_s, _val) \ 9626526202SRajkumar Manoharan do { \ 9726526202SRajkumar Manoharan len += snprintf(buf + len, size - len, "%20s : %10d\n", \ 9826526202SRajkumar Manoharan _s, (_val)); \ 9926526202SRajkumar Manoharan } while (0) 10026526202SRajkumar Manoharan 101203c4805SLuis R. Rodriguez #define SM(_v, _f) (((_v) << _f##_S) & _f) 102203c4805SLuis R. Rodriguez #define MS(_v, _f) (((_v) & _f) >> _f##_S) 103203c4805SLuis R. Rodriguez #define REG_RMW_FIELD(_a, _r, _f, _v) \ 104845e03c9SFelix Fietkau REG_RMW(_a, _r, (((_v) << _f##_S) & _f), (_f)) 1051547da37SLuis R. Rodriguez #define REG_READ_FIELD(_a, _r, _f) \ 1061547da37SLuis R. Rodriguez (((REG_READ(_a, _r) & _f) >> _f##_S)) 107203c4805SLuis R. Rodriguez #define REG_SET_BIT(_a, _r, _f) \ 108845e03c9SFelix Fietkau REG_RMW(_a, _r, (_f), 0) 109203c4805SLuis R. Rodriguez #define REG_CLR_BIT(_a, _r, _f) \ 110845e03c9SFelix Fietkau REG_RMW(_a, _r, 0, (_f)) 111203c4805SLuis R. Rodriguez 112203c4805SLuis R. Rodriguez #define DO_DELAY(x) do { \ 113e7fc6338SRajkumar Manoharan if (((++(x) % 64) == 0) && \ 114e7fc6338SRajkumar Manoharan (ath9k_hw_common(ah)->bus_ops->ath_bus_type \ 115e7fc6338SRajkumar Manoharan != ATH_USB)) \ 116203c4805SLuis R. Rodriguez udelay(1); \ 117203c4805SLuis R. Rodriguez } while (0) 118203c4805SLuis R. Rodriguez 119a9b6b256SFelix Fietkau #define REG_WRITE_ARRAY(iniarray, column, regWr) \ 120a9b6b256SFelix Fietkau ath9k_hw_write_array(ah, iniarray, column, &(regWr)) 121203c4805SLuis R. Rodriguez 122203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_OUTPUT 0 123203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED 1 124203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_PCIE_POWER_LED 2 125203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_TX_FRAME 3 1261773912bSVasanthakumar Thiagarajan #define AR_GPIO_OUTPUT_MUX_AS_RX_CLEAR_EXTERNAL 4 127203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_MAC_NETWORK_LED 5 128203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_MAC_POWER_LED 6 129*93d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_DATA 0x16 130*93d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_CLK 0x17 131*93d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_MCI_BT_DATA 0x18 132*93d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_MCI_BT_CLK 0x19 133*93d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_WL_IN_TX 0x14 134*93d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_WL_IN_RX 0x13 135*93d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_BT_IN_TX 9 136*93d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_BT_IN_RX 8 137*93d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_RUCKUS_STROBE 0x1d 138*93d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_RUCKUS_DATA 0x1e 139203c4805SLuis R. Rodriguez 140203c4805SLuis R. Rodriguez #define AR_GPIOD_MASK 0x00001FFF 141203c4805SLuis R. Rodriguez #define AR_GPIO_BIT(_gpio) (1 << (_gpio)) 142203c4805SLuis R. Rodriguez 143203c4805SLuis R. Rodriguez #define BASE_ACTIVATE_DELAY 100 1440b488ac6SVasanthakumar Thiagarajan #define RTC_PLL_SETTLE_DELAY (AR_SREV_9340(ah) ? 1000 : 100) 145203c4805SLuis R. Rodriguez #define COEF_SCALE_S 24 146203c4805SLuis R. Rodriguez #define HT40_CHANNEL_CENTER_SHIFT 10 147203c4805SLuis R. Rodriguez 148203c4805SLuis R. Rodriguez #define ATH9K_ANTENNA0_CHAINMASK 0x1 149203c4805SLuis R. Rodriguez #define ATH9K_ANTENNA1_CHAINMASK 0x2 150203c4805SLuis R. Rodriguez 151203c4805SLuis R. Rodriguez #define ATH9K_NUM_DMA_DEBUG_REGS 8 152203c4805SLuis R. Rodriguez #define ATH9K_NUM_QUEUES 10 153203c4805SLuis R. Rodriguez 154203c4805SLuis R. Rodriguez #define MAX_RATE_POWER 63 155203c4805SLuis R. Rodriguez #define AH_WAIT_TIMEOUT 100000 /* (us) */ 156f9b604f6SGabor Juhos #define AH_TSF_WRITE_TIMEOUT 100 /* (us) */ 157203c4805SLuis R. Rodriguez #define AH_TIME_QUANTUM 10 158203c4805SLuis R. Rodriguez #define AR_KEYTABLE_SIZE 128 159d8caa839SSujith #define POWER_UP_TIME 10000 160203c4805SLuis R. Rodriguez #define SPUR_RSSI_THRESH 40 161331c5ea2SMohammed Shafi Shajakhan #define UPPER_5G_SUB_BAND_START 5700 162331c5ea2SMohammed Shafi Shajakhan #define MID_5G_SUB_BAND_START 5400 163203c4805SLuis R. Rodriguez 164203c4805SLuis R. Rodriguez #define CAB_TIMEOUT_VAL 10 165203c4805SLuis R. Rodriguez #define BEACON_TIMEOUT_VAL 10 166203c4805SLuis R. Rodriguez #define MIN_BEACON_TIMEOUT_VAL 1 167203c4805SLuis R. Rodriguez #define SLEEP_SLOP 3 168203c4805SLuis R. Rodriguez 169203c4805SLuis R. Rodriguez #define INIT_CONFIG_STATUS 0x00000000 170203c4805SLuis R. Rodriguez #define INIT_RSSI_THR 0x00000700 171203c4805SLuis R. Rodriguez #define INIT_BCON_CNTRL_REG 0x00000000 172203c4805SLuis R. Rodriguez 173203c4805SLuis R. Rodriguez #define TU_TO_USEC(_tu) ((_tu) << 10) 174203c4805SLuis R. Rodriguez 175ceb26445SVasanthakumar Thiagarajan #define ATH9K_HW_RX_HP_QDEPTH 16 176ceb26445SVasanthakumar Thiagarajan #define ATH9K_HW_RX_LP_QDEPTH 128 177ceb26445SVasanthakumar Thiagarajan 178717f6bedSFelix Fietkau #define PAPRD_GAIN_TABLE_ENTRIES 32 179717f6bedSFelix Fietkau #define PAPRD_TABLE_SZ 24 1800e44d48cSMohammed Shafi Shajakhan #define PAPRD_IDEAL_AGC2_PWR_RANGE 0xe0 181717f6bedSFelix Fietkau 182066dae93SFelix Fietkau enum ath_hw_txq_subtype { 183066dae93SFelix Fietkau ATH_TXQ_AC_BE = 0, 184066dae93SFelix Fietkau ATH_TXQ_AC_BK = 1, 185066dae93SFelix Fietkau ATH_TXQ_AC_VI = 2, 186066dae93SFelix Fietkau ATH_TXQ_AC_VO = 3, 187066dae93SFelix Fietkau }; 188066dae93SFelix Fietkau 18913ce3e99SLuis R. Rodriguez enum ath_ini_subsys { 19013ce3e99SLuis R. Rodriguez ATH_INI_PRE = 0, 19113ce3e99SLuis R. Rodriguez ATH_INI_CORE, 19213ce3e99SLuis R. Rodriguez ATH_INI_POST, 19313ce3e99SLuis R. Rodriguez ATH_INI_NUM_SPLIT, 19413ce3e99SLuis R. Rodriguez }; 19513ce3e99SLuis R. Rodriguez 196203c4805SLuis R. Rodriguez enum ath9k_hw_caps { 197364734faSFelix Fietkau ATH9K_HW_CAP_HT = BIT(0), 198364734faSFelix Fietkau ATH9K_HW_CAP_RFSILENT = BIT(1), 199364734faSFelix Fietkau ATH9K_HW_CAP_CST = BIT(2), 200364734faSFelix Fietkau ATH9K_HW_CAP_AUTOSLEEP = BIT(4), 201364734faSFelix Fietkau ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(5), 202364734faSFelix Fietkau ATH9K_HW_CAP_EDMA = BIT(6), 203364734faSFelix Fietkau ATH9K_HW_CAP_RAC_SUPPORTED = BIT(7), 204364734faSFelix Fietkau ATH9K_HW_CAP_LDPC = BIT(8), 205364734faSFelix Fietkau ATH9K_HW_CAP_FASTCLOCK = BIT(9), 206364734faSFelix Fietkau ATH9K_HW_CAP_SGI_20 = BIT(10), 207364734faSFelix Fietkau ATH9K_HW_CAP_PAPRD = BIT(11), 208364734faSFelix Fietkau ATH9K_HW_CAP_ANT_DIV_COMB = BIT(12), 209d4659912SFelix Fietkau ATH9K_HW_CAP_2GHZ = BIT(13), 210d4659912SFelix Fietkau ATH9K_HW_CAP_5GHZ = BIT(14), 211ea066d5aSMohammed Shafi Shajakhan ATH9K_HW_CAP_APM = BIT(15), 212324c74adSRajkumar Manoharan ATH9K_HW_CAP_RTT = BIT(16), 2137dc181c2SRajkumar Manoharan ATH9K_HW_CAP_MCI = BIT(17), 214203c4805SLuis R. Rodriguez }; 215203c4805SLuis R. Rodriguez 216203c4805SLuis R. Rodriguez struct ath9k_hw_capabilities { 217203c4805SLuis R. Rodriguez u32 hw_caps; /* ATH9K_HW_CAP_* from ath9k_hw_caps */ 218203c4805SLuis R. Rodriguez u16 rts_aggr_limit; 219203c4805SLuis R. Rodriguez u8 tx_chainmask; 220203c4805SLuis R. Rodriguez u8 rx_chainmask; 22147c80de6SVasanthakumar Thiagarajan u8 max_txchains; 22247c80de6SVasanthakumar Thiagarajan u8 max_rxchains; 223203c4805SLuis R. Rodriguez u8 num_gpio_pins; 224ceb26445SVasanthakumar Thiagarajan u8 rx_hp_qdepth; 225ceb26445SVasanthakumar Thiagarajan u8 rx_lp_qdepth; 226ceb26445SVasanthakumar Thiagarajan u8 rx_status_len; 227162c3be3SVasanthakumar Thiagarajan u8 tx_desc_len; 2285088c2f1SVasanthakumar Thiagarajan u8 txs_len; 2298060e169SVasanthakumar Thiagarajan u16 pcie_lcr_offset; 2308060e169SVasanthakumar Thiagarajan bool pcie_lcr_extsync_en; 231203c4805SLuis R. Rodriguez }; 232203c4805SLuis R. Rodriguez 233203c4805SLuis R. Rodriguez struct ath9k_ops_config { 234203c4805SLuis R. Rodriguez int dma_beacon_response_time; 235203c4805SLuis R. Rodriguez int sw_beacon_response_time; 236203c4805SLuis R. Rodriguez int additional_swba_backoff; 237203c4805SLuis R. Rodriguez int ack_6mb; 23841f3e54dSFelix Fietkau u32 cwm_ignore_extcca; 2396a0ec30aSLuis R. Rodriguez bool pcieSerDesWrite; 240203c4805SLuis R. Rodriguez u8 pcie_clock_req; 241203c4805SLuis R. Rodriguez u32 pcie_waen; 242203c4805SLuis R. Rodriguez u8 analog_shiftreg; 2436f481010SLuis R. Rodriguez u8 paprd_disable; 244203c4805SLuis R. Rodriguez u32 ofdm_trig_low; 245203c4805SLuis R. Rodriguez u32 ofdm_trig_high; 246203c4805SLuis R. Rodriguez u32 cck_trig_high; 247203c4805SLuis R. Rodriguez u32 cck_trig_low; 248203c4805SLuis R. Rodriguez u32 enable_ani; 249203c4805SLuis R. Rodriguez int serialize_regmode; 2500ce024cbSSujith bool rx_intr_mitigation; 25155e82df4SVasanthakumar Thiagarajan bool tx_intr_mitigation; 252203c4805SLuis R. Rodriguez #define SPUR_DISABLE 0 253203c4805SLuis R. Rodriguez #define SPUR_ENABLE_IOCTL 1 254203c4805SLuis R. Rodriguez #define SPUR_ENABLE_EEPROM 2 255203c4805SLuis R. Rodriguez #define AR_SPUR_5413_1 1640 256203c4805SLuis R. Rodriguez #define AR_SPUR_5413_2 1200 257203c4805SLuis R. Rodriguez #define AR_NO_SPUR 0x8000 258203c4805SLuis R. Rodriguez #define AR_BASE_FREQ_2GHZ 2300 259203c4805SLuis R. Rodriguez #define AR_BASE_FREQ_5GHZ 4900 260203c4805SLuis R. Rodriguez #define AR_SPUR_FEEQ_BOUND_HT40 19 261203c4805SLuis R. Rodriguez #define AR_SPUR_FEEQ_BOUND_HT20 10 262203c4805SLuis R. Rodriguez int spurmode; 263203c4805SLuis R. Rodriguez u16 spurchans[AR_EEPROM_MODAL_SPURS][2]; 264f4709fdfSLuis R. Rodriguez u8 max_txtrig_level; 265e36b27afSLuis R. Rodriguez u16 ani_poll_interval; /* ANI poll interval in ms */ 266203c4805SLuis R. Rodriguez }; 267203c4805SLuis R. Rodriguez 268203c4805SLuis R. Rodriguez enum ath9k_int { 269203c4805SLuis R. Rodriguez ATH9K_INT_RX = 0x00000001, 270203c4805SLuis R. Rodriguez ATH9K_INT_RXDESC = 0x00000002, 271b5c80475SFelix Fietkau ATH9K_INT_RXHP = 0x00000001, 272b5c80475SFelix Fietkau ATH9K_INT_RXLP = 0x00000002, 273203c4805SLuis R. Rodriguez ATH9K_INT_RXNOFRM = 0x00000008, 274203c4805SLuis R. Rodriguez ATH9K_INT_RXEOL = 0x00000010, 275203c4805SLuis R. Rodriguez ATH9K_INT_RXORN = 0x00000020, 276203c4805SLuis R. Rodriguez ATH9K_INT_TX = 0x00000040, 277203c4805SLuis R. Rodriguez ATH9K_INT_TXDESC = 0x00000080, 278203c4805SLuis R. Rodriguez ATH9K_INT_TIM_TIMER = 0x00000100, 2792ee4bd1eSMohammed Shafi Shajakhan ATH9K_INT_MCI = 0x00000200, 280aea702b7SLuis R. Rodriguez ATH9K_INT_BB_WATCHDOG = 0x00000400, 281203c4805SLuis R. Rodriguez ATH9K_INT_TXURN = 0x00000800, 282203c4805SLuis R. Rodriguez ATH9K_INT_MIB = 0x00001000, 283203c4805SLuis R. Rodriguez ATH9K_INT_RXPHY = 0x00004000, 284203c4805SLuis R. Rodriguez ATH9K_INT_RXKCM = 0x00008000, 285203c4805SLuis R. Rodriguez ATH9K_INT_SWBA = 0x00010000, 286203c4805SLuis R. Rodriguez ATH9K_INT_BMISS = 0x00040000, 287203c4805SLuis R. Rodriguez ATH9K_INT_BNR = 0x00100000, 288203c4805SLuis R. Rodriguez ATH9K_INT_TIM = 0x00200000, 289203c4805SLuis R. Rodriguez ATH9K_INT_DTIM = 0x00400000, 290203c4805SLuis R. Rodriguez ATH9K_INT_DTIMSYNC = 0x00800000, 291203c4805SLuis R. Rodriguez ATH9K_INT_GPIO = 0x01000000, 292203c4805SLuis R. Rodriguez ATH9K_INT_CABEND = 0x02000000, 293203c4805SLuis R. Rodriguez ATH9K_INT_TSFOOR = 0x04000000, 294ff155a45SVasanthakumar Thiagarajan ATH9K_INT_GENTIMER = 0x08000000, 295203c4805SLuis R. Rodriguez ATH9K_INT_CST = 0x10000000, 296203c4805SLuis R. Rodriguez ATH9K_INT_GTT = 0x20000000, 297203c4805SLuis R. Rodriguez ATH9K_INT_FATAL = 0x40000000, 298203c4805SLuis R. Rodriguez ATH9K_INT_GLOBAL = 0x80000000, 299203c4805SLuis R. Rodriguez ATH9K_INT_BMISC = ATH9K_INT_TIM | 300203c4805SLuis R. Rodriguez ATH9K_INT_DTIM | 301203c4805SLuis R. Rodriguez ATH9K_INT_DTIMSYNC | 302203c4805SLuis R. Rodriguez ATH9K_INT_TSFOOR | 303203c4805SLuis R. Rodriguez ATH9K_INT_CABEND, 304203c4805SLuis R. Rodriguez ATH9K_INT_COMMON = ATH9K_INT_RXNOFRM | 305203c4805SLuis R. Rodriguez ATH9K_INT_RXDESC | 306203c4805SLuis R. Rodriguez ATH9K_INT_RXEOL | 307203c4805SLuis R. Rodriguez ATH9K_INT_RXORN | 308203c4805SLuis R. Rodriguez ATH9K_INT_TXURN | 309203c4805SLuis R. Rodriguez ATH9K_INT_TXDESC | 310203c4805SLuis R. Rodriguez ATH9K_INT_MIB | 311203c4805SLuis R. Rodriguez ATH9K_INT_RXPHY | 312203c4805SLuis R. Rodriguez ATH9K_INT_RXKCM | 313203c4805SLuis R. Rodriguez ATH9K_INT_SWBA | 314203c4805SLuis R. Rodriguez ATH9K_INT_BMISS | 315203c4805SLuis R. Rodriguez ATH9K_INT_GPIO, 316203c4805SLuis R. Rodriguez ATH9K_INT_NOCARD = 0xffffffff 317203c4805SLuis R. Rodriguez }; 318203c4805SLuis R. Rodriguez 319203c4805SLuis R. Rodriguez #define CHANNEL_CW_INT 0x00002 320203c4805SLuis R. Rodriguez #define CHANNEL_CCK 0x00020 321203c4805SLuis R. Rodriguez #define CHANNEL_OFDM 0x00040 322203c4805SLuis R. Rodriguez #define CHANNEL_2GHZ 0x00080 323203c4805SLuis R. Rodriguez #define CHANNEL_5GHZ 0x00100 324203c4805SLuis R. Rodriguez #define CHANNEL_PASSIVE 0x00200 325203c4805SLuis R. Rodriguez #define CHANNEL_DYN 0x00400 326203c4805SLuis R. Rodriguez #define CHANNEL_HALF 0x04000 327203c4805SLuis R. Rodriguez #define CHANNEL_QUARTER 0x08000 328203c4805SLuis R. Rodriguez #define CHANNEL_HT20 0x10000 329203c4805SLuis R. Rodriguez #define CHANNEL_HT40PLUS 0x20000 330203c4805SLuis R. Rodriguez #define CHANNEL_HT40MINUS 0x40000 331203c4805SLuis R. Rodriguez 332203c4805SLuis R. Rodriguez #define CHANNEL_A (CHANNEL_5GHZ|CHANNEL_OFDM) 333203c4805SLuis R. Rodriguez #define CHANNEL_B (CHANNEL_2GHZ|CHANNEL_CCK) 334203c4805SLuis R. Rodriguez #define CHANNEL_G (CHANNEL_2GHZ|CHANNEL_OFDM) 335203c4805SLuis R. Rodriguez #define CHANNEL_G_HT20 (CHANNEL_2GHZ|CHANNEL_HT20) 336203c4805SLuis R. Rodriguez #define CHANNEL_A_HT20 (CHANNEL_5GHZ|CHANNEL_HT20) 337203c4805SLuis R. Rodriguez #define CHANNEL_G_HT40PLUS (CHANNEL_2GHZ|CHANNEL_HT40PLUS) 338203c4805SLuis R. Rodriguez #define CHANNEL_G_HT40MINUS (CHANNEL_2GHZ|CHANNEL_HT40MINUS) 339203c4805SLuis R. Rodriguez #define CHANNEL_A_HT40PLUS (CHANNEL_5GHZ|CHANNEL_HT40PLUS) 340203c4805SLuis R. Rodriguez #define CHANNEL_A_HT40MINUS (CHANNEL_5GHZ|CHANNEL_HT40MINUS) 341203c4805SLuis R. Rodriguez #define CHANNEL_ALL \ 342203c4805SLuis R. Rodriguez (CHANNEL_OFDM| \ 343203c4805SLuis R. Rodriguez CHANNEL_CCK| \ 344203c4805SLuis R. Rodriguez CHANNEL_2GHZ | \ 345203c4805SLuis R. Rodriguez CHANNEL_5GHZ | \ 346203c4805SLuis R. Rodriguez CHANNEL_HT20 | \ 347203c4805SLuis R. Rodriguez CHANNEL_HT40PLUS | \ 348203c4805SLuis R. Rodriguez CHANNEL_HT40MINUS) 349203c4805SLuis R. Rodriguez 350324c74adSRajkumar Manoharan #define MAX_RTT_TABLE_ENTRY 6 351324c74adSRajkumar Manoharan #define RTT_HIST_MAX 3 352324c74adSRajkumar Manoharan struct ath9k_rtt_hist { 353324c74adSRajkumar Manoharan u32 table[AR9300_MAX_CHAINS][RTT_HIST_MAX][MAX_RTT_TABLE_ENTRY]; 354324c74adSRajkumar Manoharan u8 num_readings; 355324c74adSRajkumar Manoharan }; 356324c74adSRajkumar Manoharan 3575f0c04eaSRajkumar Manoharan #define MAX_IQCAL_MEASUREMENT 8 35877a5a664SRajkumar Manoharan #define MAX_CL_TAB_ENTRY 16 3595f0c04eaSRajkumar Manoharan 36020bd2a09SFelix Fietkau struct ath9k_hw_cal_data { 361203c4805SLuis R. Rodriguez u16 channel; 362203c4805SLuis R. Rodriguez u32 channelFlags; 363203c4805SLuis R. Rodriguez int32_t CalValid; 364203c4805SLuis R. Rodriguez int8_t iCoff; 365203c4805SLuis R. Rodriguez int8_t qCoff; 366717f6bedSFelix Fietkau bool paprd_done; 3674254bc1cSFelix Fietkau bool nfcal_pending; 36870cf1533SFelix Fietkau bool nfcal_interference; 3695f0c04eaSRajkumar Manoharan bool done_txiqcal_once; 37077a5a664SRajkumar Manoharan bool done_txclcal_once; 371717f6bedSFelix Fietkau u16 small_signal_gain[AR9300_MAX_CHAINS]; 372717f6bedSFelix Fietkau u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ]; 3735f0c04eaSRajkumar Manoharan u32 num_measures[AR9300_MAX_CHAINS]; 3745f0c04eaSRajkumar Manoharan int tx_corr_coeff[MAX_IQCAL_MEASUREMENT][AR9300_MAX_CHAINS]; 37577a5a664SRajkumar Manoharan u32 tx_clcal[AR9300_MAX_CHAINS][MAX_CL_TAB_ENTRY]; 37620bd2a09SFelix Fietkau struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; 377324c74adSRajkumar Manoharan struct ath9k_rtt_hist rtt_hist; 37820bd2a09SFelix Fietkau }; 37920bd2a09SFelix Fietkau 38020bd2a09SFelix Fietkau struct ath9k_channel { 38120bd2a09SFelix Fietkau struct ieee80211_channel *chan; 382093115b7SFelix Fietkau struct ar5416AniState ani; 38320bd2a09SFelix Fietkau u16 channel; 38420bd2a09SFelix Fietkau u32 channelFlags; 38520bd2a09SFelix Fietkau u32 chanmode; 386d9891c78SFelix Fietkau s16 noisefloor; 387203c4805SLuis R. Rodriguez }; 388203c4805SLuis R. Rodriguez 389203c4805SLuis R. Rodriguez #define IS_CHAN_G(_c) ((((_c)->channelFlags & (CHANNEL_G)) == CHANNEL_G) || \ 390203c4805SLuis R. Rodriguez (((_c)->channelFlags & CHANNEL_G_HT20) == CHANNEL_G_HT20) || \ 391203c4805SLuis R. Rodriguez (((_c)->channelFlags & CHANNEL_G_HT40PLUS) == CHANNEL_G_HT40PLUS) || \ 392203c4805SLuis R. Rodriguez (((_c)->channelFlags & CHANNEL_G_HT40MINUS) == CHANNEL_G_HT40MINUS)) 393203c4805SLuis R. Rodriguez #define IS_CHAN_OFDM(_c) (((_c)->channelFlags & CHANNEL_OFDM) != 0) 394203c4805SLuis R. Rodriguez #define IS_CHAN_5GHZ(_c) (((_c)->channelFlags & CHANNEL_5GHZ) != 0) 395203c4805SLuis R. Rodriguez #define IS_CHAN_2GHZ(_c) (((_c)->channelFlags & CHANNEL_2GHZ) != 0) 396203c4805SLuis R. Rodriguez #define IS_CHAN_HALF_RATE(_c) (((_c)->channelFlags & CHANNEL_HALF) != 0) 397203c4805SLuis R. Rodriguez #define IS_CHAN_QUARTER_RATE(_c) (((_c)->channelFlags & CHANNEL_QUARTER) != 0) 3986b42e8d0SFelix Fietkau #define IS_CHAN_A_FAST_CLOCK(_ah, _c) \ 399203c4805SLuis R. Rodriguez ((((_c)->channelFlags & CHANNEL_5GHZ) != 0) && \ 4006b42e8d0SFelix Fietkau ((_ah)->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK)) 401203c4805SLuis R. Rodriguez 402203c4805SLuis R. Rodriguez /* These macros check chanmode and not channelFlags */ 403203c4805SLuis R. Rodriguez #define IS_CHAN_B(_c) ((_c)->chanmode == CHANNEL_B) 404203c4805SLuis R. Rodriguez #define IS_CHAN_HT20(_c) (((_c)->chanmode == CHANNEL_A_HT20) || \ 405203c4805SLuis R. Rodriguez ((_c)->chanmode == CHANNEL_G_HT20)) 406203c4805SLuis R. Rodriguez #define IS_CHAN_HT40(_c) (((_c)->chanmode == CHANNEL_A_HT40PLUS) || \ 407203c4805SLuis R. Rodriguez ((_c)->chanmode == CHANNEL_A_HT40MINUS) || \ 408203c4805SLuis R. Rodriguez ((_c)->chanmode == CHANNEL_G_HT40PLUS) || \ 409203c4805SLuis R. Rodriguez ((_c)->chanmode == CHANNEL_G_HT40MINUS)) 410203c4805SLuis R. Rodriguez #define IS_CHAN_HT(_c) (IS_CHAN_HT20((_c)) || IS_CHAN_HT40((_c))) 411203c4805SLuis R. Rodriguez 412203c4805SLuis R. Rodriguez enum ath9k_power_mode { 413203c4805SLuis R. Rodriguez ATH9K_PM_AWAKE = 0, 414203c4805SLuis R. Rodriguez ATH9K_PM_FULL_SLEEP, 415203c4805SLuis R. Rodriguez ATH9K_PM_NETWORK_SLEEP, 416203c4805SLuis R. Rodriguez ATH9K_PM_UNDEFINED 417203c4805SLuis R. Rodriguez }; 418203c4805SLuis R. Rodriguez 419203c4805SLuis R. Rodriguez enum ser_reg_mode { 420203c4805SLuis R. Rodriguez SER_REG_MODE_OFF = 0, 421203c4805SLuis R. Rodriguez SER_REG_MODE_ON = 1, 422203c4805SLuis R. Rodriguez SER_REG_MODE_AUTO = 2, 423203c4805SLuis R. Rodriguez }; 424203c4805SLuis R. Rodriguez 425ad7b8060SVasanthakumar Thiagarajan enum ath9k_rx_qtype { 426ad7b8060SVasanthakumar Thiagarajan ATH9K_RX_QUEUE_HP, 427ad7b8060SVasanthakumar Thiagarajan ATH9K_RX_QUEUE_LP, 428ad7b8060SVasanthakumar Thiagarajan ATH9K_RX_QUEUE_MAX, 429ad7b8060SVasanthakumar Thiagarajan }; 430ad7b8060SVasanthakumar Thiagarajan 4312ee4bd1eSMohammed Shafi Shajakhan enum mci_message_header { /* length of payload */ 4322ee4bd1eSMohammed Shafi Shajakhan MCI_LNA_CTRL = 0x10, /* len = 0 */ 4332ee4bd1eSMohammed Shafi Shajakhan MCI_CONT_NACK = 0x20, /* len = 0 */ 4342ee4bd1eSMohammed Shafi Shajakhan MCI_CONT_INFO = 0x30, /* len = 4 */ 4352ee4bd1eSMohammed Shafi Shajakhan MCI_CONT_RST = 0x40, /* len = 0 */ 4362ee4bd1eSMohammed Shafi Shajakhan MCI_SCHD_INFO = 0x50, /* len = 16 */ 4372ee4bd1eSMohammed Shafi Shajakhan MCI_CPU_INT = 0x60, /* len = 4 */ 4382ee4bd1eSMohammed Shafi Shajakhan MCI_SYS_WAKING = 0x70, /* len = 0 */ 4392ee4bd1eSMohammed Shafi Shajakhan MCI_GPM = 0x80, /* len = 16 */ 4402ee4bd1eSMohammed Shafi Shajakhan MCI_LNA_INFO = 0x90, /* len = 1 */ 4412ee4bd1eSMohammed Shafi Shajakhan MCI_LNA_STATE = 0x94, 4422ee4bd1eSMohammed Shafi Shajakhan MCI_LNA_TAKE = 0x98, 4432ee4bd1eSMohammed Shafi Shajakhan MCI_LNA_TRANS = 0x9c, 4442ee4bd1eSMohammed Shafi Shajakhan MCI_SYS_SLEEPING = 0xa0, /* len = 0 */ 4452ee4bd1eSMohammed Shafi Shajakhan MCI_REQ_WAKE = 0xc0, /* len = 0 */ 4462ee4bd1eSMohammed Shafi Shajakhan MCI_DEBUG_16 = 0xfe, /* len = 2 */ 4472ee4bd1eSMohammed Shafi Shajakhan MCI_REMOTE_RESET = 0xff /* len = 16 */ 4482ee4bd1eSMohammed Shafi Shajakhan }; 4492ee4bd1eSMohammed Shafi Shajakhan 4507dc181c2SRajkumar Manoharan enum ath_mci_gpm_coex_profile_type { 4517dc181c2SRajkumar Manoharan MCI_GPM_COEX_PROFILE_UNKNOWN, 4527dc181c2SRajkumar Manoharan MCI_GPM_COEX_PROFILE_RFCOMM, 4537dc181c2SRajkumar Manoharan MCI_GPM_COEX_PROFILE_A2DP, 4547dc181c2SRajkumar Manoharan MCI_GPM_COEX_PROFILE_HID, 4557dc181c2SRajkumar Manoharan MCI_GPM_COEX_PROFILE_BNEP, 4567dc181c2SRajkumar Manoharan MCI_GPM_COEX_PROFILE_VOICE, 4577dc181c2SRajkumar Manoharan MCI_GPM_COEX_PROFILE_MAX 4587dc181c2SRajkumar Manoharan }; 4597dc181c2SRajkumar Manoharan 4602ee4bd1eSMohammed Shafi Shajakhan /* MCI GPM/Coex opcode/type definitions */ 4612ee4bd1eSMohammed Shafi Shajakhan enum { 4622ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_W_GPM_PAYLOAD = 1, 4632ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_GPM_TYPE = 4, 4642ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_GPM_OPCODE = 5, 4652ee4bd1eSMohammed Shafi Shajakhan /* MCI_GPM_WLAN_CAL_REQ, MCI_GPM_WLAN_CAL_DONE */ 4662ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_WLAN_CAL_W_SEQUENCE = 2, 4672ee4bd1eSMohammed Shafi Shajakhan 4682ee4bd1eSMohammed Shafi Shajakhan /* MCI_GPM_COEX_VERSION_QUERY */ 4692ee4bd1eSMohammed Shafi Shajakhan /* MCI_GPM_COEX_VERSION_RESPONSE */ 4702ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_MAJOR_VERSION = 6, 4712ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_MINOR_VERSION = 7, 4722ee4bd1eSMohammed Shafi Shajakhan /* MCI_GPM_COEX_STATUS_QUERY */ 4732ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_BT_BITMAP = 6, 4742ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_WLAN_BITMAP = 7, 4752ee4bd1eSMohammed Shafi Shajakhan /* MCI_GPM_COEX_HALT_BT_GPM */ 4762ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_HALT_STATE = 6, 4772ee4bd1eSMohammed Shafi Shajakhan /* MCI_GPM_COEX_WLAN_CHANNELS */ 4782ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_CHANNEL_MAP = 6, 4792ee4bd1eSMohammed Shafi Shajakhan /* MCI_GPM_COEX_BT_PROFILE_INFO */ 4802ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_PROFILE_TYPE = 6, 4812ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_PROFILE_LINKID = 7, 4822ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_PROFILE_STATE = 8, 4832ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_PROFILE_ROLE = 9, 4842ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_PROFILE_RATE = 10, 4852ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_PROFILE_VOTYPE = 11, 4862ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_H_PROFILE_T = 12, 4872ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_PROFILE_W = 14, 4882ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_PROFILE_A = 15, 4892ee4bd1eSMohammed Shafi Shajakhan /* MCI_GPM_COEX_BT_STATUS_UPDATE */ 4902ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_STATUS_TYPE = 6, 4912ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_STATUS_LINKID = 7, 4922ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_STATUS_STATE = 8, 4932ee4bd1eSMohammed Shafi Shajakhan /* MCI_GPM_COEX_BT_UPDATE_FLAGS */ 4942ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_W_BT_FLAGS = 6, 4952ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_B_BT_FLAGS_OP = 10 4962ee4bd1eSMohammed Shafi Shajakhan }; 4972ee4bd1eSMohammed Shafi Shajakhan 4982ee4bd1eSMohammed Shafi Shajakhan enum mci_gpm_subtype { 4992ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_BT_CAL_REQ = 0, 5002ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_BT_CAL_GRANT = 1, 5012ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_BT_CAL_DONE = 2, 5022ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_WLAN_CAL_REQ = 3, 5032ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_WLAN_CAL_GRANT = 4, 5042ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_WLAN_CAL_DONE = 5, 5052ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_AGENT = 0x0c, 5062ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_RSVD_PATTERN = 0xfe, 5072ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_RSVD_PATTERN32 = 0xfefefefe, 5082ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_BT_DEBUG = 0xff 5092ee4bd1eSMohammed Shafi Shajakhan }; 5102ee4bd1eSMohammed Shafi Shajakhan 5112ee4bd1eSMohammed Shafi Shajakhan enum mci_bt_state { 5122ee4bd1eSMohammed Shafi Shajakhan MCI_BT_SLEEP, 5132ee4bd1eSMohammed Shafi Shajakhan MCI_BT_AWAKE, 5142ee4bd1eSMohammed Shafi Shajakhan MCI_BT_CAL_START, 5152ee4bd1eSMohammed Shafi Shajakhan MCI_BT_CAL 5162ee4bd1eSMohammed Shafi Shajakhan }; 5172ee4bd1eSMohammed Shafi Shajakhan 5182ee4bd1eSMohammed Shafi Shajakhan /* Type of state query */ 5192ee4bd1eSMohammed Shafi Shajakhan enum mci_state_type { 5202ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_ENABLE, 5212ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_INIT_GPM_OFFSET, 5222ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_NEXT_GPM_OFFSET, 5232ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_LAST_GPM_OFFSET, 5242ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_BT, 5252ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_SET_BT_SLEEP, 5262ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_SET_BT_AWAKE, 5272ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_SET_BT_CAL_START, 5282ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_SET_BT_CAL, 5292ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_LAST_SCHD_MSG_OFFSET, 5302ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_REMOTE_SLEEP, 5312ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_CONT_RSSI_POWER, 5322ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_CONT_PRIORITY, 5332ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_CONT_TXRX, 5342ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_RESET_REQ_WAKE, 5352ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_SEND_WLAN_COEX_VERSION, 5362ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_SET_BT_COEX_VERSION, 5372ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_SEND_WLAN_CHANNELS, 5382ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_SEND_VERSION_QUERY, 5392ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_SEND_STATUS_QUERY, 5402ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_NEED_FLUSH_BT_INFO, 5412ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_SET_CONCUR_TX_PRI, 5422ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_RECOVER_RX, 5432ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_NEED_FTP_STOMP, 5442ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_NEED_TUNING, 5452ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_DEBUG, 5462ee4bd1eSMohammed Shafi Shajakhan MCI_STATE_MAX 5472ee4bd1eSMohammed Shafi Shajakhan }; 5482ee4bd1eSMohammed Shafi Shajakhan 5492ee4bd1eSMohammed Shafi Shajakhan enum mci_gpm_coex_opcode { 5502ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_VERSION_QUERY, 5512ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_VERSION_RESPONSE, 5522ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_STATUS_QUERY, 5532ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_HALT_BT_GPM, 5542ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_WLAN_CHANNELS, 5552ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_BT_PROFILE_INFO, 5562ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_BT_STATUS_UPDATE, 5572ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_COEX_BT_UPDATE_FLAGS 5582ee4bd1eSMohammed Shafi Shajakhan }; 5592ee4bd1eSMohammed Shafi Shajakhan 5602ee4bd1eSMohammed Shafi Shajakhan #define MCI_GPM_NOMORE 0 5612ee4bd1eSMohammed Shafi Shajakhan #define MCI_GPM_MORE 1 5622ee4bd1eSMohammed Shafi Shajakhan #define MCI_GPM_INVALID 0xffffffff 5632ee4bd1eSMohammed Shafi Shajakhan 5642ee4bd1eSMohammed Shafi Shajakhan #define MCI_GPM_RECYCLE(_p_gpm) do { \ 5652ee4bd1eSMohammed Shafi Shajakhan *(((u32 *)_p_gpm) + MCI_GPM_COEX_W_GPM_PAYLOAD) = \ 5662ee4bd1eSMohammed Shafi Shajakhan MCI_GPM_RSVD_PATTERN32; \ 5672ee4bd1eSMohammed Shafi Shajakhan } while (0) 5682ee4bd1eSMohammed Shafi Shajakhan 5692ee4bd1eSMohammed Shafi Shajakhan #define MCI_GPM_TYPE(_p_gpm) \ 5702ee4bd1eSMohammed Shafi Shajakhan (*(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_TYPE) & 0xff) 5712ee4bd1eSMohammed Shafi Shajakhan 5722ee4bd1eSMohammed Shafi Shajakhan #define MCI_GPM_OPCODE(_p_gpm) \ 5732ee4bd1eSMohammed Shafi Shajakhan (*(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_OPCODE) & 0xff) 5742ee4bd1eSMohammed Shafi Shajakhan 5752ee4bd1eSMohammed Shafi Shajakhan #define MCI_GPM_SET_CAL_TYPE(_p_gpm, _cal_type) do { \ 5762ee4bd1eSMohammed Shafi Shajakhan *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_TYPE) = (_cal_type) & 0xff;\ 5772ee4bd1eSMohammed Shafi Shajakhan } while (0) 5782ee4bd1eSMohammed Shafi Shajakhan 5792ee4bd1eSMohammed Shafi Shajakhan #define MCI_GPM_SET_TYPE_OPCODE(_p_gpm, _type, _opcode) do { \ 5802ee4bd1eSMohammed Shafi Shajakhan *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_TYPE) = (_type) & 0xff; \ 5812ee4bd1eSMohammed Shafi Shajakhan *(((u8 *)(_p_gpm)) + MCI_GPM_COEX_B_GPM_OPCODE) = (_opcode) & 0xff;\ 5822ee4bd1eSMohammed Shafi Shajakhan } while (0) 5832ee4bd1eSMohammed Shafi Shajakhan 5842ee4bd1eSMohammed Shafi Shajakhan #define MCI_GPM_IS_CAL_TYPE(_type) ((_type) <= MCI_GPM_WLAN_CAL_DONE) 5852ee4bd1eSMohammed Shafi Shajakhan 586203c4805SLuis R. Rodriguez struct ath9k_beacon_state { 587203c4805SLuis R. Rodriguez u32 bs_nexttbtt; 588203c4805SLuis R. Rodriguez u32 bs_nextdtim; 589203c4805SLuis R. Rodriguez u32 bs_intval; 590203c4805SLuis R. Rodriguez #define ATH9K_TSFOOR_THRESHOLD 0x00004240 /* 16k us */ 591203c4805SLuis R. Rodriguez u32 bs_dtimperiod; 592203c4805SLuis R. Rodriguez u16 bs_cfpperiod; 593203c4805SLuis R. Rodriguez u16 bs_cfpmaxduration; 594203c4805SLuis R. Rodriguez u32 bs_cfpnext; 595203c4805SLuis R. Rodriguez u16 bs_timoffset; 596203c4805SLuis R. Rodriguez u16 bs_bmissthreshold; 597203c4805SLuis R. Rodriguez u32 bs_sleepduration; 598203c4805SLuis R. Rodriguez u32 bs_tsfoor_threshold; 599203c4805SLuis R. Rodriguez }; 600203c4805SLuis R. Rodriguez 601203c4805SLuis R. Rodriguez struct chan_centers { 602203c4805SLuis R. Rodriguez u16 synth_center; 603203c4805SLuis R. Rodriguez u16 ctl_center; 604203c4805SLuis R. Rodriguez u16 ext_center; 605203c4805SLuis R. Rodriguez }; 606203c4805SLuis R. Rodriguez 607203c4805SLuis R. Rodriguez enum { 608203c4805SLuis R. Rodriguez ATH9K_RESET_POWER_ON, 609203c4805SLuis R. Rodriguez ATH9K_RESET_WARM, 610203c4805SLuis R. Rodriguez ATH9K_RESET_COLD, 611203c4805SLuis R. Rodriguez }; 612203c4805SLuis R. Rodriguez 613203c4805SLuis R. Rodriguez struct ath9k_hw_version { 614203c4805SLuis R. Rodriguez u32 magic; 615203c4805SLuis R. Rodriguez u16 devid; 616203c4805SLuis R. Rodriguez u16 subvendorid; 617203c4805SLuis R. Rodriguez u32 macVersion; 618203c4805SLuis R. Rodriguez u16 macRev; 619203c4805SLuis R. Rodriguez u16 phyRev; 620203c4805SLuis R. Rodriguez u16 analog5GhzRev; 621203c4805SLuis R. Rodriguez u16 analog2GhzRev; 6220b5ead91SSujith Manoharan enum ath_usb_dev usbdev; 623203c4805SLuis R. Rodriguez }; 624203c4805SLuis R. Rodriguez 625ff155a45SVasanthakumar Thiagarajan /* Generic TSF timer definitions */ 626ff155a45SVasanthakumar Thiagarajan 627ff155a45SVasanthakumar Thiagarajan #define ATH_MAX_GEN_TIMER 16 628ff155a45SVasanthakumar Thiagarajan 629ff155a45SVasanthakumar Thiagarajan #define AR_GENTMR_BIT(_index) (1 << (_index)) 630ff155a45SVasanthakumar Thiagarajan 631ff155a45SVasanthakumar Thiagarajan /* 63277c2061dSWalter Goldens * Using de Bruijin sequence to look up 1's index in a 32 bit number 633ff155a45SVasanthakumar Thiagarajan * debruijn32 = 0000 0111 0111 1100 1011 0101 0011 0001 634ff155a45SVasanthakumar Thiagarajan */ 635c90017ddSVasanthakumar Thiagarajan #define debruijn32 0x077CB531U 636ff155a45SVasanthakumar Thiagarajan 637ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer_configuration { 638ff155a45SVasanthakumar Thiagarajan u32 next_addr; 639ff155a45SVasanthakumar Thiagarajan u32 period_addr; 640ff155a45SVasanthakumar Thiagarajan u32 mode_addr; 641ff155a45SVasanthakumar Thiagarajan u32 mode_mask; 642ff155a45SVasanthakumar Thiagarajan }; 643ff155a45SVasanthakumar Thiagarajan 644ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer { 645ff155a45SVasanthakumar Thiagarajan void (*trigger)(void *arg); 646ff155a45SVasanthakumar Thiagarajan void (*overflow)(void *arg); 647ff155a45SVasanthakumar Thiagarajan void *arg; 648ff155a45SVasanthakumar Thiagarajan u8 index; 649ff155a45SVasanthakumar Thiagarajan }; 650ff155a45SVasanthakumar Thiagarajan 651ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer_table { 652ff155a45SVasanthakumar Thiagarajan u32 gen_timer_index[32]; 653ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer *timers[ATH_MAX_GEN_TIMER]; 654ff155a45SVasanthakumar Thiagarajan union { 655ff155a45SVasanthakumar Thiagarajan unsigned long timer_bits; 656ff155a45SVasanthakumar Thiagarajan u16 val; 657ff155a45SVasanthakumar Thiagarajan } timer_mask; 658ff155a45SVasanthakumar Thiagarajan }; 659ff155a45SVasanthakumar Thiagarajan 66021cc630fSVasanthakumar Thiagarajan struct ath_hw_antcomb_conf { 66121cc630fSVasanthakumar Thiagarajan u8 main_lna_conf; 66221cc630fSVasanthakumar Thiagarajan u8 alt_lna_conf; 66321cc630fSVasanthakumar Thiagarajan u8 fast_div_bias; 664c6ba9febSMohammed Shafi Shajakhan u8 main_gaintb; 665c6ba9febSMohammed Shafi Shajakhan u8 alt_gaintb; 666c6ba9febSMohammed Shafi Shajakhan int lna1_lna2_delta; 6678afbcc8bSMohammed Shafi Shajakhan u8 div_group; 66821cc630fSVasanthakumar Thiagarajan }; 66921cc630fSVasanthakumar Thiagarajan 670d70357d5SLuis R. Rodriguez /** 6714e8c14e9SFelix Fietkau * struct ath_hw_radar_conf - radar detection initialization parameters 6724e8c14e9SFelix Fietkau * 6734e8c14e9SFelix Fietkau * @pulse_inband: threshold for checking the ratio of in-band power 6744e8c14e9SFelix Fietkau * to total power for short radar pulses (half dB steps) 6754e8c14e9SFelix Fietkau * @pulse_inband_step: threshold for checking an in-band power to total 6764e8c14e9SFelix Fietkau * power ratio increase for short radar pulses (half dB steps) 6774e8c14e9SFelix Fietkau * @pulse_height: threshold for detecting the beginning of a short 6784e8c14e9SFelix Fietkau * radar pulse (dB step) 6794e8c14e9SFelix Fietkau * @pulse_rssi: threshold for detecting if a short radar pulse is 6804e8c14e9SFelix Fietkau * gone (dB step) 6814e8c14e9SFelix Fietkau * @pulse_maxlen: maximum pulse length (0.8 us steps) 6824e8c14e9SFelix Fietkau * 6834e8c14e9SFelix Fietkau * @radar_rssi: RSSI threshold for starting long radar detection (dB steps) 6844e8c14e9SFelix Fietkau * @radar_inband: threshold for checking the ratio of in-band power 6854e8c14e9SFelix Fietkau * to total power for long radar pulses (half dB steps) 6864e8c14e9SFelix Fietkau * @fir_power: threshold for detecting the end of a long radar pulse (dB) 6874e8c14e9SFelix Fietkau * 6884e8c14e9SFelix Fietkau * @ext_channel: enable extension channel radar detection 6894e8c14e9SFelix Fietkau */ 6904e8c14e9SFelix Fietkau struct ath_hw_radar_conf { 6914e8c14e9SFelix Fietkau unsigned int pulse_inband; 6924e8c14e9SFelix Fietkau unsigned int pulse_inband_step; 6934e8c14e9SFelix Fietkau unsigned int pulse_height; 6944e8c14e9SFelix Fietkau unsigned int pulse_rssi; 6954e8c14e9SFelix Fietkau unsigned int pulse_maxlen; 6964e8c14e9SFelix Fietkau 6974e8c14e9SFelix Fietkau unsigned int radar_rssi; 6984e8c14e9SFelix Fietkau unsigned int radar_inband; 6994e8c14e9SFelix Fietkau int fir_power; 7004e8c14e9SFelix Fietkau 7014e8c14e9SFelix Fietkau bool ext_channel; 7024e8c14e9SFelix Fietkau }; 7034e8c14e9SFelix Fietkau 7044e8c14e9SFelix Fietkau /** 705d70357d5SLuis R. Rodriguez * struct ath_hw_private_ops - callbacks used internally by hardware code 706d70357d5SLuis R. Rodriguez * 707d70357d5SLuis R. Rodriguez * This structure contains private callbacks designed to only be used internally 708d70357d5SLuis R. Rodriguez * by the hardware core. 709d70357d5SLuis R. Rodriguez * 710795f5e2cSLuis R. Rodriguez * @init_cal_settings: setup types of calibrations supported 711795f5e2cSLuis R. Rodriguez * @init_cal: starts actual calibration 712795f5e2cSLuis R. Rodriguez * 713d70357d5SLuis R. Rodriguez * @init_mode_regs: Initializes mode registers 714991312d8SLuis R. Rodriguez * @init_mode_gain_regs: Initialize TX/RX gain registers 7158fe65368SLuis R. Rodriguez * 7168fe65368SLuis R. Rodriguez * @rf_set_freq: change frequency 7178fe65368SLuis R. Rodriguez * @spur_mitigate_freq: spur mitigation 7188fe65368SLuis R. Rodriguez * @rf_alloc_ext_banks: 7198fe65368SLuis R. Rodriguez * @rf_free_ext_banks: 7208fe65368SLuis R. Rodriguez * @set_rf_regs: 72164773964SLuis R. Rodriguez * @compute_pll_control: compute the PLL control value to use for 72264773964SLuis R. Rodriguez * AR_RTC_PLL_CONTROL for a given channel 723795f5e2cSLuis R. Rodriguez * @setup_calibration: set up calibration 724795f5e2cSLuis R. Rodriguez * @iscal_supported: used to query if a type of calibration is supported 725ac0bb767SLuis R. Rodriguez * 726e36b27afSLuis R. Rodriguez * @ani_cache_ini_regs: cache the values for ANI from the initial 727e36b27afSLuis R. Rodriguez * register settings through the register initialization. 728d70357d5SLuis R. Rodriguez */ 729d70357d5SLuis R. Rodriguez struct ath_hw_private_ops { 730795f5e2cSLuis R. Rodriguez /* Calibration ops */ 731d70357d5SLuis R. Rodriguez void (*init_cal_settings)(struct ath_hw *ah); 732795f5e2cSLuis R. Rodriguez bool (*init_cal)(struct ath_hw *ah, struct ath9k_channel *chan); 733795f5e2cSLuis R. Rodriguez 734d70357d5SLuis R. Rodriguez void (*init_mode_regs)(struct ath_hw *ah); 735991312d8SLuis R. Rodriguez void (*init_mode_gain_regs)(struct ath_hw *ah); 736795f5e2cSLuis R. Rodriguez void (*setup_calibration)(struct ath_hw *ah, 737795f5e2cSLuis R. Rodriguez struct ath9k_cal_list *currCal); 7388fe65368SLuis R. Rodriguez 7398fe65368SLuis R. Rodriguez /* PHY ops */ 7408fe65368SLuis R. Rodriguez int (*rf_set_freq)(struct ath_hw *ah, 7418fe65368SLuis R. Rodriguez struct ath9k_channel *chan); 7428fe65368SLuis R. Rodriguez void (*spur_mitigate_freq)(struct ath_hw *ah, 7438fe65368SLuis R. Rodriguez struct ath9k_channel *chan); 7448fe65368SLuis R. Rodriguez int (*rf_alloc_ext_banks)(struct ath_hw *ah); 7458fe65368SLuis R. Rodriguez void (*rf_free_ext_banks)(struct ath_hw *ah); 7468fe65368SLuis R. Rodriguez bool (*set_rf_regs)(struct ath_hw *ah, 7478fe65368SLuis R. Rodriguez struct ath9k_channel *chan, 7488fe65368SLuis R. Rodriguez u16 modesIndex); 7498fe65368SLuis R. Rodriguez void (*set_channel_regs)(struct ath_hw *ah, struct ath9k_channel *chan); 7508fe65368SLuis R. Rodriguez void (*init_bb)(struct ath_hw *ah, 7518fe65368SLuis R. Rodriguez struct ath9k_channel *chan); 7528fe65368SLuis R. Rodriguez int (*process_ini)(struct ath_hw *ah, struct ath9k_channel *chan); 7538fe65368SLuis R. Rodriguez void (*olc_init)(struct ath_hw *ah); 7548fe65368SLuis R. Rodriguez void (*set_rfmode)(struct ath_hw *ah, struct ath9k_channel *chan); 7558fe65368SLuis R. Rodriguez void (*mark_phy_inactive)(struct ath_hw *ah); 7568fe65368SLuis R. Rodriguez void (*set_delta_slope)(struct ath_hw *ah, struct ath9k_channel *chan); 7578fe65368SLuis R. Rodriguez bool (*rfbus_req)(struct ath_hw *ah); 7588fe65368SLuis R. Rodriguez void (*rfbus_done)(struct ath_hw *ah); 7598fe65368SLuis R. Rodriguez void (*restore_chainmask)(struct ath_hw *ah); 76064773964SLuis R. Rodriguez u32 (*compute_pll_control)(struct ath_hw *ah, 76164773964SLuis R. Rodriguez struct ath9k_channel *chan); 762c16fcb49SFelix Fietkau bool (*ani_control)(struct ath_hw *ah, enum ath9k_ani_cmd cmd, 763c16fcb49SFelix Fietkau int param); 764641d9921SFelix Fietkau void (*do_getnf)(struct ath_hw *ah, int16_t nfarray[NUM_NF_READINGS]); 7654e8c14e9SFelix Fietkau void (*set_radar_params)(struct ath_hw *ah, 7664e8c14e9SFelix Fietkau struct ath_hw_radar_conf *conf); 7675f0c04eaSRajkumar Manoharan int (*fast_chan_change)(struct ath_hw *ah, struct ath9k_channel *chan, 7685f0c04eaSRajkumar Manoharan u8 *ini_reloaded); 769ac0bb767SLuis R. Rodriguez 770ac0bb767SLuis R. Rodriguez /* ANI */ 771e36b27afSLuis R. Rodriguez void (*ani_cache_ini_regs)(struct ath_hw *ah); 772d70357d5SLuis R. Rodriguez }; 773d70357d5SLuis R. Rodriguez 774d70357d5SLuis R. Rodriguez /** 775d70357d5SLuis R. Rodriguez * struct ath_hw_ops - callbacks used by hardware code and driver code 776d70357d5SLuis R. Rodriguez * 777d70357d5SLuis R. Rodriguez * This structure contains callbacks designed to to be used internally by 778d70357d5SLuis R. Rodriguez * hardware code and also by the lower level driver. 779d70357d5SLuis R. Rodriguez * 780d70357d5SLuis R. Rodriguez * @config_pci_powersave: 781795f5e2cSLuis R. Rodriguez * @calibrate: periodic calibration for NF, ANI, IQ, ADC gain, ADC-DC 782d70357d5SLuis R. Rodriguez */ 783d70357d5SLuis R. Rodriguez struct ath_hw_ops { 784d70357d5SLuis R. Rodriguez void (*config_pci_powersave)(struct ath_hw *ah, 78584c87dc8SStanislaw Gruszka bool power_off); 786cee1f625SVasanthakumar Thiagarajan void (*rx_enable)(struct ath_hw *ah); 78787d5efbbSVasanthakumar Thiagarajan void (*set_desc_link)(void *ds, u32 link); 788795f5e2cSLuis R. Rodriguez bool (*calibrate)(struct ath_hw *ah, 789795f5e2cSLuis R. Rodriguez struct ath9k_channel *chan, 790795f5e2cSLuis R. Rodriguez u8 rxchainmask, 791795f5e2cSLuis R. Rodriguez bool longcal); 79255e82df4SVasanthakumar Thiagarajan bool (*get_isr)(struct ath_hw *ah, enum ath9k_int *masked); 7932b63a41dSFelix Fietkau void (*set_txdesc)(struct ath_hw *ah, void *ds, 7942b63a41dSFelix Fietkau struct ath_tx_info *i); 795cc610ac0SVasanthakumar Thiagarajan int (*proc_txdesc)(struct ath_hw *ah, void *ds, 796cc610ac0SVasanthakumar Thiagarajan struct ath_tx_status *ts); 79769de3721SMohammed Shafi Shajakhan void (*antdiv_comb_conf_get)(struct ath_hw *ah, 79869de3721SMohammed Shafi Shajakhan struct ath_hw_antcomb_conf *antconf); 79969de3721SMohammed Shafi Shajakhan void (*antdiv_comb_conf_set)(struct ath_hw *ah, 80069de3721SMohammed Shafi Shajakhan struct ath_hw_antcomb_conf *antconf); 80169de3721SMohammed Shafi Shajakhan 802d70357d5SLuis R. Rodriguez }; 803d70357d5SLuis R. Rodriguez 804f2552e28SFelix Fietkau struct ath_nf_limits { 805f2552e28SFelix Fietkau s16 max; 806f2552e28SFelix Fietkau s16 min; 807f2552e28SFelix Fietkau s16 nominal; 808f2552e28SFelix Fietkau }; 809f2552e28SFelix Fietkau 8108ad74c4dSRajkumar Manoharan enum ath_cal_list { 8118ad74c4dSRajkumar Manoharan TX_IQ_CAL = BIT(0), 8128ad74c4dSRajkumar Manoharan TX_IQ_ON_AGC_CAL = BIT(1), 8138ad74c4dSRajkumar Manoharan TX_CL_CAL = BIT(2), 8148ad74c4dSRajkumar Manoharan }; 8158ad74c4dSRajkumar Manoharan 81697dcec57SSujith Manoharan /* ah_flags */ 81797dcec57SSujith Manoharan #define AH_USE_EEPROM 0x1 81897dcec57SSujith Manoharan #define AH_UNPLUGGED 0x2 /* The card has been physically removed. */ 819a126ff51SRajkumar Manoharan #define AH_FASTCC 0x4 82097dcec57SSujith Manoharan 821203c4805SLuis R. Rodriguez struct ath_hw { 822f9f84e96SFelix Fietkau struct ath_ops reg_ops; 823f9f84e96SFelix Fietkau 824b002a4a9SLuis R. Rodriguez struct ieee80211_hw *hw; 82527c51f1aSLuis R. Rodriguez struct ath_common common; 826203c4805SLuis R. Rodriguez struct ath9k_hw_version hw_version; 827203c4805SLuis R. Rodriguez struct ath9k_ops_config config; 828203c4805SLuis R. Rodriguez struct ath9k_hw_capabilities caps; 829cac4220bSFelix Fietkau struct ath9k_channel channels[ATH9K_NUM_CHANNELS]; 830203c4805SLuis R. Rodriguez struct ath9k_channel *curchan; 831203c4805SLuis R. Rodriguez 832203c4805SLuis R. Rodriguez union { 833203c4805SLuis R. Rodriguez struct ar5416_eeprom_def def; 834203c4805SLuis R. Rodriguez struct ar5416_eeprom_4k map4k; 835475f5989SLuis R. Rodriguez struct ar9287_eeprom map9287; 83615c9ee7aSSenthil Balasubramanian struct ar9300_eeprom ar9300_eep; 837203c4805SLuis R. Rodriguez } eeprom; 838203c4805SLuis R. Rodriguez const struct eeprom_ops *eep_ops; 839203c4805SLuis R. Rodriguez 840203c4805SLuis R. Rodriguez bool sw_mgmt_crypto; 841203c4805SLuis R. Rodriguez bool is_pciexpress; 842d4930086SStanislaw Gruszka bool aspm_enabled; 8435f841b41SRajkumar Manoharan bool is_monitoring; 8442eb46d9bSPavel Roskin bool need_an_top2_fixup; 845203c4805SLuis R. Rodriguez u16 tx_trig_level; 846f2552e28SFelix Fietkau 847bbacee13SFelix Fietkau u32 nf_regs[6]; 848f2552e28SFelix Fietkau struct ath_nf_limits nf_2g; 849f2552e28SFelix Fietkau struct ath_nf_limits nf_5g; 850203c4805SLuis R. Rodriguez u16 rfsilent; 851203c4805SLuis R. Rodriguez u32 rfkill_gpio; 852203c4805SLuis R. Rodriguez u32 rfkill_polarity; 853203c4805SLuis R. Rodriguez u32 ah_flags; 854203c4805SLuis R. Rodriguez 855d7e7d229SLuis R. Rodriguez bool htc_reset_init; 856d7e7d229SLuis R. Rodriguez 857203c4805SLuis R. Rodriguez enum nl80211_iftype opmode; 858203c4805SLuis R. Rodriguez enum ath9k_power_mode power_mode; 859203c4805SLuis R. Rodriguez 860f23fba49SFelix Fietkau s8 noise; 86120bd2a09SFelix Fietkau struct ath9k_hw_cal_data *caldata; 862a13883b0SSujith struct ath9k_pacal_info pacal_info; 863203c4805SLuis R. Rodriguez struct ar5416Stats stats; 864203c4805SLuis R. Rodriguez struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES]; 865203c4805SLuis R. Rodriguez 866203c4805SLuis R. Rodriguez int16_t curchan_rad_index; 8673069168cSPavel Roskin enum ath9k_int imask; 86874bad5cbSPavel Roskin u32 imrs2_reg; 869203c4805SLuis R. Rodriguez u32 txok_interrupt_mask; 870203c4805SLuis R. Rodriguez u32 txerr_interrupt_mask; 871203c4805SLuis R. Rodriguez u32 txdesc_interrupt_mask; 872203c4805SLuis R. Rodriguez u32 txeol_interrupt_mask; 873203c4805SLuis R. Rodriguez u32 txurn_interrupt_mask; 874e8fe7336SRajkumar Manoharan atomic_t intr_ref_cnt; 875203c4805SLuis R. Rodriguez bool chip_fullsleep; 876203c4805SLuis R. Rodriguez u32 atim_window; 8775f0c04eaSRajkumar Manoharan u32 modes_index; 878203c4805SLuis R. Rodriguez 879203c4805SLuis R. Rodriguez /* Calibration */ 8806497827fSFelix Fietkau u32 supp_cals; 881cbfe9468SSujith struct ath9k_cal_list iq_caldata; 882cbfe9468SSujith struct ath9k_cal_list adcgain_caldata; 883cbfe9468SSujith struct ath9k_cal_list adcdc_caldata; 884df23acaaSLuis R. Rodriguez struct ath9k_cal_list tempCompCalData; 885cbfe9468SSujith struct ath9k_cal_list *cal_list; 886cbfe9468SSujith struct ath9k_cal_list *cal_list_last; 887cbfe9468SSujith struct ath9k_cal_list *cal_list_curr; 888203c4805SLuis R. Rodriguez #define totalPowerMeasI meas0.unsign 889203c4805SLuis R. Rodriguez #define totalPowerMeasQ meas1.unsign 890203c4805SLuis R. Rodriguez #define totalIqCorrMeas meas2.sign 891203c4805SLuis R. Rodriguez #define totalAdcIOddPhase meas0.unsign 892203c4805SLuis R. Rodriguez #define totalAdcIEvenPhase meas1.unsign 893203c4805SLuis R. Rodriguez #define totalAdcQOddPhase meas2.unsign 894203c4805SLuis R. Rodriguez #define totalAdcQEvenPhase meas3.unsign 895203c4805SLuis R. Rodriguez #define totalAdcDcOffsetIOddPhase meas0.sign 896203c4805SLuis R. Rodriguez #define totalAdcDcOffsetIEvenPhase meas1.sign 897203c4805SLuis R. Rodriguez #define totalAdcDcOffsetQOddPhase meas2.sign 898203c4805SLuis R. Rodriguez #define totalAdcDcOffsetQEvenPhase meas3.sign 899203c4805SLuis R. Rodriguez union { 900203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 901203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 902203c4805SLuis R. Rodriguez } meas0; 903203c4805SLuis R. Rodriguez union { 904203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 905203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 906203c4805SLuis R. Rodriguez } meas1; 907203c4805SLuis R. Rodriguez union { 908203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 909203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 910203c4805SLuis R. Rodriguez } meas2; 911203c4805SLuis R. Rodriguez union { 912203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 913203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 914203c4805SLuis R. Rodriguez } meas3; 915203c4805SLuis R. Rodriguez u16 cal_samples; 9168ad74c4dSRajkumar Manoharan u8 enabled_cals; 917203c4805SLuis R. Rodriguez 918203c4805SLuis R. Rodriguez u32 sta_id1_defaults; 919203c4805SLuis R. Rodriguez u32 misc_mode; 920203c4805SLuis R. Rodriguez enum { 921203c4805SLuis R. Rodriguez AUTO_32KHZ, 922203c4805SLuis R. Rodriguez USE_32KHZ, 923203c4805SLuis R. Rodriguez DONT_USE_32KHZ, 924203c4805SLuis R. Rodriguez } enable_32kHz_clock; 925203c4805SLuis R. Rodriguez 926d70357d5SLuis R. Rodriguez /* Private to hardware code */ 927d70357d5SLuis R. Rodriguez struct ath_hw_private_ops private_ops; 928d70357d5SLuis R. Rodriguez /* Accessed by the lower level driver */ 929d70357d5SLuis R. Rodriguez struct ath_hw_ops ops; 930d70357d5SLuis R. Rodriguez 931e68a060bSLuis R. Rodriguez /* Used to program the radio on non single-chip devices */ 932203c4805SLuis R. Rodriguez u32 *analogBank0Data; 933203c4805SLuis R. Rodriguez u32 *analogBank1Data; 934203c4805SLuis R. Rodriguez u32 *analogBank2Data; 935203c4805SLuis R. Rodriguez u32 *analogBank3Data; 936203c4805SLuis R. Rodriguez u32 *analogBank6Data; 937203c4805SLuis R. Rodriguez u32 *analogBank6TPCData; 938203c4805SLuis R. Rodriguez u32 *analogBank7Data; 939203c4805SLuis R. Rodriguez u32 *addac5416_21; 940203c4805SLuis R. Rodriguez u32 *bank6Temp; 941203c4805SLuis R. Rodriguez 942597a94b3SFelix Fietkau u8 txpower_limit; 943e239d859SFelix Fietkau int coverage_class; 944203c4805SLuis R. Rodriguez u32 slottime; 945203c4805SLuis R. Rodriguez u32 globaltxtimeout; 946203c4805SLuis R. Rodriguez 947203c4805SLuis R. Rodriguez /* ANI */ 948203c4805SLuis R. Rodriguez u32 proc_phyerr; 949203c4805SLuis R. Rodriguez u32 aniperiod; 950203c4805SLuis R. Rodriguez int totalSizeDesired[5]; 951203c4805SLuis R. Rodriguez int coarse_high[5]; 952203c4805SLuis R. Rodriguez int coarse_low[5]; 953203c4805SLuis R. Rodriguez int firpwr[5]; 954203c4805SLuis R. Rodriguez enum ath9k_ani_cmd ani_function; 955203c4805SLuis R. Rodriguez 956af03abecSLuis R. Rodriguez /* Bluetooth coexistance */ 957766ec4a9SLuis R. Rodriguez struct ath_btcoex_hw btcoex_hw; 958af03abecSLuis R. Rodriguez 959203c4805SLuis R. Rodriguez u32 intr_txqs; 960203c4805SLuis R. Rodriguez u8 txchainmask; 961203c4805SLuis R. Rodriguez u8 rxchainmask; 962203c4805SLuis R. Rodriguez 963c5d0855aSFelix Fietkau struct ath_hw_radar_conf radar_conf; 964c5d0855aSFelix Fietkau 965203c4805SLuis R. Rodriguez u32 originalGain[22]; 966203c4805SLuis R. Rodriguez int initPDADC; 967203c4805SLuis R. Rodriguez int PDADCdelta; 9686de66dd9SFelix Fietkau int led_pin; 969691680b8SFelix Fietkau u32 gpio_mask; 970691680b8SFelix Fietkau u32 gpio_val; 971203c4805SLuis R. Rodriguez 972203c4805SLuis R. Rodriguez struct ar5416IniArray iniModes; 973203c4805SLuis R. Rodriguez struct ar5416IniArray iniCommon; 974203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank0; 975203c4805SLuis R. Rodriguez struct ar5416IniArray iniBB_RfGain; 976203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank1; 977203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank2; 978203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank3; 979203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank6; 980203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank6TPC; 981203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank7; 982203c4805SLuis R. Rodriguez struct ar5416IniArray iniAddac; 983203c4805SLuis R. Rodriguez struct ar5416IniArray iniPcieSerdes; 98413ce3e99SLuis R. Rodriguez struct ar5416IniArray iniPcieSerdesLowPower; 985203c4805SLuis R. Rodriguez struct ar5416IniArray iniModesAdditional; 986d89baac8SVasanthakumar Thiagarajan struct ar5416IniArray iniModesAdditional_40M; 987203c4805SLuis R. Rodriguez struct ar5416IniArray iniModesRxGain; 988203c4805SLuis R. Rodriguez struct ar5416IniArray iniModesTxGain; 9898564328dSLuis R. Rodriguez struct ar5416IniArray iniModes_9271_1_0_only; 990193cd458SSujith struct ar5416IniArray iniCckfirNormal; 991193cd458SSujith struct ar5416IniArray iniCckfirJapan2484; 992ce407afcSSenthil Balasubramanian struct ar5416IniArray ini_japan2484; 99370807e99SSujith struct ar5416IniArray iniCommon_normal_cck_fir_coeff_9271; 99470807e99SSujith struct ar5416IniArray iniCommon_japan_2484_cck_fir_coeff_9271; 99570807e99SSujith struct ar5416IniArray iniModes_9271_ANI_reg; 99670807e99SSujith struct ar5416IniArray iniModes_high_power_tx_gain_9271; 99770807e99SSujith struct ar5416IniArray iniModes_normal_power_tx_gain_9271; 998ce407afcSSenthil Balasubramanian struct ar5416IniArray ini_radio_post_sys2ant; 999ce407afcSSenthil Balasubramanian struct ar5416IniArray ini_BTCOEX_MAX_TXPWR; 1000ff155a45SVasanthakumar Thiagarajan 100113ce3e99SLuis R. Rodriguez struct ar5416IniArray iniMac[ATH_INI_NUM_SPLIT]; 100213ce3e99SLuis R. Rodriguez struct ar5416IniArray iniBB[ATH_INI_NUM_SPLIT]; 100313ce3e99SLuis R. Rodriguez struct ar5416IniArray iniRadio[ATH_INI_NUM_SPLIT]; 100413ce3e99SLuis R. Rodriguez struct ar5416IniArray iniSOC[ATH_INI_NUM_SPLIT]; 100513ce3e99SLuis R. Rodriguez 1006ff155a45SVasanthakumar Thiagarajan u32 intr_gen_timer_trigger; 1007ff155a45SVasanthakumar Thiagarajan u32 intr_gen_timer_thresh; 1008ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer_table hw_gen_timers; 1009744d4025SVasanthakumar Thiagarajan 1010744d4025SVasanthakumar Thiagarajan struct ar9003_txs *ts_ring; 1011744d4025SVasanthakumar Thiagarajan void *ts_start; 1012744d4025SVasanthakumar Thiagarajan u32 ts_paddr_start; 1013744d4025SVasanthakumar Thiagarajan u32 ts_paddr_end; 1014744d4025SVasanthakumar Thiagarajan u16 ts_tail; 1015744d4025SVasanthakumar Thiagarajan u8 ts_size; 1016aea702b7SLuis R. Rodriguez 1017aea702b7SLuis R. Rodriguez u32 bb_watchdog_last_status; 1018aea702b7SLuis R. Rodriguez u32 bb_watchdog_timeout_ms; /* in ms, 0 to disable */ 101951ac8cbbSRajkumar Manoharan u8 bb_hang_rx_ofdm; /* true if bb hang due to rx_ofdm */ 1020717f6bedSFelix Fietkau 10211bf38661SFelix Fietkau unsigned int paprd_target_power; 10221bf38661SFelix Fietkau unsigned int paprd_training_power; 10237072bf62SVasanthakumar Thiagarajan unsigned int paprd_ratemask; 1024f1a8abb0SFelix Fietkau unsigned int paprd_ratemask_ht40; 102545ef6a0bSVasanthakumar Thiagarajan bool paprd_table_write_done; 1026717f6bedSFelix Fietkau u32 paprd_gain_table_entries[PAPRD_GAIN_TABLE_ENTRIES]; 1027717f6bedSFelix Fietkau u8 paprd_gain_table_index[PAPRD_GAIN_TABLE_ENTRIES]; 10289a658d2bSLuis R. Rodriguez /* 10299a658d2bSLuis R. Rodriguez * Store the permanent value of Reg 0x4004in WARegVal 10309a658d2bSLuis R. Rodriguez * so we dont have to R/M/W. We should not be reading 10319a658d2bSLuis R. Rodriguez * this register when in sleep states. 10329a658d2bSLuis R. Rodriguez */ 10339a658d2bSLuis R. Rodriguez u32 WARegVal; 10346ee63f55SSenthil Balasubramanian 10356ee63f55SSenthil Balasubramanian /* Enterprise mode cap */ 10366ee63f55SSenthil Balasubramanian u32 ent_mode; 1037f2f5f2a1SVasanthakumar Thiagarajan 1038f2f5f2a1SVasanthakumar Thiagarajan bool is_clk_25mhz; 10393762561aSGabor Juhos int (*get_mac_revision)(void); 10407d95847cSGabor Juhos int (*external_reset)(void); 1041203c4805SLuis R. Rodriguez }; 1042203c4805SLuis R. Rodriguez 10430cb9e06bSFelix Fietkau struct ath_bus_ops { 10440cb9e06bSFelix Fietkau enum ath_bus_type ath_bus_type; 10450cb9e06bSFelix Fietkau void (*read_cachesize)(struct ath_common *common, int *csz); 10460cb9e06bSFelix Fietkau bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data); 10470cb9e06bSFelix Fietkau void (*bt_coex_prep)(struct ath_common *common); 10480cb9e06bSFelix Fietkau void (*extn_synch_en)(struct ath_common *common); 1049d4930086SStanislaw Gruszka void (*aspm_init)(struct ath_common *common); 10500cb9e06bSFelix Fietkau }; 10510cb9e06bSFelix Fietkau 10529e4bffd2SLuis R. Rodriguez static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah) 10539e4bffd2SLuis R. Rodriguez { 10549e4bffd2SLuis R. Rodriguez return &ah->common; 10559e4bffd2SLuis R. Rodriguez } 10569e4bffd2SLuis R. Rodriguez 10579e4bffd2SLuis R. Rodriguez static inline struct ath_regulatory *ath9k_hw_regulatory(struct ath_hw *ah) 10589e4bffd2SLuis R. Rodriguez { 10599e4bffd2SLuis R. Rodriguez return &(ath9k_hw_common(ah)->regulatory); 10609e4bffd2SLuis R. Rodriguez } 10619e4bffd2SLuis R. Rodriguez 1062d70357d5SLuis R. Rodriguez static inline struct ath_hw_private_ops *ath9k_hw_private_ops(struct ath_hw *ah) 1063d70357d5SLuis R. Rodriguez { 1064d70357d5SLuis R. Rodriguez return &ah->private_ops; 1065d70357d5SLuis R. Rodriguez } 1066d70357d5SLuis R. Rodriguez 1067d70357d5SLuis R. Rodriguez static inline struct ath_hw_ops *ath9k_hw_ops(struct ath_hw *ah) 1068d70357d5SLuis R. Rodriguez { 1069d70357d5SLuis R. Rodriguez return &ah->ops; 1070d70357d5SLuis R. Rodriguez } 1071d70357d5SLuis R. Rodriguez 1072895ad7ebSVasanthakumar Thiagarajan static inline u8 get_streams(int mask) 1073895ad7ebSVasanthakumar Thiagarajan { 1074895ad7ebSVasanthakumar Thiagarajan return !!(mask & BIT(0)) + !!(mask & BIT(1)) + !!(mask & BIT(2)); 1075895ad7ebSVasanthakumar Thiagarajan } 1076895ad7ebSVasanthakumar Thiagarajan 1077f637cfd6SLuis R. Rodriguez /* Initialization, Detach, Reset */ 1078203c4805SLuis R. Rodriguez const char *ath9k_hw_probe(u16 vendorid, u16 devid); 1079285f2ddaSSujith void ath9k_hw_deinit(struct ath_hw *ah); 1080f637cfd6SLuis R. Rodriguez int ath9k_hw_init(struct ath_hw *ah); 1081203c4805SLuis R. Rodriguez int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, 108220bd2a09SFelix Fietkau struct ath9k_hw_cal_data *caldata, bool bChannelChange); 1083a9a29ce6SGabor Juhos int ath9k_hw_fill_cap_info(struct ath_hw *ah); 10848fe65368SLuis R. Rodriguez u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan); 1085203c4805SLuis R. Rodriguez 1086203c4805SLuis R. Rodriguez /* GPIO / RFKILL / Antennae */ 1087203c4805SLuis R. Rodriguez void ath9k_hw_cfg_gpio_input(struct ath_hw *ah, u32 gpio); 1088203c4805SLuis R. Rodriguez u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio); 1089203c4805SLuis R. Rodriguez void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio, 1090203c4805SLuis R. Rodriguez u32 ah_signal_type); 1091203c4805SLuis R. Rodriguez void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val); 1092203c4805SLuis R. Rodriguez u32 ath9k_hw_getdefantenna(struct ath_hw *ah); 1093203c4805SLuis R. Rodriguez void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna); 1094203c4805SLuis R. Rodriguez 1095203c4805SLuis R. Rodriguez /* General Operation */ 1096203c4805SLuis R. Rodriguez bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout); 1097a9b6b256SFelix Fietkau void ath9k_hw_write_array(struct ath_hw *ah, struct ar5416IniArray *array, 1098a9b6b256SFelix Fietkau int column, unsigned int *writecnt); 1099203c4805SLuis R. Rodriguez u32 ath9k_hw_reverse_bits(u32 val, u32 n); 11004f0fc7c3SLuis R. Rodriguez u16 ath9k_hw_computetxtime(struct ath_hw *ah, 1101545750d3SFelix Fietkau u8 phy, int kbps, 1102203c4805SLuis R. Rodriguez u32 frameLen, u16 rateix, bool shortPreamble); 1103203c4805SLuis R. Rodriguez void ath9k_hw_get_channel_centers(struct ath_hw *ah, 1104203c4805SLuis R. Rodriguez struct ath9k_channel *chan, 1105203c4805SLuis R. Rodriguez struct chan_centers *centers); 1106203c4805SLuis R. Rodriguez u32 ath9k_hw_getrxfilter(struct ath_hw *ah); 1107203c4805SLuis R. Rodriguez void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits); 1108203c4805SLuis R. Rodriguez bool ath9k_hw_phy_disable(struct ath_hw *ah); 1109203c4805SLuis R. Rodriguez bool ath9k_hw_disable(struct ath_hw *ah); 1110de40f316SFelix Fietkau void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test); 1111203c4805SLuis R. Rodriguez void ath9k_hw_setopmode(struct ath_hw *ah); 1112203c4805SLuis R. Rodriguez void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1); 1113f2b2143eSLuis R. Rodriguez void ath9k_hw_setbssidmask(struct ath_hw *ah); 1114f2b2143eSLuis R. Rodriguez void ath9k_hw_write_associd(struct ath_hw *ah); 1115dd347f2fSFelix Fietkau u32 ath9k_hw_gettsf32(struct ath_hw *ah); 1116203c4805SLuis R. Rodriguez u64 ath9k_hw_gettsf64(struct ath_hw *ah); 1117203c4805SLuis R. Rodriguez void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64); 1118203c4805SLuis R. Rodriguez void ath9k_hw_reset_tsf(struct ath_hw *ah); 111954e4cec6SSujith void ath9k_hw_set_tsfadjust(struct ath_hw *ah, u32 setting); 11200005baf4SFelix Fietkau void ath9k_hw_init_global_settings(struct ath_hw *ah); 1121b84628ebSSenthil Balasubramanian u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah); 112225c56eecSLuis R. Rodriguez void ath9k_hw_set11nmac2040(struct ath_hw *ah); 1123203c4805SLuis R. Rodriguez void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period); 1124203c4805SLuis R. Rodriguez void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, 1125203c4805SLuis R. Rodriguez const struct ath9k_beacon_state *bs); 1126c9c99e5eSFelix Fietkau bool ath9k_hw_check_alive(struct ath_hw *ah); 1127a91d75aeSLuis R. Rodriguez 11289ecdef4bSLuis R. Rodriguez bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode); 1129a91d75aeSLuis R. Rodriguez 1130ff155a45SVasanthakumar Thiagarajan /* Generic hw timer primitives */ 1131ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah, 1132ff155a45SVasanthakumar Thiagarajan void (*trigger)(void *), 1133ff155a45SVasanthakumar Thiagarajan void (*overflow)(void *), 1134ff155a45SVasanthakumar Thiagarajan void *arg, 1135ff155a45SVasanthakumar Thiagarajan u8 timer_index); 1136cd9bf689SLuis R. Rodriguez void ath9k_hw_gen_timer_start(struct ath_hw *ah, 1137cd9bf689SLuis R. Rodriguez struct ath_gen_timer *timer, 1138cd9bf689SLuis R. Rodriguez u32 timer_next, 1139cd9bf689SLuis R. Rodriguez u32 timer_period); 1140cd9bf689SLuis R. Rodriguez void ath9k_hw_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer); 1141cd9bf689SLuis R. Rodriguez 1142ff155a45SVasanthakumar Thiagarajan void ath_gen_timer_free(struct ath_hw *ah, struct ath_gen_timer *timer); 1143ff155a45SVasanthakumar Thiagarajan void ath_gen_timer_isr(struct ath_hw *hw); 1144ff155a45SVasanthakumar Thiagarajan 1145f934c4d9SLuis R. Rodriguez void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len); 11462da4f01aSLuis R. Rodriguez 114705020d23SSujith /* HTC */ 114805020d23SSujith void ath9k_hw_htc_resetinit(struct ath_hw *ah); 114905020d23SSujith 11508fe65368SLuis R. Rodriguez /* PHY */ 11518fe65368SLuis R. Rodriguez void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled, 11528fe65368SLuis R. Rodriguez u32 *coef_mantissa, u32 *coef_exponent); 1153ca2c68ccSFelix Fietkau void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan); 11548fe65368SLuis R. Rodriguez 1155ebd5a14aSLuis R. Rodriguez /* 1156ebd5a14aSLuis R. Rodriguez * Code Specific to AR5008, AR9001 or AR9002, 1157ebd5a14aSLuis R. Rodriguez * we stuff these here to avoid callbacks for AR9003. 1158ebd5a14aSLuis R. Rodriguez */ 1159d8f492b7SLuis R. Rodriguez void ar9002_hw_cck_chan14_spread(struct ath_hw *ah); 1160ebd5a14aSLuis R. Rodriguez int ar9002_hw_rf_claim(struct ath_hw *ah); 116178ec2677SLuis R. Rodriguez void ar9002_hw_enable_async_fifo(struct ath_hw *ah); 1162d8f492b7SLuis R. Rodriguez 1163641d9921SFelix Fietkau /* 1164aea702b7SLuis R. Rodriguez * Code specific to AR9003, we stuff these here to avoid callbacks 1165641d9921SFelix Fietkau * for older families 1166641d9921SFelix Fietkau */ 1167aea702b7SLuis R. Rodriguez void ar9003_hw_bb_watchdog_config(struct ath_hw *ah); 1168aea702b7SLuis R. Rodriguez void ar9003_hw_bb_watchdog_read(struct ath_hw *ah); 1169aea702b7SLuis R. Rodriguez void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah); 117051ac8cbbSRajkumar Manoharan void ar9003_hw_disable_phy_restart(struct ath_hw *ah); 1171717f6bedSFelix Fietkau void ar9003_paprd_enable(struct ath_hw *ah, bool val); 1172717f6bedSFelix Fietkau void ar9003_paprd_populate_single_table(struct ath_hw *ah, 117320bd2a09SFelix Fietkau struct ath9k_hw_cal_data *caldata, 1174717f6bedSFelix Fietkau int chain); 117520bd2a09SFelix Fietkau int ar9003_paprd_create_curve(struct ath_hw *ah, 117620bd2a09SFelix Fietkau struct ath9k_hw_cal_data *caldata, int chain); 1177717f6bedSFelix Fietkau int ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain); 1178717f6bedSFelix Fietkau int ar9003_paprd_init_table(struct ath_hw *ah); 1179717f6bedSFelix Fietkau bool ar9003_paprd_is_done(struct ath_hw *ah); 1180717f6bedSFelix Fietkau void ar9003_hw_set_paprd_txdesc(struct ath_hw *ah, void *ds, u8 chains); 1181641d9921SFelix Fietkau 1182641d9921SFelix Fietkau /* Hardware family op attach helpers */ 11838fe65368SLuis R. Rodriguez void ar5008_hw_attach_phy_ops(struct ath_hw *ah); 11848525f280SLuis R. Rodriguez void ar9002_hw_attach_phy_ops(struct ath_hw *ah); 11858525f280SLuis R. Rodriguez void ar9003_hw_attach_phy_ops(struct ath_hw *ah); 11868fe65368SLuis R. Rodriguez 1187795f5e2cSLuis R. Rodriguez void ar9002_hw_attach_calib_ops(struct ath_hw *ah); 1188795f5e2cSLuis R. Rodriguez void ar9003_hw_attach_calib_ops(struct ath_hw *ah); 1189795f5e2cSLuis R. Rodriguez 1190b3950e6aSLuis R. Rodriguez void ar9002_hw_attach_ops(struct ath_hw *ah); 1191b3950e6aSLuis R. Rodriguez void ar9003_hw_attach_ops(struct ath_hw *ah); 1192b3950e6aSLuis R. Rodriguez 1193c2ba3342SRajkumar Manoharan void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan); 1194ac0bb767SLuis R. Rodriguez /* 1195ac0bb767SLuis R. Rodriguez * ANI work can be shared between all families but a next 1196ac0bb767SLuis R. Rodriguez * generation implementation of ANI will be used only for AR9003 only 1197ac0bb767SLuis R. Rodriguez * for now as the other families still need to be tested with the same 1198e36b27afSLuis R. Rodriguez * next generation ANI. Feel free to start testing it though for the 1199e36b27afSLuis R. Rodriguez * older families (AR5008, AR9001, AR9002) by using modparam_force_new_ani. 1200ac0bb767SLuis R. Rodriguez */ 1201e36b27afSLuis R. Rodriguez extern int modparam_force_new_ani; 12028eb4980cSFelix Fietkau void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning); 1203bfc472bbSFelix Fietkau void ath9k_hw_proc_mib_event(struct ath_hw *ah); 120495792178SFelix Fietkau void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan); 1205ac0bb767SLuis R. Rodriguez 120673377256SLuis R. Rodriguez #define ATH9K_CLOCK_RATE_CCK 22 120773377256SLuis R. Rodriguez #define ATH9K_CLOCK_RATE_5GHZ_OFDM 40 120873377256SLuis R. Rodriguez #define ATH9K_CLOCK_RATE_2GHZ_OFDM 44 120973377256SLuis R. Rodriguez #define ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM 44 121073377256SLuis R. Rodriguez 1211203c4805SLuis R. Rodriguez #endif 1212