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