18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Copyright (c) 2008-2011 Atheros Communications Inc. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Permission to use, copy, modify, and/or distribute this software for any 58c2ecf20Sopenharmony_ci * purpose with or without fee is hereby granted, provided that the above 68c2ecf20Sopenharmony_ci * copyright notice and this permission notice appear in all copies. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 98c2ecf20Sopenharmony_ci * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 108c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 118c2ecf20Sopenharmony_ci * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 128c2ecf20Sopenharmony_ci * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 138c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 148c2ecf20Sopenharmony_ci * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci/** 188c2ecf20Sopenharmony_ci * DOC: Programming Atheros 802.11n analog front end radios 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * AR5416 MAC based PCI devices and AR518 MAC based PCI-Express 218c2ecf20Sopenharmony_ci * devices have either an external AR2133 analog front end radio for single 228c2ecf20Sopenharmony_ci * band 2.4 GHz communication or an AR5133 analog front end radio for dual 238c2ecf20Sopenharmony_ci * band 2.4 GHz / 5 GHz communication. 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * All devices after the AR5416 and AR5418 family starting with the AR9280 268c2ecf20Sopenharmony_ci * have their analog front radios, MAC/BB and host PCIe/USB interface embedded 278c2ecf20Sopenharmony_ci * into a single-chip and require less programming. 288c2ecf20Sopenharmony_ci * 298c2ecf20Sopenharmony_ci * The following single-chips exist with a respective embedded radio: 308c2ecf20Sopenharmony_ci * 318c2ecf20Sopenharmony_ci * AR9280 - 11n dual-band 2x2 MIMO for PCIe 328c2ecf20Sopenharmony_ci * AR9281 - 11n single-band 1x2 MIMO for PCIe 338c2ecf20Sopenharmony_ci * AR9285 - 11n single-band 1x1 for PCIe 348c2ecf20Sopenharmony_ci * AR9287 - 11n single-band 2x2 MIMO for PCIe 358c2ecf20Sopenharmony_ci * 368c2ecf20Sopenharmony_ci * AR9220 - 11n dual-band 2x2 MIMO for PCI 378c2ecf20Sopenharmony_ci * AR9223 - 11n single-band 2x2 MIMO for PCI 388c2ecf20Sopenharmony_ci * 398c2ecf20Sopenharmony_ci * AR9287 - 11n single-band 1x1 MIMO for USB 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci#include "hw.h" 438c2ecf20Sopenharmony_ci#include "ar9002_phy.h" 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/** 468c2ecf20Sopenharmony_ci * ar9002_hw_set_channel - set channel on single-chip device 478c2ecf20Sopenharmony_ci * @ah: atheros hardware structure 488c2ecf20Sopenharmony_ci * @chan: 498c2ecf20Sopenharmony_ci * 508c2ecf20Sopenharmony_ci * This is the function to change channel on single-chip devices, that is 518c2ecf20Sopenharmony_ci * all devices after ar9280. 528c2ecf20Sopenharmony_ci * 538c2ecf20Sopenharmony_ci * This function takes the channel value in MHz and sets 548c2ecf20Sopenharmony_ci * hardware channel value. Assumes writes have been enabled to analog bus. 558c2ecf20Sopenharmony_ci * 568c2ecf20Sopenharmony_ci * Actual Expression, 578c2ecf20Sopenharmony_ci * 588c2ecf20Sopenharmony_ci * For 2GHz channel, 598c2ecf20Sopenharmony_ci * Channel Frequency = (3/4) * freq_ref * (chansel[8:0] + chanfrac[16:0]/2^17) 608c2ecf20Sopenharmony_ci * (freq_ref = 40MHz) 618c2ecf20Sopenharmony_ci * 628c2ecf20Sopenharmony_ci * For 5GHz channel, 638c2ecf20Sopenharmony_ci * Channel Frequency = (3/2) * freq_ref * (chansel[8:0] + chanfrac[16:0]/2^10) 648c2ecf20Sopenharmony_ci * (freq_ref = 40MHz/(24>>amodeRefSel)) 658c2ecf20Sopenharmony_ci */ 668c2ecf20Sopenharmony_cistatic int ar9002_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan) 678c2ecf20Sopenharmony_ci{ 688c2ecf20Sopenharmony_ci u16 bMode, fracMode, aModeRefSel = 0; 698c2ecf20Sopenharmony_ci u32 freq, ndiv, channelSel = 0, channelFrac = 0, reg32 = 0; 708c2ecf20Sopenharmony_ci struct chan_centers centers; 718c2ecf20Sopenharmony_ci u32 refDivA = 24; 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci ath9k_hw_get_channel_centers(ah, chan, ¢ers); 748c2ecf20Sopenharmony_ci freq = centers.synth_center; 758c2ecf20Sopenharmony_ci 768c2ecf20Sopenharmony_ci reg32 = REG_READ(ah, AR_PHY_SYNTH_CONTROL); 778c2ecf20Sopenharmony_ci reg32 &= 0xc0000000; 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci if (freq < 4800) { /* 2 GHz, fractional mode */ 808c2ecf20Sopenharmony_ci u32 txctl; 818c2ecf20Sopenharmony_ci int regWrites = 0; 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci bMode = 1; 848c2ecf20Sopenharmony_ci fracMode = 1; 858c2ecf20Sopenharmony_ci aModeRefSel = 0; 868c2ecf20Sopenharmony_ci channelSel = CHANSEL_2G(freq); 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci if (AR_SREV_9287_11_OR_LATER(ah)) { 898c2ecf20Sopenharmony_ci if (freq == 2484) { 908c2ecf20Sopenharmony_ci /* Enable channel spreading for channel 14 */ 918c2ecf20Sopenharmony_ci REG_WRITE_ARRAY(&ah->iniCckfirJapan2484, 928c2ecf20Sopenharmony_ci 1, regWrites); 938c2ecf20Sopenharmony_ci } else { 948c2ecf20Sopenharmony_ci REG_WRITE_ARRAY(&ah->iniCckfirNormal, 958c2ecf20Sopenharmony_ci 1, regWrites); 968c2ecf20Sopenharmony_ci } 978c2ecf20Sopenharmony_ci } else { 988c2ecf20Sopenharmony_ci txctl = REG_READ(ah, AR_PHY_CCK_TX_CTRL); 998c2ecf20Sopenharmony_ci if (freq == 2484) { 1008c2ecf20Sopenharmony_ci /* Enable channel spreading for channel 14 */ 1018c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_CCK_TX_CTRL, 1028c2ecf20Sopenharmony_ci txctl | AR_PHY_CCK_TX_CTRL_JAPAN); 1038c2ecf20Sopenharmony_ci } else { 1048c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_CCK_TX_CTRL, 1058c2ecf20Sopenharmony_ci txctl & ~AR_PHY_CCK_TX_CTRL_JAPAN); 1068c2ecf20Sopenharmony_ci } 1078c2ecf20Sopenharmony_ci } 1088c2ecf20Sopenharmony_ci } else { 1098c2ecf20Sopenharmony_ci bMode = 0; 1108c2ecf20Sopenharmony_ci fracMode = 0; 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci switch (ah->eep_ops->get_eeprom(ah, EEP_FRAC_N_5G)) { 1138c2ecf20Sopenharmony_ci case 0: 1148c2ecf20Sopenharmony_ci if (IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan)) 1158c2ecf20Sopenharmony_ci aModeRefSel = 0; 1168c2ecf20Sopenharmony_ci else if ((freq % 20) == 0) 1178c2ecf20Sopenharmony_ci aModeRefSel = 3; 1188c2ecf20Sopenharmony_ci else if ((freq % 10) == 0) 1198c2ecf20Sopenharmony_ci aModeRefSel = 2; 1208c2ecf20Sopenharmony_ci if (aModeRefSel) 1218c2ecf20Sopenharmony_ci break; 1228c2ecf20Sopenharmony_ci fallthrough; 1238c2ecf20Sopenharmony_ci case 1: 1248c2ecf20Sopenharmony_ci default: 1258c2ecf20Sopenharmony_ci aModeRefSel = 0; 1268c2ecf20Sopenharmony_ci /* 1278c2ecf20Sopenharmony_ci * Enable 2G (fractional) mode for channels 1288c2ecf20Sopenharmony_ci * which are 5MHz spaced. 1298c2ecf20Sopenharmony_ci */ 1308c2ecf20Sopenharmony_ci fracMode = 1; 1318c2ecf20Sopenharmony_ci refDivA = 1; 1328c2ecf20Sopenharmony_ci channelSel = CHANSEL_5G(freq); 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci /* RefDivA setting */ 1358c2ecf20Sopenharmony_ci ath9k_hw_analog_shift_rmw(ah, AR_AN_SYNTH9, 1368c2ecf20Sopenharmony_ci AR_AN_SYNTH9_REFDIVA, 1378c2ecf20Sopenharmony_ci AR_AN_SYNTH9_REFDIVA_S, refDivA); 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci } 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci if (!fracMode) { 1428c2ecf20Sopenharmony_ci ndiv = (freq * (refDivA >> aModeRefSel)) / 60; 1438c2ecf20Sopenharmony_ci channelSel = ndiv & 0x1ff; 1448c2ecf20Sopenharmony_ci channelFrac = (ndiv & 0xfffffe00) * 2; 1458c2ecf20Sopenharmony_ci channelSel = (channelSel << 17) | channelFrac; 1468c2ecf20Sopenharmony_ci } 1478c2ecf20Sopenharmony_ci } 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci reg32 = reg32 | 1508c2ecf20Sopenharmony_ci (bMode << 29) | 1518c2ecf20Sopenharmony_ci (fracMode << 28) | (aModeRefSel << 26) | (channelSel); 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_SYNTH_CONTROL, reg32); 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci ah->curchan = chan; 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci return 0; 1588c2ecf20Sopenharmony_ci} 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci/** 1618c2ecf20Sopenharmony_ci * ar9002_hw_spur_mitigate - convert baseband spur frequency 1628c2ecf20Sopenharmony_ci * @ah: atheros hardware structure 1638c2ecf20Sopenharmony_ci * @chan: 1648c2ecf20Sopenharmony_ci * 1658c2ecf20Sopenharmony_ci * For single-chip solutions. Converts to baseband spur frequency given the 1668c2ecf20Sopenharmony_ci * input channel frequency and compute register settings below. 1678c2ecf20Sopenharmony_ci */ 1688c2ecf20Sopenharmony_cistatic void ar9002_hw_spur_mitigate(struct ath_hw *ah, 1698c2ecf20Sopenharmony_ci struct ath9k_channel *chan) 1708c2ecf20Sopenharmony_ci{ 1718c2ecf20Sopenharmony_ci int bb_spur = AR_NO_SPUR; 1728c2ecf20Sopenharmony_ci int freq; 1738c2ecf20Sopenharmony_ci int bin; 1748c2ecf20Sopenharmony_ci int bb_spur_off, spur_subchannel_sd; 1758c2ecf20Sopenharmony_ci int spur_freq_sd; 1768c2ecf20Sopenharmony_ci int spur_delta_phase; 1778c2ecf20Sopenharmony_ci int denominator; 1788c2ecf20Sopenharmony_ci int tmp, newVal; 1798c2ecf20Sopenharmony_ci int i; 1808c2ecf20Sopenharmony_ci struct chan_centers centers; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci int cur_bb_spur; 1838c2ecf20Sopenharmony_ci bool is2GHz = IS_CHAN_2GHZ(chan); 1848c2ecf20Sopenharmony_ci 1858c2ecf20Sopenharmony_ci ath9k_hw_get_channel_centers(ah, chan, ¢ers); 1868c2ecf20Sopenharmony_ci freq = centers.synth_center; 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) { 1898c2ecf20Sopenharmony_ci cur_bb_spur = ah->eep_ops->get_spur_channel(ah, i, is2GHz); 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci if (AR_NO_SPUR == cur_bb_spur) 1928c2ecf20Sopenharmony_ci break; 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci if (is2GHz) 1958c2ecf20Sopenharmony_ci cur_bb_spur = (cur_bb_spur / 10) + AR_BASE_FREQ_2GHZ; 1968c2ecf20Sopenharmony_ci else 1978c2ecf20Sopenharmony_ci cur_bb_spur = (cur_bb_spur / 10) + AR_BASE_FREQ_5GHZ; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci cur_bb_spur = cur_bb_spur - freq; 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci if (IS_CHAN_HT40(chan)) { 2028c2ecf20Sopenharmony_ci if ((cur_bb_spur > -AR_SPUR_FEEQ_BOUND_HT40) && 2038c2ecf20Sopenharmony_ci (cur_bb_spur < AR_SPUR_FEEQ_BOUND_HT40)) { 2048c2ecf20Sopenharmony_ci bb_spur = cur_bb_spur; 2058c2ecf20Sopenharmony_ci break; 2068c2ecf20Sopenharmony_ci } 2078c2ecf20Sopenharmony_ci } else if ((cur_bb_spur > -AR_SPUR_FEEQ_BOUND_HT20) && 2088c2ecf20Sopenharmony_ci (cur_bb_spur < AR_SPUR_FEEQ_BOUND_HT20)) { 2098c2ecf20Sopenharmony_ci bb_spur = cur_bb_spur; 2108c2ecf20Sopenharmony_ci break; 2118c2ecf20Sopenharmony_ci } 2128c2ecf20Sopenharmony_ci } 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci if (AR_NO_SPUR == bb_spur) { 2158c2ecf20Sopenharmony_ci REG_CLR_BIT(ah, AR_PHY_FORCE_CLKEN_CCK, 2168c2ecf20Sopenharmony_ci AR_PHY_FORCE_CLKEN_CCK_MRC_MUX); 2178c2ecf20Sopenharmony_ci return; 2188c2ecf20Sopenharmony_ci } else { 2198c2ecf20Sopenharmony_ci REG_CLR_BIT(ah, AR_PHY_FORCE_CLKEN_CCK, 2208c2ecf20Sopenharmony_ci AR_PHY_FORCE_CLKEN_CCK_MRC_MUX); 2218c2ecf20Sopenharmony_ci } 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci bin = bb_spur * 320; 2248c2ecf20Sopenharmony_ci 2258c2ecf20Sopenharmony_ci tmp = REG_READ(ah, AR_PHY_TIMING_CTRL4(0)); 2268c2ecf20Sopenharmony_ci 2278c2ecf20Sopenharmony_ci ENABLE_REGWRITE_BUFFER(ah); 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci newVal = tmp | (AR_PHY_TIMING_CTRL4_ENABLE_SPUR_RSSI | 2308c2ecf20Sopenharmony_ci AR_PHY_TIMING_CTRL4_ENABLE_SPUR_FILTER | 2318c2ecf20Sopenharmony_ci AR_PHY_TIMING_CTRL4_ENABLE_CHAN_MASK | 2328c2ecf20Sopenharmony_ci AR_PHY_TIMING_CTRL4_ENABLE_PILOT_MASK); 2338c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0), newVal); 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci newVal = (AR_PHY_SPUR_REG_MASK_RATE_CNTL | 2368c2ecf20Sopenharmony_ci AR_PHY_SPUR_REG_ENABLE_MASK_PPM | 2378c2ecf20Sopenharmony_ci AR_PHY_SPUR_REG_MASK_RATE_SELECT | 2388c2ecf20Sopenharmony_ci AR_PHY_SPUR_REG_ENABLE_VIT_SPUR_RSSI | 2398c2ecf20Sopenharmony_ci SM(SPUR_RSSI_THRESH, AR_PHY_SPUR_REG_SPUR_RSSI_THRESH)); 2408c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_SPUR_REG, newVal); 2418c2ecf20Sopenharmony_ci 2428c2ecf20Sopenharmony_ci if (IS_CHAN_HT40(chan)) { 2438c2ecf20Sopenharmony_ci if (bb_spur < 0) { 2448c2ecf20Sopenharmony_ci spur_subchannel_sd = 1; 2458c2ecf20Sopenharmony_ci bb_spur_off = bb_spur + 10; 2468c2ecf20Sopenharmony_ci } else { 2478c2ecf20Sopenharmony_ci spur_subchannel_sd = 0; 2488c2ecf20Sopenharmony_ci bb_spur_off = bb_spur - 10; 2498c2ecf20Sopenharmony_ci } 2508c2ecf20Sopenharmony_ci } else { 2518c2ecf20Sopenharmony_ci spur_subchannel_sd = 0; 2528c2ecf20Sopenharmony_ci bb_spur_off = bb_spur; 2538c2ecf20Sopenharmony_ci } 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci if (IS_CHAN_HT40(chan)) 2568c2ecf20Sopenharmony_ci spur_delta_phase = 2578c2ecf20Sopenharmony_ci ((bb_spur * 262144) / 2588c2ecf20Sopenharmony_ci 10) & AR_PHY_TIMING11_SPUR_DELTA_PHASE; 2598c2ecf20Sopenharmony_ci else 2608c2ecf20Sopenharmony_ci spur_delta_phase = 2618c2ecf20Sopenharmony_ci ((bb_spur * 524288) / 2628c2ecf20Sopenharmony_ci 10) & AR_PHY_TIMING11_SPUR_DELTA_PHASE; 2638c2ecf20Sopenharmony_ci 2648c2ecf20Sopenharmony_ci denominator = IS_CHAN_2GHZ(chan) ? 44 : 40; 2658c2ecf20Sopenharmony_ci spur_freq_sd = ((bb_spur_off * 2048) / denominator) & 0x3ff; 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci newVal = (AR_PHY_TIMING11_USE_SPUR_IN_AGC | 2688c2ecf20Sopenharmony_ci SM(spur_freq_sd, AR_PHY_TIMING11_SPUR_FREQ_SD) | 2698c2ecf20Sopenharmony_ci SM(spur_delta_phase, AR_PHY_TIMING11_SPUR_DELTA_PHASE)); 2708c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_TIMING11, newVal); 2718c2ecf20Sopenharmony_ci 2728c2ecf20Sopenharmony_ci newVal = spur_subchannel_sd << AR_PHY_SFCORR_SPUR_SUBCHNL_SD_S; 2738c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_SFCORR_EXT, newVal); 2748c2ecf20Sopenharmony_ci 2758c2ecf20Sopenharmony_ci ar5008_hw_cmn_spur_mitigate(ah, chan, bin); 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci REGWRITE_BUFFER_FLUSH(ah); 2788c2ecf20Sopenharmony_ci} 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_cistatic void ar9002_olc_init(struct ath_hw *ah) 2818c2ecf20Sopenharmony_ci{ 2828c2ecf20Sopenharmony_ci u32 i; 2838c2ecf20Sopenharmony_ci 2848c2ecf20Sopenharmony_ci if (!OLC_FOR_AR9280_20_LATER) 2858c2ecf20Sopenharmony_ci return; 2868c2ecf20Sopenharmony_ci 2878c2ecf20Sopenharmony_ci if (OLC_FOR_AR9287_10_LATER) { 2888c2ecf20Sopenharmony_ci REG_SET_BIT(ah, AR_PHY_TX_PWRCTRL9, 2898c2ecf20Sopenharmony_ci AR_PHY_TX_PWRCTRL9_RES_DC_REMOVAL); 2908c2ecf20Sopenharmony_ci ath9k_hw_analog_shift_rmw(ah, AR9287_AN_TXPC0, 2918c2ecf20Sopenharmony_ci AR9287_AN_TXPC0_TXPCMODE, 2928c2ecf20Sopenharmony_ci AR9287_AN_TXPC0_TXPCMODE_S, 2938c2ecf20Sopenharmony_ci AR9287_AN_TXPC0_TXPCMODE_TEMPSENSE); 2948c2ecf20Sopenharmony_ci udelay(100); 2958c2ecf20Sopenharmony_ci } else { 2968c2ecf20Sopenharmony_ci for (i = 0; i < AR9280_TX_GAIN_TABLE_SIZE; i++) 2978c2ecf20Sopenharmony_ci ah->originalGain[i] = 2988c2ecf20Sopenharmony_ci MS(REG_READ(ah, AR_PHY_TX_GAIN_TBL1 + i * 4), 2998c2ecf20Sopenharmony_ci AR_PHY_TX_GAIN); 3008c2ecf20Sopenharmony_ci ah->PDADCdelta = 0; 3018c2ecf20Sopenharmony_ci } 3028c2ecf20Sopenharmony_ci} 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_cistatic u32 ar9002_hw_compute_pll_control(struct ath_hw *ah, 3058c2ecf20Sopenharmony_ci struct ath9k_channel *chan) 3068c2ecf20Sopenharmony_ci{ 3078c2ecf20Sopenharmony_ci int ref_div = 5; 3088c2ecf20Sopenharmony_ci int pll_div = 0x2c; 3098c2ecf20Sopenharmony_ci u32 pll; 3108c2ecf20Sopenharmony_ci 3118c2ecf20Sopenharmony_ci if (chan && IS_CHAN_5GHZ(chan) && !IS_CHAN_A_FAST_CLOCK(ah, chan)) { 3128c2ecf20Sopenharmony_ci if (AR_SREV_9280_20(ah)) { 3138c2ecf20Sopenharmony_ci ref_div = 10; 3148c2ecf20Sopenharmony_ci pll_div = 0x50; 3158c2ecf20Sopenharmony_ci } else { 3168c2ecf20Sopenharmony_ci pll_div = 0x28; 3178c2ecf20Sopenharmony_ci } 3188c2ecf20Sopenharmony_ci } 3198c2ecf20Sopenharmony_ci 3208c2ecf20Sopenharmony_ci pll = SM(ref_div, AR_RTC_9160_PLL_REFDIV); 3218c2ecf20Sopenharmony_ci pll |= SM(pll_div, AR_RTC_9160_PLL_DIV); 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci if (chan && IS_CHAN_HALF_RATE(chan)) 3248c2ecf20Sopenharmony_ci pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL); 3258c2ecf20Sopenharmony_ci else if (chan && IS_CHAN_QUARTER_RATE(chan)) 3268c2ecf20Sopenharmony_ci pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL); 3278c2ecf20Sopenharmony_ci 3288c2ecf20Sopenharmony_ci return pll; 3298c2ecf20Sopenharmony_ci} 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_cistatic void ar9002_hw_do_getnf(struct ath_hw *ah, 3328c2ecf20Sopenharmony_ci int16_t nfarray[NUM_NF_READINGS]) 3338c2ecf20Sopenharmony_ci{ 3348c2ecf20Sopenharmony_ci int16_t nf; 3358c2ecf20Sopenharmony_ci 3368c2ecf20Sopenharmony_ci nf = MS(REG_READ(ah, AR_PHY_CCA), AR9280_PHY_MINCCA_PWR); 3378c2ecf20Sopenharmony_ci nfarray[0] = sign_extend32(nf, 8); 3388c2ecf20Sopenharmony_ci 3398c2ecf20Sopenharmony_ci nf = MS(REG_READ(ah, AR_PHY_EXT_CCA), AR9280_PHY_EXT_MINCCA_PWR); 3408c2ecf20Sopenharmony_ci if (IS_CHAN_HT40(ah->curchan)) 3418c2ecf20Sopenharmony_ci nfarray[3] = sign_extend32(nf, 8); 3428c2ecf20Sopenharmony_ci 3438c2ecf20Sopenharmony_ci if (!(ah->rxchainmask & BIT(1))) 3448c2ecf20Sopenharmony_ci return; 3458c2ecf20Sopenharmony_ci 3468c2ecf20Sopenharmony_ci nf = MS(REG_READ(ah, AR_PHY_CH1_CCA), AR9280_PHY_CH1_MINCCA_PWR); 3478c2ecf20Sopenharmony_ci nfarray[1] = sign_extend32(nf, 8); 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci nf = MS(REG_READ(ah, AR_PHY_CH1_EXT_CCA), AR9280_PHY_CH1_EXT_MINCCA_PWR); 3508c2ecf20Sopenharmony_ci if (IS_CHAN_HT40(ah->curchan)) 3518c2ecf20Sopenharmony_ci nfarray[4] = sign_extend32(nf, 8); 3528c2ecf20Sopenharmony_ci} 3538c2ecf20Sopenharmony_ci 3548c2ecf20Sopenharmony_cistatic void ar9002_hw_set_nf_limits(struct ath_hw *ah) 3558c2ecf20Sopenharmony_ci{ 3568c2ecf20Sopenharmony_ci if (AR_SREV_9285(ah)) { 3578c2ecf20Sopenharmony_ci ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9285_2GHZ; 3588c2ecf20Sopenharmony_ci ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9285_2GHZ; 3598c2ecf20Sopenharmony_ci ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9285_2GHZ; 3608c2ecf20Sopenharmony_ci } else if (AR_SREV_9287(ah)) { 3618c2ecf20Sopenharmony_ci ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9287_2GHZ; 3628c2ecf20Sopenharmony_ci ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9287_2GHZ; 3638c2ecf20Sopenharmony_ci ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9287_2GHZ; 3648c2ecf20Sopenharmony_ci } else if (AR_SREV_9271(ah)) { 3658c2ecf20Sopenharmony_ci ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9271_2GHZ; 3668c2ecf20Sopenharmony_ci ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9271_2GHZ; 3678c2ecf20Sopenharmony_ci ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9271_2GHZ; 3688c2ecf20Sopenharmony_ci } else { 3698c2ecf20Sopenharmony_ci ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9280_2GHZ; 3708c2ecf20Sopenharmony_ci ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9280_2GHZ; 3718c2ecf20Sopenharmony_ci ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9280_2GHZ; 3728c2ecf20Sopenharmony_ci ah->nf_5g.max = AR_PHY_CCA_MAX_GOOD_VAL_9280_5GHZ; 3738c2ecf20Sopenharmony_ci ah->nf_5g.min = AR_PHY_CCA_MIN_GOOD_VAL_9280_5GHZ; 3748c2ecf20Sopenharmony_ci ah->nf_5g.nominal = AR_PHY_CCA_NOM_VAL_9280_5GHZ; 3758c2ecf20Sopenharmony_ci } 3768c2ecf20Sopenharmony_ci} 3778c2ecf20Sopenharmony_ci 3788c2ecf20Sopenharmony_cistatic void ar9002_hw_antdiv_comb_conf_get(struct ath_hw *ah, 3798c2ecf20Sopenharmony_ci struct ath_hw_antcomb_conf *antconf) 3808c2ecf20Sopenharmony_ci{ 3818c2ecf20Sopenharmony_ci u32 regval; 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ci regval = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL); 3848c2ecf20Sopenharmony_ci antconf->main_lna_conf = (regval & AR_PHY_9285_ANT_DIV_MAIN_LNACONF) >> 3858c2ecf20Sopenharmony_ci AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S; 3868c2ecf20Sopenharmony_ci antconf->alt_lna_conf = (regval & AR_PHY_9285_ANT_DIV_ALT_LNACONF) >> 3878c2ecf20Sopenharmony_ci AR_PHY_9285_ANT_DIV_ALT_LNACONF_S; 3888c2ecf20Sopenharmony_ci antconf->fast_div_bias = (regval & AR_PHY_9285_FAST_DIV_BIAS) >> 3898c2ecf20Sopenharmony_ci AR_PHY_9285_FAST_DIV_BIAS_S; 3908c2ecf20Sopenharmony_ci antconf->lna1_lna2_switch_delta = -1; 3918c2ecf20Sopenharmony_ci antconf->lna1_lna2_delta = -3; 3928c2ecf20Sopenharmony_ci antconf->div_group = 0; 3938c2ecf20Sopenharmony_ci} 3948c2ecf20Sopenharmony_ci 3958c2ecf20Sopenharmony_cistatic void ar9002_hw_antdiv_comb_conf_set(struct ath_hw *ah, 3968c2ecf20Sopenharmony_ci struct ath_hw_antcomb_conf *antconf) 3978c2ecf20Sopenharmony_ci{ 3988c2ecf20Sopenharmony_ci u32 regval; 3998c2ecf20Sopenharmony_ci 4008c2ecf20Sopenharmony_ci regval = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL); 4018c2ecf20Sopenharmony_ci regval &= ~(AR_PHY_9285_ANT_DIV_MAIN_LNACONF | 4028c2ecf20Sopenharmony_ci AR_PHY_9285_ANT_DIV_ALT_LNACONF | 4038c2ecf20Sopenharmony_ci AR_PHY_9285_FAST_DIV_BIAS); 4048c2ecf20Sopenharmony_ci regval |= ((antconf->main_lna_conf << AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S) 4058c2ecf20Sopenharmony_ci & AR_PHY_9285_ANT_DIV_MAIN_LNACONF); 4068c2ecf20Sopenharmony_ci regval |= ((antconf->alt_lna_conf << AR_PHY_9285_ANT_DIV_ALT_LNACONF_S) 4078c2ecf20Sopenharmony_ci & AR_PHY_9285_ANT_DIV_ALT_LNACONF); 4088c2ecf20Sopenharmony_ci regval |= ((antconf->fast_div_bias << AR_PHY_9285_FAST_DIV_BIAS_S) 4098c2ecf20Sopenharmony_ci & AR_PHY_9285_FAST_DIV_BIAS); 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval); 4128c2ecf20Sopenharmony_ci} 4138c2ecf20Sopenharmony_ci 4148c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 4158c2ecf20Sopenharmony_ci 4168c2ecf20Sopenharmony_cistatic void ar9002_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable) 4178c2ecf20Sopenharmony_ci{ 4188c2ecf20Sopenharmony_ci struct ath_btcoex_hw *btcoex = &ah->btcoex_hw; 4198c2ecf20Sopenharmony_ci u8 antdiv_ctrl1, antdiv_ctrl2; 4208c2ecf20Sopenharmony_ci u32 regval; 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_ci if (enable) { 4238c2ecf20Sopenharmony_ci antdiv_ctrl1 = ATH_BT_COEX_ANTDIV_CONTROL1_ENABLE; 4248c2ecf20Sopenharmony_ci antdiv_ctrl2 = ATH_BT_COEX_ANTDIV_CONTROL2_ENABLE; 4258c2ecf20Sopenharmony_ci 4268c2ecf20Sopenharmony_ci /* 4278c2ecf20Sopenharmony_ci * Don't disable BT ant to allow BB to control SWCOM. 4288c2ecf20Sopenharmony_ci */ 4298c2ecf20Sopenharmony_ci btcoex->bt_coex_mode2 &= (~(AR_BT_DISABLE_BT_ANT)); 4308c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex->bt_coex_mode2); 4318c2ecf20Sopenharmony_ci 4328c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_SWITCH_COM, ATH_BT_COEX_ANT_DIV_SWITCH_COM); 4338c2ecf20Sopenharmony_ci REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0, 0, 0xf0000000); 4348c2ecf20Sopenharmony_ci } else { 4358c2ecf20Sopenharmony_ci /* 4368c2ecf20Sopenharmony_ci * Disable antenna diversity, use LNA1 only. 4378c2ecf20Sopenharmony_ci */ 4388c2ecf20Sopenharmony_ci antdiv_ctrl1 = ATH_BT_COEX_ANTDIV_CONTROL1_FIXED_A; 4398c2ecf20Sopenharmony_ci antdiv_ctrl2 = ATH_BT_COEX_ANTDIV_CONTROL2_FIXED_A; 4408c2ecf20Sopenharmony_ci 4418c2ecf20Sopenharmony_ci /* 4428c2ecf20Sopenharmony_ci * Disable BT Ant. to allow concurrent BT and WLAN receive. 4438c2ecf20Sopenharmony_ci */ 4448c2ecf20Sopenharmony_ci btcoex->bt_coex_mode2 |= AR_BT_DISABLE_BT_ANT; 4458c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex->bt_coex_mode2); 4468c2ecf20Sopenharmony_ci 4478c2ecf20Sopenharmony_ci /* 4488c2ecf20Sopenharmony_ci * Program SWCOM table to make sure RF switch always parks 4498c2ecf20Sopenharmony_ci * at BT side. 4508c2ecf20Sopenharmony_ci */ 4518c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_SWITCH_COM, 0); 4528c2ecf20Sopenharmony_ci REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0, 0, 0xf0000000); 4538c2ecf20Sopenharmony_ci } 4548c2ecf20Sopenharmony_ci 4558c2ecf20Sopenharmony_ci regval = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL); 4568c2ecf20Sopenharmony_ci regval &= (~(AR_PHY_9285_ANT_DIV_CTL_ALL)); 4578c2ecf20Sopenharmony_ci /* 4588c2ecf20Sopenharmony_ci * Clear ant_fast_div_bias [14:9] since for WB195, 4598c2ecf20Sopenharmony_ci * the main LNA is always LNA1. 4608c2ecf20Sopenharmony_ci */ 4618c2ecf20Sopenharmony_ci regval &= (~(AR_PHY_9285_FAST_DIV_BIAS)); 4628c2ecf20Sopenharmony_ci regval |= SM(antdiv_ctrl1, AR_PHY_9285_ANT_DIV_CTL); 4638c2ecf20Sopenharmony_ci regval |= SM(antdiv_ctrl2, AR_PHY_9285_ANT_DIV_ALT_LNACONF); 4648c2ecf20Sopenharmony_ci regval |= SM((antdiv_ctrl2 >> 2), AR_PHY_9285_ANT_DIV_MAIN_LNACONF); 4658c2ecf20Sopenharmony_ci regval |= SM((antdiv_ctrl1 >> 1), AR_PHY_9285_ANT_DIV_ALT_GAINTB); 4668c2ecf20Sopenharmony_ci regval |= SM((antdiv_ctrl1 >> 2), AR_PHY_9285_ANT_DIV_MAIN_GAINTB); 4678c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval); 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_ci regval = REG_READ(ah, AR_PHY_CCK_DETECT); 4708c2ecf20Sopenharmony_ci regval &= (~AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV); 4718c2ecf20Sopenharmony_ci regval |= SM((antdiv_ctrl1 >> 3), AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV); 4728c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_PHY_CCK_DETECT, regval); 4738c2ecf20Sopenharmony_ci} 4748c2ecf20Sopenharmony_ci 4758c2ecf20Sopenharmony_ci#endif 4768c2ecf20Sopenharmony_ci 4778c2ecf20Sopenharmony_cistatic void ar9002_hw_spectral_scan_config(struct ath_hw *ah, 4788c2ecf20Sopenharmony_ci struct ath_spec_scan *param) 4798c2ecf20Sopenharmony_ci{ 4808c2ecf20Sopenharmony_ci u32 repeat_bit; 4818c2ecf20Sopenharmony_ci u8 count; 4828c2ecf20Sopenharmony_ci 4838c2ecf20Sopenharmony_ci if (!param->enabled) { 4848c2ecf20Sopenharmony_ci REG_CLR_BIT(ah, AR_PHY_SPECTRAL_SCAN, 4858c2ecf20Sopenharmony_ci AR_PHY_SPECTRAL_SCAN_ENABLE); 4868c2ecf20Sopenharmony_ci return; 4878c2ecf20Sopenharmony_ci } 4888c2ecf20Sopenharmony_ci REG_SET_BIT(ah, AR_PHY_RADAR_0, AR_PHY_RADAR_0_FFT_ENA); 4898c2ecf20Sopenharmony_ci REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, AR_PHY_SPECTRAL_SCAN_ENABLE); 4908c2ecf20Sopenharmony_ci 4918c2ecf20Sopenharmony_ci if (AR_SREV_9280(ah)) 4928c2ecf20Sopenharmony_ci repeat_bit = AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT; 4938c2ecf20Sopenharmony_ci else 4948c2ecf20Sopenharmony_ci repeat_bit = AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT_KIWI; 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci if (param->short_repeat) 4978c2ecf20Sopenharmony_ci REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, repeat_bit); 4988c2ecf20Sopenharmony_ci else 4998c2ecf20Sopenharmony_ci REG_CLR_BIT(ah, AR_PHY_SPECTRAL_SCAN, repeat_bit); 5008c2ecf20Sopenharmony_ci 5018c2ecf20Sopenharmony_ci /* on AR92xx, the highest bit of count will make the the chip send 5028c2ecf20Sopenharmony_ci * spectral samples endlessly. Check if this really was intended, 5038c2ecf20Sopenharmony_ci * and fix otherwise. 5048c2ecf20Sopenharmony_ci */ 5058c2ecf20Sopenharmony_ci count = param->count; 5068c2ecf20Sopenharmony_ci if (param->endless) { 5078c2ecf20Sopenharmony_ci if (AR_SREV_9280(ah)) 5088c2ecf20Sopenharmony_ci count = 0x80; 5098c2ecf20Sopenharmony_ci else 5108c2ecf20Sopenharmony_ci count = 0; 5118c2ecf20Sopenharmony_ci } else if (count & 0x80) 5128c2ecf20Sopenharmony_ci count = 0x7f; 5138c2ecf20Sopenharmony_ci else if (!count) 5148c2ecf20Sopenharmony_ci count = 1; 5158c2ecf20Sopenharmony_ci 5168c2ecf20Sopenharmony_ci if (AR_SREV_9280(ah)) { 5178c2ecf20Sopenharmony_ci REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN, 5188c2ecf20Sopenharmony_ci AR_PHY_SPECTRAL_SCAN_COUNT, count); 5198c2ecf20Sopenharmony_ci } else { 5208c2ecf20Sopenharmony_ci REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN, 5218c2ecf20Sopenharmony_ci AR_PHY_SPECTRAL_SCAN_COUNT_KIWI, count); 5228c2ecf20Sopenharmony_ci REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, 5238c2ecf20Sopenharmony_ci AR_PHY_SPECTRAL_SCAN_PHYERR_MASK_SELECT); 5248c2ecf20Sopenharmony_ci } 5258c2ecf20Sopenharmony_ci 5268c2ecf20Sopenharmony_ci REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN, 5278c2ecf20Sopenharmony_ci AR_PHY_SPECTRAL_SCAN_PERIOD, param->period); 5288c2ecf20Sopenharmony_ci REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN, 5298c2ecf20Sopenharmony_ci AR_PHY_SPECTRAL_SCAN_FFT_PERIOD, param->fft_period); 5308c2ecf20Sopenharmony_ci 5318c2ecf20Sopenharmony_ci return; 5328c2ecf20Sopenharmony_ci} 5338c2ecf20Sopenharmony_ci 5348c2ecf20Sopenharmony_cistatic void ar9002_hw_spectral_scan_trigger(struct ath_hw *ah) 5358c2ecf20Sopenharmony_ci{ 5368c2ecf20Sopenharmony_ci REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, AR_PHY_SPECTRAL_SCAN_ENABLE); 5378c2ecf20Sopenharmony_ci /* Activate spectral scan */ 5388c2ecf20Sopenharmony_ci REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, 5398c2ecf20Sopenharmony_ci AR_PHY_SPECTRAL_SCAN_ACTIVE); 5408c2ecf20Sopenharmony_ci} 5418c2ecf20Sopenharmony_ci 5428c2ecf20Sopenharmony_cistatic void ar9002_hw_spectral_scan_wait(struct ath_hw *ah) 5438c2ecf20Sopenharmony_ci{ 5448c2ecf20Sopenharmony_ci struct ath_common *common = ath9k_hw_common(ah); 5458c2ecf20Sopenharmony_ci 5468c2ecf20Sopenharmony_ci /* Poll for spectral scan complete */ 5478c2ecf20Sopenharmony_ci if (!ath9k_hw_wait(ah, AR_PHY_SPECTRAL_SCAN, 5488c2ecf20Sopenharmony_ci AR_PHY_SPECTRAL_SCAN_ACTIVE, 5498c2ecf20Sopenharmony_ci 0, AH_WAIT_TIMEOUT)) { 5508c2ecf20Sopenharmony_ci ath_err(common, "spectral scan wait failed\n"); 5518c2ecf20Sopenharmony_ci return; 5528c2ecf20Sopenharmony_ci } 5538c2ecf20Sopenharmony_ci} 5548c2ecf20Sopenharmony_ci 5558c2ecf20Sopenharmony_cistatic void ar9002_hw_tx99_start(struct ath_hw *ah, u32 qnum) 5568c2ecf20Sopenharmony_ci{ 5578c2ecf20Sopenharmony_ci REG_SET_BIT(ah, 0x9864, 0x7f000); 5588c2ecf20Sopenharmony_ci REG_SET_BIT(ah, 0x9924, 0x7f00fe); 5598c2ecf20Sopenharmony_ci REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS); 5608c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_CR, AR_CR_RXD); 5618c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_DLCL_IFS(qnum), 0); 5628c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_D_GBL_IFS_SIFS, 20); 5638c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_D_GBL_IFS_EIFS, 20); 5648c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_D_FPCTL, 0x10|qnum); 5658c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_TIME_OUT, 0x00000400); 5668c2ecf20Sopenharmony_ci REG_WRITE(ah, AR_DRETRY_LIMIT(qnum), 0xffffffff); 5678c2ecf20Sopenharmony_ci REG_SET_BIT(ah, AR_QMISC(qnum), AR_Q_MISC_DCU_EARLY_TERM_REQ); 5688c2ecf20Sopenharmony_ci} 5698c2ecf20Sopenharmony_ci 5708c2ecf20Sopenharmony_cistatic void ar9002_hw_tx99_stop(struct ath_hw *ah) 5718c2ecf20Sopenharmony_ci{ 5728c2ecf20Sopenharmony_ci REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS); 5738c2ecf20Sopenharmony_ci} 5748c2ecf20Sopenharmony_ci 5758c2ecf20Sopenharmony_civoid ar9002_hw_attach_phy_ops(struct ath_hw *ah) 5768c2ecf20Sopenharmony_ci{ 5778c2ecf20Sopenharmony_ci struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah); 5788c2ecf20Sopenharmony_ci struct ath_hw_ops *ops = ath9k_hw_ops(ah); 5798c2ecf20Sopenharmony_ci 5808c2ecf20Sopenharmony_ci priv_ops->set_rf_regs = NULL; 5818c2ecf20Sopenharmony_ci priv_ops->rf_set_freq = ar9002_hw_set_channel; 5828c2ecf20Sopenharmony_ci priv_ops->spur_mitigate_freq = ar9002_hw_spur_mitigate; 5838c2ecf20Sopenharmony_ci priv_ops->olc_init = ar9002_olc_init; 5848c2ecf20Sopenharmony_ci priv_ops->compute_pll_control = ar9002_hw_compute_pll_control; 5858c2ecf20Sopenharmony_ci priv_ops->do_getnf = ar9002_hw_do_getnf; 5868c2ecf20Sopenharmony_ci 5878c2ecf20Sopenharmony_ci ops->antdiv_comb_conf_get = ar9002_hw_antdiv_comb_conf_get; 5888c2ecf20Sopenharmony_ci ops->antdiv_comb_conf_set = ar9002_hw_antdiv_comb_conf_set; 5898c2ecf20Sopenharmony_ci ops->spectral_scan_config = ar9002_hw_spectral_scan_config; 5908c2ecf20Sopenharmony_ci ops->spectral_scan_trigger = ar9002_hw_spectral_scan_trigger; 5918c2ecf20Sopenharmony_ci ops->spectral_scan_wait = ar9002_hw_spectral_scan_wait; 5928c2ecf20Sopenharmony_ci 5938c2ecf20Sopenharmony_ci#ifdef CONFIG_ATH9K_BTCOEX_SUPPORT 5948c2ecf20Sopenharmony_ci ops->set_bt_ant_diversity = ar9002_hw_set_bt_ant_diversity; 5958c2ecf20Sopenharmony_ci#endif 5968c2ecf20Sopenharmony_ci ops->tx99_start = ar9002_hw_tx99_start; 5978c2ecf20Sopenharmony_ci ops->tx99_stop = ar9002_hw_tx99_stop; 5988c2ecf20Sopenharmony_ci 5998c2ecf20Sopenharmony_ci ar9002_hw_set_nf_limits(ah); 6008c2ecf20Sopenharmony_ci} 601