Path: blob/main/sys/dev/ath/ath_hal/ar9002/ar9285.c
39566 views
/*-1* SPDX-License-Identifier: ISC2*3* Copyright (c) 2008-2009 Sam Leffler, Errno Consulting4* Copyright (c) 2008 Atheros Communications, Inc.5*6* Permission to use, copy, modify, and/or distribute this software for any7* purpose with or without fee is hereby granted, provided that the above8* copyright notice and this permission notice appear in all copies.9*10* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES11* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF12* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR13* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES14* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN15* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF16* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.17*/18#include "opt_ah.h"1920#include "ah.h"21#include "ah_internal.h"2223#include "ah_eeprom_v14.h"2425#include "ar9002/ar9280.h"26#include "ar9002/ar9285.h"27#include "ar5416/ar5416reg.h"28#include "ar5416/ar5416phy.h"2930/*31* The ordering of nfarray is thus:32*33* nfarray[0]: Chain 0 ctl34* nfarray[1]: Chain 1 ctl35* nfarray[2]: Chain 2 ctl36* nfarray[3]: Chain 0 ext37* nfarray[4]: Chain 1 ext38* nfarray[5]: Chain 2 ext39*/40static void41ar9285GetNoiseFloor(struct ath_hal *ah, int16_t nfarray[])42{43int16_t nf;4445nf = MS(OS_REG_READ(ah, AR_PHY_CCA), AR9280_PHY_MINCCA_PWR);46if (nf & 0x100)47nf = 0 - ((nf ^ 0x1ff) + 1);48HALDEBUG(ah, HAL_DEBUG_NFCAL,49"NF calibrated [ctl] [chain 0] is %d\n", nf);50nfarray[0] = nf;5152nf = MS(OS_REG_READ(ah, AR_PHY_EXT_CCA), AR9280_PHY_EXT_MINCCA_PWR);53if (nf & 0x100)54nf = 0 - ((nf ^ 0x1ff) + 1);55HALDEBUG(ah, HAL_DEBUG_NFCAL,56"NF calibrated [ext] [chain 0] is %d\n", nf);57nfarray[3] = nf;5859/* Chain 1 - invalid */60nfarray[1] = 0;61nfarray[4] = 0;6263/* Chain 2 - invalid */64nfarray[2] = 0;65nfarray[5] = 0;66}6768HAL_BOOL69ar9285RfAttach(struct ath_hal *ah, HAL_STATUS *status)70{71if (ar9280RfAttach(ah, status) == AH_FALSE)72return AH_FALSE;7374AH_PRIVATE(ah)->ah_getNoiseFloor = ar9285GetNoiseFloor;7576return AH_TRUE;77}7879static HAL_BOOL80ar9285RfProbe(struct ath_hal *ah)81{82return (AR_SREV_KITE(ah));83}8485AH_RF(RF9285, ar9285RfProbe, ar9285RfAttach);868788