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