1*572ff6f6SMatthew Dillon /*
2*572ff6f6SMatthew Dillon * Copyright (c) 2008-2010 Atheros Communications Inc.
3*572ff6f6SMatthew Dillon * Copyright (c) 2011 Adrian Chadd, Xenion Pty Ltd.
4*572ff6f6SMatthew Dillon *
5*572ff6f6SMatthew Dillon * Redistribution and use in source and binary forms, with or without
6*572ff6f6SMatthew Dillon * modification, are permitted provided that the following conditions
7*572ff6f6SMatthew Dillon * are met:
8*572ff6f6SMatthew Dillon * 1. Redistributions of source code must retain the above copyright
9*572ff6f6SMatthew Dillon * notice, this list of conditions and the following disclaimer.
10*572ff6f6SMatthew Dillon * 2. Redistributions in binary form must reproduce the above copyright
11*572ff6f6SMatthew Dillon * notice, this list of conditions and the following disclaimer in the
12*572ff6f6SMatthew Dillon * documentation and/or other materials provided with the distribution.
13*572ff6f6SMatthew Dillon *
14*572ff6f6SMatthew Dillon * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15*572ff6f6SMatthew Dillon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16*572ff6f6SMatthew Dillon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17*572ff6f6SMatthew Dillon * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18*572ff6f6SMatthew Dillon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19*572ff6f6SMatthew Dillon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20*572ff6f6SMatthew Dillon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21*572ff6f6SMatthew Dillon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22*572ff6f6SMatthew Dillon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23*572ff6f6SMatthew Dillon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24*572ff6f6SMatthew Dillon * SUCH DAMAGE.
25*572ff6f6SMatthew Dillon *
26*572ff6f6SMatthew Dillon * $FreeBSD$
27*572ff6f6SMatthew Dillon */
28*572ff6f6SMatthew Dillon #include "opt_ah.h"
29*572ff6f6SMatthew Dillon #include "ah.h"
30*572ff6f6SMatthew Dillon #include "ah_internal.h"
31*572ff6f6SMatthew Dillon
32*572ff6f6SMatthew Dillon #include "ah_eeprom_v4k.h"
33*572ff6f6SMatthew Dillon
34*572ff6f6SMatthew Dillon #include "ar9002/ar9285.h"
35*572ff6f6SMatthew Dillon #include "ar5416/ar5416reg.h"
36*572ff6f6SMatthew Dillon #include "ar5416/ar5416phy.h"
37*572ff6f6SMatthew Dillon #include "ar9002/ar9002phy.h"
38*572ff6f6SMatthew Dillon //#include "ar9002/ar9287phy.h"
39*572ff6f6SMatthew Dillon
40*572ff6f6SMatthew Dillon #include "ar9002/ar9287_cal.h"
41*572ff6f6SMatthew Dillon
42*572ff6f6SMatthew Dillon
43*572ff6f6SMatthew Dillon void
ar9287PACal(struct ath_hal * ah,HAL_BOOL is_reset)44*572ff6f6SMatthew Dillon ar9287PACal(struct ath_hal *ah, HAL_BOOL is_reset)
45*572ff6f6SMatthew Dillon {
46*572ff6f6SMatthew Dillon /* XXX not required */
47*572ff6f6SMatthew Dillon }
48*572ff6f6SMatthew Dillon
49*572ff6f6SMatthew Dillon /*
50*572ff6f6SMatthew Dillon * This is like Merlin but without ADC disable
51*572ff6f6SMatthew Dillon */
52*572ff6f6SMatthew Dillon HAL_BOOL
ar9287InitCalHardware(struct ath_hal * ah,const struct ieee80211_channel * chan)53*572ff6f6SMatthew Dillon ar9287InitCalHardware(struct ath_hal *ah, const struct ieee80211_channel *chan)
54*572ff6f6SMatthew Dillon {
55*572ff6f6SMatthew Dillon OS_REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL);
56*572ff6f6SMatthew Dillon
57*572ff6f6SMatthew Dillon /* Calibrate the AGC */
58*572ff6f6SMatthew Dillon OS_REG_WRITE(ah, AR_PHY_AGC_CONTROL,
59*572ff6f6SMatthew Dillon OS_REG_READ(ah, AR_PHY_AGC_CONTROL) | AR_PHY_AGC_CONTROL_CAL);
60*572ff6f6SMatthew Dillon
61*572ff6f6SMatthew Dillon /* Poll for offset calibration complete */
62*572ff6f6SMatthew Dillon if (!ath_hal_wait(ah, AR_PHY_AGC_CONTROL,
63*572ff6f6SMatthew Dillon AR_PHY_AGC_CONTROL_CAL, 0)) {
64*572ff6f6SMatthew Dillon HALDEBUG(ah, HAL_DEBUG_RESET,
65*572ff6f6SMatthew Dillon "%s: offset calibration failed to complete in 1ms; "
66*572ff6f6SMatthew Dillon "noisy environment?\n", __func__);
67*572ff6f6SMatthew Dillon return AH_FALSE;
68*572ff6f6SMatthew Dillon }
69*572ff6f6SMatthew Dillon
70*572ff6f6SMatthew Dillon OS_REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL);
71*572ff6f6SMatthew Dillon
72*572ff6f6SMatthew Dillon return AH_TRUE;
73*572ff6f6SMatthew Dillon }
74