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