From owner-svn-src-all@FreeBSD.ORG Wed Apr 13 02:40:45 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE0601065676; Wed, 13 Apr 2011 02:40:45 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A9FD68FC1B; Wed, 13 Apr 2011 02:40:45 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3D2ejc3042746; Wed, 13 Apr 2011 02:40:45 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3D2ejqg042741; Wed, 13 Apr 2011 02:40:45 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201104130240.p3D2ejqg042741@svn.freebsd.org> From: Adrian Chadd Date: Wed, 13 Apr 2011 02:40:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220587 - in head/sys: conf dev/ath/ath_hal/ar9002 modules/ath X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Apr 2011 02:40:45 -0000 Author: adrian Date: Wed Apr 13 02:40:45 2011 New Revision: 220587 URL: http://svn.freebsd.org/changeset/base/220587 Log: Add the initial AR9285 PHY glue for supporting antenna diversity. This code isn't currently used anywhere; it's just linked into the build. Added: head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.c (contents, props changed) head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.h (contents, props changed) Modified: head/sys/conf/files head/sys/modules/ath/Makefile Modified: head/sys/conf/files ============================================================================== --- head/sys/conf/files Wed Apr 13 00:36:19 2011 (r220586) +++ head/sys/conf/files Wed Apr 13 02:40:45 2011 (r220587) @@ -773,6 +773,8 @@ dev/ath/ath_hal/ar9002/ar9285_reset.c op compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" dev/ath/ath_hal/ar9002/ar9285_cal.c optional ath_hal | ath_ar9285 \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" +dev/ath/ath_hal/ar9002/ar9285_phy.c optional ath_hal | ath_ar9285 \ + compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" # rf backends dev/ath/ath_hal/ar5212/ar2316.c optional ath_rf2316 \ compile-with "${NORMAL_C} -I$S/dev/ath -I$S/dev/ath/ath_hal" Added: head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.c Wed Apr 13 02:40:45 2011 (r220587) @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2008-2010 Atheros Communications Inc. + * Copyright (c) 2010-2011 Adrian Chadd, Xenion Pty Ltd. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ +#include "opt_ah.h" + +#include "ah.h" +#include "ah_internal.h" +#include "ah_devid.h" +#include "ah_eeprom_v4k.h" + +#include "ar9002/ar9280.h" +#include "ar9002/ar9285.h" +#include "ar5416/ar5416reg.h" +#include "ar5416/ar5416phy.h" +#include "ar9002/ar9285phy.h" +#include "ar9002/ar9285_phy.h" + +void +ar9285_antdiv_comb_conf_get(struct ath_hal *ah, + struct ar9285_antcomb_conf *antconf) +{ + uint32_t regval; + + regval = OS_REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL); + antconf->main_lna_conf = (regval & AR_PHY_9285_ANT_DIV_MAIN_LNACONF) >> + AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S; + antconf->alt_lna_conf = (regval & AR_PHY_9285_ANT_DIV_ALT_LNACONF) >> + AR_PHY_9285_ANT_DIV_ALT_LNACONF_S; + antconf->fast_div_bias = (regval & AR_PHY_9285_FAST_DIV_BIAS) >> + AR_PHY_9285_FAST_DIV_BIAS_S; +} + +void +ar9285_antdiv_comb_conf_set(struct ath_hal *ah, + struct ar9285_antcomb_conf *antconf) +{ + uint32_t regval; + + regval = OS_REG_READ(ah, AR_PHY_MULTICHAIN_GAIN_CTL); + regval &= ~(AR_PHY_9285_ANT_DIV_MAIN_LNACONF | + AR_PHY_9285_ANT_DIV_ALT_LNACONF | + AR_PHY_9285_FAST_DIV_BIAS); + regval |= ((antconf->main_lna_conf << AR_PHY_9285_ANT_DIV_MAIN_LNACONF_S) + & AR_PHY_9285_ANT_DIV_MAIN_LNACONF); + regval |= ((antconf->alt_lna_conf << AR_PHY_9285_ANT_DIV_ALT_LNACONF_S) + & AR_PHY_9285_ANT_DIV_ALT_LNACONF); + regval |= ((antconf->fast_div_bias << AR_PHY_9285_FAST_DIV_BIAS_S) + & AR_PHY_9285_FAST_DIV_BIAS); + + OS_REG_WRITE(ah, AR_PHY_MULTICHAIN_GAIN_CTL, regval); +} + +/* + * Check whether antenna diversity should be enabled + */ +int +ar9285_check_div_comb(struct ath_hal *ah) +{ + uint8_t ant_div_ctl1; + HAL_EEPROM_v4k *ee = AH_PRIVATE(ah)->ah_eeprom; + const MODAL_EEP4K_HEADER *pModal = &ee->ee_base.modalHeader; + + if (! AR_SREV_KITE(ah)) + return 0; + + if (pModal->version < 3) + return 0; + + ant_div_ctl1 = pModal->antdiv_ctl1; + if ((ant_div_ctl1 & 0x1) && ((ant_div_ctl1 >> 3) & 0x1)) + return 1; + + return 0; +} Added: head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/ath/ath_hal/ar9002/ar9285_phy.h Wed Apr 13 02:40:45 2011 (r220587) @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2008-2010 Atheros Communications Inc. + * Copyright (c) 2010-2011 Adrian Chadd, Xenion Pty Ltd. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ +#ifndef __AR9285_PHY_H__ +#define __AR9285_PHY_H__ + +/* + * Manipulate AR9285 antenna diversity configuration + */ +struct ar9285_antcomb_conf { + uint8_t main_lna_conf; + uint8_t alt_lna_conf; + uint8_t fast_div_bias; +}; + +extern void ar9285_antdiv_comb_conf_set(struct ath_hal *ah, + struct ar9285_antcomb_conf *antconf); +extern void ar9285_antdiv_comb_conf_get(struct ath_hal *ah, + struct ar9285_antcomb_conf *antconf); +extern int ar9285_check_div_comb(struct ath_hal *ah); + +#endif Modified: head/sys/modules/ath/Makefile ============================================================================== --- head/sys/modules/ath/Makefile Wed Apr 13 00:36:19 2011 (r220586) +++ head/sys/modules/ath/Makefile Wed Apr 13 02:40:45 2011 (r220587) @@ -98,7 +98,7 @@ SRCS+= ar9160_attach.c .PATH: ${.CURDIR}/../../dev/ath/ath_hal/ar9002 SRCS+= ar9280.c ar9280_attach.c ar9280_olc.c -SRCS+= ar9285.c ar9285_reset.c ar9285_attach.c ar9285_cal.c +SRCS+= ar9285.c ar9285_reset.c ar9285_attach.c ar9285_cal.c ar9285_phy.c # NB: rate control is bound to the driver by symbol names so only pick one .if ${ATH_RATE} == "sample"