xref: /dflybsd-src/sys/dev/netif/ath/ath_hal/ar9002/ar9285.c (revision 572ff6f6e8b95055988f178b6ba12ce77bb5b3c2)
1*572ff6f6SMatthew Dillon /*
2*572ff6f6SMatthew Dillon  * Copyright (c) 2008-2009 Sam Leffler, Errno Consulting
3*572ff6f6SMatthew Dillon  * Copyright (c) 2008 Atheros Communications, Inc.
4*572ff6f6SMatthew Dillon  *
5*572ff6f6SMatthew Dillon  * Permission to use, copy, modify, and/or distribute this software for any
6*572ff6f6SMatthew Dillon  * purpose with or without fee is hereby granted, provided that the above
7*572ff6f6SMatthew Dillon  * copyright notice and this permission notice appear in all copies.
8*572ff6f6SMatthew Dillon  *
9*572ff6f6SMatthew Dillon  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*572ff6f6SMatthew Dillon  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*572ff6f6SMatthew Dillon  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*572ff6f6SMatthew Dillon  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*572ff6f6SMatthew Dillon  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*572ff6f6SMatthew Dillon  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*572ff6f6SMatthew Dillon  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*572ff6f6SMatthew Dillon  *
17*572ff6f6SMatthew Dillon  * $FreeBSD$
18*572ff6f6SMatthew Dillon  */
19*572ff6f6SMatthew Dillon #include "opt_ah.h"
20*572ff6f6SMatthew Dillon 
21*572ff6f6SMatthew Dillon #include "ah.h"
22*572ff6f6SMatthew Dillon #include "ah_internal.h"
23*572ff6f6SMatthew Dillon 
24*572ff6f6SMatthew Dillon #include "ah_eeprom_v14.h"
25*572ff6f6SMatthew Dillon 
26*572ff6f6SMatthew Dillon #include "ar9002/ar9280.h"
27*572ff6f6SMatthew Dillon #include "ar9002/ar9285.h"
28*572ff6f6SMatthew Dillon #include "ar5416/ar5416reg.h"
29*572ff6f6SMatthew Dillon #include "ar5416/ar5416phy.h"
30*572ff6f6SMatthew Dillon 
31*572ff6f6SMatthew Dillon /*
32*572ff6f6SMatthew Dillon  * The ordering of nfarray is thus:
33*572ff6f6SMatthew Dillon  *
34*572ff6f6SMatthew Dillon  * nfarray[0]: Chain 0 ctl
35*572ff6f6SMatthew Dillon  * nfarray[1]: Chain 1 ctl
36*572ff6f6SMatthew Dillon  * nfarray[2]: Chain 2 ctl
37*572ff6f6SMatthew Dillon  * nfarray[3]: Chain 0 ext
38*572ff6f6SMatthew Dillon  * nfarray[4]: Chain 1 ext
39*572ff6f6SMatthew Dillon  * nfarray[5]: Chain 2 ext
40*572ff6f6SMatthew Dillon  */
41*572ff6f6SMatthew Dillon static void
ar9285GetNoiseFloor(struct ath_hal * ah,int16_t nfarray[])42*572ff6f6SMatthew Dillon ar9285GetNoiseFloor(struct ath_hal *ah, int16_t nfarray[])
43*572ff6f6SMatthew Dillon {
44*572ff6f6SMatthew Dillon 	int16_t nf;
45*572ff6f6SMatthew Dillon 
46*572ff6f6SMatthew Dillon 	nf = MS(OS_REG_READ(ah, AR_PHY_CCA), AR9280_PHY_MINCCA_PWR);
47*572ff6f6SMatthew Dillon 	if (nf & 0x100)
48*572ff6f6SMatthew Dillon 		nf = 0 - ((nf ^ 0x1ff) + 1);
49*572ff6f6SMatthew Dillon 	HALDEBUG(ah, HAL_DEBUG_NFCAL,
50*572ff6f6SMatthew Dillon 	    "NF calibrated [ctl] [chain 0] is %d\n", nf);
51*572ff6f6SMatthew Dillon 	nfarray[0] = nf;
52*572ff6f6SMatthew Dillon 
53*572ff6f6SMatthew Dillon 
54*572ff6f6SMatthew Dillon 	nf = MS(OS_REG_READ(ah, AR_PHY_EXT_CCA), AR9280_PHY_EXT_MINCCA_PWR);
55*572ff6f6SMatthew Dillon 	if (nf & 0x100)
56*572ff6f6SMatthew Dillon 		nf = 0 - ((nf ^ 0x1ff) + 1);
57*572ff6f6SMatthew Dillon 	HALDEBUG(ah, HAL_DEBUG_NFCAL,
58*572ff6f6SMatthew Dillon 	    "NF calibrated [ext] [chain 0] is %d\n", nf);
59*572ff6f6SMatthew Dillon 	nfarray[3] = nf;
60*572ff6f6SMatthew Dillon 
61*572ff6f6SMatthew Dillon 	/* Chain 1 - invalid */
62*572ff6f6SMatthew Dillon 	nfarray[1] = 0;
63*572ff6f6SMatthew Dillon 	nfarray[4] = 0;
64*572ff6f6SMatthew Dillon 
65*572ff6f6SMatthew Dillon 	/* Chain 2 - invalid */
66*572ff6f6SMatthew Dillon 	nfarray[2] = 0;
67*572ff6f6SMatthew Dillon 	nfarray[5] = 0;
68*572ff6f6SMatthew Dillon }
69*572ff6f6SMatthew Dillon 
70*572ff6f6SMatthew Dillon HAL_BOOL
ar9285RfAttach(struct ath_hal * ah,HAL_STATUS * status)71*572ff6f6SMatthew Dillon ar9285RfAttach(struct ath_hal *ah, HAL_STATUS *status)
72*572ff6f6SMatthew Dillon {
73*572ff6f6SMatthew Dillon 	if (ar9280RfAttach(ah, status) == AH_FALSE)
74*572ff6f6SMatthew Dillon 		return AH_FALSE;
75*572ff6f6SMatthew Dillon 
76*572ff6f6SMatthew Dillon 	AH_PRIVATE(ah)->ah_getNoiseFloor = ar9285GetNoiseFloor;
77*572ff6f6SMatthew Dillon 
78*572ff6f6SMatthew Dillon 	return AH_TRUE;
79*572ff6f6SMatthew Dillon }
80*572ff6f6SMatthew Dillon 
81*572ff6f6SMatthew Dillon static HAL_BOOL
ar9285RfProbe(struct ath_hal * ah)82*572ff6f6SMatthew Dillon ar9285RfProbe(struct ath_hal *ah)
83*572ff6f6SMatthew Dillon {
84*572ff6f6SMatthew Dillon 	return (AR_SREV_KITE(ah));
85*572ff6f6SMatthew Dillon }
86*572ff6f6SMatthew Dillon 
87*572ff6f6SMatthew Dillon AH_RF(RF9285, ar9285RfProbe, ar9285RfAttach);
88