xref: /OK3568_Linux_fs/kernel/drivers/net/wireless/ath/ath9k/ar9002_phy.c (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * Copyright (c) 2008-2011 Atheros Communications Inc.
3*4882a593Smuzhiyun  *
4*4882a593Smuzhiyun  * Permission to use, copy, modify, and/or distribute this software for any
5*4882a593Smuzhiyun  * purpose with or without fee is hereby granted, provided that the above
6*4882a593Smuzhiyun  * copyright notice and this permission notice appear in all copies.
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9*4882a593Smuzhiyun  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10*4882a593Smuzhiyun  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11*4882a593Smuzhiyun  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12*4882a593Smuzhiyun  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13*4882a593Smuzhiyun  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14*4882a593Smuzhiyun  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*4882a593Smuzhiyun  */
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun /**
18*4882a593Smuzhiyun  * DOC: Programming Atheros 802.11n analog front end radios
19*4882a593Smuzhiyun  *
20*4882a593Smuzhiyun  * AR5416 MAC based PCI devices and AR518 MAC based PCI-Express
21*4882a593Smuzhiyun  * devices have either an external AR2133 analog front end radio for single
22*4882a593Smuzhiyun  * band 2.4 GHz communication or an AR5133 analog front end radio for dual
23*4882a593Smuzhiyun  * band 2.4 GHz / 5 GHz communication.
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  * All devices after the AR5416 and AR5418 family starting with the AR9280
26*4882a593Smuzhiyun  * have their analog front radios, MAC/BB and host PCIe/USB interface embedded
27*4882a593Smuzhiyun  * into a single-chip and require less programming.
28*4882a593Smuzhiyun  *
29*4882a593Smuzhiyun  * The following single-chips exist with a respective embedded radio:
30*4882a593Smuzhiyun  *
31*4882a593Smuzhiyun  * AR9280 - 11n dual-band 2x2 MIMO for PCIe
32*4882a593Smuzhiyun  * AR9281 - 11n single-band 1x2 MIMO for PCIe
33*4882a593Smuzhiyun  * AR9285 - 11n single-band 1x1 for PCIe
34*4882a593Smuzhiyun  * AR9287 - 11n single-band 2x2 MIMO for PCIe
35*4882a593Smuzhiyun  *
36*4882a593Smuzhiyun  * AR9220 - 11n dual-band 2x2 MIMO for PCI
37*4882a593Smuzhiyun  * AR9223 - 11n single-band 2x2 MIMO for PCI
38*4882a593Smuzhiyun  *
39*4882a593Smuzhiyun  * AR9287 - 11n single-band 1x1 MIMO for USB
40*4882a593Smuzhiyun  */
41*4882a593Smuzhiyun 
42*4882a593Smuzhiyun #include "hw.h"
43*4882a593Smuzhiyun #include "ar9002_phy.h"
44*4882a593Smuzhiyun 
45*4882a593Smuzhiyun /**
46*4882a593Smuzhiyun  * ar9002_hw_set_channel - set channel on single-chip device
47*4882a593Smuzhiyun  * @ah: atheros hardware structure
48*4882a593Smuzhiyun  * @chan:
49*4882a593Smuzhiyun  *
50*4882a593Smuzhiyun  * This is the function to change channel on single-chip devices, that is
51*4882a593Smuzhiyun  * all devices after ar9280.
52*4882a593Smuzhiyun  *
53*4882a593Smuzhiyun  * This function takes the channel value in MHz and sets
54*4882a593Smuzhiyun  * hardware channel value. Assumes writes have been enabled to analog bus.
55*4882a593Smuzhiyun  *
56*4882a593Smuzhiyun  * Actual Expression,
57*4882a593Smuzhiyun  *
58*4882a593Smuzhiyun  * For 2GHz channel,
59*4882a593Smuzhiyun  * Channel Frequency = (3/4) * freq_ref * (chansel[8:0] + chanfrac[16:0]/2^17)
60*4882a593Smuzhiyun  * (freq_ref = 40MHz)
61*4882a593Smuzhiyun  *
62*4882a593Smuzhiyun  * For 5GHz channel,
63*4882a593Smuzhiyun  * Channel Frequency = (3/2) * freq_ref * (chansel[8:0] + chanfrac[16:0]/2^10)
64*4882a593Smuzhiyun  * (freq_ref = 40MHz/(24>>amodeRefSel))
65*4882a593Smuzhiyun  */
ar9002_hw_set_channel(struct ath_hw * ah,struct ath9k_channel * chan)66*4882a593Smuzhiyun static int ar9002_hw_set_channel(struct ath_hw *ah, struct ath9k_channel *chan)
67*4882a593Smuzhiyun {
68*4882a593Smuzhiyun 	u16 bMode, fracMode, aModeRefSel = 0;
69*4882a593Smuzhiyun 	u32 freq, ndiv, channelSel = 0, channelFrac = 0, reg32 = 0;
70*4882a593Smuzhiyun 	struct chan_centers centers;
71*4882a593Smuzhiyun 	u32 refDivA = 24;
72*4882a593Smuzhiyun 
73*4882a593Smuzhiyun 	ath9k_hw_get_channel_centers(ah, chan, &centers);
74*4882a593Smuzhiyun 	freq = centers.synth_center;
75*4882a593Smuzhiyun 
76*4882a593Smuzhiyun 	reg32 = REG_READ(ah, AR_PHY_SYNTH_CONTROL);
77*4882a593Smuzhiyun 	reg32 &= 0xc0000000;
78*4882a593Smuzhiyun 
79*4882a593Smuzhiyun 	if (freq < 4800) { /* 2 GHz, fractional mode */
80*4882a593Smuzhiyun 		u32 txctl;
81*4882a593Smuzhiyun 		int regWrites = 0;
82*4882a593Smuzhiyun 
83*4882a593Smuzhiyun 		bMode = 1;
84*4882a593Smuzhiyun 		fracMode = 1;
85*4882a593Smuzhiyun 		aModeRefSel = 0;
86*4882a593Smuzhiyun 		channelSel = CHANSEL_2G(freq);
87*4882a593Smuzhiyun 
88*4882a593Smuzhiyun 		if (AR_SREV_9287_11_OR_LATER(ah)) {
89*4882a593Smuzhiyun 			if (freq == 2484) {
90*4882a593Smuzhiyun 				/* Enable channel spreading for channel 14 */
91*4882a593Smuzhiyun 				REG_WRITE_ARRAY(&ah->iniCckfirJapan2484,
92*4882a593Smuzhiyun 						1, regWrites);
93*4882a593Smuzhiyun 			} else {
94*4882a593Smuzhiyun 				REG_WRITE_ARRAY(&ah->iniCckfirNormal,
95*4882a593Smuzhiyun 						1, regWrites);
96*4882a593Smuzhiyun 			}
97*4882a593Smuzhiyun 		} else {
98*4882a593Smuzhiyun 			txctl = REG_READ(ah, AR_PHY_CCK_TX_CTRL);
99*4882a593Smuzhiyun 			if (freq == 2484) {
100*4882a593Smuzhiyun 				/* Enable channel spreading for channel 14 */
101*4882a593Smuzhiyun 				REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
102*4882a593Smuzhiyun 					  txctl | AR_PHY_CCK_TX_CTRL_JAPAN);
103*4882a593Smuzhiyun 			} else {
104*4882a593Smuzhiyun 				REG_WRITE(ah, AR_PHY_CCK_TX_CTRL,
105*4882a593Smuzhiyun 					  txctl & ~AR_PHY_CCK_TX_CTRL_JAPAN);
106*4882a593Smuzhiyun 			}
107*4882a593Smuzhiyun 		}
108*4882a593Smuzhiyun 	} else {
109*4882a593Smuzhiyun 		bMode = 0;
110*4882a593Smuzhiyun 		fracMode = 0;
111*4882a593Smuzhiyun 
112*4882a593Smuzhiyun 		switch (ah->eep_ops->get_eeprom(ah, EEP_FRAC_N_5G)) {
113*4882a593Smuzhiyun 		case 0:
114*4882a593Smuzhiyun 			if (IS_CHAN_HALF_RATE(chan) || IS_CHAN_QUARTER_RATE(chan))
115*4882a593Smuzhiyun 				aModeRefSel = 0;
116*4882a593Smuzhiyun 			else if ((freq % 20) == 0)
117*4882a593Smuzhiyun 				aModeRefSel = 3;
118*4882a593Smuzhiyun 			else if ((freq % 10) == 0)
119*4882a593Smuzhiyun 				aModeRefSel = 2;
120*4882a593Smuzhiyun 			if (aModeRefSel)
121*4882a593Smuzhiyun 				break;
122*4882a593Smuzhiyun 			fallthrough;
123*4882a593Smuzhiyun 		case 1:
124*4882a593Smuzhiyun 		default:
125*4882a593Smuzhiyun 			aModeRefSel = 0;
126*4882a593Smuzhiyun 			/*
127*4882a593Smuzhiyun 			 * Enable 2G (fractional) mode for channels
128*4882a593Smuzhiyun 			 * which are 5MHz spaced.
129*4882a593Smuzhiyun 			 */
130*4882a593Smuzhiyun 			fracMode = 1;
131*4882a593Smuzhiyun 			refDivA = 1;
132*4882a593Smuzhiyun 			channelSel = CHANSEL_5G(freq);
133*4882a593Smuzhiyun 
134*4882a593Smuzhiyun 			/* RefDivA setting */
135*4882a593Smuzhiyun 			ath9k_hw_analog_shift_rmw(ah, AR_AN_SYNTH9,
136*4882a593Smuzhiyun 				      AR_AN_SYNTH9_REFDIVA,
137*4882a593Smuzhiyun 				      AR_AN_SYNTH9_REFDIVA_S, refDivA);
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun 		}
140*4882a593Smuzhiyun 
141*4882a593Smuzhiyun 		if (!fracMode) {
142*4882a593Smuzhiyun 			ndiv = (freq * (refDivA >> aModeRefSel)) / 60;
143*4882a593Smuzhiyun 			channelSel = ndiv & 0x1ff;
144*4882a593Smuzhiyun 			channelFrac = (ndiv & 0xfffffe00) * 2;
145*4882a593Smuzhiyun 			channelSel = (channelSel << 17) | channelFrac;
146*4882a593Smuzhiyun 		}
147*4882a593Smuzhiyun 	}
148*4882a593Smuzhiyun 
149*4882a593Smuzhiyun 	reg32 = reg32 |
150*4882a593Smuzhiyun 	    (bMode << 29) |
151*4882a593Smuzhiyun 	    (fracMode << 28) | (aModeRefSel << 26) | (channelSel);
152*4882a593Smuzhiyun 
153*4882a593Smuzhiyun 	REG_WRITE(ah, AR_PHY_SYNTH_CONTROL, reg32);
154*4882a593Smuzhiyun 
155*4882a593Smuzhiyun 	ah->curchan = chan;
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun 	return 0;
158*4882a593Smuzhiyun }
159*4882a593Smuzhiyun 
160*4882a593Smuzhiyun /**
161*4882a593Smuzhiyun  * ar9002_hw_spur_mitigate - convert baseband spur frequency
162*4882a593Smuzhiyun  * @ah: atheros hardware structure
163*4882a593Smuzhiyun  * @chan:
164*4882a593Smuzhiyun  *
165*4882a593Smuzhiyun  * For single-chip solutions. Converts to baseband spur frequency given the
166*4882a593Smuzhiyun  * input channel frequency and compute register settings below.
167*4882a593Smuzhiyun  */
ar9002_hw_spur_mitigate(struct ath_hw * ah,struct ath9k_channel * chan)168*4882a593Smuzhiyun static void ar9002_hw_spur_mitigate(struct ath_hw *ah,
169*4882a593Smuzhiyun 				    struct ath9k_channel *chan)
170*4882a593Smuzhiyun {
171*4882a593Smuzhiyun 	int bb_spur = AR_NO_SPUR;
172*4882a593Smuzhiyun 	int freq;
173*4882a593Smuzhiyun 	int bin;
174*4882a593Smuzhiyun 	int bb_spur_off, spur_subchannel_sd;
175*4882a593Smuzhiyun 	int spur_freq_sd;
176*4882a593Smuzhiyun 	int spur_delta_phase;
177*4882a593Smuzhiyun 	int denominator;
178*4882a593Smuzhiyun 	int tmp, newVal;
179*4882a593Smuzhiyun 	int i;
180*4882a593Smuzhiyun 	struct chan_centers centers;
181*4882a593Smuzhiyun 
182*4882a593Smuzhiyun 	int cur_bb_spur;
183*4882a593Smuzhiyun 	bool is2GHz = IS_CHAN_2GHZ(chan);
184*4882a593Smuzhiyun 
185*4882a593Smuzhiyun 	ath9k_hw_get_channel_centers(ah, chan, &centers);
186*4882a593Smuzhiyun 	freq = centers.synth_center;
187*4882a593Smuzhiyun 
188*4882a593Smuzhiyun 	for (i = 0; i < AR_EEPROM_MODAL_SPURS; i++) {
189*4882a593Smuzhiyun 		cur_bb_spur = ah->eep_ops->get_spur_channel(ah, i, is2GHz);
190*4882a593Smuzhiyun 
191*4882a593Smuzhiyun 		if (AR_NO_SPUR == cur_bb_spur)
192*4882a593Smuzhiyun 			break;
193*4882a593Smuzhiyun 
194*4882a593Smuzhiyun 		if (is2GHz)
195*4882a593Smuzhiyun 			cur_bb_spur = (cur_bb_spur / 10) + AR_BASE_FREQ_2GHZ;
196*4882a593Smuzhiyun 		else
197*4882a593Smuzhiyun 			cur_bb_spur = (cur_bb_spur / 10) + AR_BASE_FREQ_5GHZ;
198*4882a593Smuzhiyun 
199*4882a593Smuzhiyun 		cur_bb_spur = cur_bb_spur - freq;
200*4882a593Smuzhiyun 
201*4882a593Smuzhiyun 		if (IS_CHAN_HT40(chan)) {
202*4882a593Smuzhiyun 			if ((cur_bb_spur > -AR_SPUR_FEEQ_BOUND_HT40) &&
203*4882a593Smuzhiyun 			    (cur_bb_spur < AR_SPUR_FEEQ_BOUND_HT40)) {
204*4882a593Smuzhiyun 				bb_spur = cur_bb_spur;
205*4882a593Smuzhiyun 				break;
206*4882a593Smuzhiyun 			}
207*4882a593Smuzhiyun 		} else if ((cur_bb_spur > -AR_SPUR_FEEQ_BOUND_HT20) &&
208*4882a593Smuzhiyun 			   (cur_bb_spur < AR_SPUR_FEEQ_BOUND_HT20)) {
209*4882a593Smuzhiyun 			bb_spur = cur_bb_spur;
210*4882a593Smuzhiyun 			break;
211*4882a593Smuzhiyun 		}
212*4882a593Smuzhiyun 	}
213*4882a593Smuzhiyun 
214*4882a593Smuzhiyun 	if (AR_NO_SPUR == bb_spur) {
215*4882a593Smuzhiyun 		REG_CLR_BIT(ah, AR_PHY_FORCE_CLKEN_CCK,
216*4882a593Smuzhiyun 			    AR_PHY_FORCE_CLKEN_CCK_MRC_MUX);
217*4882a593Smuzhiyun 		return;
218*4882a593Smuzhiyun 	} else {
219*4882a593Smuzhiyun 		REG_CLR_BIT(ah, AR_PHY_FORCE_CLKEN_CCK,
220*4882a593Smuzhiyun 			    AR_PHY_FORCE_CLKEN_CCK_MRC_MUX);
221*4882a593Smuzhiyun 	}
222*4882a593Smuzhiyun 
223*4882a593Smuzhiyun 	bin = bb_spur * 320;
224*4882a593Smuzhiyun 
225*4882a593Smuzhiyun 	tmp = REG_READ(ah, AR_PHY_TIMING_CTRL4(0));
226*4882a593Smuzhiyun 
227*4882a593Smuzhiyun 	ENABLE_REGWRITE_BUFFER(ah);
228*4882a593Smuzhiyun 
229*4882a593Smuzhiyun 	newVal = tmp | (AR_PHY_TIMING_CTRL4_ENABLE_SPUR_RSSI |
230*4882a593Smuzhiyun 			AR_PHY_TIMING_CTRL4_ENABLE_SPUR_FILTER |
231*4882a593Smuzhiyun 			AR_PHY_TIMING_CTRL4_ENABLE_CHAN_MASK |
232*4882a593Smuzhiyun 			AR_PHY_TIMING_CTRL4_ENABLE_PILOT_MASK);
233*4882a593Smuzhiyun 	REG_WRITE(ah, AR_PHY_TIMING_CTRL4(0), newVal);
234*4882a593Smuzhiyun 
235*4882a593Smuzhiyun 	newVal = (AR_PHY_SPUR_REG_MASK_RATE_CNTL |
236*4882a593Smuzhiyun 		  AR_PHY_SPUR_REG_ENABLE_MASK_PPM |
237*4882a593Smuzhiyun 		  AR_PHY_SPUR_REG_MASK_RATE_SELECT |
238*4882a593Smuzhiyun 		  AR_PHY_SPUR_REG_ENABLE_VIT_SPUR_RSSI |
239*4882a593Smuzhiyun 		  SM(SPUR_RSSI_THRESH, AR_PHY_SPUR_REG_SPUR_RSSI_THRESH));
240*4882a593Smuzhiyun 	REG_WRITE(ah, AR_PHY_SPUR_REG, newVal);
241*4882a593Smuzhiyun 
242*4882a593Smuzhiyun 	if (IS_CHAN_HT40(chan)) {
243*4882a593Smuzhiyun 		if (bb_spur < 0) {
244*4882a593Smuzhiyun 			spur_subchannel_sd = 1;
245*4882a593Smuzhiyun 			bb_spur_off = bb_spur + 10;
246*4882a593Smuzhiyun 		} else {
247*4882a593Smuzhiyun 			spur_subchannel_sd = 0;
248*4882a593Smuzhiyun 			bb_spur_off = bb_spur - 10;
249*4882a593Smuzhiyun 		}
250*4882a593Smuzhiyun 	} else {
251*4882a593Smuzhiyun 		spur_subchannel_sd = 0;
252*4882a593Smuzhiyun 		bb_spur_off = bb_spur;
253*4882a593Smuzhiyun 	}
254*4882a593Smuzhiyun 
255*4882a593Smuzhiyun 	if (IS_CHAN_HT40(chan))
256*4882a593Smuzhiyun 		spur_delta_phase =
257*4882a593Smuzhiyun 			((bb_spur * 262144) /
258*4882a593Smuzhiyun 			 10) & AR_PHY_TIMING11_SPUR_DELTA_PHASE;
259*4882a593Smuzhiyun 	else
260*4882a593Smuzhiyun 		spur_delta_phase =
261*4882a593Smuzhiyun 			((bb_spur * 524288) /
262*4882a593Smuzhiyun 			 10) & AR_PHY_TIMING11_SPUR_DELTA_PHASE;
263*4882a593Smuzhiyun 
264*4882a593Smuzhiyun 	denominator = IS_CHAN_2GHZ(chan) ? 44 : 40;
265*4882a593Smuzhiyun 	spur_freq_sd = ((bb_spur_off * 2048) / denominator) & 0x3ff;
266*4882a593Smuzhiyun 
267*4882a593Smuzhiyun 	newVal = (AR_PHY_TIMING11_USE_SPUR_IN_AGC |
268*4882a593Smuzhiyun 		  SM(spur_freq_sd, AR_PHY_TIMING11_SPUR_FREQ_SD) |
269*4882a593Smuzhiyun 		  SM(spur_delta_phase, AR_PHY_TIMING11_SPUR_DELTA_PHASE));
270*4882a593Smuzhiyun 	REG_WRITE(ah, AR_PHY_TIMING11, newVal);
271*4882a593Smuzhiyun 
272*4882a593Smuzhiyun 	newVal = spur_subchannel_sd << AR_PHY_SFCORR_SPUR_SUBCHNL_SD_S;
273*4882a593Smuzhiyun 	REG_WRITE(ah, AR_PHY_SFCORR_EXT, newVal);
274*4882a593Smuzhiyun 
275*4882a593Smuzhiyun 	ar5008_hw_cmn_spur_mitigate(ah, chan, bin);
276*4882a593Smuzhiyun 
277*4882a593Smuzhiyun 	REGWRITE_BUFFER_FLUSH(ah);
278*4882a593Smuzhiyun }
279*4882a593Smuzhiyun 
ar9002_olc_init(struct ath_hw * ah)280*4882a593Smuzhiyun static void ar9002_olc_init(struct ath_hw *ah)
281*4882a593Smuzhiyun {
282*4882a593Smuzhiyun 	u32 i;
283*4882a593Smuzhiyun 
284*4882a593Smuzhiyun 	if (!OLC_FOR_AR9280_20_LATER)
285*4882a593Smuzhiyun 		return;
286*4882a593Smuzhiyun 
287*4882a593Smuzhiyun 	if (OLC_FOR_AR9287_10_LATER) {
288*4882a593Smuzhiyun 		REG_SET_BIT(ah, AR_PHY_TX_PWRCTRL9,
289*4882a593Smuzhiyun 				AR_PHY_TX_PWRCTRL9_RES_DC_REMOVAL);
290*4882a593Smuzhiyun 		ath9k_hw_analog_shift_rmw(ah, AR9287_AN_TXPC0,
291*4882a593Smuzhiyun 				AR9287_AN_TXPC0_TXPCMODE,
292*4882a593Smuzhiyun 				AR9287_AN_TXPC0_TXPCMODE_S,
293*4882a593Smuzhiyun 				AR9287_AN_TXPC0_TXPCMODE_TEMPSENSE);
294*4882a593Smuzhiyun 		udelay(100);
295*4882a593Smuzhiyun 	} else {
296*4882a593Smuzhiyun 		for (i = 0; i < AR9280_TX_GAIN_TABLE_SIZE; i++)
297*4882a593Smuzhiyun 			ah->originalGain[i] =
298*4882a593Smuzhiyun 				MS(REG_READ(ah, AR_PHY_TX_GAIN_TBL1 + i * 4),
299*4882a593Smuzhiyun 						AR_PHY_TX_GAIN);
300*4882a593Smuzhiyun 		ah->PDADCdelta = 0;
301*4882a593Smuzhiyun 	}
302*4882a593Smuzhiyun }
303*4882a593Smuzhiyun 
ar9002_hw_compute_pll_control(struct ath_hw * ah,struct ath9k_channel * chan)304*4882a593Smuzhiyun static u32 ar9002_hw_compute_pll_control(struct ath_hw *ah,
305*4882a593Smuzhiyun 					 struct ath9k_channel *chan)
306*4882a593Smuzhiyun {
307*4882a593Smuzhiyun 	int ref_div = 5;
308*4882a593Smuzhiyun 	int pll_div = 0x2c;
309*4882a593Smuzhiyun 	u32 pll;
310*4882a593Smuzhiyun 
311*4882a593Smuzhiyun 	if (chan && IS_CHAN_5GHZ(chan) && !IS_CHAN_A_FAST_CLOCK(ah, chan)) {
312*4882a593Smuzhiyun 		if (AR_SREV_9280_20(ah)) {
313*4882a593Smuzhiyun 			ref_div = 10;
314*4882a593Smuzhiyun 			pll_div = 0x50;
315*4882a593Smuzhiyun 		} else {
316*4882a593Smuzhiyun 			pll_div = 0x28;
317*4882a593Smuzhiyun 		}
318*4882a593Smuzhiyun 	}
319*4882a593Smuzhiyun 
320*4882a593Smuzhiyun 	pll = SM(ref_div, AR_RTC_9160_PLL_REFDIV);
321*4882a593Smuzhiyun 	pll |= SM(pll_div, AR_RTC_9160_PLL_DIV);
322*4882a593Smuzhiyun 
323*4882a593Smuzhiyun 	if (chan && IS_CHAN_HALF_RATE(chan))
324*4882a593Smuzhiyun 		pll |= SM(0x1, AR_RTC_9160_PLL_CLKSEL);
325*4882a593Smuzhiyun 	else if (chan && IS_CHAN_QUARTER_RATE(chan))
326*4882a593Smuzhiyun 		pll |= SM(0x2, AR_RTC_9160_PLL_CLKSEL);
327*4882a593Smuzhiyun 
328*4882a593Smuzhiyun 	return pll;
329*4882a593Smuzhiyun }
330*4882a593Smuzhiyun 
ar9002_hw_do_getnf(struct ath_hw * ah,int16_t nfarray[NUM_NF_READINGS])331*4882a593Smuzhiyun static void ar9002_hw_do_getnf(struct ath_hw *ah,
332*4882a593Smuzhiyun 			      int16_t nfarray[NUM_NF_READINGS])
333*4882a593Smuzhiyun {
334*4882a593Smuzhiyun 	int16_t nf;
335*4882a593Smuzhiyun 
336*4882a593Smuzhiyun 	nf = MS(REG_READ(ah, AR_PHY_CCA), AR9280_PHY_MINCCA_PWR);
337*4882a593Smuzhiyun 	nfarray[0] = sign_extend32(nf, 8);
338*4882a593Smuzhiyun 
339*4882a593Smuzhiyun 	nf = MS(REG_READ(ah, AR_PHY_EXT_CCA), AR9280_PHY_EXT_MINCCA_PWR);
340*4882a593Smuzhiyun 	if (IS_CHAN_HT40(ah->curchan))
341*4882a593Smuzhiyun 		nfarray[3] = sign_extend32(nf, 8);
342*4882a593Smuzhiyun 
343*4882a593Smuzhiyun 	if (!(ah->rxchainmask & BIT(1)))
344*4882a593Smuzhiyun 		return;
345*4882a593Smuzhiyun 
346*4882a593Smuzhiyun 	nf = MS(REG_READ(ah, AR_PHY_CH1_CCA), AR9280_PHY_CH1_MINCCA_PWR);
347*4882a593Smuzhiyun 	nfarray[1] = sign_extend32(nf, 8);
348*4882a593Smuzhiyun 
349*4882a593Smuzhiyun 	nf = MS(REG_READ(ah, AR_PHY_CH1_EXT_CCA), AR9280_PHY_CH1_EXT_MINCCA_PWR);
350*4882a593Smuzhiyun 	if (IS_CHAN_HT40(ah->curchan))
351*4882a593Smuzhiyun 		nfarray[4] = sign_extend32(nf, 8);
352*4882a593Smuzhiyun }
353*4882a593Smuzhiyun 
ar9002_hw_set_nf_limits(struct ath_hw * ah)354*4882a593Smuzhiyun static void ar9002_hw_set_nf_limits(struct ath_hw *ah)
355*4882a593Smuzhiyun {
356*4882a593Smuzhiyun 	if (AR_SREV_9285(ah)) {
357*4882a593Smuzhiyun 		ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9285_2GHZ;
358*4882a593Smuzhiyun 		ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9285_2GHZ;
359*4882a593Smuzhiyun 		ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9285_2GHZ;
360*4882a593Smuzhiyun 	} else if (AR_SREV_9287(ah)) {
361*4882a593Smuzhiyun 		ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9287_2GHZ;
362*4882a593Smuzhiyun 		ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9287_2GHZ;
363*4882a593Smuzhiyun 		ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9287_2GHZ;
364*4882a593Smuzhiyun 	} else if (AR_SREV_9271(ah)) {
365*4882a593Smuzhiyun 		ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9271_2GHZ;
366*4882a593Smuzhiyun 		ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9271_2GHZ;
367*4882a593Smuzhiyun 		ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9271_2GHZ;
368*4882a593Smuzhiyun 	} else {
369*4882a593Smuzhiyun 		ah->nf_2g.max = AR_PHY_CCA_MAX_GOOD_VAL_9280_2GHZ;
370*4882a593Smuzhiyun 		ah->nf_2g.min = AR_PHY_CCA_MIN_GOOD_VAL_9280_2GHZ;
371*4882a593Smuzhiyun 		ah->nf_2g.nominal = AR_PHY_CCA_NOM_VAL_9280_2GHZ;
372*4882a593Smuzhiyun 		ah->nf_5g.max = AR_PHY_CCA_MAX_GOOD_VAL_9280_5GHZ;
373*4882a593Smuzhiyun 		ah->nf_5g.min = AR_PHY_CCA_MIN_GOOD_VAL_9280_5GHZ;
374*4882a593Smuzhiyun 		ah->nf_5g.nominal = AR_PHY_CCA_NOM_VAL_9280_5GHZ;
375*4882a593Smuzhiyun 	}
376*4882a593Smuzhiyun }
377*4882a593Smuzhiyun 
ar9002_hw_antdiv_comb_conf_get(struct ath_hw * ah,struct ath_hw_antcomb_conf * antconf)378*4882a593Smuzhiyun static void ar9002_hw_antdiv_comb_conf_get(struct ath_hw *ah,
379*4882a593Smuzhiyun 				   struct ath_hw_antcomb_conf *antconf)
380*4882a593Smuzhiyun {
381*4882a593Smuzhiyun 	u32 regval;
382*4882a593Smuzhiyun 
383*4882a593Smuzhiyun 	regval = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL);
384*4882a593Smuzhiyun 	antconf->main_lna_conf = (regval & AR_PHY_9285_ANT_DIV_MAIN_LNACONF) >>
385*4882a593Smuzhiyun 				  AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S;
386*4882a593Smuzhiyun 	antconf->alt_lna_conf = (regval & AR_PHY_9285_ANT_DIV_ALT_LNACONF) >>
387*4882a593Smuzhiyun 				 AR_PHY_9285_ANT_DIV_ALT_LNACONF_S;
388*4882a593Smuzhiyun 	antconf->fast_div_bias = (regval & AR_PHY_9285_FAST_DIV_BIAS) >>
389*4882a593Smuzhiyun 				  AR_PHY_9285_FAST_DIV_BIAS_S;
390*4882a593Smuzhiyun 	antconf->lna1_lna2_switch_delta = -1;
391*4882a593Smuzhiyun 	antconf->lna1_lna2_delta = -3;
392*4882a593Smuzhiyun 	antconf->div_group = 0;
393*4882a593Smuzhiyun }
394*4882a593Smuzhiyun 
ar9002_hw_antdiv_comb_conf_set(struct ath_hw * ah,struct ath_hw_antcomb_conf * antconf)395*4882a593Smuzhiyun static void ar9002_hw_antdiv_comb_conf_set(struct ath_hw *ah,
396*4882a593Smuzhiyun 				   struct ath_hw_antcomb_conf *antconf)
397*4882a593Smuzhiyun {
398*4882a593Smuzhiyun 	u32 regval;
399*4882a593Smuzhiyun 
400*4882a593Smuzhiyun 	regval = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL);
401*4882a593Smuzhiyun 	regval &= ~(AR_PHY_9285_ANT_DIV_MAIN_LNACONF |
402*4882a593Smuzhiyun 		    AR_PHY_9285_ANT_DIV_ALT_LNACONF |
403*4882a593Smuzhiyun 		    AR_PHY_9285_FAST_DIV_BIAS);
404*4882a593Smuzhiyun 	regval |= ((antconf->main_lna_conf << AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S)
405*4882a593Smuzhiyun 		   & AR_PHY_9285_ANT_DIV_MAIN_LNACONF);
406*4882a593Smuzhiyun 	regval |= ((antconf->alt_lna_conf << AR_PHY_9285_ANT_DIV_ALT_LNACONF_S)
407*4882a593Smuzhiyun 		   & AR_PHY_9285_ANT_DIV_ALT_LNACONF);
408*4882a593Smuzhiyun 	regval |= ((antconf->fast_div_bias << AR_PHY_9285_FAST_DIV_BIAS_S)
409*4882a593Smuzhiyun 		   & AR_PHY_9285_FAST_DIV_BIAS);
410*4882a593Smuzhiyun 
411*4882a593Smuzhiyun 	REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval);
412*4882a593Smuzhiyun }
413*4882a593Smuzhiyun 
414*4882a593Smuzhiyun #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
415*4882a593Smuzhiyun 
ar9002_hw_set_bt_ant_diversity(struct ath_hw * ah,bool enable)416*4882a593Smuzhiyun static void ar9002_hw_set_bt_ant_diversity(struct ath_hw *ah, bool enable)
417*4882a593Smuzhiyun {
418*4882a593Smuzhiyun 	struct ath_btcoex_hw *btcoex = &ah->btcoex_hw;
419*4882a593Smuzhiyun 	u8 antdiv_ctrl1, antdiv_ctrl2;
420*4882a593Smuzhiyun 	u32 regval;
421*4882a593Smuzhiyun 
422*4882a593Smuzhiyun 	if (enable) {
423*4882a593Smuzhiyun 		antdiv_ctrl1 = ATH_BT_COEX_ANTDIV_CONTROL1_ENABLE;
424*4882a593Smuzhiyun 		antdiv_ctrl2 = ATH_BT_COEX_ANTDIV_CONTROL2_ENABLE;
425*4882a593Smuzhiyun 
426*4882a593Smuzhiyun 		/*
427*4882a593Smuzhiyun 		 * Don't disable BT ant to allow BB to control SWCOM.
428*4882a593Smuzhiyun 		 */
429*4882a593Smuzhiyun 		btcoex->bt_coex_mode2 &= (~(AR_BT_DISABLE_BT_ANT));
430*4882a593Smuzhiyun 		REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex->bt_coex_mode2);
431*4882a593Smuzhiyun 
432*4882a593Smuzhiyun 		REG_WRITE(ah, AR_PHY_SWITCH_COM, ATH_BT_COEX_ANT_DIV_SWITCH_COM);
433*4882a593Smuzhiyun 		REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0, 0, 0xf0000000);
434*4882a593Smuzhiyun 	} else {
435*4882a593Smuzhiyun 		/*
436*4882a593Smuzhiyun 		 * Disable antenna diversity, use LNA1 only.
437*4882a593Smuzhiyun 		 */
438*4882a593Smuzhiyun 		antdiv_ctrl1 = ATH_BT_COEX_ANTDIV_CONTROL1_FIXED_A;
439*4882a593Smuzhiyun 		antdiv_ctrl2 = ATH_BT_COEX_ANTDIV_CONTROL2_FIXED_A;
440*4882a593Smuzhiyun 
441*4882a593Smuzhiyun 		/*
442*4882a593Smuzhiyun 		 * Disable BT Ant. to allow concurrent BT and WLAN receive.
443*4882a593Smuzhiyun 		 */
444*4882a593Smuzhiyun 		btcoex->bt_coex_mode2 |= AR_BT_DISABLE_BT_ANT;
445*4882a593Smuzhiyun 		REG_WRITE(ah, AR_BT_COEX_MODE2, btcoex->bt_coex_mode2);
446*4882a593Smuzhiyun 
447*4882a593Smuzhiyun 		/*
448*4882a593Smuzhiyun 		 * Program SWCOM table to make sure RF switch always parks
449*4882a593Smuzhiyun 		 * at BT side.
450*4882a593Smuzhiyun 		 */
451*4882a593Smuzhiyun 		REG_WRITE(ah, AR_PHY_SWITCH_COM, 0);
452*4882a593Smuzhiyun 		REG_RMW(ah, AR_PHY_SWITCH_CHAIN_0, 0, 0xf0000000);
453*4882a593Smuzhiyun 	}
454*4882a593Smuzhiyun 
455*4882a593Smuzhiyun 	regval = REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL);
456*4882a593Smuzhiyun 	regval &= (~(AR_PHY_9285_ANT_DIV_CTL_ALL));
457*4882a593Smuzhiyun         /*
458*4882a593Smuzhiyun 	 * Clear ant_fast_div_bias [14:9] since for WB195,
459*4882a593Smuzhiyun 	 * the main LNA is always LNA1.
460*4882a593Smuzhiyun 	 */
461*4882a593Smuzhiyun 	regval &= (~(AR_PHY_9285_FAST_DIV_BIAS));
462*4882a593Smuzhiyun 	regval |= SM(antdiv_ctrl1, AR_PHY_9285_ANT_DIV_CTL);
463*4882a593Smuzhiyun 	regval |= SM(antdiv_ctrl2, AR_PHY_9285_ANT_DIV_ALT_LNACONF);
464*4882a593Smuzhiyun 	regval |= SM((antdiv_ctrl2 >> 2), AR_PHY_9285_ANT_DIV_MAIN_LNACONF);
465*4882a593Smuzhiyun 	regval |= SM((antdiv_ctrl1 >> 1), AR_PHY_9285_ANT_DIV_ALT_GAINTB);
466*4882a593Smuzhiyun 	regval |= SM((antdiv_ctrl1 >> 2), AR_PHY_9285_ANT_DIV_MAIN_GAINTB);
467*4882a593Smuzhiyun 	REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval);
468*4882a593Smuzhiyun 
469*4882a593Smuzhiyun 	regval = REG_READ(ah, AR_PHY_CCK_DETECT);
470*4882a593Smuzhiyun 	regval &= (~AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
471*4882a593Smuzhiyun 	regval |= SM((antdiv_ctrl1 >> 3), AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV);
472*4882a593Smuzhiyun 	REG_WRITE(ah, AR_PHY_CCK_DETECT, regval);
473*4882a593Smuzhiyun }
474*4882a593Smuzhiyun 
475*4882a593Smuzhiyun #endif
476*4882a593Smuzhiyun 
ar9002_hw_spectral_scan_config(struct ath_hw * ah,struct ath_spec_scan * param)477*4882a593Smuzhiyun static void ar9002_hw_spectral_scan_config(struct ath_hw *ah,
478*4882a593Smuzhiyun 				    struct ath_spec_scan *param)
479*4882a593Smuzhiyun {
480*4882a593Smuzhiyun 	u32 repeat_bit;
481*4882a593Smuzhiyun 	u8 count;
482*4882a593Smuzhiyun 
483*4882a593Smuzhiyun 	if (!param->enabled) {
484*4882a593Smuzhiyun 		REG_CLR_BIT(ah, AR_PHY_SPECTRAL_SCAN,
485*4882a593Smuzhiyun 			    AR_PHY_SPECTRAL_SCAN_ENABLE);
486*4882a593Smuzhiyun 		return;
487*4882a593Smuzhiyun 	}
488*4882a593Smuzhiyun 	REG_SET_BIT(ah, AR_PHY_RADAR_0, AR_PHY_RADAR_0_FFT_ENA);
489*4882a593Smuzhiyun 	REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, AR_PHY_SPECTRAL_SCAN_ENABLE);
490*4882a593Smuzhiyun 
491*4882a593Smuzhiyun 	if (AR_SREV_9280(ah))
492*4882a593Smuzhiyun 		repeat_bit = AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT;
493*4882a593Smuzhiyun 	else
494*4882a593Smuzhiyun 		repeat_bit = AR_PHY_SPECTRAL_SCAN_SHORT_REPEAT_KIWI;
495*4882a593Smuzhiyun 
496*4882a593Smuzhiyun 	if (param->short_repeat)
497*4882a593Smuzhiyun 		REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, repeat_bit);
498*4882a593Smuzhiyun 	else
499*4882a593Smuzhiyun 		REG_CLR_BIT(ah, AR_PHY_SPECTRAL_SCAN, repeat_bit);
500*4882a593Smuzhiyun 
501*4882a593Smuzhiyun 	/* on AR92xx, the highest bit of count will make the the chip send
502*4882a593Smuzhiyun 	 * spectral samples endlessly. Check if this really was intended,
503*4882a593Smuzhiyun 	 * and fix otherwise.
504*4882a593Smuzhiyun 	 */
505*4882a593Smuzhiyun 	count = param->count;
506*4882a593Smuzhiyun 	if (param->endless) {
507*4882a593Smuzhiyun 		if (AR_SREV_9280(ah))
508*4882a593Smuzhiyun 			count = 0x80;
509*4882a593Smuzhiyun 		else
510*4882a593Smuzhiyun 			count = 0;
511*4882a593Smuzhiyun 	} else if (count & 0x80)
512*4882a593Smuzhiyun 		count = 0x7f;
513*4882a593Smuzhiyun 	else if (!count)
514*4882a593Smuzhiyun 		count = 1;
515*4882a593Smuzhiyun 
516*4882a593Smuzhiyun 	if (AR_SREV_9280(ah)) {
517*4882a593Smuzhiyun 		REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
518*4882a593Smuzhiyun 			      AR_PHY_SPECTRAL_SCAN_COUNT, count);
519*4882a593Smuzhiyun 	} else {
520*4882a593Smuzhiyun 		REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
521*4882a593Smuzhiyun 			      AR_PHY_SPECTRAL_SCAN_COUNT_KIWI, count);
522*4882a593Smuzhiyun 		REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN,
523*4882a593Smuzhiyun 			    AR_PHY_SPECTRAL_SCAN_PHYERR_MASK_SELECT);
524*4882a593Smuzhiyun 	}
525*4882a593Smuzhiyun 
526*4882a593Smuzhiyun 	REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
527*4882a593Smuzhiyun 		      AR_PHY_SPECTRAL_SCAN_PERIOD, param->period);
528*4882a593Smuzhiyun 	REG_RMW_FIELD(ah, AR_PHY_SPECTRAL_SCAN,
529*4882a593Smuzhiyun 		      AR_PHY_SPECTRAL_SCAN_FFT_PERIOD, param->fft_period);
530*4882a593Smuzhiyun 
531*4882a593Smuzhiyun 	return;
532*4882a593Smuzhiyun }
533*4882a593Smuzhiyun 
ar9002_hw_spectral_scan_trigger(struct ath_hw * ah)534*4882a593Smuzhiyun static void ar9002_hw_spectral_scan_trigger(struct ath_hw *ah)
535*4882a593Smuzhiyun {
536*4882a593Smuzhiyun 	REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN, AR_PHY_SPECTRAL_SCAN_ENABLE);
537*4882a593Smuzhiyun 	/* Activate spectral scan */
538*4882a593Smuzhiyun 	REG_SET_BIT(ah, AR_PHY_SPECTRAL_SCAN,
539*4882a593Smuzhiyun 		    AR_PHY_SPECTRAL_SCAN_ACTIVE);
540*4882a593Smuzhiyun }
541*4882a593Smuzhiyun 
ar9002_hw_spectral_scan_wait(struct ath_hw * ah)542*4882a593Smuzhiyun static void ar9002_hw_spectral_scan_wait(struct ath_hw *ah)
543*4882a593Smuzhiyun {
544*4882a593Smuzhiyun 	struct ath_common *common = ath9k_hw_common(ah);
545*4882a593Smuzhiyun 
546*4882a593Smuzhiyun 	/* Poll for spectral scan complete */
547*4882a593Smuzhiyun 	if (!ath9k_hw_wait(ah, AR_PHY_SPECTRAL_SCAN,
548*4882a593Smuzhiyun 			   AR_PHY_SPECTRAL_SCAN_ACTIVE,
549*4882a593Smuzhiyun 			   0, AH_WAIT_TIMEOUT)) {
550*4882a593Smuzhiyun 		ath_err(common, "spectral scan wait failed\n");
551*4882a593Smuzhiyun 		return;
552*4882a593Smuzhiyun 	}
553*4882a593Smuzhiyun }
554*4882a593Smuzhiyun 
ar9002_hw_tx99_start(struct ath_hw * ah,u32 qnum)555*4882a593Smuzhiyun static void ar9002_hw_tx99_start(struct ath_hw *ah, u32 qnum)
556*4882a593Smuzhiyun {
557*4882a593Smuzhiyun 	REG_SET_BIT(ah, 0x9864, 0x7f000);
558*4882a593Smuzhiyun 	REG_SET_BIT(ah, 0x9924, 0x7f00fe);
559*4882a593Smuzhiyun 	REG_CLR_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
560*4882a593Smuzhiyun 	REG_WRITE(ah, AR_CR, AR_CR_RXD);
561*4882a593Smuzhiyun 	REG_WRITE(ah, AR_DLCL_IFS(qnum), 0);
562*4882a593Smuzhiyun 	REG_WRITE(ah, AR_D_GBL_IFS_SIFS, 20);
563*4882a593Smuzhiyun 	REG_WRITE(ah, AR_D_GBL_IFS_EIFS, 20);
564*4882a593Smuzhiyun 	REG_WRITE(ah, AR_D_FPCTL, 0x10|qnum);
565*4882a593Smuzhiyun 	REG_WRITE(ah, AR_TIME_OUT, 0x00000400);
566*4882a593Smuzhiyun 	REG_WRITE(ah, AR_DRETRY_LIMIT(qnum), 0xffffffff);
567*4882a593Smuzhiyun 	REG_SET_BIT(ah, AR_QMISC(qnum), AR_Q_MISC_DCU_EARLY_TERM_REQ);
568*4882a593Smuzhiyun }
569*4882a593Smuzhiyun 
ar9002_hw_tx99_stop(struct ath_hw * ah)570*4882a593Smuzhiyun static void ar9002_hw_tx99_stop(struct ath_hw *ah)
571*4882a593Smuzhiyun {
572*4882a593Smuzhiyun 	REG_SET_BIT(ah, AR_DIAG_SW, AR_DIAG_RX_DIS);
573*4882a593Smuzhiyun }
574*4882a593Smuzhiyun 
ar9002_hw_attach_phy_ops(struct ath_hw * ah)575*4882a593Smuzhiyun void ar9002_hw_attach_phy_ops(struct ath_hw *ah)
576*4882a593Smuzhiyun {
577*4882a593Smuzhiyun 	struct ath_hw_private_ops *priv_ops = ath9k_hw_private_ops(ah);
578*4882a593Smuzhiyun 	struct ath_hw_ops *ops = ath9k_hw_ops(ah);
579*4882a593Smuzhiyun 
580*4882a593Smuzhiyun 	priv_ops->set_rf_regs = NULL;
581*4882a593Smuzhiyun 	priv_ops->rf_set_freq = ar9002_hw_set_channel;
582*4882a593Smuzhiyun 	priv_ops->spur_mitigate_freq = ar9002_hw_spur_mitigate;
583*4882a593Smuzhiyun 	priv_ops->olc_init = ar9002_olc_init;
584*4882a593Smuzhiyun 	priv_ops->compute_pll_control = ar9002_hw_compute_pll_control;
585*4882a593Smuzhiyun 	priv_ops->do_getnf = ar9002_hw_do_getnf;
586*4882a593Smuzhiyun 
587*4882a593Smuzhiyun 	ops->antdiv_comb_conf_get = ar9002_hw_antdiv_comb_conf_get;
588*4882a593Smuzhiyun 	ops->antdiv_comb_conf_set = ar9002_hw_antdiv_comb_conf_set;
589*4882a593Smuzhiyun 	ops->spectral_scan_config = ar9002_hw_spectral_scan_config;
590*4882a593Smuzhiyun 	ops->spectral_scan_trigger = ar9002_hw_spectral_scan_trigger;
591*4882a593Smuzhiyun 	ops->spectral_scan_wait = ar9002_hw_spectral_scan_wait;
592*4882a593Smuzhiyun 
593*4882a593Smuzhiyun #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
594*4882a593Smuzhiyun 	ops->set_bt_ant_diversity = ar9002_hw_set_bt_ant_diversity;
595*4882a593Smuzhiyun #endif
596*4882a593Smuzhiyun 	ops->tx99_start = ar9002_hw_tx99_start;
597*4882a593Smuzhiyun 	ops->tx99_stop = ar9002_hw_tx99_stop;
598*4882a593Smuzhiyun 
599*4882a593Smuzhiyun 	ar9002_hw_set_nf_limits(ah);
600*4882a593Smuzhiyun }
601