svn commit: r291469 - in head/sys: contrib/dev/ath/ath_hal/ar9300 dev/ath/ath_hal

Adrian Chadd adrian at FreeBSD.org
Mon Nov 30 06:27:01 UTC 2015


Author: adrian
Date: Mon Nov 30 06:26:59 2015
New Revision: 291469
URL: https://svnweb.freebsd.org/changeset/base/291469

Log:
  fix ht/40 configuration for ar9331 (hornet).
  
  The synth programming here requires the real centre frequency,
  which for HT20 channels is the normal channel, but HT40 is
  /not/ the primary channel.  Everything else was using 'freq',
  which is the correct centre frequency, but the hornet config
  was using 'ichan' to do the lookup which was also the primary
  channel.
  
  So, modify the HAL call that does the mapping to take a frequency
  in MHz and return the channel number.
  
  Tested:
  
  * Carambola 2, AR9331, tested both HT/20 and HT/40 operation.

Modified:
  head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_radio.c
  head/sys/dev/ath/ath_hal/ah.c
  head/sys/dev/ath/ath_hal/ah_internal.h

Modified: head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_radio.c
==============================================================================
--- head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_radio.c	Mon Nov 30 06:02:35 2015	(r291468)
+++ head/sys/contrib/dev/ath/ath_hal/ar9300/ar9300_radio.c	Mon Nov 30 06:26:59 2015	(r291469)
@@ -99,7 +99,6 @@ ar9300_set_channel(struct ath_hal *ah, s
     ar9300_get_channel_centers(ah, chan, &centers);
     freq = centers.synth_center;
 
-
     if (freq < 4800) {     /* 2 GHz, fractional mode */
         b_mode = 1; /* 2 GHz */
 
@@ -116,7 +115,19 @@ ar9300_set_channel(struct ath_hal *ah, s
 #endif
             uint32_t i;
 
-            i = ath_hal_mhz2ieee_2ghz(ah, ichan);
+            /*
+             * Pay close attention to this bit!
+             *
+             * We need to map the actual desired synth frequency to
+             * one of the channel select array entries.
+             *
+             * For HT20, it'll align with the channel we select.
+             *
+             * For HT40 though it won't - the centre frequency
+             * will not be the frequency of chan->ic_freq or ichan->freq;
+             * it needs to be whatever frequency maps to 'freq'.
+             */
+            i = ath_hal_mhz2ieee_2ghz(ah, freq);
             HALASSERT(i > 0 && i <= 14);
             if (clk_25mhz) {
                 channel_sel = ar9300_chansel_xtal_25M[i - 1];

Modified: head/sys/dev/ath/ath_hal/ah.c
==============================================================================
--- head/sys/dev/ath/ath_hal/ah.c	Mon Nov 30 06:02:35 2015	(r291468)
+++ head/sys/dev/ath/ath_hal/ah.c	Mon Nov 30 06:26:59 2015	(r291469)
@@ -1431,15 +1431,15 @@ ath_hal_EepromDataRead(struct ath_hal *a
  * This is the unmapped frequency which is programmed into the hardware.
  */
 int
-ath_hal_mhz2ieee_2ghz(struct ath_hal *ah, HAL_CHANNEL_INTERNAL *ichan)
+ath_hal_mhz2ieee_2ghz(struct ath_hal *ah, int freq)
 {
 
-	if (ichan->channel == 2484)
+	if (freq == 2484)
 		return 14;
-	if (ichan->channel < 2484)
-		return ((int) ichan->channel - 2407) / 5;
+	if (freq < 2484)
+		return ((int) freq - 2407) / 5;
 	else
-		return 15 + ((ichan->channel - 2512) / 20);
+		return 15 + ((freq - 2512) / 20);
 }
 
 /*

Modified: head/sys/dev/ath/ath_hal/ah_internal.h
==============================================================================
--- head/sys/dev/ath/ath_hal/ah_internal.h	Mon Nov 30 06:02:35 2015	(r291468)
+++ head/sys/dev/ath/ath_hal/ah_internal.h	Mon Nov 30 06:26:59 2015	(r291469)
@@ -1031,7 +1031,7 @@ ath_hal_getantennaallowed(struct ath_hal
 /*
  * Map the given 2GHz channel to an IEEE number.
  */
-extern	int ath_hal_mhz2ieee_2ghz(struct ath_hal *, HAL_CHANNEL_INTERNAL *);
+extern	int ath_hal_mhz2ieee_2ghz(struct ath_hal *, int freq);
 
 /*
  * Clear the channel survey data.


More information about the svn-src-all mailing list