Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Jan 2011 10:36:43 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r217881 - head/sys/dev/ath/ath_hal/ar5416
Message-ID:  <201101261036.p0QAahJR074111@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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
+ *    <approved>
+ *
+ *  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)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101261036.p0QAahJR074111>