From owner-svn-src-all@FreeBSD.ORG Wed Jan 26 10:36:43 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 8268C106564A; Wed, 26 Jan 2011 10:36:43 +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 717698FC12; Wed, 26 Jan 2011 10:36:43 +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 p0QAahja074114; Wed, 26 Jan 2011 10:36:43 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0QAahJR074111; Wed, 26 Jan 2011 10:36:43 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201101261036.p0QAahJR074111@svn.freebsd.org> From: Adrian Chadd Date: Wed, 26 Jan 2011 10:36:43 +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: r217881 - head/sys/dev/ath/ath_hal/ar5416 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, 26 Jan 2011 10:36:43 -0000 Author: adrian Date: Wed Jan 26 10:36:43 2011 New Revision: 217881 URL: http://svn.freebsd.org/changeset/base/217881 Log: Add an AR5416 workaround - force a different bias based on 2.4ghz channel frequency. Obtained from: Linux ath9k Modified: head/sys/dev/ath/ath_hal/ar5416/ar2133.c head/sys/dev/ath/ath_hal/ar5416/ar5416reg.h Modified: head/sys/dev/ath/ath_hal/ar5416/ar2133.c ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar2133.c Wed Jan 26 10:34:21 2011 (r217880) +++ head/sys/dev/ath/ath_hal/ar5416/ar2133.c Wed Jan 26 10:36:43 2011 (r217881) @@ -58,6 +58,65 @@ ar2133WriteRegs(struct ath_hal *ah, u_in } /* + * Fix on 2.4 GHz band for orientation sensitivity issue by increasing + * rf_pwd_icsyndiv. + * + * Theoretical Rules: + * if 2 GHz band + * if forceBiasAuto + * if synth_freq < 2412 + * bias = 0 + * else if 2412 <= synth_freq <= 2422 + * bias = 1 + * else // synth_freq > 2422 + * bias = 2 + * else if forceBias > 0 + * bias = forceBias & 7 + * else + * no change, use value from ini file + * else + * no change, invalid band + * + * 1st Mod: + * 2422 also uses value of 2 + * + * + * 2nd Mod: + * Less than 2412 uses value of 0, 2412 and above uses value of 2 + */ +static void +ar2133ForceBias(struct ath_hal *ah, uint16_t synth_freq) +{ + uint32_t tmp_reg; + int reg_writes = 0; + uint32_t new_bias = 0; + struct ar2133State *priv = AR2133(ah); + + /* XXX this is a bit of a silly check for 2.4ghz channels -adrian */ + if (synth_freq >= 3000) + return; + + if (synth_freq < 2412) + new_bias = 0; + else if (synth_freq < 2422) + new_bias = 1; + else + new_bias = 2; + + /* pre-reverse this field */ + tmp_reg = ath_hal_reverseBits(new_bias, 3); + + HALDEBUG(ah, HAL_DEBUG_ANY, "%s: Force rf_pwd_icsyndiv to %1d on %4d\n", + __func__, new_bias, synth_freq); + + /* swizzle rf_pwd_icsyndiv */ + ar5416ModifyRfBuffer(priv->Bank6Data, tmp_reg, 3, 181, 3); + + /* write Bank 6 with new params */ + ath_hal_ini_bank_write(ah, &AH5416(ah)->ah_ini_bank6, priv->Bank6Data, reg_writes); +} + +/* * Take the MHz channel value and set the Channel value * * ASSUMES: Writes enabled to analog bus @@ -125,6 +184,10 @@ ar2133SetChannel(struct ath_hal *ah, con return AH_FALSE; } + /* Workaround for hw bug - AR5416 specific */ + if (AR_SREV_OWL(ah)) + ar2133ForceBias(ah, freq); + reg32 = (channelSel << 8) | (aModeRefSel << 2) | (bModeSynth << 1) | (1 << 5) | 0x1; Modified: head/sys/dev/ath/ath_hal/ar5416/ar5416reg.h ============================================================================== --- head/sys/dev/ath/ath_hal/ar5416/ar5416reg.h Wed Jan 26 10:34:21 2011 (r217880) +++ head/sys/dev/ath/ath_hal/ar5416/ar5416reg.h Wed Jan 26 10:36:43 2011 (r217881) @@ -588,6 +588,10 @@ #define AR_XSREV_REVISION_KITE_11 1 /* Kite 1.1 */ #define AR_XSREV_REVISION_KITE_12 2 /* Kite 1.2 */ +#define AR_SREV_OWL(_ah) \ + ((AH_PRIVATE((_ah))->ah_macVersion == AR_XSREV_VERSION_OWL_PCI) || \ + (AH_PRIVATE((_ah))->ah_macVersion == AR_XSREV_VERSION_OWL_PCIE)) + #define AR_SREV_OWL_20_OR_LATER(_ah) \ (AH_PRIVATE((_ah))->ah_macVersion >= AR_XSREV_VERSION_SOWL || \ AH_PRIVATE((_ah))->ah_macRev >= AR_XSREV_REVISION_OWL_20)