From owner-svn-src-all@freebsd.org Mon Nov 30 06:27:01 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id F344EA3197D; Mon, 30 Nov 2015 06:27:00 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C45A31881; Mon, 30 Nov 2015 06:27:00 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tAU6Qxrk096730; Mon, 30 Nov 2015 06:26:59 GMT (envelope-from adrian@FreeBSD.org) Received: (from adrian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tAU6Qx9n096727; Mon, 30 Nov 2015 06:26:59 GMT (envelope-from adrian@FreeBSD.org) Message-Id: <201511300626.tAU6Qx9n096727@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: adrian set sender to adrian@FreeBSD.org using -f From: Adrian Chadd Date: Mon, 30 Nov 2015 06:26:59 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291469 - in head/sys: contrib/dev/ath/ath_hal/ar9300 dev/ath/ath_hal X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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: Mon, 30 Nov 2015 06:27:01 -0000 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, ¢ers); 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.