ar9285.c revision 217631
1203930Srpaulo/* 2203930Srpaulo * Copyright (c) 2008-2009 Sam Leffler, Errno Consulting 3203930Srpaulo * Copyright (c) 2008 Atheros Communications, Inc. 4203930Srpaulo * 5203930Srpaulo * Permission to use, copy, modify, and/or distribute this software for any 6203930Srpaulo * purpose with or without fee is hereby granted, provided that the above 7203930Srpaulo * copyright notice and this permission notice appear in all copies. 8203930Srpaulo * 9203930Srpaulo * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 10203930Srpaulo * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 11203930Srpaulo * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 12203930Srpaulo * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 13203930Srpaulo * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 14203930Srpaulo * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 15203930Srpaulo * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 16203930Srpaulo * 17203930Srpaulo * $FreeBSD: head/sys/dev/ath/ath_hal/ar9002/ar9285.c 217631 2011-01-20 09:03:40Z adrian $ 18203930Srpaulo */ 19203930Srpaulo#include "opt_ah.h" 20203930Srpaulo 21203930Srpaulo#include "ah.h" 22203930Srpaulo#include "ah_internal.h" 23203930Srpaulo 24203930Srpaulo#include "ah_eeprom_v14.h" 25203930Srpaulo 26217631Sadrian#include "ar9002/ar9280.h" 27217631Sadrian#include "ar9002/ar9285.h" 28203930Srpaulo#include "ar5416/ar5416reg.h" 29203930Srpaulo#include "ar5416/ar5416phy.h" 30203930Srpaulo 31203930Srpaulostatic void 32203930Srpauloar9285GetNoiseFloor(struct ath_hal *ah, int16_t nfarray[]) 33203930Srpaulo{ 34203930Srpaulo int16_t nf; 35203930Srpaulo 36203930Srpaulo nf = MS(OS_REG_READ(ah, AR_PHY_CCA), AR9280_PHY_MINCCA_PWR); 37203930Srpaulo if (nf & 0x100) 38203930Srpaulo nf = 0 - ((nf ^ 0x1ff) + 1); 39203930Srpaulo HALDEBUG(ah, HAL_DEBUG_NFCAL, 40203930Srpaulo "NF calibrated [ctl] [chain 0] is %d\n", nf); 41203930Srpaulo nfarray[0] = nf; 42203930Srpaulo 43203930Srpaulo nfarray[1] = 0; 44203930Srpaulo 45203930Srpaulo nf = MS(OS_REG_READ(ah, AR_PHY_EXT_CCA), AR9280_PHY_EXT_MINCCA_PWR); 46203930Srpaulo if (nf & 0x100) 47203930Srpaulo nf = 0 - ((nf ^ 0x1ff) + 1); 48203930Srpaulo HALDEBUG(ah, HAL_DEBUG_NFCAL, 49203930Srpaulo "NF calibrated [ext] [chain 0] is %d\n", nf); 50203930Srpaulo nfarray[3] = nf; 51203930Srpaulo 52203930Srpaulo nfarray[4] = 0; 53203930Srpaulo} 54203930Srpaulo 55203930SrpauloHAL_BOOL 56203930Srpauloar9285RfAttach(struct ath_hal *ah, HAL_STATUS *status) 57203930Srpaulo{ 58203930Srpaulo if (ar9280RfAttach(ah, status) == AH_FALSE) 59203930Srpaulo return AH_FALSE; 60203930Srpaulo 61203930Srpaulo AH_PRIVATE(ah)->ah_getNoiseFloor = ar9285GetNoiseFloor; 62203930Srpaulo 63203930Srpaulo return AH_TRUE; 64203930Srpaulo} 65