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