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> 23ab5c4f71SGabor Juhos #include <linux/firmware.h> 24203c4805SLuis R. Rodriguez 25203c4805SLuis R. Rodriguez #include "mac.h" 26203c4805SLuis R. Rodriguez #include "ani.h" 27203c4805SLuis R. Rodriguez #include "eeprom.h" 28203c4805SLuis R. Rodriguez #include "calib.h" 29203c4805SLuis R. Rodriguez #include "reg.h" 30203c4805SLuis R. Rodriguez #include "phy.h" 31af03abecSLuis R. Rodriguez #include "btcoex.h" 32c774d57fSLorenzo Bianconi #include "dynack.h" 33203c4805SLuis R. Rodriguez 34203c4805SLuis R. Rodriguez #include "../regd.h" 35203c4805SLuis R. Rodriguez 36203c4805SLuis R. Rodriguez #define ATHEROS_VENDOR_ID 0x168c 377976b426SLuis R. Rodriguez 38203c4805SLuis R. Rodriguez #define AR5416_DEVID_PCI 0x0023 39203c4805SLuis R. Rodriguez #define AR5416_DEVID_PCIE 0x0024 40203c4805SLuis R. Rodriguez #define AR9160_DEVID_PCI 0x0027 41203c4805SLuis R. Rodriguez #define AR9280_DEVID_PCI 0x0029 42203c4805SLuis R. Rodriguez #define AR9280_DEVID_PCIE 0x002a 43203c4805SLuis R. Rodriguez #define AR9285_DEVID_PCIE 0x002b 445ffaf8a3SLuis R. Rodriguez #define AR2427_DEVID_PCIE 0x002c 45db3cc53aSSenthil Balasubramanian #define AR9287_DEVID_PCI 0x002d 46db3cc53aSSenthil Balasubramanian #define AR9287_DEVID_PCIE 0x002e 47db3cc53aSSenthil Balasubramanian #define AR9300_DEVID_PCIE 0x0030 48b99a7be4SVasanthakumar Thiagarajan #define AR9300_DEVID_AR9340 0x0031 493050c914SVasanthakumar Thiagarajan #define AR9300_DEVID_AR9485_PCIE 0x0032 505a63ef0fSLuis R. Rodriguez #define AR9300_DEVID_AR9580 0x0033 51423e38e8SRajkumar Manoharan #define AR9300_DEVID_AR9462 0x0034 5203689301SGabor Juhos #define AR9300_DEVID_AR9330 0x0035 53b1233779SGabor Juhos #define AR9300_DEVID_QCA955X 0x0038 54d4e5979cSMohammed Shafi Shajakhan #define AR9485_DEVID_AR1111 0x0037 5577fac465SSujith Manoharan #define AR9300_DEVID_AR9565 0x0036 56e6b1e46eSSujith Manoharan #define AR9300_DEVID_AR953X 0x003d 577976b426SLuis R. Rodriguez 58203c4805SLuis R. Rodriguez #define AR5416_AR9100_DEVID 0x000b 597976b426SLuis R. Rodriguez 60203c4805SLuis R. Rodriguez #define AR_SUBVENDOR_ID_NOG 0x0e11 61203c4805SLuis R. Rodriguez #define AR_SUBVENDOR_ID_NEW_A 0x7065 62203c4805SLuis R. Rodriguez #define AR5416_MAGIC 0x19641014 63203c4805SLuis R. Rodriguez 64fe12946eSVasanthakumar Thiagarajan #define AR9280_COEX2WIRE_SUBSYSID 0x309b 65fe12946eSVasanthakumar Thiagarajan #define AT9285_COEX3WIRE_SA_SUBSYSID 0x30aa 66fe12946eSVasanthakumar Thiagarajan #define AT9285_COEX3WIRE_DA_SUBSYSID 0x30ab 67fe12946eSVasanthakumar Thiagarajan 68e3d01bfcSLuis R. Rodriguez #define ATH_AMPDU_LIMIT_MAX (64 * 1024 - 1) 69e3d01bfcSLuis R. Rodriguez 70cfe8cba9SLuis R. Rodriguez #define ATH_DEFAULT_NOISE_FLOOR -95 71cfe8cba9SLuis R. Rodriguez 7204658fbaSJohn W. Linville #define ATH9K_RSSI_BAD -128 73990b70abSLuis R. Rodriguez 74cac4220bSFelix Fietkau #define ATH9K_NUM_CHANNELS 38 75cac4220bSFelix Fietkau 76203c4805SLuis R. Rodriguez /* Register read/write primitives */ 779e4bffd2SLuis R. Rodriguez #define REG_WRITE(_ah, _reg, _val) \ 78f9f84e96SFelix Fietkau (_ah)->reg_ops.write((_ah), (_val), (_reg)) 799e4bffd2SLuis R. Rodriguez 809e4bffd2SLuis R. Rodriguez #define REG_READ(_ah, _reg) \ 81f9f84e96SFelix Fietkau (_ah)->reg_ops.read((_ah), (_reg)) 82203c4805SLuis R. Rodriguez 8309a525d3SSujith Manoharan #define REG_READ_MULTI(_ah, _addr, _val, _cnt) \ 84f9f84e96SFelix Fietkau (_ah)->reg_ops.multi_read((_ah), (_addr), (_val), (_cnt)) 8509a525d3SSujith Manoharan 86845e03c9SFelix Fietkau #define REG_RMW(_ah, _reg, _set, _clr) \ 87845e03c9SFelix Fietkau (_ah)->reg_ops.rmw((_ah), (_reg), (_set), (_clr)) 88845e03c9SFelix Fietkau 8920b3efd9SSujith #define ENABLE_REGWRITE_BUFFER(_ah) \ 9020b3efd9SSujith do { \ 91f9f84e96SFelix Fietkau if ((_ah)->reg_ops.enable_write_buffer) \ 92f9f84e96SFelix Fietkau (_ah)->reg_ops.enable_write_buffer((_ah)); \ 9320b3efd9SSujith } while (0) 9420b3efd9SSujith 9520b3efd9SSujith #define REGWRITE_BUFFER_FLUSH(_ah) \ 9620b3efd9SSujith do { \ 97f9f84e96SFelix Fietkau if ((_ah)->reg_ops.write_flush) \ 98f9f84e96SFelix Fietkau (_ah)->reg_ops.write_flush((_ah)); \ 9920b3efd9SSujith } while (0) 10020b3efd9SSujith 10126526202SRajkumar Manoharan #define PR_EEP(_s, _val) \ 10226526202SRajkumar Manoharan do { \ 1035e88ba62SZefir Kurtisi len += scnprintf(buf + len, size - len, "%20s : %10d\n",\ 10426526202SRajkumar Manoharan _s, (_val)); \ 10526526202SRajkumar Manoharan } while (0) 10626526202SRajkumar Manoharan 107203c4805SLuis R. Rodriguez #define SM(_v, _f) (((_v) << _f##_S) & _f) 108203c4805SLuis R. Rodriguez #define MS(_v, _f) (((_v) & _f) >> _f##_S) 109203c4805SLuis R. Rodriguez #define REG_RMW_FIELD(_a, _r, _f, _v) \ 110845e03c9SFelix Fietkau REG_RMW(_a, _r, (((_v) << _f##_S) & _f), (_f)) 1111547da37SLuis R. Rodriguez #define REG_READ_FIELD(_a, _r, _f) \ 1121547da37SLuis R. Rodriguez (((REG_READ(_a, _r) & _f) >> _f##_S)) 113203c4805SLuis R. Rodriguez #define REG_SET_BIT(_a, _r, _f) \ 114845e03c9SFelix Fietkau REG_RMW(_a, _r, (_f), 0) 115203c4805SLuis R. Rodriguez #define REG_CLR_BIT(_a, _r, _f) \ 116845e03c9SFelix Fietkau REG_RMW(_a, _r, 0, (_f)) 117203c4805SLuis R. Rodriguez 118203c4805SLuis R. Rodriguez #define DO_DELAY(x) do { \ 119e7fc6338SRajkumar Manoharan if (((++(x) % 64) == 0) && \ 120e7fc6338SRajkumar Manoharan (ath9k_hw_common(ah)->bus_ops->ath_bus_type \ 121e7fc6338SRajkumar Manoharan != ATH_USB)) \ 122203c4805SLuis R. Rodriguez udelay(1); \ 123203c4805SLuis R. Rodriguez } while (0) 124203c4805SLuis R. Rodriguez 125a9b6b256SFelix Fietkau #define REG_WRITE_ARRAY(iniarray, column, regWr) \ 126a9b6b256SFelix Fietkau ath9k_hw_write_array(ah, iniarray, column, &(regWr)) 127203c4805SLuis R. Rodriguez 128203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_OUTPUT 0 129203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_PCIE_ATTENTION_LED 1 130203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_PCIE_POWER_LED 2 131203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_TX_FRAME 3 1321773912bSVasanthakumar Thiagarajan #define AR_GPIO_OUTPUT_MUX_AS_RX_CLEAR_EXTERNAL 4 133203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_MAC_NETWORK_LED 5 134203c4805SLuis R. Rodriguez #define AR_GPIO_OUTPUT_MUX_AS_MAC_POWER_LED 6 13593d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_DATA 0x16 13693d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_MCI_WLAN_CLK 0x17 13793d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_MCI_BT_DATA 0x18 13893d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_MCI_BT_CLK 0x19 13993d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_WL_IN_TX 0x14 14093d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_WL_IN_RX 0x13 14193d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_BT_IN_TX 9 14293d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_BT_IN_RX 8 14393d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_RUCKUS_STROBE 0x1d 14493d36e99SMohammed Shafi Shajakhan #define AR_GPIO_OUTPUT_MUX_AS_RUCKUS_DATA 0x1e 145203c4805SLuis R. Rodriguez 146203c4805SLuis R. Rodriguez #define AR_GPIOD_MASK 0x00001FFF 147203c4805SLuis R. Rodriguez #define AR_GPIO_BIT(_gpio) (1 << (_gpio)) 148203c4805SLuis R. Rodriguez 149203c4805SLuis R. Rodriguez #define BASE_ACTIVATE_DELAY 100 1500b488ac6SVasanthakumar Thiagarajan #define RTC_PLL_SETTLE_DELAY (AR_SREV_9340(ah) ? 1000 : 100) 151203c4805SLuis R. Rodriguez #define COEF_SCALE_S 24 152203c4805SLuis R. Rodriguez #define HT40_CHANNEL_CENTER_SHIFT 10 153203c4805SLuis R. Rodriguez 154203c4805SLuis R. Rodriguez #define ATH9K_ANTENNA0_CHAINMASK 0x1 155203c4805SLuis R. Rodriguez #define ATH9K_ANTENNA1_CHAINMASK 0x2 156203c4805SLuis R. Rodriguez 157203c4805SLuis R. Rodriguez #define ATH9K_NUM_DMA_DEBUG_REGS 8 158203c4805SLuis R. Rodriguez #define ATH9K_NUM_QUEUES 10 159203c4805SLuis R. Rodriguez 160203c4805SLuis R. Rodriguez #define MAX_RATE_POWER 63 161203c4805SLuis R. Rodriguez #define AH_WAIT_TIMEOUT 100000 /* (us) */ 162f9b604f6SGabor Juhos #define AH_TSF_WRITE_TIMEOUT 100 /* (us) */ 163203c4805SLuis R. Rodriguez #define AH_TIME_QUANTUM 10 164203c4805SLuis R. Rodriguez #define AR_KEYTABLE_SIZE 128 165d8caa839SSujith #define POWER_UP_TIME 10000 166203c4805SLuis R. Rodriguez #define SPUR_RSSI_THRESH 40 167331c5ea2SMohammed Shafi Shajakhan #define UPPER_5G_SUB_BAND_START 5700 168331c5ea2SMohammed Shafi Shajakhan #define MID_5G_SUB_BAND_START 5400 169203c4805SLuis R. Rodriguez 170203c4805SLuis R. Rodriguez #define CAB_TIMEOUT_VAL 10 171203c4805SLuis R. Rodriguez #define BEACON_TIMEOUT_VAL 10 172203c4805SLuis R. Rodriguez #define MIN_BEACON_TIMEOUT_VAL 1 1734ed15762SFelix Fietkau #define SLEEP_SLOP TU_TO_USEC(3) 174203c4805SLuis R. Rodriguez 175203c4805SLuis R. Rodriguez #define INIT_CONFIG_STATUS 0x00000000 176203c4805SLuis R. Rodriguez #define INIT_RSSI_THR 0x00000700 177203c4805SLuis R. Rodriguez #define INIT_BCON_CNTRL_REG 0x00000000 178203c4805SLuis R. Rodriguez 179203c4805SLuis R. Rodriguez #define TU_TO_USEC(_tu) ((_tu) << 10) 180203c4805SLuis R. Rodriguez 181ceb26445SVasanthakumar Thiagarajan #define ATH9K_HW_RX_HP_QDEPTH 16 182ceb26445SVasanthakumar Thiagarajan #define ATH9K_HW_RX_LP_QDEPTH 128 183ceb26445SVasanthakumar Thiagarajan 184717f6bedSFelix Fietkau #define PAPRD_GAIN_TABLE_ENTRIES 32 185717f6bedSFelix Fietkau #define PAPRD_TABLE_SZ 24 1860e44d48cSMohammed Shafi Shajakhan #define PAPRD_IDEAL_AGC2_PWR_RANGE 0xe0 187717f6bedSFelix Fietkau 18801c78533SMohammed Shafi Shajakhan /* 18901c78533SMohammed Shafi Shajakhan * Wake on Wireless 19001c78533SMohammed Shafi Shajakhan */ 19101c78533SMohammed Shafi Shajakhan 19201c78533SMohammed Shafi Shajakhan /* Keep Alive Frame */ 19301c78533SMohammed Shafi Shajakhan #define KAL_FRAME_LEN 28 19401c78533SMohammed Shafi Shajakhan #define KAL_FRAME_TYPE 0x2 /* data frame */ 19501c78533SMohammed Shafi Shajakhan #define KAL_FRAME_SUB_TYPE 0x4 /* null data frame */ 19601c78533SMohammed Shafi Shajakhan #define KAL_DURATION_ID 0x3d 19701c78533SMohammed Shafi Shajakhan #define KAL_NUM_DATA_WORDS 6 19801c78533SMohammed Shafi Shajakhan #define KAL_NUM_DESC_WORDS 12 19901c78533SMohammed Shafi Shajakhan #define KAL_ANTENNA_MODE 1 20001c78533SMohammed Shafi Shajakhan #define KAL_TO_DS 1 20101c78533SMohammed Shafi Shajakhan #define KAL_DELAY 4 /*delay of 4ms between 2 KAL frames */ 20201c78533SMohammed Shafi Shajakhan #define KAL_TIMEOUT 900 20301c78533SMohammed Shafi Shajakhan 20401c78533SMohammed Shafi Shajakhan #define MAX_PATTERN_SIZE 256 20501c78533SMohammed Shafi Shajakhan #define MAX_PATTERN_MASK_SIZE 32 20601c78533SMohammed Shafi Shajakhan #define MAX_NUM_PATTERN 8 20701c78533SMohammed Shafi Shajakhan #define MAX_NUM_USER_PATTERN 6 /* deducting the disassociate and 20801c78533SMohammed Shafi Shajakhan deauthenticate packets */ 20901c78533SMohammed Shafi Shajakhan 21001c78533SMohammed Shafi Shajakhan /* 21101c78533SMohammed Shafi Shajakhan * WoW trigger mapping to hardware code 21201c78533SMohammed Shafi Shajakhan */ 21301c78533SMohammed Shafi Shajakhan 21401c78533SMohammed Shafi Shajakhan #define AH_WOW_USER_PATTERN_EN BIT(0) 21501c78533SMohammed Shafi Shajakhan #define AH_WOW_MAGIC_PATTERN_EN BIT(1) 21601c78533SMohammed Shafi Shajakhan #define AH_WOW_LINK_CHANGE BIT(2) 21701c78533SMohammed Shafi Shajakhan #define AH_WOW_BEACON_MISS BIT(3) 21801c78533SMohammed Shafi Shajakhan 219066dae93SFelix Fietkau enum ath_hw_txq_subtype { 220066dae93SFelix Fietkau ATH_TXQ_AC_BE = 0, 221066dae93SFelix Fietkau ATH_TXQ_AC_BK = 1, 222066dae93SFelix Fietkau ATH_TXQ_AC_VI = 2, 223066dae93SFelix Fietkau ATH_TXQ_AC_VO = 3, 224066dae93SFelix Fietkau }; 225066dae93SFelix Fietkau 22613ce3e99SLuis R. Rodriguez enum ath_ini_subsys { 22713ce3e99SLuis R. Rodriguez ATH_INI_PRE = 0, 22813ce3e99SLuis R. Rodriguez ATH_INI_CORE, 22913ce3e99SLuis R. Rodriguez ATH_INI_POST, 23013ce3e99SLuis R. Rodriguez ATH_INI_NUM_SPLIT, 23113ce3e99SLuis R. Rodriguez }; 23213ce3e99SLuis R. Rodriguez 233203c4805SLuis R. Rodriguez enum ath9k_hw_caps { 234364734faSFelix Fietkau ATH9K_HW_CAP_HT = BIT(0), 235364734faSFelix Fietkau ATH9K_HW_CAP_RFSILENT = BIT(1), 2361b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_AUTOSLEEP = BIT(2), 2371b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_4KB_SPLITTRANS = BIT(3), 2381b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_EDMA = BIT(4), 2391b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_RAC_SUPPORTED = BIT(5), 2401b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_LDPC = BIT(6), 2411b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_FASTCLOCK = BIT(7), 2421b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_SGI_20 = BIT(8), 2431b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_ANT_DIV_COMB = BIT(10), 2441b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_2GHZ = BIT(11), 2451b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_5GHZ = BIT(12), 2461b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_APM = BIT(13), 247935477edSFelix Fietkau #ifdef CONFIG_ATH9K_PCOEM 2481b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_RTT = BIT(14), 2491b2538b2SMohammed Shafi Shajakhan ATH9K_HW_CAP_MCI = BIT(15), 250935477edSFelix Fietkau ATH9K_HW_WOW_DEVICE_CAPABLE = BIT(16), 251935477edSFelix Fietkau ATH9K_HW_CAP_BT_ANT_DIV = BIT(17), 252935477edSFelix Fietkau #else 253935477edSFelix Fietkau ATH9K_HW_CAP_RTT = 0, 254935477edSFelix Fietkau ATH9K_HW_CAP_MCI = 0, 255935477edSFelix Fietkau ATH9K_HW_WOW_DEVICE_CAPABLE = 0, 256935477edSFelix Fietkau ATH9K_HW_CAP_BT_ANT_DIV = 0, 257935477edSFelix Fietkau #endif 258935477edSFelix Fietkau ATH9K_HW_CAP_DFS = BIT(18), 259935477edSFelix Fietkau ATH9K_HW_CAP_PAPRD = BIT(19), 260935477edSFelix Fietkau ATH9K_HW_CAP_FCC_BAND_SWITCH = BIT(20), 261203c4805SLuis R. Rodriguez }; 262203c4805SLuis R. Rodriguez 2638e981389SMohammed Shafi Shajakhan /* 2648e981389SMohammed Shafi Shajakhan * WoW device capabilities 2658e981389SMohammed Shafi Shajakhan * @ATH9K_HW_WOW_DEVICE_CAPABLE: device revision is capable of WoW. 2668e981389SMohammed Shafi Shajakhan * @ATH9K_HW_WOW_PATTERN_MATCH_EXACT: device is capable of matching 2678e981389SMohammed Shafi Shajakhan * an exact user defined pattern or de-authentication/disassoc pattern. 2688e981389SMohammed Shafi Shajakhan * @ATH9K_HW_WOW_PATTERN_MATCH_DWORD: device requires the first four 2698e981389SMohammed Shafi Shajakhan * bytes of the pattern for user defined pattern, de-authentication and 2708e981389SMohammed Shafi Shajakhan * disassociation patterns for all types of possible frames recieved 2718e981389SMohammed Shafi Shajakhan * of those types. 2728e981389SMohammed Shafi Shajakhan */ 2738e981389SMohammed Shafi Shajakhan 274203c4805SLuis R. Rodriguez struct ath9k_hw_capabilities { 275203c4805SLuis R. Rodriguez u32 hw_caps; /* ATH9K_HW_CAP_* from ath9k_hw_caps */ 276203c4805SLuis R. Rodriguez u16 rts_aggr_limit; 277203c4805SLuis R. Rodriguez u8 tx_chainmask; 278203c4805SLuis R. Rodriguez u8 rx_chainmask; 27947c80de6SVasanthakumar Thiagarajan u8 max_txchains; 28047c80de6SVasanthakumar Thiagarajan u8 max_rxchains; 281203c4805SLuis R. Rodriguez u8 num_gpio_pins; 282ceb26445SVasanthakumar Thiagarajan u8 rx_hp_qdepth; 283ceb26445SVasanthakumar Thiagarajan u8 rx_lp_qdepth; 284ceb26445SVasanthakumar Thiagarajan u8 rx_status_len; 285162c3be3SVasanthakumar Thiagarajan u8 tx_desc_len; 2865088c2f1SVasanthakumar Thiagarajan u8 txs_len; 287203c4805SLuis R. Rodriguez }; 288203c4805SLuis R. Rodriguez 2894598702dSSujith Manoharan #define AR_NO_SPUR 0x8000 2904598702dSSujith Manoharan #define AR_BASE_FREQ_2GHZ 2300 2914598702dSSujith Manoharan #define AR_BASE_FREQ_5GHZ 4900 2924598702dSSujith Manoharan #define AR_SPUR_FEEQ_BOUND_HT40 19 2934598702dSSujith Manoharan #define AR_SPUR_FEEQ_BOUND_HT20 10 2944598702dSSujith Manoharan 2954598702dSSujith Manoharan enum ath9k_hw_hang_checks { 2964598702dSSujith Manoharan HW_BB_WATCHDOG = BIT(0), 2974598702dSSujith Manoharan HW_PHYRESTART_CLC_WAR = BIT(1), 2984598702dSSujith Manoharan HW_BB_RIFS_HANG = BIT(2), 2994598702dSSujith Manoharan HW_BB_DFS_HANG = BIT(3), 3004598702dSSujith Manoharan HW_BB_RX_CLEAR_STUCK_HANG = BIT(4), 3014598702dSSujith Manoharan HW_MAC_HANG = BIT(5), 3024598702dSSujith Manoharan }; 3034598702dSSujith Manoharan 304203c4805SLuis R. Rodriguez struct ath9k_ops_config { 305203c4805SLuis R. Rodriguez int dma_beacon_response_time; 306203c4805SLuis R. Rodriguez int sw_beacon_response_time; 30741f3e54dSFelix Fietkau u32 cwm_ignore_extcca; 308203c4805SLuis R. Rodriguez u32 pcie_waen; 309203c4805SLuis R. Rodriguez u8 analog_shiftreg; 310203c4805SLuis R. Rodriguez u32 ofdm_trig_low; 311203c4805SLuis R. Rodriguez u32 ofdm_trig_high; 312203c4805SLuis R. Rodriguez u32 cck_trig_high; 313203c4805SLuis R. Rodriguez u32 cck_trig_low; 31474673db9SFelix Fietkau u32 enable_paprd; 315203c4805SLuis R. Rodriguez int serialize_regmode; 3160ce024cbSSujith bool rx_intr_mitigation; 31755e82df4SVasanthakumar Thiagarajan bool tx_intr_mitigation; 318f4709fdfSLuis R. Rodriguez u8 max_txtrig_level; 319e36b27afSLuis R. Rodriguez u16 ani_poll_interval; /* ANI poll interval in ms */ 3204598702dSSujith Manoharan u16 hw_hang_checks; 321a64e1a45SSujith Manoharan u16 rimt_first; 322a64e1a45SSujith Manoharan u16 rimt_last; 3239b60b64bSSujith Manoharan 3249b60b64bSSujith Manoharan /* Platform specific config */ 325b380a43bSSujith Manoharan u32 aspm_l1_fix; 3269b60b64bSSujith Manoharan u32 xlna_gpio; 32731fd216dSSujith Manoharan u32 ant_ctrl_comm2g_switch_enable; 3289b60b64bSSujith Manoharan bool xatten_margin_cfg; 329e083a42eSSujith Manoharan bool alt_mingainidx; 3302d22c7ddSSujith Manoharan bool no_pll_pwrsave; 3310f978bfaSSujith Manoharan bool tx_gain_buffalo; 332203c4805SLuis R. Rodriguez }; 333203c4805SLuis R. Rodriguez 334203c4805SLuis R. Rodriguez enum ath9k_int { 335203c4805SLuis R. Rodriguez ATH9K_INT_RX = 0x00000001, 336203c4805SLuis R. Rodriguez ATH9K_INT_RXDESC = 0x00000002, 337b5c80475SFelix Fietkau ATH9K_INT_RXHP = 0x00000001, 338b5c80475SFelix Fietkau ATH9K_INT_RXLP = 0x00000002, 339203c4805SLuis R. Rodriguez ATH9K_INT_RXNOFRM = 0x00000008, 340203c4805SLuis R. Rodriguez ATH9K_INT_RXEOL = 0x00000010, 341203c4805SLuis R. Rodriguez ATH9K_INT_RXORN = 0x00000020, 342203c4805SLuis R. Rodriguez ATH9K_INT_TX = 0x00000040, 343203c4805SLuis R. Rodriguez ATH9K_INT_TXDESC = 0x00000080, 344203c4805SLuis R. Rodriguez ATH9K_INT_TIM_TIMER = 0x00000100, 3452ee4bd1eSMohammed Shafi Shajakhan ATH9K_INT_MCI = 0x00000200, 346aea702b7SLuis R. Rodriguez ATH9K_INT_BB_WATCHDOG = 0x00000400, 347203c4805SLuis R. Rodriguez ATH9K_INT_TXURN = 0x00000800, 348203c4805SLuis R. Rodriguez ATH9K_INT_MIB = 0x00001000, 349203c4805SLuis R. Rodriguez ATH9K_INT_RXPHY = 0x00004000, 350203c4805SLuis R. Rodriguez ATH9K_INT_RXKCM = 0x00008000, 351203c4805SLuis R. Rodriguez ATH9K_INT_SWBA = 0x00010000, 352203c4805SLuis R. Rodriguez ATH9K_INT_BMISS = 0x00040000, 353203c4805SLuis R. Rodriguez ATH9K_INT_BNR = 0x00100000, 354203c4805SLuis R. Rodriguez ATH9K_INT_TIM = 0x00200000, 355203c4805SLuis R. Rodriguez ATH9K_INT_DTIM = 0x00400000, 356203c4805SLuis R. Rodriguez ATH9K_INT_DTIMSYNC = 0x00800000, 357203c4805SLuis R. Rodriguez ATH9K_INT_GPIO = 0x01000000, 358203c4805SLuis R. Rodriguez ATH9K_INT_CABEND = 0x02000000, 359203c4805SLuis R. Rodriguez ATH9K_INT_TSFOOR = 0x04000000, 360ff155a45SVasanthakumar Thiagarajan ATH9K_INT_GENTIMER = 0x08000000, 361203c4805SLuis R. Rodriguez ATH9K_INT_CST = 0x10000000, 362203c4805SLuis R. Rodriguez ATH9K_INT_GTT = 0x20000000, 363203c4805SLuis R. Rodriguez ATH9K_INT_FATAL = 0x40000000, 364203c4805SLuis R. Rodriguez ATH9K_INT_GLOBAL = 0x80000000, 365203c4805SLuis R. Rodriguez ATH9K_INT_BMISC = ATH9K_INT_TIM | 366203c4805SLuis R. Rodriguez ATH9K_INT_DTIM | 367203c4805SLuis R. Rodriguez ATH9K_INT_DTIMSYNC | 368203c4805SLuis R. Rodriguez ATH9K_INT_TSFOOR | 369203c4805SLuis R. Rodriguez ATH9K_INT_CABEND, 370203c4805SLuis R. Rodriguez ATH9K_INT_COMMON = ATH9K_INT_RXNOFRM | 371203c4805SLuis R. Rodriguez ATH9K_INT_RXDESC | 372203c4805SLuis R. Rodriguez ATH9K_INT_RXEOL | 373203c4805SLuis R. Rodriguez ATH9K_INT_RXORN | 374203c4805SLuis R. Rodriguez ATH9K_INT_TXURN | 375203c4805SLuis R. Rodriguez ATH9K_INT_TXDESC | 376203c4805SLuis R. Rodriguez ATH9K_INT_MIB | 377203c4805SLuis R. Rodriguez ATH9K_INT_RXPHY | 378203c4805SLuis R. Rodriguez ATH9K_INT_RXKCM | 379203c4805SLuis R. Rodriguez ATH9K_INT_SWBA | 380203c4805SLuis R. Rodriguez ATH9K_INT_BMISS | 381203c4805SLuis R. Rodriguez ATH9K_INT_GPIO, 382203c4805SLuis R. Rodriguez ATH9K_INT_NOCARD = 0xffffffff 383203c4805SLuis R. Rodriguez }; 384203c4805SLuis R. Rodriguez 385324c74adSRajkumar Manoharan #define MAX_RTT_TABLE_ENTRY 6 3865f0c04eaSRajkumar Manoharan #define MAX_IQCAL_MEASUREMENT 8 38777a5a664SRajkumar Manoharan #define MAX_CL_TAB_ENTRY 16 38896da6fddSSujith Manoharan #define CL_TAB_ENTRY(reg_base) (reg_base + (4 * j)) 3895f0c04eaSRajkumar Manoharan 3904b9b42bfSSujith Manoharan enum ath9k_cal_flags { 3914b9b42bfSSujith Manoharan RTT_DONE, 3924b9b42bfSSujith Manoharan PAPRD_PACKET_SENT, 3934b9b42bfSSujith Manoharan PAPRD_DONE, 3944b9b42bfSSujith Manoharan NFCAL_PENDING, 3954b9b42bfSSujith Manoharan NFCAL_INTF, 3964b9b42bfSSujith Manoharan TXIQCAL_DONE, 3974b9b42bfSSujith Manoharan TXCLCAL_DONE, 3983001f0d0SSujith Manoharan SW_PKDET_DONE, 3994b9b42bfSSujith Manoharan }; 4004b9b42bfSSujith Manoharan 40120bd2a09SFelix Fietkau struct ath9k_hw_cal_data { 402203c4805SLuis R. Rodriguez u16 channel; 4036b21fd20SFelix Fietkau u16 channelFlags; 4044b9b42bfSSujith Manoharan unsigned long cal_flags; 405203c4805SLuis R. Rodriguez int32_t CalValid; 406203c4805SLuis R. Rodriguez int8_t iCoff; 407203c4805SLuis R. Rodriguez int8_t qCoff; 4083001f0d0SSujith Manoharan u8 caldac[2]; 409717f6bedSFelix Fietkau u16 small_signal_gain[AR9300_MAX_CHAINS]; 410717f6bedSFelix Fietkau u32 pa_table[AR9300_MAX_CHAINS][PAPRD_TABLE_SZ]; 4115f0c04eaSRajkumar Manoharan u32 num_measures[AR9300_MAX_CHAINS]; 4125f0c04eaSRajkumar Manoharan int tx_corr_coeff[MAX_IQCAL_MEASUREMENT][AR9300_MAX_CHAINS]; 41377a5a664SRajkumar Manoharan u32 tx_clcal[AR9300_MAX_CHAINS][MAX_CL_TAB_ENTRY]; 4148a90555fSSujith Manoharan u32 rtt_table[AR9300_MAX_CHAINS][MAX_RTT_TABLE_ENTRY]; 41520bd2a09SFelix Fietkau struct ath9k_nfcal_hist nfCalHist[NUM_NF_READINGS]; 41620bd2a09SFelix Fietkau }; 41720bd2a09SFelix Fietkau 41820bd2a09SFelix Fietkau struct ath9k_channel { 41920bd2a09SFelix Fietkau struct ieee80211_channel *chan; 42020bd2a09SFelix Fietkau u16 channel; 4216b21fd20SFelix Fietkau u16 channelFlags; 422d9891c78SFelix Fietkau s16 noisefloor; 423203c4805SLuis R. Rodriguez }; 424203c4805SLuis R. Rodriguez 4256b21fd20SFelix Fietkau #define CHANNEL_5GHZ BIT(0) 4266b21fd20SFelix Fietkau #define CHANNEL_HALF BIT(1) 4276b21fd20SFelix Fietkau #define CHANNEL_QUARTER BIT(2) 4286b21fd20SFelix Fietkau #define CHANNEL_HT BIT(3) 4296b21fd20SFelix Fietkau #define CHANNEL_HT40PLUS BIT(4) 4306b21fd20SFelix Fietkau #define CHANNEL_HT40MINUS BIT(5) 431203c4805SLuis R. Rodriguez 4326b21fd20SFelix Fietkau #define IS_CHAN_5GHZ(_c) (!!((_c)->channelFlags & CHANNEL_5GHZ)) 4336b21fd20SFelix Fietkau #define IS_CHAN_2GHZ(_c) (!IS_CHAN_5GHZ(_c)) 4346b21fd20SFelix Fietkau 4356b21fd20SFelix Fietkau #define IS_CHAN_HALF_RATE(_c) (!!((_c)->channelFlags & CHANNEL_HALF)) 4366b21fd20SFelix Fietkau #define IS_CHAN_QUARTER_RATE(_c) (!!((_c)->channelFlags & CHANNEL_QUARTER)) 4376b21fd20SFelix Fietkau #define IS_CHAN_A_FAST_CLOCK(_ah, _c) \ 4386b21fd20SFelix Fietkau (IS_CHAN_5GHZ(_c) && ((_ah)->caps.hw_caps & ATH9K_HW_CAP_FASTCLOCK)) 4396b21fd20SFelix Fietkau 4406b21fd20SFelix Fietkau #define IS_CHAN_HT(_c) ((_c)->channelFlags & CHANNEL_HT) 4416b21fd20SFelix Fietkau 4426b21fd20SFelix Fietkau #define IS_CHAN_HT20(_c) (IS_CHAN_HT(_c) && !IS_CHAN_HT40(_c)) 4436b21fd20SFelix Fietkau 4446b21fd20SFelix Fietkau #define IS_CHAN_HT40(_c) \ 4456b21fd20SFelix Fietkau (!!((_c)->channelFlags & (CHANNEL_HT40PLUS | CHANNEL_HT40MINUS))) 4466b21fd20SFelix Fietkau 4476b21fd20SFelix Fietkau #define IS_CHAN_HT40PLUS(_c) ((_c)->channelFlags & CHANNEL_HT40PLUS) 4486b21fd20SFelix Fietkau #define IS_CHAN_HT40MINUS(_c) ((_c)->channelFlags & CHANNEL_HT40MINUS) 449203c4805SLuis R. Rodriguez 450203c4805SLuis R. Rodriguez enum ath9k_power_mode { 451203c4805SLuis R. Rodriguez ATH9K_PM_AWAKE = 0, 452203c4805SLuis R. Rodriguez ATH9K_PM_FULL_SLEEP, 453203c4805SLuis R. Rodriguez ATH9K_PM_NETWORK_SLEEP, 454203c4805SLuis R. Rodriguez ATH9K_PM_UNDEFINED 455203c4805SLuis R. Rodriguez }; 456203c4805SLuis R. Rodriguez 457203c4805SLuis R. Rodriguez enum ser_reg_mode { 458203c4805SLuis R. Rodriguez SER_REG_MODE_OFF = 0, 459203c4805SLuis R. Rodriguez SER_REG_MODE_ON = 1, 460203c4805SLuis R. Rodriguez SER_REG_MODE_AUTO = 2, 461203c4805SLuis R. Rodriguez }; 462203c4805SLuis R. Rodriguez 463ad7b8060SVasanthakumar Thiagarajan enum ath9k_rx_qtype { 464ad7b8060SVasanthakumar Thiagarajan ATH9K_RX_QUEUE_HP, 465ad7b8060SVasanthakumar Thiagarajan ATH9K_RX_QUEUE_LP, 466ad7b8060SVasanthakumar Thiagarajan ATH9K_RX_QUEUE_MAX, 467ad7b8060SVasanthakumar Thiagarajan }; 468ad7b8060SVasanthakumar Thiagarajan 469203c4805SLuis R. Rodriguez struct ath9k_beacon_state { 470203c4805SLuis R. Rodriguez u32 bs_nexttbtt; 471203c4805SLuis R. Rodriguez u32 bs_nextdtim; 472203c4805SLuis R. Rodriguez u32 bs_intval; 473203c4805SLuis R. Rodriguez #define ATH9K_TSFOOR_THRESHOLD 0x00004240 /* 16k us */ 474203c4805SLuis R. Rodriguez u32 bs_dtimperiod; 475203c4805SLuis R. Rodriguez u16 bs_bmissthreshold; 476203c4805SLuis R. Rodriguez u32 bs_sleepduration; 477203c4805SLuis R. Rodriguez u32 bs_tsfoor_threshold; 478203c4805SLuis R. Rodriguez }; 479203c4805SLuis R. Rodriguez 480203c4805SLuis R. Rodriguez struct chan_centers { 481203c4805SLuis R. Rodriguez u16 synth_center; 482203c4805SLuis R. Rodriguez u16 ctl_center; 483203c4805SLuis R. Rodriguez u16 ext_center; 484203c4805SLuis R. Rodriguez }; 485203c4805SLuis R. Rodriguez 486203c4805SLuis R. Rodriguez enum { 487203c4805SLuis R. Rodriguez ATH9K_RESET_POWER_ON, 488203c4805SLuis R. Rodriguez ATH9K_RESET_WARM, 489203c4805SLuis R. Rodriguez ATH9K_RESET_COLD, 490203c4805SLuis R. Rodriguez }; 491203c4805SLuis R. Rodriguez 492203c4805SLuis R. Rodriguez struct ath9k_hw_version { 493203c4805SLuis R. Rodriguez u32 magic; 494203c4805SLuis R. Rodriguez u16 devid; 495203c4805SLuis R. Rodriguez u16 subvendorid; 496203c4805SLuis R. Rodriguez u32 macVersion; 497203c4805SLuis R. Rodriguez u16 macRev; 498203c4805SLuis R. Rodriguez u16 phyRev; 499203c4805SLuis R. Rodriguez u16 analog5GhzRev; 500203c4805SLuis R. Rodriguez u16 analog2GhzRev; 5010b5ead91SSujith Manoharan enum ath_usb_dev usbdev; 502203c4805SLuis R. Rodriguez }; 503203c4805SLuis R. Rodriguez 504ff155a45SVasanthakumar Thiagarajan /* Generic TSF timer definitions */ 505ff155a45SVasanthakumar Thiagarajan 506ff155a45SVasanthakumar Thiagarajan #define ATH_MAX_GEN_TIMER 16 507ff155a45SVasanthakumar Thiagarajan 508ff155a45SVasanthakumar Thiagarajan #define AR_GENTMR_BIT(_index) (1 << (_index)) 509ff155a45SVasanthakumar Thiagarajan 510ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer_configuration { 511ff155a45SVasanthakumar Thiagarajan u32 next_addr; 512ff155a45SVasanthakumar Thiagarajan u32 period_addr; 513ff155a45SVasanthakumar Thiagarajan u32 mode_addr; 514ff155a45SVasanthakumar Thiagarajan u32 mode_mask; 515ff155a45SVasanthakumar Thiagarajan }; 516ff155a45SVasanthakumar Thiagarajan 517ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer { 518ff155a45SVasanthakumar Thiagarajan void (*trigger)(void *arg); 519ff155a45SVasanthakumar Thiagarajan void (*overflow)(void *arg); 520ff155a45SVasanthakumar Thiagarajan void *arg; 521ff155a45SVasanthakumar Thiagarajan u8 index; 522ff155a45SVasanthakumar Thiagarajan }; 523ff155a45SVasanthakumar Thiagarajan 524ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer_table { 525ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer *timers[ATH_MAX_GEN_TIMER]; 526c67ce339SFelix Fietkau u16 timer_mask; 527ff155a45SVasanthakumar Thiagarajan }; 528ff155a45SVasanthakumar Thiagarajan 52921cc630fSVasanthakumar Thiagarajan struct ath_hw_antcomb_conf { 53021cc630fSVasanthakumar Thiagarajan u8 main_lna_conf; 53121cc630fSVasanthakumar Thiagarajan u8 alt_lna_conf; 53221cc630fSVasanthakumar Thiagarajan u8 fast_div_bias; 533c6ba9febSMohammed Shafi Shajakhan u8 main_gaintb; 534c6ba9febSMohammed Shafi Shajakhan u8 alt_gaintb; 535c6ba9febSMohammed Shafi Shajakhan int lna1_lna2_delta; 536f96bd2adSSujith Manoharan int lna1_lna2_switch_delta; 5378afbcc8bSMohammed Shafi Shajakhan u8 div_group; 53821cc630fSVasanthakumar Thiagarajan }; 53921cc630fSVasanthakumar Thiagarajan 540d70357d5SLuis R. Rodriguez /** 5414e8c14e9SFelix Fietkau * struct ath_hw_radar_conf - radar detection initialization parameters 5424e8c14e9SFelix Fietkau * 5434e8c14e9SFelix Fietkau * @pulse_inband: threshold for checking the ratio of in-band power 5444e8c14e9SFelix Fietkau * to total power for short radar pulses (half dB steps) 5454e8c14e9SFelix Fietkau * @pulse_inband_step: threshold for checking an in-band power to total 5464e8c14e9SFelix Fietkau * power ratio increase for short radar pulses (half dB steps) 5474e8c14e9SFelix Fietkau * @pulse_height: threshold for detecting the beginning of a short 5484e8c14e9SFelix Fietkau * radar pulse (dB step) 5494e8c14e9SFelix Fietkau * @pulse_rssi: threshold for detecting if a short radar pulse is 5504e8c14e9SFelix Fietkau * gone (dB step) 5514e8c14e9SFelix Fietkau * @pulse_maxlen: maximum pulse length (0.8 us steps) 5524e8c14e9SFelix Fietkau * 5534e8c14e9SFelix Fietkau * @radar_rssi: RSSI threshold for starting long radar detection (dB steps) 5544e8c14e9SFelix Fietkau * @radar_inband: threshold for checking the ratio of in-band power 5554e8c14e9SFelix Fietkau * to total power for long radar pulses (half dB steps) 5564e8c14e9SFelix Fietkau * @fir_power: threshold for detecting the end of a long radar pulse (dB) 5574e8c14e9SFelix Fietkau * 5584e8c14e9SFelix Fietkau * @ext_channel: enable extension channel radar detection 5594e8c14e9SFelix Fietkau */ 5604e8c14e9SFelix Fietkau struct ath_hw_radar_conf { 5614e8c14e9SFelix Fietkau unsigned int pulse_inband; 5624e8c14e9SFelix Fietkau unsigned int pulse_inband_step; 5634e8c14e9SFelix Fietkau unsigned int pulse_height; 5644e8c14e9SFelix Fietkau unsigned int pulse_rssi; 5654e8c14e9SFelix Fietkau unsigned int pulse_maxlen; 5664e8c14e9SFelix Fietkau 5674e8c14e9SFelix Fietkau unsigned int radar_rssi; 5684e8c14e9SFelix Fietkau unsigned int radar_inband; 5694e8c14e9SFelix Fietkau int fir_power; 5704e8c14e9SFelix Fietkau 5714e8c14e9SFelix Fietkau bool ext_channel; 5724e8c14e9SFelix Fietkau }; 5734e8c14e9SFelix Fietkau 5744e8c14e9SFelix Fietkau /** 575d70357d5SLuis R. Rodriguez * struct ath_hw_private_ops - callbacks used internally by hardware code 576d70357d5SLuis R. Rodriguez * 577d70357d5SLuis R. Rodriguez * This structure contains private callbacks designed to only be used internally 578d70357d5SLuis R. Rodriguez * by the hardware core. 579d70357d5SLuis R. Rodriguez * 580795f5e2cSLuis R. Rodriguez * @init_cal_settings: setup types of calibrations supported 581795f5e2cSLuis R. Rodriguez * @init_cal: starts actual calibration 582795f5e2cSLuis R. Rodriguez * 583991312d8SLuis R. Rodriguez * @init_mode_gain_regs: Initialize TX/RX gain registers 5848fe65368SLuis R. Rodriguez * 5858fe65368SLuis R. Rodriguez * @rf_set_freq: change frequency 5868fe65368SLuis R. Rodriguez * @spur_mitigate_freq: spur mitigation 5878fe65368SLuis R. Rodriguez * @set_rf_regs: 58864773964SLuis R. Rodriguez * @compute_pll_control: compute the PLL control value to use for 58964773964SLuis R. Rodriguez * AR_RTC_PLL_CONTROL for a given channel 590795f5e2cSLuis R. Rodriguez * @setup_calibration: set up calibration 591795f5e2cSLuis R. Rodriguez * @iscal_supported: used to query if a type of calibration is supported 592ac0bb767SLuis R. Rodriguez * 593e36b27afSLuis R. Rodriguez * @ani_cache_ini_regs: cache the values for ANI from the initial 594e36b27afSLuis R. Rodriguez * register settings through the register initialization. 595d70357d5SLuis R. Rodriguez */ 596d70357d5SLuis R. Rodriguez struct ath_hw_private_ops { 5974598702dSSujith Manoharan void (*init_hang_checks)(struct ath_hw *ah); 598990de2b2SSujith Manoharan bool (*detect_mac_hang)(struct ath_hw *ah); 599990de2b2SSujith Manoharan bool (*detect_bb_hang)(struct ath_hw *ah); 600990de2b2SSujith Manoharan 601795f5e2cSLuis R. Rodriguez /* Calibration ops */ 602d70357d5SLuis R. Rodriguez void (*init_cal_settings)(struct ath_hw *ah); 603795f5e2cSLuis R. Rodriguez bool (*init_cal)(struct ath_hw *ah, struct ath9k_channel *chan); 604795f5e2cSLuis R. Rodriguez 605991312d8SLuis R. Rodriguez void (*init_mode_gain_regs)(struct ath_hw *ah); 606795f5e2cSLuis R. Rodriguez void (*setup_calibration)(struct ath_hw *ah, 607795f5e2cSLuis R. Rodriguez struct ath9k_cal_list *currCal); 6088fe65368SLuis R. Rodriguez 6098fe65368SLuis R. Rodriguez /* PHY ops */ 6108fe65368SLuis R. Rodriguez int (*rf_set_freq)(struct ath_hw *ah, 6118fe65368SLuis R. Rodriguez struct ath9k_channel *chan); 6128fe65368SLuis R. Rodriguez void (*spur_mitigate_freq)(struct ath_hw *ah, 6138fe65368SLuis R. Rodriguez struct ath9k_channel *chan); 6148fe65368SLuis R. Rodriguez bool (*set_rf_regs)(struct ath_hw *ah, 6158fe65368SLuis R. Rodriguez struct ath9k_channel *chan, 6168fe65368SLuis R. Rodriguez u16 modesIndex); 6178fe65368SLuis R. Rodriguez void (*set_channel_regs)(struct ath_hw *ah, struct ath9k_channel *chan); 6188fe65368SLuis R. Rodriguez void (*init_bb)(struct ath_hw *ah, 6198fe65368SLuis R. Rodriguez struct ath9k_channel *chan); 6208fe65368SLuis R. Rodriguez int (*process_ini)(struct ath_hw *ah, struct ath9k_channel *chan); 6218fe65368SLuis R. Rodriguez void (*olc_init)(struct ath_hw *ah); 6228fe65368SLuis R. Rodriguez void (*set_rfmode)(struct ath_hw *ah, struct ath9k_channel *chan); 6238fe65368SLuis R. Rodriguez void (*mark_phy_inactive)(struct ath_hw *ah); 6248fe65368SLuis R. Rodriguez void (*set_delta_slope)(struct ath_hw *ah, struct ath9k_channel *chan); 6258fe65368SLuis R. Rodriguez bool (*rfbus_req)(struct ath_hw *ah); 6268fe65368SLuis R. Rodriguez void (*rfbus_done)(struct ath_hw *ah); 6278fe65368SLuis R. Rodriguez void (*restore_chainmask)(struct ath_hw *ah); 62864773964SLuis R. Rodriguez u32 (*compute_pll_control)(struct ath_hw *ah, 62964773964SLuis R. Rodriguez struct ath9k_channel *chan); 630c16fcb49SFelix Fietkau bool (*ani_control)(struct ath_hw *ah, enum ath9k_ani_cmd cmd, 631c16fcb49SFelix Fietkau int param); 632641d9921SFelix Fietkau void (*do_getnf)(struct ath_hw *ah, int16_t nfarray[NUM_NF_READINGS]); 6334e8c14e9SFelix Fietkau void (*set_radar_params)(struct ath_hw *ah, 6344e8c14e9SFelix Fietkau struct ath_hw_radar_conf *conf); 6355f0c04eaSRajkumar Manoharan int (*fast_chan_change)(struct ath_hw *ah, struct ath9k_channel *chan, 6365f0c04eaSRajkumar Manoharan u8 *ini_reloaded); 637ac0bb767SLuis R. Rodriguez 638ac0bb767SLuis R. Rodriguez /* ANI */ 639e36b27afSLuis R. Rodriguez void (*ani_cache_ini_regs)(struct ath_hw *ah); 640d70357d5SLuis R. Rodriguez }; 641d70357d5SLuis R. Rodriguez 642d70357d5SLuis R. Rodriguez /** 643e93d083fSSimon Wunderlich * struct ath_spec_scan - parameters for Atheros spectral scan 644e93d083fSSimon Wunderlich * 645e93d083fSSimon Wunderlich * @enabled: enable/disable spectral scan 646e93d083fSSimon Wunderlich * @short_repeat: controls whether the chip is in spectral scan mode 647e93d083fSSimon Wunderlich * for 4 usec (enabled) or 204 usec (disabled) 648e93d083fSSimon Wunderlich * @count: number of scan results requested. There are special meanings 649e93d083fSSimon Wunderlich * in some chip revisions: 650e93d083fSSimon Wunderlich * AR92xx: highest bit set (>=128) for endless mode 651e93d083fSSimon Wunderlich * (spectral scan won't stopped until explicitly disabled) 652e93d083fSSimon Wunderlich * AR9300 and newer: 0 for endless mode 653e93d083fSSimon Wunderlich * @endless: true if endless mode is intended. Otherwise, count value is 654e93d083fSSimon Wunderlich * corrected to the next possible value. 655e93d083fSSimon Wunderlich * @period: time duration between successive spectral scan entry points 656e93d083fSSimon Wunderlich * (period*256*Tclk). Tclk = ath_common->clockrate 657e93d083fSSimon Wunderlich * @fft_period: PHY passes FFT frames to MAC every (fft_period+1)*4uS 658e93d083fSSimon Wunderlich * 659e93d083fSSimon Wunderlich * Note: Tclk = 40MHz or 44MHz depending upon operating mode. 660e93d083fSSimon Wunderlich * Typically it's 44MHz in 2/5GHz on later chips, but there's 661e93d083fSSimon Wunderlich * a "fast clock" check for this in 5GHz. 662e93d083fSSimon Wunderlich * 663e93d083fSSimon Wunderlich */ 664e93d083fSSimon Wunderlich struct ath_spec_scan { 665e93d083fSSimon Wunderlich bool enabled; 666e93d083fSSimon Wunderlich bool short_repeat; 667e93d083fSSimon Wunderlich bool endless; 668e93d083fSSimon Wunderlich u8 count; 669e93d083fSSimon Wunderlich u8 period; 670e93d083fSSimon Wunderlich u8 fft_period; 671e93d083fSSimon Wunderlich }; 672e93d083fSSimon Wunderlich 673e93d083fSSimon Wunderlich /** 674d70357d5SLuis R. Rodriguez * struct ath_hw_ops - callbacks used by hardware code and driver code 675d70357d5SLuis R. Rodriguez * 676d70357d5SLuis R. Rodriguez * This structure contains callbacks designed to to be used internally by 677d70357d5SLuis R. Rodriguez * hardware code and also by the lower level driver. 678d70357d5SLuis R. Rodriguez * 679d70357d5SLuis R. Rodriguez * @config_pci_powersave: 680795f5e2cSLuis R. Rodriguez * @calibrate: periodic calibration for NF, ANI, IQ, ADC gain, ADC-DC 681e93d083fSSimon Wunderlich * 682e93d083fSSimon Wunderlich * @spectral_scan_config: set parameters for spectral scan and enable/disable it 683e93d083fSSimon Wunderlich * @spectral_scan_trigger: trigger a spectral scan run 684e93d083fSSimon Wunderlich * @spectral_scan_wait: wait for a spectral scan run to finish 685d70357d5SLuis R. Rodriguez */ 686d70357d5SLuis R. Rodriguez struct ath_hw_ops { 687d70357d5SLuis R. Rodriguez void (*config_pci_powersave)(struct ath_hw *ah, 68884c87dc8SStanislaw Gruszka bool power_off); 689cee1f625SVasanthakumar Thiagarajan void (*rx_enable)(struct ath_hw *ah); 69087d5efbbSVasanthakumar Thiagarajan void (*set_desc_link)(void *ds, u32 link); 6917b8aaeadSFelix Fietkau int (*calibrate)(struct ath_hw *ah, struct ath9k_channel *chan, 6927b8aaeadSFelix Fietkau u8 rxchainmask, bool longcal); 6936a4d05dcSFelix Fietkau bool (*get_isr)(struct ath_hw *ah, enum ath9k_int *masked, 6946a4d05dcSFelix Fietkau u32 *sync_cause_p); 6952b63a41dSFelix Fietkau void (*set_txdesc)(struct ath_hw *ah, void *ds, 6962b63a41dSFelix Fietkau struct ath_tx_info *i); 697cc610ac0SVasanthakumar Thiagarajan int (*proc_txdesc)(struct ath_hw *ah, void *ds, 698cc610ac0SVasanthakumar Thiagarajan struct ath_tx_status *ts); 699315dd114SFelix Fietkau int (*get_duration)(struct ath_hw *ah, const void *ds, int index); 70069de3721SMohammed Shafi Shajakhan void (*antdiv_comb_conf_get)(struct ath_hw *ah, 70169de3721SMohammed Shafi Shajakhan struct ath_hw_antcomb_conf *antconf); 70269de3721SMohammed Shafi Shajakhan void (*antdiv_comb_conf_set)(struct ath_hw *ah, 70369de3721SMohammed Shafi Shajakhan struct ath_hw_antcomb_conf *antconf); 704e93d083fSSimon Wunderlich void (*spectral_scan_config)(struct ath_hw *ah, 705e93d083fSSimon Wunderlich struct ath_spec_scan *param); 706e93d083fSSimon Wunderlich void (*spectral_scan_trigger)(struct ath_hw *ah); 707e93d083fSSimon Wunderlich void (*spectral_scan_wait)(struct ath_hw *ah); 70836e8825eSSujith Manoharan 70989f927afSLuis R. Rodriguez void (*tx99_start)(struct ath_hw *ah, u32 qnum); 71089f927afSLuis R. Rodriguez void (*tx99_stop)(struct ath_hw *ah); 71189f927afSLuis R. Rodriguez void (*tx99_set_txpower)(struct ath_hw *ah, u8 power); 71289f927afSLuis R. Rodriguez 71336e8825eSSujith Manoharan #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 71436e8825eSSujith Manoharan void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable); 71536e8825eSSujith Manoharan #endif 716d70357d5SLuis R. Rodriguez }; 717d70357d5SLuis R. Rodriguez 718f2552e28SFelix Fietkau struct ath_nf_limits { 719f2552e28SFelix Fietkau s16 max; 720f2552e28SFelix Fietkau s16 min; 721f2552e28SFelix Fietkau s16 nominal; 722f2552e28SFelix Fietkau }; 723f2552e28SFelix Fietkau 7248ad74c4dSRajkumar Manoharan enum ath_cal_list { 7258ad74c4dSRajkumar Manoharan TX_IQ_CAL = BIT(0), 7268ad74c4dSRajkumar Manoharan TX_IQ_ON_AGC_CAL = BIT(1), 7278ad74c4dSRajkumar Manoharan TX_CL_CAL = BIT(2), 7288ad74c4dSRajkumar Manoharan }; 7298ad74c4dSRajkumar Manoharan 73097dcec57SSujith Manoharan /* ah_flags */ 73197dcec57SSujith Manoharan #define AH_USE_EEPROM 0x1 73297dcec57SSujith Manoharan #define AH_UNPLUGGED 0x2 /* The card has been physically removed. */ 733a126ff51SRajkumar Manoharan #define AH_FASTCC 0x4 734a59dadbeSFelix Fietkau #define AH_NO_EEP_SWAP 0x8 /* Do not swap EEPROM data */ 73597dcec57SSujith Manoharan 736203c4805SLuis R. Rodriguez struct ath_hw { 737f9f84e96SFelix Fietkau struct ath_ops reg_ops; 738f9f84e96SFelix Fietkau 739c1b976d2SFelix Fietkau struct device *dev; 740b002a4a9SLuis R. Rodriguez struct ieee80211_hw *hw; 74127c51f1aSLuis R. Rodriguez struct ath_common common; 742203c4805SLuis R. Rodriguez struct ath9k_hw_version hw_version; 743203c4805SLuis R. Rodriguez struct ath9k_ops_config config; 744203c4805SLuis R. Rodriguez struct ath9k_hw_capabilities caps; 745cac4220bSFelix Fietkau struct ath9k_channel channels[ATH9K_NUM_CHANNELS]; 746203c4805SLuis R. Rodriguez struct ath9k_channel *curchan; 747203c4805SLuis R. Rodriguez 748203c4805SLuis R. Rodriguez union { 749203c4805SLuis R. Rodriguez struct ar5416_eeprom_def def; 750203c4805SLuis R. Rodriguez struct ar5416_eeprom_4k map4k; 751475f5989SLuis R. Rodriguez struct ar9287_eeprom map9287; 75215c9ee7aSSenthil Balasubramanian struct ar9300_eeprom ar9300_eep; 753203c4805SLuis R. Rodriguez } eeprom; 754203c4805SLuis R. Rodriguez const struct eeprom_ops *eep_ops; 755203c4805SLuis R. Rodriguez 756*e6510b11SChun-Yeow Yeoh bool sw_mgmt_crypto_tx; 757*e6510b11SChun-Yeow Yeoh bool sw_mgmt_crypto_rx; 758203c4805SLuis R. Rodriguez bool is_pciexpress; 759d4930086SStanislaw Gruszka bool aspm_enabled; 7605f841b41SRajkumar Manoharan bool is_monitoring; 7612eb46d9bSPavel Roskin bool need_an_top2_fixup; 762203c4805SLuis R. Rodriguez u16 tx_trig_level; 763f2552e28SFelix Fietkau 764bbacee13SFelix Fietkau u32 nf_regs[6]; 765f2552e28SFelix Fietkau struct ath_nf_limits nf_2g; 766f2552e28SFelix Fietkau struct ath_nf_limits nf_5g; 767203c4805SLuis R. Rodriguez u16 rfsilent; 768203c4805SLuis R. Rodriguez u32 rfkill_gpio; 769203c4805SLuis R. Rodriguez u32 rfkill_polarity; 770203c4805SLuis R. Rodriguez u32 ah_flags; 771203c4805SLuis R. Rodriguez 772ceb26a60SFelix Fietkau bool reset_power_on; 773d7e7d229SLuis R. Rodriguez bool htc_reset_init; 774d7e7d229SLuis R. Rodriguez 775203c4805SLuis R. Rodriguez enum nl80211_iftype opmode; 776203c4805SLuis R. Rodriguez enum ath9k_power_mode power_mode; 777203c4805SLuis R. Rodriguez 778f23fba49SFelix Fietkau s8 noise; 77920bd2a09SFelix Fietkau struct ath9k_hw_cal_data *caldata; 780a13883b0SSujith struct ath9k_pacal_info pacal_info; 781203c4805SLuis R. Rodriguez struct ar5416Stats stats; 782203c4805SLuis R. Rodriguez struct ath9k_tx_queue_info txq[ATH9K_NUM_TX_QUEUES]; 783203c4805SLuis R. Rodriguez 7843069168cSPavel Roskin enum ath9k_int imask; 78574bad5cbSPavel Roskin u32 imrs2_reg; 786203c4805SLuis R. Rodriguez u32 txok_interrupt_mask; 787203c4805SLuis R. Rodriguez u32 txerr_interrupt_mask; 788203c4805SLuis R. Rodriguez u32 txdesc_interrupt_mask; 789203c4805SLuis R. Rodriguez u32 txeol_interrupt_mask; 790203c4805SLuis R. Rodriguez u32 txurn_interrupt_mask; 791e8fe7336SRajkumar Manoharan atomic_t intr_ref_cnt; 792203c4805SLuis R. Rodriguez bool chip_fullsleep; 7935f0c04eaSRajkumar Manoharan u32 modes_index; 794203c4805SLuis R. Rodriguez 795203c4805SLuis R. Rodriguez /* Calibration */ 7966497827fSFelix Fietkau u32 supp_cals; 797cbfe9468SSujith struct ath9k_cal_list iq_caldata; 798cbfe9468SSujith struct ath9k_cal_list adcgain_caldata; 799cbfe9468SSujith struct ath9k_cal_list adcdc_caldata; 800cbfe9468SSujith struct ath9k_cal_list *cal_list; 801cbfe9468SSujith struct ath9k_cal_list *cal_list_last; 802cbfe9468SSujith struct ath9k_cal_list *cal_list_curr; 803203c4805SLuis R. Rodriguez #define totalPowerMeasI meas0.unsign 804203c4805SLuis R. Rodriguez #define totalPowerMeasQ meas1.unsign 805203c4805SLuis R. Rodriguez #define totalIqCorrMeas meas2.sign 806203c4805SLuis R. Rodriguez #define totalAdcIOddPhase meas0.unsign 807203c4805SLuis R. Rodriguez #define totalAdcIEvenPhase meas1.unsign 808203c4805SLuis R. Rodriguez #define totalAdcQOddPhase meas2.unsign 809203c4805SLuis R. Rodriguez #define totalAdcQEvenPhase meas3.unsign 810203c4805SLuis R. Rodriguez #define totalAdcDcOffsetIOddPhase meas0.sign 811203c4805SLuis R. Rodriguez #define totalAdcDcOffsetIEvenPhase meas1.sign 812203c4805SLuis R. Rodriguez #define totalAdcDcOffsetQOddPhase meas2.sign 813203c4805SLuis R. Rodriguez #define totalAdcDcOffsetQEvenPhase meas3.sign 814203c4805SLuis R. Rodriguez union { 815203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 816203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 817203c4805SLuis R. Rodriguez } meas0; 818203c4805SLuis R. Rodriguez union { 819203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 820203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 821203c4805SLuis R. Rodriguez } meas1; 822203c4805SLuis R. Rodriguez union { 823203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 824203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 825203c4805SLuis R. Rodriguez } meas2; 826203c4805SLuis R. Rodriguez union { 827203c4805SLuis R. Rodriguez u32 unsign[AR5416_MAX_CHAINS]; 828203c4805SLuis R. Rodriguez int32_t sign[AR5416_MAX_CHAINS]; 829203c4805SLuis R. Rodriguez } meas3; 830203c4805SLuis R. Rodriguez u16 cal_samples; 8318ad74c4dSRajkumar Manoharan u8 enabled_cals; 832203c4805SLuis R. Rodriguez 833203c4805SLuis R. Rodriguez u32 sta_id1_defaults; 834203c4805SLuis R. Rodriguez u32 misc_mode; 835203c4805SLuis R. Rodriguez 836d70357d5SLuis R. Rodriguez /* Private to hardware code */ 837d70357d5SLuis R. Rodriguez struct ath_hw_private_ops private_ops; 838d70357d5SLuis R. Rodriguez /* Accessed by the lower level driver */ 839d70357d5SLuis R. Rodriguez struct ath_hw_ops ops; 840d70357d5SLuis R. Rodriguez 841e68a060bSLuis R. Rodriguez /* Used to program the radio on non single-chip devices */ 842203c4805SLuis R. Rodriguez u32 *analogBank6Data; 843203c4805SLuis R. Rodriguez 844e239d859SFelix Fietkau int coverage_class; 845203c4805SLuis R. Rodriguez u32 slottime; 846203c4805SLuis R. Rodriguez u32 globaltxtimeout; 847203c4805SLuis R. Rodriguez 848203c4805SLuis R. Rodriguez /* ANI */ 849203c4805SLuis R. Rodriguez u32 aniperiod; 850203c4805SLuis R. Rodriguez enum ath9k_ani_cmd ani_function; 851424749c7SRajkumar Manoharan u32 ani_skip_count; 852c24bd362SSujith Manoharan struct ar5416AniState ani; 853203c4805SLuis R. Rodriguez 854dbccdd1dSSujith Manoharan #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 855766ec4a9SLuis R. Rodriguez struct ath_btcoex_hw btcoex_hw; 856dbccdd1dSSujith Manoharan #endif 857af03abecSLuis R. Rodriguez 858203c4805SLuis R. Rodriguez u32 intr_txqs; 859203c4805SLuis R. Rodriguez u8 txchainmask; 860203c4805SLuis R. Rodriguez u8 rxchainmask; 861203c4805SLuis R. Rodriguez 862c5d0855aSFelix Fietkau struct ath_hw_radar_conf radar_conf; 863c5d0855aSFelix Fietkau 864203c4805SLuis R. Rodriguez u32 originalGain[22]; 865203c4805SLuis R. Rodriguez int initPDADC; 866203c4805SLuis R. Rodriguez int PDADCdelta; 8676de66dd9SFelix Fietkau int led_pin; 868691680b8SFelix Fietkau u32 gpio_mask; 869691680b8SFelix Fietkau u32 gpio_val; 870203c4805SLuis R. Rodriguez 8714a878b9fSSujith Manoharan struct ar5416IniArray ini_dfs; 872203c4805SLuis R. Rodriguez struct ar5416IniArray iniModes; 873203c4805SLuis R. Rodriguez struct ar5416IniArray iniCommon; 874203c4805SLuis R. Rodriguez struct ar5416IniArray iniBB_RfGain; 875203c4805SLuis R. Rodriguez struct ar5416IniArray iniBank6; 876203c4805SLuis R. Rodriguez struct ar5416IniArray iniAddac; 877203c4805SLuis R. Rodriguez struct ar5416IniArray iniPcieSerdes; 87813ce3e99SLuis R. Rodriguez struct ar5416IniArray iniPcieSerdesLowPower; 879c7d36f9fSFelix Fietkau struct ar5416IniArray iniModesFastClock; 880c7d36f9fSFelix Fietkau struct ar5416IniArray iniAdditional; 881203c4805SLuis R. Rodriguez struct ar5416IniArray iniModesRxGain; 8828bc45c6bSGabor Juhos struct ar5416IniArray ini_modes_rx_gain_bounds; 883203c4805SLuis R. Rodriguez struct ar5416IniArray iniModesTxGain; 884193cd458SSujith struct ar5416IniArray iniCckfirNormal; 885193cd458SSujith struct ar5416IniArray iniCckfirJapan2484; 88670807e99SSujith struct ar5416IniArray iniModes_9271_ANI_reg; 887ce407afcSSenthil Balasubramanian struct ar5416IniArray ini_radio_post_sys2ant; 88851dbd0a8SSujith Manoharan struct ar5416IniArray ini_modes_rxgain_5g_xlna; 889c177fabeSSujith Manoharan struct ar5416IniArray ini_modes_rxgain_bb_core; 890c177fabeSSujith Manoharan struct ar5416IniArray ini_modes_rxgain_bb_postamble; 891ff155a45SVasanthakumar Thiagarajan 89213ce3e99SLuis R. Rodriguez struct ar5416IniArray iniMac[ATH_INI_NUM_SPLIT]; 89313ce3e99SLuis R. Rodriguez struct ar5416IniArray iniBB[ATH_INI_NUM_SPLIT]; 89413ce3e99SLuis R. Rodriguez struct ar5416IniArray iniRadio[ATH_INI_NUM_SPLIT]; 89513ce3e99SLuis R. Rodriguez struct ar5416IniArray iniSOC[ATH_INI_NUM_SPLIT]; 89613ce3e99SLuis R. Rodriguez 897ff155a45SVasanthakumar Thiagarajan u32 intr_gen_timer_trigger; 898ff155a45SVasanthakumar Thiagarajan u32 intr_gen_timer_thresh; 899ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer_table hw_gen_timers; 900744d4025SVasanthakumar Thiagarajan 901744d4025SVasanthakumar Thiagarajan struct ar9003_txs *ts_ring; 902744d4025SVasanthakumar Thiagarajan u32 ts_paddr_start; 903744d4025SVasanthakumar Thiagarajan u32 ts_paddr_end; 904744d4025SVasanthakumar Thiagarajan u16 ts_tail; 905016c2177SRajkumar Manoharan u16 ts_size; 906aea702b7SLuis R. Rodriguez 907aea702b7SLuis R. Rodriguez u32 bb_watchdog_last_status; 908aea702b7SLuis R. Rodriguez u32 bb_watchdog_timeout_ms; /* in ms, 0 to disable */ 90951ac8cbbSRajkumar Manoharan u8 bb_hang_rx_ofdm; /* true if bb hang due to rx_ofdm */ 910717f6bedSFelix Fietkau 9111bf38661SFelix Fietkau unsigned int paprd_target_power; 9121bf38661SFelix Fietkau unsigned int paprd_training_power; 9137072bf62SVasanthakumar Thiagarajan unsigned int paprd_ratemask; 914f1a8abb0SFelix Fietkau unsigned int paprd_ratemask_ht40; 91545ef6a0bSVasanthakumar Thiagarajan bool paprd_table_write_done; 916717f6bedSFelix Fietkau u32 paprd_gain_table_entries[PAPRD_GAIN_TABLE_ENTRIES]; 917717f6bedSFelix Fietkau u8 paprd_gain_table_index[PAPRD_GAIN_TABLE_ENTRIES]; 9189a658d2bSLuis R. Rodriguez /* 9199a658d2bSLuis R. Rodriguez * Store the permanent value of Reg 0x4004in WARegVal 9209a658d2bSLuis R. Rodriguez * so we dont have to R/M/W. We should not be reading 9219a658d2bSLuis R. Rodriguez * this register when in sleep states. 9229a658d2bSLuis R. Rodriguez */ 9239a658d2bSLuis R. Rodriguez u32 WARegVal; 9246ee63f55SSenthil Balasubramanian 9256ee63f55SSenthil Balasubramanian /* Enterprise mode cap */ 9266ee63f55SSenthil Balasubramanian u32 ent_mode; 927f2f5f2a1SVasanthakumar Thiagarajan 928e60001e7SSujith Manoharan #ifdef CONFIG_ATH9K_WOW 92901c78533SMohammed Shafi Shajakhan u32 wow_event_mask; 93001c78533SMohammed Shafi Shajakhan #endif 931f2f5f2a1SVasanthakumar Thiagarajan bool is_clk_25mhz; 9323762561aSGabor Juhos int (*get_mac_revision)(void); 9337d95847cSGabor Juhos int (*external_reset)(void); 9343468968eSFelix Fietkau bool disable_2ghz; 9353468968eSFelix Fietkau bool disable_5ghz; 936ab5c4f71SGabor Juhos 937ab5c4f71SGabor Juhos const struct firmware *eeprom_blob; 938c774d57fSLorenzo Bianconi 939c774d57fSLorenzo Bianconi struct ath_dynack dynack; 940203c4805SLuis R. Rodriguez }; 941203c4805SLuis R. Rodriguez 9420cb9e06bSFelix Fietkau struct ath_bus_ops { 9430cb9e06bSFelix Fietkau enum ath_bus_type ath_bus_type; 9440cb9e06bSFelix Fietkau void (*read_cachesize)(struct ath_common *common, int *csz); 9450cb9e06bSFelix Fietkau bool (*eeprom_read)(struct ath_common *common, u32 off, u16 *data); 9460cb9e06bSFelix Fietkau void (*bt_coex_prep)(struct ath_common *common); 947d4930086SStanislaw Gruszka void (*aspm_init)(struct ath_common *common); 9480cb9e06bSFelix Fietkau }; 9490cb9e06bSFelix Fietkau 9509e4bffd2SLuis R. Rodriguez static inline struct ath_common *ath9k_hw_common(struct ath_hw *ah) 9519e4bffd2SLuis R. Rodriguez { 9529e4bffd2SLuis R. Rodriguez return &ah->common; 9539e4bffd2SLuis R. Rodriguez } 9549e4bffd2SLuis R. Rodriguez 9559e4bffd2SLuis R. Rodriguez static inline struct ath_regulatory *ath9k_hw_regulatory(struct ath_hw *ah) 9569e4bffd2SLuis R. Rodriguez { 9579e4bffd2SLuis R. Rodriguez return &(ath9k_hw_common(ah)->regulatory); 9589e4bffd2SLuis R. Rodriguez } 9599e4bffd2SLuis R. Rodriguez 960d70357d5SLuis R. Rodriguez static inline struct ath_hw_private_ops *ath9k_hw_private_ops(struct ath_hw *ah) 961d70357d5SLuis R. Rodriguez { 962d70357d5SLuis R. Rodriguez return &ah->private_ops; 963d70357d5SLuis R. Rodriguez } 964d70357d5SLuis R. Rodriguez 965d70357d5SLuis R. Rodriguez static inline struct ath_hw_ops *ath9k_hw_ops(struct ath_hw *ah) 966d70357d5SLuis R. Rodriguez { 967d70357d5SLuis R. Rodriguez return &ah->ops; 968d70357d5SLuis R. Rodriguez } 969d70357d5SLuis R. Rodriguez 970895ad7ebSVasanthakumar Thiagarajan static inline u8 get_streams(int mask) 971895ad7ebSVasanthakumar Thiagarajan { 972895ad7ebSVasanthakumar Thiagarajan return !!(mask & BIT(0)) + !!(mask & BIT(1)) + !!(mask & BIT(2)); 973895ad7ebSVasanthakumar Thiagarajan } 974895ad7ebSVasanthakumar Thiagarajan 975f637cfd6SLuis R. Rodriguez /* Initialization, Detach, Reset */ 976285f2ddaSSujith void ath9k_hw_deinit(struct ath_hw *ah); 977f637cfd6SLuis R. Rodriguez int ath9k_hw_init(struct ath_hw *ah); 978203c4805SLuis R. Rodriguez int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, 979caed6579SSujith Manoharan struct ath9k_hw_cal_data *caldata, bool fastcc); 980a9a29ce6SGabor Juhos int ath9k_hw_fill_cap_info(struct ath_hw *ah); 9818fe65368SLuis R. Rodriguez u32 ath9k_regd_get_ctl(struct ath_regulatory *reg, struct ath9k_channel *chan); 982203c4805SLuis R. Rodriguez 983203c4805SLuis R. Rodriguez /* GPIO / RFKILL / Antennae */ 984203c4805SLuis R. Rodriguez void ath9k_hw_cfg_gpio_input(struct ath_hw *ah, u32 gpio); 985203c4805SLuis R. Rodriguez u32 ath9k_hw_gpio_get(struct ath_hw *ah, u32 gpio); 986203c4805SLuis R. Rodriguez void ath9k_hw_cfg_output(struct ath_hw *ah, u32 gpio, 987203c4805SLuis R. Rodriguez u32 ah_signal_type); 988203c4805SLuis R. Rodriguez void ath9k_hw_set_gpio(struct ath_hw *ah, u32 gpio, u32 val); 989203c4805SLuis R. Rodriguez void ath9k_hw_setantenna(struct ath_hw *ah, u32 antenna); 990203c4805SLuis R. Rodriguez 991203c4805SLuis R. Rodriguez /* General Operation */ 9927c5adc8dSFelix Fietkau void ath9k_hw_synth_delay(struct ath_hw *ah, struct ath9k_channel *chan, 9937c5adc8dSFelix Fietkau int hw_delay); 994203c4805SLuis R. Rodriguez bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout); 9950166b4beSFelix Fietkau void ath9k_hw_write_array(struct ath_hw *ah, const struct ar5416IniArray *array, 996a9b6b256SFelix Fietkau int column, unsigned int *writecnt); 997203c4805SLuis R. Rodriguez u32 ath9k_hw_reverse_bits(u32 val, u32 n); 9984f0fc7c3SLuis R. Rodriguez u16 ath9k_hw_computetxtime(struct ath_hw *ah, 999545750d3SFelix Fietkau u8 phy, int kbps, 1000203c4805SLuis R. Rodriguez u32 frameLen, u16 rateix, bool shortPreamble); 1001203c4805SLuis R. Rodriguez void ath9k_hw_get_channel_centers(struct ath_hw *ah, 1002203c4805SLuis R. Rodriguez struct ath9k_channel *chan, 1003203c4805SLuis R. Rodriguez struct chan_centers *centers); 1004203c4805SLuis R. Rodriguez u32 ath9k_hw_getrxfilter(struct ath_hw *ah); 1005203c4805SLuis R. Rodriguez void ath9k_hw_setrxfilter(struct ath_hw *ah, u32 bits); 1006203c4805SLuis R. Rodriguez bool ath9k_hw_phy_disable(struct ath_hw *ah); 1007203c4805SLuis R. Rodriguez bool ath9k_hw_disable(struct ath_hw *ah); 1008de40f316SFelix Fietkau void ath9k_hw_set_txpowerlimit(struct ath_hw *ah, u32 limit, bool test); 1009203c4805SLuis R. Rodriguez void ath9k_hw_setopmode(struct ath_hw *ah); 1010203c4805SLuis R. Rodriguez void ath9k_hw_setmcastfilter(struct ath_hw *ah, u32 filter0, u32 filter1); 1011f2b2143eSLuis R. Rodriguez void ath9k_hw_write_associd(struct ath_hw *ah); 1012dd347f2fSFelix Fietkau u32 ath9k_hw_gettsf32(struct ath_hw *ah); 1013203c4805SLuis R. Rodriguez u64 ath9k_hw_gettsf64(struct ath_hw *ah); 1014203c4805SLuis R. Rodriguez void ath9k_hw_settsf64(struct ath_hw *ah, u64 tsf64); 1015203c4805SLuis R. Rodriguez void ath9k_hw_reset_tsf(struct ath_hw *ah); 10168d7e09ddSFelix Fietkau u32 ath9k_hw_get_tsf_offset(struct timespec *last, struct timespec *cur); 101760ca9f87SSujith Manoharan void ath9k_hw_set_tsfadjust(struct ath_hw *ah, bool set); 10180005baf4SFelix Fietkau void ath9k_hw_init_global_settings(struct ath_hw *ah); 1019b84628ebSSenthil Balasubramanian u32 ar9003_get_pll_sqsum_dvc(struct ath_hw *ah); 1020e4744ec7SFelix Fietkau void ath9k_hw_set11nmac2040(struct ath_hw *ah, struct ath9k_channel *chan); 1021203c4805SLuis R. Rodriguez void ath9k_hw_beaconinit(struct ath_hw *ah, u32 next_beacon, u32 beacon_period); 1022203c4805SLuis R. Rodriguez void ath9k_hw_set_sta_beacon_timers(struct ath_hw *ah, 1023203c4805SLuis R. Rodriguez const struct ath9k_beacon_state *bs); 10241e516ca7SSujith Manoharan void ath9k_hw_check_nav(struct ath_hw *ah); 1025c9c99e5eSFelix Fietkau bool ath9k_hw_check_alive(struct ath_hw *ah); 1026a91d75aeSLuis R. Rodriguez 10279ecdef4bSLuis R. Rodriguez bool ath9k_hw_setpower(struct ath_hw *ah, enum ath9k_power_mode mode); 1028a91d75aeSLuis R. Rodriguez 1029ff155a45SVasanthakumar Thiagarajan /* Generic hw timer primitives */ 1030ff155a45SVasanthakumar Thiagarajan struct ath_gen_timer *ath_gen_timer_alloc(struct ath_hw *ah, 1031ff155a45SVasanthakumar Thiagarajan void (*trigger)(void *), 1032ff155a45SVasanthakumar Thiagarajan void (*overflow)(void *), 1033ff155a45SVasanthakumar Thiagarajan void *arg, 1034ff155a45SVasanthakumar Thiagarajan u8 timer_index); 1035cd9bf689SLuis R. Rodriguez void ath9k_hw_gen_timer_start(struct ath_hw *ah, 1036cd9bf689SLuis R. Rodriguez struct ath_gen_timer *timer, 1037cd9bf689SLuis R. Rodriguez u32 timer_next, 1038cd9bf689SLuis R. Rodriguez u32 timer_period); 1039cd9bf689SLuis R. Rodriguez void ath9k_hw_gen_timer_stop(struct ath_hw *ah, struct ath_gen_timer *timer); 1040cd9bf689SLuis R. Rodriguez 1041ff155a45SVasanthakumar Thiagarajan void ath_gen_timer_free(struct ath_hw *ah, struct ath_gen_timer *timer); 1042ff155a45SVasanthakumar Thiagarajan void ath_gen_timer_isr(struct ath_hw *hw); 1043ff155a45SVasanthakumar Thiagarajan 1044f934c4d9SLuis R. Rodriguez void ath9k_hw_name(struct ath_hw *ah, char *hw_name, size_t len); 10452da4f01aSLuis R. Rodriguez 10468fe65368SLuis R. Rodriguez /* PHY */ 10478fe65368SLuis R. Rodriguez void ath9k_hw_get_delta_slope_vals(struct ath_hw *ah, u32 coef_scaled, 10488fe65368SLuis R. Rodriguez u32 *coef_mantissa, u32 *coef_exponent); 104964ea57d0SGabor Juhos void ath9k_hw_apply_txpower(struct ath_hw *ah, struct ath9k_channel *chan, 105064ea57d0SGabor Juhos bool test); 10518fe65368SLuis R. Rodriguez 1052ebd5a14aSLuis R. Rodriguez /* 1053ebd5a14aSLuis R. Rodriguez * Code Specific to AR5008, AR9001 or AR9002, 1054ebd5a14aSLuis R. Rodriguez * we stuff these here to avoid callbacks for AR9003. 1055ebd5a14aSLuis R. Rodriguez */ 1056ebd5a14aSLuis R. Rodriguez int ar9002_hw_rf_claim(struct ath_hw *ah); 105778ec2677SLuis R. Rodriguez void ar9002_hw_enable_async_fifo(struct ath_hw *ah); 1058d8f492b7SLuis R. Rodriguez 1059641d9921SFelix Fietkau /* 1060aea702b7SLuis R. Rodriguez * Code specific to AR9003, we stuff these here to avoid callbacks 1061641d9921SFelix Fietkau * for older families 1062641d9921SFelix Fietkau */ 1063d88527d3SSujith Manoharan bool ar9003_hw_bb_watchdog_check(struct ath_hw *ah); 1064aea702b7SLuis R. Rodriguez void ar9003_hw_bb_watchdog_config(struct ath_hw *ah); 1065aea702b7SLuis R. Rodriguez void ar9003_hw_bb_watchdog_read(struct ath_hw *ah); 1066aea702b7SLuis R. Rodriguez void ar9003_hw_bb_watchdog_dbg_info(struct ath_hw *ah); 106751ac8cbbSRajkumar Manoharan void ar9003_hw_disable_phy_restart(struct ath_hw *ah); 1068717f6bedSFelix Fietkau void ar9003_paprd_enable(struct ath_hw *ah, bool val); 1069717f6bedSFelix Fietkau void ar9003_paprd_populate_single_table(struct ath_hw *ah, 107020bd2a09SFelix Fietkau struct ath9k_hw_cal_data *caldata, 1071717f6bedSFelix Fietkau int chain); 107220bd2a09SFelix Fietkau int ar9003_paprd_create_curve(struct ath_hw *ah, 107320bd2a09SFelix Fietkau struct ath9k_hw_cal_data *caldata, int chain); 107436d2943bSSujith Manoharan void ar9003_paprd_setup_gain_table(struct ath_hw *ah, int chain); 1075717f6bedSFelix Fietkau int ar9003_paprd_init_table(struct ath_hw *ah); 1076717f6bedSFelix Fietkau bool ar9003_paprd_is_done(struct ath_hw *ah); 10770f21ee8dSSujith Manoharan bool ar9003_is_paprd_enabled(struct ath_hw *ah); 10784a8f1995SFelix Fietkau void ar9003_hw_set_chain_masks(struct ath_hw *ah, u8 rx, u8 tx); 1079641d9921SFelix Fietkau 1080641d9921SFelix Fietkau /* Hardware family op attach helpers */ 1081c1b976d2SFelix Fietkau int ar5008_hw_attach_phy_ops(struct ath_hw *ah); 10828525f280SLuis R. Rodriguez void ar9002_hw_attach_phy_ops(struct ath_hw *ah); 10838525f280SLuis R. Rodriguez void ar9003_hw_attach_phy_ops(struct ath_hw *ah); 10848fe65368SLuis R. Rodriguez 1085795f5e2cSLuis R. Rodriguez void ar9002_hw_attach_calib_ops(struct ath_hw *ah); 1086795f5e2cSLuis R. Rodriguez void ar9003_hw_attach_calib_ops(struct ath_hw *ah); 1087795f5e2cSLuis R. Rodriguez 1088c1b976d2SFelix Fietkau int ar9002_hw_attach_ops(struct ath_hw *ah); 1089b3950e6aSLuis R. Rodriguez void ar9003_hw_attach_ops(struct ath_hw *ah); 1090b3950e6aSLuis R. Rodriguez 1091c2ba3342SRajkumar Manoharan void ar9002_hw_load_ani_reg(struct ath_hw *ah, struct ath9k_channel *chan); 10926790ae7aSFelix Fietkau 10938eb4980cSFelix Fietkau void ath9k_ani_reset(struct ath_hw *ah, bool is_scanning); 109495792178SFelix Fietkau void ath9k_hw_ani_monitor(struct ath_hw *ah, struct ath9k_channel *chan); 1095ac0bb767SLuis R. Rodriguez 10968e15e094SLorenzo Bianconi void ath9k_hw_set_ack_timeout(struct ath_hw *ah, u32 us); 10978e15e094SLorenzo Bianconi void ath9k_hw_set_cts_timeout(struct ath_hw *ah, u32 us); 10988e15e094SLorenzo Bianconi void ath9k_hw_setslottime(struct ath_hw *ah, u32 us); 10998e15e094SLorenzo Bianconi 11008a309305SFelix Fietkau #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 1101dbccdd1dSSujith Manoharan static inline bool ath9k_hw_btcoex_is_enabled(struct ath_hw *ah) 1102dbccdd1dSSujith Manoharan { 1103dbccdd1dSSujith Manoharan return ah->btcoex_hw.enabled; 1104dbccdd1dSSujith Manoharan } 11055955b2b0SSujith Manoharan static inline bool ath9k_hw_mci_is_enabled(struct ath_hw *ah) 11065955b2b0SSujith Manoharan { 1107e1ecad78SRajkumar Manoharan return ah->common.btcoex_enabled && 1108e1ecad78SRajkumar Manoharan (ah->caps.hw_caps & ATH9K_HW_CAP_MCI); 11095955b2b0SSujith Manoharan 11105955b2b0SSujith Manoharan } 1111dbccdd1dSSujith Manoharan void ath9k_hw_btcoex_enable(struct ath_hw *ah); 11128a309305SFelix Fietkau static inline enum ath_btcoex_scheme 11138a309305SFelix Fietkau ath9k_hw_get_btcoex_scheme(struct ath_hw *ah) 11148a309305SFelix Fietkau { 11158a309305SFelix Fietkau return ah->btcoex_hw.scheme; 11168a309305SFelix Fietkau } 11178a309305SFelix Fietkau #else 1118dbccdd1dSSujith Manoharan static inline bool ath9k_hw_btcoex_is_enabled(struct ath_hw *ah) 1119dbccdd1dSSujith Manoharan { 1120dbccdd1dSSujith Manoharan return false; 1121dbccdd1dSSujith Manoharan } 11225955b2b0SSujith Manoharan static inline bool ath9k_hw_mci_is_enabled(struct ath_hw *ah) 11235955b2b0SSujith Manoharan { 11245955b2b0SSujith Manoharan return false; 11255955b2b0SSujith Manoharan } 1126dbccdd1dSSujith Manoharan static inline void ath9k_hw_btcoex_enable(struct ath_hw *ah) 1127dbccdd1dSSujith Manoharan { 1128dbccdd1dSSujith Manoharan } 1129dbccdd1dSSujith Manoharan static inline enum ath_btcoex_scheme 1130dbccdd1dSSujith Manoharan ath9k_hw_get_btcoex_scheme(struct ath_hw *ah) 1131dbccdd1dSSujith Manoharan { 1132dbccdd1dSSujith Manoharan return ATH_BTCOEX_CFG_NONE; 1133dbccdd1dSSujith Manoharan } 113464ab38dfSSujith Manoharan #endif /* CONFIG_ATH9K_BTCOEX_SUPPORT */ 11358a309305SFelix Fietkau 113664875c63SMohammed Shafi Shajakhan 1137e60001e7SSujith Manoharan #ifdef CONFIG_ATH9K_WOW 113864875c63SMohammed Shafi Shajakhan const char *ath9k_hw_wow_event_to_string(u32 wow_event); 113964875c63SMohammed Shafi Shajakhan void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, u8 *user_pattern, 114064875c63SMohammed Shafi Shajakhan u8 *user_mask, int pattern_count, 114164875c63SMohammed Shafi Shajakhan int pattern_len); 114264875c63SMohammed Shafi Shajakhan u32 ath9k_hw_wow_wakeup(struct ath_hw *ah); 114364875c63SMohammed Shafi Shajakhan void ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable); 114464875c63SMohammed Shafi Shajakhan #else 114564875c63SMohammed Shafi Shajakhan static inline const char *ath9k_hw_wow_event_to_string(u32 wow_event) 114664875c63SMohammed Shafi Shajakhan { 114764875c63SMohammed Shafi Shajakhan return NULL; 114864875c63SMohammed Shafi Shajakhan } 114964875c63SMohammed Shafi Shajakhan static inline void ath9k_hw_wow_apply_pattern(struct ath_hw *ah, 115064875c63SMohammed Shafi Shajakhan u8 *user_pattern, 115164875c63SMohammed Shafi Shajakhan u8 *user_mask, 115264875c63SMohammed Shafi Shajakhan int pattern_count, 115364875c63SMohammed Shafi Shajakhan int pattern_len) 115464875c63SMohammed Shafi Shajakhan { 115564875c63SMohammed Shafi Shajakhan } 115664875c63SMohammed Shafi Shajakhan static inline u32 ath9k_hw_wow_wakeup(struct ath_hw *ah) 115764875c63SMohammed Shafi Shajakhan { 115864875c63SMohammed Shafi Shajakhan return 0; 115964875c63SMohammed Shafi Shajakhan } 116064875c63SMohammed Shafi Shajakhan static inline void ath9k_hw_wow_enable(struct ath_hw *ah, u32 pattern_enable) 116164875c63SMohammed Shafi Shajakhan { 116264875c63SMohammed Shafi Shajakhan } 116364875c63SMohammed Shafi Shajakhan #endif 116464875c63SMohammed Shafi Shajakhan 116573377256SLuis R. Rodriguez #define ATH9K_CLOCK_RATE_CCK 22 116673377256SLuis R. Rodriguez #define ATH9K_CLOCK_RATE_5GHZ_OFDM 40 116773377256SLuis R. Rodriguez #define ATH9K_CLOCK_RATE_2GHZ_OFDM 44 116873377256SLuis R. Rodriguez #define ATH9K_CLOCK_FAST_RATE_5GHZ_OFDM 44 116973377256SLuis R. Rodriguez 1170203c4805SLuis R. Rodriguez #endif 1171